コード例 #1
0
        }//GetCostPrice

        //-------------------------------------------------------------------------------------------------------//

        /// <summary>
        /// Make sure all objects are released for garbage collection.
        /// </summary>
        public void DestroyAllObjects()
        {
            if (salesRecord != null)
            {
                Marshal.FinalReleaseComObject(salesRecord);
                salesRecord = null;
            }//If
            if (currencyData != null)
            {
                Marshal.FinalReleaseComObject(currencyData);
                currencyData = null;
            }//If
            if (stockRecord != null)
            {
                Marshal.FinalReleaseComObject(stockRecord);
                stockRecord = null;
            }//If

            if (ws != null)
            {
                ws.Disconnect();
                Marshal.FinalReleaseComObject(ws);
                ws = null;
            }//If

            if (sdo != null)
            {
                Marshal.FinalReleaseComObject(sdo);
                sdo = null;
            } //If
        }     //DestroyAllObjects
コード例 #2
0
      }//parseExMsg

      //------------------------------------------------------------------------------------------------------------------//

      /// <summary>
      /// Make sure all objects are released for garbage collection.
      /// </summary>
      public void DestroyAllObjects()
      {
         if (invoiceRecord != null)
         {
            Marshal.FinalReleaseComObject(invoiceRecord);
            invoiceRecord = null;
         }//If
         if (invoiceItem != null)
         {
            Marshal.FinalReleaseComObject(invoiceItem);
            invoiceItem = null;
         }//If


         if (ws != null)
         {
            ws.Disconnect();
            Marshal.FinalReleaseComObject(ws);
            ws = null;
         }//If

         if (sdo != null)
         {
            Marshal.FinalReleaseComObject(sdo);
            sdo = null;
         }//If

      }//DestroyAllObjects
コード例 #3
0
        //-------------------------------------------------------------------------------------------------------//

        public SDOProductReader()
        {
            sdo = new SDOEngine();
            ws  = (WorkSpace)sdo.Workspaces.Add("App Server Update");
            ws.Disconnect();
            ws.Connect(sageUsrSet.sageDBDir, sageUsrSet.sageUsername, sageUsrSet.sagePassword, "UniqueUpdater");
        }//ctor
コード例 #4
0
        }     //AddItem

        //----------------------------------------------------------------------------------------------//

        private void DestroyAllObjects()
        {
            if (conData != null)
            {
                Marshal.FinalReleaseComObject(conData);
                conData = null;
            }//If
            if (currData != null)
            {
                Marshal.FinalReleaseComObject(currData);
                currData = null;
            }//If
            if (sopPost != null)
            {
                Marshal.FinalReleaseComObject(sopPost);
                sopPost = null;
            }//If
            if (sopItem != null)
            {
                Marshal.FinalReleaseComObject(sopItem);
                sopItem = null;
            }//If
            if (stockRecord != null)
            {
                Marshal.FinalReleaseComObject(stockRecord);
                stockRecord = null;
            }//If

            if (ws != null)
            {
                ws.Disconnect();
                Marshal.FinalReleaseComObject(ws);
                ws = null;
            }//If

            if (sdo != null)
            {
                Marshal.FinalReleaseComObject(sdo);
                sdo = null;
            } //If
        }     //DestroyAllObjects
コード例 #5
0
      }//readInvoiceData

      //-------------------------------------------------------------------------------------------------------//

      /// <summary>
      /// Get Last price of the product that this customer bought.
      /// </summary>
      /// <param name="customerCode">Customer Code</param>
      /// <param name="productCode">Product Code</param>
      /// <returns></returns>
      public Sale GetLastPriceData(string customerCode, string productCode)
      {

         ///Start date is lookBackYrs year ago.
         int lookBackYrs = (int)Settings.Default.invoiceLookBackYrs;
         DateTime startDate = DateTime.Now.AddYears(-lookBackYrs);
         int invNum = -1;
         //string cusCode = String.Empty;
         double salePrice = -1;
         int currCode = -1;
         double xRate = -1;
         DateTime invDate = new DateTime();

         try
         {
            sdo = new SDOEngine();
            //Try a connection, will throw an exception if it fails
            ws = (WorkSpace)sdo.Workspaces.Add("App Server Update");
            ws.Disconnect();
            ws.Connect(sageUsrSet.sageDBDir, sageUsrSet.sageUsername, sageUsrSet.sagePassword, "UniqueUpdater");

            //Create instances of the objects
            invoiceRecord = (InvoiceRecord)ws.CreateObject("InvoiceRecord");
            invoiceItem = (InvoiceItem)ws.CreateObject("InvoiceItem");
            var cs = (string)SDOHelper.Read(invoiceRecord, "ACCOUNT_REF");

            SDOHelper.Write(invoiceRecord, "ACCOUNT_REF", customerCode);
            invoiceRecord.Find(false);
            invNum = (int)SDOHelper.Read(invoiceRecord, "INVOICE_NUMBER");
            //Start at last Invoice
            invoiceRecord.MoveLast();
            do
            {
               //Invoice info
               invDate = (DateTime)SDOHelper.Read(invoiceRecord, "INVOICE_DATE");
               cs =  (string)SDOHelper.Read(invoiceRecord, "ACCOUNT_REF");

               //Only read invoice details if it is recent enough.
               if (invDate < startDate)
                  break;

               invNum = (int)SDOHelper.Read(invoiceRecord, "INVOICE_NUMBER");
               currCode = (sbyte)SDOHelper.Read(invoiceRecord, "CURRENCY");
               xRate = (double)SDOHelper.Read(invoiceRecord, "FOREIGN_RATE");

               //Link Items to Record
               invoiceItem = invoiceRecord.Link;


               var lastPriceResult = invoiceItem.FindFirst("STOCK_CODE", productCode);

               if (lastPriceResult)
               {
                  double netAmount = (double)SDOHelper.Read(invoiceItem, "NET_AMOUNT");
                  double qty = (double)SDOHelper.Read(invoiceItem, "QTY_ORDER");
                  salePrice = netAmount / qty;
                  return new Sale(invDate, salePrice, productCode);
               }//If




            } while (invoiceRecord.MovePrev());

         }
         catch (Exception e)
         {
            string eString = "Problem reading Invoice Data"
                              + "\r\n    -----------------     \r\n"
                              + e.GetType() + "\r\n" + e.Message
                              + "\r\n    -----------------     \r\n"
                              + "\r\nInvoice No.: " + invNum + ", Product: " + productCode + ", Customer : " + customerCode
                              + "\r\nSale Price : " + salePrice + "\r\n";
            throw new Exception(eString);
         }
         finally
         {
            DestroyAllObjects();
         }//Finally

         return null;
         
      }//readInvoiceData