Esempio n. 1
0
        public Order Save()
        {
            string request = "";
            string response = "";
            string logMessage, logNote;
            var    provider = _provider as LiveEBSProvider;

            if (String.IsNullOrWhiteSpace(provider.OrderInboundURL))
            {
                throw new Exception("Provider's InitForOrder not run.");
            }

            PROCESS_ORDER.OE_INBOUND_INT_Service client = EBSProxyFactory.GetOrderInboundServiceInstance(provider.OrderInboundURL, ConfigurationSetting.username, ConfigurationSetting.password, ConfigurationSetting.EBSServiceTimeout);
            PROCESS_ORDER.SOAHeader hdr = new PROCESS_ORDER.SOAHeader();
            hdr.Responsibility  = "ORDER_MGMT_SUPER_USER";
            hdr.RespApplication = "ONT";
            hdr.Org_Id          = "204";
            hdr.SecurityGroup   = "STANDARD";
            hdr.NLSLanguage     = "AMERICAN";

            client.SOAHeaderValue = hdr;

            var ip = new PROCESS_ORDER.InputParameters();

            ip.P_API_VERSION_NUMBER          = 1;
            ip.P_API_VERSION_NUMBERSpecified = true;
            ip.P_INIT_MSG_LIST = "T";
            ip.P_RETURN_VALUES = "T";
            ip.P_ACTION_COMMIT = "T";
            ip.P_RTRIM_DATA    = "T";

            ip.P_HEADER_REC                        = new PROCESS_ORDER.APPSOE_ORDER_PUB_HEADER_REC_TYPE();
            ip.P_HEADER_REC.ATTRIBUTE15            = ATTRIBUTE15;
            ip.P_HEADER_REC.BOOKED_FLAG            = "N";
            ip.P_HEADER_REC.ORDER_TYPE_ID          = 1430;
            ip.P_HEADER_REC.ORDER_TYPE_IDSpecified = true;
            ip.P_HEADER_REC.OPERATION              = "CREATE";

            ip.P_LINE_TBL = new PROCESS_ORDER.APPSOE_ORDER_PUB_LINE_REC_TYPE[Items.Count];
            var items = Items.ToArray();

            for (int i = 0; i < Items.Count; i++)
            {
                var src  = items[i];
                var dest = ip.P_LINE_TBL[i] = new PROCESS_ORDER.APPSOE_ORDER_PUB_LINE_REC_TYPE();
                dest.INVENTORY_ITEM_ID           = src.INVENTORY_ITEM_ID;
                dest.INVENTORY_ITEM_IDSpecified  = true;
                dest.ORDERED_QUANTITY            = src.ORDERED_QUANTITY;
                dest.ORDERED_QUANTITYSpecified   = true;
                dest.UNIT_SELLING_PRICE          = src.UNIT_SELLING_PRICE;
                dest.UNIT_SELLING_PRICESpecified = true;
                dest.OPERATION = "CREATE";
            }
            PROCESS_ORDER.OutputParameters op = null;
            Stopwatch stopwatch = new Stopwatch();

            try
            {
                var serializer = LiveEBSProvider.serializer;
                request = serializer.Serialize(ip);

                logMessage = "Request of saving Order (PROCESS_ORDER). ";
                logNote    = "Request Payload: " + request;
                provider.log.DebugLog(IncidentId, ContactId, logMessage, logNote);
                // call the web service, catch the exception right away
                stopwatch.Start();
                op = client.PROCESS_ORDER(ip);
                stopwatch.Stop();
                response         = serializer.Serialize(op);
                HEADER_ID        = op.X_HEADER_REC.HEADER_ID;
                CREATION_DATE    = op.X_HEADER_REC.CREATION_DATE;
                LAST_UPDATE_DATE = op.X_HEADER_REC.LAST_UPDATE_DATE;
                FLOW_STATUS_CODE = op.X_HEADER_REC.FLOW_STATUS_CODE;
            }
            catch (Exception ex)
            {
                provider.handleEBSException(ex, "PROCESS_ORDER", IncidentId, ContactId);
                // will throw the new exception (either timeout or error communicating ...)
                throw;
            }

            if (op.X_RETURN_STATUS == "S")
            {
                logMessage = "Response of saving Order(PROCESS_ORDER). ";
                logNote    = "Response Payload: " + response;
                provider.log.DebugLog(IncidentId, ContactId, logMessage, logNote, (int)stopwatch.ElapsedMilliseconds);
            }
            else
            {
                logMessage = "Response of saving Order (PROCESS_ORDER (Failure). ";
                logNote    = "Response Payload: " + response;
                provider.log.ErrorLog(IncidentId, ContactId, logMessage, logNote);
            }
            return(this);
        }
 public static OE_INBOUND_INT_Service GetOrderInboundServiceInstance(string url, string username = null, string password = null, int timeout = -1)
 {
     if (_order_inbound == null)
     {
         _order_inbound = new OE_INBOUND_INT_Service();
         serviceClientSetting(_order_inbound, url, username, password, timeout);
     }
     return _order_inbound;
 }