public static CassetteInfo LoadCassette(string cassetteFolder, bool loaddata) { //var cassetteFolder = cassettePath.Value; if (!Directory.Exists(cassetteFolder) || (!File.Exists(cassetteFolder + "cassette.finfo") && false)) { return(null); } var cassette = new Cassette(cassetteFolder, loaddata); var cassetteInfo = new CassetteInfo { fullName = "iiss://" + cassette.Name + "@iis.nsk.su", cassette = cassette, url = cassette.Dir.FullName + '/', docsInfo = !loaddata ? new List <factograph.RDFDocumentInfo>() : cassette .DataDocuments() .Select(xDoc => new RDFDocumentInfo(xDoc, cassetteFolder)) .ToList() }; if (loaddata) { cassetteInfo.docsInfo.Add(new RDFDocumentInfo(cassette)); } return(cassetteInfo); }
public void Save() { db.Save(Dir.FullName + "/meta/" + Name + "_current.fog"); XElement xconfig = Cassette.RDFdb(Name + "_cassette_1", new XElement(ONames.TagSourcemeta, new XAttribute(SNames.rdfabout, Name + "config_1"), new XElement(ONames.TagFoldername, _folderNumber), new XElement(ONames.TagDocumentNumber, _documentNumber))); xconfig.Save(Dir.FullName + "/meta/" + Name + "_config.fog"); }
/// <summary> /// Создатель новой кассеты /// </summary> /// <param name="cassPath"></param> /// <returns></returns> static public Cassette Create(string cassPath) { string cass_name = cassPath.Split(Cassette.slashes).Last(); if (Directory.Exists(cassPath) && File.Exists(cassPath + "/cassette.finfo")) { return(new Cassette(cassPath)); } else { DirectoryInfo dir = Directory.Exists(cassPath) ? new DirectoryInfo(cassPath) : Directory.CreateDirectory(cassPath); // Специальная отметка для кассеты Cassette.finfo_default.Save(dir.FullName + "/cassette.finfo"); DirectoryInfo meta = Directory.CreateDirectory(cassPath + "/meta"); DirectoryInfo originals = Directory.CreateDirectory(cassPath + "/originals"); DirectoryInfo preview = Directory.CreateDirectory(cassPath + "/documents"); Directory.CreateDirectory(originals.FullName + "/0001"); DirectoryInfo small = Directory.CreateDirectory(preview.FullName + "/small/0001"); DirectoryInfo medium = Directory.CreateDirectory(preview.FullName + "/medium/0001"); DirectoryInfo normal = Directory.CreateDirectory(preview.FullName + "/normal/0001"); XElement xconfig = Cassette.RDFdb("configdb_" + cass_name + "_1", new XElement(ONames.TagSourcemeta, new XAttribute(SNames.rdfabout, "sourcemeta_" + cass_name + "_1"), new XElement(ONames.TagFoldername, "0001"), new XElement(ONames.TagDocumentNumber, "0001"))); xconfig.Save(meta.FullName + "/" + cass_name + "_config.fog"); string owner = "mag_9347"; string uri = "iiss://" + cass_name + "@iis.nsk.su/meta"; XElement xmetadb = Cassette.RDFdb(cass_name + "_current", new XAttribute(ONames.AttUri, uri), new XAttribute(ONames.AttOwner, owner), new XAttribute(ONames.AttPrefix, cass_name + "_"), new XAttribute(ONames.AttCounter, "1001"), new XElement(ONames.TagCassette, new XAttribute(SNames.rdfabout, cass_name + "_cassetteId"), new XElement(ONames.TagName, cass_name), new XElement(ONames.TagCassetteUri, uri)), new XElement(ONames.TagCollectionmember, new XAttribute(SNames.rdfabout, cass_name + "_cassetteId_cmId"), new XElement(ONames.TagIncollection, new XAttribute(SNames.rdfresource, "cassetterootcollection")), new XElement(ONames.TagCollectionitem, new XAttribute(SNames.rdfresource, cass_name + "_cassetteId")))); xmetadb.Save(meta.FullName + "/" + cass_name + "_current.fog"); return(new Cassette(dir, cass_name, "0001", "0001", xmetadb)); } }
/// <summary> /// Конструктор для основного документа кассеты /// </summary> /// <param name="cassette"></param> public RDFDocumentInfo(Cassette cassette) { this.uri = "iiss://" + cassette.Name + "@iis.nsk.su/meta"; filePath = cassette.Dir.FullName + "/meta/" + cassette.Name + "_current.fog"; dbId = cassette.dbId ?? (cassette.Name + "Id"); owner = cassette.owner; this.root = //File.Exists(filePath+".xml") ? XElement.Load(filePath+".xml") : XElement.Load(filePath); var pAtt = root.Attribute("prefix"); var cAtt = root.Attribute("counter"); if (pAtt != null && cAtt != null && Int32.TryParse(cAtt.Value, out counter)) { prefix = pAtt.Value; //isEditable = true; } }
private void SetCassette(Cassette cas) { this.Title = "В работе: " + cas.Name; this.cass = cas; this.BuildTreeView(); //// Построение маленьких имиджей и таблицы соответствия UriInd = new Dictionary<string, ImageInfo>(); //Далее может быть какое-то предвычисление // ....... // Построение списка меню пользователя user_menu_list = new List<RelationSpec>(); // Почистим имеющиеся чекбоксы while(toolBar1.Items[toolBar1.Items.Count - 1].GetType() != typeof(Separator)) toolBar1.Items.RemoveAt(toolBar1.Items.Count - 1); // Теперь сформируем чекбоксы и список меню foreach(XElement member in cass.GetInverseXItems("menurootcollection")) { // Нужно выявить коллекцию, в которую надо "помещать" документы var menu_position = member.Element(factograph.ONames.TagCollectionitem); if(menu_position == null) continue; XAttribute mp_att = menu_position.Attribute(ONames.rdfresource); if(mp_att == null) continue; string mp_id = mp_att.Value; CheckBox chb = new CheckBox() { Content=cass.GetXItemById(mp_id).Element(factograph.ONames.TagName).Value }; chb.Click += new RoutedEventHandler(ChangeState); RelationSpec rs = new RelationSpec() { relationName = factograph.ONames.TagCollectionmember, linkSelf = factograph.ONames.TagCollectionitem, linkOther = factograph.ONames.TagIncollection, idOther = mp_id, usedCheckbox = chb }; chb.Tag = rs; user_menu_list.Add(rs); toolBar1.Items.Add(chb); } // перепостроение правой панели ((TreeViewItem)treeView1.Items[0]).IsSelected = true; this.cassIsReady = true; // Привязка события появления необходимости в перевычислении превьюшек по видео //this.cass.NeedToCalculateVideoPreview += new EventHandler((sender, e) => { this.commandMakeVideo.Background = Brushes.AliceBlue; }); this.RefreshViewPort(); }
// Обработчики команд void commandLoad_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog fdialog = new Microsoft.Win32.OpenFileDialog() { Filter = "Cassette info files (*.finfo)|*.finfo" }; if(fdialog.ShowDialog().Value) { var finfo = new FileInfo(fdialog.FileName); var cassObj = new Cassette(finfo.Directory.FullName); this.SetCassette(cassObj); //debugField.Text = "HasValue: " + fdialog.FileName; } }
public RDFDocumentInfo(Cassette cassette, bool toload) { this.cassette = cassette; this.uri = "iiss://" + cassette.Name + "@iis.nsk.su/meta"; filePath = cassette.Dir.FullName + "/meta/" + cassette.Name + "_current.fog"; dbId = cassette.dbId ?? (cassette.Name + "Id"); owner = cassette.owner; if (toload) { this.root = //File.Exists(filePath+".xml") ? XElement.Load(filePath+".xml") : XElement.Load(filePath); var pAtt = root.Attribute("prefix"); var cAtt = root.Attribute("counter"); if (pAtt != null && cAtt != null && Int32.TryParse(cAtt.Value, out counter)) { prefix = pAtt.Value; isEditable = true; } } }
/// <summary> /// Конструктор для основного документа кассеты /// </summary> /// <param name="cassette"></param> public RDFDocumentInfo(Cassette cassette) : this(cassette, true) { }
public static CassetteInfo LoadCassette(string cassetteFolder, bool loaddata) { //var cassetteFolder = cassettePath.Value; //if (!Directory.Exists(cassetteFolder) || (!File.Exists(cassetteFolder + "cassette.finfo"))) return null; var cassette = new Cassette(cassetteFolder, loaddata); List<RDFDocumentInfo> di_list = null; if (loaddata) { di_list = new List<RDFDocumentInfo>(); var dd = cassette.DataDocuments().ToList(); foreach (var xDoc in dd) { di_list.Add( new RDFDocumentInfo(xDoc, cassetteFolder)); } } var cassetteInfo = new CassetteInfo { fullName = "iiss://" + cassette.Name + "@iis.nsk.su", cassette = cassette, url = cassette.Dir.FullName + '/', docsInfo = di_list, loaddata = loaddata }; if (loaddata) cassetteInfo.docsInfo.Add(new RDFDocumentInfo(cassette)); return cassetteInfo; }