示例#1
0
 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);
 }
示例#2
0
 public AddGood()
 {
     InitializeComponent();
     using (DocContext db = new DocContext())
     {
         var GoodsList = db.Goods;
         this.objectListView1.SetObjects(GoodsList);
     }
 }
示例#3
0
 public void addItems(AutoCompleteStringCollection col)
 {
     using (DocContext db = new DocContext())
     {
         foreach (Good g in db.Goods)
         {
             col.Add(g.name);
         }
     }
 }
示例#4
0
 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);
     }
 }
示例#5
0
        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("Документ сохранен");
            }
        }
示例#6
0
        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);
            }
        }
示例#7
0
        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();
        }
示例#8
0
        public void LeaveContext(DocContext ctx)
        {
            if (SteelTransaction != null)
            {
                SteelTransaction.Commit();
                SteelTransaction = null;
            }

            if (DocumentLocked == true)
            {
                DocumentLocked = DocumentManager.UnlockCurrentDocument();
                DocumentLocked = false;
            }
        }
示例#9
0
        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);
            }
        }
示例#10
0
        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);
            }
        }
示例#11
0
        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;
                }
            }
        }
示例#13
0
        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);
            }
        }
示例#14
0
        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);
        }
示例#15
0
        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;
            }
        }
示例#16
0
 public void LeaveContext(DocContext ctx)
 {
 }
示例#17
0
 public void EnsureInContext(DocContext ctx)
 {
     StartTransaction();
     SubscribeToRefreshCompleted();
 }
示例#18
0
        //cистема внедрения зависимостей использует конструкторы классов для передачи всех зависимостей.
        //Соответственно в конструкторе контроллера мы можем получить зависимость.
        //Конструкторы являются наиболее предпочтительным вариантом для получения зависимостей

        public DocController(DocContext context, IWebHostEnvironment appEnvironment, IDocsService services)
        {
            _context        = context;
            _appEnvironment = appEnvironment;
            _services       = services;
        }
示例#19
0
 public DocsService(DocContext context, IConfiguration configuration)
 {
     _context       = context;
     _configuration = configuration;
 }
示例#20
0
		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");
		}
示例#21
0
 public ArchiveRepository()
 {
     _db = new DocContext();
 }
示例#22
0
 //public DocsService(DocContext context, IWebHostEnvironment appEnvironment, IConfiguration configuration)
 public DocsService(DocContext context, IConfiguration configuration)
 {
     _context = context;
     //_appEnvironment = appEnvironment;
     _configuration = configuration;
 }