示例#1
0
        private TokenID ScanKeywordOrIdentifier()
        {
            StringBuilder sb = new StringBuilder();

            bool hasLettersOnly;

            ScanIdentifier(sb, out hasLettersOnly);

            string strValue = sb.ToString();

            TokenID token = TokenID.Unknown;

            if (hasLettersOnly && currentToken != TokenID.Dot)
            {
                // It might be a keyword.
                KeywordInfo keyword = null;
                if (keywordMap.TryGetValue(strValue.ToLowerInvariant(), out keyword))
                {
                    token      = keyword.Token;
                    tokenValue = keyword.TokenValue;
                    return(token);
                }
            }

            // Otherwise, it's an identifier
            token      = TokenID.Identifier;
            tokenValue = strValue;

            return(token);
        }
示例#2
0
        internal bool Keyword_Update(KeywordInfo info)
        {
            var sql = string.Format("UPDATE k set k.ChineseName = '{0}' FROM Keyword AS k WHERE k.KeywordID ={1}", info.ChineseName, info.KeywordID);
            var cmd = dbw.GetSqlStringCommand(sql);

            return(dbw.ExecuteNonQuery(cmd) > 0);
        }
示例#3
0
        public void Update(KeywordInfo keywordInfo)
        {
            if (keywordInfo != null && keywordInfo.KeywordID > 0)
            {
                var parms = new IDataParameter[]
                {
                    GetParameter(PARM_PUBLISHMENT_SYSTEM_ID, EDataType.Integer, keywordInfo.PublishmentSystemID),
                    GetParameter(PARM_KEYWORDS, EDataType.NVarChar, 255, keywordInfo.Keywords),
                    GetParameter(PARM_IS_DISABLED, EDataType.VarChar, 18, keywordInfo.IsDisabled.ToString()),
                    GetParameter(PARM_KEYWORD_TYPE, EDataType.VarChar, 50, EKeywordTypeUtils.GetValue(keywordInfo.KeywordType)),
                    GetParameter(PARM_MATCH_TYPE, EDataType.VarChar, 50, EMatchTypeUtils.GetValue(keywordInfo.MatchType)),
                    GetParameter(PARM_REPLY, EDataType.NText, keywordInfo.Reply),
                    GetParameter(PARM_ADD_DATE, EDataType.DateTime, keywordInfo.AddDate),
                    GetParameter(PARM_TAXIS, EDataType.Integer, keywordInfo.Taxis),
                    GetParameter(PARM_KEYWORD_ID, EDataType.Integer, keywordInfo.KeywordID)
                };

                ExecuteNonQuery(SQL_UPDATE, parms);

                DataProviderWX.KeywordMatchDAO.DeleteByKeywordID(keywordInfo.KeywordID);

                foreach (var str in TranslateUtils.StringCollectionToStringList(keywordInfo.Keywords, ' '))
                {
                    var keyword = str.Trim();
                    if (!string.IsNullOrEmpty(keyword))
                    {
                        DataProviderWX.KeywordMatchDAO.Insert(new KeywordMatchInfo(0, keywordInfo.PublishmentSystemID, keyword, keywordInfo.KeywordID, keywordInfo.IsDisabled, keywordInfo.KeywordType, keywordInfo.MatchType));
                    }
                }
            }
        }
 private void SaveKeywordToTable(string txtKeyWord, int generalId)
 {
     foreach (string str in txtKeyWord.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries))
     {
         if (EasyOne.Accessories.Keywords.Exists(str))
         {
             KeywordInfo keywordByKeywordName = EasyOne.Accessories.Keywords.GetKeywordByKeywordName(str);
             string      str2        = ContentManage.RebuildArr(keywordByKeywordName.ArrayGeneralId + "," + generalId.ToString());
             int         length      = str2.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Length;
             DateTime    lastUseTime = keywordByKeywordName.LastUseTime;
             keywordByKeywordName.ArrayGeneralId = str2;
             keywordByKeywordName.QuoteTimes     = length;
             EasyOne.Accessories.Keywords.Update(keywordByKeywordName);
         }
         else
         {
             KeywordInfo keywordInfo = new KeywordInfo();
             keywordInfo.KeywordText    = str;
             keywordInfo.KeywordType    = 1;
             keywordInfo.LastUseTime    = DateTime.Now;
             keywordInfo.Priority       = 0;
             keywordInfo.ArrayGeneralId = generalId.ToString();
             keywordInfo.QuoteTimes     = 1;
             EasyOne.Accessories.Keywords.Add(keywordInfo);
         }
     }
 }
示例#5
0
        public KeywordInfo GetKeywordInfo(int keywordID)
        {
            KeywordInfo keywordInfo = null;

            if (keywordID > 0)
            {
                var parms = new IDataParameter[]
                {
                    GetParameter(PARM_KEYWORD_ID, EDataType.Integer, keywordID)
                };

                using (var rdr = ExecuteReader(SQL_SELECT, parms))
                {
                    if (rdr.Read())
                    {
                        keywordInfo = new KeywordInfo(rdr.GetInt32(0), rdr.GetInt32(1), rdr.GetValue(2).ToString(), TranslateUtils.ToBool(rdr.GetValue(3).ToString()), EKeywordTypeUtils.GetEnumType(rdr.GetValue(4).ToString()), EMatchTypeUtils.GetEnumType(rdr.GetValue(5).ToString()), rdr.GetValue(6).ToString(), rdr.GetDateTime(7), rdr.GetInt32(8));
                    }
                    rdr.Close();
                }
            }
            else
            {
                keywordInfo           = new KeywordInfo();
                keywordInfo.KeywordID = 0;
                keywordInfo.Keywords  = "";
            }

            if (keywordInfo == null)
            {
                keywordInfo           = new KeywordInfo();
                keywordInfo.KeywordID = 0;
                keywordInfo.Keywords  = "";
            }
            return(keywordInfo);
        }
示例#6
0
        public void Update(KeywordInfo keywordInfo)
        {
            if (keywordInfo != null && keywordInfo.KeywordId > 0)
            {
                var parms = new IDataParameter[]
                {
                    GetParameter(ParmPublishmentSystemId, EDataType.Integer, keywordInfo.PublishmentSystemId),
                    GetParameter(ParmKeywords, EDataType.NVarChar, 255, keywordInfo.Keywords),
                    GetParameter(ParmIsDisabled, EDataType.VarChar, 18, keywordInfo.IsDisabled.ToString()),
                    GetParameter(ParmKeywordType, EDataType.VarChar, 50, EKeywordTypeUtils.GetValue(keywordInfo.KeywordType)),
                    GetParameter(ParmMatchType, EDataType.VarChar, 50, EMatchTypeUtils.GetValue(keywordInfo.MatchType)),
                    GetParameter(ParmReply, EDataType.NText, keywordInfo.Reply),
                    GetParameter(ParmAddDate, EDataType.DateTime, keywordInfo.AddDate),
                    GetParameter(ParmTaxis, EDataType.Integer, keywordInfo.Taxis),
                    GetParameter(ParmKeywordId, EDataType.Integer, keywordInfo.KeywordId)
                };

                ExecuteNonQuery(SqlUpdate, parms);

                DataProviderWx.KeywordMatchDao.DeleteByKeywordId(keywordInfo.KeywordId);

                foreach (var str in TranslateUtils.StringCollectionToStringList(keywordInfo.Keywords, ' '))
                {
                    var keyword = str.Trim();
                    if (!string.IsNullOrEmpty(keyword))
                    {
                        DataProviderWx.KeywordMatchDao.Insert(new KeywordMatchInfo(0, keywordInfo.PublishmentSystemId, keyword, keywordInfo.KeywordId, keywordInfo.IsDisabled, keywordInfo.KeywordType, keywordInfo.MatchType));
                    }
                }
            }
        }
        //  private HashSet<char> kwSingle;

        private ScriptExpressionReader()
        {
            if (kws == null)
            {
                kws      = new Dictionary <string, KeywordInfo>();
                operChar = "";
                // kwSingle = new HashSet<char>();
                Action <string, int> addKeyword = (keyword, priority) =>
                {
                    kws[keyword] = new KeywordInfo()
                    {
                        Keyword  = keyword,
                        Priority = priority,
                    };
                    //if (keyword.Length == 1)
                    //    kwSingle.Add(keyword[0]);
                    foreach (var ch in keyword)
                    {
                        if (operChar.IndexOf(ch) < 0)
                        {
                            operChar += ch;
                        }
                    }
                };
                addKeyword(".", 0);
                addKeyword("(", 0);
                addKeyword("=", 0);
                addKeyword(",", 0);
                addKeyword("||", 2);
                addKeyword("&&", 2);
                addKeyword("==", 3);
                addKeyword("!=", 3);
                addKeyword("<", 3);
                addKeyword("<=", 3);
                addKeyword(">", 3);
                addKeyword(">=", 3);
                addKeyword("+", 4);
                addKeyword("-", 4);
                addKeyword("*", 5);
                addKeyword("/", 5);
                addKeyword("%", 5);
                addKeyword("!", 6);
                addKeyword(")", 7);
            }
            kwTypes = new Dictionary <ExpressionType, KeywordInfo>();


            //foreach (var cfgKw in ScriptConfig.Config.Keywords)
            //{
            //    KeywordInfo kw = new KeywordInfo();
            //    kw.Keyword = cfgKw.Keyword;
            //    kw.NodeType = cfgKw.Type;
            //    kw.Priority = cfgKw.Priority;
            //    kws.Add(kw.Keyword, kw);
            //    if (kw.NodeType != ExpressionType.None)
            //        kwTypes.Add(kw.NodeType, kw);
            //    if (kw.Keyword.Length == 1)
            //        kwSingle.Add(kw.Keyword[0]);
            //}
        }
        /// <summary>
        /// Ok button click event handler.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event arguments.</param>
        private void buttonOk_Click(object sender, System.EventArgs e)
        {
            // Generate new keyword
            this.Keyword = string.Empty;

            // Get selected keyword
            KeywordInfo keywordInfo = this._listBoxKeywords.SelectedItem as KeywordInfo;

            if (keywordInfo != null)
            {
                this.Keyword = keywordInfo.Keyword;

                if (keywordInfo.SupportsValueIndex &&
                    (int)_numericUpDownYValue.Value > 0)
                {
                    this.Keyword += "Y" + ((int)_numericUpDownYValue.Value).ToString(CultureInfo.InvariantCulture);
                }
                if (keywordInfo.SupportsFormatting &&
                    _comboBoxFormat.SelectedIndex > 0 &&
                    this.GetFormatString().Length > 0)
                {
                    this.Keyword += "{" + this.GetFormatString() + "}";
                }
            }
        }
示例#9
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The customer ID for which the call is made.</param>
        /// <param name="adGroupId">ID of the ad group to which keywords are added.</param>
        /// <param name="keywordText">The keyword text to add to the ad group.</param>
        public void Run(GoogleAdsClient client, long customerId, long adGroupId,
                        string keywordText)
        {
            // Get the AdGroupCriterionServiceClient.
            AdGroupCriterionServiceClient service = client.GetService(
                Services.V4.AdGroupCriterionService);

            // Configures the keyword text and match type settings.
            KeywordInfo keywordInfo = new KeywordInfo()
            {
                Text      = keywordText,
                MatchType = KeywordMatchType.Exact
            };

            // Constructs an ad group criterion using the keyword text info above.
            AdGroupCriterion adGroupCriterion = new AdGroupCriterion()
            {
                AdGroup = ResourceNames.AdGroup(customerId, adGroupId),
                Status  = AdGroupCriterionStatus.Paused,
                Keyword = keywordInfo
            };

            AdGroupCriterionOperation operation = new AdGroupCriterionOperation()
            {
                Create = adGroupCriterion
            };

            try
            {
                try
                {
                    // Try sending a mutate request to add the keyword.
                    MutateAdGroupCriteriaResponse response = service.MutateAdGroupCriteria(
                        customerId.ToString(), new[] { operation });
                    Console.WriteLine($"Added a keyword with resource name " +
                                      $"'{response.Results[0].ResourceName}'.");
                }
                catch (GoogleAdsException ex)
                {
                    PolicyViolationKey[] exemptPolicyViolationKeys =
                        FetchExemptPolicyViolationKeys(ex);

                    // Try sending exemption requests for creating a keyword. However, if your
                    // keyword contains many policy violations, but not all of them are exemptible,
                    // the request will not be sent.
                    RequestExemption(customerId, service, operation, exemptPolicyViolationKeys);
                }
            }
            catch (GoogleAdsException e)
            {
                Console.WriteLine("Failure:");
                Console.WriteLine($"Message: {e.Message}");
                Console.WriteLine($"Failure: {e.Failure}");
                Console.WriteLine($"Request ID: {e.RequestId}");
                throw;
            }
        }
示例#10
0
        public bool Add(KeywordInfo keywordInfo)
        {
            Parameters cmdParams = new Parameters();

            cmdParams.AddInParameter("@KeywordText", DbType.StringFixedLength, keywordInfo.KeywordText);
            cmdParams.AddInParameter("@KeywordType", DbType.Int32, keywordInfo.KeywordType);
            cmdParams.AddInParameter("@Priority", DbType.Int32, keywordInfo.Priority);
            cmdParams.AddInParameter("@ArrayGeneralId", DbType.String, keywordInfo.ArrayGeneralId);
            cmdParams.AddInParameter("@QuoteTimes", DbType.Int32, keywordInfo.QuoteTimes);
            return(DBHelper.ExecuteProc("PR_Accessories_Keywords_Add", cmdParams));
        }
示例#11
0
        private void InitKeyWords(ObjectItemTask parentItem, string parentID)
        {
            try
            {
                mListKeywordInfos.Clear();
                WebRequest webRequest = new WebRequest();
                webRequest.Session = CurrentApp.Session;
                webRequest.Code    = (int)S3103Codes.GetKeyWords;

                //   Service31031Client client = new Service31031Client();
                Service31031Client client = new Service31031Client(
                    WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                    WebHelper.CreateEndpointAddress(
                        CurrentApp.Session.AppServerInfo,
                        "Service31031"));
                WebHelper.SetServiceClient(client);
                WebReturn webReturn = client.UMPTaskOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    ShowException(string.Format("Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                    return;
                }
                if (webReturn.ListData == null)
                {
                    ShowException(string.Format("Fail.\tListData is null"));
                    return;
                }
                OperationReturn optReturn;
                for (int i = 0; i < webReturn.ListData.Count; i++)
                {
                    string strInfo = webReturn.ListData[i];
                    optReturn = XMLHelper.DeserializeObject <KeywordInfo>(strInfo);
                    if (!optReturn.Result)
                    {
                        ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                        return;
                    }
                    KeywordInfo info = optReturn.Data as KeywordInfo;
                    if (info == null)
                    {
                        ShowException(string.Format("KeywordInfo is null."));
                        return;
                    }
                    mListKeywordInfos.Add(info);
                }

                CurrentApp.WriteLog("LoadKeywordInfos", string.Format("End.\t{0}", mListKeywordInfos.Count));
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
        }
 protected void RepKeyWords_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
     {
         KeywordInfo dataItem = (KeywordInfo)e.Item.DataItem;
         this.allKeyword = this.allKeyword + " " + dataItem.KeywordText;
         ExtendedLiteral literal = e.Item.FindControl("LitKeyword") as ExtendedLiteral;
         string          format  = "<a href=\"#\" onclick=\"add('{0}')\" title='{1}'>{2}</a>";
         literal.HtmlEncode = false;
         literal.Text       = string.Format(format, DataSecurity.HtmlEncode(DataSecurity.ConvertToJavaScript(dataItem.KeywordText)), DataSecurity.HtmlEncode(dataItem.KeywordText), (dataItem.KeywordText.Length < 6) ? DataSecurity.HtmlEncode(dataItem.KeywordText) : (DataSecurity.HtmlEncode(dataItem.KeywordText.Substring(0, 6)) + "..."));
     }
 }
        protected void OnGUI()
        {
            EZEditorGUIUtility.WindowTitle(this);

            if (GUILayout.Button("Clear"))
            {
                keywordInfoDict.Clear();
            }

            EditorGUILayout.Space();
            keywordStringFromWarning = EditorGUILayout.TextArea(keywordStringFromWarning, GUILayout.Height(80));
            if (GUILayout.Button("Get Keywords"))
            {
                GetKeywords();
            }
            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
            bool changed = false;
            int  index   = 0;

            foreach (var pair in keywordInfoDict)
            {
                KeywordInfo keywordInfo = pair.Value;
                EditorGUILayout.BeginHorizontal();
                keywordInfo.foldout = EditorGUILayout.Foldout(keywordInfo.foldout, index++.ToString("000 ") + keywordInfo.keyword);
                EditorGUILayout.LabelField("Count:" + keywordInfo.materials.Count, GUILayout.Width(80));
                EditorGUILayout.LabelField("IsGlobal:" + keywordInfo.isGlobal, GUILayout.Width(120));
                if (GUILayout.Button("Delete", GUILayout.Width(80)))
                {
                    foreach (Material mat in keywordInfo.materials)
                    {
                        mat.DisableKeyword(keywordInfo.keyword);
                        EditorUtility.SetDirty(mat);
                    }
                    Shader.DisableKeyword(keywordInfo.keyword);
                    changed = true;
                }
                EditorGUILayout.EndHorizontal();
                if (keywordInfo.foldout)
                {
                    EditorGUI.indentLevel++;
                    foreach (Material mat in keywordInfo.materials)
                    {
                        EditorGUILayout.ObjectField(mat, typeof(Material), true);
                    }
                    EditorGUI.indentLevel--;
                }
            }
            if (changed)
            {
                GetKeywords();
            }
            EditorGUILayout.EndScrollView();
        }
示例#14
0
        public void Update(KeywordInfo keywordInfo)
        {
            var parms = new IDataParameter[]
            {
                GetParameter(ParmKeyword, DataType.VarChar, 50, keywordInfo.Keyword),
                GetParameter(ParmAlternative, DataType.VarChar, 50, keywordInfo.Alternative),
                GetParameter(ParmGrade, DataType.VarChar, 50, EKeywordGradeUtils.GetValue(keywordInfo.Grade)),
                GetParameter(ParmId, DataType.Integer, keywordInfo.Id)
            };

            ExecuteNonQuery(SqlUpdate, parms);
        }
示例#15
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isChanged = false;

            if (_keywordId > 0)
            {
                try
                {
                    var keywordInfo = DataProvider.KeywordDao.GetKeywordInfo(_keywordId);
                    keywordInfo.Keyword     = tbKeyword.Text.Trim();
                    keywordInfo.Alternative = tbAlternative.Text.Trim();
                    keywordInfo.Grade       = EKeywordGradeUtils.GetEnumType(ddlGrade.SelectedValue);
                    DataProvider.KeywordDao.Update(keywordInfo);

                    isChanged = true;
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "修改敏感词失败!");
                }
            }
            else
            {
                if (DataProvider.KeywordDao.IsExists(tbKeyword.Text))
                {
                    FailMessage("敏感词添加失败,敏感词名称已存在!");
                }
                else
                {
                    try
                    {
                        var keywordInfo = new KeywordInfo
                        {
                            Keyword     = tbKeyword.Text.Trim(),
                            Alternative = tbAlternative.Text.Trim(),
                            Grade       = EKeywordGradeUtils.GetEnumType(ddlGrade.SelectedValue)
                        };
                        DataProvider.KeywordDao.Insert(keywordInfo);
                        isChanged = true;
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "添加敏感词失败!");
                    }
                }
            }

            if (isChanged)
            {
                PageUtils.CloseModalPage(Page);
            }
        }
示例#16
0
        public void Insert(KeywordInfo keywordInfo)
        {
            var sqlString = "INSERT INTO siteserver_Keyword(Keyword, Alternative, Grade) VALUES(@Keyword, @Alternative, @Grade)";

            var parms = new IDataParameter[]
            {
                GetParameter(ParmKeyword, DataType.VarChar, 50, keywordInfo.Keyword),
                GetParameter(ParmAlternative, DataType.VarChar, 50, keywordInfo.Alternative),
                GetParameter(ParmGrade, DataType.VarChar, 50, EKeywordGradeUtils.GetValue(keywordInfo.Grade))
            };

            ExecuteNonQuery(sqlString, parms);
        }
示例#17
0
        private static KeywordInfo KeywordsFromrdr(NullableDataReader rdr)
        {
            KeywordInfo info = new KeywordInfo();

            info.KeywordId      = rdr.GetInt32("KeywordID");
            info.KeywordText    = rdr.GetString("KeywordText");
            info.KeywordType    = rdr.GetInt32("KeywordType");
            info.Priority       = rdr.GetInt32("Priority");
            info.Hits           = rdr.GetInt32("Hits");
            info.LastUseTime    = rdr.GetDateTime("LastUseTime");
            info.ArrayGeneralId = rdr.GetString("arrGeneralID");
            info.QuoteTimes     = rdr.GetInt32("QuoteTimes");
            return(info);
        }
示例#18
0
        public int Insert(KeywordInfo keywordInfo)
        {
            var keywordID = 0;

            var sqlString = "INSERT INTO wx_Keyword (PublishmentSystemID, Keywords, IsDisabled, KeywordType, MatchType, Reply, AddDate, Taxis) VALUES (@PublishmentSystemID, @Keywords, @IsDisabled, @KeywordType, @MatchType, @Reply, @AddDate, @Taxis)";

            var taxis = GetMaxTaxis(keywordInfo.PublishmentSystemID, keywordInfo.KeywordType) + 1;
            var parms = new IDataParameter[]
            {
                GetParameter(PARM_PUBLISHMENT_SYSTEM_ID, EDataType.Integer, keywordInfo.PublishmentSystemID),
                GetParameter(PARM_KEYWORDS, EDataType.NVarChar, 255, keywordInfo.Keywords),
                GetParameter(PARM_IS_DISABLED, EDataType.VarChar, 18, keywordInfo.IsDisabled.ToString()),
                GetParameter(PARM_KEYWORD_TYPE, EDataType.VarChar, 50, EKeywordTypeUtils.GetValue(keywordInfo.KeywordType)),
                GetParameter(PARM_MATCH_TYPE, EDataType.VarChar, 50, EMatchTypeUtils.GetValue(keywordInfo.MatchType)),
                GetParameter(PARM_REPLY, EDataType.NText, keywordInfo.Reply),
                GetParameter(PARM_ADD_DATE, EDataType.DateTime, keywordInfo.AddDate),
                GetParameter(PARM_TAXIS, EDataType.Integer, taxis)
            };

            using (var conn = GetConnection())
            {
                conn.Open();
                using (var trans = conn.BeginTransaction())
                {
                    try
                    {
                        ExecuteNonQuery(trans, sqlString, parms);
                        keywordID = BaiRongDataProvider.DatabaseDao.GetSequence(trans, "wx_Keyword");
                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }

            foreach (var str in TranslateUtils.StringCollectionToStringList(keywordInfo.Keywords, ' '))
            {
                var keyword = str.Trim();
                if (!string.IsNullOrEmpty(keyword))
                {
                    DataProviderWX.KeywordMatchDAO.Insert(new KeywordMatchInfo(0, keywordInfo.PublishmentSystemID, keyword, keywordID, keywordInfo.IsDisabled, keywordInfo.KeywordType, keywordInfo.MatchType));
                }
            }

            return(keywordID);
        }
示例#19
0
        private static void PreformStep(TestInfo testInfo, ProjectInfo projectInfo, Suite test, StepInfo step)
        {
            stepTimer.Start();
            ControlInfo controlInfo = null;
            XpathInfo   pathInfo    = null;
            ActionInfo  actionInfo  = null;
            KeywordInfo keywordInfo = null;

            PopulateStepInformation(test, step, ref controlInfo, ref pathInfo, ref actionInfo, ref keywordInfo);
            ConsoleLogger.LogStepInfo();
            ExecuteKeyword(testInfo, projectInfo, test, step, keywordInfo);

            ExecuteAction(test, step, controlInfo, pathInfo, actionInfo);
            stepTimer.Stop();
        }
示例#20
0
        public int Insert(KeywordInfo keywordInfo)
        {
            var keywordId = 0;

            var sqlString = "INSERT INTO wx_Keyword (PublishmentSystemID, Keywords, IsDisabled, KeywordType, MatchType, Reply, AddDate, Taxis) VALUES (@PublishmentSystemID, @Keywords, @IsDisabled, @KeywordType, @MatchType, @Reply, @AddDate, @Taxis)";

            var taxis = GetMaxTaxis(keywordInfo.PublishmentSystemId, keywordInfo.KeywordType) + 1;
            var parms = new IDataParameter[]
            {
                GetParameter(ParmPublishmentSystemId, EDataType.Integer, keywordInfo.PublishmentSystemId),
                GetParameter(ParmKeywords, EDataType.NVarChar, 255, keywordInfo.Keywords),
                GetParameter(ParmIsDisabled, EDataType.VarChar, 18, keywordInfo.IsDisabled.ToString()),
                GetParameter(ParmKeywordType, EDataType.VarChar, 50, EKeywordTypeUtils.GetValue(keywordInfo.KeywordType)),
                GetParameter(ParmMatchType, EDataType.VarChar, 50, EMatchTypeUtils.GetValue(keywordInfo.MatchType)),
                GetParameter(ParmReply, EDataType.NText, keywordInfo.Reply),
                GetParameter(ParmAddDate, EDataType.DateTime, keywordInfo.AddDate),
                GetParameter(ParmTaxis, EDataType.Integer, taxis)
            };

            using (var conn = GetConnection())
            {
                conn.Open();
                using (var trans = conn.BeginTransaction())
                {
                    try
                    {
                        keywordId = ExecuteNonQueryAndReturnId(trans, sqlString, parms);
                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }

            foreach (var str in TranslateUtils.StringCollectionToStringList(keywordInfo.Keywords, ' '))
            {
                var keyword = str.Trim();
                if (!string.IsNullOrEmpty(keyword))
                {
                    DataProviderWx.KeywordMatchDao.Insert(new KeywordMatchInfo(0, keywordInfo.PublishmentSystemId, keyword, keywordId, keywordInfo.IsDisabled, keywordInfo.KeywordType, keywordInfo.MatchType));
                }
            }

            return(keywordId);
        }
示例#21
0
 private void UpdateKeywordsToTable(int generalId, DataTable dataTable)
 {
     DataRow[] rowArray = dataTable.Select("FieldName = 'keyword'");
     if (rowArray.Length > 0)
     {
         string str = rowArray[0]["FieldValue"].ToString();
         if (!string.IsNullOrEmpty(str))
         {
             KeywordInfo keywordById = EasyOne.Accessories.Keywords.GetKeywordById(generalId);
             if (str != keywordById.KeywordText)
             {
                 this.SaveKeywordToTable(str, generalId);
             }
         }
     }
 }
示例#22
0
        public List <KeywordInfo> GetKeywordInfoList()
        {
            var list = new List <KeywordInfo>();

            using (var rdr = ExecuteReader(SqlSelectAll))
            {
                while (rdr.Read())
                {
                    var i           = 0;
                    var keywordInfo = new KeywordInfo(GetInt(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), EKeywordGradeUtils.GetEnumType(GetString(rdr, i)));
                    list.Add(keywordInfo);
                }
                rdr.Close();
            }
            return(list);
        }
示例#23
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isChanged = false;

            try
            {
                var grade = EKeywordGradeUtils.GetEnumType(ddlGrade.SelectedValue);

                var keywordArray = tbKeywords.Text.Split(',');
                foreach (var item in keywordArray)
                {
                    if (!string.IsNullOrEmpty(item))
                    {
                        var value       = item.Trim();
                        var keyword     = string.Empty;
                        var alternative = string.Empty;

                        if (value.IndexOf('|') != -1)
                        {
                            keyword     = value.Split('|')[0];
                            alternative = value.Split('|')[1];
                        }
                        else
                        {
                            keyword = value;
                        }

                        if (!string.IsNullOrEmpty(keyword) && !DataProvider.KeywordDao.IsExists(keyword))
                        {
                            var keywordInfo = new KeywordInfo(0, keyword, alternative, grade);
                            DataProvider.KeywordDao.Insert(keywordInfo);
                        }
                    }
                }

                isChanged = true;
            }
            catch (Exception ex)
            {
                FailMessage(ex, "导入敏感词失败");
            }

            if (isChanged)
            {
                PageUtils.CloseModalPage(Page);
            }
        }
示例#24
0
        internal int Keyword_Insert(KeywordInfo info)
        {
            var sql = "INSERT INTO [dbo].[Keyword]([ChineseName], [PingyingName], [FirstLetter], [Status], [TypeID], [Creator], [CreateTime], [Updater], [UpdateTime]) VALUES (@ChineseName, @PingyingName, @FirstLetter, @Status, @TypeID, @Creator, @CreateTime, @Creator, @CreateTime);select SCOPE_IDENTITY();";

            var cmd = dbw.GetSqlStringCommand(sql);

            dbw.AddInParameter(cmd, "ChineseName", DbType.String, info.ChineseName);
            dbw.AddInParameter(cmd, "PingYingName", DbType.String, info.PingyingName);
            dbw.AddInParameter(cmd, "Firstletter", DbType.String, info.FirstLetter);
            dbw.AddInParameter(cmd, "Status", DbType.Int32, info.Status);
            dbw.AddInParameter(cmd, "TypeID", DbType.Int32, info.TypeID);
            dbw.AddInParameter(cmd, "Creator", DbType.String, info.Creator);
            dbw.AddInParameter(cmd, "CreateTime", DbType.DateTime, info.CreateTime);
            var result = int.Parse(dbw.ExecuteScalar(cmd).ToString());

            return(result);
        }
        /// <summary>
        /// Selected keyword changed event handler.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event arguments.</param>
        private void listBoxKeywords_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            // Get selected keyword
            KeywordInfo keywordInfo = _listBoxKeywords.SelectedItem as KeywordInfo;

            if (keywordInfo != null)
            {
                // Show description of the selected keyword
                this._labelDescription.Text = keywordInfo.Description.Replace("\\n", "\n");

                // Check if keyword support value formatting
                _groupBoxFormat.Enabled = keywordInfo.SupportsFormatting;

                // Check if keyword support Y value index
                _labelYValue.Enabled         = keywordInfo.SupportsValueIndex;
                _numericUpDownYValue.Enabled = keywordInfo.SupportsValueIndex && this._maxYValueIndex > 0;
                this._labelYValue.Enabled    = keywordInfo.SupportsValueIndex && this._maxYValueIndex > 0;
            }
        }
示例#26
0
        public KeywordInfo GetKeywordInfo(int id)
        {
            var keywordInfo = new KeywordInfo();

            var parms = new IDataParameter[]
            {
                GetParameter(ParmId, DataType.Integer, id)
            };

            using (var rdr = ExecuteReader(SqlSelect, parms))
            {
                if (rdr.Read())
                {
                    var i = 0;
                    keywordInfo = new KeywordInfo(GetInt(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), EKeywordGradeUtils.GetEnumType(GetString(rdr, i)));
                }
                rdr.Close();
            }
            return(keywordInfo);
        }
示例#27
0
        private static void PopulateStepInformation(Suite test, StepInfo step, ref ControlInfo controlInfo, ref XpathInfo pathInfo, ref ActionInfo actionInfo, ref KeywordInfo keywordInfo)
        {
            if (step.action != "")
            {
                actionInfo = new ActionInfo().Populate(step.action);
            }
            if (step.keyword != "")
            {
                keywordInfo = new KeywordInfo().Populate(step.keyword, test.projectName);
            }

            if (step.controlName != "")
            {
                controlInfo = new ControlInfo().Populate(step.controlName, test.projectName);
                if (controlInfo.xpathName != "")
                {
                    pathInfo = new XpathInfo().Populate(controlInfo.xpathName.ToString(), test.projectName);
                }
            }
        }
 private static void GetKeywordsFromMaterials()
 {
     foreach (Material material in materials)
     {
         foreach (string keyword in material.shaderKeywords)
         {
             if (keywordInfoDict.ContainsKey(keyword))
             {
                 keywordInfoDict[keyword].materials.Add(material);
             }
             else
             {
                 KeywordInfo info = new KeywordInfo(keyword);
                 info.materials.Add(material);
                 keywordInfoDict.Add(keyword, info);
             }
         }
     }
     keywordInfoDict = keywordInfoDict.OrderBy((item) => item.Key).ToDictionary((item) => item.Key, (item) => item.Value);
 }
示例#29
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!base.IsPostBack)
     {
         string str = BasePage.RequestString("Action", "Add");
         this.ViewState["action"] = str;
         if (str == "Modify")
         {
             this.EBtnSubmit.Text = "修 改";
             KeywordInfo keywordById = Keywords.GetKeywordById(BasePage.RequestInt32("KeywordID"));
             if (!keywordById.IsNull)
             {
                 this.TxtKeywordText.Text           = keywordById.KeywordText;
                 this.TxtPriority.Text              = keywordById.Priority.ToString();
                 this.RadlKeywordType.SelectedValue = keywordById.KeywordType.ToString();
                 this.HdnKeywordText.Value          = keywordById.KeywordText.ToString();
             }
         }
     }
 }
示例#30
0
        public List <KeywordInfo> GetKeywordInfoList(int publishmentSystemID)
        {
            var list = new List <KeywordInfo>();

            var parms = new IDataParameter[]
            {
                GetParameter(PARM_PUBLISHMENT_SYSTEM_ID, EDataType.Integer, publishmentSystemID)
            };

            using (var rdr = ExecuteReader(SQL_SELECT_ALL, parms))
            {
                while (rdr.Read())
                {
                    var keywordInfo = new KeywordInfo(rdr.GetInt32(0), rdr.GetInt32(1), rdr.GetValue(2).ToString(), TranslateUtils.ToBool(rdr.GetValue(3).ToString()), EKeywordTypeUtils.GetEnumType(rdr.GetValue(4).ToString()), EMatchTypeUtils.GetEnumType(rdr.GetValue(5).ToString()), rdr.GetValue(6).ToString(), rdr.GetDateTime(7), rdr.GetInt32(8));
                    list.Add(keywordInfo);
                }
                rdr.Close();
            }

            return(list);
        }
        //=====================================================================
        /// <summary>
        /// Parse the given set of files to generate title and keyword info
        /// and localize the files if necessary.
        /// </summary>
        /// <param name="fileFolder">The folder containing the files to parse</param>
        /// <param name="localizedOutputFolder">The folder in which to store localized
        /// output or null for no localized output.</param>
        private static void ParseFiles(string fileFolder, string localizedOutputFolder)
        {
            KeywordInfo kw;
            string[] fileList;
            string ext, folder, destFile, mainEntry = String.Empty;
            int htmlFiles = 0;

            keywords.Clear();
            titles.Clear();

            if(fileFolder.Length != 0 && fileFolder[fileFolder.Length - 1] == '\\')
                fileFolder = fileFolder.Substring(0, fileFolder.Length - 1);

            // Process all *.htm and *.html files in the given folder and all of its subfolders.
            fileList = Directory.GetFiles(fileFolder, "*.*", SearchOption.AllDirectories);

            foreach(string file in fileList)
            {
                ext = Path.GetExtension(file).ToLower(CultureInfo.InvariantCulture);

                if(ext == ".htm" || ext == ".html")
                {
                    ProcessFile(fileFolder, file, localizedOutputFolder);
                    htmlFiles++;
                }
                else
                    if(localizedOutputFolder != null)
                    {
                        // Copy supporting files only if localizing
                        destFile = Path.Combine(localizedOutputFolder, file.Substring(fileFolder.Length + 1));
                        folder = Path.GetDirectoryName(destFile);

                        if(!Directory.Exists(folder))
                            Directory.CreateDirectory(folder);

                        File.Copy(file, destFile, true);
                    }
            }

            Console.WriteLine("Processed {0} HTML files\r\nSorting keywords and generating See Also indices", htmlFiles);

            // Sort the keywords
            keywords.Sort((x, y) =>
            {
                string subX, subY;

                if(x.MainEntry != y.MainEntry)
                    return String.Compare(x.MainEntry, y.MainEntry, StringComparison.OrdinalIgnoreCase);

                subX = x.SubEntry;
                subY = y.SubEntry;

                if(subX == null)
                    subX = String.Empty;

                if(subY == null)
                    subY = String.Empty;

                if(subX != subY)
                    return String.Compare(subX, subY, StringComparison.OrdinalIgnoreCase);

                return String.Compare(x.File, y.File, StringComparison.OrdinalIgnoreCase);
            });

            // Insert the See Also indices for each sub-entry
            for(int idx = 0; idx < keywords.Count; idx++)
                if(!String.IsNullOrEmpty(keywords[idx].SubEntry))
                {
                    if(idx > 0)
                        mainEntry = keywords[idx - 1].MainEntry;

                    if(mainEntry != keywords[idx].MainEntry)
                    {
                        kw = new KeywordInfo();
                        kw.MainEntry = keywords[idx].MainEntry;
                        keywords.Insert(idx, kw);
                    }
                }
        }
        /// <summary>
        /// Parse each file looking for the title and index keywords and remove the unnecessary Help 2 constructs
        /// that cause issues in Internet Explorer 10.
        /// </summary>
        /// <param name="basePath">The base folder path</param>
        /// <param name="sourceFile">The file to parse</param>
        /// <param name="localizedOutputFolder">The folder in which to store localized output or null for no
        /// localized output.</param>
        private static void ProcessFile(string basePath, string sourceFile, string localizedOutputFolder)
        {
            Encoding currentEncoding = Encoding.Default;
            MatchCollection matches;
            Match match;
            KeywordInfo keyword;
            string content, topicTitle, tocTitle, term, folder, key, destFile;
            byte[] currentBytes, convertedBytes;

            // Read the file in using the proper encoding
            using(StreamReader sr = new StreamReader(sourceFile, currentEncoding, true))
            {
                content = sr.ReadToEnd();
                currentEncoding = sr.CurrentEncoding;
            }

            topicTitle = tocTitle = String.Empty;

            // Extract the topic title
            match = reTitle.Match(content);

            if(match.Success)
                topicTitle = match.Groups[1].Value;

            // If a TOC title entry is present, get that too
            match = reTocTitle.Match(content);

            if(match.Success)
                tocTitle = match.Groups[1].Value;

            key = Path.GetFileNameWithoutExtension(sourceFile);

            if(!titles.TryAdd(key, new TitleInfo(WebUtility.HtmlDecode(topicTitle),
              WebUtility.HtmlDecode(tocTitle), sourceFile)))
                Console.WriteLine("SHFB: Warning SHE0004: The key '{0}' used for '{1}' is already in use by '{2}'.  " +
                    "'{1}' will be ignored.", key, sourceFile, titles[key].File);

            // Extract K index keywords
            matches = reKKeyword.Matches(content);

            foreach(Match m in matches)
            {
                keyword = new KeywordInfo();
                term = m.Groups[1].Value;

                if(!String.IsNullOrEmpty(term))
                {
                    term = WebUtility.HtmlDecode(term.Replace("%3C", "<").Replace("%3E", ">").Replace("%2C", ","));

                    // See if there is a sub-entry
                    match = reSubEntry.Match(term);

                    if(match.Success)
                    {
                        keyword.MainEntry = term.Substring(0, match.Index);
                        keyword.SubEntry = term.Substring(match.Index + 1).TrimStart(new char[] { ' ' });
                    }
                    else
                        keyword.MainEntry = term;

                    keyword.File = sourceFile;
                    keywordBag.Add(keyword);
                }
            }

            // Remove the XML data island, the MS Help CSS link, and the unused namespaces
            content = reXmlIsland.Replace(content, String.Empty);
            content = reHxLinkCss.Replace(content, String.Empty);

            Match htmlMatch = reHtmlElement.Match(content);
            string htmlElement = reUnusedNamespaces.Replace(htmlMatch.Value, String.Empty);
            
            content = reHtmlElement.Replace(content, htmlElement, 1);

            // If localizing, perform the substitutions, convert the encoding, and save the file to the
            // localized folder using the appropriate encoding.
            if(localizedOutputFolder != null)
            {
                foreach(KeyValuePair<Regex, string> pair in patterns)
                    content = pair.Key.Replace(content, pair.Value);

                currentBytes = currentEncoding.GetBytes(content);
                convertedBytes = Encoding.Convert(currentEncoding, destEncoding, currentBytes);

                destFile = Path.Combine(localizedOutputFolder, sourceFile.Substring(basePath.Length + 1));
                folder = Path.GetDirectoryName(destFile);

                if(!Directory.Exists(folder))
                    Directory.CreateDirectory(folder);

                using(StreamWriter writer = new StreamWriter(destFile, false, destEncoding))
                {
                    writer.Write(destEncoding.GetString(convertedBytes));
                }
            }

            // Save the file to its original location without the Help 2 elements using the original encoding
            using(StreamWriter writer = new StreamWriter(sourceFile, false, currentEncoding))
            {
                writer.Write(content);
            }
        }
        //=====================================================================

        /// <summary>
        /// Parse the given set of files to generate title and keyword info
        /// and localize the files if necessary.
        /// </summary>
        /// <param name="fileFolder">The folder containing the files to parse</param>
        /// <param name="localizedOutputFolder">The folder in which to store localized
        /// output or null for no localized output.</param>
        private static void ParseFiles(string fileFolder, string localizedOutputFolder)
        {
            KeywordInfo kw;
            string mainEntry = String.Empty;
            int htmlFiles = 0;

            keywords.Clear();
            keywordBag = new ConcurrentBag<KeywordInfo>();
            titles.Clear();

            if(fileFolder.Length != 0 && fileFolder[fileFolder.Length - 1] == '\\')
                fileFolder = fileFolder.Substring(0, fileFolder.Length - 1);

            // Process all *.htm and *.html files in the given folder and all of its subfolders.
            Parallel.ForEach(Directory.EnumerateFiles(fileFolder, "*.*", SearchOption.AllDirectories),
              new ParallelOptions { MaxDegreeOfParallelism = maxDegreeOfParallelism }, file =>
            {
                string ext = Path.GetExtension(file).ToLowerInvariant();

                if(ext == ".htm" || ext == ".html")
                {
                    ProcessFile(fileFolder, file, localizedOutputFolder);
                    Interlocked.Add(ref htmlFiles, 1);
                }
                else
                    if(localizedOutputFolder != null)
                    {
                        // Copy supporting files only if localizing
                        string destFile = Path.Combine(localizedOutputFolder, file.Substring(fileFolder.Length + 1));
                        string folder = Path.GetDirectoryName(destFile);

                        if(!Directory.Exists(folder))
                            Directory.CreateDirectory(folder);

                        File.Copy(file, destFile, true);
                    }
            });

            Console.WriteLine("Processed {0} HTML files\r\nSorting keywords and generating See Also indices", htmlFiles);

            // Sort the keywords
            keywords.AddRange(keywordBag);
            keywords.Sort((x, y) =>
            {
                string subX, subY;

                if(x.MainEntry != y.MainEntry)
                    return String.Compare(x.MainEntry, y.MainEntry, StringComparison.OrdinalIgnoreCase);

                subX = x.SubEntry;
                subY = y.SubEntry;

                if(subX == null)
                    subX = String.Empty;

                if(subY == null)
                    subY = String.Empty;

                if(subX != subY)
                    return String.Compare(subX, subY, StringComparison.OrdinalIgnoreCase);

                subX = titles[Path.GetFileNameWithoutExtension(x.File)].TopicTitle;
                subY = titles[Path.GetFileNameWithoutExtension(y.File)].TopicTitle;

                return String.Compare(subX, subY, StringComparison.OrdinalIgnoreCase);
            });

            // Insert the See Also indices for each sub-entry
            for(int idx = 0; idx < keywords.Count; idx++)
                if(!String.IsNullOrEmpty(keywords[idx].SubEntry))
                {
                    if(idx > 0)
                        mainEntry = keywords[idx - 1].MainEntry;

                    if(mainEntry != keywords[idx].MainEntry)
                    {
                        kw = new KeywordInfo();
                        kw.MainEntry = keywords[idx].MainEntry;
                        keywords.Insert(idx, kw);
                    }
                }
        }
        /// <summary>
        /// Parse each file looking for the title and index keywords
        /// </summary>
        /// <param name="basePath">The base folder path</param>
        /// <param name="sourceFile">The file to parse</param>
        /// <param name="localizedOutputFolder">The folder in which to store localized
        /// output or null for no localized output.</param>
        private static void ProcessFile(string basePath, string sourceFile, string localizedOutputFolder)
        {
            Encoding currentEncoding = Encoding.Default;
            MatchCollection matches;
            Match match;
            KeywordInfo keyword;
            string content, title, term, folder, key;
            byte[] currentBytes, convertedBytes;

            // Read the file in using the proper encoding
            using(StreamReader sr = new StreamReader(sourceFile, currentEncoding, true))
            {
                content = sr.ReadToEnd();
                currentEncoding = sr.CurrentEncoding;
            }

            title = String.Empty;

            // Extract the title
            match = reTitle.Match(content);

            if(match.Success)
                title = match.Groups[1].Value;

            // If a TOC title entry is present, use that instead
            match = reTocTitle.Match(content);

            if(match.Success)
                title = match.Groups[1].Value;

            key = Path.GetFileNameWithoutExtension(sourceFile);

            if(titles.ContainsKey(key))
                Console.WriteLine("SHFB: Warning SHE0004: The key '{0}' used for '{1}' is already in use by '{2}'.  " +
                    "'{1}' will be ignored.", key, sourceFile, titles[key].File);
            else
                titles.Add(key, new TitleInfo(HttpUtility.HtmlDecode(title), sourceFile));

            // Extract K index keywords
            matches = reKKeyword.Matches(content);

            foreach(Match m in matches)
            {
                keyword = new KeywordInfo();
                term = m.Groups[1].Value;

                if(!String.IsNullOrEmpty(term))
                {
                    term = HttpUtility.HtmlDecode(term.Replace("%3C", "<").Replace("%3E", ">").Replace("%2C", ","));

                    // See if there is a sub-entry
                    match = reSubEntry.Match(term);

                    if(match.Success)
                    {
                        keyword.MainEntry = term.Substring(0, match.Index);
                        keyword.SubEntry = term.Substring(match.Index + 1).TrimStart(new char[] { ' ' });
                    }
                    else
                        keyword.MainEntry = term;

                    keyword.File = sourceFile;
                    keywords.Add(keyword);
                }
            }

            // If localizing, perform the substitutions, convert the encoding, and save the
            // file to the localized folder.
            if(localizedOutputFolder != null)
            {
                foreach(KeyValuePair<Regex, string> pair in patterns)
                    content = pair.Key.Replace(content, pair.Value);

                currentBytes = currentEncoding.GetBytes(content);
                convertedBytes = Encoding.Convert(currentEncoding, destEncoding, currentBytes);

                sourceFile = Path.Combine(localizedOutputFolder, sourceFile.Substring(basePath.Length + 1));
                folder = Path.GetDirectoryName(sourceFile);

                if(!Directory.Exists(folder))
                    Directory.CreateDirectory(folder);

                using(StreamWriter writer = new StreamWriter(sourceFile, false, destEncoding))
                {
                    writer.Write(destEncoding.GetString(convertedBytes));
                }
            }
        }