private string Build(
            MessageType type,
            string path,
            ComponentStatus status)
        {
            using (_logger.Scope("Getting contents for message of type {MessageType} with path {ComponentPath} and status {ComponentStatus}.",
                                 type, path, status))
            {
                if (!_messageTypeToMessageTemplate.TryGetValue(type, out string messageTemplate))
                {
                    throw new ArgumentException("Could not find a template for type.", nameof(type));
                }

                _logger.LogInformation("Using template {MessageTemplate}.", messageTemplate);

                var nameString = GetName(path);
                _logger.LogInformation("Using {ComponentName} for name of component.", nameString);

                var actionDescription = GetActionDescriptionFromPath(path);
                if (actionDescription == null)
                {
                    throw new ArgumentException("Could not find an action description for path.", nameof(path));
                }

                var statusString = status.ToString().ToLowerInvariant();
                var contents     = string.Format(messageTemplate, nameString, statusString, actionDescription);
                _logger.LogInformation("Returned {Contents} for contents of message.", contents);
                return(contents);
            }
        }
Exemplo n.º 2
0
 public MessageChangeEvent(DateTime timestamp, string affectedComponentPath, ComponentStatus affectedComponentStatus, MessageType type)
 {
     Timestamp               = timestamp;
     AffectedComponentPath   = affectedComponentPath;
     AffectedComponentStatus = affectedComponentStatus;
     Type = type;
 }
Exemplo n.º 3
0
            public async Task CreatesStartMessageFromNullContext(ComponentStatus status)
            {
                var child = new TestComponent("child");
                var root  = new TreeComponent("hi", "", new[] { child });

                var affectedComponent = root.GetByNames <IComponent>(root.Name, child.Name);
                var change            = new MessageChangeEvent(
                    DefaultTimestamp,
                    affectedComponent.Path,
                    status,
                    MessageType.Start);

                var result = await Processor.ProcessAsync(change, EventEntity, root, null);

                Assert.Equal(change.Timestamp, result.Timestamp);
                Assert.Equal(affectedComponent, result.AffectedComponent);
                Assert.Equal(affectedComponent.Status, result.AffectedComponentStatus);

                Factory
                .Verify(
                    x => x.CreateMessageAsync(
                        EventEntity,
                        DefaultTimestamp,
                        MessageType.Start,
                        affectedComponent),
                    Times.Once());
            }
 public string Build(
     MessageType type,
     IComponent component,
     ComponentStatus status)
 {
     return(Build(type, component.Path, status));
 }
Exemplo n.º 5
0
            public async Task UpdatesExistingStartMessageFromContext(ComponentStatus changeStatus, ComponentStatus existingStatus)
            {
                var changedChild  = new TestComponent("child");
                var existingChild = new TestComponent("existing");
                var root          = new TreeComponent("hi", "", new[] { changedChild, existingChild });

                var affectedComponent = root.GetByNames <IComponent>(root.Name, changedChild.Name);
                var change            = new MessageChangeEvent(
                    DefaultTimestamp,
                    affectedComponent.Path,
                    changeStatus,
                    MessageType.Start);

                var existingAffectedComponent = root.GetByNames <IComponent>(root.Name, existingChild.Name);
                var context = new ExistingStartMessageContext(
                    new DateTime(2018, 10, 9),
                    existingAffectedComponent,
                    existingStatus);

                var result = await Processor.ProcessAsync(change, EventEntity, root, context);

                Assert.Equal(context.Timestamp, result.Timestamp);
                Assert.Equal(root, result.AffectedComponent);
                Assert.Equal(root.Status, result.AffectedComponentStatus);

                Factory
                .Verify(
                    x => x.UpdateMessageAsync(
                        EventEntity,
                        context.Timestamp,
                        MessageType.Start,
                        root),
                    Times.Once());
            }
Exemplo n.º 6
0
            public async Task CreatesEndMessageWithContext(ComponentStatus changeStatus, ComponentStatus existingStatus)
            {
                var child = new TestComponent("child");

                child.Status = changeStatus;
                var root = new PrimarySecondaryComponent("hi", "", new[] { child });

                var affectedComponent = root.GetByNames <IComponent>(root.Name, child.Name);
                var change            = new MessageChangeEvent(
                    DefaultTimestamp + TimeSpan.FromDays(1),
                    affectedComponent.Path,
                    changeStatus,
                    MessageType.End);

                var context = new ExistingStartMessageContext(
                    DefaultTimestamp,
                    root,
                    existingStatus);

                var result = await Processor.ProcessAsync(change, EventEntity, root, context);

                Assert.Null(result);

                Factory
                .Verify(
                    x => x.CreateMessageAsync(
                        EventEntity,
                        change.Timestamp,
                        MessageType.End,
                        context.AffectedComponent,
                        context.AffectedComponentStatus),
                    Times.Once());
            }
Exemplo n.º 7
0
        public void ReturnsStatusIfSetWithoutSubComponents(ComponentStatus status)
        {
            var component = CreateComponent("component", "description");

            component.Status = status;

            Assert.Equal(status, component.Status);
        }
Exemplo n.º 8
0
 public ReadOnlyComponent(
     string name,
     string description,
     ComponentStatus status,
     IEnumerable <ReadOnlyComponent> subComponents)
     : this(name, description, status, subComponents?.Cast <IReadOnlyComponent>())
 {
 }
Exemplo n.º 9
0
        public void EditComponent(int id)
        {
            target(SaveComponent, id);
            Component c = cdb.findById <Component>(id);

            set("c.Name", c.Name);
            radioList("status", ComponentStatus.GetAllStatus(), "Name=Id", c.Status);
        }
Exemplo n.º 10
0
 public EventEntity(
     string affectedComponentPath,
     ComponentStatus affectedComponentStatus,
     DateTime startTime,
     DateTime?endTime = null)
     : this(affectedComponentPath, (int)affectedComponentStatus, startTime, endTime)
 {
 }
Exemplo n.º 11
0
        public virtual void EditComponent(long id)
        {
            target(SaveComponent, id);
            Component c = cdb.findById <Component>(id);

            set("c.Name", c.Name);
            radioList("status", ComponentStatus.GetStatusList(c.TypeFullName), "Name=Id", c.Status);
        }
Exemplo n.º 12
0
 public AlwaysSameValueTestComponent(
     ComponentStatus value,
     string name,
     string description)
     : base(name, description)
 {
     _returnedStatus = value;
 }
Exemplo n.º 13
0
 public ReadOnlyComponent(
     string name,
     string description,
     ComponentStatus status,
     IEnumerable <IReadOnlyComponent> subComponents)
     : this(name, description, subComponents)
 {
     Status = status;
 }
 public ExistingStartMessageContext(
     DateTime timestamp,
     IComponent affectedComponent,
     ComponentStatus affectedComponentStatus)
 {
     Timestamp               = timestamp;
     AffectedComponent       = affectedComponent;
     AffectedComponentStatus = affectedComponentStatus;
 }
        public void ReturnsSubStatusIfStatusNotSet(ComponentStatus subStatus)
        {
            var subComponent = CreateComponent("subComponent", "subdescription");

            subComponent.Status = subStatus;

            var component = CreateComponent("component", "description", new[] { subComponent });

            Assert.Equal(subStatus, component.Status);
        }
Exemplo n.º 16
0
 public AlwaysSameValueTestComponent(
     ComponentStatus value,
     string name,
     string description,
     IEnumerable <IComponent> subComponents,
     bool displaySubComponents = true)
     : base(name, description, subComponents, displaySubComponents)
 {
     _returnedStatus = value;
 }
Exemplo n.º 17
0
 public override void StopInternal(bool stopInstances, bool forceStop, float target, float curve, double scheduleEnd = 0.0)
 {
     if (_looped && _playMode == RandomComponentPlayMode.RandomNoRepeat && _triggerMode == RandomComponentTriggerMode.Retrigger)
     {
         _retriggerTime  = 0f;
         _retriggerTimer = 0f;
     }
     base.StopInternal(stopInstances, forceStop, target, curve, scheduleEnd);
     _status = ComponentStatus.Stopped;
 }
Exemplo n.º 18
0
 public override void Action()
 {
     foreach (Component target in targets)
     {
         if (target != null && !ComponentStatus.IsEnabled(target))
         {
             ComponentStatus.SetComponentEnabled(target);
         }
     }
 }
            public void BuildsContentsSuccessfully(MessageType type, string[] names, ComponentStatus status, Func <string, string> getExpected)
            {
                var root      = new NuGetServiceComponentFactory().Create();
                var component = root.GetByNames(names);
                var result    = Invoke(type, component, status);

                Assert.Equal(
                    getExpected(GetStatus(component, status).ToString().ToLowerInvariant()),
                    result);
            }
Exemplo n.º 20
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (_formListViewInitialItems.SelectedItem == null)
            {
                return;
            }

            _formListViewInitialItems.SelectedItem.Priority      = comboBoxPriority.SelectedItem as Priority ?? Priority.UNK;
            _formListViewInitialItems.SelectedItem.Measure       = comboBoxMeasure.SelectedItem as Measure ?? Measure.Unknown;
            _formListViewInitialItems.SelectedItem.Quantity      = (double)numericUpDownQuantity.Value;
            _formListViewInitialItems.SelectedItem.Remarks       = metroTextBox1.Text;
            _formListViewInitialItems.SelectedItem.AirportCodeId = ((AirportsCodes)comboBoxStation.SelectedItem)?.ItemId ?? -1;
            _formListViewInitialItems.SelectedItem.Reference     = metroTextBoxReference.Text;

            ComponentStatus costCondition = ComponentStatus.Unknown;

            if (checkBoxNew.Checked)
            {
                costCondition = costCondition | ComponentStatus.New;
            }
            if (checkBoxServiceable.Checked)
            {
                costCondition = costCondition | ComponentStatus.Serviceable;
            }
            if (checkBoxOverhaul.Checked)
            {
                costCondition = costCondition | ComponentStatus.Overhaul;
            }
            if (checkBoxRepair.Checked)
            {
                costCondition = costCondition | ComponentStatus.Repair;
            }

            _formListViewInitialItems.SelectedItem.CostCondition = costCondition;

            if (comboBoxDestination.SelectedItem != null)
            {
                var destination = comboBoxDestination.SelectedItem as BaseEntityObject;
                if (destination != null)
                {
                    _formListViewInitialItems.SelectedItem.DestinationObjectType = destination.SmartCoreObjectType;
                    _formListViewInitialItems.SelectedItem.DestinationObjectId   = destination.ItemId;
                }
                else
                {
                    _formListViewInitialItems.SelectedItem.DestinationObjectType = SmartCoreType.Unknown;
                    _formListViewInitialItems.SelectedItem.DestinationObjectId   = -1;
                }
            }

            _formListViewInitialItems.SetItemsArray(_addedInitialOrderRecords.ToArray());

            _formListViewInitialItems.radGridView1.ClearSelection();
            Reset();
        }
Exemplo n.º 21
0
        /// <summary>
        /// Создает запись  без дополнительной информации
        /// </summary>
        public InitialOrderRecord(int rfqId, Product accessory, double quantity,
                                  BaseEntityObject parent,
                                  DateTime effDate,
                                  ComponentStatus costCondition,
                                  NextPerformance perfornamce = null,
                                  DeferredCategory category   = null) : this()
        {
            ParentPackageId = rfqId;

            if (accessory != null)
            {
                ProductId        = accessory.ItemId;
                ProductType      = accessory.SmartCoreObjectType;
                EffectiveDate    = effDate;
                DeferredCategory = category ?? DeferredCategory.Unknown;
                CostCondition    = costCondition;
                _quantity        = quantity;

                if (perfornamce != null)
                {
                    Task                    = perfornamce.Parent;
                    PackageItemId           = perfornamce.Parent.ItemId;
                    PackageItemType         = perfornamce.Parent.SmartCoreObjectType;
                    PerformanceNumFromStart = perfornamce.PerformanceNum;
                    IsSchedule              = true;
                }
                if (DeferredCategory != DeferredCategory.Unknown && DeferredCategory.Threshold != null)
                {
                    LifeLimit       = DeferredCategory.Threshold.FirstPerformanceSinceEffectiveDate;
                    LifeLimitNotify = DeferredCategory.Threshold.FirstNotification;
                    IsSchedule      = false;
                }
                if (parent != null && !parent.SmartCoreObjectType.Equals(SmartCoreType.Operator))
                {
                    DestinationObject     = parent;
                    DestinationObjectType = parent.SmartCoreObjectType;
                    DestinationObjectId   = parent.ItemId;
                }
            }
            else
            {
                PackageItemId           = -1;
                EffectiveDate           = DateTime.Today;
                costCondition           = ComponentStatus.Unknown;
                PackageItemType         = SmartCoreType.Unknown;
                DeferredCategory        = DeferredCategory.Unknown;
                _quantity               = 0;
                Task                    = null;
                ProductId               = -1;
                ProductType             = SmartCoreType.Unknown;
                PerformanceNumFromStart = -1;
                IsSchedule              = false;
            }
        }
Exemplo n.º 22
0
        public async Task <ComponentStatus> EvaluateAsync(string component, CloudBlobClient client, Func <CloudBlobClient, Task <bool> > fn)
        {
            var details = new Dictionary <string, object>
            {
                ["Uri"] = client.BaseUri
            };

            return(await fn(client)
                ? ComponentStatus.Up(component, details)
                : ComponentStatus.Down(component, details));
        }
Exemplo n.º 23
0
 private void SetStatus(Type type, ComponentStatus status)
 {
     if (type != null)
     {
         SetStatus(GetMetadata(type), status);
     }
     else
     {
         _logger.Log(string.Format("Unable to set status of component \"{0}\"", type.Name), LogMessageSeverity.Error);
     }
 }
            private void AssertComponentStatus(ComponentStatus expected, IComponent component, params ComponentAffectingEntity[] entities)
            {
                Assert.Equal(expected, component.Status);
                Assert.Equal(component.Path, entities.First().AffectedComponentPath);

                for (var i = 1; i < entities.Count(); i++)
                {
                    Assert.Equal(
                        entities[i - 1].AffectedComponentPath,
                        entities[i].AffectedComponentPath);
                }
            }
Exemplo n.º 25
0
            public async Task CreatesEntityAndDoesNotIncreaseSeverity(ComponentStatus existingStatus)
            {
                var input = new ParsedIncident(Incident, "the path", ComponentStatus.Degraded);

                IncidentEntity entity = null;

                Table
                .Setup(x => x.InsertOrReplaceAsync(It.IsAny <ITableEntity>()))
                .Returns(Task.CompletedTask)
                .Callback <ITableEntity>(e =>
                {
                    Assert.IsType <IncidentEntity>(e);
                    entity = e as IncidentEntity;
                });

                var group = new IncidentGroupEntity
                {
                    RowKey = "parentRowKey",
                    AffectedComponentStatus = (int)existingStatus
                };

                Provider
                .Setup(x => x.GetAsync(input))
                .ReturnsAsync(group);

                var expectedPath = "the provided path";

                PathProvider
                .Setup(x => x.Get(input))
                .Returns(expectedPath);

                var result = await Factory.CreateAsync(input);

                Assert.Equal(entity, result);

                Assert.Equal(input.Id, entity.IncidentApiId);
                Assert.Equal(group.RowKey, entity.ParentRowKey);
                Assert.Equal(expectedPath, entity.AffectedComponentPath);
                Assert.Equal((int)input.AffectedComponentStatus, entity.AffectedComponentStatus);
                Assert.Equal(input.StartTime, entity.StartTime);
                Assert.Equal(input.EndTime, entity.EndTime);
                Assert.Equal((int)existingStatus, group.AffectedComponentStatus);

                Table
                .Verify(
                    x => x.InsertOrReplaceAsync(It.IsAny <IncidentEntity>()),
                    Times.Once());

                Table
                .Verify(
                    x => x.ReplaceAsync(It.IsAny <IncidentGroupEntity>()),
                    Times.Never());
            }
Exemplo n.º 26
0
 public EditStatusEventManualChangeEntity(
     string eventAffectedComponentPath,
     ComponentStatus eventAffectedComponentStatus,
     DateTime eventStartTime,
     bool eventIsActive)
     : base(ManualStatusChangeType.EditStatusEvent)
 {
     EventAffectedComponentPath   = eventAffectedComponentPath ?? throw new ArgumentNullException(nameof(eventAffectedComponentPath));
     EventAffectedComponentStatus = (int)eventAffectedComponentStatus;
     EventStartTime = eventStartTime;
     EventIsActive  = eventIsActive;
 }
 public AddStatusEventManualChangeEntity(
     string eventAffectedComponentPath,
     ComponentStatus eventAffectedComponentStatus,
     string messageContents,
     bool eventIsActive)
     : base(ManualStatusChangeType.AddStatusEvent)
 {
     EventAffectedComponentPath   = eventAffectedComponentPath ?? throw new ArgumentNullException(nameof(eventAffectedComponentPath));
     EventAffectedComponentStatus = (int)eventAffectedComponentStatus;
     MessageContents = messageContents ?? throw new ArgumentNullException(nameof(messageContents));
     EventIsActive   = eventIsActive;
 }
Exemplo n.º 28
0
 public Event(
     string affectedComponentPath,
     ComponentStatus affectedComponentStatus,
     DateTime startTime,
     DateTime?endTime,
     IEnumerable <Message> messages)
 {
     AffectedComponentPath   = affectedComponentPath;
     AffectedComponentStatus = affectedComponentStatus;
     StartTime = startTime;
     EndTime   = endTime;
     Messages  = messages;
 }
        public static string GetComponentStatus(ComponentStatus status)
        {
            var statusText = status switch
            {
                ComponentStatus.Operational => "Operational",
                ComponentStatus.PerformanceIssues => "Performance Issues",
                ComponentStatus.PartialOutage => "Partial Outage",
                ComponentStatus.MajorOutage => "Major Outage",
                _ => "Unknown"
            };

            return(statusText);
        }
Exemplo n.º 30
0
        private void SetStatus(ComponentMetadata info, ComponentStatus status)
        {
            if (info != null)
            {
                info.Status = status;

                _logger.Log(string.Format("Set component \"{0}\" status to \"{1}\".", info.FriendlyName, info.Status));
            }
            else
            {
                _logger.Log("Unable to set status, Null argument provided.", LogMessageSeverity.Error);
            }
        }
    public UnitComponentData( UnitComponentData _src )
    {
        this.m_Name = _src.m_Name ;
        this.m_HP = new StandardParameter( _src.m_HP ) ;
        this.m_Energy = new StandardParameter( _src.m_Energy ) ;
        this.m_Generation = new StandardParameter( _src.m_Generation ) ;
        this.m_Effect = new StandardParameter( _src.m_Effect ) ;

        this.m_Status = _src.m_Status ;
        this.m_StatusDescription = new StatusDescription( _src.m_StatusDescription ) ;
        this.m_Effect_HP_Curve = new InterpolateTable( _src.m_Effect_HP_Curve ) ;

        this.m_ReloadEnergy = new StandardParameter( _src.m_ReloadEnergy ) ;
        this.m_ReloadGeneration = new StandardParameter( _src.m_ReloadGeneration ) ;
        this.m_WeaponReloadStatus = _src.m_WeaponReloadStatus ;

        this.m_ComponentParam = new ComponentParam( _src.m_ComponentParam ) ;
        this.m_WeaponParam = new WeaponParam( _src.m_WeaponParam ) ;
    }
    public static Color GetColor( ComponentStatus _status )
    {
        Color retColor = Color.white ;
        switch( _status )
        {
        case ComponentStatus.Offline :
        case ComponentStatus.OfflineAble :
        case ComponentStatus.OfflineRepair :
        case ComponentStatus.ForceOffline :
            retColor = Color.gray ;
            break ;
        case ComponentStatus.Normal :
            retColor = new Color( 0.5f , 1.0f , 0.5f , 1 ) ;
            break ;
        case ComponentStatus.Holding :
            retColor = Color.yellow ;
            break ;
        case ComponentStatus.Danger :
            retColor = new Color( 1.0f , 0.5f , 0 , 1 ) ;
            break ;
        }

        return retColor ;
    }
Exemplo n.º 33
0
 public ComponentHealth(string componentName, ComponentStatus status)
 {
     ComponentName = componentName;
     Status = status;
 }