private IEnumerable <string> insertTags(IEnumerable <string> tags) { IEnumerable <string> newtags = null; using (FileDataModelContainer db = new FileDataModelContainer()) { var query = from c in db.TagTable //where !tags.Contains(c.tag) select c.tag; newtags = tags.Except(query).ToList(); foreach (string t in newtags) { TagTable tabtable = new TagTable(); tabtable.tag = t; db.AddToTagTable(tabtable); } db.SaveChanges(); } return(newtags); }
private void setDetailView() { var panel = ViewSplitContainer.Panel2; detailview = new DetailView(); detailview.OnChagedName += (sender, args) => { updataListviewItem(getActiveListView(), args.guid, args.key, args.data); using (FileDataModelContainer db = new FileDataModelContainer()) { var query = from c in db.FileTable where c.guid == args.guid select c; foreach (FileTable ftable in query) { ftable.name = args.data; } db.SaveChanges(); } }; detailview.OnChagedComment += (sender, args) => { updataListviewItem(getActiveListView(), args.guid, args.key, args.data); using (FileDataModelContainer db = new FileDataModelContainer()) { var query = from c in db.FileTable where c.guid == args.guid select c; foreach (FileTable ftable in query) { ftable.comment = args.data; } db.SaveChanges(); } }; detailview.Dock = DockStyle.Fill; panel.Controls.Add(detailview); }
private void insertFileData(IEnumerable<string> fullpaths, List<string> tags) { using (FileDataModelContainer db = new FileDataModelContainer()) { foreach (string fullpath in fullpaths) { string strguid = Win32.getObjectID(fullpath).ToString(); var query = from c in db.FileTable where c.guid == strguid select c; if(query.Count() == 0){ FileInfo fileinfo = new FileInfo(fullpath); //FileTable filetable = new FileTable(){ // guid=strguid, // name=fileinfo.Name, // ext=fileinfo.Extension, // comment="", // createtime=fileinfo.CreationTime //}; FileTable filetable = new FileTable(); filetable.guid = strguid; filetable.name = fileinfo.Name; filetable.size = fileinfo.Length; filetable.ext = fileinfo.Extension; filetable.comment = ""; filetable.creationtime = fileinfo.CreationTime; filetable.lastwritetime = fileinfo.LastWriteTime; db.AddToFileTable(filetable); db.SaveChanges(); foreach (string tag in tags) { filetable.TagTable.Add(new TagTable() { tag = tag, FileTable = filetable }); } //var fquery = from c in db.FileTable // where c.guid == strguid // select c; //foreach (FileTable f in fquery) { //db.AttachTo(filetable.EntityKey.EntitySetName, // new FileTable() { filetableid = filetable.filetableid }); // foreach (string tag in tags) { // db.AddToTagTable(new TagTable() { tag = tag, FileTable = filetable }); // } //} //TagTable tagtable = new TagTable() { id = filetable.TagTable.id }; //db.AttachTo("FileTable", new FileTable() { filetableid = filetable.filetableid }); //foreach (string tag in tags) { // db.AddToTagTable(new TagTable() { tag = tag, FileTable = filetable }); //} }else{ foreach (FileTable filetable in query) { //var queryt = from c in db.TagTable // where c.FileTable.filetableid == filetable.filetableid // select c.tag; foreach (string tag in tags) { //Console.WriteLine("tag = " + tag); filetable.TagTable.Add(new TagTable() { tag = tag, FileTable = filetable }); } //db.AttachTo("FileTable", new FileTable() { filetableid = filetable.filetableid }); //foreach (string tag in tags) { // //db.AddToTagTable(new TagTable() { tag = tag, FileTable = filetable }); // filetable.TagTable.Add(new TagTable() { tag = tag, FileTable = filetable }); //} } } } db.SaveChanges(); } }
private IEnumerable<string> insertTags(IEnumerable<string> tags) { IEnumerable<string> newtags = null; using (FileDataModelContainer db = new FileDataModelContainer()) { var query = from c in db.TagTable //where !tags.Contains(c.tag) select c.tag; newtags = tags.Except(query).ToList(); foreach(string t in newtags){ TagTable tabtable = new TagTable(); tabtable.tag = t; db.AddToTagTable(tabtable); } db.SaveChanges(); } return newtags; }
private void insertFileData(IEnumerable <string> fullpaths, List <string> tags) { using (FileDataModelContainer db = new FileDataModelContainer()) { foreach (string fullpath in fullpaths) { string strguid = Win32.getObjectID(fullpath).ToString(); var query = from c in db.FileTable where c.guid == strguid select c; if (query.Count() == 0) { FileInfo fileinfo = new FileInfo(fullpath); //FileTable filetable = new FileTable(){ // guid=strguid, // name=fileinfo.Name, // ext=fileinfo.Extension, // comment="", // createtime=fileinfo.CreationTime //}; FileTable filetable = new FileTable(); filetable.guid = strguid; filetable.name = fileinfo.Name; filetable.size = fileinfo.Length; filetable.ext = fileinfo.Extension; filetable.comment = ""; filetable.creationtime = fileinfo.CreationTime; filetable.lastwritetime = fileinfo.LastWriteTime; db.AddToFileTable(filetable); db.SaveChanges(); foreach (string tag in tags) { filetable.TagTable.Add(new TagTable() { tag = tag, FileTable = filetable }); } //var fquery = from c in db.FileTable // where c.guid == strguid // select c; //foreach (FileTable f in fquery) { //db.AttachTo(filetable.EntityKey.EntitySetName, // new FileTable() { filetableid = filetable.filetableid }); // foreach (string tag in tags) { // db.AddToTagTable(new TagTable() { tag = tag, FileTable = filetable }); // } //} //TagTable tagtable = new TagTable() { id = filetable.TagTable.id }; //db.AttachTo("FileTable", new FileTable() { filetableid = filetable.filetableid }); //foreach (string tag in tags) { // db.AddToTagTable(new TagTable() { tag = tag, FileTable = filetable }); //} } else { foreach (FileTable filetable in query) { //var queryt = from c in db.TagTable // where c.FileTable.filetableid == filetable.filetableid // select c.tag; foreach (string tag in tags) { //Console.WriteLine("tag = " + tag); filetable.TagTable.Add(new TagTable() { tag = tag, FileTable = filetable }); } //db.AttachTo("FileTable", new FileTable() { filetableid = filetable.filetableid }); //foreach (string tag in tags) { // //db.AddToTagTable(new TagTable() { tag = tag, FileTable = filetable }); // filetable.TagTable.Add(new TagTable() { tag = tag, FileTable = filetable }); //} } } } db.SaveChanges(); } }
private void setDetailView() { var panel = ViewSplitContainer.Panel2; detailview = new DetailView(); detailview.OnChagedName += (sender, args) => { updataListviewItem(getActiveListView(), args.guid, args.key, args.data); using (FileDataModelContainer db = new FileDataModelContainer()) { var query = from c in db.FileTable where c.guid == args.guid select c; foreach (FileTable ftable in query) { ftable.name = args.data; } db.SaveChanges(); } }; detailview.OnChagedComment += (sender, args) => { updataListviewItem(getActiveListView(), args.guid, args.key, args.data); using (FileDataModelContainer db = new FileDataModelContainer()) { var query = from c in db.FileTable where c.guid == args.guid select c; foreach (FileTable ftable in query) { ftable.comment = args.data; } db.SaveChanges(); } }; detailview.Dock = DockStyle.Fill; panel.Controls.Add(detailview); }