Exemple #1
0
        private void EventTypeOptionOnPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            IsDirty = true;

            var option = sender as EventOptionModel;

            if (e.PropertyName == "IsChecked")
            {
                if (option.IsChecked)
                {
                    var eventTypeOption = new EventTypeOption()
                    {
                        ID            = Guid.NewGuid(),
                        EventTypeID   = SelectedEventType.EventType.ID,
                        EventOptionID = option.EventOption.ID
                    };

                    _adminDataUnit.EventTypeOptionsRepository.Add(eventTypeOption);
                }
                else
                {
                    var eventTypeOption = SelectedEventType.EventType.EventTypeOptions.FirstOrDefault(x => x.EventOptionID == option.EventOption.ID);
                    _adminDataUnit.EventTypeOptionsRepository.Delete(eventTypeOption);
                }

                SaveChangesCommand.RaiseCanExecuteChanged();
            }
        }
Exemple #2
0
 void IEventService.Write(EventTypeOption option, List <TypedItem> items)
 {
     if (HandleEvent != null)
     {
         HandleEvent(option, items);
     }
 }
Exemple #3
0
 protected override void Publish(EventTypeOption eventType, List <TypedItem> properties)
 {
     Debug.WriteLine(String.Format("An {0} occurred", eventType.ToString()));
     foreach (var property in properties)
     {
         Debug.WriteLine(String.Format("{0}:\t{1}", property.Key, property.Value.ToString()));
     }
 }
Exemple #4
0
        internal void LocalPublish(EventTypeOption option, IDictionary <string, object> properties)
        {
            List <TypedItem> list = Convert(properties);

            //new Action<EventTypeOption, List<TypedItem>>(Publish).BeginInvoke(option, list,null,null);
            // Retained for debugging purposes
            Publish(option, list);
        }
        protected override void Publish(EventTypeOption eventType, List <TypedItem> properties)
        {
            string url = eXtensibleConfig.BigDataUrl;

            if (!String.IsNullOrWhiteSpace(url))
            {
                Run(eventType, properties, url);
            }
            //RunAsync(eventType, properties,url).Wait();
        }
Exemple #6
0
        private void Run(EventTypeOption eventType, List <TypedItem> properties, string baseUrl)
        {
            try
            {
                string endpoint = ResolveEndpoint(eventType);

                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(baseUrl);
                    client.DefaultRequestHeaders.Add("Authorization", String.Format("{0} {1}", "basic", eXtensibleConfig.ServiceToken));
                    var response = client.PostAsJsonAsync(endpoint, properties);
                    if (response.Result.IsSuccessStatusCode)
                    {
                        int i = 0;
                    }
                    else
                    {
                        int j = 1;
                    }
                }
            }
            catch (Exception ex)
            {
                StringBuilder sb = new StringBuilder();
                if (ex.InnerException != null)
                {
                    if (ex.InnerException.InnerException != null)
                    {
                        if (ex.InnerException.InnerException.InnerException != null)
                        {
                            sb.Append(ex.InnerException.InnerException.InnerException.Message);
                        }
                        else
                        {
                            sb.Append(ex.InnerException.InnerException.Message);
                        }
                    }
                    else
                    {
                        sb.Append(ex.InnerException.Message);
                    }
                    sb.Append(ex.Message);
                }
                try
                {
                    EventLog.WriteEntry(XFConstants.Config.DefaultLogSource, sb.ToString(), EventLogEntryType.Error, 1);
                    Console.WriteLine(sb.ToString());
                }
                catch
                {
                }
            }
        }
Exemple #7
0
        internal void LocalPublish(EventTypeOption option, IDictionary <string, object> properties)
        {
            if (!properties.ContainsKey("xf-id"))
            {
                Guid g = eXtensiblePrincipal.GetCallerId();
                properties.Add("xf-id", g);
            }
            List <TypedItem> list = Convert(properties);

            //new Action<EventTypeOption, List<TypedItem>>(Publish).BeginInvoke(option, list,null,null);
            // Retained for debugging purposes
            Publish(option, list);
        }
Exemple #8
0
        protected override void Publish(EventTypeOption eventType, List <TypedItem> properties)
        {
            bool b = false;

            if (passthroughs.Contains(eventType))
            {
                b = true;
            }
            TraceEventTypeOption option = TraceEventTypeOption.Verbose;
            StringBuilder        sb     = new StringBuilder();

            foreach (var prop in properties)
            {
                if (prop.Value != null)
                {
                    if (prop.Key.Equals(XFConstants.EventWriter.ErrorSeverity) && Enum.TryParse <TraceEventTypeOption>(prop.Value.ToString(), out option))
                    {
                        b = true;
                    }
                    sb.AppendLine(String.Format("{0}\t:\t{1}", prop.Key, prop.Value.ToString()));
                }
            }

            if (!String.IsNullOrWhiteSpace(eXtensibleConfig.LogSource) && !EventLog.SourceExists(eXtensibleConfig.LogSource))
            {
                try
                {
                    EventLog.CreateEventSource(eXtensibleConfig.LogSource, LogName);
                }
                catch (Exception)
                {
                    b = false;
                }
            }
            if (b)
            {
                if (option == TraceEventTypeOption.Critical | option == TraceEventTypeOption.Error)
                {
                    Publish(EventLogEntryType.Error, sb.ToString());
                }
                else if (option == TraceEventTypeOption.Warning)
                {
                    Publish(EventLogEntryType.Warning, sb.ToString());
                }
                else
                {
                    Publish(EventLogEntryType.Information, sb.ToString());
                }
            }
        }
Exemple #9
0
        private void PublishLocal(EventTypeOption eventType, List <TypedItem> properties)
        {
            try
            {
                string          pipeName = "pipeXF";
                EndpointAddress endpoint = new EndpointAddress(String.Format("{0}/{1}", XFConstants.PipeUrl, pipeName));
                IEventService   proxy    = ChannelFactory <IEventService> .CreateChannel(new NetNamedPipeBinding(), endpoint);

                proxy.Write(eventType, properties);
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
        }
        protected override void Publish(EventTypeOption eventType, List <TypedItem> properties)
        {
            switch (eventType)
            {
            case EventTypeOption.Error:
                eXError error = new eXError(properties);
                SqlServerEventWriter.Post(error);
                break;

            case EventTypeOption.Status:
            case EventTypeOption.Task:
            case EventTypeOption.Alert:
            case EventTypeOption.Kpi:
            case EventTypeOption.None:
            case EventTypeOption.Event:
            default:
                SqlServerEventWriter.Post(properties);
                break;
            }
        }
        private static string ResolveEndpoint(EventTypeOption option)
        {
            string endpoint = String.Format(ApiUrlFormat, eXtensibleConfig.ApiRoot, eXtensibleConfig.ApiEvents);

            switch (option)
            {
            case EventTypeOption.Error:
                endpoint = String.Format(ApiUrlFormat, eXtensibleConfig.ApiRoot, eXtensibleConfig.ApiErrors);        //"/log/errors"
                break;

            case EventTypeOption.Event:
                endpoint = String.Format(ApiUrlFormat, eXtensibleConfig.ApiRoot, eXtensibleConfig.ApiEvents);     //"/log/events";
                break;

            case EventTypeOption.Status:
                endpoint = String.Format(ApiUrlFormat, eXtensibleConfig.ApiRoot, eXtensibleConfig.ApiStatii);     // "/log/statii";
                break;

            case EventTypeOption.Task:
                endpoint = String.Format(ApiUrlFormat, eXtensibleConfig.ApiRoot, eXtensibleConfig.ApiTasks);     // "/log/tasks";
                break;

            case EventTypeOption.Alert:
                endpoint = String.Format(ApiUrlFormat, eXtensibleConfig.ApiRoot, eXtensibleConfig.ApiAlerts);     // "/log/alerts";
                break;

            case EventTypeOption.Kpi:
                endpoint = String.Format(ApiUrlFormat, eXtensibleConfig.ApiRoot, eXtensibleConfig.ApiKpi);     // "/log/kpi";
                break;

            case EventTypeOption.Custom:
                endpoint = String.Format(ApiUrlFormat, eXtensibleConfig.ApiRoot, eXtensibleConfig.ApiCustom);     // "/log/custom";
                break;

            case EventTypeOption.None:
            default:
                endpoint = String.Format(ApiUrlFormat, eXtensibleConfig.ApiRoot, eXtensibleConfig.ApiEvents);     // "/log/events";
                break;
            }
            return(endpoint);
        }
Exemple #12
0
        internal void LocalPublish(EventTypeOption option, IDictionary <string, object> properties)
        {
            var principal = Thread.CurrentPrincipal as eXtensibleClaimsPrincipal;

            if (principal != null)
            {
                principal.HasError = true;
            }

            if (!properties.ContainsKey("xf-id"))
            {
                Guid g = eXtensiblePrincipal.GetCallerId();
                properties.Add("xf-id", g);
            }

            List <TypedItem> list = Convert(properties);

            //new Action<EventTypeOption, List<TypedItem>>(Publish).BeginInvoke(option, list,null,null);
            // Retained for debugging purposes
            Publish(option, list);
        }
Exemple #13
0
 public static void Write(EventTypeOption option, List <TypedItem> properties)
 {
     Writer.Write(option, properties);
 }
Exemple #14
0
 protected override void Publish(EventTypeOption eventType, List <TypedItem> properties)
 {
     PublishLocal(eventType, properties);
 }
Exemple #15
0
 protected abstract void Publish(EventTypeOption eventType, List <TypedItem> properties);
Exemple #16
0
 void IEventWriter.Write(EventTypeOption option, List <TypedItem> properties)
 {
     Publish(option, properties);
 }