public static bool DbUpdate(this TEarthworkBlocking entity, DbSession session, params PDMDbProperty[] fields)
        {
            var           query   = session.GetDbQueryBuilder();
            UpdateBuilder builder = new UpdateBuilder();

            builder.ComponentWhere.Add(new ComponentValueOfWhere(TEarthworkBlockingProperties.IssueDateTime, entity.IssueDateTime, LocateType.Equal));
            if (fields == null || fields.Length == 0)
            {
                builder.ComponentSet.Add(new ComponentValueOfSet(TEarthworkBlockingProperties.EarthworkBlockMaxId, entity.EarthworkBlockMaxId));
                builder.ComponentSet.Add(new ComponentValueOfSet(TEarthworkBlockingProperties.ColorForUnsettled, entity.ColorForUnsettled));
                builder.ComponentSet.Add(new ComponentValueOfSet(TEarthworkBlockingProperties.ColorForSettled, entity.ColorForSettled));
                builder.ComponentSet.Add(new ComponentValueOfSet(TEarthworkBlockingProperties.IsImplementationInfoConflicted, entity.IsImplementationInfoConflicted));
            }
            else
            {
                if (fields.Contains(TEarthworkBlockingProperties.EarthworkBlockMaxId))
                {
                    builder.ComponentSet.Add(new ComponentValueOfSet(TEarthworkBlockingProperties.EarthworkBlockMaxId, entity.EarthworkBlockMaxId));
                }
                if (fields.Contains(TEarthworkBlockingProperties.ColorForUnsettled))
                {
                    builder.ComponentSet.Add(new ComponentValueOfSet(TEarthworkBlockingProperties.ColorForUnsettled, entity.ColorForUnsettled));
                }
                if (fields.Contains(TEarthworkBlockingProperties.ColorForSettled))
                {
                    builder.ComponentSet.Add(new ComponentValueOfSet(TEarthworkBlockingProperties.ColorForSettled, entity.ColorForSettled));
                }
                if (fields.Contains(TEarthworkBlockingProperties.IsImplementationInfoConflicted))
                {
                    builder.ComponentSet.Add(new ComponentValueOfSet(TEarthworkBlockingProperties.IsImplementationInfoConflicted, entity.IsImplementationInfoConflicted));
                }
            }
            query.UpdateBuilders.Add(builder);
            return(session.GetQueryOperator().Update <TEarthworkBlocking>(query));
        }
        /// <summary>
        /// 未查询到数据时返回 null
        /// </summary>
        public static TEarthworkBlocking DbSelect(this TEarthworkBlocking entity, DbSession session, SelectBuilder select)
        {
            var query = session.GetDbQueryBuilder();

            query.SelectBuilder = select;
            return(session.GetQueryOperator().Select <TEarthworkBlocking>(query));
        }
        public static bool DbInsert(this TEarthworkBlocking entity, DbSession session)
        {
            var           query   = session.GetDbQueryBuilder();
            InsertBuilder builder = new InsertBuilder();

            builder.ComponentInsert.Add(new ComponentValueOfInsert(TEarthworkBlockingProperties.IssueDateTime, entity.IssueDateTime));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TEarthworkBlockingProperties.EarthworkBlockMaxId, entity.EarthworkBlockMaxId));
            if (entity.ColorForUnsettled == null)
            {
                throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.ColorForUnsettled));
            }
            if (entity.ColorForUnsettled.Length > 20)
            {
                throw new NotImplementedException(string.Format("参数项:{0}长度:{1}超过额定限制:{2}", nameof(entity.ColorForUnsettled), entity.ColorForUnsettled.Length, 20));
            }
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TEarthworkBlockingProperties.ColorForUnsettled, entity.ColorForUnsettled));
            if (entity.ColorForSettled == null)
            {
                throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.ColorForSettled));
            }
            if (entity.ColorForSettled.Length > 20)
            {
                throw new NotImplementedException(string.Format("参数项:{0}长度:{1}超过额定限制:{2}", nameof(entity.ColorForSettled), entity.ColorForSettled.Length, 20));
            }
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TEarthworkBlockingProperties.ColorForSettled, entity.ColorForSettled));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TEarthworkBlockingProperties.IsImplementationInfoConflicted, entity.IsImplementationInfoConflicted));
            query.InsertBuilders.Add(builder);
            return(session.GetQueryOperator().Insert <TEarthworkBlocking>(query));
        }
        /// <summary>
        /// 未查询到数据时返回 null
        /// </summary>
        public static TEarthworkBlocking DbSelect(this TEarthworkBlocking entity, DbSession session, params PDMDbProperty[] fields)
        {
            var           query   = session.GetDbQueryBuilder();
            SelectBuilder builder = new SelectBuilder();

            if (fields.Count() == 0)
            {
                builder.ComponentSelect.Add(TEarthworkBlockingProperties.IssueDateTime);
                builder.ComponentSelect.Add(TEarthworkBlockingProperties.EarthworkBlockMaxId);
                builder.ComponentSelect.Add(TEarthworkBlockingProperties.ColorForUnsettled);
                builder.ComponentSelect.Add(TEarthworkBlockingProperties.ColorForSettled);
                builder.ComponentSelect.Add(TEarthworkBlockingProperties.IsImplementationInfoConflicted);
            }
            else
            {
                builder.ComponentSelect.Add(TEarthworkBlockingProperties.IssueDateTime);
                foreach (var field in fields)
                {
                    builder.ComponentSelect.Add(field);
                }
            }
            builder.ComponentWhere.Add(new ComponentValueOfWhere(TEarthworkBlockingProperties.IssueDateTime, entity.IssueDateTime, LocateType.Equal));
            query.SelectBuilders.Add(builder);
            return(session.GetQueryOperator().Select <TEarthworkBlocking>(query));
        }
Exemple #5
0
 /// <summary>
 /// 加载关联数据完整的数据
 /// </summary>
 /// <param name="tEarthworkBlocking"></param>
 /// <param name="session"></param>
 public static void LoadSolid(this TEarthworkBlocking tEarthworkBlocking, DateTime issueTime)
 {
     TransactionHelper.HandleTransactionEvent(SQLiteHelper.GetConnectingString(), (session) =>
     {
         tEarthworkBlocking.IssueDateTime = issueTime.Date;
         //加载TEarthworkBlocking;
         if (tEarthworkBlocking.DbLoad(session))//加载TEarthworkBlocking下级数据
         {
             tEarthworkBlocking.FetchEarthworkBlocks(session);
             foreach (TEarthworkBlock earthworkBlock in tEarthworkBlocking.EarthworkBlocks)
             {
                 if (earthworkBlock.FetchEarthworkBlockElements(session))
                 {
                     foreach (var earthworkBlockElements in earthworkBlock.EarthworkBlockElements)
                     {
                         earthworkBlock.ElementIds.AddRange(earthworkBlockElements.ElementIds.Split(',').Select(c => Convert.ToInt32(c)));
                     }
                     if (earthworkBlock.ElementIds.Count() > 0)
                     {
                         earthworkBlock.CPSettings_Obj.ApplySetting(tEarthworkBlocking, earthworkBlock.ElementIds.Select(c => new Autodesk.Revit.DB.ElementId(c)).ToList());
                     }
                 }
             }
             tEarthworkBlocking.EarthworkBlocks = tEarthworkBlocking.EarthworkBlocks.OrderBy(c => c.Indexer).ToList();
         }
         else
         {
             tEarthworkBlocking = new TEarthworkBlocking();
         }
     });
     tEarthworkBlocking.ColorForUnsettled_Color = ColorTranslator.FromHtml(tEarthworkBlocking.ColorForUnsettled);
     tEarthworkBlocking.ColorForSettled_Color   = ColorTranslator.FromHtml(tEarthworkBlocking.ColorForSettled);
 }
        public static bool DbDelete(this TEarthworkBlocking entity, DbSession session)
        {
            var query = session.GetDbQueryBuilder();

            query.DeleteBuilder.ComponentWhere.Add(new ComponentValueOfWhere(TEarthworkBlockingProperties.IssueDateTime, entity.IssueDateTime, LocateType.Equal));
            return(session.GetQueryOperator().Delete <TEarthworkBlocking>(query));
        }
Exemple #7
0
 /// <summary>
 /// 提交数据
 /// </summary>
 /// <param name="tEarthworkBlocking"></param>
 /// <param name="issueTime"></param>
 public static void Commit(this TEarthworkBlocking tEarthworkBlocking, DateTime issueTime)
 {
     TransactionHelper.HandleTransactionEvent(SQLiteHelper.GetConnectingString(), (session) =>
     {
         tEarthworkBlocking.IssueDateTime = issueTime.Date;
         //检测存在
         bool isExist;
         isExist = tEarthworkBlocking.CheckExistence(session, issueTime);
         if (!isExist)//插入
         {
             tEarthworkBlocking.DbInsert(session);
         }
         else//更新
         {
             tEarthworkBlocking.DbUpdate(session);
         }
         tEarthworkBlocking.DeleteEarthworkBlock(session);
         foreach (var earthworkBlock in tEarthworkBlocking.EarthworkBlocks)
         {
             earthworkBlock.Indexer       = (short)tEarthworkBlocking.EarthworkBlocks.IndexOf(earthworkBlock);
             earthworkBlock.IssueDateTime = issueTime;
             earthworkBlock.DbInsert(session);
             earthworkBlock.DeleteEarthworkBlockElements(session);
             earthworkBlock.InsertEarthworkBlockElements(session);
         }
         tEarthworkBlocking.Adds.Clear();
         tEarthworkBlocking.Deletes.Clear();
     });
 }
Exemple #8
0
        /// <summary>
        /// 删除 TEarthworkBlocking 所属的 TEarthworkBlock
        /// </summary>
        /// <param name="tEarthworkBlocking"></param>
        /// <param name="session"></param>
        public static void DeleteEarthworkBlock(this TEarthworkBlocking tEarthworkBlocking, DbSession session)
        {
            var query = session.GetDbQueryBuilder().DeleteBuilder;

            query.ComponentWhere.Add(TEarthworkBlockProperties.IssueDateTime, tEarthworkBlocking.IssueDateTime, LocateType.Equal);
            var @operator = session.GetQueryOperator();

            @operator.Delete <TEarthworkBlock>(query);
        }
Exemple #9
0
 public void ApplySetting(TEarthworkBlocking blocking, List <ElementId> elementIds)
 {
     using (var transaction = new Transaction(VLConstraints.Doc, "EarthworkBlocking." + nameof(ApplySetting)))
     {
         transaction.Start();
         ApplySettingWithoutTransaction(blocking, elementIds);
         transaction.Commit();
     }
 }
Exemple #10
0
        public static bool FetchEarthworkBlocks(this TEarthworkBlocking tEarthworkBlocking, DbSession session)
        {
            var           query   = session.GetDbQueryBuilder();
            SelectBuilder builder = new SelectBuilder();

            builder.ComponentWhere.Add(new ComponentValueOfWhere(TEarthworkBlockProperties.IssueDateTime, tEarthworkBlocking.IssueDateTime, LocateType.Equal));
            query.SelectBuilders.Add(builder);
            tEarthworkBlocking.EarthworkBlocks = session.GetQueryOperator().SelectAll <TEarthworkBlock>(query);
            return(tEarthworkBlocking.EarthworkBlocks.Count > 0);
        }
Exemple #11
0
        /// <summary>
        /// 获取最新的周期时间,无时为null
        /// </summary>
        /// <returns></returns>
        public static DateTime GetLatestIssueTime(this TEarthworkBlocking tEarthworkBlocking)
        {
            DateTime issueTime = DateTime.MinValue;

            TransactionHelper.HandleTransactionEvent(SQLiteHelper.GetConnectingString(), (session) =>
            {
                var query = session.GetDbQueryBuilder().SelectBuilder;
                query.ComponentSelect.Add($"max(IssueDateTime)");
                var result = session.GetQueryOperator().SelectAsDateTime <TEarthworkBlocking>(query);
                issueTime  = result.HasValue ? result.Value : DateTime.MinValue;
            });
            return(issueTime);
        }
Exemple #12
0
        /// <summary>
        /// 检测当期的TEarthworkBlocking是否存在
        /// </summary>
        /// <param name="issueTime"></param>
        /// <param name="session"></param>
        /// <returns></returns>
        public static bool CheckExistence(this TEarthworkBlocking tEarthworkBlocking, DbSession session, DateTime issueTime)
        {
            bool isExist;
            var  query = session.GetDbQueryBuilder().SelectBuilder;

            query.ComponentSelect.Add("1");
            query.ComponentWhere.Add(TEarthworkBlockingProperties.IssueDateTime, issueTime, LocateType.Equal);
            var @operator = session.GetQueryOperator();
            var result    = @operator.SelectAsBool <TEarthworkBlocking>(query);

            isExist = result.HasValue ? result.Value : false;
            return(isExist);
        }
Exemple #13
0
        /// <summary>
        /// 获取最新的周期时间,无时为 DateTime.MinValue
        /// </summary>
        /// <returns></returns>
        public static DateTime GetPreviousIssueTime(this TEarthworkBlocking tEarthworkBlocking, DateTime issueDate)
        {
            DateTime issueTime = DateTime.MinValue;

            TransactionHelper.HandleTransactionEvent(SQLiteHelper.GetConnectingString(), (session) =>
            {
                var query = session.GetDbQueryBuilder().SelectBuilder;
                query.ComponentSelect.Add($"max(IssueDateTime)");
                query.ComponentWhere.Add(TEarthworkBlockingProperties.IssueDateTime, issueDate, LocateType.LessThan);
                var result = session.GetQueryOperator().SelectAsDateTime <TEarthworkBlocking>(query);
                issueTime  = result.HasValue ? result.Value : DateTime.MinValue;
            });
            return(issueTime);
        }
Exemple #14
0
 /// <summary>
 /// 解除对元素增加的节点的配置
 /// </summary>
 /// <param name="element"></param>
 public void DeapplySetting(TEarthworkBlocking blocking, List <ElementId> elementIds)
 {
     using (var transaction = new Transaction(VLConstraints.Doc, "EarthworkBlocking." + nameof(DeapplySetting)))
     {
         OverrideGraphicSettings setting = GetOverrideGraphicSettings(VLConstraints.Doc);
         transaction.Start();
         //元素可见性
         VLConstraints.View3D.UnhideElements(elementIds);
         //元素表面填充物配置
         foreach (var elementId in elementIds)
         {
             DeapplySetting(VLConstraints.View3D, elementId);
         }
         transaction.Commit();
     }
 }
Exemple #15
0
        public void ApplySettingWithoutTransaction(TEarthworkBlocking blocking, List <ElementId> elementIds)
        {
            if (elementIds == null || elementIds.Count == 0)
            {
                return;
            }
            OverrideGraphicSettings setting = GetOverrideGraphicSettings(VLConstraints.Doc);

            //元素可见性
            if (IsVisible)
            {
                VLConstraints.View3D.UnhideElements(elementIds);
            }
            else
            {
                VLConstraints.View3D.HideElements(elementIds);
            }
            //元素表面填充物配置
            foreach (var elementId in elementIds)
            {
                Revit_Helper.ApplyOverrideGraphicSettings(VLConstraints.View3D, elementId, setting);
            }
        }
        /// <summary>
        /// 存在相应对象时返回true,缺少对象时返回false
        /// </summary>
        public static bool DbLoad(this TEarthworkBlocking entity, DbSession session, params PDMDbProperty[] fields)
        {
            var result = entity.DbSelect(session, fields);

            if (result == null)
            {
                return(false);
            }
            if (fields.Count() == 0)
            {
                entity.EarthworkBlockMaxId            = result.EarthworkBlockMaxId;
                entity.ColorForUnsettled              = result.ColorForUnsettled;
                entity.ColorForSettled                = result.ColorForSettled;
                entity.IsImplementationInfoConflicted = result.IsImplementationInfoConflicted;
            }
            else
            {
                if (fields.Contains(TEarthworkBlockingProperties.EarthworkBlockMaxId))
                {
                    entity.EarthworkBlockMaxId = result.EarthworkBlockMaxId;
                }
                if (fields.Contains(TEarthworkBlockingProperties.ColorForUnsettled))
                {
                    entity.ColorForUnsettled = result.ColorForUnsettled;
                }
                if (fields.Contains(TEarthworkBlockingProperties.ColorForSettled))
                {
                    entity.ColorForSettled = result.ColorForSettled;
                }
                if (fields.Contains(TEarthworkBlockingProperties.IsImplementationInfoConflicted))
                {
                    entity.IsImplementationInfoConflicted = result.IsImplementationInfoConflicted;
                }
            }
            return(true);
        }