Beispiel #1
0
        public object GetNodeInfo(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg = string.Empty;
                string id     = dicParas.ContainsKey("id") ? dicParas["id"].ToString() : string.Empty;

                if (string.IsNullOrWhiteSpace(id))
                {
                    errMsg = "节点id参数不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                try
                {
                    Convert.ToInt32(id);
                }
                catch (Exception ex)
                {
                    return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, ex.Message));
                }

                IDict_SystemService dict_SystemService = BLLContainer.Resolve <IDict_SystemService>();
                int iId = Convert.ToInt32(id);
                if (!dict_SystemService.Any(p => p.ID.Equals(iId)))
                {
                    errMsg = "节点id数据库不存在";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                var dict_SystemModel = dict_SystemService.GetModels(p => p.ID.Equals(iId)).FirstOrDefault <Dict_System>();

                return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn, dict_SystemModel));
            }
            catch (Exception e)
            {
                return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message));
            }
        }
Beispiel #2
0
        public object SetSub(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg    = string.Empty;
                string id        = dicParas.ContainsKey("id") ? dicParas["id"].ToString() : string.Empty;
                string dictKey   = dicParas.ContainsKey("dictKey") ? dicParas["dictKey"].ToString() : string.Empty;
                string dictValue = dicParas.ContainsKey("dictValue") ? dicParas["dictValue"].ToString() : string.Empty;
                string comment   = dicParas.ContainsKey("comment") ? dicParas["comment"].ToString() : string.Empty;
                string enabled   = dicParas.ContainsKey("enabled") ? dicParas["enabled"].ToString() : string.Empty;
                string merchId   = dicParas.ContainsKey("merchId") ? dicParas["merchId"].ToString() : string.Empty;
                XCCloudUserTokenModel userTokenKeyModel = (XCCloudUserTokenModel)dicParas[Constant.XCCloudUserTokenModel];
                if (userTokenKeyModel.LogType == (int)RoleType.MerchUser)
                {
                    merchId = userTokenKeyModel.DataModel.MerchID;
                }

                if (string.IsNullOrWhiteSpace(id))
                {
                    errMsg = "选中节点id不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                try
                {
                    Convert.ToInt32(id);
                }
                catch (Exception ex)
                {
                    return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, ex.Message));
                }

                //验证参数信息
                if (!checkParams(dicParas, out errMsg))
                {
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                IDict_SystemService dict_SystemService = BLLContainer.Resolve <IDict_SystemService>();
                int iId = Convert.ToInt32(id);
                if (!dict_SystemService.Any(p => p.ID == iId))
                {
                    errMsg = "选中节点数据库不存在";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                Dict_System dict_System = dict_SystemService.GetModels(p => p.ID == iId).FirstOrDefault <Dict_System>();
                if (dict_System.PID == null || !dict_SystemService.Any(p => p.ID == dict_System.PID))
                {
                    errMsg = "主节点不可修改";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                int pId = Convert.ToInt32(dict_System.PID.Value);
                if (dict_SystemService.Any(p => p.ID != iId && p.PID.Value == pId && p.DictKey.Equals(dictKey, StringComparison.OrdinalIgnoreCase)))
                {
                    errMsg = "同一级别下存在重名的节点";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (!string.IsNullOrWhiteSpace(merchId))
                {
                    if (dict_SystemService.Any(p => p.DictKey.Equals(dictKey, StringComparison.OrdinalIgnoreCase) && (p.MerchID == null || p.MerchID.Trim() == string.Empty)))
                    {
                        errMsg = "不能与公有节点重名";
                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                    }
                }

                dict_System.DictKey   = dictKey;
                dict_System.DictValue = dictValue;
                dict_System.Comment   = comment;
                dict_System.Enabled   = Convert.ToInt32(enabled);
                if (dicParas.ContainsKey("merchId"))
                {
                    dict_System.MerchID = dicParas["merchId"].ToString();
                }

                if (!dict_SystemService.Update(dict_System))
                {
                    errMsg = "修改子节点失败";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                return(ResponseModelFactory.CreateAnonymousSuccessModel(isSignKeyReturn, default(Dict_System)));
            }
            catch (Exception e)
            {
                return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message));
            }
        }
Beispiel #3
0
        public object AddRoot(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg    = string.Empty;
                string dictKey   = dicParas.ContainsKey("dictKey") ? dicParas["dictKey"].ToString() : string.Empty;
                string dictValue = dicParas.ContainsKey("dictValue") ? dicParas["dictValue"].ToString() : string.Empty;
                string comment   = dicParas.ContainsKey("comment") ? dicParas["comment"].ToString() : string.Empty;
                string enabled   = dicParas.ContainsKey("enabled") ? dicParas["enabled"].ToString() : string.Empty;
                string merchId   = dicParas.ContainsKey("merchId") ? dicParas["merchId"].ToString() : string.Empty;
                XCCloudUserTokenModel userTokenKeyModel = (XCCloudUserTokenModel)dicParas[Constant.XCCloudUserTokenModel];
                if (userTokenKeyModel.LogType == (int)RoleType.MerchUser)
                {
                    merchId = userTokenKeyModel.DataModel.MerchID;
                }

                //验证参数信息
                if (!checkParams(dicParas, out errMsg))
                {
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                IDict_SystemService dict_SystemService = BLLContainer.Resolve <IDict_SystemService>();

                if (!string.IsNullOrWhiteSpace(merchId))
                {
                    if (dict_SystemService.Any(p => (!p.PID.HasValue || p.PID.Value == 0) && p.DictKey.Equals(dictKey, StringComparison.OrdinalIgnoreCase) && p.MerchID.Equals(merchId, StringComparison.OrdinalIgnoreCase)))
                    {
                        errMsg = "存在重名的主节点";
                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                    }

                    if (dict_SystemService.Any(p => p.DictKey.Equals(dictKey, StringComparison.OrdinalIgnoreCase) && (p.MerchID == null || p.MerchID.Trim() == string.Empty)))
                    {
                        errMsg = "不能与公有节点重名";
                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                    }
                }
                else
                {
                    if (dict_SystemService.Any(p => (!p.PID.HasValue || p.PID.Value == 0) && p.DictKey.Equals(dictKey, StringComparison.OrdinalIgnoreCase) && (p.MerchID == null || p.MerchID.Trim() == string.Empty)))
                    {
                        errMsg = "存在重名的主节点";
                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                    }
                }

                Dict_System dict_System = new Dict_System();
                dict_System.PID       = 0;
                dict_System.DictKey   = dictKey;
                dict_System.DictValue = dictValue;
                dict_System.Comment   = comment;
                dict_System.Enabled   = Convert.ToInt32(enabled);
                if (dicParas.ContainsKey("merchId"))
                {
                    dict_System.MerchID = dicParas["merchId"].ToString();
                }

                if (!dict_SystemService.Add(dict_System))
                {
                    errMsg = "添加主节点失败";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn));
            }
            catch (Exception e)
            {
                return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message));
            }
        }