/// <summary> /// saveModel(Model md) - записываем измененную модель в файловую систему /// </summary> /// <param name="name">имя модели для записи.</param> /// <history>6.8.16 -- nonstatic method</history> public Model saveModel(string name) { Log.set("saveModel(\"" + name + "\")"); Docs doc = Docs.getDoc(Decl.MODELS); doc.Reset("Now"); Models.Sort(); foreach (var m in Models) { string t = Lib.timeStr(m.date); doc.wrDoc(1, t, m.name, m.dir, m.Made, m.Phase, m.MD5, m.strListRules); } doc.isChanged = true; Docs.saveDoc(doc); Log.exit(); return getModel(name); }
/// <summary> /// saveDoc(doc [,BodySave, string MD5]) - сохраняет Документ в Excel файл, если он изменялся /// </summary> /// <param name="name">имя документа</param> /// <param name="BodySave>true - doc.Body нужно сохранить, false - уже в Excel</param> /// <param name="MD5">MD5 документа. Если BodySave = false - обязательно</param> /// <history>10.1.2016 /// 18.1.16 - аккуратная обработка BodySave=false и MD5 /// 20.1.16 - fix bug: not write EOLinTOC for TSmatch type Documents /// 1.04.16 - overlay saveDoc(..) /// </history> public static void saveDoc(Document doc, bool BodySave = true, string MD5 = "", int EOL = 0) { Log.set("saveDoc(\"" + doc.name + "\")"); try { Document toc = Documents[Decl.DOC_TOC]; if (doc.type == Decl.DOC_TYPE_N) doc.isChanged = true; if (doc.isChanged) { int EOLinTOC = EOL; if (BodySave) { FileOp.setRange(doc.Sheet); FileOp.saveRngValue(doc.Body); //24/4/17 doc.chkSum = doc.Body.ComputeMD5(); //2/8/17 removed EOLinTOC doc.EOLinTOC = doc.Body.iEOL(); doc.il = doc.Body.iEOL(); FileOp.fileSave(doc.Wb); doc.isChanged = false; } else { if (MD5.Length < 20 || EOL == 0) { Message.Message Msg = new Message.Message(); Msg.F("ERR_05.8_saveDoc_NOMD5"); } //2/8/17 removed EOLinTOC else { doc.chkSum = MD5; doc.EOLinTOC = EOLinTOC; } else { doc.chkSum = MD5; doc.il = EOLinTOC; } } Mtr tmp = FileOp.getSheetValue(toc.Sheet); for (int n = toc.i0; n <= toc.il; n++) { // находим и меняем строку документа doc TOC if ((string)toc.Body[n, Decl.DOC_NAME] != doc.name) continue; tmp[1, 1] = Lib.timeStr(); tmp[n, Decl.DOC_TIME] = Lib.timeStr(); tmp[n, Decl.DOC_MD5] = doc.chkSum; if (doc.type == "N") tmp[n, Decl.DOC_CREATED] = Lib.timeStr(); //2/8/17 removed EOLinTOC if (doc.type != Decl.TSMATCH_TYPE) tmp[n, Decl.DOC_EOL] = doc.EOLinTOC; if (doc.type != Decl.TSMATCH_TYPE) tmp[n, Decl.DOC_EOL] = doc.il; FileOp.setRange(toc.Sheet); FileOp.saveRngValue(tmp, AutoFit: false); //======= save TОC in TSmatch.xlsx break; } } } catch (Exception e) { Log.FATAL("Ошибка \"" + e.Message + "\" сохранения файла \"" + doc.name + "\""); } Log.exit(); }
/// <summary> /// Reset() - "Reset" of the Document. All contents of hes Excel Sheet erased, write Header form /// Reset("Now") - write DataTime.Now string in Cell [1,1] /// </summary> /// <history>9.1.2014 /// 17.1.16 - полностью переписано с записью Шапки /// 16.3.16 - header name get from doc.forms[0] /// 26.3.16 - Reset("Now") /// 27.3.16 - bug fixed. Issue was: Reset named as a doc.name instead SheetN /// </history> public void Reset(string str = "") { Log.set("Reset(" + this.name + ")"); Document toc = getDoc(); this.Sheet = FileOp.SheetReset(this.Wb, this.SheetN); Excel.Range rng = FileOp.setRange(this.Sheet); if (this.forms.Count == 0) Msg.F("Document.Reset no HDR form", this.name); string myHDR_name = this.forms[0].name; FileOp.CopyRng(toc.Wb, myHDR_name, rng); this.Body = FileOp.getSheetValue(this.Sheet); if (str == "Now") { Body[1, 1] = Lib.timeStr(); FileOp.setRange(this.Sheet); FileOp.saveRngValue(Body); } Log.exit(); }
public string sDat(DateTime d) { return Lib.timeStr(d, "d.MM.yyyy H:mm"); }