示例#1
0
        ///// <summary>
        ///// 初始化用户操作习惯
        ///// </summary>
        //public static void InitUserPractice(string paramUserID)
        //{
        //    //记录日志
        //    LogHelper.WriteBussLog(BussID, LoginInfoDAX.UserName, "CacheDAX.InitializeUserPractice", "【Start】", string.Empty, null);

        //    string tableName = LocalConfigFileConst.TableName.SM_ListStyle;
        //    string localXmlFilePath = LocalConfigFileConst.ConfigFilePath.SM_ListStyle.Replace(SysConst.PH_USERID, paramUserID);
        //    var serverTableTimeStamp = SystemConfigInfo.DBTimeStampList.Find(table => table.TableName.Equals(tableName));
        //    var localTableTimeStamp = LocalConfigInfo.DBTimeStampList.Find(table => table.TableName.Equals(tableName));

        //    var resultList = new ObservableCollection<MDLSM_ListStyle>();

        //    if (!File.Exists(localXmlFilePath)
        //        || localTableTimeStamp == null
        //        || serverTableTimeStamp == null
        //        || localTableTimeStamp.LastUpdatedTime < serverTableTimeStamp.LastUpdatedTime
        //        )
        //    {
        //        //创建数据CRUD对象
        //        CRUD crud = new CRUD(DBCONFIG.Coeus);
        //        MDLSM_ListStyle argsCondition = new MDLSM_ListStyle
        //        {
        //            LS_UserID = LoginInfoDAX.UserID,
        //            LS_IsValid = true
        //        };
        //        //查询系统所有枚举数据
        //        crud.QueryForList(argsCondition, resultList);

        //        XmlFileUtility.SerializeToXmlFile(localXmlFilePath, typeof(ObservableCollection<MDLSM_ListStyle>), resultList);
        //        if (localTableTimeStamp == null)
        //        {
        //            if (serverTableTimeStamp != null)
        //            {
        //                localTableTimeStamp = new DBTableTimeStampUIModel { TableName = tableName, LastUpdatedTime = serverTableTimeStamp.LastUpdatedTime };
        //                LocalConfigInfo.DBTimeStampList.Add(localTableTimeStamp);
        //            }
        //        }
        //        else
        //        {
        //            if (serverTableTimeStamp != null)
        //            {
        //                localTableTimeStamp.LastUpdatedTime = serverTableTimeStamp.LastUpdatedTime;
        //            }
        //        }
        //    }
        //    else if (File.Exists(localXmlFilePath))
        //    {
        //        resultList = XmlFileUtility.DeserializeXmlFileToObj(localXmlFilePath, typeof(ObservableCollection<MDLSM_ListStyle>)) as ObservableCollection<MDLSM_ListStyle>;
        //    }

        //    //将查询结果数据保存到缓存中
        //    if (resultList != null)
        //    {
        //        foreach (MDLSM_ListStyle listStyle in resultList)
        //        {
        //            StringBuilder strKey = new StringBuilder();
        //            if (!string.IsNullOrEmpty(listStyle.LS_ClassFullName))
        //            {
        //                strKey.Append(CacheType.ET1001 + SysConst.ULINE + listStyle.LS_ClassFullName);
        //            }
        //            if (!string.IsNullOrEmpty(listStyle.LS_ListControlName))
        //            {
        //                strKey.Append(SysConst.ULINE + listStyle.LS_ListControlName);
        //            }
        //            Add(strKey.ToString(), listStyle.LS_State, true);
        //        }
        //    }
        //    //记录日志
        //    LogHelper.WriteBussLog(BussID, LoginInfoDAX.UserName, "CacheDAX.InitializeUserPractice", "【End】", string.Empty, null);
        //}

        /// <summary>
        /// 初始化汽车品牌车系信息
        /// </summary>
        public static void InitVehicleBrandInspireList()
        {
            //记录日志
            LogHelper.WriteBussLog(BussID, LoginInfoDAX.UserName, "CacheDAX.InitializeCarBrandInfo", "【Start】", string.Empty, null);

            string tableName            = LocalConfigFileConst.TableName.SCON_VehicleBrandInspireSumma;
            string localXmlFilePath     = LocalConfigFileConst.ConfigFilePath.OtherTablePath.Replace(SysConst.PH_TABLENAME, tableName);
            var    serverTableTimeStamp = SystemConfigInfo.DBTimeStampList.Find(table => table.TableName.Equals(tableName));
            var    localTableTimeStamp  = LocalConfigInfo.DBTimeStampList.Find(table => table.TableName.Equals(tableName));

            var resultList = new ObservableCollection <MDLBS_VehicleBrandInspireSumma>();

            if (!File.Exists(localXmlFilePath) ||
                localTableTimeStamp == null ||
                serverTableTimeStamp == null ||
                localTableTimeStamp.LastUpdatedTime < serverTableTimeStamp.LastUpdatedTime
                )
            {
                //创建数据CRUD对象
                CRUD crud           = new CRUD(DBCONFIG.Coeus);
                var  tempResultList = new List <MDLBS_VehicleBrandInspireSumma>();
                var  argsCondition  = new MDLBS_VehicleBrandInspireSumma {
                    VBIS_IsValid = true
                };
                crud.QueryForList(argsCondition, tempResultList);

                foreach (var sortedItem in tempResultList.OrderBy(x => x.VBIS_Brand).ThenBy(x => x.VBIS_Inspire).ToList())
                {
                    var newItem = new MDLBS_VehicleBrandInspireSumma();
                    _baseDax.CopyModel(sortedItem, newItem);
                    resultList.Add(newItem);
                }

                XmlFileUtility.SerializeToXmlFile(localXmlFilePath, typeof(ObservableCollection <MDLBS_VehicleBrandInspireSumma>), resultList);
                if (localTableTimeStamp == null)
                {
                    if (serverTableTimeStamp != null)
                    {
                        localTableTimeStamp = new DBTableTimeStampUIModel {
                            TableName = tableName, LastUpdatedTime = serverTableTimeStamp.LastUpdatedTime
                        };
                        LocalConfigInfo.DBTimeStampList.Add(localTableTimeStamp);
                    }
                }
                else
                {
                    if (serverTableTimeStamp != null)
                    {
                        localTableTimeStamp.LastUpdatedTime = serverTableTimeStamp.LastUpdatedTime;
                    }
                }
            }
            else if (File.Exists(localXmlFilePath))
            {
                resultList =
                    XmlFileUtility.DeserializeXmlFileToObj(localXmlFilePath,
                                                           typeof(ObservableCollection <MDLBS_VehicleBrandInspireSumma>)) as
                    ObservableCollection <MDLBS_VehicleBrandInspireSumma>;
            }

            if (resultList != null)
            {
                var brandList = resultList.GroupBy(p => new { p.VBIS_Brand, p.VBIS_BrandSpellCode })
                                .Select(g => g.First()).OrderBy(x => x.VBIS_Brand).ToList();

                var brandObsCol = new ObservableCollection <MDLBS_VehicleBrandInspireSumma>();
                foreach (MDLBS_VehicleBrandInspireSumma brandInspire in brandList)
                {
                    MDLBS_VehicleBrandInspireSumma newBrand = new MDLBS_VehicleBrandInspireSumma
                    {
                        VBIS_Brand          = brandInspire.VBIS_Brand,
                        VBIS_BrandSpellCode = brandInspire.VBIS_BrandSpellCode
                    };
                    brandObsCol.Add(newBrand);
                }
                HttpRuntime.Cache.Insert(ConfigDataKey.VehicleBrand, brandObsCol);

                var inspireList = resultList.GroupBy(p => new { p.VBIS_Brand, p.VBIS_Inspire, p.VBIS_InspireSpellCode })
                                  .Select(g => g.First()).OrderBy(x => x.VBIS_Brand).ThenBy(x => x.VBIS_Inspire).ToList();
                var inspireObsCol = new ObservableCollection <MDLBS_VehicleBrandInspireSumma>();
                foreach (MDLBS_VehicleBrandInspireSumma brandInspire in inspireList)
                {
                    MDLBS_VehicleBrandInspireSumma newInspire = new MDLBS_VehicleBrandInspireSumma
                    {
                        VBIS_ID               = brandInspire.VBIS_ID,
                        VBIS_Brand            = brandInspire.VBIS_Brand,
                        VBIS_Inspire          = brandInspire.VBIS_Inspire,
                        VBIS_InspireSpellCode = brandInspire.VBIS_InspireSpellCode,
                        VBIS_Model            = brandInspire.VBIS_Model
                    };
                    inspireObsCol.Add(newInspire);
                }
                HttpRuntime.Cache.Insert(ConfigDataKey.VehicleBrandInspire, inspireObsCol);
            }

            //记录日志
            LogHelper.WriteBussLog(BussID, LoginInfoDAX.UserName, "CacheDAX.InitializeCarBrandInfo", "【End】", string.Empty, null);
        }
示例#2
0
        /// <summary>
        /// 初始化系统码表
        /// </summary>
        public static void InitializeCode()
        {
            //记录日志
            LogHelper.WriteBussLogStart(BussID, LoginInfoDAX.UserName, MethodBase.GetCurrentMethod().ToString(), String.Empty, String.Empty, null);

            //定义码表对象列表
            ObservableCollection <MDLSM_CodeTable> resultList = new ObservableCollection <MDLSM_CodeTable>();

            string tableName        = LocalConfigFileConst.TableName.SM_CodeTable;
            string localXmlFilePath = LocalConfigFileConst.ConfigFilePath.OtherTablePath.Replace(SysConst.PH_TABLENAME, tableName);

            SystemConfigInfo.DBTimeStampList = new List <DBTableTimeStampUIModel>();
            LocalConfigInfo.DBTimeStampList  = new List <DBTableTimeStampUIModel>();

            DBTableTimeStampUIModel serverTableTimeStamp = SystemConfigInfo.DBTimeStampList.Find(table => table.TableName.Equals(tableName));
            DBTableTimeStampUIModel localTableTimeStamp  = LocalConfigInfo.DBTimeStampList.Find(table => table.TableName.Equals(tableName));

            if (!File.Exists(localXmlFilePath) ||
                localTableTimeStamp == null ||
                serverTableTimeStamp == null ||
                localTableTimeStamp.LastUpdatedTime < serverTableTimeStamp.LastUpdatedTime
                )
            {
                //创建数据CRUD对象
                CRUD crud = new CRUD(DBCONFIG.Coeus);
                //查询系统所有码表数据
                MDLSM_CodeTable argsCondition = new MDLSM_CodeTable {
                    CT_IsValid = true
                };
                crud.QueryForList <MDLSM_CodeTable>(argsCondition, resultList);

                XmlFileUtility.SerializeToXmlFile(localXmlFilePath, typeof(ObservableCollection <MDLSM_CodeTable>), resultList);
                if (localTableTimeStamp == null)
                {
                    if (serverTableTimeStamp != null)
                    {
                        localTableTimeStamp = new DBTableTimeStampUIModel {
                            TableName = tableName, LastUpdatedTime = serverTableTimeStamp.LastUpdatedTime
                        };
                        LocalConfigInfo.DBTimeStampList.Add(localTableTimeStamp);
                    }
                }
                else
                {
                    if (serverTableTimeStamp != null)
                    {
                        localTableTimeStamp.LastUpdatedTime = serverTableTimeStamp.LastUpdatedTime;
                    }
                }
            }
            else if (File.Exists(localXmlFilePath))
            {
                resultList = XmlFileUtility.DeserializeXmlFileToObj(localXmlFilePath, typeof(ObservableCollection <MDLSM_CodeTable>)) as ObservableCollection <MDLSM_CodeTable>;
            }

            //初始化字典
            //_codeTableDic = new Dictionary<CodeType, ObservableCollection<MDLSCON_CodeTable>>();
            _codeTableValueTextDic = new Dictionary <CodeType, ObservableCollection <CodeTableValueTextModel> >();

            //将查询结果数据保存到字典中
            foreach (MDLSM_CodeTable ctb in resultList)
            {
                try
                {
                    //将字符串转换成对应的码表类型
                    CodeType cType = (CodeType)Enum.Parse(typeof(CodeType), ctb.CT_Type, true);
                    ////码表Key存在的场合:追加数据到码表值列表
                    //if (_codeTableDic.ContainsKey(cType))
                    //{
                    //    //获取已有码表值列表
                    //    var valueList = _codeTableDic[cType];
                    //    valueList.Add(ctb);
                    //}
                    ////码表Key不存在的场合:新增码表值
                    //else
                    //{
                    //    //创建码表值对象
                    //    var valueList = new ObservableCollection<MDLSCON_CodeTable> { ctb };
                    //    if (!_codeTableDic.ContainsKey(cType))
                    //    {
                    //        _codeTableDic.Add(cType, valueList);
                    //    }
                    //}

                    if (_codeTableValueTextDic.ContainsKey(cType))
                    {
                        var valueList = _codeTableValueTextDic[cType];
                        valueList.Add(new CodeTableValueTextModel
                        {
                            Value = ctb.CT_Value,
                            Text  = ctb.CT_Desc
                        });
                    }
                    else
                    {
                        var valueList = new ObservableCollection <CodeTableValueTextModel> {
                            new CodeTableValueTextModel {
                                Value = ctb.CT_Value,
                                Text  = ctb.CT_Desc
                            }
                        };
                        _codeTableValueTextDic.Add(cType, valueList);
                    }
                }
                catch (ArgumentException)
                {
                    continue;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            //记录日志
            LogHelper.WriteBussLogEndOK(BussID, LoginInfoDAX.UserName, MethodBase.GetCurrentMethod().ToString(), String.Empty, String.Empty, null);
        }
示例#3
0
        /// <summary>
        /// 初始化系统参数
        /// </summary>
        public static void InitSystemParameter()
        {
            //记录日志
            LogHelper.WriteBussLog(BussID, LoginInfoDAX.UserName, "CacheDAX.InitializeCache", "【Start】", string.Empty, null);

            string tableName            = LocalConfigFileConst.TableName.SM_Parameter;
            string localXmlFilePath     = LocalConfigFileConst.ConfigFilePath.OtherTablePath.Replace(SysConst.PH_TABLENAME, tableName);
            var    serverTableTimeStamp = SystemConfigInfo.DBTimeStampList.Find(table => table.TableName.Equals(tableName));
            var    localTableTimeStamp  = LocalConfigInfo.DBTimeStampList.Find(table => table.TableName.Equals(tableName));

            var resultList = new ObservableCollection <MDLSM_Parameter>();

            if (!File.Exists(localXmlFilePath) ||
                localTableTimeStamp == null ||
                serverTableTimeStamp == null ||
                localTableTimeStamp.LastUpdatedTime < serverTableTimeStamp.LastUpdatedTime
                )
            {
                //创建数据CRUD对象
                CRUD crud = new CRUD(DBCONFIG.Coeus);
                //查询系统所有枚举数据
                MDLSM_Parameter argsCondition = new MDLSM_Parameter {
                    Para_IsValid = true
                };
                crud.QueryForList(argsCondition, resultList);

                XmlFileUtility.SerializeToXmlFile(localXmlFilePath, typeof(ObservableCollection <MDLSM_Parameter>), resultList);
                if (localTableTimeStamp == null)
                {
                    if (serverTableTimeStamp != null)
                    {
                        localTableTimeStamp = new DBTableTimeStampUIModel {
                            TableName = tableName, LastUpdatedTime = serverTableTimeStamp.LastUpdatedTime
                        };
                        LocalConfigInfo.DBTimeStampList.Add(localTableTimeStamp);
                    }
                }
                else
                {
                    if (serverTableTimeStamp != null)
                    {
                        localTableTimeStamp.LastUpdatedTime = serverTableTimeStamp.LastUpdatedTime;
                    }
                }
            }
            else if (File.Exists(localXmlFilePath))
            {
                resultList = XmlFileUtility.DeserializeXmlFileToObj(localXmlFilePath, typeof(ObservableCollection <MDLSM_Parameter>)) as ObservableCollection <MDLSM_Parameter>;
            }

            //将查询结果数据保存到字典中
            if (resultList != null)
            {
                foreach (MDLSM_Parameter para in resultList)
                {
                    StringBuilder strKey = new StringBuilder();
                    if (!string.IsNullOrEmpty(para.Para_Code1))
                    {
                        strKey.Append("S" + para.Para_Code1);
                    }
                    if (!string.IsNullOrEmpty(para.Para_Code2))
                    {
                        strKey.Append("-" + para.Para_Code2);
                    }
                    if (!string.IsNullOrEmpty(para.Para_Code3))
                    {
                        strKey.Append("-" + para.Para_Code3);
                    }
                    if (!string.IsNullOrEmpty(para.Para_Code4))
                    {
                        strKey.Append("-" + para.Para_Code4);
                    }
                    if (!string.IsNullOrEmpty(para.Para_Code5))
                    {
                        strKey.Append("-" + para.Para_Code5);
                    }

                    //枚举Key存在的场合:追加数据到枚举值列表
                    if (HttpRuntime.Cache.Get(strKey.ToString()) != null)
                    {
                        //获取已有枚举值列表
                        var valueList = HttpRuntime.Cache.Get(strKey.ToString()) as List <MDLSM_Parameter>;
                        if (valueList != null)
                        {
                            valueList.Add(para);
                        }
                    }
                    //枚举Key不存在的场合:新增枚举值
                    else
                    {
                        //创建枚举值对象
                        List <MDLSM_Parameter> valueList = new List <MDLSM_Parameter> {
                            para
                        };
                        HttpRuntime.Cache.Insert(strKey.ToString(), valueList);
                    }
                }
            }

            #region 存储配置参数

            #endregion

            //记录日志
            LogHelper.WriteBussLog(BussID, LoginInfoDAX.UserName, "CacheDAX.InitializeCache", "【End】", string.Empty, null);
        }
示例#4
0
        /// <summary>
        /// 同步码表
        /// </summary>
        /// <param name="paramDataRowID"></param>
        /// <param name="paramSyncAction"></param>
        public static void SyncCodeTable(string paramDataRowID, SyncConfigDataAction paramSyncAction)
        {
            //本地列表
            ObservableCollection <MDLSM_CodeTable> localResultList = new ObservableCollection <MDLSM_CodeTable>();

            string tableName        = LocalConfigFileConst.TableName.SM_CodeTable;
            string localXmlFilePath = LocalConfigFileConst.ConfigFilePath.OtherTablePath.Replace(SysConst.PH_TABLENAME, tableName);

            DBTableTimeStampUIModel localTableTimeStamp = LocalConfigInfo.DBTimeStampList.Find(table => table.TableName.Equals(tableName));

            if (File.Exists(localXmlFilePath))
            {
                localResultList = XmlFileUtility.DeserializeXmlFileToObj(localXmlFilePath, typeof(ObservableCollection <MDLSM_CodeTable>)) as ObservableCollection <MDLSM_CodeTable>;
            }

            if (localResultList != null)
            {
                try
                {
                    MDLSM_CodeTable existDataRow = localResultList.FirstOrDefault(localDataRow => localDataRow.CT_ID == paramDataRowID);
                    if (existDataRow != null)
                    {
                        localResultList.Remove(existDataRow);
                        var cType = (CodeType)Enum.Parse(typeof(CodeType), existDataRow.CT_Type, true);
                        if (_codeTableValueTextDic.ContainsKey(cType))
                        {
                            var tempList  = _codeTableValueTextDic[cType];
                            var tempModel = tempList.FirstOrDefault(x => x.Value == existDataRow.CT_Value && x.Text == existDataRow.CT_Desc);
                            if (tempModel != null)
                            {
                                tempList.Remove(tempModel);
                            }
                        }
                    }

                    //创建数据CRUD对象
                    CRUD crud = new CRUD(DBCONFIG.Coeus);
                    //查询新的数据
                    MDLSM_CodeTable newDataRow = new MDLSM_CodeTable();
                    newDataRow = (MDLSM_CodeTable)crud.QueryForObject <MDLSM_CodeTable>(new MDLSM_CodeTable {
                        CT_ID = paramDataRowID, CT_IsValid = true
                    });

                    if (newDataRow != null && paramSyncAction == SyncConfigDataAction.Update)
                    {
                        localResultList.Add(newDataRow);
                        var cType = (CodeType)Enum.Parse(typeof(CodeType), newDataRow.CT_Type, true);
                        if (_codeTableValueTextDic.ContainsKey(cType))
                        {
                            var tempList  = _codeTableValueTextDic[cType];
                            var tempModel = tempList.FirstOrDefault(x => x.Value == newDataRow.CT_Value && x.Text == newDataRow.CT_Desc);
                            if (tempModel == null)
                            {
                                tempList.Add(new CodeTableValueTextModel {
                                    Value = newDataRow.CT_Value, Text = newDataRow.CT_Desc
                                });
                            }
                        }
                        else
                        {
                            _codeTableValueTextDic[cType] = new ObservableCollection <CodeTableValueTextModel>
                            {
                                new CodeTableValueTextModel {
                                    Value = newDataRow.CT_Value, Text = newDataRow.CT_Desc
                                }
                            };
                        }
                        if (localTableTimeStamp != null && newDataRow.CT_UpdatedTime != null)
                        {
                            localTableTimeStamp.LastUpdatedTime = newDataRow.CT_UpdatedTime.Value;
                        }
                    }
                    XmlFileUtility.SerializeToXmlFile(localXmlFilePath, typeof(ObservableCollection <MDLSM_CodeTable>), localResultList);
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }