예제 #1
0
        /// <summary>
        /// the method incharge to close the hanlers and the all service.
        /// </summary>
        public void onCloseService()
        {
            CloseService?.Invoke(this, null);
            m_logging.Log("On stop", Logging.Modal.MessageTypeEnum.INFO);
            bool   res;
            string s = m_controller.ExecuteCommand((int)CommandEnum.LastLogCommand, null, out res);

            this.m_tcpServer.NotifyAll(s);
        }
예제 #2
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="controller">image controller</param>
 /// <param name="loggingService">logger</param>
 ///
 public void OnCloseSevice()
 {
     try
     {
         m_logging.Log("server->on flose service", Logging.Modal.MessageTypeEnum.INFO);
         CloseService?.Invoke(this, null);
     }
     catch (Exception ex)
     {
         this.m_logging.Log("server->on close service Exception: " + ex.ToString(), Logging.Modal.MessageTypeEnum.FAIL);
     }
 }
예제 #3
0
        protected override void OnStop()
        {
            // Update the service state to Stop Pending.
            ServiceStatus serviceStatus = new ServiceStatus();

            serviceStatus.dwCurrentState = ServiceState.SERVICE_STOP_PENDING;
            serviceStatus.dwWaitHint     = 100000;
            SetServiceStatus(this.ServiceHandle, ref serviceStatus);

            eventLog1.WriteEntry("In onStop");

            // Update the service state to Stop.
            serviceStatus.dwCurrentState = ServiceState.SERVICE_STOPPED;
            SetServiceStatus(this.ServiceHandle, ref serviceStatus);

            CloseService?.Invoke(this, EventArgs.Empty);
        }
예제 #4
0
        public CloseShipmentResponse CloseShipmentService(ShipServiceInfo clsService)
        {
            FedExWebServiceClient.CloseWebReference.CloseService service = new CloseService();
            F21.Service.CloseShipmentResponse closeResponse = new CloseShipmentResponse();

            string iResultCode    = string.Empty;
            string iResultMessage = string.Empty;
            string iErrorMessage  = string.Empty;
            string retValue       = string.Empty;
            string serviceURL     = string.Empty;
            string transactionId  = string.Empty;

            string noticeCode     = string.Empty;
            string noticeMessage  = string.Empty;
            string noticeSeverity = string.Empty;
            string noticeSource   = string.Empty;

            try
            {
                if (F21.Framework.ConfigManager.GetAppSetting2("mode").Equals("production", StringComparison.OrdinalIgnoreCase))
                {
                    serviceURL = F21.Framework.ConfigManager.GetAppSetting2("Live_FedExCloseUrl");
                }
                else
                {
                    serviceURL = F21.Framework.ConfigManager.GetAppSetting2("Test_FedExCloseUrl");
                }

                // Webservice URL
                service.Url = serviceURL;

                NameValueCollection nvcNotification = null;

                #region Ground Close
                GroundCloseWithDocumentsRequest request = CreateGroundCloseWithDocumentsRequest(clsService, out transactionId);
                closeResponse.TransactionId = Basic.IsNull(transactionId);
                //GroundCloseRequest request = CreateGroundCloseRequest();

                // [8/8/2016 jh.kim] Serialize To Soap
                System.Diagnostics.Debug.WriteLine(Encoding.Default.GetString(Serialize.serializeToSoap(request)));

                // Call the Close web service passing in a GroundCloseWithDocumentsRequest and returning a GroundCloseDocumentsReply
                GroundCloseDocumentsReply reply = service.groundCloseWithDocuments(request);

                // Call ShowNotifications(reply)
                nvcNotification = ShowNotifications(reply, out iResultMessage);

                // SUCCESS, NOTE, WARNING
                if (reply.HighestSeverity == NotificationSeverityType.SUCCESS || reply.HighestSeverity == NotificationSeverityType.NOTE || reply.HighestSeverity == NotificationSeverityType.WARNING)
                {
                    closeResponse.HighestSeverity = reply.HighestSeverity.ToString();

                    // Call ShowGroundCloseDocumentsReply(reply)
                    closeResponse = ShowGroundCloseDocumentsReply(reply, closeResponse);

                    if (nvcNotification["Code"].ToString() == "0000" && nvcNotification["Message"].ToString() == "Success")
                    {
                        closeResponse.isSuccess    = true;
                        closeResponse.ErrorMessage = Basic.IsNull(closeResponse.ErrorMessage, "");
                    }
                    else
                    {
                        closeResponse.isSuccess = false;

                        if (closeResponse.ErrorMessage == "")
                        {
                            closeResponse.ErrorMessage = "[FedEx Close Service : " + closeResponse.HighestSeverity + "]\r\nNotification Code: " + nvcNotification["Code"].ToString() + ",\r\nNotification Message: " + nvcNotification["Message"].ToString();
                        }
                        else
                        {
                            closeResponse.ErrorMessage = "[FedEx Close Service : " + closeResponse.HighestSeverity + "]\r\nNotification Code: " + nvcNotification["Code"].ToString() + ",\r\nNotification Message: " + nvcNotification["Message"].ToString() + "\r\n" + closeResponse.ErrorMessage;
                        }
                    }
                }
                else // ERROR, FAILURE
                {
                    closeResponse.HighestSeverity = Basic.IsNull(reply.HighestSeverity.ToString(), "Empty");

                    closeResponse.isSuccess    = false;
                    closeResponse.ErrorMessage = "[" + closeResponse.HighestSeverity + "] Notification Code: " + nvcNotification["Code"].ToString() + ",\r\nNotification Message: " + nvcNotification["Message"].ToString();
                }
                #endregion Ground Close


                foreach (string nvKey in nvcNotification.AllKeys)
                {
                    switch (nvKey)
                    {
                    case "Code":
                        closeResponse.NoticeCode = nvcNotification[nvKey].ToString();
                        break;

                    case "Message":
                        closeResponse.NoticeMessage = nvcNotification[nvKey].ToString();
                        break;

                    case "Severity":
                        closeResponse.NoticeSeverity = nvcNotification[nvKey].ToString();
                        break;

                    case "Source":
                        closeResponse.NoticeSource = nvcNotification[nvKey].ToString();
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (System.Web.Services.Protocols.SoapException ex)
            {
                throw ex;
            }
            catch (System.ServiceModel.CommunicationException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (service != null)
                {
                    service.Dispose();
                }
            }

            return(closeResponse);
        }