Ejemplo n.º 1
0
        public UInt32 GetMatchingFactor(DataItem item)
        {
            if (Content == null)
                return 100;

            if (Content.Length == 0)
                return 100;

            if (item.Key.Equals(Content, StringComparison.CurrentCultureIgnoreCase))
                return 100;

            UInt32 matchingFactor = 0;
            if (SearchUtil.DoesContainStringIngoreCase(item.Key, Content))
                matchingFactor += 20;

            if (SearchUtil.DoesContainStringIngoreCase(item.Title, Content))
                matchingFactor += 20;

            if (SearchUtil.DoesContainStringIngoreCase(item.Value, Content))
                matchingFactor += 20;

            if (SearchUtil.DoesContainStringIngoreCase(item.Comments, Content))
                matchingFactor += 20;

            return matchingFactor;
        }
Ejemplo n.º 2
0
        public void AddDataItem()
        {
            MemoryDataSource dataSource = new MemoryDataSource();

            // Item 1
            DataItem dataItem1 = new DataItem();
            dataItem1.Id = "dummyId";

            dataItem1.Key = "mk";
            dataItem1.Title = "mailTitle";
            dataItem1.Value = "this is the value of the mail item";
            dataItem1.Comments = "the comments for the mail is added here";

            dataItem1.Labels = "mail;dummy";
            dataItem1.AccessCounter = 2;

            bool bSucc = dataSource.AddDataItem(dataItem1);

            Assert.AreEqual(true, bSucc);

            dataItem1.Key = "newKey";

            // Verify the data isn't changed.
            Assert.AreEqual("mk", dataSource.GetDataItems()[0].Key);
        }
Ejemplo n.º 3
0
        public void CopyConstructor()
        {
            DataItem dataItem = new DataItem();
            dataItem.Id = "dummyId";

            dataItem.Key = "mk";
            dataItem.Title = "mailTitle";
            dataItem.Value = "mailValue";
            dataItem.Comments = "mailComments";

            dataItem.Labels = "mail;dummy";
            dataItem.AccessCounter = 2;

            DataItem newItem = new DataItem(dataItem);

            // Change the original one.
            dataItem.Id = "changed";
            dataItem.Key = "changed";
            dataItem.Title = "changed";
            dataItem.Value = "changed";
            dataItem.Comments = "changed";
            dataItem.Labels = "changed";
            dataItem.AccessCounter = 10;

            // Verify the clone item isn't changed
            Assert.AreEqual("dummyId", newItem.Id);
            Assert.AreEqual("mk", newItem.Key);
            Assert.AreEqual("mailTitle", newItem.Title);
            Assert.AreEqual("mailValue", newItem.Value);
            Assert.AreEqual("mailComments", newItem.Comments);
            Assert.AreEqual("mail;dummy", newItem.Labels);
            Assert.AreEqual(2, newItem.AccessCounter);
        }
Ejemplo n.º 4
0
        public bool AddDataItem(DataItem item)
        {
            item.Id = Id + mItemIndex.ToString();
            DataItem newItem = new DataItem(item);

            mDataItemList.Add(newItem);
            mItemIndex++;

            return true;
        }
Ejemplo n.º 5
0
 public void Constructor()
 {
     DataItem item = new DataItem();
     Assert.AreEqual("", item.Id);
     Assert.AreEqual("", item.Key);
     Assert.AreEqual("", item.Title);
     Assert.AreEqual("", item.Value);
     Assert.AreEqual("", item.Comments);
     Assert.AreEqual("", item.Labels);
     Assert.AreEqual(0, item.AccessCounter);
 }
Ejemplo n.º 6
0
        public List<DataItem> GetDataItems()
        {
            List<DataItem> clonedItemList = new List<DataItem>();

            foreach (DataItem tempItem in mDataItemList)
            {
                DataItem newItem = new DataItem(tempItem);
                clonedItemList.Add(newItem);
            }

            return clonedItemList;
        }
Ejemplo n.º 7
0
        public bool UpdateDataItem(DataItem item)
        {
            foreach (DataItem tempItem in mDataItemList)
            {
                if (tempItem.Id.Equals(item.Id, StringComparison.CurrentCultureIgnoreCase))
                {
                    tempItem.CloneFrom(item);
                    return true;
                }
            }

            return false;
        }
Ejemplo n.º 8
0
        public void GetMatchingFactor_20()
        {
            DataItem dataItem = new DataItem();
            dataItem.Id = "dummyId";

            dataItem.Key = "mk";
            dataItem.Title = "mailTitle";
            dataItem.Value = "this is the value of the mail item";
            dataItem.Comments = "the comments for the mail is added here";

            dataItem.Labels = "mail;dummy";
            dataItem.AccessCounter = 2;

            ContentFilter filter = new ContentFilter("title");

            UInt32 matchingFactor = filter.GetMatchingFactor(dataItem);

            Assert.AreEqual(20, matchingFactor);
        }
Ejemplo n.º 9
0
        public void AddDeleteDataItem()
        {
            MemoryDataSource dataSource = new MemoryDataSource();

            // Item 1
            DataItem dataItem1 = new DataItem();
            dataItem1.Id = "dummyId";

            dataItem1.Key = "mk";
            dataItem1.Title = "mailTitle";
            dataItem1.Value = "this is the value of the mail item";
            dataItem1.Comments = "the comments for the mail is added here";

            dataItem1.Labels = "mail;dummy";
            dataItem1.AccessCounter = 2;

            dataSource.AddDataItem(dataItem1);

            Assert.AreEqual(1, dataSource.GetDataItems().Count);

            // Item 2
            DataItem dataItem2 = new DataItem();
            dataItem2.Id = "dummyId";

            dataItem2.Key = "mk";
            dataItem2.Title = "mailTitle";
            dataItem2.Value = "this is the value of the mail item";
            dataItem2.Comments = "the comments for the mail is added here";

            dataItem2.Labels = "mail;dummy";
            dataItem2.AccessCounter = 2;

            dataSource.AddDataItem(dataItem2);

            Assert.AreEqual(2, dataSource.GetDataItems().Count);

            bool bSucc = dataSource.DeleteDataItem(dataSource.GetDataItems()[0].Id);

            Assert.AreEqual(true, bSucc);
            Assert.AreEqual(1, dataSource.GetDataItems().Count);
        }
Ejemplo n.º 10
0
        public void Search()
        {
            SimpleSearchEngine simpleSearchEngin = new SimpleSearchEngine();
            DataSourceManager dsManager = new DataSourceManager();
            MemoryDataSource dataSource = new MemoryDataSource();
            dsManager.AddDataSource(dataSource);

            // Item 1
            {
                DataItem dataItem = new DataItem();
                dataItem.Id = "dummyId";

                dataItem.Key = "mk";
                dataItem.Title = "mailTitle";
                dataItem.Value = "this is the value of the mail item";
                dataItem.Comments = "the comments for the mail is added here";

                dataItem.Labels = "mail;dummy";
                dataItem.AccessCounter = 2;

                dataSource.AddDataItem(dataItem);
            }
        }
Ejemplo n.º 11
0
        public Form1()
        {
            InitializeComponent();

            mSearchEngine = new SimpleSearchEngine();
            mDsManager = new DataSourceManager();
            mDataSource = new MemoryDataSource();
            mDsManager.AddDataSource(mDataSource);

            mExtToolMgr = new ExternalToolManager();

            bool bSucc = mExtToolMgr.Load("S:\\Build Tools\\pc\\_ExternalTools.xml");

            if(bSucc)
            {
                List<ExternalTool> extTools = mExtToolMgr.GetAllExternalTools();
                for (int i =0; i < extTools.Count; i++)
                {
                    ExternalTool et = extTools[i];
                    TitleList.Items.Add(et.GetTitle());

                    DataItem dataItem = new DataItem();
                    dataItem.Id = i.ToString();

                    dataItem.Key = et.GetTitle();
                    dataItem.Title = et.GetTitle();
                    dataItem.Value = et.GetCommand() + " " + et.GetParameter();
                    dataItem.Comments = i.ToString(); // save the indes in the comments

                    dataItem.Labels = "";
                    dataItem.AccessCounter = 0;

                    mDataSource.AddDataItem(dataItem);
                }
            }
        }
Ejemplo n.º 12
0
        public void Properties()
        {
            DataItem dataItem = new DataItem();
            dataItem.Id = "dummyId";

            dataItem.Key = "mk";
            dataItem.Title = "mailTitle";
            dataItem.Value = "mailValue";
            dataItem.Comments = "mailComments";

            dataItem.Labels = "mail;dummy";
            dataItem.AccessCounter = 2;

            // Change the original one.
            dataItem.Id = "changed";
            dataItem.Key = "changed";
            dataItem.Title = "changed";
            dataItem.Value = "changed";
            dataItem.Comments = "changed";
            dataItem.Labels = "changed";
            dataItem.AccessCounter = 10;

            // Verify the changes
            Assert.AreEqual("changed", dataItem.Id);
            Assert.AreEqual("changed", dataItem.Key);
            Assert.AreEqual("changed", dataItem.Title);
            Assert.AreEqual("changed", dataItem.Value);
            Assert.AreEqual("changed", dataItem.Comments);
            Assert.AreEqual("changed", dataItem.Labels);
            Assert.AreEqual(10, dataItem.AccessCounter);
        }
Ejemplo n.º 13
0
 public bool UpdateDataItem(DataItem item)
 {
     return false;
 }
Ejemplo n.º 14
0
 public bool AddDataItem(DataItem item)
 {
     return false;
 }
Ejemplo n.º 15
0
        public void CloneFrom(DataItem src)
        {
            Id = src.Id.Clone() as String;

            Key = src.Key.Clone() as String;
            Title = src.Title.Clone() as String;
            Value = src.Value.Clone() as String;
            Comments = src.Comments.Clone() as String;

            Labels = src.Labels.Clone() as String;
            AccessCounter = src.AccessCounter;
        }
Ejemplo n.º 16
0
 public DataItem(DataItem src)
 {
     CloneFrom(src);
 }