Esempio n. 1
0
        private void LevelEnableDisable(OperationType optType)
        {
            BookmarkLevelEntityInList level = lvBookmarkLevelsObject.SelectedItem as BookmarkLevelEntityInList;

            if (level == null)
            {
                return;
            }
            string strPopupMsg = string.Empty;

            if (optType == Common5100.OperationType.Enable)
            {
                if (level.BookmarkLevelStatus == "1")
                {
                    CurrentApp.ShowInfoMessage(CurrentApp.GetLanguageInfo("5101007", "This is already enabled, without the need to repeat the"));
                    return;
                }
                else
                {
                    strPopupMsg = CurrentApp.GetLanguageInfo("5101010", "Are you sure to enable this?");
                }
            }
            else if (optType == Common5100.OperationType.Disable)
            {
                if (level.BookmarkLevelStatus == "0")
                {
                    CurrentApp.ShowInfoMessage(CurrentApp.GetLanguageInfo("5101008", "This is a disabled state, no need to repeat the disabled"));
                    return;
                }
                else
                {
                    strPopupMsg = CurrentApp.GetLanguageInfo("5101009", "Are you sure to disable this?");
                }
            }
            string           strConfirm = CurrentApp.GetLanguageInfo("5102013", "Confirm");
            MessageBoxResult result     = MessageBox.Show(strPopupMsg, strConfirm, MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (result == MessageBoxResult.Yes)
            {
                SetLevelStatus(optType, level);
            }
            else
            {
                string msg = string.Empty;
                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_CANCEL, 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_CANCEL, msg);
                }
            }
        }
Esempio n. 2
0
        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;
                }
                switch (optItem.ID)
                {
                case S5100Const.OPT_BookmarkLevelAdd:
                    UC_BookmarkLevelEdit uc_Edit = new UC_BookmarkLevelEdit();
                    uc_Edit.CurrentApp   = CurrentApp;
                    uc_Edit.iAddOrModify = OperationType.Add;
                    uc_Edit.ParentPage   = this;
                    PopupPanel.Content   = uc_Edit;
                    PopupPanel.Title     = CurrentApp.GetLanguageInfo("5101004", "Add a new bookmark level ");
                    PopupPanel.IsOpen    = true;
                    break;

                case S5100Const.OPT_BookmarkLevelModify:
                    BookmarkLevelEntityInList level = lvBookmarkLevelsObject.SelectedItem as BookmarkLevelEntityInList;
                    if (level == null)
                    {
                        return;
                    }
                    uc_Edit              = new UC_BookmarkLevelEdit();
                    uc_Edit.CurrentApp   = CurrentApp;
                    uc_Edit.iAddOrModify = OperationType.Modify;
                    uc_Edit.ParentPage   = this;
                    PopupPanel.Content   = uc_Edit;

                    uc_Edit.LevelInModify = level;
                    PopupPanel.Title      = CurrentApp.GetLanguageInfo("5101006", "Modify bookmark level");
                    PopupPanel.IsOpen     = true;
                    break;

                case S5100Const.OPT_BookmarkLevelDisable:
                    LevelEnableDisable(Common5100.OperationType.Disable);
                    break;

                case S5100Const.OPT_BookmarkLevelEnable:
                    LevelEnableDisable(Common5100.OperationType.Enable);
                    break;

                case S5100Const.OPT_BookmarkLevelDelete:
                    DeleteLevel();
                    break;
                }
            }
        }
Esempio n. 3
0
        public void UpdateListView(BookmarkLevelEntityInList level, OperationType optType)
        {
            switch (optType)
            {
            case OperationType.Add:
                if (lstLevelsInList.Count > 0)
                {
                    BookmarkLevelEntityInList last = lstLevelsInList.Last();
                    if (last.Background == Brushes.Transparent)
                    {
                        level.Background = Brushes.LightGray;
                    }
                    else
                    {
                        level.Background = Brushes.Transparent;
                    }
                }
                else
                {
                    level.Background = Brushes.Transparent;
                }
                lstLevelsInList.Add(level);
                break;

            case OperationType.Modify:
                BookmarkLevelEntityInList entity = lstLevelsInList.Where(p => p.BookmarkLevelID == level.BookmarkLevelID).First();
                entity.BookmarkLevelColor = level.BookmarkLevelColor;
                break;

            case OperationType.Delete:
                entity = lstLevelsInList.Where(p => p.BookmarkLevelID == level.BookmarkLevelID).First();
                lstLevelsInList.Remove(entity);
                break;

            case Common5100.OperationType.Enable:
                entity = lstLevelsInList.Where(p => p.BookmarkLevelID == level.BookmarkLevelID).First();
                entity.BookmarkLevelStatus     = level.BookmarkLevelStatus;
                entity.BookmarkLevelStatusIcon = level.BookmarkLevelStatusIcon;
                break;

            case Common5100.OperationType.Disable:
                entity = lstLevelsInList.Where(p => p.BookmarkLevelID == level.BookmarkLevelID).First();
                entity.BookmarkLevelStatus     = level.BookmarkLevelStatus;
                entity.BookmarkLevelStatusIcon = level.BookmarkLevelStatusIcon;
                break;
            }
            PopupPanel.IsOpen = false;
        }
Esempio n. 4
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;
            }
        }
Esempio n. 5
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();
                    }
                }
            }
        }
Esempio n. 6
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();
                    }
                }
            }
        }
        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
        }
Esempio n. 8
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();
                    }
                }
            }
        }