Exemple #1
0
        /// <summary>
        /// 获得所有关键词
        /// </summary>
        /// <param name="session"></param>
        /// <param name="lstParams"></param>
        /// <returns></returns>
        private OperationReturn GetAllKeyWorlds(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 = "select a.C001 as keyworldID,a.C006 as keyworldContent,b.C001 as levelID,b.C006 as  levelColor ,b.C009 as LevelName" +
                             " from T_11_009_{0} as a left join T_11_009_{1} as b " +
                             " on a.C009 = b.C001 where a.C000=4 and b.C000=3 and a.C010 <>'1'";
                    strSql    = string.Format(strSql, strToken, strToken);
                    optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql);
                    break;

                case 3:
                    strSql = "select a.C001 as keyworldID,a.C006 as keyworldContent,b.C001 as levelID,b.C006 as  levelColor ,b.C009 as LevelName" +
                             " from T_11_009_{0} a left join T_11_009_{1} b " +
                             " on a.C009 = b.C001  where a.C000=4 and b.C000=3 and a.C010 <>'1'";
                    strSql    = string.Format(strSql, strToken, strToken);
                    optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql);
                    break;
                }
                optReturn.Message = strSql;
                if (!optReturn.Result)
                {
                    optReturn.Code = (int)S5100WcfErrorCode.GetAllKeyWorldsError;
                    return(optReturn);
                }
                List <string> lstRecords = new List <string>();
                DataSet       ds         = optReturn.Data as DataSet;
                if (ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0)
                {
                    optReturn.Data = lstRecords;
                    return(optReturn);
                }
                KeyWorldsEntity keyWorld = null;
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    keyWorld                    = new KeyWorldsEntity();
                    keyWorld.KeyWorldID         = row["keyworldID"].ToString();
                    keyWorld.KeyWorldContent    = S5100EncryptOperation.DecryptWithM002(row["keyworldContent"].ToString());
                    keyWorld.BookmarkLevelID    = row["levelID"].ToString();
                    keyWorld.BookmarkLevelcolor = S5100EncryptOperation.DecryptWithM002(row["levelColor"].ToString());
                    keyWorld.LevelName          = row["LevelName"].ToString();
                    optReturn                   = XMLHelper.SeriallizeObject <KeyWorldsEntity>(keyWorld);
                    if (optReturn.Result)
                    {
                        lstRecords.Add(optReturn.Data as string);
                    }
                }
                optReturn.Data   = lstRecords;
                optReturn.Result = true;
                optReturn.Code   = Defines.RET_SUCCESS;
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }
Exemple #2
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();
                    }
                }
            }
        }