Ejemplo n.º 1
0
        private void SaveDomainInfo()
        {
            string OptCode = string.Empty;

            if (IsAdd == 1)
            {
                OptCode = "FO1112001";
            }
            else
            {
                OptCode = "FO1112002";
            }
            try
            {
                WebRequest webRequest = new WebRequest();
                webRequest.Code    = (int)S1112Codes.SaveDomainInfo;
                webRequest.Session = CurrentApp.Session;
                webRequest.ListData.Add(IsAdd.ToString());
                OperationReturn optR = XMLHelper.SeriallizeObject(domainInfo);
                if (!optR.Result)
                {
                    CurrentApp.ShowExceptionMessage(string.Format("Fail.\t{0}\t{1}", optR.Code, optR.Message));
                    return;
                }
                webRequest.ListData.Add(optR.Data as string);
                Service11121Client client = new Service11121Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                                   WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service11121"));
                //Service11121Client client = new Service11121Client();
                WebReturn webReturn = client.DoOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    if (webReturn.Code == 99)
                    {
                        CurrentApp.ShowExceptionMessage(CurrentApp.GetLanguageInfo("", "域名已存在"));
                    }
                    else
                    {
                        CurrentApp.ShowExceptionMessage(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                    }
                    return;
                }
                CurrentApp.GetLanguageInfo("1112T001", "域信息保存成功");
                //写操作日志

                string msg = string.Format("{0}:{1}", CurrentApp.GetLanguageInfo(OptCode, ""), domainInfo.DomainName);
                CurrentApp.WriteOperationLog(OptCode.Substring(2), ConstValue.OPT_RESULT_SUCCESS, msg);
                ParentPage.mListDomainInfo.Clear();
                ParentPage.InitDomainInfo();
            }
            catch (Exception ex)
            {
                if (OptCode != string.Empty)
                {
                    string msg = string.Format("{0}:{1}", CurrentApp.GetLanguageInfo(OptCode, ""), domainInfo.DomainName);
                    CurrentApp.WriteOperationLog(OptCode.Substring(2), ConstValue.OPT_RESULT_FAIL, msg);
                }
                CurrentApp.ShowExceptionMessage(ex.Message);
            }
        }
Ejemplo n.º 2
0
 private void DeleteDomianInfo()
 {
     try
     {
         if (Domaininfo == null)
         {
             return;
         }
         string strInfoMsg = CurrentApp.GetLanguageInfo("1112T008", "确定删除改域信息吗?");
         var    result     = MessageBox.Show(string.Format("{0}\r\n\r\n{1}",
                                                           CurrentApp.GetMessageLanguageInfo("003", "Confirm delete user ?"),
                                                           strInfoMsg), "UMP",
                                             MessageBoxButton.YesNo, MessageBoxImage.Question);
         if (result == MessageBoxResult.Yes)
         {
             WebRequest webRequest = new WebRequest();
             webRequest.Code    = (int)S1112Codes.SaveDomainInfo;
             webRequest.Session = CurrentApp.Session;
             webRequest.ListData.Add("0");
             OperationReturn optR = XMLHelper.SeriallizeObject(Domaininfo);
             if (!optR.Result)
             {
                 CurrentApp.ShowExceptionMessage(string.Format("Fail.\t{0}\t{1}", optR.Code, optR.Message));
                 return;
             }
             webRequest.ListData.Add(optR.Data as string);
             Service11121Client client = new Service11121Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                                WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service11121"));
             WebReturn webReturn = client.DoOperation(webRequest);
             client.Close();
             if (!webReturn.Result)
             {
                 //if (webReturn.Code == 99)
                 //{
                 //    App.ShowExceptionMessage(App.GetLanguageInfo("", "域名已存在"));
                 //}
                 //else
                 //{
                 CurrentApp.ShowExceptionMessage(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                 //}
                 return;
             }
             CurrentApp.ShowInfoMessage(CurrentApp.GetLanguageInfo("1112T002", "域信息删除成功"));
             //写操作日志
             string msg = string.Format("{0}:{1}", CurrentApp.GetLanguageInfo("FO1112003", "delete"), Domaininfo.DomainName);
             CurrentApp.WriteOperationLog(string.Format("1112003"), ConstValue.OPT_RESULT_SUCCESS, msg);
             mListDomainInfo.Clear();
             InitDomainInfo();
         }
     }
     catch (Exception ex)
     {
         string msg = string.Format("{0}:{1}", CurrentApp.GetLanguageInfo("FO1112003", "delete"), Domaininfo.DomainName);
         CurrentApp.WriteOperationLog(string.Format("1112003"), ConstValue.OPT_RESULT_FAIL, msg);
         CurrentApp.ShowExceptionMessage(ex.Message);
     }
 }
Ejemplo n.º 3
0
        public void InitDomainInfo()
        {
            try
            {
                WebRequest webRequest = new WebRequest();
                webRequest.Code    = (int)S1112Codes.GetDomainInfo;
                webRequest.Session = CurrentApp.Session;

                Service11121Client client = new Service11121Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                                   WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service11121"));
                WebReturn webReturn = client.DoOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    CurrentApp.ShowExceptionMessage(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                    return;
                }
                //Dispatcher.Invoke(new Action(() => mListDomainInfo.Clear()));
                List <BasicDomainInfo> ListDomainInfo = new List <BasicDomainInfo>();
                for (int i = 0; i < webReturn.ListData.Count; i++)
                {
                    OperationReturn optReturn = XMLHelper.DeserializeObject <BasicDomainInfo>(webReturn.ListData[i]);
                    if (!optReturn.Result)
                    {
                        CurrentApp.ShowExceptionMessage(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                        return;
                    }
                    BasicDomainInfo domainInfo = optReturn.Data as BasicDomainInfo;
                    if (domainInfo != null)
                    {
                        domainInfo.DomainUserPassWord = domainInfo.DomainUserPassWord.Substring(20);
                        ListDomainInfo.Add(domainInfo);
                    }
                }
                ListDomainInfo = ListDomainInfo.OrderBy(p => p.DomainCode).ToList();
                foreach (BasicDomainInfo di in ListDomainInfo)
                {
                    if (!di.IsDelete)
                    {
                        //DomainInfos dis = new DomainInfos(di);
                        Dispatcher.Invoke(new Action(() => mListDomainInfo.Add(di)));
                    }
                }
                CurrentApp.WriteLog("PageLoad", string.Format("Load Operation"));
            }
            catch (Exception ex)
            {
                CurrentApp.ShowExceptionMessage(ex.Message);
            }
        }
Ejemplo n.º 4
0
        private bool CheckValues()
        {
            string description = this.TexDomainDescription.Text.Trim();
            string domainName  = this.TxtDomainName.Text.Trim();
            string username    = this.TxtUserName.Text.Trim();
            string password    = this.PassBoxUserPassword.Password.Trim();

            //1.域名称不能为空,且不重复,添加的时候在wcf里面判断
            //2.域账号和密码要可以查到域里的账号
            //3.域描述不能为空
            //4.密码不能有@
            //5.不能有大写字母
            if (domainName.Trim() == string.Empty)
            {
                CurrentApp.ShowInfoMessage(CurrentApp.GetLanguageInfo("1112T004", "域名为空"));
                return(false);
            }
            if (description.Trim() == string.Empty)
            {
                CurrentApp.ShowInfoMessage(CurrentApp.GetLanguageInfo("1112T005", "域描述为空"));
                return(false);
            }
            if (password.Trim().Equals("@"))
            {
                CurrentApp.ShowInfoMessage(CurrentApp.GetLanguageInfo("1112T006", "密码不能有@字符"));
                return(false);
            }
            bool IsUsed = false;

            try
            {
                string IStrADPath = string.Format("LDAP://{0}", domainName);

                WebRequest webRequest = new WebRequest();
                webRequest.Code    = (int)S1112Codes.CheckDomainInfo;
                webRequest.Session = CurrentApp.Session;
                webRequest.ListData.Add(IStrADPath);
                webRequest.ListData.Add(username);
                webRequest.ListData.Add(password);

                Service11121Client client = new Service11121Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                                   WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service11121"));
                WebReturn webReturn = client.DoOperation(webRequest);
                client.Close();
                if (webReturn.Result)
                {
                    IsUsed = true;
                }
                else
                {
                    CurrentApp.ShowExceptionMessage(string.Format("{0}:{1}", CurrentApp.GetLanguageInfo("1112T007", "域连接出错"), webReturn.Message));
                }
            }
            catch (Exception ex)
            {
                //域不可用
                CurrentApp.ShowExceptionMessage(CurrentApp.GetLanguageInfo("1112T007", "域连接出错"));
                //S1112App.ShowExceptionMessage(string.Format("Get Users Info From LDAP Fail:{0}", ex.Message));
                CurrentApp.WriteLog(string.Format("Get all AD users fail.\t{0}", ex.Message));
                return(false);
            }
            if (IsAdd == 1)
            {
                domainInfo = new BasicDomainInfo();
            }
            domainInfo.Description        = description;
            domainInfo.DomainName         = domainName;
            domainInfo.DomainUserName     = username;
            domainInfo.DomainUserPassWord = password;
            domainInfo.IsActiveLogin      = this.CheckDomainActiveLogin.IsChecked == true ? true : false;
            //domainInfo.IsActive = true;
            //domainInfo.IsDelete = false;
            return(IsUsed);
        }