예제 #1
0
        private void OnAddTag()
        {
            string[] array = TagArray.Split(';');
            for (int i = 0; i < array.Length; i++)
            {
                if (string.IsNullOrEmpty(array[i]))
                {
                    continue;
                }
                DBTagInfo tagInfo = null;
                tagInfo = TotalTags.FirstOrDefault(item => (0 == string.Compare(array[i], item.Name)));
                if (tagInfo.IsNull())
                {
                    tagInfo = new DBTagInfo()
                    {
                        Name = array[i]
                    };
                    TotalTags.Add(tagInfo);
                }

                if (!tagInfo.IsNull())
                {
                    AddTag(tagInfo);
                }
            }
        }
예제 #2
0
 private void RemoveTag(DBTagInfo tagInfo)
 {
     if (Tags.Contains(tagInfo))
     {
         Tags.Remove(tagInfo);
     }
 }
예제 #3
0
        private void OnListBoxItemDoubleClick(object sender, MouseButtonEventArgs e)
        {
            ListBoxItem listBoxItem = e.Source as ListBoxItem;

            if (listBoxItem.IsNull())
            {
                return;
            }
            DBTagInfo tagInfo = listBoxItem.DataContext as DBTagInfo;

            if (tagInfo.IsNull())
            {
                return;
            }

            switch (listBoxItem.Tag.ToString())
            {
            case "Add":
                AddTag(tagInfo);
                break;

            case "Remove":
                RemoveTag(tagInfo);
                break;
            }
        }
예제 #4
0
        public bool InsertTag(DBTagInfo tagInfo)
        {
            bool bRel = false;

            if (null == tagInfo)
            {
                return(bRel);
            }
            string sqlInsertFormat = "INSERT INTO {0} (ID, VALUE) VALUES (NULL, @VALUE); " + DataAccess.SQL_SELECT_ID_LAST;
            string sqlInsert       = string.Format(sqlInsertFormat, DataAccess.TABLE_NAME_TAG);

            SQLiteParameter[] parms =
            {
                new SQLiteParameter("@VALUE", DbType.String)
            };
            parms[0].Value = tagInfo.Name;
            object objRel = SqliteHelper.ExecuteScalar(DataAccess.ConnectionStringProfile, CommandType.Text, sqlInsert, parms);

            if (null != objRel)
            {
                int id = Convert.ToInt32(objRel);
                tagInfo.ID = id;
                bRel       = true;
            }
            return(bRel);
        }
예제 #5
0
        public IList <DBTagInfo> GetContainTags(DBFileInfo monitoredFile)
        {
            IList <DBTagInfo> tagInfos = new List <DBTagInfo>();

            if (monitoredFile.IsNull())
            {
                return(tagInfos);
            }

            string[] array = monitoredFile.Tag.Split(';');
            for (int i = 0; i < array.Length; i++)
            {
                int tagId = -1;
                if (!Int32.TryParse(array[i], out tagId))
                {
                    continue;
                }
                DBTagInfo tagInfo = TagInfos.FirstOrDefault(tag => tag.ID == tagId);
                if (tagInfo.IsNull())
                {
                    continue;
                }
                tagInfos.Add(tagInfo);
            }
            return(tagInfos);
        }
예제 #6
0
 private void AddTag(DBTagInfo tagInfo)
 {
     if (Tags.Contains(tagInfo))
     {
         return;
     }
     Tags.Add(tagInfo);
 }
예제 #7
0
 private void OnTagSelected(DBTagInfo tag)
 {
     Files.Clear();
     if (!currentJob.IsNull())
     {
         JobManager.Instance.ForceStop(currentJob);
         currentJob = null;
     }
     currentJob = LoadMediasJob.Create(new LoadMediasJob.LoadPattern()
     {
         Category = LoadMediasJob.Category.Tag, keyword = tag.ID.ToString()
     });
     JobManager.Instance.AddJob(currentJob);
     JobManager.Instance.ForceStart(currentJob);
 }
예제 #8
0
        public IList <DBTagInfo> GetTags()
        {
            IList <DBTagInfo> tagList   = new List <DBTagInfo>();
            string            sqlSelect = "SELECT * FROM " + DataAccess.TABLE_NAME_TAG;
            SQLiteDataReader  dr        = SqliteHelper.ExecuteReader(DataAccess.ConnectionStringProfile, CommandType.Text, sqlSelect, null);

            while (dr.Read())
            {
                if (dr.IsDBNull(1))
                {
                    continue;
                }
                int       id      = dr.GetInt32(0);
                string    name    = dr.GetString(1);
                DBTagInfo tagInfo = new DBTagInfo()
                {
                    ID = id, Name = name
                };
                tagList.Add(tagInfo);
            }
            dr.Close();
            return(tagList);
        }
예제 #9
0
 private void OnTagSelected(DBTagInfo tag)
 {
     this.eventAggregator.GetEvent <TagChangedEvent>().Publish(tag);
 }
예제 #10
0
 public static bool InsertTag(DBTagInfo tagInfo)
 {
     return(iTag.InsertTag(tagInfo));
 }