예제 #1
0
        //获取参数大项里面的内容 也就是参数小项
        private void LoadParamContent()
        {
            try
            {
                WebRequest webRequest = new WebRequest();
                webRequest.Code    = (int)S3108Codes.GetSelectParamItemsInfos;
                webRequest.Session = CurrentApp.Session;
                //先传入选择的参数大项的ID
                webRequest.ListData.Add(StatisticalParam.StatisticalParamID.ToString());

                Service31081Client client = new Service31081Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                                   WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service31081"));
                WebReturn webReturn = client.DoOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    ShowException(string.Format("Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                    return;
                }

                mListParamItems.Clear();
                List <CombinedParamItemModel> templist = new List <CombinedParamItemModel>();
                mListStatisticalParamItem.Clear();
                for (int i = 0; i < webReturn.ListData.Count; i++)
                {
                    OperationReturn optReturn = XMLHelper.DeserializeObject <StatisticalParamItem>(webReturn.ListData[i]);
                    if (!optReturn.Result)
                    {
                        ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                        return;
                    }
                    StatisticalParamItem item = optReturn.Data as StatisticalParamItem;//注意看这里的类型
                    mListStatisticalParamItem.Add(item);
                    if (item == null)
                    {
                        ShowException(string.Format("Fail. CustomConditionItem is null"));
                        return;
                    }

                    CombinedParamItemModel itemItem = new CombinedParamItemModel(item, CurrentApp);//再看下这里的类型  看下这个是怎么实现的
                    templist.Add(itemItem);
                }
                var itemList = templist.OrderBy(temp => temp.SortID).ToList();
                for (int i = 0; i < itemList.Count; i++)
                {
                    mListParamItems.Add(itemList[i]);
                }
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
        }
 private void LoadAddedCombinedParamItems()
 {
     try
     {
         WebRequest webRequest = new WebRequest();
         webRequest.Code    = (int)S3108Codes.GetAddedCombinedParamItems;
         webRequest.Session = CurrentApp.Session;
         //webRequest.ListData.Add(CurrentApp.Session.UserInfo.UserID.ToString());
         Service31081Client client = new Service31081Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                            WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service31081"));
         WebReturn webReturn = client.DoOperation(webRequest);
         client.Close();
         if (!webReturn.Result)
         {
             ShowException(string.Format("Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
             return;
         }
         if (webReturn.ListData == null)
         {
             ShowException(string.Format("Fail. WebReturn ListData is null"));
             return;
         }
         mListAddedParamsItems.Clear();
         for (int i = 0; i < webReturn.ListData.Count; i++)
         {
             OperationReturn optReturn = XMLHelper.DeserializeObject <StatisticalParamItem>(webReturn.ListData[i]);
             if (!optReturn.Result)
             {
                 ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                 return;
             }
             StatisticalParamItem item = optReturn.Data as StatisticalParamItem;
             if (item == null)
             {
                 ShowException(string.Format("Fail. StatisticalParamItem is null"));
                 return;
             }
             if (mListAllCombinedParamItem.Count(c => c.StatisticalParamItemID == item.StatisticalParamItemID.ToString()) > 0)
             {
                 CombinedParamItemModel itemItem = new CombinedParamItemModel(item, CurrentApp);
                 mListAddedParamsItems.Add(itemItem);
             }
         }
     }
     catch (Exception ex)
     {
         ShowException(ex.Message);
     }
 }
 private void DoDropOperation(CombinedParamItemModel sourceItem, CombinedParamItemModel targetItem)
 {
     try
     {
         if (sourceItem == null ||
             targetItem == null ||
             sourceItem == targetItem)
         {
             return;
         }
         var item = mListAddedParamsItems.FirstOrDefault(c => c.ID == sourceItem.ID);
         //如果源不在用户条件项集合中,将源添加到当前用户tab下的条件项集合中
         if (item == null)
         {
             var tabItem = TabControlCondition.SelectedItem as CombinedParamTabItem;
             if (tabItem != null)
             {
                 int index = tabItem.Items.IndexOf(targetItem);
                 sourceItem.IsAddedItem = true;
                 sourceItem.TabIndex    = tabItem.TabIndex;
                 sourceItem.TabName     = tabItem.TabName;
                 tabItem.Items.Insert(index + 1, sourceItem);
                 tabItem.SetSortID();
                 mListAddedParamsItems.Add(sourceItem);
                 mListAvaliableParamItems.Remove(sourceItem);
             }
         }
         else
         {
             //调整顺序
             var tabItem = TabControlCondition.SelectedItem as CombinedParamTabItem;
             if (tabItem != null)
             {
                 tabItem.Items.Remove(sourceItem);
                 int index = tabItem.Items.IndexOf(targetItem);
                 tabItem.Items.Insert(index + 1, sourceItem);
                 tabItem.SetSortID();
             }
         }
     }
     catch (Exception ex)
     {
         ShowException(ex.Message);
     }
 }
 private void CreateAvaliableParamsItems()//这个是读取可用的条件的,这些条件是在左边的Listview里面的,用户可以将其拖出来放到查询条件里面去使用
 {
     //mListUserConditions这个变量是在LoadAllConditionItems()和LoadDefaultConditionItems()里面塞值进去的
     //mListAvaliableConditions这个是在这里面塞值的,存的是Listview里面的可用查询条件,只是没有在查询窗口显示而已
     mListAvaliableParamItems.Clear();
     for (int i = 0; i < mListAllCombinedParamItem.Count; i++)
     {
         CombinedParamItemModel item = mListAllCombinedParamItem[i];
         if (item.ID == 0 || mListAddedParamsItems.Count(c => c.ID == item.ID) <= 0)
         {
             item.IsAddedItem = false;
             item.Display     = CurrentApp.GetLanguageInfo(string.Format("3108A{0}", item.StatisticalParamItemID), item.Name);
             item.StrFormat   =
                 CurrentApp.GetLanguageInfo(string.Format("310801FORMAT0{0}", ((int)item.Format).ToString("00")),
                                            item.Format.ToString());
             item.StrType       = CurrentApp.GetLanguageInfo(string.Format("310801TYPE0{0}", ((int)item.Type).ToString("00")), item.Type.ToString());
             item.StartDragged += item_StartDragged;
             item.DragOver     += item_DragOver;
             item.Dropped      += item_Dropped;
             mListAvaliableParamItems.Add(item);
         }
     }
 }
        //根据放入的统计参数子项来给其赋初始值[增加值的记录]或者删除那条记录,对T_31_044表进行的操作
        private OperationReturn ModifyValue()
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                //如果没有加入到的,或者已经从可组合参数大项里面移除的,那么就对T_31_044表进行删除操作
                if (mListAvaliableParamItems != null)
                {
                    for (int i = 0; i < mListAvaliableParamItems.Count; i++)
                    {
                        CombinedParamItemModel temp       = mListAvaliableParamItems[i];
                        WebRequest             webRequest = new WebRequest();
                        webRequest.Session = CurrentApp.Session;
                        webRequest.Code    = (int)S3108Codes.ModifyCombinedParamItems;
                        //此子项表示已经移除了参数大项,要对T_31_044里面的相应的记录做删除操作
                        webRequest.ListData.Add("Delete");
                        webRequest.ListData.Add(temp.ID.ToString());
                        webRequest.ListData.Add(temp.StatisticalParamItemID);
                        Service31081Client client = new Service31081Client(
                            WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                            WebHelper.CreateEndpointAddress(
                                CurrentApp.Session.AppServerInfo,
                                "Service31081"));
                        WebReturn webReturn = client.DoOperation(webRequest);
                        client.Close();
                        if (!webReturn.Result)
                        {
                            optReturn.Result  = false;
                            optReturn.Code    = webReturn.Code;
                            optReturn.Message = webReturn.Message;
                            return(optReturn);
                        }
                    }
                }
                //如果已经加入到了可组合的参数大项里面,那么就在T_31_044表里面增加一个记录,并且初始值(C004)为空
                if (mListAddedParamsItems != null)
                {
                    for (int i = 0; i < mListAddedParamsItems.Count; i++)
                    {
                        CombinedParamItemModel temp       = mListAddedParamsItems[i];
                        WebRequest             webRequest = new WebRequest();
                        webRequest.Session = CurrentApp.Session;
                        webRequest.Code    = (int)S3108Codes.ModifyCombinedParamItems;
                        //此子项表示已经添加到参数大项里,要对T_31_044里增加相应的记录
                        webRequest.ListData.Add("Add");
                        webRequest.ListData.Add(temp.ID.ToString());
                        webRequest.ListData.Add(temp.StatisticalParamItemID);
                        Service31081Client client = new Service31081Client(
                            WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                            WebHelper.CreateEndpointAddress(
                                CurrentApp.Session.AppServerInfo,
                                "Service31081"));
                        WebReturn webReturn = client.DoOperation(webRequest);
                        client.Close();
                        if (!webReturn.Result)
                        {
                            optReturn.Result  = false;
                            optReturn.Code    = webReturn.Code;
                            optReturn.Message = webReturn.Message;
                            ShowException(optReturn.Message);
                            return(optReturn);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
                ShowException(ex.Message);
            }
            return(optReturn);
        }
        public OperationReturn SaveConfig()
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                List <StatisticalParamItem> listItems = new List <StatisticalParamItem>();
                for (int i = 0; i < mListTabItems.Count; i++)
                {
                    CombinedParamTabItem tabItem = mListTabItems[i];
                    for (int j = 0; j < tabItem.Items.Count; j++)
                    {
                        CombinedParamItemModel item = tabItem.Items[j];
                        //这个是将我要的东西给到公共类StatisticalParamItem里面  赋好值
                        item.Apply();
                        listItems.Add(item.ParamItem);
                    }
                }
                if (listItems.Count > 0)
                {
                    WebRequest webRequest = new WebRequest();
                    webRequest.Session = CurrentApp.Session;
                    webRequest.Code    = (int)S3108Codes.SaveAddedParamItemsInfos;
                    int count = listItems.Count;
                    //webRequest.ListData.Add(count.ToString());
                    //webRequest.ListData.Add(CurrentApp.Session.UserID.ToString());
                    for (int i = 0; i < count; i++)
                    {
                        optReturn = XMLHelper.SeriallizeObject(listItems[i]);
                        if (!optReturn.Result)
                        {
                            return(optReturn);
                        }
                        webRequest.ListData.Add(optReturn.Data.ToString());
                    }
                    Service31081Client client = new Service31081Client(
                        WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                        WebHelper.CreateEndpointAddress(
                            CurrentApp.Session.AppServerInfo,
                            "Service31081"));
                    WebReturn webReturn = client.DoOperation(webRequest);
                    client.Close();
                    if (!webReturn.Result)
                    {
                        optReturn.Result  = false;
                        optReturn.Code    = webReturn.Code;
                        optReturn.Message = webReturn.Message;
                        return(optReturn);
                    }
                }
                //那些没有放入Tab里的也需修改里面的字段保存(有的做了删除参数的 也是需要将其存入数据库的)
                if (mListAvaliableParamItems.Count > 0)
                {
                    WebRequest webRequest = new WebRequest();
                    webRequest.Session = CurrentApp.Session;
                    webRequest.Code    = (int)S3108Codes.SaveAddedParamItemsInfos;
                    int count = mListAvaliableParamItems.Count;
                    //webRequest.ListData.Add(count.ToString());
                    //webRequest.ListData.Add(CurrentApp.Session.UserID.ToString());
                    for (int i = 0; i < count; i++)
                    {
                        optReturn = XMLHelper.SeriallizeObject(mListAvaliableParamItems[i].ParamItem);
                        if (!optReturn.Result)
                        {
                            return(optReturn);
                        }
                        webRequest.ListData.Add(optReturn.Data.ToString());
                    }
                    Service31081Client client = new Service31081Client(
                        WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                        WebHelper.CreateEndpointAddress(
                            CurrentApp.Session.AppServerInfo,
                            "Service31081"));
                    WebReturn webReturn = client.DoOperation(webRequest);
                    client.Close();
                    if (!webReturn.Result)
                    {
                        optReturn.Result  = false;
                        optReturn.Code    = webReturn.Code;
                        optReturn.Message = webReturn.Message;
                        return(optReturn);
                    }
                }
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }
 private void CreateCombinedParamTabItem()
 {
     try
     {
         //mListTabItems这个是在这个方法里面塞值进去的
         mListTabItems.Clear();
         List <CombinedParamTabItem> listTabItems = new List <CombinedParamTabItem>();
         //先写个方法
         for (int i = 0; i < 2; i++)
         {
             CombinedParamTabItem tabItem = new CombinedParamTabItem();
             if (i == 0)
             {
                 tabItem.TabIndex = 0;
                 tabItem.ID       = 3110000000000000001;
                 tabItem.TabName  = CurrentApp.GetLanguageInfo("FO31080102001", "ServiceAttitude");
             }
             if (i == 1)
             {
                 tabItem.TabIndex = 1;
                 tabItem.ID       = 3110000000000000002;
                 tabItem.TabName  = CurrentApp.GetLanguageInfo("FO31080102002", "ProfessionalLevel");
             }
             listTabItems.Add(tabItem);
         }
         listTabItems = listTabItems.OrderBy(t => t.TabIndex).ToList();
         for (int i = 0; i < listTabItems.Count; i++)
         {
             CombinedParamTabItem tabItem = listTabItems[i];
             tabItem.Items.Clear();
             List <CombinedParamItemModel> listItems =
                 mListAddedParamsItems.Where(c => c.ID == tabItem.ID).OrderBy(c => c.SortID).ToList();
             for (int j = 0; j < listItems.Count; j++)
             {
                 CombinedParamItemModel item = listItems[j];
                 item.IsAddedItem = true;
                 item.Display     = CurrentApp.GetLanguageInfo(string.Format("3108C{0}", item.ID), item.Name);
                 item.StrFormat   =
                     CurrentApp.GetLanguageInfo(string.Format("3108TIP004{0}", ((int)item.Format).ToString("00")),
                                                item.Format.ToString());
                 item.StrType       = CurrentApp.GetLanguageInfo(string.Format("3102TIP003{0}", ((int)item.Type).ToString("00")), item.Type.ToString());
                 item.StartDragged += item_StartDragged;
                 item.DragOver     += item_DragOver;
                 item.Dropped      += item_Dropped;
                 item.SortID        = j;
                 tabItem.Items.Add(item);
             }
             mListTabItems.Add(tabItem);
         }
         if (mListTabItems.Count > 0)
         {
             StatisticalParam temps = ParamsItemsConfigPage.StatisticalParam_;
             if (temps.StatisticalParamID == 3110000000000000001)
             {
                 TabControlCondition.SelectedIndex = 0;
                 var item = mListTabItems.FirstOrDefault(t => t.ID == 3110000000000000001);
                 if (item != null)
                 {
                     item.IsEnable = true;
                 }
             }
             if (temps.StatisticalParamID == 3110000000000000002)
             {
                 TabControlCondition.SelectedIndex = 1;
                 var item = mListTabItems.FirstOrDefault(t => t.ID == 3110000000000000002);
                 if (item != null)
                 {
                     item.IsEnable = true;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         ShowException(ex.Message);
     }
 }