Esempio n. 1
0
        private InstanceEntity GetInstanceLogById(long instanceId)
        {
            using (SqlConnection sqlCon = new SqlConnection(AppSettings.GetConnectionString("Edge.Core.Services", "SystemDatabase")))
            {
                InstanceEntity entity = new InstanceEntity();

                sqlCon.Open();
                SqlCommand sqlCommand = new SqlCommand(
                    "SELECT [ID],[Source],[Message],[ExceptionDetails],[MessageType] FROM [dbo].[Log] where [ServiceInstanceID] = @instanceId");

                sqlCommand.Parameters.Add(new SqlParameter()
                {
                    ParameterName = "@instanceId",
                    Value         = instanceId,
                    SqlDbType     = System.Data.SqlDbType.BigInt
                });

                sqlCommand.Connection = sqlCon;

                using (var _reader = sqlCommand.ExecuteReader())
                {
                    if (!_reader.IsClosed)
                    {
                        while (_reader.Read())
                        {
                            entity.Id               = Convert.ToInt64(_reader[0]);
                            entity.Source           = _reader[1].ToString();
                            entity.Message          = _reader[2].ToString();
                            entity.ExceptionDetails = _reader[3].ToString();
                            entity.MessageType      = _reader[4].ToString();
                        }
                    }
                }

                return(entity);
            }
        }
Esempio n. 2
0
        public void UpdateForm(long parentInstanceId, string instanceName, string accountId)
        {
            string deliveryId = string.Empty;

            this.instaceIDValue.Text  = parentInstanceId.ToString();
            this.SourceNameValue.Text = instanceName;
            this.AccountIdValue.Text  = accountId;
            this._accountId           = Convert.ToInt32(accountId);
            FromPicker.Value          = FromPicker.Value.AddDays(-1);
            ToPicker.Value            = ToPicker.Value.AddDays(-1);

            #region Getting Instaces
            _instances = GetWorkFlowServicesInstaceIdList(parentInstanceId);
            if (_instances.Count > 0)
            {
                InstancesListBox.Items.Clear();
                foreach (var instance in _instances)
                {
                    InstancesListBox.Items.Add(string.Format("{0} ({1})", instance.Value, instance.Key));
                }

                if (TryGetDeliveryId(_instances, out deliveryId))
                {
                    deliveryID_lbl.Text = deliveryId;
                }
                else
                {
                    deliveryID_lbl.Text = "No Delivery";
                }
            }
            #endregion

            #region Setting instances List in overview
            InstanceEntity parent = GetInstanceLogById(parentInstanceId);
            if (!string.IsNullOrEmpty(parent.Message))
            {
                this.instacesSummaryDataGrid.Rows.Add(
                    parent.Id, parent.Source, string.Format("{0} {1}", parent.Message, parent.ExceptionDetails), parent.MessageType);
            }
            #endregion

            #region Setting instances Summary Grid
            foreach (var id in _instances)
            {
                InstanceEntity entity = GetInstanceLogById(id.Key);
                this.instacesSummaryDataGrid.Rows.Add(
                    entity.Id, entity.Source, string.Format("{0} {1}", entity.Message, entity.ExceptionDetails), entity.MessageType);
            }
            #endregion

            #region Service Configuration
            //Loading Service Configuration
            XmlDocument xmlDoc = new XmlDocument();

            try
            {
                string xmlContent = GetConfigurationFromDB(parentInstanceId);
                xmlDoc.LoadXml(xmlContent);
                foreach (XmlAttribute attribute in xmlDoc.DocumentElement.Attributes)
                {
                    _attributes.Add(attribute.Name, attribute.Value);

                    if (!attribute.Name.Equals(PipelineService.ConfigurationOptionNames.TimePeriod))
                    {
                        optionsListView.Items.Add(new ListViewItem(new string[] { attribute.Name, attribute.Value }));
                    }
                    else
                    {
                        AttributesToRunList.Items.Add(new ListViewItem(new string[] { attribute.Name, attribute.Value }));
                    }
                }
            }
            catch
            {
                //TO DO : throw exception
            }

            //Getting TimePeriod
            if (TryGetDeliveryTargetPeriod(deliveryId, out _dateTimeRange))
            {
                _options.Add(PipelineService.ConfigurationOptionNames.TimePeriod, _dateTimeRange.ToAbsolute().ToString());
                FromPicker.Value = _dateTimeRange.Start.ToDateTime();
                ToPicker.Value   = _dateTimeRange.End.ToDateTime();
            }
            else
            {
                this.deliveryID_lbl.Text = "Unavailable";
                this.run_btn.Enabled     = false;
                MessageBox.Show("\"Run Service Again\" button has been disabled due the following reason : Cannot find target period in delivery data base");
            }

            #endregion
        }