コード例 #1
0
ファイル: ProcessError.cs プロジェクト: krisburtoft/QBWC
        public static void ProcessFailedOrder(Order order)
        {
            var rep = new Repository();
            var failure = new FailedOrder()
            {
                Imported = false,
                OrderID = order.OrderID,
                DateAdded = DateTime.Now,
                ClientID = rep.GetUser(WebSecurity.CurrentUserId).ClientID ?? 0
            };
            order.Reported = true;
            rep.Add(failure);
            rep.Save();

            var hostUrl = HttpContext.Current.Request.Url.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped);
            hostUrl = "http://quickbooks.infomedia.com";
            var importUrl = hostUrl + VirtualPathUtility.ToAbsolute("~/Account/Unprocessed-Invoices");
            var modifyUrl = hostUrl + VirtualPathUtility.ToAbsolute("~/Account/Inventory");
            var body = new System.Text.StringBuilder();
            body.AppendLine("Someone has made a purchase on your website which was not possible to import through the Web Connector and is ready for manual import.");
            body.AppendLine("Please view the order that failed and create the invoice manually here: " + importUrl);
            body.AppendLine(order.Receipt);
            var user = rep.GetUser(WebSecurity.CurrentUserId);
            var email = user.Client.EmailRecipient != null ? user.Client.EmailRecipient : WebSecurity.CurrentUserName;
            WebMail.Send(email, "Quickbooks Web Connector Failed Invoice Attempt", body.ToString(), cc: "*****@*****.**", isBodyHtml: false);
        }
コード例 #2
0
ファイル: ProcessError.cs プロジェクト: krisburtoft/QBWC
        public static void ProcessFailedOrder(int requestID, string xmlMessage)
        {
            var rep = new Repository();
            var failure = new FailedOrder()
            {
                Imported = false,
                RequestID = requestID,
                OrderID = rep.GetQuickBooksOrderByRequestID(requestID).OrderID,
                DateAdded = DateTime.Now,
                ClientID = rep.GetUser(WebSecurity.CurrentUserId).ClientID ?? 0
            };

            var order = rep.GetQuickBooksOrderByRequestID(requestID);
            order.ResponseXML = xmlMessage;
            rep.Add(failure);
            rep.Save();

            var hostUrl = HttpContext.Current.Request.Url.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped);
            hostUrl = "http://quickbooks.infomedia.com";
            var importUrl = hostUrl + VirtualPathUtility.ToAbsolute("~/Account/Unprocessed-Invoices");
            var modifyUrl = hostUrl + VirtualPathUtility.ToAbsolute("~/Account/Inventory");
            var body = new System.Text.StringBuilder();
            body.AppendLine("There was an error processing a website sale with Quickbooks");
            body.AppendLine("The most likely cause was that an item on the order was not found in your quickbooks inventory.");
            body.AppendLine("Please view the order that failed and create the invoice manually here: " + importUrl);
            body.AppendLine("You can modify your inventory naming schema here: " + modifyUrl);
            body.AppendLine(order.Receipt);
            body.AppendLine(xmlMessage);
            var user = rep.GetUser(WebSecurity.CurrentUserId);
            var email = user.Client.EmailRecipient != null ? user.Client.EmailRecipient : WebSecurity.CurrentUserName;
            WebMail.Send(email, "Quickbooks Web Connector Failed Invoice Attempt", body.ToString(), cc: "*****@*****.**", isBodyHtml: false);
        }
コード例 #3
0
ファイル: ProcessQueryRs.cs プロジェクト: krisburtoft/QBWC
 public static void InventoryQuery(string response)
 {
     var rep = new Repository();
     var doc = XDocument.Parse(response);
     var itemInventoryQueryRs = doc.Document.Root.Descendants("QBXMLMsgsRs").FirstOrDefault().Descendants("ItemInventoryQueryRs").FirstOrDefault();
     var msg = itemInventoryQueryRs.Attribute("statusMessage").Value;
     var requestID = Convert.ToInt32(itemInventoryQueryRs.Attribute("requestID").Value);
     if (msg == "A query request did not find a matching object in QuickBooks")
     {
         Error.ProcessFailedOrder(requestID,response);
     }
     else
     {
         var order = rep.GetQuickBooksOrderByRequestID(requestID);
         var quickbooksItem = new QuickbooksInventory(){
             ClientID = order.ClientID,
             FullName = itemInventoryQueryRs.Element("ItemInventoryRet").Element("FullName").Value,
             ListID = itemInventoryQueryRs.Element("ItemInventoryRet").Element("ListID").Value,
         };
         rep.Add(quickbooksItem);
         rep.Save();
         var shopInventory = rep.GetShopInventoryItems(order.ClientID).Where(i => i.Name == itemInventoryQueryRs.Element("ItemInventoryRet").Element("FullName").Value).SingleOrDefault();
         if (shopInventory == null)
         {
             rep.Add(new ShopInventory(){
                  ClientID = order.ClientID,
                  Name = itemInventoryQueryRs.Element("ItemInventoryRet").Element("FullName").Value,
                  QuickbooksInventoryID = quickbooksItem.QuickbooksInventoryID
             });
         }
         else
         {
             shopInventory.QuickbooksInventoryID = quickbooksItem.QuickbooksInventoryID;
         }
         order.Reported = false;
         rep.Save();
     }
 }
コード例 #4
0
ファイル: WebShopInventory.cs プロジェクト: krisburtoft/QBWC
 public static void GetCeInventory(webpages_Membership user)
 {
     var rep = new Repository();
     var infomediainventory = rep.GetCeInventoryItems(user.Client.ContentEditsClientID);
     var items = from inv in infomediainventory
                 select new ShopInventory()
                 {
                     ClientID = user.ClientID ?? 0,
                     Name = inv.title
                 };
     foreach (var item in items)
     {
         if (rep.GetShopInventory(user.ClientID ?? 0, item.Name) == null)
             rep.Add(item);
     }
     rep.Save();
 }
コード例 #5
0
ファイル: ProcessQueryRs.cs プロジェクト: krisburtoft/QBWC
        public static void ItemSalesTaxGroupQueryRs(string response)
        {
            var rep = new Repository();
            var client = rep.GetClient(rep.GetUser(WebSecurity.CurrentUserId).ClientID ?? 0);
            var db = Database.Open("Quickbooks");
            var taxCodes = XDocument.Parse(response).Document.Root.Descendants("QBXMLMsgsRs").Descendants("ItemSalesTaxGroupQueryRs").FirstOrDefault().Descendants("ItemSalesTaxGroupRet");
            var clientID = rep.GetUser(WebSecurity.CurrentUserId).ClientID;
            foreach (var item in taxCodes)
            {
                var taxCode = rep.GetSalesTaxCode(rep.GetUser(WebSecurity.CurrentUserId).ClientID ?? 0, item.Descendants("Name").FirstOrDefault().Value);
                var taxCodeExists = taxCode != null;
                var name = item.Descendants("Name").FirstOrDefault().Value;
                var listID = item.Descendants("ListID").FirstOrDefault().Value;
                decimal rate = 0;

                foreach(var rat in item.Descendants("ItemSalesTaxRef"))
                {
                    rate += rep.GetSalesTaxCode(clientID ?? 0,rat.Descendants("FullName").FirstOrDefault().Value).Rate;
                }
                var taxRate = rate;
                if (!taxCodeExists)
                {
                    var taxcode = new SalesTaxCode()
                    {
                        ClientID = clientID ?? 0,
                        QuickbooksFullName = name,
                        Rate = taxRate
                    };
                    rep.Add(taxcode);
                }

                rep.Save();
            }
        }
コード例 #6
0
ファイル: ProcessQueryRs.cs プロジェクト: krisburtoft/QBWC
        private static void ParseItemQuery(string retType,string itemNode,string response)
        {
            var rep = new Repository();
            var clientID = rep.GetUser(WebSecurity.CurrentUserId).ClientID ?? 0;
            var items = XDocument.Parse(response).Document.Root.Descendants("QBXMLMsgsRs").Descendants(retType).FirstOrDefault().Descendants(itemNode);
            List<QuickbooksInventory> inventoryList = new List<QuickbooksInventory>();
            foreach(var item in items)
            {
                var DatabaseItem = rep.GetQuickbooksInventoryItem(clientID,item.Descendants("ListID").FirstOrDefault().Value);
                if (DatabaseItem != null)
                {
                    DatabaseItem.FullName = item.Descendants("FullName").FirstOrDefault().Value;
                }
                else
                {
                    inventoryList.Add(new QuickbooksInventory(){
                        ClientID = clientID,
                        ListID = item.Descendants("ListID").FirstOrDefault().Value,
                        FullName = item.Descendants("FullName").FirstOrDefault().Value
                    });
                }

            }
            rep.Add(inventoryList);
            rep.Save();
        }