public static void SaveDicts(Model.DataUnion.BASE_DICTS[] dicts)
        {
            if (dicts?.Length > 0)
            {
                int seq = 0;
                List<Model.DataUnion.BASE_DICTS> dictList = dicts.ToList();
                dictList.ForEach(d => d.dicts_sequence = seq++);

                Service.LocalDatabaseService.InsertOrReplaceAll(dictList, Model.DataUnion.BASE_DICTS.TableName);
            }
        }
        public static void SaveAcvt(Model.DataUnion.BASE_ACVT[] acvts)
        {
            if (acvts?.Length > 0)
            {
                int seq_acvt = 0;
                List<Model.DataUnion.BASE_ACVT> acvtList = acvts.ToList();
                List<Model.DataUnion.BASE_ACVT_QST> qstList = new List<Model.DataUnion.BASE_ACVT_QST>();
                List<Model.DataUnion.BASE_ACVT_QST_OPT> optList = new List<Model.DataUnion.BASE_ACVT_QST_OPT>();
                acvtList.ForEach(a =>
                {
                    a.seq = seq_acvt++;
                    if (a.qst?.Length > 0)
                    {
                        qstList.AddRange(a.qst);
                        (qstList = a.qst.ToList()).ForEach(q =>
                        {
                            try
                            {
                                q._id = Convert.ToInt32(q.acvtQstId);
                            }
                            catch (Exception ex)
                            {
                                Logger.Log(LogType.Exception, "Convert.ToInt32 Error @SaveAcvt.", ex);
                            }
                            if (q.opt?.Length > 0)
                            {
                                optList.AddRange(q.opt);
                                int optSeq = 0;
                                optList.ForEach(o => o.seq = optSeq++);
                            }
                        });
                    }
                });

                Service.LocalDatabaseService.InsertAll(acvtList, Model.DataUnion.BASE_ACVT.TableName);
                Service.LocalDatabaseService.InsertAll(qstList, Model.DataUnion.BASE_ACVT_QST.TableName);
                //Service.LocalDatabaseService.InsertAllOneByOne(optList, Model.DataUnion.BASE_ACVT_QST_OPT.TableName);
                Service.LocalDatabaseService.InsertAll(optList.DistinctBy(o => o._id), Model.DataUnion.BASE_ACVT_QST_OPT.TableName);//Distinct the same id item.
            }
        }
 public static void SaveProds(Model.DataUnion.BASE_PRODUCT[] prods)
 {
     if (prods?.Length > 0)
     {
         var prodList = prods.ToList();
         int seq_ = 0;
         prodList.ForEach(p =>
         {
             p.seq = seq_++;
         });
         Service.LocalDatabaseService.InsertAll(prodList, Model.DataUnion.BASE_PRODUCT.TableName);
     }
 }
        public static void SaveMsgs(Model.DataUnion.BASE_MSG_TYPE[] msgs)
        {
            if (msgs?.Length > 0)
            {
                int seq = 0;
                var msgTypeList = msgs.ToList();
                List<Model.DataUnion.BASE_MSG> msgList = new List<Model.DataUnion.BASE_MSG>();
                msgTypeList.ForEach(t =>
                {
                    t.msg_sequence = (seq++).ToString();
                    t.msg_amount = 0;
                    if(t.msg?.Length > 0)
                    {
                        msgList.AddRange(t.msg);
                    }
                });

                Service.LocalDatabaseService.InsertAll(msgTypeList,Model.DataUnion.BASE_MSG_TYPE.TableName);
                Service.LocalDatabaseService.InsertAll(msgList, Model.DataUnion.BASE_MSG.TableName);
            }
        }
        public static void SaveFuncs2(Model.DataUnion.BASE_FUNCS[] funcs)
        {
            if (funcs?.Length > 0)
            {
                List<Model.DataUnion.BASE_FUNCS> originfuncsList = funcs.ToList();

                //Real list to insert
                List<Model.DataUnion.BASE_FUNCS> targetFuncsList = new List<Model.DataUnion.BASE_FUNCS>();
                originfuncsList.ForEach(f =>
                {
                    if (!string.IsNullOrEmpty(f.spec))
                    {
                        try
                        {
                            var targetFuncs = Common.Serializer.JsonNetSerializer.Deserialize<Model.DataUnion.BASE_FUNCS>(f.spec);
                            targetFuncs._id = f._id;
                            targetFuncs.parentId = f.parentId;
                            targetFuncs.userId = f.userId;
                            targetFuncs.fc = f.fc;
                            targetFuncs.sort = f.sort;
                            targetFuncs.levelCode = f.levelCode;
                            targetFuncs.subCode = f.subCode;

                            targetFuncsList.Add(targetFuncs);
                        }
                        catch (Exception ex)
                        {
                            Logger.Log(LogType.Exception, "SaveFuncs2-spec error.", ex);
                        }
                    }
                    else
                    {
                        targetFuncsList.Add(f);
                    }
                });
                Service.LocalDatabaseService.InsertAll(targetFuncsList, Model.DataUnion.BASE_FUNCS.TableName);

            }
        }