Exemple #1
0
        public Result GetSysParams(string strSysParamsKey)
        {
            Result result = new Result();

            result.StateCodeID = 0;
            result.IsOK        = false;
            try
            {
                PCBEntities pcbEntities = new PCBEntities();

                //collcetDictionary<string, string, string> configTB = new collcetDictionary<string, string, string>();
                var configTBList = from cTB in pcbEntities.PCB_ConfigTB
                                   select new { key = cTB.ConfigCode, value = cTB.ConfigValue, remark = cTB.Remark };
                if (string.IsNullOrEmpty(strSysParamsKey))
                {
                    //configTB.Clear();
                    //foreach (PCB_ConfigTB c in pcbEntities.PCB_ConfigTB)
                    //{
                    //    configTB.Add(c.ConfigCode, c.ConfigValue, c.Remark);
                    //}
                    result.ExtData     = JsonConvert.SerializeObject(configTBList);
                    result.IsOK        = true;
                    result.StateCodeID = 1;
                    result.Description = "查询成功";
                }
                else
                {
                    PCB_ConfigTB configSysTB = pcbEntities.PCB_ConfigTB.FirstOrDefault(p => p.ConfigCode == strSysParamsKey);
                    if (configSysTB == null)
                    {
                        result.IsOK        = false;
                        result.Description = "无对应项";
                        return(result);
                    }
                    //configTB.Clear();
                    //configTB.Add(configSysTB.ConfigCode, configSysTB.ConfigValue, configSysTB.Remark);
                    result.ExtData     = JsonConvert.SerializeObject(configTBList);
                    result.IsOK        = true;
                    result.StateCodeID = 1;
                    result.Description = "查询成功";
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(GetType()).Info(ex.StackTrace);
                result.IsOK        = false;
                result.Description = ex.Message;
            }

            return(result);
        }
Exemple #2
0
        public Result UpdateSysParams(string key, string value, string remark)
        {
            Result result = new Result();

            result.StateCodeID = 0;
            result.IsOK        = false;
            try
            {
                PCBEntities pCBEntities = new PCBEntities();
                //PCB_ConfigTB configSys = ParameterAPI.GetConfig(key);
                PCB_ConfigTB configSys = pCBEntities.PCB_ConfigTB.FirstOrDefault(p => p.ConfigCode == key);
                if (configSys == null)
                {
                    ////增加
                    //PCB_ConfigTB confignew = new PCB_ConfigTB();
                    //confignew.ConfigID = new Guid();
                    //confignew.ConfigCode = key;
                    //confignew.ConfigValue = value;
                    //confignew.Remark = remark;
                    //pCBEntities.AddToPCB_ConfigTB(confignew);

                    //result.IsOK = Convert.ToBoolean(pCBEntities.SaveChanges());
                    //if (result.IsOK)
                    //    result.Description = "增加" + key + "成功";
                    result.IsOK        = false;
                    result.StateCodeID = 1;
                    result.Description = "没有找到需要更新对应项";
                    return(result);
                }
                else
                {
                    //更新
                    configSys.ConfigValue = value;
                    configSys.Remark      = remark;
                    pCBEntities.Refresh(System.Data.Objects.RefreshMode.ClientWins, configSys);
                    result.IsOK = Convert.ToBoolean(pCBEntities.SaveChanges());
                    //result = Common.Common.UpdateConfigTB(key, value, remark);
                    if (result.IsOK)
                    {
                        result.Description = "更新" + key + "成功";
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(GetType()).Info(ex.StackTrace);
                result.IsOK        = false;
                result.Description = ex.Message;
            }
            return(result);
        }
Exemple #3
0
        /// <summary>
        /// 获取配置信息
        /// </summary>
        /// <param name="configCoede"></param>
        /// <returns></returns>
        public static PCB_ConfigTB GetConfig(string configCoede)
        {
            PCB_ConfigTB config = null;

            try
            {
                PCBEntities pCBEntities = new PCBEntities();
                config = pCBEntities.PCB_ConfigTB.FirstOrDefault(p => p.ConfigCode == configCoede);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.InnerException.Message);
            }

            return(config);
        }
Exemple #4
0
        public Result DelSysParams(string key)
        {
            Result result = new Result();

            result.StateCodeID = 0;
            result.IsOK        = false;
            try
            {
                PCBEntities pCBEntities = new PCBEntities();
                //PCB_ConfigTB configSys = ParameterAPI.GetConfig(key);
                PCB_ConfigTB configSys = pCBEntities.PCB_ConfigTB.FirstOrDefault(p => p.ConfigCode == key);
                if (configSys == null)
                {
                    result.IsOK        = false;
                    result.Description = "无对应项";
                    return(result);
                }
                else
                {
                    //del
                    pCBEntities.DeleteObject(configSys);
                    result.IsOK = Convert.ToBoolean(pCBEntities.SaveChanges());
                    //result = Common.Common.UpdateConfigTB(key, value, remark);
                    if (result.IsOK)
                    {
                        result.Description = "删除" + key + "成功";
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(GetType()).Info(ex.StackTrace);
                result.IsOK        = false;
                result.Description = ex.Message;
            }
            return(result);
        }