Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="inOrder"></param>
        /// <returns></returns>
        WebOrderDBInfo createWebOrderDBInfo(WebOrder inOrder)
        {
            WebOrderDBInfo result = new WebOrderDBInfo();

            //....................................................

            DTO_WebOrderHeader  headerSection  = inOrder.GetCompleteHeaderSection();
            DTO_WebOrderAccount accountSection = inOrder.GetCompleteAccountSection();

            result.GUID         = inOrder.Handle;
            result.Name         = accountSection.Name;
            result.StoreName    = headerSection.StoreName;
            result.OrderDate    = headerSection.OrderDate;
            result.ExpectedDate = headerSection.ExpectedDate;
            result.Status       = WebOrderDB.WebOrderStatus.ewosReceived;

            result.Recipient  = accountSection.Delivery.Recipient;
            result.StreetNo   = accountSection.Delivery.StreetNo;
            result.StreetName = accountSection.Delivery.StreetName;
            result.Suburb     = accountSection.Delivery.Suburb;
            result.City       = accountSection.Delivery.City;
            result.Country    = accountSection.Delivery.Country;
            result.Note       = accountSection.Delivery.Note;
            result.Phone      = accountSection.Delivery.Phone;

            result.Comments        = accountSection.Comments;
            result.PaymentRequired = accountSection.Payments.PaymentRequired;

            result.OrderTotal = headerSection.OrderTotal;
            result.Email      = accountSection.Email;
            result.OrderType  = accountSection.OrderType;
            //....................................................

            return(result);
        }
Ejemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="inWebOrderHandle"></param>
 /// <param name="inOrderHeader"></param>
 /// <returns></returns>
 public DTO_WebOrderResponse SaveIncompleteOrderHeaderSection(
     string inOrderHandle,
     DTO_WebOrderHeader inOrderHeaderSection)
 {
     try
     {
         if ((getWebOrder(inOrderHandle).HeaderSection = inOrderHeaderSection) != null)
         {
             // WebOrder successfuly open
             return(createResponseNoError());
         }
         else
         {
             // WebOrder: Failed to create an order
             return(createResponseError(@"Failed to set order's header",
                                        string.Format(@"Invalid order handle [{0}]", inOrderHandle),
                                        ResponseCode.FailedToCreateOrderHeaderSection));
         }
     }
     catch (Exception exc)
     {
         // WebOrder: Failed to create an order
         return(createResponseError(@"Failed to set order's header", exc.Message, ResponseCode.FailedToCreateOrderHeaderSection));
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="inStoreName"></param>
        /// <param name="inGUID"></param>
        /// <param name="inScheduled"></param>
        /// <param name="inRespond"></param>
        /// <param name="inOrderDate"></param>
        /// <param name="inExpectedDate"></param>
        /// <param name="inOrderTotal"></param>
        /// <param name="outOrderHeader"></param>
        /// <returns></returns>
        public bool CreateWebOrderHeader(
            string inStoreName,
            string inGUID,
            UInt16 inScheduled,
            bool inRespond,
            DateTime inOrderDate,
            DateTime inExpectedDate,
            Decimal inOrderTotal,
            ref DTO_WebOrderHeader outOrderHeader)
        {
            errorMsg_  = "";
            errorCode_ = ResponseCode.Successful;

            DTO_WebOrderResponse response = wcfClient_.CreateWebOrderHeader(
                inStoreName,
                inGUID,
                inScheduled,
                inRespond,
                inOrderDate,
                inExpectedDate,
                inOrderTotal,
                ref outOrderHeader);

            if (!response.Succesful)
            {
                errorMsg_  = response.Message;
                errorCode_ = response.ResponseCode;
            }

            return(response.Succesful);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        DTO_WebOrderHeader createOrderHeaderSection(
            string inOrderGUID,                                     // Order GUID
            decimal inOrderTotal,                                   // Order Total
            DateTime inOrderTime,                                   // Order Date
            DateTime inExpectedTime,                                // Expected Date
            UInt16 inScheduled,                                     // Scheduled
            string inStoreName,                                     // Store Name
            bool inRespond = false)
        {
            DTO_WebOrderHeader result = new DTO_WebOrderHeader();

            //.........................................

            result.GUID         = inOrderGUID;
            result.OrderTotal   = inOrderTotal;
            result.OrderDate    = inOrderTime;
            result.ExpectedDate = inExpectedTime;
            result.Scheduled    = inScheduled;
            result.StoreName    = inStoreName;
            result.Respond      = inRespond;

            //.........................................

            return(result);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        void saveHeaderSection(
            string inOrderHandle,                   // Incomplete Order Handle
            string inOrderGUID,                     // Order GUID
            decimal inOrderTotal,                   // Order Total
            DateTime inOrderTime,                   // Order Date
            DateTime inExpectedTime,                // Expected Date
            UInt16 inScheduled,                     // Scheduled
            string inStoreName,                     // Store Name
            bool inRespond         = false,
            bool inPaymentRequired = false)
        {
            DTO_WebOrderHeader orderHeader = createOrderHeaderSection(
                inOrderGUID,
                inOrderTotal,
                inOrderTime,
                inExpectedTime,
                inScheduled,
                inStoreName,
                inRespond);

            DTO_WebOrderResponse response = webmateClient_.SaveIncompleteOrderHeaderSection(
                inOrderHandle,
                orderHeader);

            if (!response.Succesful)
            {
                throw new Exception(string.Format(@"{0}: {1}", response.Message, response.Description));
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="inOrder"></param>
        /// <returns></returns>
        WebOrderDBItem[] createWebOrderDBItems(WebOrder inOrder, WebOrderDB inWebOrderDB, int inMenuKey) //changes for menu_key
        {
            List <WebOrderDBItem> result = new List <WebOrderDBItem>();

            //....................................................

            DTO_WebOrderAccount accountSection = inOrder.GetCompleteAccountSection();
            DTO_WebOrderHeader  headerSection  = inOrder.GetCompleteHeaderSection();

            foreach (DTO_WebOrderItem orderItem in accountSection.OrderItems)
            {
                WebOrderDBItem item = new WebOrderDBItem();
                item.ThirdPartyCodeKey = dbGetThirdPartyCodeKey(orderItem.UID, inWebOrderDB, inMenuKey); //changes for menu_key
                item.Qty         = orderItem.Qty;
                item.Price       = orderItem.BasePrice;
                item.PriceLevel0 = orderItem.BasePrice;
                item.PriceLevel1 = orderItem.BasePrice;
                item.TabName     = accountSection.Name;
                item.TimeStamp   = headerSection.OrderDate;
                item.Note        = orderItem.Note;

                //--------------------------------------------------------
                // Options are ignored in this version of Webmate
                //--------------------------------------------------------

                /*
                 * foreach (DTO_WebOrderItemOption orderItemOption in orderItem.ItemOptions)
                 * {
                 *  WebOrderDBItemOption option = new WebOrderDBItemOption();
                 *  option.OptionKey = Convert.ToInt32(orderItemOption.UID);
                 *  item.ItemOptions.Add(option);
                 * }
                 */

                foreach (DTO_WebOrderItemSide orderItemSide in orderItem.ItemSides)
                {
                    WebOrderDBItemSide side = new WebOrderDBItemSide();
                    side.ThirdPartyCodeKey = dbGetThirdPartyCodeKey(orderItemSide.UID, inWebOrderDB, inMenuKey); //changes for menu_key
                    side.Qty               = orderItemSide.Qty;
                    side.Price             = orderItemSide.BasePrice;
                    side.PriceLevel0       = orderItemSide.BasePrice;
                    side.PriceLevel1       = orderItemSide.BasePrice;
                    side.TimeStamp         = headerSection.OrderDate;
                    side.TransactionNumber = orderItemSide.UID;
                    side.TabName           = accountSection.Name;
                    side.Note              = orderItem.Note;
                    item.ItemSides.Add(side);
                }

                result.Add(item);
            }

            //....................................................

            return(result.ToArray());
        }
Ejemplo n.º 7
0
 public void GetHeader_InvalidHandle()
 {
     using (WCFServiceTestSettings settings = new WCFServiceTestSettings())
     {
         string             handle = "e6a9bb54-da25-102b-9a03-2db401e887ec";
         DTO_WebOrderHeader header = new DTO_WebOrderHeader();
         var response = settings.Client.RetrieveIncompleteOrderHeaderSection(out header, handle);
         Assert.IsFalse(response.Succesful);
     }
 }
Ejemplo n.º 8
0
 public void SaveHeader_ValidHandle()
 {
     using (WCFServiceTestSettings settings = new WCFServiceTestSettings())
     {
         string handle = "";
         settings.Client.OpenWebOrder(out handle);
         DTO_WebOrderHeader header = settings.CreateHeaderSection();
         var response = settings.Client.SaveIncompleteOrderHeaderSection(handle, header);
         Assert.IsTrue(response.Succesful);
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="inOrderHeader"></param>
        /// <returns></returns>
        void setHeaderSection(DTO_WebOrderHeader inOrderHeader)
        {
            _headerSection.StoreName    = inOrderHeader.StoreName;
            _headerSection.GUID         = inOrderHeader.GUID;
            _headerSection.Scheduled    = inOrderHeader.Scheduled;
            _headerSection.Respond      = inOrderHeader.Respond;
            _headerSection.OrderTotal   = inOrderHeader.OrderTotal;
            _headerSection.ExpectedDate = inOrderHeader.ExpectedDate;
            _headerSection.OrderDate    = inOrderHeader.OrderDate;

            web_order_commit.SetHeaderSection(_handle.ToString(), _headerSection);
        }
Ejemplo n.º 10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="inOrderHandle"></param>
 /// <param name="incompleteHeader"></param>
 public void RetrieveIncompleteHeaderSection(
     string inOrderHandle,
     out DTO_WebOrderHeader incompleteHeader)
 {
     try
     {
         retrieveIncompleteHeader(inOrderHandle, out incompleteHeader);
     }
     catch (Exception ex)
     {
         errorMs_ = ex.Message;
         throw;
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        Guid initDBWebOrder()
        {
            _headerSection  = getEmptyHeaderSection();
            _fromSection    = getEmptyFromSection();
            _accountSection = getEmptyAccountSection();

            //...............................................

            web_order_commit = new WebOrderCommit();
            xml_doc          = new XmlDocument();

            //...............................................

            return(Guid.NewGuid());
        }
Ejemplo n.º 12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="inOrderHandle"></param>
        /// <param name="incompleteHeader"></param>
        private void retrieveIncompleteHeader(string inOrderHandle, out DTO_WebOrderHeader incompleteHeader)
        {
            if (string.IsNullOrEmpty(inOrderHandle))
            {
                throw new Exception("Invalid order handle");
            }

            DTO_WebOrderResponse response = webmateClient_.RetrieveIncompleteOrderHeaderSection(
                out incompleteHeader,
                inOrderHandle);

            if (!response.Succesful)
            {
                throw new Exception(response.Message);
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        DTO_WebOrderHeader getEmptyHeaderSection()
        {
            DTO_WebOrderHeader result = new DTO_WebOrderHeader();

            //..................................

            result.StoreName    = @"";
            result.GUID         = Guid.Empty.ToString();
            result.Scheduled    = 0;
            result.Respond      = true;
            result.OrderTotal   = 0;
            result.ExpectedDate = DateTime.Now;
            result.OrderDate    = DateTime.Now;

            //..................................

            return(result);
        }
Ejemplo n.º 14
0
        public void GetHeader_ValidHandle()
        {
            using (WCFServiceTestSettings settings = new WCFServiceTestSettings())
            {
                string handle = "";
                settings.Client.OpenWebOrder(out handle);
                DTO_WebOrderHeader header = settings.CreateHeaderSection();
                var response = settings.Client.SaveIncompleteOrderHeaderSection(handle, header);
                DTO_WebOrderHeader headerPart = new DTO_WebOrderHeader();
                settings.Client.RetrieveIncompleteOrderHeaderSection(out headerPart, handle);

                Assert.AreEqual(header.StoreName, headerPart.StoreName);
                Assert.AreEqual(header.Scheduled, headerPart.Scheduled);
                Assert.AreEqual(header.Respond, headerPart.Respond);
                Assert.AreEqual(header.OrderTotal, headerPart.OrderTotal);
                Assert.AreEqual(header.OrderDate.ToShortDateString(), headerPart.OrderDate.ToShortDateString());
                Assert.AreEqual(header.ExpectedDate.ToShortDateString(), headerPart.ExpectedDate.ToShortDateString());
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="inOrderHandle"></param>
        /// <param name="outHeader"></param>
        /// <returns></returns>
        public DTO_WebOrderResponse RetrieveIncompleteOrderHeaderSection(
            string inOrderHandle,
            out DTO_WebOrderHeader outHeaderSection)
        {
            try
            {
                outHeaderSection = getWebOrder(inOrderHandle).HeaderSection;

                // WebOrder's header successfuly retrieved
                return(createResponseNoError());
            }
            catch (Exception exc)
            {
                //outHeaderSection = getWebOrder(inOrderHandle).EmptyHeaderSection;
                outHeaderSection = null;

                // WebOrder: Failed to retrieve an order's header section
                return(createResponseError(@"Failed to retrieve order's header",
                                           exc.Message,
                                           ResponseCode.FailedToRetrieveOrderHeaderSection));
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="inHeader"></param>
        /// <param name="inFrom"></param>
        /// <param name="inAccount"></param>
        /// <param name="outWebOrder"></param>
        /// <returns></returns>
        public bool OpenWebOrder(
            DTO_WebOrderHeader inHeader,
            DTO_WebOrderFrom inFrom,
            DTO_WebOrderAccount inAccount,
            ref DTO_WebOrder outWebOrder)
        {
            errorMsg_  = "";
            errorCode_ = ResponseCode.Successful;

            inHeader.PropertyChanged  += propertyChangedEventHandler;
            inFrom.PropertyChanged    += propertyChangedEventHandler;
            inAccount.PropertyChanged += propertyChangedEventHandler;

            DTO_WebOrderResponse response = wcfClient_.OpenWebOrder(inHeader, inFrom, inAccount, ref outWebOrder);

            if (!response.Succesful)
            {
                errorMsg_  = response.Message;
                errorCode_ = response.ResponseCode;
            }

            return(response.Succesful);
        }
Ejemplo n.º 17
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="inWebOrderHandle"></param>
 /// <param name="inOrderHeader"></param>
 /// <returns></returns>
 public void SetHeaderSection(string inWebOrderHandle, DTO_WebOrderHeader inOrderHeader)
 {
     web_order_xml_manager.SetIncompleteHeaderSection(inWebOrderHandle, inOrderHeader);
 }
Ejemplo n.º 18
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="inWebOrderHandle"></param>
 /// <param name="outOrderHeader"></param>
 public void LoadHeaderSection(string inWebOrderHandle, DTO_WebOrderHeader outOrderHeader)
 {
     web_order_xml_manager.LoadIncompleteHeaderSection(inWebOrderHandle, outOrderHeader);
 }