public BaseTransferObject(DbEntity dbEntity)
        {
            if(dbEntity == null)
                throw new ArgumentNullException("dbEntity");

            Id = dbEntity.Id;
        }
示例#2
0
        private string SerializeProperty(PropertyInfo property, DbEntity item)
        {
            const string escapedChars       = @";\,=";
            var          valueStringBuilder = new StringBuilder();
            var          propertyValue      = property.GetValue(item).ToString();
            var          currentIndex       = 0;

            while (currentIndex < propertyValue.Length)
            {
                if (escapedChars.Contains(propertyValue[currentIndex]))
                {
                    valueStringBuilder.Append($"\\{propertyValue[currentIndex++]}");
                }
                else
                {
                    valueStringBuilder.Append(propertyValue[currentIndex++]);
                }
            }

            return($"{property.Name}={valueStringBuilder},");
        }
示例#3
0
        private static List <DbEntity> GetEntitiesReferencingGivenEntity(DbEntity entity, Predicate <PropertyInfo> predicate)
        {
            List <DbEntity> neighbors = new List <DbEntity>();

            // Check all nullable references of this instance to other objects
            Type type = entity.GetType();

            PropertyInfo[] pis = type.GetProperties(BindingFlags.Instance | BindingFlags.Public);
            neighbors = new List <DbEntity>();
            foreach (PropertyInfo pi in pis.Where(p => predicate(p)))
            {
                // Check if the property returns a linq object
                DbEntity neighbor = GetNeighborEntityFromPropertyInfo(entity, propertyInfo: pi, propertyInfos: pis);
                if (neighbor != null)
                {
                    neighbors.Add(neighbor);
                }
                else if (pi.PropertyType.IsGenericType)
                {
                    // All collection properties are validated too
                    if (typeof(IEnumerable).IsAssignableFrom(pi.PropertyType.GetGenericTypeDefinition()))
                    {
                        if (pi.PropertyType.GetGenericArguments()[0].Namespace == type.Namespace)
                        {
                            foreach (object obj in (IEnumerable)pi.GetValue(entity, null))
                            {
                                neighbor = obj as DbEntity;
                                if (neighbor != null)
                                {
                                    neighbors.Add(neighbor);
                                }
                            }
                        }
                    }
                }
            }

            return(neighbors);
        }
        public JsonResult SaveSc(DbEntity entity)
        {
            var result = new AjaxResultModel {
                success = false,
                code    = 400,
                message = "Error: Installation.SaveSc."
            };

            try {
                if (entity == null)
                {
                    throw new ArgumentException("参数无效 entity");
                }

                entity.Id       = Guid.NewGuid();
                entity.Provider = EnmDbProvider.SqlServer;
                entity.Type     = EnmDbType.Sc;

                _dataProvider.DelEntites(new List <DbEntity>()
                {
                    entity
                });
                _dataProvider.SaveEntites(new List <DbEntity>()
                {
                    entity
                });
                _cacheManager.Clear();
                _dbManager.Initializer();
                EngineContext.Initialize(true);

                result.success = true;
                result.code    = 200;
                result.message = "数据保存成功";
            } catch (Exception err) {
                result.message = err.Message;
            }

            return(Json(result));
        }
示例#5
0
        public void Test_method_name()
        {
            Action <Database, Transaction> action1 = (db, trans) =>
            {
                DBText dbText = new DBText {
                    TextString = "cat"
                };
                string testMe;

                ObjectId dbTextObjectId = DbEntity.AddToModelSpace(dbText, db);
                dbText.TextString = "dog";

                DBText testText = trans.GetObject(dbTextObjectId, OpenMode.ForRead) as DBText;
                testMe = testText != null ? testText.TextString : string.Empty;

                // Assert
                StringAssert.AreEqualIgnoringCase("dog", testMe, "DBText string was not changed to \"dog\".");
                StringAssert.AreNotEqualIgnoringCase("cat", testMe, "DBText string was not changed.");
            };

            ExecuteActionDWG(null, action1);
        }
示例#6
0
        /// <summary>
        /// 单表分页数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="queryColumns">要查询字段</param>
        /// <param name="sortColumn">排序字段</param>
        /// <param name="sortType">排序方式</param>
        /// <param name="pageSize">每页条数</param>
        /// <param name="pageIndex">第几页</param>
        /// <param name="whereSql">过滤条件Sql</param>
        /// <param name="whereParam">过滤条件字段名及字段值参数,例:new {Uname="joyet",Age = 110}</param>
        /// <returns></returns>
        public override DbEntity QueryPageList <T>(string queryColumns, string sortColumn, string sortType, long pageSize, long pageIndex, string whereSql, object whereParam)
        {
            DbEntity dbEntity = null;

            dbEntity = base.QueryPageList <T>(queryColumns, sortColumn, sortType, pageSize, pageIndex, whereSql, whereParam);
            if (dbEntity == null)
            {
                return(dbEntity);
            }
            Type type             = typeof(T);
            var  attributeBuilder = new AttributeBuilder();
            var  tableEntity      = attributeBuilder.GetTableInfo(type);

            dbEntity.TableEntity = tableEntity;
            var startNum   = pageSize * (pageIndex - 1);
            var dbOperator = DbFactory.GetDbParamOperator();
            List <TableColumnAttribute> whereColumns = attributeBuilder.GetColumnInfos(whereParam);
            var dbParams = new List <IDbDataParameter>();

            //分页查询模板
            var           queryTemplate = @"select  {queryColumns} from 
(
	select {sortColumn} from {tableName} {whereCriteria} order by {sortColumn} {sortType} limit {startNum},{pageSize}
) 
a inner join {tableName} b on a.{sortColumn}=b.{sortColumn} order by b.{sortColumn} {sortType};";
            StringBuilder sqlBuild      = new StringBuilder(queryTemplate);

            sqlBuild.Replace("{sortColumn}", sortColumn);
            sqlBuild.Replace("{tableName}", tableEntity.TableName);
            sqlBuild.Replace("{sortType}", sortType);
            sqlBuild.Replace("{startNum}", startNum.ToString());
            sqlBuild.Replace("{pageSize}", pageSize.ToString());
            HandleQueryColumParam(queryColumns, "b", ref sqlBuild);
            HandleWhereParam(whereSql, whereColumns, ref sqlBuild, ref dbParams);
            dbEntity.CommandText = sqlBuild.ToString();
            dbEntity.DbParams    = dbParams;
            return(dbEntity);
        }
示例#7
0
        public virtual bool RollBackLastOperation()
        {
            try
            {
                Infraestrutura.Modifieditem <TEntity> lastItem = _modifiedItens.Count > 0 ? _modifiedItens.Last() : null;

                if (!(lastItem is null))
                {
                    switch (lastItem.status)
                    {
                    case EntityState.Added:
                        DbEntity.Remove(lastItem.entity);
                        break;

                    case EntityState.Deleted:
                        DbEntity.Add(lastItem.entity);
                        break;

                    case EntityState.Modified:
                        if (DbEntity.AsEnumerable().Any(x => x == lastItem.entity))
                        {
                            _ctoProjetos.Entry(lastItem.entity).CurrentValues.SetValues(_ctoProjetos.Entry(lastItem.entity).OriginalValues);
                            _ctoProjetos.Entry(lastItem.entity).State = EntityState.Unchanged;
                        }
                        break;
                    }

                    _modifiedItens.Remove(lastItem);
                    return(true);
                }

                return(false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#8
0
        public virtual void executeDatabaseOperation(string operationType, object parameter)
        {
            if (DebugEnabled)
            {
                string message;
                if (parameter != null)
                {
                    message = parameter.ToString();
                }
                else
                {
                    message = "null";
                }

                if (parameter is DbEntity)
                {
                    DbEntity dbEntity = (DbEntity)parameter;
                    message = ClassNameUtil.getClassNameWithoutPackage(dbEntity) + "[id=" + dbEntity.Id + "]";
                }

                logDebug("009", "SQL operation: '{}'; Entity: '{}'", operationType, message);
            }
        }
        public JsonResult DbTest(DbEntity entity)
        {
            var result = new AjaxResultModel {
                success = false,
                code    = 400,
                message = "Error: Installation.DbTest."
            };

            try {
                if (entity == null)
                {
                    throw new ArgumentException("参数无效 entity");
                }
                SqlHelper.TestConnection(false, entity.IP, entity.Port, entity.Name, entity.Uid, entity.Password);
                result.success = true;
                result.code    = 200;
                result.message = "数据库连接成功";
            } catch (Exception err) {
                result.message = err.Message;
            }

            return(Json(result));
        }
示例#10
0
 static PaginateTests()
 {
     for (var i = 1; i <= 10; ++i)
     {
         Items[i - 1] = new DbEntity {
             Key = i
         };
     }
     for (var i = 1; i <= 3; ++i)
     {
         InitalPage[i - 1] = new DbEntity {
             Key = i
         };
     }
     for (var i = 4; i <= 6; ++i)
     {
         InnerPage[i - 4] = new DbEntity {
             Key = i
         };
     }
     Context.DbSet.AddRange(Items);
     Context.SaveChanges();
 }
示例#11
0
        /// <summary>
        /// get an object from the cache
        /// </summary>
        /// <param name="type"> the type of the object </param>
        /// <param name="id"> the id of the object </param>
        /// <returns> the object or 'null' if the object is not in the cache </returns>
        /// <exception cref="ProcessEngineException"> if an object for the given id can be found but is of the wrong type. </exception>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") public <T extends org.camunda.bpm.engine.impl.db.DbEntity> T get(Class<T> type, String id)
        public virtual T get <T>(Type type, string id) where T : org.camunda.bpm.engine.impl.db.DbEntity
        {
            type = typeof(T);
            Type           cacheKey       = cacheKeyMapping.getEntityCacheKey(type);
            CachedDbEntity cachedDbEntity = getCachedEntity(cacheKey, id);

            if (cachedDbEntity != null)
            {
                DbEntity dbEntity = cachedDbEntity.Entity;
                try
                {
                    return((T)dbEntity);
                }
                catch (System.InvalidCastException e)
                {
                    throw LOG.entityCacheLookupException(type, id, dbEntity.GetType(), e);
                }
            }
            else
            {
                return(null);
            }
        }
示例#12
0
        protected virtual bool Delete(TEntity entity)
        {
            try
            {
                if (!(entity is null))
                {
                    if (_allItens.Any(x => x.Equals(entity)) && (!_modifiedItens.Any(x => x.entity == entity) || _modifiedItens.OrderByDescending(x => x.DateLog).First(x => x.entity == entity).status != EntityState.Deleted))
                    {
                        DbEntity.Remove(entity);
                        _modifiedItens.Add(new Infraestrutura.Modifieditem <TEntity>(entity, EntityState.Deleted));
                        return(true);
                    }

                    throw new Exception("O objecto indicado não pode ser removido pois não pertence a listagem de dados.");
                }

                throw new ArgumentNullException("o Parametro entity nao pode ser nulo");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#13
0
 /// <summary>
 ///(I)ncident [guid]; civil s(E)rvant [guid]; instituti(O)n [guid]; (C)alendar event [guid]; (B)log post [guid]; (S)tateprovinceregion [int];
 ///county(A)rea [int]; ci(T)ty [int]; comme(N)tthread [int]; (R)eply [int]; (M)ention [int]; o(F)ficial register [guid];  official re[G]ister entry [guid];
 ///a(L)ert [guid]; incidentcategor(Y) [guid]; co(U)ntry [iso]; u(Z)er [guid]; incident u(P)date [guid]
 /// </summary>
 public static string StringDbEntity(DbEntity dbEntityEnum)
 {
     return(dbEntityEnum switch
     {
         DbEntity.Incident => "I",              //guid
         DbEntity.CivilServant => "E",          //guid
         DbEntity.Institution => "O",           //guid
         DbEntity.CalendarEvent => "C",         //guid
         DbEntity.BlogPost => "B",              //guid
         DbEntity.StateProvinceRegion => "S",   //int
         DbEntity.CountyArea => "A",            //int
         DbEntity.City => "T",                  //int
         DbEntity.CommentInThread => "N",       //int
         DbEntity.Reply => "R",                 //int
         DbEntity.CommentMention => "M",        //int
         DbEntity.OfficialRegister => "F",      //guid
         DbEntity.Alert => "L",                 //guid
         DbEntity.IncidentCategory => "Y",      //guid
         DbEntity.Country => "U",               //iso
         DbEntity.User => "Z",                  //guid
         DbEntity.OfficialRegisterEntry => "G", //guid
         DbEntity.IncidentUpdate => "P",        //guid
         _ => String.Empty,
     });
示例#14
0
        /// <summary>
        /// Checks if the reason for a persistence exception was the foreign-key referencing of a (currently)
        /// non-existing entity. This might happen with concurrent transactions, leading to an
        /// OptimisticLockingException.
        /// </summary>
        /// <param name="failedOperation">
        /// @return </param>
        private bool isOptimisticLockingException(DbOperation failedOperation, Exception cause)
        {
            bool isConstraintViolation        = ExceptionUtil.checkForeignKeyConstraintViolation(cause);
            bool isVariableIntegrityViolation = ExceptionUtil.checkVariableIntegrityViolation(cause);

            if (isVariableIntegrityViolation)
            {
                return(true);
            }
            else if (isConstraintViolation && failedOperation is DbEntityOperation && ((DbEntityOperation)failedOperation).Entity is HasDbReferences && (failedOperation.OperationType.Equals(DbOperationType.INSERT) || failedOperation.OperationType.Equals(DbOperationType.UPDATE)))
            {
                DbEntity entity = ((DbEntityOperation)failedOperation).Entity;
                foreach (KeyValuePair <string, Type> reference in ((HasDbReferences)entity).ReferencedEntitiesIdAndClass.SetOfKeyValuePairs())
                {
                    DbEntity referencedEntity = this.persistenceSession.selectById(reference.Value, reference.Key);
                    if (referencedEntity == null)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
        /// <summary>
        /// コマンドによって処理を分ける
        /// </summary>
        /// <returns>レスポンス文字列</returns>
        public string Logic()
        {
            try
            {
                switch (wpd.Command)
                {
                case "add":
                {
                    var logic = new DbEntity();
                    logic.Ins(wpd);

                    return("0");
                }

                case "get":
                {
                    var logic = new DbEntity();
                    // 取得
                    var getData = logic.Get(wpd);
                    // 移動
                    logic.Tohistory();
                    // 消去
                    logic.Del();

                    return(getData.SaveInJson <List <WebPageData> >());
                }
                }

                throw new Exception();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return("error");
            }
        }
示例#16
0
        private string SerializeItemForRequest(DbEntity item, DbEntity compareItem, out int propertiesInRequestCount)
        {
            var itemAddRequestBuilder = new StringBuilder();

            var type       = item.GetType();
            var properties = type.GetProperties();

            propertiesInRequestCount = 0;
            foreach (var property in properties)
            {
                var propertyValue = property.GetValue(item);
                var defaultValue  = property.GetValue(compareItem);
                if (propertyValue != null && !propertyValue.Equals(defaultValue) ||
                    property.Name == "Id")
                {
                    itemAddRequestBuilder.Append(SerializeProperty(property, item));
                    propertiesInRequestCount++;
                }
            }

            itemAddRequestBuilder.Remove(itemAddRequestBuilder.Length - 1, 1).Append(";");

            return(itemAddRequestBuilder.ToString());
        }
示例#17
0
        public override hresult OnEdit(Point3d pnt, EditFlags lFlag)
        {
            Editor ed = HostMgd.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            PromptIntegerOptions opts = new PromptIntegerOptions("Enter Count number: ");

            opts.AllowNegative = false;
            opts.AllowZero     = false;
            PromptIntegerResult pr = ed.GetInteger(opts);

            if (PromptStatus.OK == pr.Status)
            {
                ed.WriteMessage("You entered: " + pr.StringResult);
                Count = pr.Value;
                DbEntity.Erase();
                DbEntity.AddToCurrentDocument();
            }
            else
            {
                ed.WriteMessage("Cancel");
            }

            return(hresult.s_Ok);
        }
示例#18
0
        public async Task <IEntity> NewEntityAsync(IGame game, IEntity entity)
        {
            try
            {
                var gridEntity = (GridEntity)entity;
                var dbEntity   = new DbEntity()
                {
                    RecordBy   = "notlinktoausercontextyet",
                    RecordDate = DateTimeOffset.Now,
                    Name       = gridEntity.Name,
                    Class      = null,
                    Stats      = gridEntity.Stats.Select(s => new DbEntityStat()
                    {
                        Current = s.Value,
                        Base    = s.Base,
                        Name    = s.Name
                    }).ToList(),
                    Items = gridEntity.Items.Select(i => new DbEntityItem()
                    {
                        BaseItemId = i.Id
                    }).ToList()
                };
                using (var context = new GameDbContext())
                {
                    var tracked = context.Entities.Add(dbEntity);
                    await context.SaveChangesAsync();

                    return(tracked.Entity.ToEntity(game));
                }
            }
            catch (Exception ex)
            {
                _logger.LogWarning("new entity rejected: " + ex.Message);
                return(null);
            }
        }
示例#19
0
        private void ExecuteCmdAgainstEntityList <T>(IList <T> entities, string commandName, SqlConnection connection, SqlTransaction transaction)
        {
            foreach (T entity in entities)
            {
                if (!(entity is DbEntity))
                {
                    return;
                }

                DbEntity baseEntity = entity as DbEntity;

                if (baseEntity.IsChanged)
                {
                    using (SqlCommand command = new SqlCommand(commandName, connection, transaction))
                    {
                        command.CommandType = CommandType.StoredProcedure;

                        command.Parameters.AddRange(entity.ToSqlParameters().ToArray());

                        command.ExecuteNonQuery();
                    }
                }
            }
        }
示例#20
0
 public TestsController(DbEntity context)
 {
     _context = context;
 }
        // added in v. 1.1
        private void OnChanged(object source, FileSystemEventArgs e)
        {
            DocumentCollection dm = HostMgd.ApplicationServices.Application.DocumentManager;
            Editor             ed = dm.MdiActiveDocument.Editor;

            ed.WriteMessage("File: " + e.FullPath + " " + e.ChangeType);

            //read new value from file
            try
            {
                if (File.Exists(_monFilePath))
                {
                    int mStatus = -1;
                    ed.WriteMessage("File exists ");

                    using (StreamReader sr = new StreamReader(new FileStream(_monFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
                    {
                        if (sr.BaseStream.CanRead)
                        {
                            if (int.TryParse(sr.ReadLine(), out mStatus))
                            {
                                if (Enum.IsDefined(typeof(Status), mStatus))
                                {
                                    if (!TryModify())
                                    {
                                        return;
                                    }
                                    Stat = (Status)mStatus; // преобразование
                                    if (!TryModify())
                                    {
                                        return;
                                    }
                                    DbEntity.Update();
                                    McContext.ExecuteCommand("REGENALL");
                                    ed.WriteMessage("Door state is changed");
                                }
                                else
                                {
                                    ed.WriteMessage("Incorrect data in the file. Should be in diapason: 0, 1, 2 ");
                                }
                            }
                        }
                        else
                        {
                            ed.WriteMessage("Can't read file ");
                        }
                    }
                }
                else
                {
                    ed.WriteMessage("File not exists  ");
                }



                _watcher.EnableRaisingEvents = false; // disable tracking
            }
            finally
            {
                _watcher.EnableRaisingEvents = true; // reconnect tracking
            }
        }
示例#22
0
 internal DbSqlException(string message, SqlException innerException, DbEntity failingEntity, SqlQueryType sqlQueryType)
     : this(message, innerException)
 {
     FailingEntity = failingEntity;
     SqlQueryType  = sqlQueryType;
 }
示例#23
0
        /// <summary>
        /// Model instance
        /// </summary>
        public Core.Model.Entities.Organization ToModelInstance(DbOrganization orgInstance, DbEntityVersion dbEntityVersion, DbEntity dbEntity, DataContext context)
        {
            var retVal = m_entityPersister.ToModelInstance <Core.Model.Entities.Organization>(dbEntityVersion, dbEntity, context);

            if (retVal == null)
            {
                return(null);
            }
            retVal.IndustryConceptKey = orgInstance?.IndustryConceptKey;
            return(retVal);
        }
示例#24
0
 public static String CreateConnectionString(DbEntity database)
 {
     return(SqlHelper.CreateConnectionString(false, database.IP, database.Port, database.Db, database.Uid, database.Password, 120));
 }
示例#25
0
 public ResultsController(DbEntity context)
 {
     _context = context;
 }
示例#26
0
 public bool IsMarkedForDeletion(DbEntity entity)
 {
     return(deleteOnEndOfSubmitSet.Contains(entity) || deleteOnBeginOfSubmitSet.Contains(entity));
 }
        /// <summary>
        /// Creates the specified model instance
        /// </summary>
        public TModel ToModelInstance <TModel>(DbMaterial dbMat, DbEntityVersion dbEntVersion, DbEntity dbEnt, DataContext context, IPrincipal principal)
            where TModel : Core.Model.Entities.Material, new()
        {
            var retVal = this.m_entityPersister.ToModelInstance <TModel>(dbEntVersion, dbEnt, context, principal);

            if (retVal == null)
            {
                return(null);
            }

            retVal.ExpiryDate         = dbMat.ExpiryDate;
            retVal.IsAdministrative   = dbMat.IsAdministrative;
            retVal.Quantity           = dbMat.Quantity;
            retVal.QuantityConceptKey = dbMat.QuantityConceptKey;
            retVal.FormConceptKey     = dbMat.FormConceptKey;
            return(retVal);
        }
示例#28
0
 public abstract string GenerateDeleteSql(DbEntity entity);
示例#29
0
 public abstract string GenerateUpdateSql(DbEntity entity, params string[] fieldsNeedUpdate);
示例#30
0
        /// <summary>
        /// Convert the database representation to a model instance
        /// </summary>
        public Core.Model.Entities.DeviceEntity ToModelInstance(DbDeviceEntity deviceEntity, DbEntityVersion entityVersion, DbEntity entity, DataContext context, IPrincipal principal)
        {
            var retVal = m_entityPersister.ToModelInstance <Core.Model.Entities.DeviceEntity>(entityVersion, entity, context, principal);

            if (retVal == null)
            {
                return(null);
            }

            retVal.SecurityDeviceKey     = deviceEntity.SecurityDeviceKey;
            retVal.ManufacturerModelName = deviceEntity.ManufacturerModelName;
            retVal.OperatingSystemName   = deviceEntity.OperatingSystemName;
            return(retVal);
        }
        public Model()
        {
            string name = getName();

            db = new DbEntity(name, this);
        }
示例#32
0
        public override hresult PlaceObject(PlaceFlags lInsertType)
        {
            InputJig          jig           = new InputJig();
            List <McObjectId> SelectObjects = jig.SelectObjects("Select Object");

            //InputResult res = jig.SelectObject("Select a Polyline");
            //McObjectId id = SelectObjects[0];//.ObjectId;
            //DbGeometry selection = id.GetObject();
            if (SelectObjects.Count == 0)
            {
                DbEntity.Erase();
                return(hresult.e_Fail);
            }

            McDocument document = McDocumentsManager.GetActiveDoc();
            McDocument block    = document.CreateBlock("ArrayBlock", true);

            _block_name = block.Name;

            InputResult res = jig.GetPoint("Select Base Point:");

            foreach (McObjectId obj in SelectObjects)
            {
                McDbObject item = obj.GetObject();
                item.Entity.DbEntity.Transform(Matrix3d.Displacement(res.Point.GetAsVector().MultiplyBy(-1)));
                block.AddObject(item.Clone());
            }

            _idRef = document.GetBlock(_block_name);

            res = jig.GetPoint("Select first point:");
            if (res.Result != InputResult.ResultCode.Normal)
            {
                return(hresult.e_Fail);
            }
            _pnt1 = res.Point;
            foreach (McObjectId obj in SelectObjects)
            {
                McDbObject item = obj.GetObject();
                item.Erase();
            }

            McBlockRef blockref = new McBlockRef();

            blockref.BlockName   = _block_name;
            blockref.InsertPoint = res.Point;
            blockref.DbEntity.AddToCurrentDocument();
            _blockRef.Add(blockref);
            _blockRef.Add(_blockRef[0].DbEntity.Clone());
            _blockRef.Add(_blockRef[0].DbEntity.Clone());
            DbEntity.AddToCurrentDocument();
            //Exclude this from osnap to avoid osnap to itself
            jig.ExcludeObject(ID);
            //Monitor mouse move
            jig.MouseMove = (s, a) => {
                TryModify();
                _pnt2 = a.Point;
                DbEntity.Update();
            };

            res = jig.GetPoint("Select second point:", res.Point);
            if (res.Result != InputResult.ResultCode.Normal)
            {
                DbEntity.Erase();
                blockref.DbEntity.Erase();
                return(hresult.e_Fail);
            }
            _pnt2 = res.Point;

            Editor ed = HostMgd.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            PromptIntegerOptions opts = new PromptIntegerOptions("Enter Count number: ");

            opts.AllowNegative = false;
            opts.AllowZero     = false;
            opts.DefaultValue  = 1;
            PromptIntegerResult pr = ed.GetInteger(opts);

            if (PromptStatus.OK == pr.Status)
            {
                ed.WriteMessage("You entered: " + pr.StringResult);
                _count = pr.Value;

                _blockRef.Add(blockref.DbEntity.Clone());
                _blockRef[1].InsertPoint = res.Point;
                _blockRef[1].DbEntity.AddToCurrentDocument();
            }
            else
            {
                _count = 1;

                _blockRef.Add(blockref.DbEntity.Clone());
                _blockRef[1].InsertPoint = res.Point;
                _blockRef[1].DbEntity.AddToCurrentDocument();
            }

            for (int i = 1; i < Count; i++)
            {
                _blockRef.Add(_blockRef[0].DbEntity.Clone());
            }

            return(hresult.s_Ok);
        }
示例#33
0
 private bool DoHardDeleteEntity(DbEntity entity)
 {
     return(!(entity is IDeleteDate) ||
            iDeleteDateEntitiesToHardDelete?.Contains(entity) == true);
 }
示例#34
0
 public abstract string GenerateInsertSql(DbEntity entity);