Esempio n. 1
0
        public void cGprsTest()
        {
            var newtraceLog = new TraceLog("SingtelTest", "Zero1", null);

            using (var eventClient = new EventClient(Helpers.GetSelcommWsEndpointName()))
            {
                ServiceClient serviceclient = new ServiceClient(Helpers.GetSelcommWsEndpointName());
                ContactClient contactClient = new ContactClient(Helpers.GetSelcommWsEndpointName());

                //Create the session.
                var authService = new SelcommWSsvc.SelcommWSAll.AuthenticationClient(Helpers.GetSelcommWsEndpointName());
                var sessionKey  = authService.AuthenticateSimpleCreateSessionAndAuthenticateContact("2041591443", "webuser", "resubew", "40000287", "1234");

                //Adding a new service to an existing account
                var pack = new SelcommWSsvc.SelcommWSAll.PackagesClient(Helpers.GetSelcommWsEndpointName())
                {
                };
                var packageList = pack.PackageDisplayListCurrent(sessionKey, false);
                var newId       = serviceclient.ServiceAddNewSimple(sessionKey, "40000287", DateTime.Now, packageList[0].Code, 1, 1, "MRBR", "0298" + (new System.Random()).Next(0, 1000000).ToString("000000"), "1234");

                //creating new event associated with service Id
                Event NewEvent = new Event
                {
                    EventType = new EventType
                    {
                        EventTypeMember = "CM",
                        EventCode       = "IC",
                    },
                    Schedule = new EventSchedule
                    {
                        ToLogin      = "******",
                        ToDepartment = new Department {
                            Code = "SYS"
                        },
                        EventScheduleType = new EventScheduleType {
                            Code = "ACT"
                        },
                        EventScheduleStatus = new EventScheduleStatus {
                            Code = "O"
                        }
                    },
                    Note = string.Format("Event opened for sp_cn_ref {0}", newId)
                };


                var testevent = eventClient.EventAddForService(sessionKey, NewEvent, new Service {
                    ServiceId = newId
                });
                var eventDisplay = eventClient.EventDisplay(sessionKey, testevent, true);
                newtraceLog.CreateLog($"Global ServiceId: " + newId);
                newtraceLog.CreateLog($"Event Display: " + eventDisplay);

                SelcommWebServices.SelcommOSS.Singtel.MD.Processes.ActionHandler.cGprsActionHandler a = new SelcommWebServices.SelcommOSS.Singtel.MD.Processes.ActionHandler.cGprsActionHandler("2041591443");
                var response = a.ProcessEvent(eventDisplay, newtraceLog);
                newtraceLog.CreateLog($"Command string: " + response);
                Assert.AreEqual(response.Length, 90, "length of Command string for cGprs are equal");

                //    Assert.AreEqual(response.Length,163, "length of Command string for cGprs are equal");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// <para>Checks the event dispatcher list and if available, Processes the Event Dispatchers.</para>
        /// </summary>
        public void ProcessAllEventDispatchers(TraceLog t)
        {
            var eventDispatcherList = this.GetTargetEventDispatchers();

            t.CreateLog(null);
            t.CreateLog("---------------------------------------------------------------------------------------------------------");
            t.CreateLog("List of Event Dispatcher:" + eventDispatcherList.Count());
            this.ProcessEventDispatchers(eventDispatcherList, t);
        }
Esempio n. 3
0
        /// <summary>
        /// Sends email to Web Support if an event failure occurs
        /// </summary>
        protected void SendEmailToWebSupport(string Note, TraceLog t)
        {
            try
            {
                using (var ConfigurationClientWS = new SelcommWSsvc.SelcommWSAll.ConfigurationClient(Singtel.Helpers.Helpers.GetSelcommWsEndpointName()))
                {
                    string body = $"provider code : {this.PrivateKey} <br />" +
                                  $"server environment : {Singtel.Helpers.Utility.ServerEnvironment}<br />" +
                                  $"{Note}";
                    string subject = "this is just for test ";//$"selcommoss - attention required for trustpower event processing. server : {utility.serverenvironment}";

                    string emailTo = ConfigurationClientWS.GetConfigValue(this.SessionKey, "TPOWER_WEBSUPPORT_EMAIL", null, null, null, null, null, null);
                    if (string.IsNullOrWhiteSpace(emailTo))
                    {
                        emailTo = "*****@*****.**";
                        t.CreateLog($"To email is not configured in the system. The email address [{emailTo}] is assigned as To email on the fly to send email.");
                    }
                    EmailHelper.SendEmail("*****@*****.**", emailTo, subject, body, true);
                    t.CreateLog($"Email has been sent to {emailTo} to notify the action.");
                }
            }
            catch (Exception ex)
            {
                t.CreateLog("Email to websupport is unsuccessful");
                t.CreateLog(Singtel.Helpers.Helpers.getExceptionString(ex).Replace("<br/>", Environment.NewLine).Replace("<br />", Environment.NewLine));
                t.CreateLog("==================The email was supposed to be sent to notify the following issue.===============================");
                t.CreateLog(Note.Replace("<br/>", Environment.NewLine).Replace("<br />", Environment.NewLine));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// <para>Checks the event and if available, Processes the service actions.</para>
        /// </summary>
        protected virtual void ProcessEventDispatchers(IEnumerable <EventDispatcher> eventDispatcherList, TraceLog t)
        {
            using (var eventClient = new SelcommWSsvc.SelcommWSAll.EventClient(Singtel.Helpers.Helpers.GetSelcommWsEndpointName()))
            {
                foreach (var eventDispatcher in eventDispatcherList)
                {
                    var events = eventClient.EventDisplayList(this.ClientSessionWS.SessionKey, new EventType {
                        EventCode = eventDispatcher.EventCode, EventTypeMember = eventDispatcher.EventType
                    }, eventDispatcher.ScheduleStatus);

                    t.CreateLog($"Number of events to be processed- {events.Count}");
                    int totalEvents = events?.Count ?? 0;
                    if (events?.Any() == true)
                    {
                        foreach (var evnt in events)
                        {
                            try
                            {
                                this.ProcessEvent(evnt, t);
                                //TODO - below should be in generic helper
                                // WcfService2.Helpers.Helpers.updateEventStatus(this.SessionKey, evnt.EventId, "C", t, null);
                            }
                            catch (Exception ex)
                            {
                                //record the error and continue with next event
                                t.CreateLog("----------------------------------------!! ERROR OCCURRED !!----------------------------------------");
                                string note = $"ERROR OCCURED. The provisioning action {TargetActionCode} stopped due to the reason: {ex.Message}";
                                t.CreateLog(note);
                                // SendEmailToWebSupport(note, t);
                                //TODO - below should be in generic helper
                                Singtel.Helpers.Helpers.updateEventStatus(this.SessionKey, evnt.EventId, "F", t, null);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// process an event for sendSms service.
        /// </summary>
        /// <param name="targetEvent"></param>
        /// <param name="t"></param>
        public override void ProcessEvent(EventDisplay targetEvent, TraceLog t)
        {
            t.CreateLog(null);
            t.CreateLog($"********************STARTED { TargetActionCode}********************************");
            t.CreateLog("Start Of The Process For Event " + targetEvent.EventId + " And Service Number " + targetEvent.ServiceNumber + " - !!!! ServiceRequest() !!!!");

            using (var EventClientWS = new SelcommWSsvc.SelcommWSAll.EventClient(Singtel.Helpers.Helpers.GetSelcommWsEndpointName()))
                using (var ContactClientWS = new SelcommWSsvc.SelcommWSAll.ContactClient(Singtel.Helpers.Helpers.GetSelcommWsEndpointName()))
                    using (var ServiceClientWS = new SelcommWSsvc.SelcommWSAll.ServiceClient(Singtel.Helpers.Helpers.GetSelcommWsEndpointName()))
                    {
                        // Updating EventSchedule Status to R - START
                        t.CreateLog("Updating Event Status to R- START - EventClientWS.EventScheduleUpdate()");

                        Singtel.Helpers.Helpers.updateEventStatus(SessionKey, targetEvent.EventId, "R", t, null);
                        t.CreateLog("Updating Completed");
                        // Updating EventSchedule Status - END

                        // Loading ServiceDisplay details of a current processing event
                        t.CreateLog("Loading ServiceDisplay Details - ServiceClientWS.ServiceDisplay() For service id: " + targetEvent.ServiceId);
                        var aService = ServiceClientWS.ServiceDisplay(this.ClientSessionWS.SessionKey, new SelcommWSsvc.SelcommWSAll.ServiceDisplay {
                            Id = targetEvent.ServiceId
                        });
                        if (aService != null)
                        {
                            t.CreateLog("ServiceDisplay Details loaded Successfully");
                        }
                        else
                        {
                            t.CreateLog("ServiceDisplay Details not loaded");
                        }

                        var ContactObj       = ContactClientWS.Contact(ClientSessionWS.SessionKey, targetEvent.ContactCode, true, false, false, false);
                        var businessUnitCode = ContactObj.CurrentBusinessUnit.Code;

                        var eventNote = EventClientWS.EventNoteList(ClientSessionWS.SessionKey, targetEvent.EventId, false).FirstOrDefault();

                        try
                        {
                            SendSmsService newSMS = new SendSmsService();
                            sendSms        newMSG = new sendSms();

                            List <string> address  = new List <string>();
                            string        aAddress = aService.ServiceNumber; //"tel:6596165414";
                            var           FirstTwoDigitOfServiceNumber = Helpers.SmscHelper.GetFirstTwoDigitOfServiceNumber(aAddress);
                            if (FirstTwoDigitOfServiceNumber != 65)
                            {
                                aAddress = "tel:65".Trim() + aAddress;
                            }
                            address.Add(aAddress);
                            newMSG.addresses = address.ToArray();
                            newMSG.message   = eventNote?.Text.ToString().Trim();
                            if (newMSG.message == null)
                            {
                                throw new Exception("Message should not be null. Event notes is null.");
                            }
                            newMSG.senderName = GetSystemConfigValue("SG_SMSC_FROM", "SG_SMSC_FROM_" + ContBusUnitCode);
                            t.CreateLog($"Request sent from IOTB:{Utility.SerializeToJSON(newMSG)}");
                            sendSmsResponse newResponse = newSMS.sendSms(newMSG);
                            t.CreateLog($"Response received{Utility.SerializeToJSON(newResponse)}");
                        }

                        catch (Exception ex)
                        {
                            var sx = ex as System.Web.Services.Protocols.SoapException;
                            if (sx != null)
                            {
                                t.CreateLog($"got SoapException. InnerText=\"{sx.Detail.InnerText}\"");
                                t.CreateLog($"OuterXML=\"{sx.Detail.OuterXml}\"");
                            }
                            t.CreateLog("ex.ToString=" + ex.ToString());

                            //record the error and continue with next event
                            t.CreateLog("----------------------------------------!! ERROR OCCURRED !!----------------------------------------");
                            string note = $"ERROR OCCURED. The provisioning action {TargetActionCode} stopped due to the reason: {ex.Message}";
                            t.CreateLog(note);
                            SendEmailToWebSupport(note, t);
                            Singtel.Helpers.Helpers.updateEventStatus(SessionKey, targetEvent.EventId, "F", t, note);
                        }
                    }
        }