public DeepZoomLinkAnnotationsDtoProfile()
 {
     CreateMap <Defect, DeepZoomLinkAnnotationsDto>()
     .Ignore(x => x.XCenter)
     .Ignore(x => x.YCenter)
     .Ignore(x => x.Height)
     .Ignore(x => x.Width)
     .Ignore(x => x.Shape)
     .ForMember(x => x.Color, opt => opt.MapFrom(k => DefectHelper.GetColorForDefect(k.Name)))
     .AfterMap((defect, dest) => { dest.TransformShapeForDeepZoomLink(defect); });
 }
        public DataResult GetDefect([FromQuery] int qId, int wId, bool menu)
        {
            var result = new DataResult();

            result.datas.AddRange(menu
                ? DefectHelper.GetMenu(wId, qId)
                : DefectHelper.GetDetails(wId, qId));
            if (qId != 0 && !result.datas.Any())
            {
                result.errno = Error.DefectNotExist;
                return(result);
            }
            return(result);
        }
        public object PutDefect([FromBody] IEnumerable <DefectDetail> details)
        {
            if (details == null || !details.Any())
            {
                return(Result.GenError <Result>(Error.ParamError));
            }
            if (details.Any(x => x.Id == 0))
            {
                return(Result.GenError <Result>(Error.DefectNotExist));
            }
            var markedDateTime = DateTime.Now;

            foreach (var detail in details)
            {
                detail.MarkedDateTime = markedDateTime;
                detail.Remark         = detail.Remark ?? "";
            }
            if (details.Any(x => x.Name.IsNullOrEmpty()))
            {
                var ids = details.Select(x => x.Id);
                var cnt = DefectHelper.Instance.GetCountByIds(ids);
                if (cnt != details.Count())
                {
                    return(Result.GenError <Result>(Error.DefectNotExist));
                }
                DefectHelper.Enable(details);
            }
            else
            {
                if (details.GroupBy(x => x.Name).Any(y => y.Count() > 1))
                {
                    return(Result.GenError <Result>(Error.DefectDuplicate));
                }
                var wId   = details.FirstOrDefault()?.WorkshopId ?? 0;
                var sames = details.Select(x => x.Name);
                var ids   = details.Select(x => x.Id);
                if (DefectHelper.GetHaveSame(wId, sames, ids))
                {
                    return(Result.GenError <Result>(Error.DefectIsExist));
                }
                var cnt = DefectHelper.Instance.GetCountByIds(ids);
                if (cnt != details.Count())
                {
                    return(Result.GenError <Result>(Error.DefectNotExist));
                }
                DefectHelper.Instance.Update(details);
            }
            return(Result.GenError <Result>(Error.Success));
        }
 public AnnotationsDtoProfile()
 {
     CreateMap <Defect, AnnotationsDto>()
     .ForMember(dest => dest.Url, opt => opt.MapFrom(src =>
                                                     $"{HttpContext.Current.Request.Url.Scheme}://{HttpContext.Current.Request.Url.Host}:{HttpContext.Current.Request.Url.Port}/{src.Sequence.Blade.Turbine.Site.Country.Name}/{src.Sequence.Blade.Turbine.Site.Name}/{src.Sequence.Blade.Turbine.SerialNumber}/{src.Sequence.Blade.SerialNumber}/{src.SerialNumber}"))
     .ForMember(dest => dest.Color, opt => opt.MapFrom(src => DefectHelper.GetColorForDefect(src.Name)))
     .Ignore(x => x.XCenter)
     .Ignore(x => x.YCenter)
     .Ignore(x => x.Height)
     .Ignore(x => x.Width)
     .Ignore(x => x.Shape)
     .AfterMap((defect, dest) =>
     {
         dest.SetShapeFromDefect(defect.Shape);
     });
 }
        public object PostDefect([FromBody] IEnumerable <DefectDetail> details)
        {
            if (details == null || !details.Any())
            {
                return(Result.GenError <Result>(Error.ParamError));
            }
            if (details.Any(x => x.Name.IsNullOrEmpty()))
            {
                return(Result.GenError <Result>(Error.DefectNotEmpty));
            }
            if (details.GroupBy(x => x.Name).Any(y => y.Count() > 1))
            {
                return(Result.GenError <Result>(Error.DefectDuplicate));
            }

            var wId   = details.FirstOrDefault()?.WorkshopId ?? 0;
            var sames = details.Select(x => x.Name);

            if (DefectHelper.GetHaveSame(wId, sames))
            {
                return(Result.GenError <Result>(Error.DefectIsExist));
            }

            if (details.Any(x => x.Name.IsNullOrEmpty()))
            {
                return(Result.GenError <Result>(Error.DefectNotEmpty));
            }

            var userId         = Request.GetIdentityInformation();
            var markedDateTime = DateTime.Now;

            foreach (var detail in details)
            {
                detail.CreateUserId   = userId;
                detail.MarkedDateTime = markedDateTime;
                detail.Remark         = detail.Remark ?? "";
            }
            DefectHelper.Instance.Add(details);
            return(Result.GenError <Result>(Error.Success));
        }
Exemplo n.º 6
0
        private void Init()
        {
            this.m_ErrorCount   = 0;
            this.m_SucceedCount = 0;

            // 验证
            if (this.m_BaseWorkspace == null)
            {
                SendMessage(enumMessageType.Exception, "检查驱动的Base库没有设置,无法继续检查");
                return;
            }
            if (this.m_QueryWorkspace == null || this.m_QueryConnection == null)
            {
                SendMessage(enumMessageType.Exception, "检查驱动的Query库没有设置,无法继续检查");
                return;
            }

            // 结果库
            try
            {
                string strResultDBFile = this.m_ResultPath + "\\" + COMMONCONST.DB_Name_Result;
                System.IO.File.Copy(System.Windows.Forms.Application.StartupPath + "\\template\\report\\result_AutoTmpl.mdb", strResultDBFile, true);
                this.m_ResultConnection = Hy.Common.Utility.Data.AdoDbHelper.GetDbConnection(strResultDBFile);
            }
            catch (Exception exp)
            {
                SendMessage(enumMessageType.Exception, string.Format("创建结果库出错,信息:{0}", exp.Message));
                return;
            }

            // 创建规则实例,赋值,分类

            if (RuleInfos == null || RuleInfos.Count == 0)
            {
                return;
            }

            int count = RuleInfos.Count;

            m_NormalRuleList  = new List <ICheckRule>();
            m_TopoRuleList    = new List <ICheckRule>();
            m_DictRuleAndInfo = new Dictionary <ICheckRule, SchemaRule>();
            for (int i = 0; i < count; i++)
            {
                if (this.RuleInfos[i] == null || this.RuleInfos[i].ruleDllInfo == null)
                {
                    continue;
                }

                RuleInfo ruleInfo = new RuleInfo();// this.RuleInfos[i].ruleDllInfo;
                ruleInfo.ID            = this.RuleInfos[i].arrayRuleParas[0].strInstID;
                ruleInfo.Name          = this.RuleInfos[i].arrayRuleParas[0].strName;
                ruleInfo.Paramters     = this.RuleInfos[i].arrayRuleParas[0].pParas;
                ruleInfo.RuleClassInfo = this.RuleInfos[i].ruleDllInfo;
                ruleInfo.Description   = this.RuleInfos[i].strRemark;

                //if (ruleClassInfo == null)
                //    continue;

                if (ruleInfo.RuleClassInfo == null)
                {
                    SendMessage(enumMessageType.OperationalLog, string.Format("规则“{0}”无类信息,跳过检查", ruleInfo.Name));
                    continue;
                }

                ICheckRule checkRule = RuleFactory.CreateRuleInstance(ruleInfo.RuleClassInfo.DllName, ruleInfo.RuleClassInfo.ClassName);
                if (checkRule == null)
                {
                    SendMessage(enumMessageType.OperationalLog, string.Format("规则“{0}”反射未成功,跳过检查", ruleInfo.Name));
                    continue;
                }

                try
                {
                    // 参数设置
                    checkRule.BaseWorkspace    = this.m_BaseWorkspace;
                    checkRule.InstanceName     = ruleInfo.Name;
                    checkRule.InstanceID       = ruleInfo.ID;
                    checkRule.DefectLevel      = DefectHelper.GetRuleDefectLevel(ruleInfo.ID);
                    checkRule.MessageHandler   = this.m_Messager;
                    checkRule.QueryConnection  = this.m_QueryConnection;
                    checkRule.QueryWorkspace   = this.m_QueryWorkspace;
                    checkRule.TopoWorkspace    = this.m_TopoWorkspace;
                    checkRule.ResultConnection = this.m_ResultConnection;
                    checkRule.SchemaID         = this.m_SchemaID;
                    checkRule.SetParamters(ruleInfo.Paramters);

                    if (checkRule.ErrorType == enumErrorType.Topology)
                    {
                        if (m_Topology == null)
                        {
                            try
                            {
                                // 先创建Topo库(空库)和结果库
                                if (System.IO.Directory.Exists(this.m_TopoDBPath + "\\" + COMMONCONST.DB_Name_Topo))
                                {
                                    System.IO.Directory.Delete(this.m_TopoDBPath + "\\" + COMMONCONST.DB_Name_Topo, true);
                                }
                                Hy.Common.Utility.Esri.AEAccessFactory.CreateFGDB(this.m_TopoDBPath, COMMONCONST.DB_Name_Topo, ref this.m_TopoWorkspace);
                                if (this.m_TopoWorkspace == null)
                                {
                                    SendMessage(enumMessageType.Exception, "创建拓扑库失败");
                                }

                                // 根据Base库找第一个Geodataset的空间参考,用来创建拓扑库
                                ISpatialReference topoSptatialRef = null;
                                IEnumDataset      enDataset       = this.m_BaseWorkspace.get_Datasets(esriDatasetType.esriDTAny);
                                IDataset          ds = enDataset.Next();
                                while (ds != null)
                                {
                                    if (ds is IGeoDataset)
                                    {
                                        topoSptatialRef = (ds as IGeoDataset).SpatialReference;
                                        break;
                                    }
                                    ds = enDataset.Next();
                                }
                                IFeatureDataset fDataset = (this.m_TopoWorkspace as IFeatureWorkspace).CreateFeatureDataset(COMMONCONST.Dataset_Name, topoSptatialRef);
                                if (fDataset == null)
                                {
                                    SendMessage(enumMessageType.Exception, "创建拓扑库Dataset失败");
                                }

                                ITopologyContainer topoContainer = fDataset as ITopologyContainer;
                                //m_Topology = topoContainer.get_TopologyByName(COMMONCONST.Topology_Name);    // 若已有Topology,则不再创建

                                //if (m_Topology == null)
                                m_Topology = topoContainer.CreateTopology(COMMONCONST.Topology_Name, this.m_TopoTolerance, COMMONCONST.TopoError_MaxCount, "esriConfigurationKeywordTopology");
                            }
                            catch (Exception exp)
                            {
                                SendMessage(enumMessageType.Exception, "创建Topology出错,信息:" + exp.ToString());
                            }
                        }
                        (checkRule as ITopologicalRule).Topology = m_Topology;

                        m_TopoRuleList.Add(checkRule);
                    }
                    else
                    {
                        m_NormalRuleList.Add(checkRule);
                    }
                    //m_RuleList.Add(checkRule);
                    m_DictRuleAndInfo.Add(checkRule, this.RuleInfos[i]);
                }
                catch (Exception ex)
                {
                    SendMessage(enumMessageType.Exception, "初始化规则失败,信息:" + ex.ToString());
                    continue;
                }
            }
        }