Beispiel #1
0
        private bool CreateContents()
        {
            WebRequest         webRequest;
            Service36041Client client;
            WebReturn          webReturn;

            string[] strContents     = new string[10];
            long[]   strResultId     = new long[10];
            var      lstContentsTree = new List <ContentsTree>();

            if (RbutOneContentsName.IsChecked == true)
            {
                if (!string.IsNullOrWhiteSpace(TxtOneContentsName.Text))
                {
                    strContents[0] = TxtOneContentsName.Text;
                    if (strContents[0] == _mContentsTree.StrNodeName)
                    {
                        ShowInformation(CurrentApp.GetLanguageInfo("3604T00019",
                                                                   "Subfolder name can not be the same as the parent"));
                        return(false);
                    }
                    foreach (var param in _mContentsTree.LstChildInfos)
                    {
                        if (string.Equals(TxtOneContentsName.Text, param.StrNodeName))
                        {
                            ShowInformation(CurrentApp.GetLanguageInfo("3604T00020",
                                                                       "Contents has been created!"));
                            return(false);
                        }
                    }
                }
                else
                {
                    ShowInformation(CurrentApp.GetLanguageInfo("3604T00021", "Please Input ContentsName"));
                    return(false);
                }
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(TxtMoreContentsName.Text))
                {
                    strContents = TxtMoreContentsName.Text.Split(new char[] { '\\' });
                    if (strContents[0] == S3604App.GContentsTree.StrNodeName)
                    {
                        ShowInformation(CurrentApp.GetLanguageInfo("3604T00019",
                                                                   "Subfolder name can not be the same as the parent"));
                        return(false);
                    }
                    for (int i = 0; i < strContents.Length - 1; i++)
                    {
                        if (strContents[i] == strContents[i + 1])
                        {
                            ShowInformation(CurrentApp.GetLanguageInfo("3604T00019",
                                                                       "Subfolder name can not be the same as the parent"));
                            return(false);
                        }
                        if (i + 2 > 10)
                        {
                            ShowInformation(CurrentApp.GetLanguageInfo("3604T00022",
                                                                       "Create cannot exceed 10 more Contents"));
                            return(false);
                        }
                    }
                }
                else
                {
                    ShowInformation(CurrentApp.GetLanguageInfo("3604T00021", "Please Input ContentsName"));
                    return(false);
                }
            }

            for (int i = 0; i < strContents.Length; i++)
            {
                if (!S3604App.GQueryModify)
                {
                    //生成新的查询配置表主键
                    webRequest         = new WebRequest();
                    webRequest.Session = CurrentApp.Session;
                    webRequest.Code    = (int)RequestCode.WSGetSerialID;
                    webRequest.ListData.Add("36");
                    webRequest.ListData.Add("3604");
                    webRequest.ListData.Add(DateTime.Now.ToString("yyyyMMddHHmmss"));
//                     client = new Service36041Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
//                         WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service36041"));
                    client    = new Service36041Client();
                    webReturn = client.UmpTaskOperation(webRequest);
                    client.Close();
                    if (!webReturn.Result)
                    {
                        return(false);
                    }
                    string strNewResultId = webReturn.Data;
                    if (string.IsNullOrEmpty(strNewResultId))
                    {
                        return(false);
                    }
                    strResultId[i] = Convert.ToInt64(strNewResultId);
                }
            }

            for (int i = 0; i < strContents.Length; i++)
            {
                var contentsTree = new ContentsTree();
                if (string.IsNullOrEmpty(strContents[i]))
                {
                    break;
                }
                if (i == 0)
                {
                    _mContentsParam.LongParentNodeId  = _mContentsTree.LongNodeId;
                    _mContentsParam.StrParentNodeName = _mContentsTree.StrNodeName;
                    contentsTree.LongParentNodeId     = _mContentsTree.LongNodeId;
                }
                else
                {
                    _mContentsParam.LongParentNodeId  = strResultId[i - 1];
                    _mContentsParam.StrParentNodeName = strContents[i - 1];
                    contentsTree.LongParentNodeId     = strResultId[i - 1];
                }
                _mContentsParam.StrNodeName = strContents[i];
                _mContentsParam.LongNodeId  = strResultId[i];
                _mContentsParam.StrDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                contentsTree.LongNodeId     = strResultId[i];
                contentsTree.StrNodeName    = strContents[i];

                webRequest         = new WebRequest();
                webRequest.Session = CurrentApp.Session;
                webRequest.Code    = (int)S3604Codes.OptCreateContents;
                OperationReturn optReturn = XMLHelper.SeriallizeObject(_mContentsParam);
                if (!optReturn.Result)
                {
                    ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code,
                                                optReturn.Message));
                    return(false);
                }
                webRequest.ListData.Add(optReturn.Data.ToString());
                //client = new Service36041Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                //    WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service36041"));
                client    = new Service36041Client();
                webReturn = client.UmpTaskOperation(webRequest);
                client.Close();
                string strLog;
                if (!webReturn.Result)
                {
                    #region 写操作日志
                    strLog = string.Format("{0} {1} : {2}", Utils.FormatOptLogString("3604T00003"), Utils.FormatOptLogString("3604T00026"), webReturn.Message);
                    CurrentApp.WriteOperationLog(S3604Consts.OPT_Add.ToString(), ConstValue.OPT_RESULT_FAIL, strLog);
                    #endregion

                    ShowException(string.Format("{0} : {1}",
                                                CurrentApp.GetLanguageInfo("3604T00026", "Insert data failed"), webReturn.Message));
                    return(false);
                }
                #region 写操作日志
                strLog = string.Format("{0}", Utils.FormatOptLogString("3604T00003"));
                CurrentApp.WriteOperationLog(S3604Consts.OPT_Add.ToString(), ConstValue.OPT_RESULT_SUCCESS, strLog);
                #endregion
                CurrentApp.WriteLog(CurrentApp.GetLanguageInfo("3604T00003", "Add Contents!"));
                CurrentApp.WriteLog(CurrentApp.GetLanguageInfo("3604T00027", "Add Success!"));
                lstContentsTree.Add(contentsTree);
            }

            ParentPage.RefreshTree(lstContentsTree);
            return(true);
        }
Beispiel #2
0
        private bool ChangeContents()
        {
            if (!string.IsNullOrWhiteSpace(TxtOneContentsName.Text))
            {
                if (string.Equals(TxtOneContentsName.Text, _mContentsTree.StrParentNodeName))
                {
                    ShowInformation(CurrentApp.GetLanguageInfo("3604T00019",
                                                               "Subfolder name can not be the same as the parent"));
                    return(false);
                }
                if (_mContentsTree.LstChildInfos.Any(param => string.Equals(TxtOneContentsName.Text, param.StrNodeName)))
                {
                    ShowInformation(CurrentApp.GetLanguageInfo("3604T00019",
                                                               "Subfolder name can not be the same as the parent"));
                    return(false);
                }
                if (_mContentsTree.LstNodeInfos.Any(param => string.Equals(TxtOneContentsName.Text, param.StrNodeName)))
                {
                    ShowInformation(CurrentApp.GetLanguageInfo("3604T00023",
                                                               "Subfolder name can not be the same as the parent"));
                    return(false);
                }
            }
            else
            {
                ShowInformation(CurrentApp.GetLanguageInfo("3604T00021", "Please Input ContentsName"));
                return(false);
            }

            _mContentsParam             = new ContentsParam();
            _mContentsParam.LongNodeId  = _mContentsTree.LongNodeId;
            _mContentsParam.StrNodeName = TxtOneContentsName.Text;
            _mContentsTree.StrNodeName  = TxtOneContentsName.Text;

            WebRequest         webRequest;
            Service36041Client client;
            WebReturn          webReturn;

            webRequest         = new WebRequest();
            webRequest.Session = CurrentApp.Session;
            webRequest.Code    = (int)S3604Codes.OptChangeContents;
            OperationReturn optReturn = XMLHelper.SeriallizeObject(_mContentsParam);

            if (!optReturn.Result)
            {
                ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code,
                                            optReturn.Message));
                return(false);
            }
            webRequest.ListData.Add(optReturn.Data.ToString());
//             client = new Service36041Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
//                 WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service36041"));
            client    = new Service36041Client();
            webReturn = client.UmpTaskOperation(webRequest);
            client.Close();
            string strLog;

            if (!webReturn.Result)
            {
                #region 写操作日志
                strLog = string.Format("{0} {1} : {2}", Utils.FormatOptLogString("3604T00010"), Utils.FormatOptLogString("3604T00024"), webReturn.Message);
                CurrentApp.WriteOperationLog(S3604Consts.OPT_Add.ToString(), ConstValue.OPT_RESULT_FAIL, strLog);
                #endregion
                ShowException(string.Format("{0}: {1}",
                                            CurrentApp.GetLanguageInfo("3604T00024", "Insert data failed"), webReturn.Message));
                return(false);
            }
            #region 写操作日志
            strLog = string.Format("{0}", Utils.FormatOptLogString("3604T00010"));
            CurrentApp.WriteOperationLog(S3604Consts.OPT_Add.ToString(), ConstValue.OPT_RESULT_SUCCESS, strLog);
            #endregion
            CurrentApp.WriteLog(CurrentApp.GetLanguageInfo("3604T00010", "Change Contents!"));
            CurrentApp.WriteLog(CurrentApp.GetLanguageInfo("3604T00025", "Change Success!"));
            ParentPage.RefreshTree(_mContentsTree);
            return(true);
        }
Beispiel #3
0
        public void InitContentsTreeInfo(string strSql)
        {
            try
            {
                _mLstContentsTreeParam.Clear();
                WebRequest webRequest = new WebRequest();
                webRequest.Session = CurrentApp.Session;
                webRequest.Code    = (int)S3604Codes.OptGetContents;
                //Service36041Client client = new Service36041Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                //    WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service36041"));
                var             client    = new Service36041Client();
                OperationReturn optReturn = XMLHelper.SeriallizeObject(strSql);
                if (!optReturn.Result)
                {
                    ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                    return;
                }
                webRequest.ListData.Add(optReturn.Data.ToString());
                WebReturn webReturn = client.UmpTaskOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    ShowException(webReturn.Message);
                    return;
                }

                for (int i = 0; i < webReturn.ListData.Count; i++)
                {
                    optReturn = XMLHelper.DeserializeObject <ContentsParam>(webReturn.ListData[i]);
                    if (!optReturn.Result)
                    {
                        ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                        continue;
                    }
                    ContentsParam param = optReturn.Data as ContentsParam;
                    if (param == null)
                    {
                        ShowException("Fail. queryItem is null");
                        return;
                    }

                    ContentsTree tempTree = new ContentsTree();
                    tempTree.LongNodeId        = param.LongNodeId;
                    tempTree.StrNodeName       = param.StrNodeName;
                    tempTree.LongParentNodeId  = param.LongParentNodeId;
                    tempTree.StrParentNodeName = param.StrParentNodeName;
                    tempTree.LongFounderId     = param.LongFounderId;
                    tempTree.StrFounderName    = param.StrFounderName;
                    tempTree.StrDateTime       = param.StrDateTime;
                    _mLstContentsTreeParam.Add(tempTree);
                }

                _mContentsRootNode.Children.Clear();
                _mLstContentsTreeNodes.Clear();
                ContentsCheckableTree.ItemsSource = _mContentsRootNode.Children;
                InitContentsTree(_mLstContentsTreeParam, 0, _mContentsRootNode);
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
        }