Esempio n. 1
0
File: Nod.cs Progetto: eltoca03/Gxt
        public static void WriteToNod(ProfileObject obj)
        {
            Editor      ed    = Application.DocumentManager.MdiActiveDocument.Editor;
            Transaction trans = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction();

            using (trans)
            {
                if (!AppDictionary.IsWriteEnabled)
                {
                    AppDictionary.UpgradeOpen();
                }

                //create new Xrecord
                Xrecord xrecord = new Xrecord();
                //create the resbuf list
                ResultBuffer data = new ResultBuffer(new TypedValue((int)DxfCode.Text, obj.NodKey),
                                                     new TypedValue((int)DxfCode.Int64, obj.DistanceAtCrossing),
                                                     new TypedValue((int)DxfCode.Text, obj.Layer),
                                                     new TypedValue((int)DxfCode.Text, obj.LineType),
                                                     new TypedValue((int)DxfCode.Int32, obj.Depth));
                //add data to new record
                xrecord.Data = data;

                //create the entry to nod
                AppDictionary.SetAt(obj.NodKey, xrecord);

                try
                {
                    //add to transaction, if exist then handle in catch
                    trans.AddNewlyCreatedDBObject(xrecord, true);
                }
                catch
                {
                    //what todo when xrecord already exists
                }

                //all ok then commit
                trans.Commit();

                //increment object counter
                Count++;
            }
        }