/// <summary> /// 将界面上的值写入EncryptionPolicy对象 /// </summary> /// <returns></returns> public UMPEncryptionPolicy GetPolicyInTypeC(UMPEncryptionPolicy policy, PolicyUpdateEntry policyUpdate) { ComboBoxItem item = ComboOccurs.SelectedItem as ComboBoxItem; policy.PolicyOccursFrequency = item.Tag.ToString(); if (item.Tag.ToString() == "U") { //如果是用户自定义天数 policy.BeginDayofCycle = TextExecutionInterval.Text; } else if (item.Tag.ToString() == "W") { //如果是周 ComboBoxItem firstDayItem = ComboFirstDayOfWeek.SelectedItem as ComboBoxItem; policy.BeginDayofCycle = firstDayItem.Tag.ToString(); } if (IPageParent.iAddOrModify == (int)OperationType.Modify) { if (chkUpdateKeyImmediately.IsChecked == true) { IPageParent.mainPage.GetAppServerCurrentTime(); policyUpdate.EffectTime = S2400App.GolbalCurrentEncryptionDBTime.ToString("yyyy-MM-dd HH:mm:ss"); policyUpdate.IsUpdatePwd = true; policy.IsImmediately = 1; if (chkUpdateCycle.IsChecked == true) { policy.ResetCycle = "1"; policyUpdate.IsResetCycle = true; } } } return(policy); }
void BasicOpt_Click(object sender, RoutedEventArgs e) { var btn = e.Source as Button; if (btn != null) { var optItem = btn.DataContext as OperationInfo; if (optItem == null) { return; } UC_AddPolicy uc_AddPolicy = null; switch (optItem.ID) { case S2400Const.OPT_EncryptionPolicyAdd: uc_AddPolicy = new UC_AddPolicy(); uc_AddPolicy.CurrentApp = CurrentApp; uc_AddPolicy.ChangeLanguage(); uc_AddPolicy.iAddOrModify = (int)OperationType.Add; uc_AddPolicy.mainPage = this; PopupPanel.Content = uc_AddPolicy; PopupPanel.Title = CurrentApp.GetLanguageInfo("2402T001", "Add encryption policy"); PopupPanel.IsOpen = true; break; case S2400Const.OPT_EncryptionPolicyModify: uc_AddPolicy = new UC_AddPolicy(); uc_AddPolicy.CurrentApp = CurrentApp; //根据listview的选中项 获得策略实体类 UMPEncryptionPolicy policy = null; if (lvEncryptionPolicyObject.SelectedItem == null) { return; } PolicyInfoInList policyInList = lvEncryptionPolicyObject.SelectedItem as PolicyInfoInList; bool bo = GetSelectedPolicyInfo(ref policy); if (!bo) { return; } uc_AddPolicy.policyModifying = policy; uc_AddPolicy.ChangeLanguage(); uc_AddPolicy.iAddOrModify = (int)OperationType.Modify; uc_AddPolicy.mainPage = this; uc_AddPolicy.PolicyModifyingInList = policyInList; PopupPanel.Content = uc_AddPolicy; PopupPanel.Title = CurrentApp.GetLanguageInfo("2402T002", "Update encryption policy " + policy.PolicyName); PopupPanel.IsOpen = true; break; case S2400Const.Opt_EncryptionPolicyDisable: EnableDisablePolicy("2"); break; case S2400Const.OPT_EncryptionPolicyEnable: EnableDisablePolicy("1"); break; } } }
/// <summary> /// 将界面上的值写入EncryptionPolicy对象 /// </summary> /// <returns></returns> public UMPEncryptionPolicy GetPolicyInTypeU(UMPEncryptionPolicy policy, PolicyUpdateEntry policyUpdate) { string strPwd = string.Empty; if (IPageParent.iAddOrModify == (int)OperationType.Add) { if (chkShowPasswordI.IsChecked == true) { strPwd = TextPasswordShow.Text; } else { strPwd = TextPasswordHidden.Password; } } else if (IPageParent.iAddOrModify == (int)OperationType.Modify) { if (chkChangeKey.IsChecked == true) { if (chkShowPasswordC.IsChecked == true) { strPwd = TextChangePwdShow.Text; } else { strPwd = TextChangePwdHidden.Password; } policyUpdate.IsUpdatePwd = true; } else { strPwd = S2400EncryptOperation.DecryptWithM002(IPageParent.policyModifying.TypeuEncryptKey); } if (radEnableDate.IsChecked == true) { policy.TypeUStartTime = DateTime.Parse(StartDateTime.Text).ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss"); policyUpdate.EffectTime = policy.TypeUStartTime; } else if (radEnableImmediately.IsChecked == true) { policy.IsImmediately = 1; IPageParent.mainPage.GetAppServerCurrentTime(); policyUpdate.EffectTime = S2400App.GolbalCurrentEncryptionDBTime.ToString("yy-MM-dd HH:mm:ss"); } } policy.TypeuEncryptKey = S2400EncryptOperation.EncryptWithM002(strPwd); return(policy); }
/// <summary> /// 获得listview选中项的策略信息 /// </summary> /// <returns></returns> private bool GetSelectedPolicyInfo(ref UMPEncryptionPolicy policy) { PolicyInfoInList policyInList = lvEncryptionPolicyObject.SelectedItem as PolicyInfoInList; Service24021Client client = null; try { WebRequest webRequest = new WebRequest(); webRequest.Code = (int)S2400RequestCode.GetPolicyByID; webRequest.Session = CurrentApp.Session; webRequest.ListData.Add(policyInList.PolicyID); client = new Service24021Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service24021")); WebReturn webReturn = client.DoOperation(webRequest); CurrentApp.MonitorHelper.AddWebReturn(webReturn); if (!webReturn.Result) { ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, CurrentApp.GetLanguageInfo(webReturn.Code.ToString(), webReturn.Message))); return(false); } OperationReturn optReturn = XMLHelper.DeserializeObject <UMPEncryptionPolicy>(webReturn.Data); if (!optReturn.Result) { ShowException(string.Format("WSFail.\t{0}\t{1}", optReturn.Code, CurrentApp.GetLanguageInfo(optReturn.Code.ToString(), optReturn.Message))); return(false); } policy = optReturn.Data as UMPEncryptionPolicy; return(true); } catch (Exception ex) { ShowException(ex.Message); } finally { if (client != null) { if (client.State == System.ServiceModel.CommunicationState.Opened) { client.Close(); } } } return(true); }