public void SendChildStatusMessageToParentApps(string appId, string status)
        {
            Component component = ComponentLogic.GetByAppId(appId);

            if (component != null)
            {
                var parentComponents = ComponentLogic.GetParentComponents(component);
                if (parentComponents != null && parentComponents.Count > 0)
                {
                    foreach (var parent in parentComponents)
                    {
                        AppStatus AggregatedStatus = AppStatus.Up;
                        if (status == "Down" || parent.HeartBeatStatus == HeartBeatStatus.Down)
                        {
                            AggregatedStatus = AppStatus.Down;
                        }
                        else
                        {
                            //check through health message status and other children component messages to determine final status
                            //what of if the parent app is down, not sending heart beats this check would then not be sufficient
                            var checkStatus = HealthMessageUtility.GetStatusBasedOnHealthChecks(parent.AppID);
                            var appStatus   = HealthMessageUtility.GetStatusBasedOnChildrenApps(parent);
                            // AggregatedStatus = HealthMessageUtility.ReturnAggregateStatus(checkStatus, appStatus);
                        }
                        //Update the Status of the Application in the database
                        parent.Status     = AggregatedStatus;
                        parent.LastUpdate = DateTime.Now;
                        ComponentLogic.EditEntity(parent);
                        Clients.All.reportAppStatus(parent.AppID, AggregatedStatus.ToString());
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string appID = Convert.ToString(Request.QueryString["appID"]);

            if (!string.IsNullOrEmpty(appID))
            {
                isEdit = true;
            }
            else
            {
                isEdit = false;
            }
            if (!IsPostBack)
            {
                appList = ComponentDb.GetAll();
                BindData();
                if (isEdit)
                {
                    Component application = ComponentLogic.GetByAppId(appID);
                    AppNameTxt.Value = application.AppName;
                    // AppIDTxt.Value = application.AppID;
                    if (application.ChildrenComponents != null && application.ChildrenComponents.Count > 0)
                    {
                        foreach (var item in application.ChildrenComponents)
                        {
                            ListItem listItem = new ListItem(item.AppName, item.Id.ToString());
                            listItem.Selected = true;
                            AppsDrpDown.Items.Add(listItem);
                        }
                    }
                    SaveButton.Text = "Update";
                    ID = application.Id.ToString();
                }
            }
        }
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            Component application;
            Dictionary <string, Component> appListDic = new Dictionary <string, Component>();

            appListDic = appList.ToDictionary <Component, string>(x => x.Id.ToString());
            string appName       = AppNameTxt.Value;
            string appID         = AppIDTxt.Value;
            var    selectedItems = from item in AppsDrpDown.Items.Cast <ListItem>() where item.Selected select appListDic[item.Value];

            application = ComponentLogic.GetByAppId(appID);
            if (!isEdit)
            {
                application                 = new Component();
                application.Status          = AppStatus.Down;
                application.HeartBeatStatus = HeartBeatStatus.Down;
            }
            application.AppID              = appID;
            application.AppName            = appName;
            application.ChildrenComponents = selectedItems.ToList();
            if (isEdit)
            {
                ComponentLogic.EditEntity(application);
                Response.Redirect("view-applications.html");
            }
            else
            {
                ComponentLogic.AddNewEntity(application);
                Response.Redirect(Request.RawUrl);
            }
        }
        public void LoadApplicationInfo(string appId)
        {
            Component component = ComponentLogic.GetByAppId(appId);
            string    data      = JsonConvert.SerializeObject(component);

            Clients.All.loadApplicationInfo(data);
        }
        public static void SendHealthMessage(SelfHealthMessage healthMessage)
        {
            AppStatus AggregatedStatus   = AppStatus.Up;
            string    failedMessagesJson = string.Empty;

            //Step 1: Get Aggregate Status of AppID depeding on status of related health messages
            var checkStatus = GetStatusBasedOnHealthChecks(healthMessage.AppID);

            //Step 2: Check if there is a App set up with this ID if there is, get agg status of APP depending on status of Child Apps.
            Component component = ComponentLogic.GetByAppId(healthMessage.AppID);

            if (component != null)
            {
                var appStatus = GetStatusBasedOnChildrenApps(component, AggregatedStatus);
                AggregatedStatus = ReturnAggregateStatus(checkStatus, appStatus);
                //Update the Status of the Application in the database
                component.Status     = AggregatedStatus;
                component.LastUpdate = DateTime.Now;
                ComponentLogic.EditEntity(component);
            }

            string status = AggregatedStatus.ToString();

            GlobalHost.ConnectionManager.GetHubContext <HealthMessageHub>().Clients.All.addHealthMessage(healthMessage.AppID,
                                                                                                         healthMessage.Results[0].Title,
                                                                                                         String.Format("{0:d/M/yyyy HH:mm:ss}", healthMessage.DateChecked),
                                                                                                         String.Format("{0:HH:mm:ss}", healthMessage.DateChecked),
                                                                                                         Convert.ToString(healthMessage.OverallStatus),
                                                                                                         healthMessage.Results[0].TimeElasped,
                                                                                                         healthMessage.Results[0].AdditionalInformation,
                                                                                                         AggregatedStatus.ToString(),
                                                                                                         failedMessagesJson);
        }
        public void LoadAllApplications()
        {
            List <Component> components = ComponentLogic.GetAllComponents();
            string           data       = JsonConvert.SerializeObject(components);

            Clients.All.loadAllApllications(data);
        }
Exemple #7
0
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);

            bool setUpCommand = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["SetUpDejaVuCommands"]);

            if (setUpCommand)
            {
                ComponentLogic.SetUpAppForDejaVuCommands();
            }
        }
Exemple #8
0
        public FormProductComponent(ComponentLogic logic)
        {
            InitializeComponent();
            List <ComponentViewModel> list = logic.Read(null);

            if (list != null)
            {
                comboBoxComponent.DisplayMember = "ComponentName";
                comboBoxComponent.ValueMember   = "Id";
                comboBoxComponent.DataSource    = list;
                comboBoxComponent.SelectedItem  = null;
            }
        }
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            Component application;
            Dictionary <string, Component> appListDic = new Dictionary <string, Component>();

            appListDic = appList.ToDictionary <Component, string>(x => x.Id.ToString());
            string appName = AppNameTxt.Value;
            string appID   = string.Empty;

            //  string appID = AppIDTxt.Value;
            if (!isEdit)
            {
                appID = new ComponentLogic().GenerateAppID();
            }
            else
            {
                appID = Convert.ToString(Request.QueryString["appID"]);
            }
            var    selectedItems = from item in AppsDrpDown.Items.Cast <ListItem>() where item.Selected select appListDic[item.Value];
            string state;
            bool   isExists = ComponentLogic.isExist(appID, appName, ID, out state);

            if (isExists)
            {
                ShowNotification(false, string.Format("An Application with this {0} already exists", state), "");
                return;
            }
            application = ComponentLogic.GetByAppId(appID);
            if (!isEdit)
            {
                application                 = new Component();
                application.Status          = AppStatus.Down;
                application.HeartBeatStatus = HeartBeatStatus.Down;
            }
            application.AppID              = appID;
            application.AppName            = appName;
            application.ChildrenComponents = selectedItems.ToList();
            if (isEdit)
            {
                ComponentLogic.EditEntity(application);
                ShowNotification(true, "Sucessfully Updated", "view-applications.html");
                //Response.Redirect("view-applications.html");
            }
            else
            {
                ComponentLogic.AddNewEntity(application);
                ShowNotification(true, string.Format("Sucessfully Created, APPLICATION ID: {0}", application.AppID), "AddApplication.aspx");
                //Response.Redirect(Request.RawUrl);
            }
        }
        public void UpdateHeartBeat(string appId, string status)
        {
            //we save the heartbeat status
            Component component = ComponentLogic.GetByAppId(appId);

            if (component != null)
            {
                component.HeartBeatStatus = (HeartBeatStatus)Enum.Parse(typeof(HeartBeatStatus), status);
                if ((HeartBeatStatus)Enum.Parse(typeof(HeartBeatStatus), status) == HeartBeatStatus.Down)
                {
                    component.Status = AppStatus.Down;
                }
                ComponentLogic.EditEntity(component);
            }
        }
        public static void SendHealthMessage(SelfHealthMessage healthMessage)
        {
            //  new HealthMessageLogic().SaveOrUpdateHealthStatus(healthMessage);
            Trace.TraceInformation("Health Messaged Received " + healthMessage.AppID + "Status is " + healthMessage.OverallStatus);
            AppStatus AggregatedStatus   = AppStatus.Up;
            string    failedMessagesJson = string.Empty;

            Trace.TraceInformation("About to get status based on health checks " + healthMessage.AppID);

            //Step 1: Get Aggregate Status of AppID depeding on status of related health messages
            var checkStatus = GetStatusBasedOnHealthChecks(healthMessage.AppID, healthMessage.IPAddress);

            Trace.TraceInformation("Check Status is " + checkStatus);

            Trace.TraceInformation("About to get Component " + healthMessage.AppID);

            //Step 2: Check if there is an App set up with this ID if there is, get agg status of APP depending on status of Child Apps.
            Component component = ComponentLogic.GetByAppId(healthMessage.AppID);

            if (component != null)
            {
                var appStatus = GetStatusBasedOnChildrenApps(component, AggregatedStatus);
                AggregatedStatus = ReturnAggregateStatus(checkStatus, appStatus);
                //Update the Status of the Application in the database
                component.Status     = AggregatedStatus;
                component.LastUpdate = DateTime.Now;
                ComponentLogic.EditEntity(component);
            }
            Trace.TraceInformation("About to send info to client  " + healthMessage.AppID);
            string status  = AggregatedStatus.ToString();
            var    connect = GlobalHost.ConnectionManager.GetHubContext <HealthMessageHub>();

            connect.Clients.All.test();

            var message = JsonConvert.SerializeObject(healthMessage);

            connect.Clients.All.sendHealthMessage(message);                             // to health message ui
            connect.Clients.All.sendHealthStatus(message, AggregatedStatus.ToString()); //to monitor ui
            Trace.TraceInformation("Health Info has been sent to client ");
        }
        public void LoadAllApplications()
        {
            List <Component> components = ComponentLogic.GetAllComponents();

            foreach (var component  in components)
            {
                List <AppStatus> replicaAppStatus = null;
                List <string>    subComponentIPs  = new HealthMessageLogic().GetIPAddressesForApp(component.AppID);
                var data = JsonConvert.SerializeObject(component);
                if (subComponentIPs == null || subComponentIPs.Count() == 0)
                {
                    Clients.All.loadAllApllications(data, null, null);
                    continue;
                }

                Trace.TraceInformation("About to Get Status based on Replica apps");
                replicaAppStatus = HealthMessageUtility.GetStatusBasedOnReplicas(component, subComponentIPs);
                Trace.TraceInformation("Replica App Status Done ");

                //string data = JsonConvert.SerializeObject(component);
                Clients.All.loadAllApllications(data, JsonConvert.SerializeObject(subComponentIPs), replicaAppStatus);
            }
        }
 public FormComponent(ComponentLogic logic)
 {
     InitializeComponent();
     this.logic = logic;
 }
Exemple #14
0
 public FormAdditionToWarehouse(WarehouseLogic logicW, ComponentLogic logicC)
 {
     InitializeComponent();
     _logicW = logicW;
     _logicС = logicC;
 }