Exemplo n.º 1
0
        private void DeleteKeyworld()
        {
            Service510011Client client = null;

            try
            {
                KeyWorldsEntityInList keyWorld   = lvKeyWorldsObject.SelectedItem as KeyWorldsEntityInList;
                WebRequest            webRequest = new WebRequest();
                webRequest.Code    = (int)S5100RequestCode.DeleteKeyWorld;
                webRequest.Session = CurrentApp.Session;
                webRequest.ListData.Add(keyWorld.KeyWorldID);
                client = new Service510011Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                 WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service51001"));
                WebReturn webReturn = client.DoOperation(webRequest);
                CurrentApp.MonitorHelper.AddWebReturn(webReturn);
                client.Close();
                if (!webReturn.Result)
                {
                    if (webReturn.Code != Defines.RET_FAIL)
                    {
                        ShowException(CurrentApp.GetLanguageInfo(((int)webReturn.Code).ToString(), string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message)));
                        return;
                    }
                    else
                    {
                        ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                        return;
                    }
                }
                CurrentApp.ShowInfoMessage(CurrentApp.GetLanguageInfo("OPR1", "Success"));
                UpdateListView(keyWorld, OperationType.Delete);
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
            finally
            {
                if (client != null)
                {
                    if (client.State == System.ServiceModel.CommunicationState.Opened)
                    {
                        client.Close();
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void DeleteLevel()
        {
            BookmarkLevelEntityInList level = lvBookmarkLevelsObject.SelectedItem as BookmarkLevelEntityInList;

            if (level == null)
            {
                return;
            }
            string           strPopupMsg = CurrentApp.GetLanguageInfo("5101015", "Are you sure to delete this?");
            string           strConfirm  = CurrentApp.GetLanguageInfo("5102013", "Confirm");
            MessageBoxResult result      = MessageBox.Show(strPopupMsg, strConfirm, MessageBoxButton.YesNo, MessageBoxImage.Warning);
            string           msg         = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO5101005")), level.BookmarkLevelName);

            if (result == MessageBoxResult.Yes)
            {
                Service510011Client client = null;
                try
                {
                    WebRequest webRequest = new WebRequest();
                    webRequest.Session = CurrentApp.Session;
                    webRequest.ListData.Add(level.BookmarkLevelID);
                    webRequest.Code = (int)S5100RequestCode.DeleteBookmarkLevel;
                    client          = new Service510011Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                              WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service51001"));
                    WebReturn webReturn = client.DoOperation(webRequest);
                    CurrentApp.MonitorHelper.AddWebReturn(webReturn);
                    client.Close();

                    if (!webReturn.Result)
                    {
                        CurrentApp.WriteOperationLog("5101005", ConstValue.OPT_RESULT_FAIL, msg);
                        if (webReturn.Code != Defines.RET_FAIL)
                        {
                            ShowException(CurrentApp.GetLanguageInfo(((int)webReturn.Code).ToString(), string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message)));
                            return;
                        }
                        else
                        {
                            ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                            return;
                        }
                    }
                    CurrentApp.WriteOperationLog("5101005", ConstValue.OPT_RESULT_SUCCESS, msg);
                    UpdateListView(level, OperationType.Delete);
                }
                catch (Exception ex)
                {
                    CurrentApp.WriteOperationLog("5101005", ConstValue.OPT_RESULT_FAIL, msg);
                    ShowException(ex.Message);
                }
                finally
                {
                    if (client != null)
                    {
                        if (client.State == System.ServiceModel.CommunicationState.Opened)
                        {
                            client.Close();
                        }
                    }
                }
            }
            else
            {
                CurrentApp.WriteOperationLog("5101005", ConstValue.OPT_RESULT_FAIL, msg);
            }
            if (lstLevelsInList.Count > 0)
            {
                lvBookmarkLevelsObject.SelectedIndex = 0;
            }
        }
Exemplo n.º 3
0
        private void SetLevelStatus(OperationType optType, BookmarkLevelEntityInList level)
        {
            Service510011Client client = null;

            try
            {
                WebRequest webRequest = new WebRequest();
                webRequest.Session = CurrentApp.Session;
                webRequest.ListData.Add(level.BookmarkLevelID);
                if (optType == Common5100.OperationType.Enable)
                {
                    webRequest.ListData.Add("1");
                }
                else
                {
                    webRequest.ListData.Add("0");
                }
                webRequest.Code = (int)S5100RequestCode.SetBookmarkLevelStatus;
                client          = new Service510011Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                          WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service51001"));
                WebReturn webReturn = client.DoOperation(webRequest);
                CurrentApp.MonitorHelper.AddWebReturn(webReturn);
                client.Close();
                string msg = string.Empty;
                if (!webReturn.Result)
                {
                    if (optType == Common5100.OperationType.Enable)
                    {
                        msg = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO5101003")), level.BookmarkLevelName);
                        CurrentApp.WriteOperationLog("5101003", ConstValue.OPT_RESULT_FAIL, msg);
                    }
                    else if (optType == Common5100.OperationType.Disable)
                    {
                        msg = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO5101004")), level.BookmarkLevelName);
                        CurrentApp.WriteOperationLog("5101004", ConstValue.OPT_RESULT_FAIL, msg);
                    }
                    if (webReturn.Code != Defines.RET_FAIL)
                    {
                        ShowException(CurrentApp.GetLanguageInfo(((int)webReturn.Code).ToString(), string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message)));
                        return;
                    }
                    else
                    {
                        ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                        return;
                    }
                }
                if (optType == Common5100.OperationType.Disable)
                {
                    level.BookmarkLevelStatus     = "0";
                    level.BookmarkLevelStatusIcon = "Images/disabled.ico";
                }
                else if (optType == Common5100.OperationType.Enable)
                {
                    level.BookmarkLevelStatus     = "1";
                    level.BookmarkLevelStatusIcon = "Images/avaliable.ico";
                }
                if (optType == Common5100.OperationType.Enable)
                {
                    msg = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO5101003")), level.BookmarkLevelName);
                    CurrentApp.WriteOperationLog("5101003", ConstValue.OPT_RESULT_SUCCESS, msg);
                }
                else if (optType == Common5100.OperationType.Disable)
                {
                    msg = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO5101004")), level.BookmarkLevelName);
                    CurrentApp.WriteOperationLog("5101004", ConstValue.OPT_RESULT_SUCCESS, msg);
                }
                UpdateListView(level, optType);
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
            finally
            {
                if (client != null)
                {
                    if (client.State == System.ServiceModel.CommunicationState.Opened)
                    {
                        client.Close();
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void GetAllBookmarkLevel()
        {
            lstLevelsInList.Clear();
            Service510011Client client = null;

            try
            {
                WebRequest webRequest = new WebRequest();
                webRequest.Code    = (int)S5100RequestCode.GetAllBookmarkLevels;
                webRequest.Session = CurrentApp.Session;
                client             = new Service510011Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                             WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service51001"));
                WebReturn webReturn = client.DoOperation(webRequest);
                CurrentApp.MonitorHelper.AddWebReturn(webReturn);
                client.Close();
                if (!webReturn.Result)
                {
                    if (webReturn.Code != Defines.RET_FAIL)
                    {
                        ShowException(CurrentApp.GetLanguageInfo(((int)webReturn.Code).ToString(), string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message)));
                        return;
                    }
                    else
                    {
                        ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                        return;
                    }
                }
                List <string>             lstRecords  = webReturn.ListData;
                OperationReturn           optReturn   = null;
                BookmarkLevelEntity       level       = null;
                BookmarkLevelEntityInList levelInList = null;
                for (int i = 0; i < lstRecords.Count; i++)
                {
                    optReturn = XMLHelper.DeserializeObject <BookmarkLevelEntity>(lstRecords[i]);
                    if (optReturn.Result)
                    {
                        level       = optReturn.Data as BookmarkLevelEntity;
                        levelInList = new BookmarkLevelEntityInList();
                        levelInList.BookmarkLevelID     = level.BookmarkLevelID;
                        levelInList.BookmarkLevelName   = level.BookmarkLevelName;
                        levelInList.BookmarkLevelStatus = level.BookmarkLevelStatus;
                        levelInList.BookmarkLevelColor  = level.BookmarkLevelColor;
                        if (level.BookmarkLevelStatus == "0")
                        {
                            levelInList.BookmarkLevelStatusIcon = "Images/disabled.ico";
                        }
                        else
                        {
                            levelInList.BookmarkLevelStatusIcon = "Images/avaliable.ico";
                        }
                        lstLevelsInList.Add(levelInList);
                        if (i % 2 == 1)
                        {
                            levelInList.Background = Brushes.LightGray;
                        }
                        else
                        {
                            levelInList.Background = Brushes.Transparent;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
            finally
            {
                if (client != null)
                {
                    if (client.State == System.ServiceModel.CommunicationState.Opened)
                    {
                        client.Close();
                    }
                }
            }
        }
Exemplo n.º 5
0
        void BtnApply_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(txtName.Text))
            {
                ShowException(CurrentApp.GetLanguageInfo("5101005", "Class name can not be empty"));
                return;
            }

            Service510011Client client = null;

            try
            {
                WebRequest webRequest = new WebRequest();
                webRequest.Session = CurrentApp.Session;
                string strColor = colorLevel.SelectedColor.ToString().Substring(3);

                #region Add
                if (iAddOrModify == 0)
                {
                    webRequest.Code = (int)S5100RequestCode.AddBookmarkLevel;
                    webRequest.ListData.Add(txtName.Text);
                    webRequest.ListData.Add(strColor);
                }
                #endregion
                #region Modify
                else if (iAddOrModify == OperationType.Modify)
                {
                    webRequest.Code = (int)S5100RequestCode.ModifyBookmarkLevel;
                    webRequest.ListData.Add(LevelInModify.BookmarkLevelID);
                    webRequest.ListData.Add(strColor);
                }
                client = new Service510011Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                 WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service51001"));
                WebReturn webReturn = client.DoOperation(webRequest);
                CurrentApp.MonitorHelper.AddWebReturn(webReturn);
                client.Close();
                if (!webReturn.Result)
                {
                    if (iAddOrModify == OperationType.Add)
                    {
                        string msg = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO5101001")), txtName.Text);
                        CurrentApp.WriteOperationLog("5101001", ConstValue.OPT_RESULT_FAIL, msg);
                    }
                    else if (iAddOrModify == OperationType.Modify)
                    {
                        string msg = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO5101002")), txtName.Text);
                        CurrentApp.WriteOperationLog("5101002", ConstValue.OPT_RESULT_FAIL, msg);
                    }
                    if (webReturn.Code != Defines.RET_FAIL)
                    {
                        ShowException(CurrentApp.GetLanguageInfo(((int)webReturn.Code).ToString(), string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message)));
                        return;
                    }
                    else
                    {
                        ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                        return;
                    }
                }
                //添加成功

                BookmarkLevelEntityInList level = new BookmarkLevelEntityInList();
                if (iAddOrModify == OperationType.Add)
                {
                    string msg = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO5101001")), txtName.Text);
                    CurrentApp.WriteOperationLog("5101001", ConstValue.OPT_RESULT_SUCCESS, msg);

                    string str     = webReturn.Data;
                    long   levelID = 0;
                    long.TryParse(str, out levelID);
                    if (levelID == 0)
                    {
                        return;
                    }

                    level.BookmarkLevelID         = levelID.ToString();
                    level.BookmarkLevelName       = txtName.Text;
                    level.BookmarkLevelStatus     = "1";
                    level.BookmarkLevelStatusIcon = "Images/avaliable.ico";
                    level.BookmarkLevelColor      = strColor;
                    ParentPage.UpdateListView(level, OperationType.Add);
                }
                else if (iAddOrModify == OperationType.Modify)
                {
                    string msg = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO5101002")), txtName.Text);
                    CurrentApp.WriteOperationLog("5101002", ConstValue.OPT_RESULT_SUCCESS, msg);
                    level.BookmarkLevelColor = strColor;
                    level.BookmarkLevelID    = LevelInModify.BookmarkLevelID;
                    ParentPage.UpdateListView(level, OperationType.Modify);
                }
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
            finally
            {
                if (client != null)
                {
                    if (client.State == System.ServiceModel.CommunicationState.Opened)
                    {
                        client.Close();
                    }
                }
            }
            #endregion
        }
Exemplo n.º 6
0
        private void GetAllKeyWorlds()
        {
            Service510011Client client = null;

            try
            {
                WebRequest webRequest = new WebRequest();
                webRequest.Code    = (int)S5100RequestCode.GetAllKeyWorlds;
                webRequest.Session = CurrentApp.Session;
                client             = new Service510011Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                             WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service51001"));
                WebReturn webReturn = client.DoOperation(webRequest);
                CurrentApp.MonitorHelper.AddWebReturn(webReturn);
                client.Close();
                if (!webReturn.Result)
                {
                    if (webReturn.Code != Defines.RET_FAIL)
                    {
                        ShowException(CurrentApp.GetLanguageInfo(((int)webReturn.Code).ToString(), string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message)));
                        return;
                    }
                    else
                    {
                        ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                        return;
                    }
                }
                List <string>         lstRecords     = webReturn.ListData;
                OperationReturn       optReturn      = null;
                KeyWorldsEntity       keyWrold       = null;
                KeyWorldsEntityInList keyWroldInList = null;
                for (int i = 0; i < lstRecords.Count; i++)
                {
                    optReturn = XMLHelper.DeserializeObject <KeyWorldsEntity>(lstRecords[i]);
                    if (optReturn.Result)
                    {
                        keyWrold       = optReturn.Data as KeyWorldsEntity;
                        keyWroldInList = new KeyWorldsEntityInList();
                        keyWroldInList.BookmarkLevelColor = keyWrold.BookmarkLevelcolor;
                        keyWroldInList.BookmarkLevelID    = keyWrold.BookmarkLevelID;
                        keyWroldInList.KeyWorldContent    = keyWrold.KeyWorldContent;
                        keyWroldInList.KeyWorldID         = keyWrold.KeyWorldID;
                        keyWroldInList.LevelName          = keyWrold.LevelName;
                        lstKeyWorldsInList.Add(keyWroldInList);
                        if (i % 2 == 1)
                        {
                            keyWroldInList.Background = Brushes.LightGray;
                        }
                        else
                        {
                            keyWroldInList.Background = Brushes.Transparent;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
            finally
            {
                if (client != null)
                {
                    if (client.State == System.ServiceModel.CommunicationState.Opened)
                    {
                        client.Close();
                    }
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 获得所有可用的标签等级
        /// </summary>
        private void GetAllBookmarkLevel()
        {
            Service510011Client client = null;

            lstLevels.Clear();
            try
            {
                WebRequest webRequest = new WebRequest();
                webRequest.Code    = (int)S5100RequestCode.GetAllBookmarkLevels;
                webRequest.Session = CurrentApp.Session;
                client             = new Service510011Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                             WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service51001"));
                WebReturn webReturn = client.DoOperation(webRequest);
                CurrentApp.MonitorHelper.AddWebReturn(webReturn);
                client.Close();
                if (!webReturn.Result)
                {
                    if (webReturn.Code != Defines.RET_FAIL)
                    {
                        ShowException(CurrentApp.GetLanguageInfo(((int)webReturn.Code).ToString(), string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message)));
                        return;
                    }
                    else
                    {
                        ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                        return;
                    }
                }
                List <string>             lstRecords  = webReturn.ListData;
                OperationReturn           optReturn   = null;
                BookmarkLevelEntity       level       = null;
                BookmarkLevelEntityInList levelInList = null;
                for (int i = 0; i < lstRecords.Count; i++)
                {
                    optReturn = XMLHelper.DeserializeObject <BookmarkLevelEntity>(lstRecords[i]);
                    if (optReturn.Result)
                    {
                        level = optReturn.Data as BookmarkLevelEntity;
                        if (level.BookmarkLevelStatus == "1")
                        {
                            lstLevels.Add(level);
                        }
                    }
                }
                ComboBoxItem item = null;
                for (int i = 0; i < lstLevels.Count; i++)
                {
                    item             = new ComboBoxItem();
                    item.Content     = lstLevels[i].BookmarkLevelName;
                    item.DataContext = lstLevels[i];
                    cmbLevels.Items.Add(item);
                }
                if (cmbLevels.Items.Count > 0)
                {
                    cmbLevels.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
            finally
            {
                if (client != null)
                {
                    if (client.State == System.ServiceModel.CommunicationState.Opened)
                    {
                        client.Close();
                    }
                }
            }
        }
Exemplo n.º 8
0
        private void ModifyKeyWorld()
        {
            Service510011Client client = null;

            try
            {
                KeyWorldsEntityInList keyworld = new KeyWorldsEntityInList();
                BookmarkLevelEntity   level    = (cmbLevels.SelectedItem as ComboBoxItem).DataContext as BookmarkLevelEntity;
                keyworld.KeyWorldID         = keyWorldInModify.KeyWorldID;
                keyworld.KeyWorldContent    = txtName.Text;
                keyworld.BookmarkLevelID    = level.BookmarkLevelID;
                keyworld.BookmarkLevelColor = level.BookmarkLevelColor;
                WebRequest webRequest = new WebRequest();
                webRequest.Code    = (int)S5100RequestCode.ModifyKeyWorld;
                webRequest.Session = CurrentApp.Session;
                webRequest.ListData.Add(keyworld.KeyWorldID);
                webRequest.ListData.Add(level.BookmarkLevelID);
                client = new Service510011Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                                                 WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service51001"));
                WebReturn webReturn = client.DoOperation(webRequest);
                CurrentApp.MonitorHelper.AddWebReturn(webReturn);
                client.Close();
                string msg = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO5102002")), txtName.Text);
                msg += Utils.FormatOptLogString(string.Format("5102012")) + keyWorldInModify.LevelName + " -- " + level.BookmarkLevelName;
                if (!webReturn.Result)
                {
                    CurrentApp.WriteOperationLog("5102002", ConstValue.OPT_RESULT_FAIL, msg);
                    if (webReturn.Code != Defines.RET_FAIL)
                    {
                        if (webReturn.Code == (int)S5100WcfErrorCode.UploadKeyWorldXmlFailed)
                        {
                            string strMsg = CurrentApp.GetLanguageInfo(((int)webReturn.Code).ToString(), "Upload file failed, may be right enough, please complete control of license to the '{0}' folder Everyone");
                            strMsg = string.Format(strMsg, webReturn.Message);
                            ShowException(strMsg);
                        }
                        else
                        {
                            ShowException(CurrentApp.GetLanguageInfo(((int)webReturn.Code).ToString(), string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message)));
                        }
                    }
                    else
                    {
                        ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                        return;
                    }
                    if (webReturn.Code > (int)S5100WcfErrorCode.GenerateKeyWorldXmlException)
                    {
                        ParentPage.UpdateListView(keyworld, OperationType.Modify);
                    }
                }
                else
                {
                    CurrentApp.ShowInfoMessage(CurrentApp.GetLanguageInfo("OPR1", "Success"));
                    CurrentApp.WriteOperationLog("5102002", ConstValue.OPT_RESULT_SUCCESS, msg);
                    ParentPage.UpdateListView(keyworld, OperationType.Modify);
                }
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
            finally
            {
                if (client != null)
                {
                    if (client.State == System.ServiceModel.CommunicationState.Opened)
                    {
                        client.Close();
                    }
                }
            }
        }