/// <summary>
        /// Connects the end.
        /// When connecting the end, it also updates information in the experiment model data.
        /// </summary>
        /// <param name='end'>
        /// End.
        /// </param>
        public override void ConnectEnd(MonoHotDraw.Connectors.IConnector end)
        {
            base.ConnectEnd(end);

            if (end != null)
            {
                IComponentControl startComponentControl = StartConnector.Owner as IComponentControl;
                IComponentControl endComponentControl   = end.Owner as IComponentControl;
                if (endComponentControl != null && startComponentControl != null)
                {
                    //get access to owner experiment
                    IEditableExperiment ownerExperiment = endComponentControl.ExperimentNode.Owner as IEditableExperiment;
                    if (ownerExperiment != null)
                    {
                        ExperimentNodeConnection nodeConnection = ownerExperiment.AddConnection(startComponentControl.ExperimentNode, endComponentControl.ExperimentNode);
                        OnConnectionCompleted(nodeConnection);
                        m_experimentNodeConnection = nodeConnection;

                        // SPRINT 2: TLAB-129
                        CommentNode comment = nodeConnection.Source as CommentNode;
                        if (comment != null)
                        {
                            isSourceComment = true;
                        }
                        // END SPRINT 2: TLAB-129
                    }
                }
            }
        }
Example #2
0
        public void AddLogMessage(IComponentControl componentControl, LogMessage logMessage)
        {
            if (componentControl == null)
            {
                return;
            }
            if (logMessage == null)
            {
                return;
            }
            if (Disabled)
            {
                return;
            }
            var webLogs = new WebLogMessage()
            {
                Attemps          = 0,
                ComponentControl = componentControl,
                CreateDate       = DateTime.Now,
                Order            = Order,
                Date             = logMessage.Date,
                Level            = logMessage.Level,
                Message          = logMessage.Message,
                Context          = logMessage.Context,
                Properties       = logMessage.Properties
            };

            webLogs.Size = GetMessageSize(webLogs);
            LogQueue.Add(webLogs);
            Order++;

            OnAddLogMessage?.Invoke(componentControl, logMessage);
        }
Example #3
0
 public static void CheckComponent(GetOrCreateComponentData createData, IComponentControl control)
 {
     Assert.False(control.IsFake());
     CheckComponent(createData, control.Info);
     Assert.Equal(createData.SystemName, control.SystemName);
     Assert.Equal(createData.Version, control.Version);
 }
 public UnitTestControlOffline(
     IComponentControl component,
     IUnitTestTypeControl type,
     string systemName)
     : base(component, type, systemName)
 {
 }
Example #5
0
        protected void InitMonitoring()
        {
            var client = SystemAccountHelper.GetInternalSystemClient();

            // Создадим компонент
            // Если запускаемся в отладке, то компонент будет не в корне, а в папке DEBUG
            var folder        = !DebugHelper.IsDebugMode ? client.GetRootComponentControl() : client.GetRootComponentControl().GetOrCreateChildFolderControl("DEBUG");
            var componentType = client.GetOrCreateComponentTypeControl(!DebugHelper.IsDebugMode ? "Agent" : DebugHelper.DebugComponentType);

            ComponentControl = folder
                               .GetOrCreateChildComponentControl(new GetOrCreateComponentData("Agent", componentType)
            {
                DisplayName = "Агент",
                Version     = AgentHelper.GetVersion()
            });

            // Присвоим Id компонента по умолчанию, чтобы адаптер NLog мог его использовать
            Client.Instance = client;
            Client.Instance.Config.DefaultComponent.Id = ComponentControl.Info?.Id;

            Logger = LogManager.GetLogger("Agent");
            Logger.Info("Запуск, IsFake={0}", ComponentControl.IsFake());

            AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
        }
Example #6
0
 public static void CheckComponent(IComponentControl a, IComponentControl b)
 {
     Assert.False(a.IsFake());
     Assert.False(b.IsFake());
     CheckComponent(a.Info, b.Info);
     Assert.Equal(a.SystemName, b.SystemName);
     Assert.Equal(a.Version, b.Version);
 }
Example #7
0
        public static ApplicationErrorData CreateRandomApplicationError(IComponentControl component)
        {
            var randomName = GetRandomSystemName();
            var eventData  = component.CreateApplicationError("RandomApplicationError " + randomName);

            InitRandomEvent(eventData);
            return(eventData);
        }
Example #8
0
 public ComponentSelfTest(IComponentControl componentControl)
 {
     if (componentControl == null)
     {
         throw new ArgumentNullException("componentControl");
     }
     _componentControl = componentControl;
 }
Example #9
0
        public static ComponentEventData CreateRandomComponentEvent(IComponentControl component)
        {
            var randomName = GetRandomSystemName();
            var eventData  = component.CreateComponentEvent("RandomComponentEvent " + randomName);

            InitRandomEvent(eventData);
            return(eventData);
        }
Example #10
0
 public static void CheckExternalStatus(Guid accountId, IComponentControl componentControl, Core.Api.MonitoringStatus status)
 {
     using (var accountDbContext = AccountDbContext.CreateFromAccountId(accountId))
     {
         var component = accountDbContext.Components.First(x => x.Id == componentControl.Info.Id);
         Assert.Equal(component.ExternalStatus.Status, status);
     }
 }
Example #11
0
 public static void CheckMetricaStatus(Guid accountId, IComponentControl componentControl, string metricName, Core.Api.MonitoringStatus status)
 {
     using (var accountDbContext = AccountDbContext.CreateFromAccountId(accountId))
     {
         var component = accountDbContext.Components.First(x => x.Id == componentControl.Info.Id);
         var metric    = component.Metrics.Single(x => x.MetricType.SystemName == metricName && x.IsDeleted == false);
         Assert.Equal(metric.Bulb.Status, status);
     }
 }
Example #12
0
 public UnitTestControlOnline(IComponentControl component, IUnitTestTypeControl type, UnitTestInfo info)
     : base(component, type, info.SystemName)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     InfoInternal = info;
 }
Example #13
0
        public IComponentControl CreateRandomComponentControl(IComponentControl parent = null)
        {
            var client        = GetClient();
            var parentControl = parent ?? client.GetRootComponentControl();
            var message       = TestHelper.GetRandomGetOrCreateComponentData(client);
            var newComponent  = parentControl.GetOrCreateChildComponentControl(message);

            return(newComponent);
        }
Example #14
0
        public MetricsMiddleware(RequestDelegate next)
        {
            _next = next;

            var client = Client.Instance;

            _component = client.GetDefaultComponentControl();
            _stopwatch = new Stopwatch();
        }
Example #15
0
        public Log(IComponentControl componentControl)
        {
            if (componentControl == null)
            {
                throw new ArgumentNullException("componentControl");
            }

            ComponentControl = componentControl;
        }
Example #16
0
 protected long GetGlobalJoinKey(IComponentControl componentControl, SendEventBase eventData)
 {
     return(HashHelper.GetInt64(
                componentControl.SystemName,
                eventData.TypeSystemName,
                eventData.JoinKey.ToString(),
                eventData.EventCategory.ToString(),
                (eventData.Importance ?? EventImportance.Unknown).ToString(),
                eventData.Version));
 }
        protected string FixEventVersion(IComponentControl componentControl, string version)
        {
            string value = FixVersion(version);

            if (string.IsNullOrEmpty(value))
            {
                value = componentControl.Version;
            }
            return(FixVersion(value));
        }
Example #18
0
 public void Detatch()
 {
     if (owner != null && owner.HasComponent(ComponentTypes.COMPONENT_PLAYER_CONTROL))
     {
         IComponentControl controlComponent = (IComponentControl)owner.FindComponent(ComponentTypes.COMPONENT_PLAYER_CONTROL);
         controlComponent.Enabled = false;
         IsFreeCamera             = true;
     }
     owner   = null;
     ownerID = "";
 }
Example #19
0
 public void EndReloadConfig(IComponentControl componentControl)
 {
     lock (ReloadConfigsSynchRoot)
     {
         ReloadControls.Remove(componentControl);
         if (componentControl.IsFake() == false)
         {
             ReloadControls.RemoveAll(x => x.IsFake() == false && x.Info.Id == componentControl.Info.Id);
         }
     }
 }
Example #20
0
 public static void SetControl(IComponentControl control)
 {
     if (control == null)
     {
         throw new ArgumentNullException("control");
     }
     Events.ComponentControl      = GetCacheControl(control, "EventsCache");
     StatusDatas.ComponentControl = GetCacheControl(control, "StatusDatasCache");
     UnitTests.ComponentControl   = GetCacheControl(control, "UnitTestsCache");
     Components.ComponentControl  = GetCacheControl(control, "ComponentsCache");
 }
Example #21
0
 public void BeginReloadConfig(IComponentControl componentControl)
 {
     lock (ReloadConfigsSynchRoot)
     {
         var data = ReloadControls.FirstOrDefault(x => x == componentControl);
         if (data == null)
         {
             ReloadControls.Add(componentControl);
         }
     }
 }
Example #22
0
 private Bulb GetInternalStatus(TestAccountInfo account, IComponentControl componentControl)
 {
     using (var accountDbContext = account.CreateAccountDbContext())
     {
         var id        = componentControl.Info.Id;
         var component = accountDbContext.Components.Single(x => x.Id == id);
         var status    = component.InternalStatus;
         var r         = status.Status;
         return(status);
     }
 }
Example #23
0
 protected SendEventBase(IComponentControl componentControl, string typeSystemName)
 {
     if (componentControl == null)
     {
         throw new ArgumentNullException("componentControl");
     }
     if (typeSystemName == null)
     {
         throw new ArgumentNullException("typeSystemName");
     }
     ComponentControl = componentControl;
     TypeSystemName   = typeSystemName;
     Properties       = new ExtentionPropertyCollection();
 }
Example #24
0
 public IComponentControl GetRootComponentControl()
 {
     if (_rootComponentControl == null)
     {
         lock (typeof(Client))
         {
             if (_rootComponentControl == null)
             {
                 _rootComponentControl = ComponentControlWrapper.CreateRoot(this);
             }
         }
     }
     return(_rootComponentControl);
 }
Example #25
0
 public BufferEventData(IComponentControl componentControl, SendEventBase eventBase)
 {
     if (componentControl == null)
     {
         throw new ArgumentNullException("componentControl");
     }
     if (eventBase == null)
     {
         throw new ArgumentNullException("eventBase");
     }
     ComponentControl = componentControl;
     SendEventBase    = eventBase;
     Init();
 }
Example #26
0
        public static void Init(IComponentControl componentControl)
        {
            if (componentControl == null)
            {
                throw new ArgumentNullException("componentControl");
            }
            ComponentControl = componentControl;

            // запустим тест самопроверки
            SelfTest = new ComponentSelfTest(ComponentControl);
            SelfTest.AddUnitTest("GetServerTime", GetServerTimeTest);
            SelfTest.AddUnitTest("CheckComponentControl", CheckComponentControl);
            SelfTest.StartTimer(TimeSpan.FromMinutes(1));
        }
Example #27
0
 public IComponentControl GetDefaultComponentControl()
 {
     if (_defaultComponentControl == null)
     {
         lock (typeof(Client))
         {
             if (_defaultComponentControl == null)
             {
                 _defaultComponentControl = ComponentControlWrapper.GetDefault(this);
             }
         }
     }
     return(_defaultComponentControl);
 }
Example #28
0
        private void CheckStatus(
            TestAccountInfo account,
            IComponentControl control,
            MonitoringStatus internalStatus,
            MonitoringStatus externalStatus)
        {
            var client        = account.GetClient();
            var internalState = client.ApiService.GetComponentInternalState(control.Info.Id, false).Data;

            Assert.Equal(internalStatus, internalState.Status);
            var totalState = client.ApiService.GetComponentTotalState(control.Info.Id, false).Data;

            Assert.Equal(externalStatus, totalState.Status);
        }
Example #29
0
        public ApplicationErrorData CreateEventFromLog(IComponentControl componentControl, LogLevel level, Exception exception, string message, IDictionary <string, object> properties)
        {
            EventImportance importance;

            if (level == LogLevel.Fatal)
            {
                importance = EventImportance.Alarm;
            }
            else if (level == LogLevel.Warning || level == LogLevel.Error)
            {
                importance = EventImportance.Warning;
            }
            else if (level == LogLevel.Info)
            {
                importance = EventImportance.Success;
            }
            else
            {
                importance = EventImportance.Unknown;
            }

            ApplicationErrorData data;

            if (exception != null)
            {
                data = componentControl.CreateApplicationError(exception);
                if (data.Message != message)
                {
                    data.Message = message + " : " + data.Message;
                }
            }
            else
            {
                data = componentControl.CreateApplicationError("CustomError", message);
                data.SetProperty(ExtentionPropertyName.Stack, Environment.StackTrace);
            }

            data.SetImportance(importance).SetProperty("FromLog", true);

            var propertiesCollection = new ExtentionPropertyCollection(properties);

            foreach (var property in propertiesCollection)
            {
                data.Properties.Add(property);
            }

            return(data);
        }
Example #30
0
 public DispatcherWrapper(
     IDispatcherService service,
     IComponentControl componentControl)
 {
     if (service == null)
     {
         throw new ArgumentNullException("service");
     }
     if (componentControl == null)
     {
         throw new ArgumentNullException("componentControl");
     }
     InternalService = service;
     Control         = componentControl;
     DeadLockHunter  = new DeadLockHunter(componentControl);
 }
 public PixToggleButtonHandle(IComponentControl owner, ILocator locator, Gdk.Pixbuf iconOff, Gdk.Pixbuf iconOn)
     : base (owner, locator) 
 {
     m_imageOff = GdkCairoHelper.PixbufToImageSurface(iconOff);
     m_imageOn = GdkCairoHelper.PixbufToImageSurface(iconOn);
 }
 public RemoveNodeHandle(IComponentControl owner, ILocator locator): base (owner, locator, s_trashIcon) 
 {
     m_ownerComponent = owner;
 }