コード例 #1
0
 public virtual void LogClusterHealthState(ClusterEntity cluster)
 {
     MonitoringEventSource.Current.LogClusterHealthState(
         cluster.ClusterName,
         cluster.Health.AggregatedHealthState.ToString(),
         cluster.Health.GetHealthEvaluationString());
 }
コード例 #2
0
        protected void MasterPage_YesClickHandler(object sender, EventArgs e)
        {
            if (ViewState["Delete"] != null)
            {
                try
                {
                    ClusterEntity entity = new ClusterEntity();
                    entity.OperationId = (int)OperationType.Delete;
                    entity.ClusterId   = Utility.GetLong(ViewState["ClusterId"]);

                    OperationStatusEntity c = new ConfigrationRepository(SessionContext).UpdateCluster(entity);

                    if (c.StatusResult == true)
                    {
                        ShowInfoMessage(c.InfoMessage);
                        ClearPageControl();
                        FillGrid();
                    }
                    else
                    {
                        ShowErrorMessage(c.InfoMessage);
                    }
                }
                catch (BaseException bex)
                {
                    ShowErrorMessage(bex.Message);
                }
            }
        }
コード例 #3
0
 public override void EmitClusterHealthState(ClusterEntity cluster)
 {
     AppendToFile(
         string.Format(
             "clusterHealthMetric: ClusterName: {0}, HealthState: {1}",
             cluster.ClusterName,
             cluster.Health.AggregatedHealthState.ToString()));
 }
コード例 #4
0
        public OperationStatusEntity UpdateCluster(ClusterEntity param)
        {
            var parameters = new object[]
            {
                param.OperationId, param.RegionId, param.ZoneId, param.BranchId, param.HubId, param.ClusterId, param.ClusterName
            };

            return(EntityBase.FillObject <OperationStatusEntity>("ClusterManage", parameters));
        }
コード例 #5
0
 public override void LogClusterHealthState(ClusterEntity cluster)
 {
     AppendToFile(
         string.Format(
             "LogClusterHealthState: ClusterName: {0}, HealthState: {1}, EvaluationString: {2}",
             cluster.ClusterName,
             cluster.Health.AggregatedHealthState.ToString(),
             cluster.Health.GetHealthEvaluationString()));
 }
コード例 #6
0
 public override void LogClusterHealthEvent(
     ClusterEntity cluster, EntityHealthEvent healthEvent)
 {
     AppendHealthEventToFile(
         string.Format(
             "LogClusterHealthEvent: ClusterName: {0}",
             cluster.ClusterName),
         healthEvent);
 }
コード例 #7
0
        public async Task SaveTagsAndModelAsync(List <Tag> tags, NewsEntity newsEntity)
        {
            // Check if this article is already in database
            var allNewsDesctiptions = await context.NewsEntities.Select(t => t.Description).ToListAsync();

            if (allNewsDesctiptions.Contains(newsEntity.Description))
            {
                throw new DbUpdateException("News article already in DB.");
            }

            // Create new cluster for news item
            var cluster = new ClusterEntity {
                Id = Guid.NewGuid(), NewsCount = 1
            };

            // Link cluster to news item
            newsEntity.ClusterId = cluster.Id;

            if (tags != null)
            {
                var newTags = new List <TagEntity>();
                var allTags = await context.Tags.Select(t => t).ToListAsync();

                foreach (var tag in tags)
                {
                    if (!allTags.Any(t => t.Name == tag.Name))
                    {
                        newTags.Add(new TagEntity()
                        {
                            Id   = Guid.NewGuid(),
                            Name = tag.Name
                        });
                    }
                }
                context.Tags.AddRange(newTags);
                allTags.AddRange(newTags);

                // Adding links between clusters and tags
                foreach (var tag in tags)
                {
                    context.TagsClusters.Add(
                        new TagClusterEntity
                    {
                        ClusterId           = cluster.Id,
                        TagId               = allTags.Where(t => t.Name == tag.Name).FirstOrDefault().Id,
                        OccurencesCount     = tag.OccurencesCount,
                        NormOccurencesCount = tag.NormCount
                    });
                }
            }

            context.Clusters.Add(cluster);
            context.NewsEntities.Add(newsEntity);
            await context.SaveChangesAsync();
        }
コード例 #8
0
        public virtual void EmitClusterHealthState(ClusterEntity cluster)
        {
            if (!this.isMetricsEnabled)
            {
                return;
            }

            this.clusterHealthMetric.LogValue(
                1,
                cluster.ClusterName,
                cluster.Health.AggregatedHealthState.ToString());
        }
コード例 #9
0
 public virtual void LogClusterHealthEvent(
     ClusterEntity cluster, EntityHealthEvent healthEvent)
 {
     MonitoringEventSource.Current.LogClusterHealthEvent(
         cluster.ClusterName,
         healthEvent.HealthState.ToString(),
         healthEvent.Description,
         healthEvent.Property,
         healthEvent.SequenceNumber.ToString(),
         healthEvent.SourceId,
         healthEvent.IsExpired.ToString());
 }
コード例 #10
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                ValidateBusinessData("G1");
                ValidateBusinessData("G2");
                ValidateBusinessData("G3");
                ValidateBusinessData("G4");
                ValidateBusinessData("G5");

                ClusterEntity entity = new ClusterEntity();

                if (Convert.ToString(ViewState["Add"]) == "Add")
                {
                    entity.OperationId = 1;
                }
                else if (Convert.ToString(ViewState["Update"]) == "Update")
                {
                    entity.OperationId = 2;
                    entity.ClusterId   = Utility.GetLong(ViewState["ClusterId"]);
                }

                entity.ClusterName = txtClusterName.Text.Trim();

                entity.RegionId = Utility.GetLong(ddlRegion.SelectedValue);
                entity.ZoneId   = Utility.GetLong(ddlZone.SelectedValue);
                entity.BranchId = Utility.GetLong(ddlBranch.SelectedValue);
                entity.HubId    = Utility.GetLong(ddlHub.SelectedValue);

                OperationStatusEntity c = new ConfigrationRepository(SessionContext).UpdateCluster(entity);

                if (c.StatusResult == true)
                {
                    ShowInfoMessage(c.InfoMessage);
                    ClearPageControl();
                    FillGrid();
                }
                else
                {
                    ShowErrorMessage(c.InfoMessage);
                }
            }
            catch (ValidationException ex)
            {
                ShowErrorMessage(ex.Message);
            }

            catch (BaseException be)
            {
                ShowErrorMessage(be.DisplayMessage);
            }
        }
コード例 #11
0
        public override Task ProcessClusterHealthAsync(ClusterEntity cluster)
        {
            this.eventWriter.LogClusterHealthState(cluster);
            this.metrics.EmitClusterHealthState(cluster);

            cluster.Health.HealthEvents
            .ForEachHealthEvent(healthEvent =>
            {
                this.eventWriter.LogClusterHealthEvent(cluster, healthEvent);
            });

            return(this.completedTask);
        }
コード例 #12
0
        public virtual void EmitClusterHealthEvent(
            ClusterEntity cluster, EntityHealthEvent healthEvent)
        {
            if (!this.isMetricsEnabled)
            {
                return;
            }

            this.clusterHealthEventMetric.LogValue(
                1,
                cluster.ClusterName,
                healthEvent.HealthState.ToString(),
                healthEvent.SourceId,
                healthEvent.Property,
                healthEvent.IsExpired.ToString());
        }
コード例 #13
0
    public List <int> RequestSituationFromCluster(int clusterID)
    {
        List <int> result     = new List <int>();
        LocalDb    _ClusterDB = new LocalDb("Cluster");

        //New situation
        System.Data.IDataReader reader = _ClusterDB.getSitByCluster(clusterID.ToString());
        while (reader.Read())
        {
            ClusterEntity entity = new ClusterEntity(reader[0].ToString(), reader[1].ToString(), reader[2].ToString());
            result = entity._sitID;
            result.Insert(0, int.Parse(entity._socialImpact));
        }
        result = _ClusterDB.updateSitStatus(result);
        _ClusterDB.close();
        return(result);
    }
コード例 #14
0
        public async Task SaveClusterAndTagsAsync(ClusterEntity cluster, List <Tag> tags)
        {
            var allTags = await context.Tags.Select(t => t).ToListAsync();

            foreach (var tag in tags)
            {
                context.TagsClusters.Add(
                    new TagClusterEntity
                {
                    ClusterId           = cluster.Id,
                    TagId               = allTags.Where(t => t.Name == tag.Name).FirstOrDefault().Id,
                    OccurencesCount     = tag.OccurencesCount,
                    NormOccurencesCount = tag.NormCount
                });
            }

            context.Clusters.Add(cluster);
            await context.SaveChangesAsync();
        }
コード例 #15
0
        public Guid MergeClusters(List <ClusterEntity> clusters)
        {
            // Create new cluster
            var newCluster = new ClusterEntity {
                Id = Guid.NewGuid(), NewsCount = clusters.Sum(c => c.NewsCount)
            };

            // Add dependencies to Subcluster
            foreach (ClusterEntity cluster in clusters)
            {
                context.Subclusters.Add(new SubclusterEntity {
                    ChildId = cluster.Id, ParentId = newCluster.Id
                });
            }

            // Add average vector to TagCluster



            context.SaveChangesAsync();

            // Return new Guid
            return(newCluster.Id);
        }