Exemplo n.º 1
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (ResourceName.Length != 0)
            {
                hash ^= ResourceName.GetHashCode();
            }
            if (gclid_ != null)
            {
                hash ^= Gclid.GetHashCode();
            }
            if (areaOfInterest_ != null)
            {
                hash ^= AreaOfInterest.GetHashCode();
            }
            if (locationOfPresence_ != null)
            {
                hash ^= LocationOfPresence.GetHashCode();
            }
            if (pageNumber_ != null)
            {
                hash ^= PageNumber.GetHashCode();
            }
            if (adGroupAd_ != null)
            {
                hash ^= AdGroupAd.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 2
0
 public void MergeFrom(ClickView other)
 {
     if (other == null)
     {
         return;
     }
     if (other.ResourceName.Length != 0)
     {
         ResourceName = other.ResourceName;
     }
     if (other.HasGclid)
     {
         Gclid = other.Gclid;
     }
     if (other.areaOfInterest_ != null)
     {
         if (areaOfInterest_ == null)
         {
             AreaOfInterest = new global::Google.Ads.GoogleAds.V8.Common.ClickLocation();
         }
         AreaOfInterest.MergeFrom(other.AreaOfInterest);
     }
     if (other.locationOfPresence_ != null)
     {
         if (locationOfPresence_ == null)
         {
             LocationOfPresence = new global::Google.Ads.GoogleAds.V8.Common.ClickLocation();
         }
         LocationOfPresence.MergeFrom(other.LocationOfPresence);
     }
     if (other.HasPageNumber)
     {
         PageNumber = other.PageNumber;
     }
     if (other.HasAdGroupAd)
     {
         AdGroupAd = other.AdGroupAd;
     }
     if (other.HasCampaignLocationTarget)
     {
         CampaignLocationTarget = other.CampaignLocationTarget;
     }
     if (other.HasUserList)
     {
         UserList = other.UserList;
     }
     if (other.Keyword.Length != 0)
     {
         Keyword = other.Keyword;
     }
     if (other.keywordInfo_ != null)
     {
         if (keywordInfo_ == null)
         {
             KeywordInfo = new global::Google.Ads.GoogleAds.V8.Common.KeywordInfo();
         }
         KeywordInfo.MergeFrom(other.KeywordInfo);
     }
     _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
 }
Exemplo n.º 3
0
 public void BeginVerification(AreaOfInterest areaOfInterest)
 {
     foreach (IVerificationReportBuilder builder in _reportBuilders)
     {
         builder.BeginVerification(areaOfInterest);
     }
 }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description")] AreaOfInterest areaOfInterest)
        {
            if (id != areaOfInterest.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(areaOfInterest);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AreaOfInterestExists(areaOfInterest.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(areaOfInterest));
        }
Exemplo n.º 5
0
        public XmlAreaOfInterest([NotNull] AreaOfInterest aoi)
        {
            Assert.ArgumentNotNull(aoi, nameof(aoi));

            Type = aoi.IsEmpty
                                       ? AreaOfInterestType.Empty
                                       : aoi.Geometry is IPolygon
                                               ? AreaOfInterestType.Polygon
                                               : AreaOfInterestType.Box;

            Description = GetValue(aoi.Description);

            FeatureSource = GetValue(aoi.FeatureSource);
            WhereClause   = GetValue(aoi.WhereClause);

            BufferDistance          = aoi.BufferDistance;
            GeneralizationTolerance = aoi.GeneralizationTolerance;

            if (aoi.ClipExtent != null && !aoi.ClipExtent.IsEmpty)
            {
                ClipExtent = new Xml2DEnvelope(aoi.ClipExtent);
            }

            Extent = aoi.IsEmpty
                                         ? null
                                         : new Xml2DEnvelope(aoi.Extent);
        }
Exemplo n.º 6
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "AreaOfInterest")
     {
         startInteraction = true;
         interactWith     = other.gameObject.GetComponent <AreaOfInterest>();
     }
 }
 public ActionResult Create(AreaOfInterest aoi)
 {
     if (ModelState.IsValid)
     {
         areaOfInterestRepo.create(aoi);
         return(RedirectToAction("Index"));
     }
     return(View(aoi));
 }
 public ActionResult Edit(int id, AreaOfInterest aoi)
 {
     if (ModelState.IsValid)
     {
         areaOfInterestRepo.update(id, aoi);
         return(RedirectToAction("Index"));
     }
     return(View(aoi));
 }
Exemplo n.º 9
0
        public void ExecuteVerification(
            [NotNull] string dataQualityXml,
            [NotNull] string specificationName,
            [NotNull] List <DataSource> dataSourceReplacements,
            [CanBeNull] AreaOfInterest areaOfInterest,
            [CanBeNull] string optionsXml,
            double tileSize,
            string outputDirectoryPath,
            IssueRepositoryType issueRepositoryType = IssueRepositoryType.FileGdb,
            bool ignoreConditionsForUnknownDatasets = true,
            ITrackCancel cancelTracker = null)
        {
            IList <XmlQualitySpecification> qualitySpecifications;
            XmlDataQualityDocument          document = ReadXmlDocument(dataQualityXml,
                                                                       out qualitySpecifications);

            _msg.DebugFormat("Available specifications: {0}",
                             StringUtils.Concatenate(qualitySpecifications.Select(s => s.Name),
                                                     ", "));

            XmlVerificationOptions verificationOptions =
                StringUtils.IsNotEmpty(optionsXml)
                                        ? VerificationOptionUtils.ReadOptionsXml(optionsXml)
                                        : null;

            IList <KeyValuePair <string, string> > properties =
                new List <KeyValuePair <string, string> >();

            Directory.CreateDirectory(outputDirectoryPath);

            try
            {
                int  errorCount;
                int  warningCount;
                int  exceptionCount;
                int  unusedExceptionObjectCount;
                int  rowCountWithStopConditions;
                bool fulfilled = Verify(document, specificationName, dataSourceReplacements,
                                        tileSize, outputDirectoryPath,
                                        issueRepositoryType, properties,
                                        verificationOptions,
                                        areaOfInterest,
                                        cancelTracker,
                                        ignoreConditionsForUnknownDatasets,
                                        out errorCount,
                                        out warningCount,
                                        out exceptionCount,
                                        out unusedExceptionObjectCount,
                                        out rowCountWithStopConditions);
            }
            catch (Exception)
            {
                StandaloneVerificationUtils.TryDeleteOutputDirectory(outputDirectoryPath);
                throw;
            }
        }
Exemplo n.º 10
0
        public async Task <IActionResult> Create([Bind("Id,Name,Description")] AreaOfInterest areaOfInterest)
        {
            if (ModelState.IsValid)
            {
                _context.Add(areaOfInterest);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(areaOfInterest));
        }
Exemplo n.º 11
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="BuildPolygonFromPointsCommand" /> class.
        /// </summary>
        /// <param name="geometryJson"> The geometry json. </param>
        /// <exception cref="System.ArgumentException">No coordinate pairs in area of interest polygon</exception>
        public BuildPolygonFromPointsCommand(AreaOfInterest geometryJson)
        {
            _geometryJson = geometryJson;
            if (_geometryJson.PointCollection.Count < 1)
            {
                throw new ArgumentException("No coordinate pairs in area of interest polygon");
            }

            if (_geometryJson.PointCollection.Count % 2 != 0)
            {
                throw new ArgumentException("Coordinate pairs do not match. Must be even number.");
            }
        }
Exemplo n.º 12
0
        public void BeginVerification(AreaOfInterest areaOfInterest)
        {
            Assert.False(_verificationOngoing, "verification already begun");

            _verificationOngoing   = true;
            _verificationStartTime = DateTime.Now;
            _stopWatch             = Stopwatch.StartNew();
            _areaOfInterest        = areaOfInterest;

            _issuesByQualityCondition.Clear();
            _qualitySpecificationElementsByDataset.Clear();
            _verifiedDatasets.Clear();
            _verifiedQualityConditions.Clear();
        }
        private static void LogBeginVerification(
            [NotNull] QualitySpecification qualitySpecification,
            double tileSize,
            [CanBeNull] AreaOfInterest areaOfInterest)
        {
            using (_msg.IncrementIndentation("Begin quality verification"))
            {
                _msg.InfoFormat("Quality specification: {0}", qualitySpecification.Name);
                _msg.InfoFormat("Verification tile size: {0}", tileSize);

                if (areaOfInterest != null)
                {
                    IGeometry testPerimeter = areaOfInterest.Geometry;

                    if (testPerimeter.IsEmpty)
                    {
                        _msg.Warn("Test perimeter is empty");
                    }
                    else
                    {
                        var envelope = testPerimeter as IEnvelope;

                        string message;
                        if (envelope == null)
                        {
                            Assert.ArgumentCondition(testPerimeter is IPolygon,
                                                     "Unexpected test perimeter type: {0}; must be polygon or envelope",
                                                     testPerimeter.GeometryType);

                            envelope = testPerimeter.Envelope;
                            message  = string.Format("Polygon extent: {0} x {1}",
                                                     envelope.Width, envelope.Height);
                        }
                        else
                        {
                            message = string.Format("Extent: {0} x {1}",
                                                    envelope.Width, envelope.Height);
                        }

                        using (_msg.IncrementIndentation(message))
                        {
                            _msg.InfoFormat("X-Min: {0}", envelope.XMin);
                            _msg.InfoFormat("Y-Min: {0}", envelope.YMin);
                            _msg.InfoFormat("X-Max: {0}", envelope.XMax);
                            _msg.InfoFormat("Y-Max: {0}", envelope.YMax);
                        }
                    }
                }
            }
        }
Exemplo n.º 14
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (ResourceName.Length != 0)
            {
                hash ^= ResourceName.GetHashCode();
            }
            if (HasGclid)
            {
                hash ^= Gclid.GetHashCode();
            }
            if (areaOfInterest_ != null)
            {
                hash ^= AreaOfInterest.GetHashCode();
            }
            if (locationOfPresence_ != null)
            {
                hash ^= LocationOfPresence.GetHashCode();
            }
            if (HasPageNumber)
            {
                hash ^= PageNumber.GetHashCode();
            }
            if (HasAdGroupAd)
            {
                hash ^= AdGroupAd.GetHashCode();
            }
            if (HasCampaignLocationTarget)
            {
                hash ^= CampaignLocationTarget.GetHashCode();
            }
            if (HasUserList)
            {
                hash ^= UserList.GetHashCode();
            }
            if (Keyword.Length != 0)
            {
                hash ^= Keyword.GetHashCode();
            }
            if (keywordInfo_ != null)
            {
                hash ^= KeywordInfo.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 15
0
 public void MergeFrom(ClickView other)
 {
     if (other == null)
     {
         return;
     }
     if (other.ResourceName.Length != 0)
     {
         ResourceName = other.ResourceName;
     }
     if (other.gclid_ != null)
     {
         if (gclid_ == null || other.Gclid != "")
         {
             Gclid = other.Gclid;
         }
     }
     if (other.areaOfInterest_ != null)
     {
         if (areaOfInterest_ == null)
         {
             AreaOfInterest = new global::Google.Ads.GoogleAds.V4.Common.ClickLocation();
         }
         AreaOfInterest.MergeFrom(other.AreaOfInterest);
     }
     if (other.locationOfPresence_ != null)
     {
         if (locationOfPresence_ == null)
         {
             LocationOfPresence = new global::Google.Ads.GoogleAds.V4.Common.ClickLocation();
         }
         LocationOfPresence.MergeFrom(other.LocationOfPresence);
     }
     if (other.pageNumber_ != null)
     {
         if (pageNumber_ == null || other.PageNumber != 0L)
         {
             PageNumber = other.PageNumber;
         }
     }
     if (other.adGroupAd_ != null)
     {
         if (adGroupAd_ == null || other.AdGroupAd != "")
         {
             AdGroupAd = other.AdGroupAd;
         }
     }
     _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
 }
        private bool Verify([NotNull] XmlDataQualityDocument document,
                            [NotNull] string specificationName,
                            [NotNull] IEnumerable <DataSource> dataSources,
                            double tileSize,
                            [NotNull] string directoryPath,
                            IssueRepositoryType issureRepositoryType,
                            [NotNull] IEnumerable <KeyValuePair <string, string> > properties,
                            [CanBeNull] XmlVerificationOptions verificationOptions,
                            [CanBeNull] AreaOfInterest areaOfInterest,
                            [CanBeNull] ITrackCancel trackCancel,
                            bool ignoreConditionsForUnknownDatasets,
                            out int errorCount,
                            out int warningCount,
                            out int exceptionCount,
                            out int unusedExceptionObjectCount,
                            out int rowCountWithStopConditions)
        {
            try
            {
                QualitySpecification qualitySpecification;
                using (_msg.IncrementIndentation("Setting up quality specification"))
                {
                    var modelFactory = new VerifiedModelFactory(
                        CreateSimpleWorkspaceContext, new SimpleVerifiedDatasetHarvester());

                    var datasetOpener = new SimpleDatasetOpener(new MasterDatabaseDatasetContext());

                    var factory =
                        new XmlBasedQualitySpecificationFactory(modelFactory, datasetOpener);

                    qualitySpecification = factory.CreateQualitySpecification(
                        document, specificationName, dataSources,
                        ignoreConditionsForUnknownDatasets);
                }

                return(Verify(qualitySpecification, tileSize, directoryPath,
                              issureRepositoryType, properties, verificationOptions,
                              areaOfInterest, trackCancel,
                              out errorCount,
                              out warningCount,
                              out exceptionCount,
                              out unusedExceptionObjectCount,
                              out rowCountWithStopConditions));
            }
            finally
            {
                GC.Collect();
            }
        }
        private static IssueProcessor CreateIssueProcessor(
            [NotNull] TestContainer testContainer,
            [NotNull] IIssueWriter issueWriter,
            [CanBeNull] AreaOfInterest areaOfInterest,
            [CanBeNull] IExceptionObjectRepository exceptionObjectRepository,
            [NotNull] IDictionary <ITest, QualitySpecificationElement> elementsByTest)
        {
            IGeometry testPerimeter = GetTestPerimeter(areaOfInterest, testContainer);

            return(new IssueProcessor(
                       issueWriter,
                       elementsByTest,
                       testPerimeter,
                       exceptionObjectRepository?.ExceptionObjectEvaluator));
        }
        private static IGeometry GetTestPerimeter([CanBeNull] AreaOfInterest areaOfInterest,
                                                  [NotNull] TestContainer testContainer)
        {
            if (areaOfInterest == null)
            {
                return(null);
            }

            IGeometry result;

            GeometryUtils.EnsureSpatialReference(areaOfInterest.Geometry,
                                                 testContainer.GetSpatialReference(), false,
                                                 out result);
            return(result);
        }
        public static ExceptionObjectRepository PrepareExceptionRepository(
            [NotNull] QualitySpecification qualitySpecification,
            [NotNull] IDatasetContext datasetContext,
            [NotNull] IQualityConditionObjectDatasetResolver datasetResolver,
            [CanBeNull] AreaOfInterest areaOfInterest,
            [CanBeNull] XmlVerificationOptions verificationOptions)
        {
            if (verificationOptions == null)
            {
                return(null);
            }

            IWorkspace workspace = VerificationOptionUtils.GetExceptionWorkspace(
                verificationOptions);

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

            bool useDbfFieldNames = WorkspaceUtils.IsShapefileWorkspace(workspace);

            IIssueTableFieldManagement issueTableFields =
                IssueTableFieldsFactory.GetIssueTableFields(true, useDbfFieldNames);

            var result = new ExceptionObjectRepository(workspace, issueTableFields,
                                                       datasetContext, datasetResolver,
                                                       areaOfInterest?.Geometry);

            List <QualityCondition> qualityConditions =
                qualitySpecification.Elements.Select(element => element.QualityCondition)
                .ToList();

            InvolvedObjectsMatchCriteria involvedObjectsMatchCriteria =
                VerificationOptionUtils.GetInvolvedObjectMatchCriteria(verificationOptions);

            result.ReadExceptions(qualityConditions,
                                  VerificationOptionUtils.GetDefaultShapeMatchCriterion(
                                      verificationOptions),
                                  VerificationOptionUtils.GetDefaultExceptionObjectStatus(
                                      verificationOptions),
                                  involvedObjectsMatchCriteria);
            return(result);
        }
        /// <inheritdoc />
        public override void Start()
        {
            base.Start();

            var observablePosition = new ObservablePosition()
            {
                ToggleEnabledKey = Keys.D1,
                IsEnabled        = true,
            };

            var camera = this.SceneSystem.SceneInstance.RootScene.Entities.First(entity => entity.Name == "Camera");

            camera.Add(observablePosition);
            ////camera.Transform.Position += new Vector3(0, 0, 0);
            camera.Transform.Position += new Vector3(0, 256, 0);

            this.stage = new InterestStage <ChunkKey, bool, Entity>(
                Factory.From((ChunkKey key) => new Entity()), SingleInterest.Merger);

            ////var meshFactory = StreamingStageMeshFactory.CreateCubes();
            ////var meshFactory = StreamingStageMeshFactory.CreateCubeOutlines();
            ////var meshFactory = StreamingStageMeshFactory.CreateNoise();
            var meshFactory = StreamingStageMeshFactory.CreateSkyIsland();

            var viewDiameter = meshFactory.ChunkLength * ViewDiameterInChunks;
            var converter    = new TwoWayTypeConverter <Index3D, ChunkKey>(
                index => new ChunkKey(index), key => key.Index);

            AreaOfInterest.CreateCenteredSpiral(
                new ConverterInterestMap <ChunkKey, Index3D, bool>(this.stage.Interests, converter),
                true,
                observablePosition.PositionChanged.ToMono(),
                new SphereMask <bool>(viewDiameter),
                meshFactory.ChunkLength);

            var stageEntity = new Entity("Stage");

            stageEntity.Add(new StreamingChunkGeneratorScript(this.stage.Chunks, meshFactory));
            this.SceneSystem.SceneInstance.RootScene.Entities.Add(stageEntity);
        }
Exemplo n.º 21
0
        public NotificationOptionsDialog(AreaOfInterest area)

        {
            _area = area;
            InitializeComponent();

            int count = 0;

            foreach (var url in area.Notifications.Urls)
            {
                ListViewItem urlItem = new ListViewItem(new string[] { url.Url, url.CoolDown.CooldownTime.ToString() });
                urlsList.Items.Add(urlItem);
                urlItem.Checked = url.Active;
                urlItem.Tag     = url;

                ++count;
            }

            count = 0;
            foreach (var option in area.Notifications.Email)
            {
                ListViewItem emailItem = new ListViewItem(new string[] { option.EmailAddress, option.CoolDown.CooldownTime.ToString() });
                emailsList.Items.Add(emailItem);
                emailItem.Tag     = option;
                emailItem.Checked = option.Active;
                ++count;
            }

            if (emailsList.Items.Count > 0)
            {
                emailsList.Items[0].Selected = true;
                emailsList.Select();
            }

            if (urlsList.Items.Count > 0)
            {
                urlsList.Items[0].Selected = true;
                urlsList.Select();
            }
        }
        /// <summary>
        /// Verifies the specified object classes.
        /// </summary>
        /// <param name="qualitySpecification">The quality specification to verify.</param>
        /// <param name="datasetContext">The model context.</param>
        /// <param name="datasetResolver">The resolver for getting the object dataset based on a table name, in the context of a quality condition</param>
        /// <param name="issueRepository">The issue repository.</param>
        /// <param name="exceptionObjectRepository">The exception object repository</param>
        /// <param name="tileSize">Tile size for the quality verification.</param>
        /// <param name="getKeyFieldName">Function for getting the key field name for an object dataset</param>
        /// <param name="areaOfInterest">The area of interest for the verification (optional).</param>
        /// <param name="trackCancel">The cancel tracker.</param>
        /// <returns></returns>
        public bool Verify(
            [NotNull] QualitySpecification qualitySpecification,
            [NotNull] IDatasetContext datasetContext,
            [NotNull] IQualityConditionObjectDatasetResolver datasetResolver,
            [CanBeNull] IIssueRepository issueRepository,
            [CanBeNull] IExceptionObjectRepository exceptionObjectRepository,
            double tileSize,
            [CanBeNull] Func <IObjectDataset, string> getKeyFieldName,
            [CanBeNull] AreaOfInterest areaOfInterest,
            [CanBeNull] ITrackCancel trackCancel)
        {
            int errorCount;
            int warningCount;
            int rowCountWithStopConditions;

            return(Verify(qualitySpecification, datasetContext, datasetResolver,
                          issueRepository, exceptionObjectRepository, tileSize,
                          getKeyFieldName, areaOfInterest, trackCancel,
                          out errorCount,
                          out warningCount,
                          out rowCountWithStopConditions));
        }
Exemplo n.º 23
0
 // Area of Interest function
 public JsonResult AreaofInterest(string data, bool flag)
 {
     try
     {
         // Creating object for AreaOfInterest class
         AreaOfInterest aoi_obj = new AreaOfInterest();
         // Calling the GetAreaOfInterest
         aoi_obj.GetAreaofInterest(data, flag);
         //Checking error is empty or not
         if (aoi_obj.Error == "")  //converting all object array to Json and returning the Json
         {
             return(Json(new { Left = aoi_obj.Left, Top = aoi_obj.Top, Width = aoi_obj.Width, Height = aoi_obj.Height, Error = "" }));
         }
         else
         {
             return(Json(new { Left = "", Top = "", Width = "", Height = "", Error = aoi_obj.Error }));
         }
     }
     catch (Exception e)// handling runtime errors and returning error as Json
     {
         return(Json(new { Erorr = e.Message }));
     }
 }
Exemplo n.º 24
0
        private void UpdateRedFlagNotifications(string countryCode)
        {
            RedFlagsNotifications.Clear();

            var redFlags = new AreaOfInterest()
            {
                MapModel = new MapModel(BmpPlanner)
                {
                    Shading = MapPolygonExtensions.REDFLAG_AREA_SHADING,
                    Stroke  = MapPolygonExtensions.REDFLAG_AREA_STROKE
                }
            };

            switch (countryCode)
            {
            case "UNITED STATES":
                var fireAlerts = NationalWeatherService.QueryFireAlerts(NationalWeatherService.RED_FLAG_ALERT, countryCode);
                if (fireAlerts.Any())
                {
                    NationalWeatherService.ConvertUGCtoPolygon(fireAlerts, redFlags.MapModel);
                }
                break;

            case "ARGENTINA":
                NationalWeatherService.GetAllPolygonsFromShape(redFlags.MapModel, "ar");
                break;
            }

            AnyRedFlagsNotification = redFlags.MapModel.Polygons.Any() ? Visibility.Visible : Visibility.Collapsed;
            if (AnyRedFlagsNotification == Visibility.Visible)
            {
                RedFlagsNotifications.Add(redFlags);
            }

            NotifyPropertyChanged("AnyRedFlagsNotification");
            NotifyPropertyChanged("RedFlagsNotifications");
        }
Exemplo n.º 25
0
 private void RemoveObjectReferences()
 {
     startInteraction = false;
     interactWith     = null;
 }
Exemplo n.º 26
0
        public void Execute(IEnumerable <ITest> tests, AreaOfInterest areaOfInterest,
                            CancellationTokenSource cancellationTokenSource)
        {
            Assert.NotNull(QualitySpecification, "QualitySpecification has not been initialized.");
            Assert.NotNull(TestAssembler, "TestAssembler has not been initialized.");

            StartVerification(QualityVerification);

            CancellationTokenSource = cancellationTokenSource;

            IList <IList <QualityCondition> > qcGroups =
                TestAssembler.BuildQualityConditionGroups(tests.ToList(), areaOfInterest,
                                                          FilterTableRowsUsingRelatedGeometry,
                                                          _originalRequest.MaxParallelProcessing);

            foreach (IList <QualityCondition> qcGroup in qcGroups)
            {
                if (qcGroup.Count == 0)
                {
                    continue;
                }

                VerificationRequest subRequest =
                    CreateSubRequest(_originalRequest, QualitySpecification, qcGroup);

                SubResponse subResponse = new SubResponse();

                Task <bool> task = Task.Run(
                    async() =>
                    await VerifyAsync(_qaClient, subRequest, subResponse,
                                      CancellationTokenSource),
                    CancellationTokenSource.Token);

                // Process the messages even though the foreground thread is blocking/busy processing results
                task.ConfigureAwait(false);
                _tasks.Add(Assert.NotNull(task), subResponse);

                Thread.Sleep(50);
            }

            while (_tasks.Count > 0)
            {
                if (TryTakeCompletedRun(_tasks, out Task <bool> task,
                                        out SubResponse subResponse))
                {
                    ProcessFinalResult(task, subResponse);

                    _msg.InfoFormat("Remaining work unit verifications: {0}", _tasks.Count);
                }
                else
                {
                    // Process intermediate errors (might need de-duplication or other manipulation in the future)

                    bool reportProgress = false;
                    foreach (SubResponse response in _tasks.Values)
                    {
                        if (DrainIssues(response))
                        {
                            reportProgress = true;
                        }

                        if (UpdateOverallProgress(response))
                        {
                            reportProgress = true;
                        }
                    }

                    if (reportProgress)
                    {
                        var eventArgs = new VerificationProgressEventArgs(
                            VerificationProgressType.ProcessParallel, OverallProgressCurrent,
                            OverallProgressTotal);

                        eventArgs.Tag = "TODO";
                        Progress?.Invoke(this, eventArgs);
                    }
                }

                Thread.Sleep(100);
            }

            EndVerification(QualityVerification);
        }
        /// <summary>
        /// Verifies the specified object classes.
        /// </summary>
        /// <param name="qualitySpecification">The quality specification to verify.</param>
        /// <param name="datasetContext">The model context.</param>
        /// <param name="datasetResolver">The resolver for getting the object dataset based on a table name, in the context of a quality condition</param>
        /// <param name="issueRepository">The issue repository.</param>
        /// <param name="exceptionObjectRepository">The exception object repository</param>
        /// <param name="tileSize">Tile size for the quality verification.</param>
        /// <param name="getKeyFieldName">Function for getting the key field name for an object dataset</param>
        /// <param name="areaOfInterest">The test run perimeter (optional).</param>
        /// <param name="trackCancel">The cancel tracker.</param>
        /// <param name="errorCount">The number of (hard) errors.</param>
        /// <param name="warningCount">The number of warnings.</param>
        /// <param name="rowCountWithStopConditions">The number of rows for which a stop condition was violated - those rows may not be completely tested.</param>
        /// <returns></returns>
        public bool Verify([NotNull] QualitySpecification qualitySpecification,
                           [NotNull] IDatasetContext datasetContext,
                           [NotNull] IQualityConditionObjectDatasetResolver datasetResolver,
                           [CanBeNull] IIssueRepository issueRepository,
                           [CanBeNull] IExceptionObjectRepository exceptionObjectRepository,
                           double tileSize,
                           [CanBeNull] Func <IObjectDataset, string> getKeyFieldName,
                           [CanBeNull] AreaOfInterest areaOfInterest,
                           [CanBeNull] ITrackCancel trackCancel,
                           out int errorCount,
                           out int warningCount,
                           out int rowCountWithStopConditions)
        {
            Assert.ArgumentNotNull(qualitySpecification, nameof(qualitySpecification));
            Assert.ArgumentNotNull(datasetContext, nameof(datasetContext));
            Assert.ArgumentNotNull(datasetResolver, nameof(datasetResolver));
            Assert.ArgumentCondition(tileSize > 0, "Invalid tile size: {0}", tileSize);

            _verificationReportBuilder.BeginVerification(areaOfInterest);

            IEnumerable <QualitySpecificationElement> elements =
                GetOrderedElements(qualitySpecification).ToList();

            IDictionary <ITest, QualitySpecificationElement> elementsByTest;
            IEnumerable <ITest> tests =
                CreateTests(elements, datasetContext, out elementsByTest).ToList();

            var qualityConditionCount = 0;

            foreach (QualitySpecificationElement element in elements)
            {
                qualityConditionCount++;
                _verificationReportBuilder.AddVerifiedQualityCondition(element);
            }

            var datasetCount = 0;

            foreach (Dataset dataset in
                     GetVerifiedDatasets(qualitySpecification, datasetContext))
            {
                datasetCount++;
                _verificationReportBuilder.AddVerifiedDataset(dataset);
            }

            Stopwatch watch = _msg.DebugStartTiming();

            LogTests(tests, elementsByTest);

            TestContainer testContainer = CreateTestContainer(tests, tileSize);

            LogBeginVerification(qualitySpecification, tileSize, areaOfInterest);

            IssueProcessor    issueProcessor;
            ProgressProcessor progressProcessor;

            using (var issueWriter = new BufferedIssueWriter(_verificationReportBuilder,
                                                             datasetContext, datasetResolver,
                                                             issueRepository,
                                                             getKeyFieldName))
            {
                issueProcessor = CreateIssueProcessor(testContainer, issueWriter,
                                                      areaOfInterest, exceptionObjectRepository,
                                                      elementsByTest);

                progressProcessor = new ProgressProcessor(testContainer, elementsByTest,
                                                          trackCancel);

                testContainer.QaError += (sender, args) => issueProcessor.Process(args);

                testContainer.TestingRow +=
                    delegate(object o, RowEventArgs args)
                {
                    if (issueProcessor.HasStopCondition(args.Row))
                    {
                        args.Cancel = true;
                    }
                };

                testContainer.ProgressChanged +=
                    (sender, args) => progressProcessor.Process(args);

                // run the tests
                TestExecutionUtils.Execute(testContainer, areaOfInterest);
            }

            _verificationReportBuilder.AddRowsWithStopConditions(
                issueProcessor.GetRowsWithStopConditions());

            if (exceptionObjectRepository != null)
            {
                _verificationReportBuilder.AddExceptionStatistics(
                    exceptionObjectRepository.ExceptionStatistics);
            }

            _verificationReportBuilder.EndVerification(progressProcessor.Cancelled);

            _msg.DebugStopTiming(watch, "Verification");

            errorCount   = issueProcessor.ErrorCount;
            warningCount = issueProcessor.WarningCount;
            rowCountWithStopConditions = issueProcessor.RowsWithStopConditionsCount;

            bool fulfilled = errorCount == 0 && !progressProcessor.Cancelled;

            LogResults(elements, issueProcessor,
                       qualityConditionCount, datasetCount,
                       fulfilled, progressProcessor.Cancelled,
                       exceptionObjectRepository?.ExceptionStatistics);

            return(fulfilled);
        }
        private bool Verify([NotNull] QualitySpecification qualitySpecification,
                            double tileSize,
                            [NotNull] string directory,
                            IssueRepositoryType issueRepositoryType,
                            [NotNull] IEnumerable <KeyValuePair <string, string> > properties,
                            [CanBeNull] XmlVerificationOptions verificationOptions,
                            [CanBeNull] AreaOfInterest areaOfInterest,
                            [CanBeNull] ITrackCancel trackCancel,
                            out int errorCount,
                            out int warningCount,
                            out int exceptionCount,
                            out int unusedExceptionObjectCount,
                            out int rowCountWithStopConditions)
        {
            Model primaryModel = StandaloneVerificationUtils.GetPrimaryModel(qualitySpecification);

            Assert.NotNull(primaryModel, "no primary model found for quality specification");

            // TODO disable quality conditions based on primaryModel and DatasetTestParameterValue.UsedAsReferenceData?
            // TODO this would probably require an explicit identification of the primary data source
            XmlVerificationReportBuilder xmlReportBuilder = GetReportBuilder();
            var statisticsBuilder = new IssueStatisticsBuilder();

            var datasetsCollector = new InvolvedDatasetsCollector();

            var service = new StandaloneQualityVerificationService(
                new MultiReportBuilder(xmlReportBuilder,
                                       statisticsBuilder,
                                       datasetsCollector),
                (context) => new SimpleDatasetOpener(context));

            // This context excludes geometric networks, terrains, topology, etc.:
            var datasetContext  = new MasterDatabaseDatasetContext();
            var datasetResolver =
                new QualityConditionObjectDatasetResolver(
                    new MasterDatabaseWorkspaceContextLookup());

            string issueWorkspaceName =
                VerificationOptionUtils.GetIssueWorkspaceName(verificationOptions);
            string verificationReportFileName =
                VerificationOptionUtils.GetXmlReportFileName(verificationOptions);

            ISpatialReference spatialReference =
                primaryModel.SpatialReferenceDescriptor?.SpatialReference;

            var  issueGdbWritten = false;
            bool fulfilled;

            List <string> htmlReportFilePaths;
            List <string> specificationReportFilePaths;
            string        gdbPath = null;

            Func <IObjectDataset, string> getKeyField =
                StandaloneVerificationUtils.GetKeyFieldLookupFunction(verificationOptions);

            ExceptionObjectRepository exceptionObjectRepository =
                StandaloneVerificationUtils.PrepareExceptionRepository(
                    qualitySpecification, datasetContext, datasetResolver, areaOfInterest,
                    verificationOptions);

            using (IIssueRepository issueRepository =
                       ExternalIssueRepositoryUtils.GetIssueRepository(
                           directory, issueWorkspaceName, spatialReference, issueRepositoryType,
                           addExceptionFields: true))
            {
                fulfilled = service.Verify(qualitySpecification, datasetContext, datasetResolver,
                                           issueRepository, exceptionObjectRepository, tileSize,
                                           getKeyField,
                                           areaOfInterest, trackCancel,
                                           out errorCount,
                                           out warningCount,
                                           out rowCountWithStopConditions);

                if (issueRepository != null)
                {
                    issueGdbWritten = true;

                    gdbPath = ((IWorkspace)issueRepository.FeatureWorkspace).PathName;

                    _msg.InfoFormat("Issues written to {0}", gdbPath);

                    issueRepository.CreateIndexes(GetForSubProcess(trackCancel),
                                                  ignoreErrors: true);
                }

                using (_msg.IncrementIndentation("Documenting verification results..."))
                {
                    XmlVerificationReport verificationReport = GetVerificationReport(
                        xmlReportBuilder, qualitySpecification, properties);

                    string verificationReportPath = Path.Combine(directory,
                                                                 verificationReportFileName);
                    XmlUtils.Serialize(verificationReport, verificationReportPath);

                    _msg.InfoFormat("Verification report written to {0}", verificationReportPath);

                    IssueStatistics issueStatistics = statisticsBuilder.IssueStatistics;

                    if (issueRepository != null)
                    {
                        var issueStatisticsWriter =
                            new IssueStatisticsWriter(issueRepository.FeatureWorkspace);

                        issueStatisticsWriter.WriteStatistics(issueStatistics);

                        if (spatialReference != null &&
                            areaOfInterest != null &&
                            !areaOfInterest.IsEmpty)
                        {
                            var aoiWriter =
                                new AreaOfInterestWriter(issueRepository.FeatureWorkspace);
                            aoiWriter.WriteAreaOfInterest(areaOfInterest, spatialReference);
                        }
                    }

                    specificationReportFilePaths =
                        StandaloneVerificationUtils.WriteQualitySpecificationReport(
                            qualitySpecification, directory, _qualitySpecificationTemplatePath,
                            verificationOptions);

                    htmlReportFilePaths = StandaloneVerificationUtils.WriteHtmlReports(
                        qualitySpecification, directory, issueStatistics, verificationReport,
                        verificationReportFileName, _htmlReportTemplatePath, verificationOptions,
                        issueGdbWritten ? gdbPath : null,
                        null, specificationReportFilePaths);
                }
            }

            GC.Collect();
            GC.WaitForPendingFinalizers();

            if (htmlReportFilePaths.Count > 0)
            {
                using (_msg.IncrementIndentation(htmlReportFilePaths.Count == 1
                                                                         ? "Html report:"
                                                                         : "Html reports:"))
                {
                    foreach (string path in htmlReportFilePaths)
                    {
                        _msg.Info(path);
                    }
                }
            }

            if (specificationReportFilePaths.Count > 0)
            {
                using (_msg.IncrementIndentation(specificationReportFilePaths.Count == 1
                                                                         ? "Quality specification report:"
                                                                         : "Quality specification reports:"))
                {
                    foreach (string path in specificationReportFilePaths)
                    {
                        _msg.Info(path);
                    }
                }
            }

            if (exceptionObjectRepository != null)
            {
                IExceptionStatistics stats = exceptionObjectRepository.ExceptionStatistics;
                exceptionCount             = stats.ExceptionCount;
                unusedExceptionObjectCount = stats.UnusedExceptionObjectCount;
            }
            else
            {
                exceptionCount             = 0;
                unusedExceptionObjectCount = 0;
            }

            return(fulfilled);
        }
Exemplo n.º 29
0
        public async Task <ActionResult> Index()
        {
            //Check for initial RUN
            if (appdbContext.Users.Count() == 0)
            {
                //make new roles for Administrator, Trainer, Student
                IdentityRole adminrole = new IdentityRole()
                {
                    Name = "Administrator"
                };
                IdentityRole trainerrole = new IdentityRole()
                {
                    Name = "Trainer"
                };
                IdentityRole studentrole = new IdentityRole()
                {
                    Name = "Student"
                };

                appdbContext.Roles.Add(adminrole);
                appdbContext.Roles.Add(trainerrole);
                appdbContext.Roles.Add(studentrole);
                appdbContext.SaveChanges();

                //make Default Area of interest entry as "Computer Science"
                AreaOfInterest aoi = new AreaOfInterest()
                {
                    Name = "Computer Science"
                };
                context.AreaOfInterests.Add(aoi);
                context.SaveChanges();

                //register new user Administrator
                RegisterViewModel model = new RegisterViewModel();
                model.Email           = "*****@*****.**";
                model.Password        = "******";
                model.ConfirmPassword = "******";
                string Role = "Administrator";

                ApplicationUser user = new ApplicationUser();
                user.UserName = "******";
                user.Email    = "*****@*****.**";

                var res = await UserManager.CreateAsync(user, model.Password);

                //assign administrator user to Administrator role
                UserManager.AddToRole(user.Id, Role);
            }



            //get all courses and show courses
            var result = courseRepo.getData();

            //store logged in user data in viewbag
            if (User != null && User.IsInRole("Student"))
            {
                string  userId = User.Identity.GetUserId();
                Student user   = context.Students.Where(e => e.UserId == userId).FirstOrDefault();
                ViewBag.loggedInUser = user.StudentRowId;
            }

            return(View(result));
        }
Exemplo n.º 30
0
 public void BeginVerification(AreaOfInterest areaOfInterest)
 {
 }