Exemplo n.º 1
0
        private void lstKeywords_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index < 0)
            {
                return;
            }

            e.DrawBackground();
            Graphics g = e.Graphics;

            // Hightlight selected item.
            g.FillRectangle(new SolidBrush(Color.White), e.Bounds);
            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                e.Graphics.FillRectangle(new SolidBrush(Color.LightGray), e.Bounds);
            }

            // Change font color according to KeywordsType.
            ListBox      lb      = (ListBox)sender;
            KeywordModel keyword = (KeywordModel)lb.Items[e.Index];

            if (keyword.Type == KeywordType.Normal)
            {
                g.DrawString(keyword.ToString(), e.Font, new SolidBrush(Color.Black), new PointF(e.Bounds.X, e.Bounds.Y));
            }
            else
            {
                g.DrawString(keyword.ToString(), e.Font, new SolidBrush(Color.Blue), new PointF(e.Bounds.X, e.Bounds.Y));
            }

            e.DrawFocusRectangle();
        }
Exemplo n.º 2
0
        public bool UpdateKeyword(KeywordModel model)
        {
            using (var connection = new SqlConnection(_connectionString))
            {
                string sQuery = @"    if exists (select * from Keywords where (KeywordName=@KeywordName))

                           Update Keywords set KeywordValues = @KeywordValues, KeywordName = @KeywordName, DateModified = getdate(),KeywordComment=@KeywordComment


                          Where  KeywordName= @KeywordName;

                            else Insert Into Keywords
                    (KeywordValues, KeywordName, KeywordComment,  DateModified)
                    Values (@KeywordValues, @KeywordName, @KeywordComment,getdate())  ";



                connection.Open();

                try
                {
                    connection.Execute(sQuery, model);
                    return(true);
                }
                catch (Exception e)
                {
                    Console.Write(e);
                    return(false);
                }
            }
        }
Exemplo n.º 3
0
        public ActionResult Keyword()
        {
            ViewBag.Message = "Keyword counter";
            KeywordModel model = new KeywordModel();

            return(View(model));
        }
Exemplo n.º 4
0
        private KeywordModel GetKeyword()
        {
            KeywordModel keyword = new KeywordModel();

            keyword.KeywordText = txtKeyword.Text;;
            keyword.Type        = toolBtnRegExp.Checked ? KeywordType.RegExp : KeywordType.Normal;
            return(keyword);
        }
Exemplo n.º 5
0
 public void RenderKeyword(KeywordModel keyword)
 {
     if (keyword != null)
     {
         txtKeyword.Text       = keyword.KeywordText;
         toolBtnRegExp.Checked = keyword.Type == KeywordType.RegExp;
     }
 }
        public string Render(Project project, EventSourceModel eventSource, KeywordModel model)
        {
            var output = EventSourceKeywordTemplate.Template_KEYWORD;

            output = output.Replace(EventSourceKeywordTemplate.Template_KEYWORD_NAME, model.Name);
            output = output.Replace(EventSourceKeywordTemplate.Template_KEYWORD_INDEX, model.Value.ToString());

            return(output);
        }
Exemplo n.º 7
0
        public ActionResult Keyword(KeywordModel model)
        {
            if (ModelState.IsValid)
            {
                return(Json(handler.getKeywordCountResult(model.keywords, model.url), JsonRequestBehavior.AllowGet));
            }

            return(Json("Invalid Inputs", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 8
0
 private static void AssertValidKeywordModel(KeywordModel keywordModel, string expectedTitle, string expectedDescription, string expectedKey, string subjectName)
 {
     Assert.IsNotNull(keywordModel, subjectName);
     Assert.AreEqual(expectedTitle, keywordModel.Title, subjectName + ".Title");
     Assert.AreEqual(expectedDescription, keywordModel.Description, subjectName + ".Description");
     Assert.AreEqual(expectedKey, keywordModel.Key, subjectName + ".Key");
     StringAssert.Matches(keywordModel.Id, new Regex(@"\d+"), subjectName + ".Id");
     StringAssert.Matches(keywordModel.TaxonomyId, new Regex(@"\d+"), subjectName + ".TaxonomyId");
 }
        public ActionResult Detail(int keywordID)
        {
            ViewBag.Message = "Keyword";
            ViewBag.UserID  = AccountManager.getLocalAccountID(User.Identity.Name).ToString();

            KeywordModel model = DatabaseAccessLayer.Instance.GetKeywordFromID(keywordID);

            return(View(model));
        }
        protected virtual object MapKeyword(KeywordModelData keywordModelData, Type targetType, ILocalization localization)
        {
            if (typeof(KeywordModel).IsAssignableFrom(targetType))
            {
                KeywordModel result;
                if (keywordModelData.SchemaId == null)
                {
                    result = new KeywordModel
                    {
                        ExtensionData = keywordModelData.ExtensionData
                    };
                }
                else
                {
                    MappingData keywordMappingData = new MappingData
                    {
                        SourceViewModel    = keywordModelData,
                        ModelType          = targetType,
                        PropertyValidation = new Validation
                        {
                            MainSchema       = SemanticMapping.GetSchema(keywordModelData.SchemaId, localization),
                            InheritedSchemas = GetInheritedSemanticSchemas(keywordModelData as ViewModelData, localization)
                        },
                        MetadataFields = keywordModelData.Metadata,
                        Localization   = localization
                    };

                    result = (KeywordModel)CreateViewModel(keywordMappingData);
                }

                result.Id          = keywordModelData.Id;
                result.Title       = keywordModelData.Title;
                result.Description = keywordModelData.Description ?? string.Empty;
                result.Key         = keywordModelData.Key ?? string.Empty;
                result.TaxonomyId  = keywordModelData.TaxonomyId;

                return(result);
            }

            if (targetType == typeof(Tag))
            {
                return(new Tag
                {
                    DisplayText = GetKeywordDisplayText(keywordModelData),
                    Key = keywordModelData.Key,
                    TagCategory = localization.GetCmUri(keywordModelData.TaxonomyId, (int)ItemType.Category)
                });
            }

            if (targetType == typeof(bool))
            {
                string key = string.IsNullOrEmpty(keywordModelData.Key) ? keywordModelData.Title : keywordModelData.Key;
                return(Convert.ToBoolean(key));
            }

            return(GetKeywordDisplayText(keywordModelData));
        }
Exemplo n.º 11
0
 private void SwapKeywordAt(Object sender, SwapPositionEventArgs args)
 {
     if (args.Src >= 0 && args.Src < keywords.Count && args.Dest >= 0 && args.Dest < keywords.Count)
     {
         KeywordModel tmp = keywords[args.Src];
         keywords[args.Src]  = keywords[args.Dest];
         keywords[args.Dest] = tmp;
         view.SelectKeywordAt(args.Dest);
     }
 }
Exemplo n.º 12
0
        public int Save(KeywordModel model)
        {
            Keyword keyword = new Keyword
            {
                Name = model.Name
            };

            keywordRepository.Save(keyword);
            return(keyword.Id);
        }
Exemplo n.º 13
0
        public JsonResult ListName(string term)
        {
            term = term.ToLower();
            var list = new KeywordModel().GetKeywords().Where(x => x.Name.ToLower().Contains(term)).Select(x => x.Name).Take(5);

            return(Json(new
            {
                data = list
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 14
0
 private void LaunchNppSearchDialogWithKeyword(KeywordModel keyword)
 {
     if (keyword != null)
     {
         Clipboard.SetText(keyword.ToString());
     }
     Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_MENUCOMMAND, 0, NppMenuCmd.IDM_SEARCH_FIND);
     if (keyword != null)
     {
         SendKeys.SendWait("^{v}");
     }
 }
		public static void ApplyKeywords(this IEnumerable<BaseLibraryLink> links, KeywordModel[] keywords)
		{
			foreach (var libraryLink in links)
			{
				libraryLink.Tags.Keywords.RemoveAll(tagForRemove =>
					!keywords.Any(k => String.Equals(k.Name, tagForRemove.Name, StringComparison.OrdinalIgnoreCase)));
				libraryLink.Tags.Keywords.AddRange(keywords
					.Where(tagForAdd => tagForAdd.IsShared && !libraryLink.Tags.Keywords.Any(k => String.Equals(k.Name, tagForAdd.Name, StringComparison.OrdinalIgnoreCase)))
					.Select(tag => new SearchTag { Name = tag.Name }));
				libraryLink.MarkAsModified();
			}
		}
Exemplo n.º 16
0
        private void OnKeywordSelected(Object sender, OnKeywordSelectedEventArgs args)
        {
            int index = args.Index;

            if (index < 0 || index >= keywords.Count)
            {
                return;
            }

            bool isSelectedIndexChanged = false;

            if (index != lastSelectedIndex)
            {
                isSelectedIndexChanged = true;
                lastSelectedIndex      = index;
                view.ShowStatusMessage(Properties.Resources.quick_search_status_initial_message, Color.Black);
            }

            KeywordModel keyword = keywords[index];

            if (args.Mouse == OnKeywordSelectedEventArgs.MouseButton.Left)
            {
                if (args.Key == OnKeywordSelectedEventArgs.KeyboardButton.Ctrl)
                {
                    LaunchNppSearchDialogWithKeyword(keyword);
                }
                else if (args.Key == OnKeywordSelectedEventArgs.KeyboardButton.Shift)
                {
                    ShowSearchingIndication();
                    using (Scintilla sci = new Scintilla())
                    {
                        int pos = sci.SearchBackward(keyword.ToString(),
                                                     keyword.Type == KeywordType.RegExp, args.MatchWord, args.MatchCase, args.WrapSearch);
                        ShowSearchResult(sci, pos);
                    }
                }
                else if (args.Key == OnKeywordSelectedEventArgs.KeyboardButton.None)
                {
                    if (!isSelectedIndexChanged)
                    {
                        ShowSearchingIndication();
                        using (Scintilla sci = new Scintilla())
                        {
                            int pos = sci.SearchForward(keyword.ToString(),
                                                        keyword.Type == KeywordType.RegExp, args.MatchWord, args.MatchCase, args.WrapSearch);
                            ShowSearchResult(sci, pos);
                        }
                    }
                }
            }
        }
Exemplo n.º 17
0
        public ActionResult ViewKeyWord(int id = 0)
        {
            KeywordModel vm = new KeywordModel();

            if (id != 0)
            {
                var keyword = _context.tblDocumentKeyWords.SingleOrDefault(x => x.Id == id);
                vm.KeyWordName = keyword.KeyWordName;
                vm.Id          = keyword.Id;
                vm.IsEdit      = true;
            }

            return(PartialView("_AddKeyword", vm));
        }
Exemplo n.º 18
0
        public ActionResult InsertKeyword([FromBody] KeywordModel model)
        {
            var isValid = validator.Validate(model);

            if (!isValid)
            {
                return(BadRequest(model));
            }
            var keyword   = mapper.Map <KeywordEntity>(model);
            var keywordId = keywordService.InsertKeyword(keyword);

            apiCuaNha.SendRestRequest(keyword);

            cacheService.UpdateCache(keyword);

            return(Created(keywordId, keyword));
        }
Exemplo n.º 19
0
        public ActionResult CreateKeyWord(KeywordModel vm)
        {
            tblDocumentKeyWord keyword = new tblDocumentKeyWord();

            if (vm.IsEdit)
            {
                keyword = _context.tblDocumentKeyWords.SingleOrDefault(x => x.Id == vm.Id);
            }

            keyword.KeyWordName = vm.KeyWordName;
            keyword.Id          = vm.Id;

            if (!vm.IsEdit)
            {
                _context.tblDocumentKeyWords.Add(keyword);
            }

            _context.SaveChanges();

            return(RedirectToAction("Keyword", new { area = "Document" }));
        }
Exemplo n.º 20
0
        public void Build(Project project, ProjectItem <EventSourceModel> eventSourceProjectItem, LoggerModel model)
        {
            if (model == null)
            {
                return;
            }
            var eventSource = eventSourceProjectItem.Content;

            if (eventSource == null)
            {
                LogError($"{eventSourceProjectItem.Name} should have a content of type {typeof(EventSourceModel).Name} set but found {eventSourceProjectItem.Content?.GetType().Name ?? "null"}");
                return;
            }
            var loggerKeyword = model.Keyword;

            model.SourceFileName = model.Name.Substring(1);
            var allKeywords = new List <KeywordModel>();

            allKeywords.AddRange(eventSource.Keywords);
            var nextKeyword = allKeywords.Any() ? allKeywords.Max(kw => kw.Value ?? 1) * 2 : 1;
            var keyword     = new KeywordModel()
            {
                Name = loggerKeyword, Value = nextKeyword
            };

            if (eventSource.Keywords.Find(loggerKeyword) == null)
            {
                allKeywords.Add(keyword);
            }

            eventSource.Keywords = allKeywords.ToArray();

            foreach (var loggerEvent in model.Events ?? new EventModel[0])
            {
                loggerEvent.Keywords = loggerEvent.Keywords.Add(keyword);
            }
        }
Exemplo n.º 21
0
        public bool UpdateKeyword([FromBody] KeywordModel model)
        {
            var result = _settingRepo.UpdateKeyword(model);

            return(result);
        }
Exemplo n.º 22
0
 public SearchEventArgs()
 {
     Keyword = new KeywordModel();
 }
Exemplo n.º 23
0
 public AddKeywordEventArgs(KeywordModel keyword)
 {
     this.Keyword = keyword;
 }
 public LaunchNppSearchDialogEventArgs(KeywordModel keyword)
 {
     this.Keyword = keyword;
 }
        /// <summary>
        /// Populates the dictionary with values from the item fields.
        /// </summary>
        /// <param name="itemFields">The Tridion itemfields to populate the dictionary with.</param>
        private void PopulateDynamicItemFields(ItemFields itemFields)
        {
            if (itemFields == null)
                return;

            foreach (ItemField itemField in itemFields)
            {
                string key = itemField.Name.ToLower();

                if (itemField is XhtmlField)
                {
                    XhtmlField xhtmlField = (XhtmlField)itemField;
                    if (xhtmlField.Definition.MaxOccurs == 1)
                        _dictionary[key] = TemplateUtilities.ResolveRichTextFieldXhtml(xhtmlField.Value);
                    else
                    {
                        List<string> values = new List<string>();
                        foreach (string value in xhtmlField.Values)
                        {
                            values.Add(TemplateUtilities.ResolveRichTextFieldXhtml(value));
                        }
                        _dictionary[key] = values;
                    }
                }
                else if (itemField is TextField)
                {
                    TextField textField = (TextField)itemField;
                    if (textField.Definition.MaxOccurs == 1)
                        _dictionary[key] = textField.Value;
                    else
                        _dictionary[key] = textField.Values;
                }
                else if (itemField is DateField)
                {
                    DateField dateField = (DateField)itemField;
                    if (dateField.Definition.MaxOccurs == 1)
                        _dictionary[key] = dateField.Value;
                    else
                        _dictionary[key] = dateField.Values;
                }
                else if (itemField is KeywordField)
                {
                    KeywordField keywordField = (KeywordField)itemField;
                    if (keywordField.Definition.MaxOccurs == 1)
                        if (keywordField.Value == null)
                            _dictionary[key] = null;
                        else
                            _dictionary[key] = new KeywordModel(_engine, keywordField.Value);
                    else
                    {
                        List<KeywordModel> keywords = new List<KeywordModel>();
                        int i = 0;
                        foreach (Keyword k in keywordField.Values)
                        {
                            var kw = new KeywordModel(_engine, k);
                            kw.Index = i++;
                            kw.IsLast = Index == keywordField.Values.Count - 1;
                            keywords.Add(kw);
                        }
                        _dictionary[key] = keywords;
                    }
                }
                else if (itemField is EmbeddedSchemaField)
                {
                    EmbeddedSchemaField embeddedSchemaField = (EmbeddedSchemaField)itemField;
                    if (embeddedSchemaField.Definition.MaxOccurs == 1)
                        if (embeddedSchemaField.Values.Count == 0)
                            _dictionary[key] = null;
                        else
                            _dictionary[key] = new DynamicItemFields(_engine, embeddedSchemaField.Value);
                    else
                    {
                        List<dynamic> embeddedFields = new List<dynamic>();

                        int i = 0;
                        foreach (ItemFields fields in embeddedSchemaField.Values)
                        {
                            var dif = new DynamicItemFields(_engine, fields);
                            dif.Index = i++;
                            dif.IsLast = dif.Index == embeddedSchemaField.Values.Count - 1;
                            embeddedFields.Add(dif);
                        }
                        _dictionary[key] = embeddedFields;
                    }
                }
                else if (itemField is ComponentLinkField)
                {
                    ComponentLinkField componentLinkField = (ComponentLinkField)itemField;
                    if (componentLinkField.Definition.MaxOccurs == 1)
                        if (componentLinkField.Value == null)
                            _dictionary[key] = null;
                        else
                            _dictionary[key] = new ComponentModel(_engine, componentLinkField.Value);
                    else
                    {
                        List<ComponentModel> components = new List<ComponentModel>();
                        int i = 0;
                        foreach (Component c in componentLinkField.Values)
                        {
                            var cm = new ComponentModel(_engine, c);
                            cm.Index = i++;
                            cm.IsLast = cm.Index == componentLinkField.Values.Count - 1;
                            components.Add(cm);
                        }
                        _dictionary[key] = components;
                    }
                }
                else if (itemField is ExternalLinkField)
                {
                    ExternalLinkField externalLink = (ExternalLinkField)itemField;
                    if (externalLink.Definition.MaxOccurs == 1)
                        _dictionary[key] = externalLink.Value;
                    else
                        _dictionary[key] = externalLink.Values;
                }
                else if (itemField is NumberField)
                {
                    NumberField numberField = (NumberField)itemField;
                    if (itemField.Definition.MaxOccurs == 1)
                        _dictionary[key] = numberField.Value;
                    else
                        _dictionary[key] = numberField.Values;
                }
                else
                {
                    _dictionary[key] = itemField.ToString();
                }
            }
        }
Exemplo n.º 26
0
 public UpdateKeywordAtEventArgs(int position, KeywordModel keyword)
 {
     this.Position = position;
     this.Keyword  = keyword;
 }