//添加角色时同时将人一起写入
        void AddRoleUser(long RoleID)
        {
            List <string> lstRoleUsers = new List <string>();

            lstRoleUsers.Add(XmlRoleUser(RoleID, S1102App.LongParse(string.Format(S1102Consts.USER_ADMIN, CurrentApp.Session.RentInfo.Token), 0)));
            if (CurrentApp.Session.UserInfo.UserID != S1102App.LongParse(string.Format(S1102Consts.USER_ADMIN, CurrentApp.Session.RentInfo.Token), 0))
            {
                lstRoleUsers.Add(XmlRoleUser(RoleID, CurrentApp.Session.UserInfo.UserID));
            }


            try
            {
                WebRequest webRequest = new WebRequest();
                webRequest.Session  = CurrentApp.Session;
                webRequest.Code     = (int)S1102Codes.SubmitRoleUser;
                webRequest.ListData = lstRoleUsers;
                webRequest.Data     = RoleID.ToString();
                Service11021Client client = new Service11021Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service11021"));
                //Service11021Client client  = new Service11021Client();
                WebHelper.SetServiceClient(client);
                WebReturn webReturn = client.URPOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    CurrentApp.ShowExceptionMessage(string.Format("Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                }
            }
            catch (Exception ex)
            {
                CurrentApp.ShowExceptionMessage(ex.Message);
            }
        }
        private void ModifyRoleInfo(List <string> RoleList)
        {
            try
            {
                WebRequest webRequest = new WebRequest();
                webRequest.Session = CurrentApp.Session;
                webRequest.Code    = (int)S1102Codes.ModifyRole;
                //px屏蔽
                //OperationReturn optReturn = XMLHelper.SeriallizeObject(RoleInfo);
                //if (!optReturn.Result)
                //{
                //    S1102App.ShowExceptionMessage(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                //    return;
                //}
                //webRequest.Data = optReturn.Data.ToString();
                //px-end

                //px+
                webRequest.ListData = RoleList;
                //end

                //Service11021Client client = new Service11021Client();
                Wcf11021.Service11021Client client = new Service11021Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service11021"));
                WebHelper.SetServiceClient(client);
                WebReturn webReturn = client.URPOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    if (webReturn.Code == Defines.RET_DBACCESS_EXIST)
                    {
                        CurrentApp.ShowInfoMessage(CurrentApp.GetLanguageInfo("1102T00033", "Role Name Already Exists"));
                        //引用对象的加密数据还原
                        //RoleInfo.RoleName = S1102App.DecryptString(RoleInfo.RoleName);
                        //RoleInfo.StrEnableTime = S1102App.DecryptString(RoleInfo.StrEnableTime);
                        //RoleInfo.StrEndTime = S1102App.DecryptString(RoleInfo.StrEndTime);
                        return;
                    }
                    else
                    {
                        CurrentApp.ShowExceptionMessage(string.Format("Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                        return;
                    }
                }
                RoleModel RoleInfo = this.ObjRoleItem as RoleModel;
                RoleInfo.RoleName      = S1102App.DecryptString(RoleList[1]);
                RoleInfo.StrEnableTime = Convert.ToDateTime(S1102App.DecryptString(RoleList[8])).ToLocalTime().ToString();
                RoleInfo.StrEndTime    = S1102App.DecryptString(RoleList[9]);
                mAsyncResult           = true;
            }
            catch (Exception ex)
            {
                CurrentApp.ShowExceptionMessage(ex.Message);
            }
        }
        void AddNewRoleInfo(RoleModel newRoleInfo)
        {
            try
            {
                WebRequest webRequest = new WebRequest();
                webRequest.Session = CurrentApp.Session;
                webRequest.Code    = (int)S1102Codes.AddNewRole;
                OperationReturn optReturn = XMLHelper.SeriallizeObject(newRoleInfo);
                if (!optReturn.Result)
                {
                    #region
                    string msg = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString("FO1102001"), RoleInfo.RoleName);
                    CurrentApp.WriteOperationLog(S1102Consts.OPT_AddRole.ToString(), ConstValue.OPT_RESULT_FAIL, msg);
                    #endregion
                    CurrentApp.ShowExceptionMessage(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                    return;
                }
                webRequest.Data = optReturn.Data.ToString();

                //Service11021Client client = new Service11021Client();
                Wcf11021.Service11021Client client = new Service11021Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service11021"));
                WebHelper.SetServiceClient(client);
                WebReturn webReturn = client.URPOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    if (webReturn.Code == Defines.RET_DBACCESS_EXIST)
                    {
                        CurrentApp.ShowInfoMessage(CurrentApp.GetLanguageInfo("1102T00033", "Role Name Already Exists"));
                        return;
                    }
                    else
                    {
                        CurrentApp.ShowExceptionMessage(string.Format("Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                        return;
                    }
                }
                else
                {
                    long RoleID = Convert.ToInt64(webReturn.Data);
                    AddRoleUser(RoleID);
                }
                mAsyncResult = true;
            }
            catch (Exception ex)
            {
                CurrentApp.ShowExceptionMessage(ex.Message);
            }
        }
Exemple #4
0
        //得到当前用所有角色的权限并集
        public void InitControledOperations(string modelId, string parentId)
        {
            try
            {
                WebRequest webRequest = new WebRequest();
                webRequest.Code    = (int)S1102Codes.GetCurrentOperationList;
                webRequest.Session = Session;
                webRequest.ListData.Add(modelId);
                webRequest.ListData.Add(parentId);

                //Service11021Client client = new Service11021Client();
                Service11021Client client = new Service11021Client(WebHelper.CreateBasicHttpBinding(Session), WebHelper.CreateEndpointAddress(Session.AppServerInfo, "Service11021"));
                WebHelper.SetServiceClient(client);
                WebReturn webReturn = client.URPOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    ShowExceptionMessage(string.Format("Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                    return;
                }
                if (webReturn.ListData.Count > 0)
                {
                    for (int i = 0; i < webReturn.ListData.Count; i++)
                    {
                        OperationReturn optReturn = XMLHelper.DeserializeObject <OperationInfo>(webReturn.ListData[i]);
                        if (!optReturn.Result)
                        {
                            ShowExceptionMessage(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                            return;
                        }
                        OperationInfo optInfo = optReturn.Data as OperationInfo;
                        if (optInfo != null)
                        {
                            optInfo.Display = GetLanguageInfo(string.Format("FO{0}", optInfo.ID), optInfo.ID.ToString());
                            ListOperationInfos.Add(optInfo);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ShowExceptionMessage(ex.Message);
            }
        }