/// <summary>
        ///  删除筛选策略
        /// </summary>
        private void DeleteFilterStrategy()
        {
            AllFilterData item = LvStrategy.SelectedItem as AllFilterData;

            if (item != null)
            {
                string           messageBoxText = App.GetLanguageInfo("2101T00031", "Confirm Remove?");
                MessageBoxButton button         = MessageBoxButton.OKCancel;
                MessageBoxImage  icon           = MessageBoxImage.Warning;
                MessageBoxResult result         = MessageBox.Show(messageBoxText, App.AppName, button, icon);
                switch (result)
                {
                case MessageBoxResult.Cancel:
                    return;
                }

                try
                {
                    WebRequest webRequest = new WebRequest();
                    webRequest.Session = App.Session;
                    webRequest.Code    = (int)S2101Codes.DeleteStrategy;
                    webRequest.ListData.Add(item.StrategyCode.ToString());//筛选策略编码
                    //Service21011Client client = new Service21011Client();
                    Service21011Client client = new Service21011Client(WebHelper.CreateBasicHttpBinding(App.Session), WebHelper.CreateEndpointAddress(App.Session.AppServerInfo, "Service21011"));
                    //WebHelper.SetServiceClient(client);
                    WebReturn webReturn = client.DoOperation(webRequest);
                    client.Close();
                    if (!webReturn.Result)
                    {
                        App.ShowExceptionMessage(string.Format("{0}\t{1}", App.GetLanguageInfo("2101T00027", "Operation Field."), webReturn.Message));
                        return;
                    }
                    else
                    {
                        string strLog = string.Format("{0}{1}{2}", App.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO2101003")), item.StrategyName);
                        App.WriteOperationLog("2101", ConstValue.OPT_RESULT_SUCCESS, strLog);
                        //操作成功 刷新数据
                        InitFilters();
                        App.ShowInfoMessage(App.GetLanguageInfo("2101T00026", "Operation Succeed."));
                    }
                }
                catch (Exception ex)
                { App.ShowExceptionMessage(string.Format("{0}\t{1}", App.GetLanguageInfo("2101T00027", "Operation Field."), ex.Message)); }
            }
            else
            {
                App.ShowInfoMessage(App.GetLanguageInfo("2101T00029", "Please select at least one Strategy."));
            }
        }
 private void InitFilters()
 {
     try
     {
         try
         {
             mListGetAllFilter.Clear();
         }
         catch { }
         WebRequest webRequest = new WebRequest();
         webRequest.Code    = (int)S2101Codes.GetFilterWithCreator;
         webRequest.Session = App.Session;
         //Service21011Client client = new Service21011Client();
         Service21011Client client = new Service21011Client(WebHelper.CreateBasicHttpBinding(App.Session), WebHelper.CreateEndpointAddress(App.Session.AppServerInfo, "Service21011"));
         //WebHelper.SetServiceClient(client);
         WebReturn webReturn = client.DoOperation(webRequest);
         client.Close();
         if (!webReturn.Result)
         {
             App.ShowExceptionMessage(string.Format("{0}\t{1}", App.GetLanguageInfo("2101T00027", "Operation Field."), webReturn.Message));
             return;
         }
         if (webReturn.ListData.Count > 0)
         {
             for (int i = 0; i < webReturn.ListData.Count; i++)
             {
                 OperationReturn optReturn = XMLHelper.DeserializeObject <AllFilterData>(webReturn.ListData[i]);
                 if (!optReturn.Result)
                 {
                     App.ShowExceptionMessage(string.Format("{0}\t{1}", App.GetLanguageInfo("2101T00027", "Operation Field."), webReturn.Message));
                     return;
                 }
                 AllFilterData fdata = optReturn.Data as AllFilterData;
                 if (fdata != null)
                 {
                     fdata.StrategyName = App.DecryptString(fdata.StrategyName);
                     fdata.StrIsValid   = fdata.IsValid == "1" ? App.GetLanguageInfo("2101T00020", "Valid") : App.GetLanguageInfo("2101T00021", "InValid");
                     mListGetAllFilter.Add(fdata);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         App.ShowExceptionMessage(ex.Message);
     }
 }
Ejemplo n.º 3
0
        private void GetAllowConditions()
        {
            mListAllStrategy.Clear();
            string     datatarget = "1";//1:录音记录
            WebRequest webRequest = new WebRequest();

            webRequest.Session = mParent.CurrentApp.Session;
            webRequest.Code    = (int)S2101Codes.GetAllowConditions;
            webRequest.ListData.Add(datatarget);
            //Service21011Client client = new Service21011Client();
            Service21011Client client    = new Service21011Client(WebHelper.CreateBasicHttpBinding(mParent.CurrentApp.Session), WebHelper.CreateEndpointAddress(mParent.CurrentApp.Session.AppServerInfo, "Service21011"));
            WebReturn          webReturn = client.DoOperation(webRequest);

            client.Close();
            if (!webReturn.Result)
            {
                mParent.CurrentApp.ShowExceptionMessage(string.Format("Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                return;
            }
            if (webReturn.ListData.Count <= 0)
            {
                return;
            }
            for (int i = 0; i < webReturn.ListData.Count; i++)
            {
                OperationReturn optReturn = XMLHelper.DeserializeObject <StrategyInfo>(webReturn.ListData[i]);
                if (!optReturn.Result)
                {
                    mParent.CurrentApp.ShowExceptionMessage(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                    continue;
                }
                StrategyInfo strategyinfo = optReturn.Data as StrategyInfo;
                if (strategyinfo == null)
                {
                    return;
                }
                string tempTableName = strategyinfo.StrategyType == 1 ? "T_21_001" : "";
                //strategyinfo.ConditionName = tempTableName + "." + strategyinfo.FieldName;
                strategyinfo.ConditionName = strategyinfo.FieldName;
                strategyinfo.Display       = mParent.CurrentApp.GetLanguageInfo(("2101T0" + strategyinfo.FieldName).ToUpper(), strategyinfo.FieldName.ToUpper());
                mListAllStrategy.Add(strategyinfo);
            }
        }
        /// <summary>
        ///  修改筛选策略
        /// </summary>
        private void UpdateFilterStrategy()
        {
            AllFilterData item = LvStrategy.SelectedItem as AllFilterData;

            if (item != null)
            {
                string           messageBoxText = App.GetLanguageInfo("2101T00030", "Confirm Update?");
                MessageBoxButton button         = MessageBoxButton.OKCancel;
                MessageBoxImage  icon           = MessageBoxImage.Warning;
                MessageBoxResult result         = MessageBox.Show(messageBoxText, App.AppName, button, icon);
                switch (result)
                {
                case MessageBoxResult.Cancel:
                    return;
                }
                try
                {
                    mlstcfoperator.Clear();
                    #region 条件
                    if (cmbsttype.SelectedItem == null || string.IsNullOrWhiteSpace(txtstname.Text) || !IsValidDate(DateStart.Text) || !IsValidDate(DateEnd.Text))
                    {
                        App.ShowInfoMessage(App.GetLanguageInfo("2101T00024", "Illegal Parameter"));
                        return;
                    }
                    foreach (var c in SPAllParameters.Children)
                    {
                        if (c is UC_ConditionTextbox)
                        {
                            UC_ConditionTextbox tb = (UC_ConditionTextbox)c;
                            if (tb.Name.Contains("uc"))
                            {
                                try
                                {
                                    ComboBox cmbcondition = tb.cmbcondition as ComboBox;
                                    ComboBox cmbope       = tb.cmbope as ComboBox;
                                    TextBox  txtval       = tb.txtval as TextBox;
                                    ComboBox cmblog       = tb.cmblog as ComboBox;
                                    if (!string.IsNullOrWhiteSpace(cmbcondition.Text) &&
                                        !string.IsNullOrWhiteSpace(cmbope.Text) &&
                                        !string.IsNullOrWhiteSpace(txtval.Text))
                                    {
                                        StrategyInfo selStrategy = (cmbcondition.SelectionBoxItem as StrategyInfo);
                                        if (selStrategy.ConditionName.ToUpper() == "C004" || selStrategy.ConditionName.ToUpper() == "C005")
                                        {
                                            //时间格式判断
                                            if (!IsDateTimeValue(txtval.Text))
                                            {
                                                App.ShowInfoMessage(App.GetLanguageInfo("2101T00028", "Invalid Format."));//+ "\t" + "2015-01-01 01:01:01"
                                                return;
                                            }
                                        }
                                        int id = int.Parse(tb.Name.Substring(2, tb.Name.Length - 2));
                                        CFilterCondition tempfc = new CFilterCondition();
                                        tempfc.FilterTarget  = 1;
                                        tempfc.ID            = id;
                                        tempfc.ConditionName = (cmbcondition.SelectionBoxItem as StrategyInfo).ConditionName;
                                        tempfc.Operator      = cmbope.Text;
                                        tempfc.isEnum        = txtval.Text.Length > 1024 ? "1" : "0";
                                        tempfc.Value         = txtval.Text;
                                        tempfc.Logical       = cmblog.Text;
                                        mlstcfoperator.Add(tempfc);
                                    }
                                }
                                catch
                                { }
                            }
                        }
                    }
                    if (mlstcfoperator.Count < 1)
                    {
                        App.ShowInfoMessage(App.GetLanguageInfo("2101T00024", "Illegal Parameter"));
                        return;
                    }
                    #endregion
                    AllFilterData allfd = new AllFilterData();
                    allfd.FilterType   = 1;
                    allfd.StrategyCode = item.StrategyCode;
                    allfd.StrategyType = cmbsttype.SelectedValue.ToString();
                    allfd.StrategyName = txtstname.Text;
                    allfd.IsValid      = rdbValid.IsChecked == true ? "1" : "0";
                    allfd.IsDelete     = "0";
                    allfd.Creator      = App.Session.UserID;
                    allfd.CreateTime   = DateTime.Now.ToUniversalTime().ToString("yyyyMMddHHmmss");
                    //allfd.FilterNumber = 0;
                    allfd.DateStart           = Convert.ToDateTime(DateStart.Text).ToUniversalTime().ToString("yyyyMMddHHmmss");
                    allfd.DateEnd             = Convert.ToDateTime(DateEnd.Text).ToUniversalTime().ToString("yyyyMMddHHmmss");
                    allfd.Remarks             = txtdes.Text;
                    allfd.listFilterCondition = mlstcfoperator;

                    WebRequest webRequest = new WebRequest();
                    webRequest.Session = App.Session;
                    webRequest.Code    = (int)S2101Codes.SubmitStrategies;
                    OperationReturn optReturn = XMLHelper.SeriallizeObject(allfd);
                    if (!optReturn.Result)
                    {
                        App.ShowExceptionMessage(string.Format("{0}\t{1}", App.GetLanguageInfo("2101T00027", "Operation Field."), optReturn.Message));
                        return;
                    }
                    webRequest.Data = optReturn.Data.ToString();
                    webRequest.ListData.Add("1");//1 修改策略
                    //Service21011Client client = new Service21011Client();
                    Service21011Client client = new Service21011Client(WebHelper.CreateBasicHttpBinding(App.Session), WebHelper.CreateEndpointAddress(App.Session.AppServerInfo, "Service21011"));
                    //WebHelper.SetServiceClient(client);
                    WebReturn webReturn = client.DoOperation(webRequest);
                    client.Close();
                    if (!webReturn.Result)
                    {
                        if (webReturn.Code == Defines.RET_ALREADY_EXIST)
                        {
                            App.ShowExceptionMessage(App.GetLanguageInfo("2101T00025", "Filter Strategy exists."));
                        }
                        else
                        {
                            App.ShowExceptionMessage(string.Format("{0}\t{1}", App.GetLanguageInfo("2101T00027", "Operation Field."), webReturn.Message));
                        }
                        return;
                    }
                    else
                    {
                        string strLog = string.Format("{0}{1}{2}", App.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO2101002")), item.StrategyName + "->" + allfd.StrategyName);
                        App.WriteOperationLog("2101", ConstValue.OPT_RESULT_SUCCESS, strLog);
                        //操作成功 刷新数据
                        InitFilters();
                        App.ShowInfoMessage(App.GetLanguageInfo("2101T00026", "Operation Succeed."));
                    }
                }
                catch (Exception ex)
                { App.ShowExceptionMessage(string.Format("{0}\t{1}", App.GetLanguageInfo("2101T00027", "Operation Field."), ex.Message)); }
            }
            else
            {
                App.ShowInfoMessage(App.GetLanguageInfo("2101T00029", "Please select at least one Strategy."));
            }
        }