To find the state of this project's repository at the time of any of these versions, check out the tags.
HistoryDb.cs 1.28 KB

using FLY.OBJComponents.Server;
using FLY.OBJComponents.Server.Model;

using FObjBase;
using SQLite;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FLY.Weight2.Server.Model
{
    /// <summary>
    /// 数据库 写操作
    /// </summary>
    public class HistoryDb
    {
        DbModel dbModel;
        public BulkDbSQLite<Lc_Flow, Db_Flow> FlowBuffer;
        public BufferError ErrorBuffer;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dBModel"></param>
        public void Init(DbModel dBModel)
        {
            this.dbModel = dBModel;
            FlowBuffer = new BulkDbSQLite<Lc_Flow, Db_Flow>();
            FlowBuffer.Init(dBModel.TbFlow,
                (lc) => Lc_AutoMapperProfile.Mapper.Map<Db_Flow>(lc),
                (db) => Lc_AutoMapperProfile.Mapper.Map<Lc_Flow>(db)
                );

            ErrorBuffer = new OBJComponents.Server.BufferError();
            ErrorBuffer.Init(dBModel.TbError);
        }


        public void AddFlow(
            Lc_Flow flow
            )
        {
            FlowBuffer.Add(flow);
        }
        public void AddFlowRange(IEnumerable<Lc_Flow> flows) 
        {
            FlowBuffer.AddRange(flows);
        }

    }
}