Exemple #1
0
        /// <summary>
        /// 获得所有标签等级
        /// </summary>
        /// <param name="session"></param>
        /// <param name="lstParams"></param>
        /// <returns></returns>
        private OperationReturn GetAllBookmarkLevels(SessionInfo session, List <string> lstParams)
        {
            OperationReturn optReturn = new OperationReturn();

            try
            {
                string strToken = session.RentInfo.Token;
                string strSql   = string.Empty;
                switch (session.DBType)
                {
                case 2:
                    strSql    = string.Format("select * from T_11_009_{0} where C000 = 3  and C010 = '0'", strToken);
                    optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql);
                    break;

                case 3:
                    strSql    = string.Format("select * from T_11_009_{0} where C000 = 3 and C010 = '0'", strToken);
                    optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql);
                    break;
                }
                optReturn.Message = strSql;
                if (!optReturn.Result)
                {
                    optReturn.Code = (int)S5100WcfErrorCode.GetAllBookmarkLevelError;
                    return(optReturn);
                }
                DataSet ds = optReturn.Data as DataSet;
                if (ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0)
                {
                    optReturn.Data = new List <string>();
                    return(optReturn);
                }
                List <string>       lstRecords = new List <string>();
                BookmarkLevelEntity level      = null;
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    level = new BookmarkLevelEntity();
                    level.BookmarkLevelID     = row["C001"].ToString();
                    level.BookmarkLevelName   = row["C009"].ToString();
                    level.BookmarkLevelColor  = S5100EncryptOperation.DecryptWithM002(row["C006"].ToString());
                    level.BookmarkLevelStatus = row["C004"].ToString();
                    optReturn = XMLHelper.SeriallizeObject <BookmarkLevelEntity>(level);
                    if (optReturn.Result)
                    {
                        lstRecords.Add(optReturn.Data as string);
                    }
                }

                optReturn.Result = true;
                optReturn.Code   = Defines.RET_SUCCESS;
                optReturn.Data   = lstRecords;
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }
 void UC_KeyWorldEdit_Loaded(object sender, RoutedEventArgs e)
 {
     InitLanguage();
     GetAllBookmarkLevel();
     if (iAddOrModify == OperationType.Modify)
     {
         txtName.Text      = keyWorldInModify.KeyWorldContent;
         txtName.IsEnabled = false;
         BookmarkLevelEntity level = null;
         foreach (ComboBoxItem item in cmbLevels.Items)
         {
             level = item.DataContext as BookmarkLevelEntity;
             if (level.BookmarkLevelID == keyWorldInModify.BookmarkLevelID)
             {
                 cmbLevels.SelectedItem = item;
             }
         }
     }
 }
        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();
                    }
                }
            }
        }
        /// <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();
                    }
                }
            }
        }
        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();
                    }
                }
            }
        }