private static object CreateSpecialObject(string type, FLDict *properties, DocContext context) { Debug.Assert(context != null); return(type == ObjectTypeBlob || FLValueConverter.IsOldAttachment(context.Db, properties) ? context.ToObject((FLValue *)properties, true) : null); }
public AddGood() { InitializeComponent(); using (DocContext db = new DocContext()) { var GoodsList = db.Goods; this.objectListView1.SetObjects(GoodsList); } }
public void addItems(AutoCompleteStringCollection col) { using (DocContext db = new DocContext()) { foreach (Good g in db.Goods) { col.Add(g.name); } } }
public AddDoc() { InitializeComponent(); using (DocContext db = new DocContext()) { dataGridView1.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(dataGridView1_EditingControlShowing); dataGridView1.RowsAdded += new DataGridViewRowsAddedEventHandler(dataGridView1_RowsAdded); dataGridView1.RowsRemoved += new DataGridViewRowsRemovedEventHandler(dataGridView1_RowsRemoved); } }
private void save_Click(object sender, EventArgs e) { using (DocContext db = new DocContext()) { Doc newDoc = new Doc(); newDoc.DocCreateTime = DateTime.Now; newDoc.DocType = comboBox1.SelectedItem.ToString(); TablePart tablePart = new TablePart(); for (int i = 0; i < dataGridView1.Rows.Count; i++) { string nameCellValue = dataGridView1.Rows[i].Cells[1].Value.ToString(); if (db.Goods.FirstOrDefault(Good => Good.name == nameCellValue) != null) { TablePartString tablePartString = new TablePartString(); tablePartString.serial = i; tablePartString.Good = db.Goods.FirstOrDefault(Good => Good.name == nameCellValue); tablePartString.quantity = int.Parse(dataGridView1.Rows[i].Cells[2].Value.ToString()); tablePartString.balance = int.Parse(dataGridView1.Rows[i].Cells[3].Value.ToString()); tablePart.AddString(tablePartString); } else { MessageBox.Show("Документ НЕ сохранен"); return; } } newDoc.DocTablePart = tablePart; db.Docs.Add(newDoc); foreach (TablePartString stringWhithGoodForAddBalance in tablePart) { string goodNameForAddBalance = stringWhithGoodForAddBalance.Good.name.ToString(); Good goodForAddBalance = db.Goods.FirstOrDefault(Good => Good.name == goodNameForAddBalance); goodForAddBalance.balance += int.Parse(stringWhithGoodForAddBalance.balance.ToString()); try { db.SaveChanges(); } catch (Exception) { MessageBox.Show("Не удалось сохранить изменения в " + stringWhithGoodForAddBalance.serial.ToString() + " строке документа!"); throw; } } //string goodName = dataGridView1.Rows[0].Cells[1].Value.ToString(); //Good goodItem = db.Goods.FirstOrDefault(Good => Good.name == goodName); //goodItem.balance += int.Parse(dataGridView1.Rows[0].Cells[2].Value.ToString()); //db.SaveChanges(); MessageBox.Show("Документ сохранен"); } }
public unsafe void TestReadOnlyDictionary() { var now = DateTimeOffset.UtcNow; var nestedArray = new[] { 1L, 2L, 3L }; var nestedDict = new Dictionary <string, object> { ["foo"] = "bar" }; var masterData = new Dictionary <string, object> { ["date"] = now, ["array"] = nestedArray, ["dict"] = nestedDict }; var flData = new FLSliceResult(); Db.InBatch(() => { flData = masterData.FLEncode(); }); try { var context = new DocContext(Db, null); using (var mRoot = new MRoot(context)) { mRoot.Context.Should().BeSameAs(context); FLDoc *fleeceDoc = Native.FLDoc_FromResultData(flData, FLTrust.Trusted, Native.c4db_getFLSharedKeys(Db.c4db), FLSlice.Null); var flValue = Native.FLDoc_GetRoot(fleeceDoc); var mDict = new MDict(new MValue(flValue), mRoot); var deserializedDict = new DictionaryObject(mDict, false); deserializedDict["bogus"].Blob.Should().BeNull(); deserializedDict["date"].Date.Should().Be(now); deserializedDict.GetDate("bogus").Should().Be(DateTimeOffset.MinValue); deserializedDict.GetArray("array").Should().Equal(1L, 2L, 3L); deserializedDict.GetArray("bogus").Should().BeNull(); deserializedDict.GetDictionary("dict").Should().BeEquivalentTo(nestedDict); deserializedDict.GetDictionary("bogus").Should().BeNull(); var dict = deserializedDict.ToDictionary(); dict["array"].As <IList>().Should().Equal(1L, 2L, 3L); dict["dict"].As <IDictionary <string, object> >().Should().BeEquivalentTo(nestedDict); var isContain = mDict.Contains(""); isContain.Should().BeFalse(); Native.FLDoc_Release(fleeceDoc); } } finally { Native.FLSliceResult_Release(flData); } }
public unsafe void TestReadOnlyArray() { var now = DateTimeOffset.UtcNow; var nestedArray = new[] { 1L, 2L, 3L }; var nestedDict = new Dictionary <string, object> { ["foo"] = "bar" }; var masterData = new object[] { 1, "str", nestedArray, now, nestedDict }; var flData = new FLSliceResult(); Db.InBatch(() => { flData = masterData.FLEncode(); }); try { var context = new DocContext(Db, null); using (var mRoot = new MRoot(context)) { mRoot.Context.Should().BeSameAs(context); FLDoc *fleeceDoc = Native.FLDoc_FromResultData(flData, FLTrust.Trusted, Native.c4db_getFLSharedKeys(Db.c4db), FLSlice.Null); var flValue = Native.FLDoc_GetRoot(fleeceDoc); var mArr = new FleeceMutableArray(new MValue(flValue), mRoot); var deserializedArray = new ArrayObject(mArr, false); deserializedArray.GetArray(2).Should().Equal(1L, 2L, 3L); deserializedArray.GetArray(3).Should().BeNull(); deserializedArray.GetBlob(1).Should().BeNull(); deserializedArray.GetDate(3).Should().Be(now); deserializedArray.GetDate(4).Should().Be(DateTimeOffset.MinValue); deserializedArray[1].ToString().Should().Be("str"); deserializedArray.GetString(2).Should().BeNull(); deserializedArray.GetDictionary(4).Should().BeEquivalentTo(nestedDict); deserializedArray[0].Dictionary.Should().BeNull(); var list = deserializedArray.ToList(); list[2].Should().BeAssignableTo <IList <object> >(); list[4].Should().BeAssignableTo <IDictionary <string, object> >(); var mVal = new MValue(); mVal.Dispose(); Native.FLDoc_Release(fleeceDoc); } } finally { Native.FLSliceResult_Release(flData); } var mroot = new MRoot(); }
public void LeaveContext(DocContext ctx) { if (SteelTransaction != null) { SteelTransaction.Commit(); SteelTransaction = null; } if (DocumentLocked == true) { DocumentLocked = DocumentManager.UnlockCurrentDocument(); DocumentLocked = false; } }
public unsafe void TestReadOnlyDictionary() { var now = DateTimeOffset.UtcNow; var nestedArray = new[] { 1L, 2L, 3L }; var nestedDict = new Dictionary <string, object> { ["foo"] = "bar" }; var masterData = new Dictionary <string, object> { ["date"] = now, ["array"] = nestedArray, ["dict"] = nestedDict }; var flData = new FLSliceResult(); Db.InBatch(() => { flData = masterData.FLEncode(); }); try { var context = new DocContext(Db, null); using (var mRoot = new MRoot(context)) { mRoot.Context.Should().BeSameAs(context); var flValue = NativeRaw.FLValue_FromTrustedData((FLSlice)flData); var mDict = new MDict(new MValue(flValue), mRoot); var deserializedDict = new DictionaryObject(mDict, false); deserializedDict["bogus"].Blob.Should().BeNull(); deserializedDict["date"].Date.Should().Be(now); deserializedDict.GetDate("bogus").Should().Be(DateTimeOffset.MinValue); deserializedDict.GetArray("array").Should().Equal(1L, 2L, 3L); deserializedDict.GetArray("bogus").Should().BeNull(); deserializedDict.GetDictionary("dict").Should().BeEquivalentTo(nestedDict); deserializedDict.GetDictionary("bogus").Should().BeNull(); var dict = deserializedDict.ToDictionary(); dict["array"].As <IList>().Should().Equal(1L, 2L, 3L); dict["dict"].As <IDictionary <string, object> >().ShouldBeEquivalentTo(nestedDict); } } finally { Native.FLSliceResult_Free(flData); } }
public unsafe void TestSharedstrings() { var now = DateTimeOffset.UtcNow; var nestedArray = new[] { 1L, 2L, 3L }; var nestedDict = new Dictionary <string, object> { ["foo"] = "bar" }; var masterData = new object[] { 1, "str", nestedArray, now, nestedDict }; var flData = new FLSliceResult(); Db.InBatch(() => { flData = masterData.FLEncode(); }); try { var context = new DocContext(Db, null); using (var mRoot = new MRoot(context)) { var flValue = NativeRaw.FLValue_FromTrustedData((FLSlice)flData); var mArr = new MArray(new MValue(flValue), mRoot); var sharedstrings = context.SharedStrings; FLEncoder *fLEncoder = Db.SharedEncoder; mRoot.FLEncode(fLEncoder); mRoot.Encode(); var isReadonly = mArr.IsReadOnly; isReadonly.Should().BeFalse(); #if !WINDOWS_UWP Assert.Throws <NotImplementedException>(() => mArr.IndexOf(now)); Assert.Throws <NotImplementedException>(() => mArr.Contains(now)); Assert.Throws <NotImplementedException>(() => mArr.Remove(now)); Assert.Throws <NotImplementedException>(() => mArr.CopyTo(new object[] { }, 12)); #endif var flDict = Native.FLValue_AsDict(flValue); var sharedStringCache = new SharedStringCache(); var sharedStringCache1 = new SharedStringCache(sharedStringCache); sharedStringCache1 = new SharedStringCache(sharedStringCache, flDict); var i = default(FLDictIterator); var iterKey = sharedStringCache1.GetDictIterKey(&i); sharedStringCache1.UseDocumentRoot(flDict); } } finally { Native.FLSliceResult_Free(flData); } }
public void EnsureInContext(DocContext ctx) { if (SteelTransaction != null || DocumentLocked == true) { throw new System.Exception("Nested context"); } DocumentLocked = DocumentManager.LockCurrentDocument(); if (DocumentLocked == true) { SteelTransaction = Autodesk.AdvanceSteel.CADAccess.TransactionManager.StartTransaction(); } if (DocumentLocked == false || SteelTransaction == null) { throw new System.Exception("Failed to access Document"); } }
public override void Dispose() { lock (access_obj) { // Do not cleanup elements if we are shutting down Dynamo. if (DisposeLogic.IsShuttingDown || DisposeLogic.IsClosingHomeworkspace) { return; } //this function is not implemented for the moment bool didAdvanceSteelDelete = LifecycleManager <string> .GetInstance().IsAdvanceSteelDeleted(Handle); var elementManager = LifecycleManager <string> .GetInstance(); int remainingBindings = elementManager.UnRegisterAssociation(Handle, this); // Do not delete owned elements if (remainingBindings == 0 && !didAdvanceSteelDelete) { if (Handle != null) { //lock the document and start a transaction using (var ctx = new DocContext()) { var filerObject = Utils.GetObject(Handle); if (filerObject != null) { filerObject.DelFromDb(); } ObjectHandle = string.Empty; } } } else { //This element has gone ObjectHandle = string.Empty; } } }
public unsafe void TestReadOnlyArray() { var now = DateTimeOffset.UtcNow; var nestedArray = new[] { 1L, 2L, 3L }; var nestedDict = new Dictionary <string, object> { ["foo"] = "bar" }; var masterData = new object[] { 1, "str", nestedArray, now, nestedDict }; var flData = new FLSliceResult(); Db.InBatch(() => { flData = masterData.FLEncode(); }); try { var context = new DocContext(Db, null); using (var mRoot = new MRoot(context)) { mRoot.Context.Should().BeSameAs(context); var flValue = NativeRaw.FLValue_FromTrustedData((FLSlice)flData); var mArr = new MArray(new MValue(flValue), mRoot); var deserializedArray = new ArrayObject(mArr, false); deserializedArray.GetArray(2).Should().Equal(1L, 2L, 3L); deserializedArray.GetArray(3).Should().BeNull(); deserializedArray.GetBlob(1).Should().BeNull(); deserializedArray.GetDate(3).Should().Be(now); deserializedArray.GetDate(4).Should().Be(DateTimeOffset.MinValue); deserializedArray[1].ToString().Should().Be("str"); deserializedArray.GetString(2).Should().BeNull(); deserializedArray.GetDictionary(4).Should().BeEquivalentTo(nestedDict); deserializedArray[0].Dictionary.Should().BeNull(); var list = deserializedArray.ToList(); list[2].Should().BeAssignableTo <IList <object> >(); list[4].Should().BeAssignableTo <IDictionary <string, object> >(); } } finally { Native.FLSliceResult_Free(flData); } }
public IEnumerable <string> PickElements() { List <string> ret = new List <string>() { }; using (var ctx = new DocContext()) { List <ObjectId> OIDx = UserInteraction.SelectObjects(); if (OIDx.Count > 0) { for (int i = 0; i < OIDx.Count; i++) { FilerObject obj = FilerObject.GetFilerObject(OIDx[i]); if (obj != null) { ret.Add(obj.Handle); } } } } return(ret); }
public RegObr(Appeal_gr _appeal_Gr) { InitializeComponent(); docCon = new DocContext(); // appeal_Gr = _appeal_Gr; if (appeal_Gr != null) { save_app = 1; Date_prBox.SelectedDate = _appeal_Gr.Date_pr; Time_pr_sBox.Text = _appeal_Gr.Time_pr_s.ToString(); Time_pr_doBox.Text = _appeal_Gr.Time_pr_do.ToString(); FIO_grBox.Text = _appeal_Gr.FIO_gr; FIO_prinBox.Text = _appeal_Gr.FIO_prin; BoolCheck.IsChecked = _appeal_Gr.Bool_pr; } else { save_app = 0; } }
public void LeaveContext(DocContext ctx) { }
public void EnsureInContext(DocContext ctx) { StartTransaction(); SubscribeToRefreshCompleted(); }
//cистема внедрения зависимостей использует конструкторы классов для передачи всех зависимостей. //Соответственно в конструкторе контроллера мы можем получить зависимость. //Конструкторы являются наиболее предпочтительным вариантом для получения зависимостей public DocController(DocContext context, IWebHostEnvironment appEnvironment, IDocsService services) { _context = context; _appEnvironment = appEnvironment; _services = services; }
public DocsService(DocContext context, IConfiguration configuration) { _context = context; _configuration = configuration; }
public MiniDocReader(FileType fileType) { _foundText = new Dictionary<string, DocContext>(); // Collect Paragraph text // NOTE: Comment text is output in both Paragraph and Comment contexts _foundText[ParagraphType] = new DocContext(ParagraphType, "\r\n"); // Always get cell data (XLS) and text box data (PPT/PPTX) _foundText[CellTextType] = new DocContext(CellTextType, " "); // NOTE: PPTX TextBox and Paragraph text is duplicate data. Paragraph contains // extraneous text not found in visible document but breaks lines better if (fileType != FileType.PowerPointX) { _foundText[TextBoxType] = new DocContext(TextBoxType, "\r\n"); } _foundText[EmailBodyType] = new DocContext(EmailBodyType, String.Empty); _foundText[HTTPContent] = new DocContext(HTTPContent, String.Empty); // Collect Footnote text _foundText[FootnoteType] = new DocContext(FootnoteType, "\r\n"); }
public ArchiveRepository() { _db = new DocContext(); }
//public DocsService(DocContext context, IWebHostEnvironment appEnvironment, IConfiguration configuration) public DocsService(DocContext context, IConfiguration configuration) { _context = context; //_appEnvironment = appEnvironment; _configuration = configuration; }