Esempio n. 1
0
        public IEnumerable <NaesbEvent> Get()
        {
            //dynamic workRequest = _workRequestRequestor.Get(new Uri(BaseManagedWorkApiUri + ResolveCurlyBrackets(Properties.Settings.Default.ManagedWorkOrderApiResourse_WorkRequest, workPacket.WorkRequestId.ToString())));

            //var stuff = _container.Resolve<IResourse<NaesbEvent>>().Get(
            //    new Uri(ResolveCurlyBrackets(Properties.Settings.Default.PegasysHost + Properties.Settings.Default.PegasysApiResourse_RequestForConfirmation, "NGPL-PGL-20190625-EVE"))
            //);

            NaesbEvent naesbEvent = _container.Resolve <IResourse <NaesbEvent> >().Get(
                new Uri(ResolveCurlyBrackets("http://localhost:4955" + Properties.Settings.Default.PegasysApiResourse_NaesbEvent, "1000000005"))
                );
            NaesbEvent naesbEvent2 = _container.Resolve <IResourse <NaesbEvent> >().Get(
                new Uri(ResolveCurlyBrackets("http://localhost:4955" + Properties.Settings.Default.PegasysApiResourse_NaesbEvent, "1000000022"))
                );
            NaesbEvent naesbEvent3 = _container.Resolve <IResourse <NaesbEvent> >().Get(
                new Uri(ResolveCurlyBrackets("http://localhost:4955" + Properties.Settings.Default.PegasysApiResourse_NaesbEvent, "1000000031"))
                );
            NaesbEvent naesbEvent4 = _container.Resolve <IResourse <NaesbEvent> >().Get(
                new Uri(ResolveCurlyBrackets("http://localhost:4955" + Properties.Settings.Default.PegasysApiResourse_NaesbEvent, "1000000034"))
                );

            List <NaesbEvent> naesbEvents = new List <NaesbEvent>();

            naesbEvents.Add(naesbEvent);
            naesbEvents.Add(naesbEvent2);
            naesbEvents.Add(naesbEvent3);
            naesbEvents.Add(naesbEvent4);

            return(naesbEvents);
        }
Esempio n. 2
0
        public void Change(int id, NaesbEvent obj)
        {
            obj.Id = id;
            var entity = new Nomination.Persistence.Common.ModelFactory().Map(obj);

            base.Change(entity);
        }
Esempio n. 3
0
        public IHttpActionResult Put([FromBody] NaesbEvent value, [FromUri] string id)
        {
            var naesbEvent = _container.Resolve <IResourse <NaesbEvent> >().Put(
                new Uri(ResolveCurlyBrackets("http://localhost:4955" + Properties.Settings.Default.PegasysApiResourse_NaesbEvent, id)), value
                );


            return(Ok(value));
        }
        public IHttpActionResult Get(int id)
        {
            NaesbEvent naesbEvent = _container.Resolve <INaesbEventGet>().Invoke(id);

            if (naesbEvent != null)
            {
                return(Ok(naesbEvent));
            }

            return(NotFound());
        }
Esempio n. 5
0
        private static void ProcessRequestForConfirmations(DateTime processStart)
        {
            //return all valid rfcs to be processed
            var rfcs = Container.Resolve <INaesbEventGetRfcsToProcess>().Invoke(processStart);

            if (rfcs != null && rfcs.Count > 0)
            {
                Console.WriteLine("==Processing:[" + Properties.Settings.Default.EventType + "'s] [File Count: " + rfcs.Count + "]");

                int i = 1;
                foreach (var rfc in rfcs)
                {
                    try
                    {
                        NaesbEvent naesbEvent = Container.Resolve <INaesbEventGet>().Invoke("RFC", rfc.PartyIndentificaton.PipelineEntity, rfc.PartyIndentificaton.UtilityEntity, rfc.Cycle);

                        //this will always be current because if an rfc for a cycle doesn't go out...then it never does for that cycle.
                        rfc.GasDay = processStart.AddDays(naesbEvent.OffSet != null ? Convert.ToDouble(naesbEvent.OffSet) : 0);

                        Console.WriteLine("==Processing: [" + Properties.Settings.Default.EventType + "] [" + i + " of " + rfcs.Count + "] [Cycle: " + rfc.Cycle + "] [Utility: " + rfc.PartyIndentificaton.UtilityEntity + "] [Pipeline: " + rfc.PartyIndentificaton.PipelineEntity + "]");

                        ProcessRequestForConfirmation(rfc, processStart);

                        //update naesb event process
                        DateTime now = DateTime.Now;
                        Container.Resolve <INaesbEventUpdate>().Invoke(naesbEvent.Id, now);
                        Console.WriteLine("==Processing:  4. Updated the naesb event process Processed Time: " + now);

                        i++;

                        Console.WriteLine("==Processing: [" + Properties.Settings.Default.EventType + "] <<SUCCESSFUL>>");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("==Processing Error:");
                        Console.WriteLine(ex);
                        i++;

                        CreateIncident(ex, null);

                        Console.WriteLine("==Processing: [" + Properties.Settings.Default.EventType + "] <<UNSUCCESSFUL>>");
                    }
                }
            }
            else
            {
                Console.WriteLine("==Processing:[" + Properties.Settings.Default.EventType + "'s] None to Process");
            }

            Console.WriteLine("============================================================================");
        }
Esempio n. 6
0
 public void Invoke(int id, NaesbEvent obj)
 {
     _repository.Update(id,
                        new KeyValuePair <string, string>("Type", obj.FileType),
                        new KeyValuePair <string, string>("Cycle", obj.Cycle),
                        new KeyValuePair <string, string>("Pipeline", obj.Pipeline),
                        new KeyValuePair <string, string>("Utility", obj.Utility),
                        new KeyValuePair <string, DateTime?>("ProcessedTime", obj.ProcessedTime),
                        new KeyValuePair <string, TimeSpan?>("CycleStart", obj.CycleStart),
                        new KeyValuePair <string, TimeSpan?>("CycleEnd", obj.CycleEnd),
                        new KeyValuePair <string, short?>("OffSet", obj.OffSet),
                        new KeyValuePair <string, bool?>("On", obj.On)
                        );
 }
Esempio n. 7
0
        public IHttpActionResult Post([FromBody] NaesbEvent value)
        {
            return(Created("", value));

            int id = 3;

            if (id > 0)
            {
                string location = Request.RequestUri + "/" + id;
                return(Created(location, id));
            }

            return(BadRequest());
        }
Esempio n. 8
0
 public int Invoke(NaesbEvent obj)
 {
     throw new NotImplementedException();
 }
        public void Put(int id, [FromBody] NaesbEvent value)
        {
            _container.Resolve <INaesbEventUpdate>().Invoke(id, value);

            var x = Request;
        }
Esempio n. 10
0
        private static List <NaesbEventEmail> RetrieveNaesbEventMonitors(DateTime runTime)
        {
            int i = 0;

            //get list of possible past due naesb event monitors
            //where -->  active
            //           AND
            //          (runtime.TimeOfDay > than naesb_event_monitor.EventMonitorTime && naesb_event_monitor.LastCheckedTime = NULL
            //           OR
            //           runtime.TimeOfDay > than naesb_event_monitor.EventMonitorTime && naesb_event_monitor.LastCheckedTime.Date and runTime.Date difference is more than 1 day ... at least next day)
            List <NaesbEventMonitor> list = Container.Resolve <INaesbEventMonitorGetEventMonitors>().Invoke(runTime);

            if (list != null && list.Count > 0)
            {
                Console.WriteLine("==Processing:[Naesb Event Monitor] Event Notification(s) -> DETERMINING... ");

                //List<NaesbEventMonitor> notifications = new List<NaesbEventMonitor>();
                List <NaesbEventEmail> notifications = new List <NaesbEventEmail>();

                //loop through each naesb event monitor to determine possible past due naesb event
                foreach (var item in list)
                {
                    DateTime naesbEventMonitorCurrentDateTime = new DateTime(runTime.Year, runTime.Month, runTime.Day, item.EventMonitorTime.Hours, item.EventMonitorTime.Minutes, item.EventMonitorTime.Seconds);
                    if (runTime > naesbEventMonitorCurrentDateTime && (item.LastCheckedTime == null || runTime > item.LastCheckedTime))
                    {
                        //get current naesb event
                        NaesbEvent naesbEvent = Container.Resolve <INaesbEventGet>().Invoke(item.EventType, item.Pipeline, item.Utility, item.Cycle);

                        if (naesbEvent.FileType == "RFC")
                        {
                            //if true the naesb event is past due
                            if ((naesbEvent.ProcessedTime == null || ((runTime.Date - naesbEvent.ProcessedTime.Value.Date).TotalDays > 0 && runTime.TimeOfDay > naesbEvent.CycleEnd)) && naesbEvent.On == true)
                            {
                                Console.WriteLine("==Processing: Event Notification -> PAST DUE MONITOR EVENT");
                                Console.WriteLine("==Processing: Event Notification -> [EventTypeDesc: " + item.EventTypeDescription + "] [EventType: " + item.EventType + "] [Cycle: " + item.Cycle + "] [Utility: " + item.Utility + "] [Pipeline: " + item.Pipeline + "]");

                                notifications.Add(new NaesbEventEmail
                                {
                                    Id                   = item.Id,
                                    Cycle                = item.Cycle,
                                    CycleDescription     = item.CycleDescription,
                                    SortSeq              = item.SortSeq,
                                    Pipeline             = item.Pipeline,
                                    Utility              = item.Utility,
                                    EventType            = item.EventType,
                                    EventTypeDescription = item.EventTypeDescription,
                                    Processed            = naesbEvent.ProcessedTime,
                                    EventMonitorTime     = item.EventMonitorTime,
                                    LastCheckedTime      = item.LastCheckedTime,
                                    ActiveStart          = item.ActiveStart,
                                    ActiveEnd            = item.ActiveEnd,
                                    LastUpdateTime       = item.LastUpdateTime,
                                    LastUpdateUserId     = item.LastUpdateUserId,
                                    OffSet               = naesbEvent.OffSet
                                });
                                Console.WriteLine("==Processing: Event Notification -> ADDED TO NOTIFICATIONS");

                                i++;
                            }
                        }
                        if (naesbEvent.FileType == "CR" || naesbEvent.FileType == "OSQ")
                        {
                            //if true the naesb event is past due
                            if ((naesbEvent.ProcessedTime == null || (runTime.Date - naesbEvent.ProcessedTime.Value.Date).TotalDays > 0) && naesbEvent.On == true)
                            {
                                Console.WriteLine("==Processing: Event Notification -> PAST DUE MONITOR EVENT");
                                Console.WriteLine("==Processing: Event Notification -> [EventTypeDesc: " + item.EventTypeDescription + "] [EventType: " + item.EventType + "] [Cycle: " + item.Cycle + "] [Utility: " + item.Utility + "] [Pipeline: " + item.Pipeline + "]");

                                notifications.Add(new NaesbEventEmail
                                {
                                    Id                   = item.Id,
                                    Cycle                = item.Cycle,
                                    CycleDescription     = item.CycleDescription,
                                    SortSeq              = item.SortSeq,
                                    Pipeline             = item.Pipeline,
                                    Utility              = item.Utility,
                                    EventType            = item.EventType,
                                    EventTypeDescription = item.EventTypeDescription,
                                    Processed            = naesbEvent.ProcessedTime,
                                    EventMonitorTime     = item.EventMonitorTime,
                                    LastCheckedTime      = item.LastCheckedTime,
                                    ActiveStart          = item.ActiveStart,
                                    ActiveEnd            = item.ActiveEnd,
                                    LastUpdateTime       = item.LastUpdateTime,
                                    LastUpdateUserId     = item.LastUpdateUserId,
                                    OffSet               = naesbEvent.OffSet
                                });
                                Console.WriteLine("==Processing: Event Notification -> ADDED TO NOTIFICATIONS");

                                i++;
                            }
                        }
                    }

                    //update NaesbEventMonitors LastCheckedTime
                    Container.Resolve <INaesbEventMonitorUpdate>().Invoke(item.Id, runTime);
                }

                if (i > 0)
                {
                    Console.WriteLine("==Processing:[Naesb Event Monitor] " + i + " Event Notification(s) -> CREATED");
                }

                return(notifications);
            }

            return(null);
        }
 public void Invoke(int id, NaesbEvent obj)
 {
     _repository.Change(id, obj);
 }