コード例 #1
0
        public List <IntershopWebService.ProductPrice> GetItemsPrice(List <IntershopWebService.ProductPriceIn> products, string company, string customerID)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            MessageLogger.info(string.Format("GetItemsPrice(count={0}, custaccount={1}, company={2})", (object)products.Count, (object)customerID, (object)company));
            Axapta ax = this.axLogon(company);
            List <IntershopWebService.ProductPrice> productPriceList = new List <IntershopWebService.ProductPrice>();

            try
            {
                foreach (IntershopWebService.ProductPriceIn product in products)
                {
                    object obj = ax.CallStaticClassMethod("BTX_ISHItemDescriptionProxy", "GetSalesPrice", (object)customerID, (object)product.itemId, (object)product.unitId);
                    IntershopWebService.ProductPrice productPrice = new IntershopWebService.ProductPrice()
                    {
                        itemId = product.itemId,
                        price  = Math.Round(Convert.ToDouble(obj), 2)
                    };
                    productPrice.miscCharges = this.ExtractMiscCharges(ax, productPrice.itemId, customerID, productPrice.price, (int)product.quantity, product.unitId);
                    stopwatch.Stop();
                    MessageLogger.info(string.Format("GetItemsPrice({0}, {1}, {2}) -> {3} , exec time -> {4} ms", (object)productPrice.itemId, (object)customerID, (object)company, (object)productPrice.price, (object)stopwatch.ElapsedMilliseconds));
                    productPriceList.Add(productPrice);
                }
                return(productPriceList);
            }
            catch (Exception ex)
            {
                return((List <IntershopWebService.ProductPrice>)null);
            }
            finally
            {
                ax.Logoff();
            }
        }
コード例 #2
0
        public IntershopWebService.TrackInfo GetTrackInfo(string company, string customerID, string salesID)
        {
            MessageLogger.info(string.Format("GetTrackInfo(company={0}, customerID={1}, salesID={2})", (object)company, (object)customerID, (object)salesID));
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            if (string.IsNullOrEmpty(customerID) || string.IsNullOrEmpty(salesID))
            {
                return new IntershopWebService.TrackInfo()
                       {
                           ErrorMsg  = "Please populate both lookup fields.",
                           ErrorCode = IntershopWebService.TrackInfoError.ERROR_NO_PARAM
                       }
            }
            ;
            Axapta axapta = this.axLogon(company);

            try
            {
                IntershopWebService.TrackInfo trackInfo = this.extractTrackInfo(Convert.ToString(axapta.CallStaticClassMethod("BTX_SharedFunctionsProxy", "getTrackAndTraceLinks", (object)customerID, (object)salesID)));

                stopwatch.Stop();
                MessageLogger.info(string.Format("GetTrackInfo() -> {0} ms", (object)stopwatch.ElapsedMilliseconds));
                return(trackInfo);
            }
            catch (Exception ex)
            {
                MessageLogger.info(string.Format("GetTrackInfo() -> error: {0}", (object)ex.Message));
                return((IntershopWebService.TrackInfo)null);
            }
            finally
            {
                axapta.Logoff();
            }
        }
コード例 #3
0
        public List <IntershopWebService.ProductStock> GetItemsStock(List <IntershopWebService.ProductStockIn> products, string company)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            MessageLogger.info(string.Format("GetItemsStock(count={0}, company={1})", (object)products.Count, (object)company));
            Axapta axapta = (Axapta)null;
            List <IntershopWebService.ProductStock> productStockList = new List <IntershopWebService.ProductStock>();

            try
            {
                axapta = this.axLogon(company);
                foreach (IntershopWebService.ProductStockIn product in products)
                {
                    string str = Convert.ToString(axapta.CallStaticClassMethod("BTX_ISHItemDescriptionProxy", "GetOnHandUrl", (object)product.itemId, (object)string.Empty));
                    IntershopWebService.ProductStock productStock = new IntershopWebService.ProductStock();
                    productStock.itemId     = product.itemId;
                    productStock.stockLevel = str;
                    productStockList.Add(productStock);
                    stopwatch.Stop();
                    MessageLogger.info(string.Format("GetItemsStock({0}, {1}, {2}, {3}) -> {4} , exec time -> {5} ms", (object)product.itemId, (object)product.size, (object)product.color, (object)company, (object)productStock.stockLevel, (object)stopwatch.ElapsedMilliseconds));
                }
                return(productStockList);
            }
            catch (Exception ex)
            {
                return((List <IntershopWebService.ProductStock>)null);
            }
            finally
            {
                axapta.Logoff();
            }
        }
コード例 #4
0
        public ActionResult UpdateTransfer(Transfer transfer)
        {
            try
            {
                TransferStates status = (TransferStates)Enum.ToObject(typeof(TransferStates), transfer.Status);

                Axapta axDB1 = new Axapta();
                System.Net.NetworkCredential ncDB1 = new System.Net.NetworkCredential("EP_AX2012", "VendTable1", "RIWAL01");
                axDB1.LogonAs(ConfigurationManager.AppSettings["User"], ConfigurationManager.AppSettings["Domain"], ncDB1, transfer.DataAreaId, ConfigurationManager.AppSettings["Language"], ConfigurationManager.AppSettings["AOS"], "");

                axDB1.TTSBegin();
                AxaptaRecord A4URequest = (AxaptaRecord)axDB1.CallStaticRecordMethod("A4URequests", "Find", transfer.RequestId, true);
                if (transfer.ExactDateInput)
                {
                    A4URequest.set_Field("DateOffHire", transfer.DateOffHire);
                }
                else
                {
                    A4URequest.set_Field("DateExpectedOffHire", transfer.DateOffHire);
                }
                A4URequest.set_Field("Status", (int)status);
                A4URequest.Update();
                axDB1.TTSCommit();
                axDB1.Logoff();
                axDB1.Dispose();
                return(Content("true"));
            }
            catch
            {
                return(Content("false"));
            }
        }
コード例 #5
0
        // GET /Download/InvoicePath
        public ContentResult InvoicePath(string companyid, string invoiceid, string invoiceType)
        {
            string filePath  = "";
            string sessionId = "";
            Axapta axESP     = new Axapta();

            System.Net.NetworkCredential ncESP = new System.Net.NetworkCredential("EP_AX2012", "VendTable1", "RIWAL01");
            axESP.LogonAs(ConfigurationManager.AppSettings["User"], ConfigurationManager.AppSettings["Domain"], ncESP, companyid, ConfigurationManager.AppSettings["Language"], ConfigurationManager.AppSettings["AOS"], "");

            sessionId = axESP.CallStaticClassMethod("LNIDocuAction", "SessionId").ToString();
            string tempFile = String.Format(@"\\RIWLSN01\OUT\Batch\{0}_{1}_Invoice_AX40_ESP_Live.pdf", sessionId, companyid);

            if (System.IO.File.Exists(tempFile))
            {
                System.IO.File.Delete(tempFile);
            }

            if (invoiceType == "S")
            {
                filePath = axESP.CallStaticClassMethod("LNIDocuAction", "PrintDocumentExternal", invoiceid).ToString();
            }
            if (invoiceType == "P")
            {
                filePath = axESP.CallStaticClassMethod("LNIDocuAction", "PrintDocumentExternal_ProjInvoice", invoiceid).ToString();
            }
            axESP.Logoff();

            return(Content(filePath));
        }
コード例 #6
0
        public IntershopWebService.ProductPrice GetItemPrice(string itemId, string customerID, string Unit, string company)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            Axapta ax = this.axLogon(company);

            IntershopWebService.ProductPrice productPrice = new IntershopWebService.ProductPrice();
            try
            {
                double num = Convert.ToDouble(ax.CallStaticClassMethod("BTX_ISHItemDescriptionProxy", "GetSalesPrice", new object[4]
                {
                    (object)customerID,
                    (object)itemId,
                    (object)Unit,
                    (object)""
                }));
                productPrice.itemId      = itemId;
                productPrice.price       = num;
                productPrice.miscCharges = this.ExtractMiscCharges(ax, productPrice.itemId, customerID, productPrice.price, 1, Unit);
                stopwatch.Stop();
                MessageLogger.info(string.Format("GetItemPrice({0}, {1}, {2}, {3}) -> {4} , exec time -> {5} ms", (object)itemId, (object)customerID, (object)Unit, (object)company, (object)productPrice.price, (object)stopwatch.ElapsedMilliseconds));
                return(productPrice);
            }
            catch (Exception ex)
            {
                return((IntershopWebService.ProductPrice)null);
            }
            finally
            {
                ax.Logoff();
            }
        }
コード例 #7
0
        private bool DeletedAxComination(tbl_AccessoryAttributesDetails detailsToUpdate, int userIserial)
        {
            var axapta = new Axapta();                                            //Ready To be Dependent from Ax;

            var         credential = new NetworkCredential("bcproxy", "around1"); //Ready To be Dependent from Ax
            bool        result     = false;
            TblAuthUser userToLogin;

            using (var model = new WorkFlowManagerDBEntities())
            {
                userToLogin = model.TblAuthUsers.SingleOrDefault(x => x.Iserial == userIserial);
            }
            axapta.LogonAs(userToLogin.User_Win_Login, userToLogin.User_Domain, credential, "Ccm", null, null, null);
            try
            {
                var importNew = axapta.CreateAxaptaObject("CreateProductionJournals");
                result = (bool)importNew.Call("DeleteInventDimCombination", detailsToUpdate.tbl_AccessoryAttributesHeader.Code, detailsToUpdate.Configuration, detailsToUpdate.Size);
            }
            catch (Exception)
            {
            }

            axapta.Logoff();
            return(result);
        }
コード例 #8
0
ファイル: BusinessLogic.cs プロジェクト: MaKeBits/AxRest
        static void Main(string[] args)
        {
            // Create the .NET Business Connector objects.
            Axapta ax;
            string sID = "@SYS21669";
            object o;
            bool b;

            try
            {
                // Login to Microsoft Dynamics Ax.
                ax = new Axapta();
                ax.Logon(null, null, null, null);

            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred in object creation or Axapta logon: {0}", e.Message);
                return;
            }

            // Logon was successful.
            try
            {
                // Call a static class method.
                // In this example, call SysLabel::labelId2String2
                // to determine the label string for a particular label ID.
                o = ax.CallStaticClassMethod("SysLabel", "labelId2String2", sID);
            }
            catch (Exception e)
            {
                Console.WriteLine("An error has been encountered during CallStaticClassMethod: {0}", e.Message);
                b = ax.Logoff();
                return;
            }

            // Display the returned string.
            Console.WriteLine("The label string for {0} is {1}.", sID, o.ToString());

            // Log off from Microsoft Dynamics AX.
            b = ax.Logoff();
        }
コード例 #9
0
ファイル: BusinessLogic.cs プロジェクト: pimphongphat/AxRest
        static void Main(string[] args)
        {
            // Create the .NET Business Connector objects.
            Axapta ax;
            string sID = "@SYS21669";
            object o;
            bool   b;

            try
            {
                // Login to Microsoft Dynamics Ax.
                ax = new Axapta();
                ax.Logon(null, null, null, null);
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred in object creation or Axapta logon: {0}", e.Message);
                return;
            }

            // Logon was successful.
            try
            {
                // Call a static class method.
                // In this example, call SysLabel::labelId2String2
                // to determine the label string for a particular label ID.
                o = ax.CallStaticClassMethod("SysLabel", "labelId2String2", sID);
            }
            catch (Exception e)
            {
                Console.WriteLine("An error has been encountered during CallStaticClassMethod: {0}", e.Message);
                b = ax.Logoff();
                return;
            }

            // Display the returned string.
            Console.WriteLine("The label string for {0} is {1}.", sID, o.ToString());

            // Log off from Microsoft Dynamics AX.
            b = ax.Logoff();
        }
コード例 #10
0
        public bool CreateRepairLines(string serviceOrderNo, string serviceOrderRelation, string conditionId, string symptomAreaId, string symptomCodeId, string diagonsisAreaId, string diagonsisCodeId, string resolutionId, string repairStageId, string technicianNo, string description, string serviceComments, string userName)
        {
            Axapta ax = null;
            object[] param = new object[12];
            object axObject;
            bool flagValue;
            bool isSuccess = false;
            try
            {
                ax = new Axapta();
                ax.LogonAs(userName.Trim(), "", networkCredentials, axCompany, "", "", "");

                param[0] = serviceOrderNo;
                param[1] = serviceOrderRelation;
                param[2] = conditionId;
                param[3] = symptomAreaId;
                param[4] = symptomCodeId;
                param[5] = diagonsisAreaId;
                param[6] = diagonsisCodeId;
                param[7] = resolutionId;
                param[8] = repairStageId;
                param[9] = technicianNo;
                param[10] = description;
                param[11] = serviceComments;

                axObject = ax.CallStaticClassMethod("ServiceOrderManagement", "createSMARepairLine", param).ToString();
                if (bool.TryParse(axObject.ToString(), out flagValue))
                {
                    isSuccess = flagValue;
                }

                if (!isSuccess)
                {
                    string parameterString = "";
                    for (int i = 0; i < param.Length; i++)
                    {
                        parameterString += "param[" + i + "]" + param[i].ToString() + "; ";
                    }

                    throw new Exception(String.Format("AX Failure:- Method='{0}' Parameters:Values = {1} - ", "createSMARepairLine", parameterString));
                }
            }
            catch (Exception e)
            {
                throw e;
                // Take other error action as needed.
            }
            finally
            {
                if (ax != null) ax.Logoff();
            }
            return isSuccess;
        }
コード例 #11
0
        public IntershopWebService.TotalDetails OrderTotalAmountDetails(string customerID, List <IntershopWebService.IshOrderLine> orderLines, string IshBasketID, string company)
        {
            MessageLogger.info(string.Format("OrderTotalAmountDetails(company={0}, customerID={1})", (object)company, (object)customerID));
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            Axapta ax = this.axLogon(company);

            ax.Refresh();
            try
            {
                AxaptaContainer axaptaContainer1 = ax.CreateAxaptaContainer();
                foreach (IntershopWebService.IshOrderLine orderLine in orderLines)
                {
                    IntershopWebService.IshOrderLine productIn = orderLine;
                    string str = string.Empty;
                    productIn.size  = this.normalizeXmlString(productIn.size);
                    productIn.color = this.normalizeXmlString(productIn.color);
                    List <IntershopWebService.SizeStock> itemDims = this.getItemDims(productIn.ItemID, company);
                    if (itemDims.Count > 0 && (!string.IsNullOrEmpty(productIn.size) || !string.IsNullOrEmpty(productIn.color)))
                    {
                        if (itemDims.FindIndex((Predicate <IntershopWebService.SizeStock>)(f => f.size == productIn.size)) >= 0)
                        {
                            str = productIn.size;
                        }
                        if (itemDims.FindIndex((Predicate <IntershopWebService.SizeStock>)(f => f.color == productIn.color)) >= 0)
                        {
                            str = productIn.color;
                        }
                    }
                    AxaptaContainer axaptaContainer2 = ax.CreateAxaptaContainer();
                    axaptaContainer2.Add((object)productIn.ItemID);
                    axaptaContainer2.Add((object)productIn.Qty);
                    axaptaContainer2.Add((object)productIn.SalesUnit);
                    axaptaContainer2.Add((object)str);
                    axaptaContainer1.Add((object)axaptaContainer2);
                }
                AxaptaContainer totalContainer = (AxaptaContainer)ax.CallStaticClassMethod("BTX_ISHItemDescriptionProxy", "CalcTotalAmountDetails", (object)customerID, (object)axaptaContainer1, (object)IshBasketID);
                stopwatch.Stop();
                MessageLogger.info(string.Format("OrderTotalAmount() -> {0} ms", (object)stopwatch.ElapsedMilliseconds));
                return(this.extractTotalDetails(ax, totalContainer));
            }
            catch (Exception ex)
            {
                MessageLogger.info(string.Format("OrderTotalAmount() -> error: {0}", (object)ex.Message));
                return((IntershopWebService.TotalDetails)null);
            }
            finally
            {
                ax.Logoff();
            }
        }
コード例 #12
0
        public ContentResult OrderConfirmationPath(string companyId, string orderConfirmation)
        {
            string filePath  = "";
            string sessionId = "";
            Axapta axDB1     = new Axapta();

            System.Net.NetworkCredential ncDB1 = new System.Net.NetworkCredential("EP_AX2012", "VendTable1", "RIWAL01");
            axDB1.LogonAs(ConfigurationManager.AppSettings["User"], ConfigurationManager.AppSettings["Domain"], ncDB1, companyId, ConfigurationManager.AppSettings["Language"], ConfigurationManager.AppSettings["AOS"], "");
            sessionId = axDB1.CallStaticClassMethod("LNIDocuAction", "SessionId").ToString();
            System.IO.File.Delete(@"\\Lasernet2\OUT\Batch\" + sessionId + "_" + companyId + "_Confirmation_AX40_DB1_Live.pdf");
            filePath = axDB1.CallStaticClassMethod("LNIDocuAction", "PrintDocumentExternal_Confirm", orderConfirmation).ToString();
            axDB1.Logoff();
            return(Content(filePath));
        }
コード例 #13
0
ファイル: Revervation.cs プロジェクト: Osama91/CCWFM
        public void DeleteReservationOrder(Tbl_ReservationHeader reservationHeader, int userIserial)
        {
            var axapta = new Axapta();//Ready To be Dependent from Ax

            if (SharedOperation.UseAx())
            {
                var         credential = new NetworkCredential("bcproxy", "around1");
                TblAuthUser userToLogin;
                using (var model = new WorkFlowManagerDBEntities())
                {
                    userToLogin = model.TblAuthUsers.SingleOrDefault(x => x.Iserial == userIserial);
                }
                axapta.LogonAs(userToLogin.User_Win_Login, userToLogin.User_Domain, credential, "Ccm", null, null, null);
            }
            using (var entities = new WorkFlowManagerDBEntities())
            {
                var headerRow =
                    entities.Tbl_ReservationHeader.SingleOrDefault(x => x.Iserial == reservationHeader.Iserial);
                var rows = entities.Tbl_ReservationMainDetails.Include("Tbl_ReservationDetails").Include("Tbl_ReservationHeader1").Where(x => x.Tbl_ReservationHeader == reservationHeader.Iserial);

                foreach (var mainRow in rows)
                {
                    foreach (var detailsRow in mainRow.Tbl_ReservationDetails.ToList())
                    {
                        entities.DeleteObject(detailsRow);
                        if (SharedOperation.UseAx())
                        {
                            var importNew = axapta.CreateAxaptaObject("CreateProductionJournals");

                            if (detailsRow.AxPicklingListJournal != null)
                            {
                                importNew.Call("deletejournal", 0, detailsRow.AxPicklingListJournal, 0);
                            }
                        }
                    }
                    entities.DeleteObject(mainRow);
                }

                entities.DeleteObject(headerRow);
                entities.SaveChanges();
            }
            if (SharedOperation.UseAx())
            {
                axapta.Logoff();
            }
        }
コード例 #14
0
        private void DeleteAXroute(RouteCardHeader header)
        {
            var deleteOrReverse = 0;

            if (header.IsPosted == true)
            {
                deleteOrReverse = 1;
            }

            using (var axapta = new Axapta())
            {
                var credential = new NetworkCredential("bcproxy", "around1");
                axapta.LogonAs("osama.gamal", "ccasual.loc", credential, "ccm", null, null, null);

                var import = axapta.CreateAxaptaObject("CreateProductionJournals");

                string journal = null;
                switch (header.RouteType)
                {
                case 3:
                    journal = header.AxReportAsAFinishedJournalId;
                    break;

                case 5:
                    journal = header.AxRouteCardJournalId;
                    break;

                case 0:
                    journal = header.AxRouteCardFabricsJournalId;
                    break;
                }

                if (journal != null)
                {
                    import.Call("deletejournal", header.RouteType, journal, deleteOrReverse);
                }
                if (header.AxRouteCardFabricsJournalId != null)
                {
                    import.Call("deletejournal", 0, header.AxRouteCardFabricsJournalId, deleteOrReverse);
                }
                axapta.Logoff();
            }
        }
コード例 #15
0
ファイル: PurchaseOrderRequest.cs プロジェクト: Osama91/CCWFM
        private void CreatePackingSlip(string packingSlipId, string purchId, string transactionGuid, int userIserial)
        {
            var         axapta     = new Axapta();
            var         credential = new NetworkCredential("bcproxy", "around1");
            TblAuthUser userToLogin;

            using (var model = new WorkFlowManagerDBEntities())
            {
                userToLogin = model.TblAuthUsers.SingleOrDefault(x => x.Iserial == userIserial);
            }
            if (userToLogin != null)
            {
                axapta.LogonAs(userToLogin.User_Win_Login, userToLogin.User_Domain, credential, "Ccm", null, null, null);
            }

            var importNew = axapta.CreateAxaptaObject("CreateProductionJournals");

            importNew.Call("PostPurchFormLetter", packingSlipId, purchId, transactionGuid);

            axapta.Logoff();
        }
コード例 #16
0
        public ActionResult CreateTransfer(Transfer transfer)
        {
            try
            {
                Axapta axDB1 = new Axapta();
                System.Net.NetworkCredential ncDB1 = new System.Net.NetworkCredential("EP_AX2012", "VendTable1", "RIWAL01");
                axDB1.LogonAs(ConfigurationManager.AppSettings["User"], ConfigurationManager.AppSettings["Domain"], ncDB1, transfer.DataAreaId, ConfigurationManager.AppSettings["Language"], ConfigurationManager.AppSettings["AOS"], "");

                axDB1.TTSBegin();
                AxaptaRecord transferRequest = axDB1.CreateAxaptaRecord("A4URequests");
                transferRequest.Call("InitValue");
                if (!string.IsNullOrWhiteSpace(transfer.ContactPersonId))
                {
                    transferRequest.set_Field("ContactPersonId", transfer.ContactPersonId);
                }
                transferRequest.set_Field("CustAccount", transfer.CustAccount);
                if (!string.IsNullOrWhiteSpace(transfer.TransferFromContactPersonid))
                {
                    transferRequest.set_Field("TransferFromContactPersonId", transfer.TransferFromContactPersonid);
                }
                transferRequest.set_Field("TransferFromCustAccount", transfer.TransferFromCustAccount);
                transferRequest.set_Field("Type", (Int32)RequestTypes.Transfer);
                transferRequest.set_Field("Status", (Int32)TransferStates.Requested);
                transferRequest.set_Field("TransferfromInventTransId", transfer.TransferfromInventTransId);
                transferRequest.set_Field("DateOnHire", transfer.DateOnHire);
                transferRequest.set_Field("UserId", transfer.UserId);
                transferRequest.set_Field("TransferFromUserId", transfer.TransferFromUserId);
                transferRequest.set_Field("TransferFromSalesName", transfer.TransferFromSalesName);
                transferRequest.set_Field("SalesName", transfer.SalesName);
                transferRequest.Insert();
                axDB1.TTSCommit();
                axDB1.Logoff();
                axDB1.Dispose();
                return(Content("true"));
            }
            catch
            {
                return(Content("false"));
            }
        }
コード例 #17
0
        public List <IntershopWebService.SizeStock> getItemDims(string itemId, string company)
        {
            List <IntershopWebService.SizeStock> sizeStockList = new List <IntershopWebService.SizeStock>();
            Axapta axapta = (Axapta)null;

            try
            {
                axapta = this.axLogon(company);
                string       str          = "select * from %1 where %1.ItemId == '" + itemId + "'";
                AxaptaRecord axaptaRecord = axapta.CreateAxaptaRecord("InventSize");
                axaptaRecord.ExecuteStmt(str);
                while (axaptaRecord.Found)
                {
                    IntershopWebService.SizeStock sizeStock = new IntershopWebService.SizeStock();
                    if (Convert.ToBoolean(axaptaRecord.get_Field("Color")))
                    {
                        sizeStock.color = Convert.ToString(axaptaRecord.get_Field("InventSizeId"));
                    }
                    else
                    {
                        sizeStock.size = Convert.ToString(axaptaRecord.get_Field("InventSizeId"));
                    }
                    sizeStockList.Add(sizeStock);
                    axaptaRecord.Next();
                }
                return(sizeStockList);
            }
            catch (Exception ex)
            {
                MessageLogger.info(string.Format("getItemDims(itemId={0}, company={1} -> error: {2})", itemId, company, ex.Message));
                return((List <IntershopWebService.SizeStock>)null);
            }
            finally
            {
                axapta.Logoff();
            }
        }
コード例 #18
0
        public string GetItemStockSize(string itemId, string size, string company)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            Axapta axapta = (Axapta)null;

            try
            {
                axapta = this.axLogon(company);
                object obj = axapta.CallStaticClassMethod("BTX_ISHItemDescriptionProxy", "GetOnHandUrl", (object)itemId, (object)size);
                stopwatch.Stop();
                MessageLogger.info(string.Format("GetItemStock({0}, {1}, {2}) -> {3} , exec time -> {5} ms", (object)itemId, (object)size, (object)company, (object)Convert.ToString(obj), (object)stopwatch.ElapsedMilliseconds));
                return(Convert.ToString(obj));
            }
            catch (Exception ex)
            {
                return("An error occured: " + ex.Message);
            }
            finally
            {
                axapta.Logoff();
            }
        }
コード例 #19
0
        public List <IntershopWebService.ProductPrice> GetItemsPriceSize(List <IntershopWebService.ProductPriceIn> products, string company, string customerID)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            Axapta ax = null;

            if (products.Count == 1)
            {
                MessageLogger.info(string.Format("GetItemsPriceSize(itemId={0}, custaccount={1}, company={2})", products[0].itemId, customerID, company));
            }
            else
            {
                MessageLogger.info(string.Format("GetItemsPriceSize(count={0}, custaccount={1}, company={2})", (object)products.Count, (object)customerID, (object)company));
            }

            try
            {
                ax = this.axLogon(company);
                List <IntershopWebService.ProductPrice> productPriceList = new List <IntershopWebService.ProductPrice>();
                foreach (IntershopWebService.ProductPriceIn product in products)
                {
                    IntershopWebService.ProductPriceIn productIn    = product;
                    IntershopWebService.ProductPrice   productPrice = new IntershopWebService.ProductPrice();
                    productPrice.itemId = productIn.itemId;
                    string inventSizeId = string.Empty;
                    productIn.size  = this.normalizeXmlString(productIn.size);
                    productIn.color = this.normalizeXmlString(productIn.color);
                    List <IntershopWebService.SizeStock> itemDims = this.getItemDims(productIn.itemId, company);
                    if (itemDims.Count > 0 && (!string.IsNullOrEmpty(productIn.size) || !string.IsNullOrEmpty(productIn.color)))
                    {
                        if (itemDims.FindIndex((Predicate <IntershopWebService.SizeStock>)(f => f.size == productIn.size)) >= 0)
                        {
                            inventSizeId = productIn.size;
                        }
                        if (itemDims.FindIndex((Predicate <IntershopWebService.SizeStock>)(f => f.color == productIn.color)) >= 0)
                        {
                            inventSizeId = productIn.color;
                        }
                    }
                    double salesPrice;
                    string priceTypeStr;
                    this.ExtractPriceValues((AxaptaContainer)ax.CallStaticClassMethod("BTX_ISHItemDescriptionProxy", "GetPriceType", new object[4]
                    {
                        (object)customerID,
                        (object)productIn.itemId,
                        (object)productIn.unitId,
                        (object)inventSizeId
                    }), out salesPrice, out priceTypeStr);
                    productPrice.price       = salesPrice;
                    productPrice.priceType   = priceTypeStr;
                    productPrice.miscCharges = this.ExtractMiscCharges(ax, productPrice.itemId, customerID, productPrice.price, 1, inventSizeId, productIn.unitId);
                    stopwatch.Stop();
                    MessageLogger.info(string.Format("GetItemsPriceSize({0}, {1}, {2}, {3}, {4}) -> {5}, exec time -> {6} ms", (object)productIn.itemId, (object)productIn.size, (object)productIn.color, (object)customerID, (object)company, (object)productPrice.price, (object)stopwatch.ElapsedMilliseconds));
                    productPriceList.Add(productPrice);
                }
                return(productPriceList);
            }
            catch (Exception ex)
            {
                if (products.Count == 1)
                {
                    MessageLogger.info(string.Format("GetItemsPriceSize(itemId={0}, custaccount={1}, company={2}) -> error: {3}", products[0].itemId, customerID, company, ex.Message));
                }
                else
                {
                    MessageLogger.info(string.Format("GetItemsPriceSize(count={0}, custaccount={1}, company={2}) -> error: {3}", products.Count, customerID, company, ex.Message));
                }

                MessageLogger.info(string.Format("Stack trace: {0}", ex.StackTrace.ToString()));

                return((List <IntershopWebService.ProductPrice>)null);
            }
            finally
            {
                ax.Logoff();
            }
        }
コード例 #20
0
        private void PostReportAsAFinish(int transId, int journalType, int routeCardHeaderIserial, int postPostOrNo)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                var routeCardHeaderRow = context
                                         .RouteCardHeaders.SingleOrDefault(x => x.Iserial == routeCardHeaderIserial);

                var chainSetupList = context.tblChainSetups.Where(x => x.sGridHeaderEName == "Route Card").ToList();

                var routeCardDetailList = context.RouteCardDetails.Where(x => x.RoutGroupID == routeCardHeaderRow.RoutGroupID &&
                                                                         x.Trans_TransactionHeader == transId && x.Direction == routeCardHeaderRow.Direction).ToList();
                var axapta     = new Axapta();
                var credential = new NetworkCredential("bcproxy", "around1");
                axapta.LogonAs("osama.gamal", "ccasual.loc", credential, "ccm", null, null, null);
                const string tableName = "AutoRoute";
                AxaptaRecord salesRecord = axapta.CreateAxaptaRecord("SalesLine"), invent = axapta.CreateAxaptaRecord("InventDim");

                int i = 0;
                try
                {
                    if (routeCardDetailList.Count > 0)
                    {
                        foreach (var item in routeCardDetailList)
                        {
                            string warehouse = null;
                            if (item.Degree == "1st")
                            {
                                warehouse = chainSetupList.SingleOrDefault(x => x.sGlobalSettingCode == "DefaultFPWarehouse1st").sSetupValue;
                            }
                            else if (item.Degree == "2nd")
                            {
                                warehouse = chainSetupList.SingleOrDefault(x => x.sGlobalSettingCode == "DefaultFPWarehouse2st").sSetupValue;
                            }
                            else if (item.Degree == "3rd")
                            {
                                warehouse = chainSetupList.SingleOrDefault(x => x.sGlobalSettingCode == "DefaultFPWarehouse3rd").sSetupValue;
                            }

                            var site = context.GetLocations.Where(x => x.INVENTLOCATIONID == warehouse).Select(x => x.INVENTSITEID).FirstOrDefault();

                            #region MyRegion

                            axapta.ExecuteStmt("select * from %1 "
                                               + "JOIN %2"
                                               + " where %1.InventDimId == %2.InventDimId"
                                               + " && %2.ConfigID =='" + item.Color + "'"
                                               + " && %1.SalesId == '" + item.SalesOrder + "'", salesRecord, invent);
                            var inventDim = salesRecord.get_Field("InventDimID").ToString();

                            #endregion MyRegion

                            var axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                            axaptaRecord.Clear();
                            axaptaRecord.InitValue();

                            axaptaRecord.set_Field("TransId", routeCardHeaderRow.Iserial);
                            if (item.Style != null)
                            {
                                axaptaRecord.set_Field("ItemID", item.Style);
                            }
                            if (item.SalesOrder != null)
                            {
                                axaptaRecord.set_Field("SalesId", item.SalesOrder);
                            }
                            if (item.Color != null)
                            {
                                axaptaRecord.set_Field("Colour", item.Color);
                            }
                            //  AxaptaRecord.set_Field("Machine", _WorkStationID);
                            if (item.SizeQuantity != null)
                            {
                                axaptaRecord.set_Field("Qty", Convert.ToDecimal(item.SizeQuantity));
                            }
                            //   AxaptaRecord.set_Field("Operation", _OperationID);
                            if (routeCardHeaderRow.DocDate != null)
                            {
                                axaptaRecord.set_Field("DocDate", routeCardHeaderRow.DocDate);
                            }
                            if (warehouse != null)
                            {
                                axaptaRecord.set_Field("WhareHouse", warehouse);
                            }
                            if (warehouse != null)
                            {
                                axaptaRecord.set_Field("Location", warehouse);
                            }
                            if (site != null)
                            {
                                axaptaRecord.set_Field("Site", site);
                            }
                            axaptaRecord.set_Field("InventDimID", inventDim);
                            axaptaRecord.set_Field("JournalType", journalType);
                            axaptaRecord.set_Field("BatchId", "N/a");
                            if (item.Size != null)
                            {
                                axaptaRecord.set_Field("SreialId", item.Size);
                            }

                            if (i < 3)
                            {
                                i++;
                            }
                            axaptaRecord.Insert();
                        }
                        var import = axapta.CreateAxaptaObject("CreateProductionJournals");

                        var retval = import.Call("CreateReportJournal", routeCardHeaderRow.Iserial, journalType, true, postPostOrNo);

                        if (retval.ToString() == "0")
                        {
                            throw new Exception("Error While Posting To AX");
                        }
                        else
                        {
                            routeCardHeaderRow.AxReportAsAFinishedJournalId = retval.ToString();
                        }

                        ClearAxTable(tableName, axapta);

                        context.SaveChanges();
                    }
                }
                catch (Exception ex)
                {
                    //There was some errors, Abort transaction and Raise error!
                    //Axapta.TTSAbort();
                    throw new Exception(ex.Message);
                }
                finally
                {
                    //Finally logoff the Axapta Session
                    axapta.Logoff();
                }
            }
        }
コード例 #21
0
        private void UpdateAccDetailsInAX(List <tbl_AccessoryAttributesDetails> detailsToUpdate, int userIserial)
        {
            var axapta = new Axapta();//Ready To be Dependent from Ax

            var credential = new NetworkCredential("bcproxy", "around1");

            TblAuthUser userToLogin;

            using (var model = new WorkFlowManagerDBEntities())
            {
                userToLogin = model.TblAuthUsers.SingleOrDefault(x => x.Iserial == userIserial);
            }
            axapta.LogonAs(userToLogin.User_Win_Login, userToLogin.User_Domain, credential, "Ccm", null, null, null);

            foreach (var item in detailsToUpdate.Select(x => x.Configuration).Distinct())
            {
                try
                {
                    var importNew = axapta.CreateAxaptaObject("CreateProductionJournals");
                    importNew.Call("CreateConfig", detailsToUpdate.Select(x => x.Code).FirstOrDefault(), item);
                }
                catch (Exception)
                {
                }
            }

            foreach (var item in detailsToUpdate.Select(x => x.Size).Distinct())
            {
                try
                {
                    var importNew = axapta.CreateAxaptaObject("CreateProductionJournals");
                    importNew.Call("CreateSize", detailsToUpdate.Select(x => x.Code).FirstOrDefault(), item);
                }
                catch (Exception)
                {
                }
                //--------------------------------------------//
                //--------------------------------------------//
                //--------------------------------------------//C:\Users\GDE\Desktop\CCWFM\CCWFM.Web\Service\Operations\AccessoriesOperations.cs
            }

            foreach (var item in detailsToUpdate)
            {
                try
                {
                    const string tableName    = "InventDimCombination";
                    var          axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();

                    axaptaRecord.set_Field("ItemId", item.Code);
                    axaptaRecord.set_Field("InventSizeID", item.Size);
                    axaptaRecord.set_Field("ConfigId", item.Configuration);
                    //Commit the record to the database.
                    axaptaRecord.Insert();
                }
                catch (Exception)
                {
                }
            }

            axapta.Logoff();
        }
コード例 #22
0
        private void PostNewPoToAx(tblNewRFQPurchaseOrderHeader paramHeaderObjToPost)
        {
            var context         = new WorkFlowManagerDBEntities();
            var headerObjToPost =
                context.tblNewRFQPurchaseOrderHeaders.Include("tblNewRFQPurchLines.tbl_PurchaseOrderSizeDetails")
                .FirstOrDefault(x => x.TransID == paramHeaderObjToPost.TransID);

            var axapta = new Axapta();

            var credential = new NetworkCredential("bcproxy", "around1");

            try
            {
                axapta.LogonAs("ahmed.gamal", "ccasual.loc", credential, "ccr", null, null, null);
            }
            catch (Exception)
            {
                throw new Exception("There was a problem logging to ax");
            }
            try
            {
                axapta.TTSBegin();
                var inventDimTable       = axapta.CreateAxaptaRecord("InventDim");
                var inventColorTable     = axapta.CreateAxaptaRecord("InventColor");
                var inventDimCombination = axapta.CreateAxaptaRecord("InventDimCombination");

                var axaptaRecord = axapta.CreateAxaptaRecord("PurchTable");
                axaptaRecord.Clear();
                axaptaRecord.InitValue();
                var purchId = headerObjToPost.PurchaseID;
                axaptaRecord.set_Field("PurchId", purchId);

                var header =
                    axapta.CallStaticRecordMethod("VendTable", "find", headerObjToPost.Vendor) as AxaptaRecord;
                axaptaRecord.Call("initFromVendTable", header);

                axaptaRecord.Insert();
                context.tbl_PurchaseOrderDetails.MergeOption = MergeOption.NoTracking;
                context.V_Warehouse.MergeOption = MergeOption.NoTracking;
                var detailHeadersFull = headerObjToPost.tblNewRFQPurchLines;

                foreach (var ditem in detailHeadersFull)
                {
                    foreach (var sdItem in ditem.tblNewRFQPurchLineSizes)
                    {
                        var itemId = ditem.StyleCode;

                        axaptaRecord = axapta.CreateAxaptaRecord("PurchLine");
                        axaptaRecord.Clear();
                        axaptaRecord.InitValue();

                        inventDimTable.Clear();
                        inventDimTable.set_Field("InventLocationId", headerObjToPost.WareHouseID);

                        var warehouse =
                            context.V_Warehouse.SingleOrDefault(
                                x => x.DataAreaID == "ccr" && x.WarehouseID == headerObjToPost.WareHouseID);
                        if (warehouse !=
                            null)
                        {
                            inventDimTable.set_Field("InventSiteId", warehouse.SiteId);
                        }

                        inventColorTable.set_Field("ItemID", ditem.StyleCode);
                        inventColorTable.set_Field("InventColorId", ditem.ColorCode);
                        var clr =
                            (bool)
                            axapta.CallStaticRecordMethod("InventColor", "checkExist", ditem.StyleCode, ditem.ColorCode);
                        if (!clr)
                        {
                            inventColorTable.Insert();
                        }
                        else
                        {
                            inventColorTable.Clear();
                        }

                        try
                        {
                            inventDimCombination.set_Field("ItemID", ditem.StyleCode);
                            inventDimCombination.set_Field("InventSizeId", sdItem.Size);
                            inventDimCombination.set_Field("InventColorId", ditem.ColorCode);
                            inventDimCombination.Insert();
                        }
                        catch
                        {
                        }

                        inventDimTable.set_Field("InventColorId", ditem.ColorCode);
                        inventDimTable.set_Field("InventSizeId", sdItem.Size);

                        inventDimTable =
                            axapta.CallStaticRecordMethod("InventDim", "findOrCreate", inventDimTable) as
                            AxaptaRecord;

                        var tempx = inventDimTable.get_Field("inventDimId").ToString();
                        axaptaRecord.set_Field("InventDimId", tempx);

                        if (ditem.DeliveryDate != null)
                        {
                            axaptaRecord.set_Field("DeliveryDate", ditem.DeliveryDate);
                        }

                        axaptaRecord.set_Field("ItemId", itemId);
                        axaptaRecord.set_Field("purchId", purchId);
                        axaptaRecord.set_Field("PurchUnit", "Pcs");
                        axaptaRecord.set_Field("QtyOrdered", Convert.ToDecimal(sdItem.Qty.ToString()));
                        axaptaRecord.set_Field("PurchPrice", Convert.ToDecimal(ditem.PurchasePrice));
                        axaptaRecord.set_Field("PurchQty", Convert.ToDecimal(sdItem.Qty.ToString()));
                        axaptaRecord.set_Field("LineAmount",
                                               Convert.ToDecimal((sdItem.Qty * ditem.PurchasePrice).ToString()));

                        axaptaRecord.Call("createLine", true, true, false, true, true, false);
                    }

                    //TO DO: Add Posting TO Retail Plus Logic Here!

                    //-////////////////////////////////////////////
                    var retailContext = new ccnewEntities();
                    //var retailPoHeader = new TblPOHeader
                    //{
                    //    Code = headerObjToPost.PurchaseID,
                    //    tblstore = headerObjToPost.WareHouseID,
                    //     tblseason = headerObjToPost.tbl_RFQHeader.SeasonCode,

                    //};
                    var retailPoMainDetail = new TblPOMainDetail();
                    var retailPoDetail     = new TblPODetail();

                    axapta.TTSCommit();
                    headerObjToPost.IsPosted = true;
                    context.SaveChanges();
                }
            }
            catch (Exception)
            {
                axapta.TTSAbort();
                throw;
            }
            finally
            {
                axapta.Logoff();
                axapta.Dispose();
            }
        }
コード例 #23
0
        public DataTable GetRespairStageList(string userName)
        {
            DataTable resultTable = new DataTable();
            Axapta ax = null;
            AxaptaRecord axRecord;
            try
            {
                // Login to Microsoft Dynamics AX.
                ax = new Axapta();
                ax.LogonAs(userName.Trim(), "", networkCredentials, axCompany, "", "", "");
                resultTable.Columns.Add("Name", typeof(String));
                resultTable.Columns.Add("RepairStageId", typeof(String));

                using (axRecord = ax.CreateAxaptaRecord("SMARepairStage"))
                {
                    // Execute the query on the table.
                    axRecord.ExecuteStmt("select RepairStageId, Name from %1 where %1.DataAreaID=='" + axCompany + "'");
                    // Loop through the set of retrieved records.
                    while (axRecord.Found)
                    {

                        DataRow row = resultTable.NewRow();
                        row["Name"] = axRecord.get_Field("Name");
                        row["RepairStageId"] = axRecord.get_Field("RepairStageId");

                        resultTable.Rows.Add(row);
                        axRecord.Next();

                    }

                }
            }
            catch (Exception e)
            {
                throw e;
                // Take other error action as needed.
            }
            finally
            {
                if (ax != null) ax.Logoff();
            }
            return resultTable;
        }
コード例 #24
0
        public DataTable GetRepairLines(string serviceOrderId, string userName)
        {
            Axapta ax = null;
            AxaptaRecord axRecord;
            DataTable repairLineTable = new DataTable();

            repairLineTable.Columns.Add("RepServiceOrder", typeof(String));
            repairLineTable.Columns.Add("UniqueId", typeof(String));
            repairLineTable.Columns.Add("SORelationID", typeof(String));
            repairLineTable.Columns.Add("Description", typeof(String));
            repairLineTable.Columns.Add("ConditionId", typeof(String));
            repairLineTable.Columns.Add("SymptomAreaId", typeof(String));
            repairLineTable.Columns.Add("SymptomCodeId", typeof(String));
            repairLineTable.Columns.Add("DiagnosisAreaId", typeof(String));
            repairLineTable.Columns.Add("DiagnosisCodeId", typeof(String));

            repairLineTable.Columns.Add("ResolutionId", typeof(String));
            repairLineTable.Columns.Add("RepairStageId", typeof(String));
            repairLineTable.Columns.Add("TechnicianNo", typeof(String));
            repairLineTable.Columns.Add("TechnicianName", typeof(String));
            repairLineTable.Columns.Add("ServiceComments", typeof(String));

            try
            {

                ax = new Axapta();
                ax.LogonAs(userName.Trim(), "", networkCredentials, axCompany, "", "", "");

                axRecord = (AxaptaRecord)ax.CallStaticClassMethod("ServiceOrderManagement", "getSMARepairLine", serviceOrderId);
                axRecord.ExecuteStmt("select * from %1");

                while (axRecord.Found)
                {
                    DataRow row = repairLineTable.NewRow();
                    row["RepServiceOrder"] = axRecord.get_Field("ServiceOrderId");
                    row["UniqueId"] = axRecord.get_Field("UniqueID");
                    row["SORelationID"] = axRecord.get_Field("ServiceObjectRelationId");

                    row["Description"] = axRecord.get_Field("Description");
                    row["ConditionId"] = axRecord.get_Field("ConditionId");
                    row["SymptomAreaId"] = axRecord.get_Field("SymptomAreaId");
                    row["SymptomCodeId"] = axRecord.get_Field("SymptomCodeId");
                    row["DiagnosisAreaId"] = axRecord.get_Field("DiagnosisAreaId");
                    row["DiagnosisCodeId"] = axRecord.get_Field("DiagnosisCodeId");
                    row["ResolutionId"] = axRecord.get_Field("ResolutionId");
                    row["RepairStageId"] = axRecord.get_Field("RepairStageId");
                    row["TechnicianNo"] = axRecord.get_Field("workernumber");
                    row["TechnicianName"] = axRecord.get_Field("WorkerName");
                    row["ServiceComments"] = axRecord.get_Field("Name");

                    repairLineTable.Rows.Add(row);
                    axRecord.Next();
                }

            }

            catch (Exception e)
            {
                throw e;
                // Take other error action as needed.
            }
            finally
            {
                if (ax != null) ax.Logoff();
            }
            return repairLineTable;
        }
コード例 #25
0
        public DataTable GetDefaultSitesByUsername(string username)
        {
            object objUser, objInventId, objDefault, objSiteName;
            DataTable siteTable = new DataTable();
            Axapta ax = null;
            //string strCurrUserName = username.Split('\\')[1];
            try
            {
                ax = new Axapta();

                siteTable.Columns.Add("User", typeof(String));
                siteTable.Columns.Add("Sites", typeof(String));
                siteTable.Columns.Add("SitesName", typeof(String));
                siteTable.Columns.Add("Default", typeof(String));
                ax.LogonAs(username.Trim(), "", networkCredentials, axCompany, "", "", "");
                AxaptaRecord axRecord;
                axRecord = (AxaptaRecord)ax.CallStaticClassMethod("ServiceOrderManagement", "getSMASitesUser", username);

                axRecord.ExecuteStmt("select * from %1");
                // Loop through the set of retrieved records.

                while (axRecord.Found)
                {
                    objUser = axRecord.get_Field("NetworkAlias");
                    objInventId = axRecord.get_Field("InventSiteId");
                    objDefault = axRecord.get_Field("Default");
                    objSiteName = axRecord.get_Field("Name");
                    DataRow row = siteTable.NewRow();

                    row["User"] = objUser.ToString();
                    row["Sites"] = objInventId.ToString();
                    row["Default"] = objDefault.ToString();
                    row["SitesName"] = objSiteName.ToString();
                    siteTable.Rows.Add(row);

                    axRecord.Next();

                }
            }
            catch (Exception e)
            {
                throw e;
                // Take other error action as needed.
            }
            finally
            {
                if (ax != null) ax.Logoff();
            }

            return siteTable;
        }
コード例 #26
0
        //orderstatus - 0: Inprocess; 1-Posted; 2-Cancelled; -1: All
        public DataTable GetServiceOrders(string inventSiteId, string orderStatus, string serviceOrder, string userName)
        {
            Axapta ax = null;
            AxaptaRecord axRecord;
            DataTable serviceTable = new DataTable();
            serviceTable.Columns.Add("ServiceorderId", typeof(String));
            serviceTable.Columns.Add("CustAccount", typeof(String));
            serviceTable.Columns.Add("CustomerPO", typeof(String));
            serviceTable.Columns.Add("CustomerName", typeof(String));
            serviceTable.Columns.Add("Description", typeof(String));
            serviceTable.Columns.Add("Status", typeof(String));
            serviceTable.Columns.Add("WOClassification", typeof(String));
            serviceTable.Columns.Add("ServiceTechnician", typeof(String));
            serviceTable.Columns.Add("ServiceTechnicianNo", typeof(String));
            serviceTable.Columns.Add("ServiceResponsible", typeof(String));
            serviceTable.Columns.Add("BillingAddress", typeof(String));
            serviceTable.Columns.Add("ShippingAddress", typeof(String));
            serviceTable.Columns.Add("EntryDate", typeof(DateTime));
            try
            {

                ax = new Axapta();
                ax.LogonAs(userName.Trim(), "", networkCredentials, axCompany, "", "", "");

                axRecord = (AxaptaRecord)ax.CallStaticClassMethod("ServiceOrderManagement", "getSMAServiceOrders", inventSiteId, orderStatus, serviceOrder);
                    axRecord.ExecuteStmt("select * from %1 order by %1.DateEntry desc");

                    while (axRecord.Found)
                    {
                        DataRow row = serviceTable.NewRow();
                        row["ServiceorderId"] = axRecord.get_Field("ServiceOrderId");
                        row["CustAccount"] = axRecord.get_Field("CustomerAccount");
                        row["CustomerPO"] = axRecord.get_Field("CustomerPO");
                        row["CustomerName"] = axRecord.get_Field("CustomerName");
                        row["Description"] = axRecord.get_Field("CustomerComments");
                        row["Status"] = axRecord.get_Field("Status");
                        row["WOClassification"] = axRecord.get_Field("WOClassification");
                        row["ServiceTechnician"] = axRecord.get_Field("ServiceTechnician");
                        row["ServiceTechnicianNo"] = axRecord.get_Field("TechnicianNumber");
                        row["ServiceResponsible"] = axRecord.get_Field("ServiceResponsible");
                        row["BillingAddress"] = axRecord.get_Field("BillingAddress");
                        row["ShippingAddress"] = axRecord.get_Field("ShippingAddress");
                        row["EntryDate"] = axRecord.get_Field("DateEntry");
                        serviceTable.Rows.Add(row);
                        axRecord.Next();
                    }

            }
            catch (Exception e)
            {
               // Take other error action as needed.
               throw e;
            }
            finally
            {
                if (ax != null) ax.Logoff();
            }
            return serviceTable;
        }
コード例 #27
0
ファイル: PostPOTOAxOperations.cs プロジェクト: Osama91/CCWFM
        public void PostPOWithPurchIDToAx(int purchID)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                var headerObjToPost  = context.tbl_PurchaseOrderHeader.SingleOrDefault(x => x.TransID == purchID);
                var detailsObjToPost = context.v_PurchaseOrderDetailsWithSizes.Where(x => x.Trans_TransactionHeader == purchID).ToList();
                var axapta           = new Axapta();

                var credential = new NetworkCredential("bcproxy", "around1");

                axapta.LogonAs("osama.gamal", "ccasual.loc", credential, "ccr", null, null, null);

                var inventTable = axapta.CreateAxaptaRecord("InventDim");
                //var inventColorTable = axapta.CreateAxaptaRecord("InventColor");
                //var inventSizeTable = axapta.CreateAxaptaRecord("InventSize");

                try
                {
                    //Start Transaction
                    //Axapta.TTSBegin();

                    //string _journalid = "143887_109";
                    var tableName    = "PurchTable";
                    var _PurchID     = "143887_109";
                    var axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();

                    axaptaRecord.set_Field("PurchId", _PurchID);
                    axaptaRecord.set_Field("DeliveryDate", headerObjToPost.DelivaryDate);
                    axaptaRecord.set_Field("PurchId", _PurchID);

                    var header = axapta.CallStaticRecordMethod("VendTable", "find", headerObjToPost.Vendor) as AxaptaRecord;
                    axaptaRecord.Call("initFromVendTable", header);

                    axaptaRecord.Insert();

                    tableName = "PurchLine";
                    foreach (var item in detailsObjToPost)
                    {
                        var styleID = context.StyleHeader_SalesOrder
                                      .Where(x => x.SalesOrderID == item.SalesOrder)
                                      .Select(x => x.StyleHeader).FirstOrDefault().ToString();

                        axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                        axaptaRecord.Clear();
                        axaptaRecord.InitValue();

                        inventTable.Clear();
                        inventTable.set_Field("InventLocationId", headerObjToPost.WareHouseID);
                        inventTable.set_Field("InventColorId", item.Color);
                        inventTable.set_Field("InventSizeId", item.Size);
                        inventTable = axapta.CallStaticRecordMethod("InventDim", "findOrCreate", inventTable) as AxaptaRecord;

                        var tempx = inventTable.get_Field("inventDimId").ToString();
                        axaptaRecord.set_Field("InventDimId", tempx);

                        axaptaRecord.set_Field("ItemId", styleID);
                        axaptaRecord.set_Field("purchId", _PurchID);
                        axaptaRecord.set_Field("QtyOrdered", Convert.ToDecimal(item.TotalQty.ToString()));
                        axaptaRecord.set_Field("PurchPrice", item.PurchasePrice);
                        axaptaRecord.set_Field("PurchQty", Convert.ToDecimal(item.TotalQty.ToString()));
                        axaptaRecord.set_Field("LineAmount", Convert.ToDecimal(item.TotalQty.ToString()));
                        axaptaRecord.Call("createLine", true, true, true, true, true, true);
                    }
                    //No errors occured, Commit!
                    //Axapta.TTSCommit();
                }
                catch (Exception ex)
                {
                    //There was some errors, Abort transaction and Raise error!
                    //Axapta.TTSAbort();
                    throw new Exception(ex.Message);
                }
                finally
                {
                    //Finally logoff the Axapta Session
                    axapta.Logoff();
                }
            }
        }
コード例 #28
0
        public void PurchaseDyeingServicesToAxAcc(TblDyeingOrdersHeaderAcc objToPost, TblDyeingOrdersMainDetailsACC headerObjToPost, int postPostOrNo, int userIserial, string transactionGuid)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                using (var axapta = new Axapta())
                {
                    var credential = new NetworkCredential("bcproxy", "around1");

                    TblAuthUser userToLogin;

                    userToLogin = context.TblAuthUsers.SingleOrDefault(x => x.Iserial == userIserial);

                    axapta.LogonAs(userToLogin.User_Win_Login, userToLogin.User_Domain, credential, "Ccm", null, null, null);

                    var inventTable = axapta.CreateAxaptaRecord("InventDim");

                    try
                    {
                        var vendorWmsLocation = context.GetWmsLocations.SingleOrDefault(x => x.VENDID == objToPost.Vendor);

                        var vendorLoc =
                            context.GetLocations.SingleOrDefault(x => x.INVENTLOCATIONID == vendorWmsLocation.INVENTLOCATIONID);
                        var purchId          = "Rc_ " + headerObjToPost.DyeingProductionOrder.ToString() + headerObjToPost.TransId.ToString() + headerObjToPost.TransactionType;
                        var tableName        = "PurchTable";
                        var purchTableRecord = axapta.CreateAxaptaRecord(tableName);
                        purchTableRecord.Clear();
                        purchTableRecord.InitValue();

                        purchTableRecord.set_Field("PurchId", purchId);
                        purchTableRecord.set_Field("DeliveryDate", headerObjToPost.TblDyeingOrdersDetailsAccs.OrderByDescending(x => x.EstimatedDeliveryDate).FirstOrDefault().EstimatedDeliveryDate ?? DateTime.Now);

                        var headerax = axapta.CallStaticRecordMethod("VendTable", "find", objToPost.Vendor) as AxaptaRecord;
                        purchTableRecord.Call("initFromVendTable", headerax);

                        purchTableRecord.Insert();

                        foreach (var item in headerObjToPost.TblDyeingOrdersDetailsAccs)
                        {
                            tableName = "PurchLine";
                            foreach (var servicerow in item.DyeingOrderDetailsServicesAccs)
                            {
                                var axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                                axaptaRecord.Clear();
                                axaptaRecord.InitValue();

                                inventTable.Clear();
                                inventTable.set_Field("InventLocationId", vendorLoc.INVENTLOCATIONID);
                                if (item.Color != null)
                                {
                                    inventTable.set_Field("InventColorId", item.Color);
                                }

                                var importNew        = axapta.CreateAxaptaObject("CreateProductionJournals");
                                var producationOrder = "Free";
                                using (var model = new ax2009_ccEntities())
                                {
                                    //  var batch = item.BatchNo.ToString();

                                    var firstOrDefault = model.PRODCONNECTIONs.FirstOrDefault(
                                        x =>
                                        x.DYEDITEM == item.DyedFabric && x.TRANSID == item.DyeingProductionOrder &&
                                        x.FROMCONFIG == item.Color &&
                                        // x.FROMBATCH == batch &&
                                        x.JOURNALLINKID == item.TransId);
                                    if (firstOrDefault != null)
                                    {
                                        producationOrder =
                                            firstOrDefault.PRODID;
                                    }
                                }
                                if (producationOrder == null || producationOrder == "")
                                {
                                    producationOrder = "Free";
                                }

                                importNew.Call("CreateConfig", servicerow.ServiceCode, item.Color);
                                importNew.Call("CreateBatch", servicerow.ServiceCode, producationOrder);
                                inventTable.set_Field("configId", item.Color);
                                inventTable.set_Field("inventBatchId", producationOrder);
                                inventTable = axapta.CallStaticRecordMethod("InventDim", "findOrCreate", inventTable) as AxaptaRecord;

                                if (inventTable != null)
                                {
                                    var tempx = inventTable.get_Field("inventDimId").ToString();
                                    axaptaRecord.set_Field("InventDimId", tempx);
                                }

                                axaptaRecord.set_Field("ItemId", servicerow.ServiceCode);
                                axaptaRecord.set_Field("purchId", purchId);
                                axaptaRecord.set_Field("QtyOrdered", Convert.ToDecimal(item.CalculatedTotalQty.ToString()));
                                decimal price = 1;

                                //context.TblTradeAgreementDetails.Where(x => x.ItemCode == servicerow.ServiceCode && x.TblTradeAgreementHeader1.Vendor == objToPost.Vendor);
                                axaptaRecord.set_Field("PurchPrice", Convert.ToDecimal(price));
                                axaptaRecord.set_Field("PurchQty", Convert.ToDecimal(item.CalculatedTotalQty.ToString()));
                                axaptaRecord.set_Field("LineAmount", Convert.ToDecimal(item.CalculatedTotalQty.ToString()) * price);
                                axaptaRecord.Call("createLine", true, true, true, true, true, false);
                            }
                            //No errors occured, Commit!
                            //Axapta.TTSCommit();

                            if (postPostOrNo == 1)
                            {
                                var importNew = axapta.CreateAxaptaObject("CreateProductionJournals");
                                importNew.Call("PostPurchaseOrder", purchId, objToPost.TransactionDate ?? DateTime.Now);
                                PickingListForAxServicesAcc(objToPost, headerObjToPost, postPostOrNo, userIserial,
                                                            transactionGuid);
                            }
                        }
                    }

                    catch (Exception ex)
                    {
                        //There was some errors, Abort transaction and Raise error!
                        //Axapta.TTSAbort();
                        throw new Exception(ex.Message);
                    }
                    finally
                    {
                        //Finally logoff the Axapta Session
                        axapta.Logoff();
                    }
                }
            }
        }
コード例 #29
0
ファイル: IssueJournal.cs プロジェクト: Osama91/CCWFM
        private void IssueJournalTransfer(TblIssueJournalHeader row, int userIserial)
        {
            using (var entities = new WorkFlowManagerDBEntities())
            {
                if (SharedOperation.UseAx())
                {
                    var          transactionGuid   = Guid.NewGuid().ToString();
                    var          vendorWmsLocation = entities.GetWmsLocations.SingleOrDefault(x => x.VENDID == row.Vendor);
                    const string tableName         = "PRODCONNECTION";
                    var          vendorLoc         = entities.GetLocations.SingleOrDefault(x => x.INVENTLOCATIONID == vendorWmsLocation.INVENTLOCATIONID);
                    var          axapta            = new Axapta();
                    var          credential        = new NetworkCredential("bcproxy", "around1");
                    var          detail            = entities.TblIssueJournalDetails.Where(w => w.TblIssueJournalHeader == row.Iserial).ToList();

                    var userToLogin = entities.TblAuthUsers.SingleOrDefault(x => x.Iserial == userIserial);
                    axapta.LogonAs(userToLogin.User_Win_Login, userToLogin.User_Domain, credential, "Ccm", null, null, null);
                    axapta.CallStaticClassMethod("SysFlushAOD", "doFlush");
                    foreach (var item in detail)
                    {
                        var locationLoc = entities.GetLocations.SingleOrDefault(x => x.INVENTLOCATIONID == item.Location);

                        AxaptaRecord AxaptaRecord = axapta.CreateAxaptaRecord(tableName);
                        AxaptaRecord.Clear();
                        AxaptaRecord.InitValue();

                        //Transfer To Vendor's Location
                        var fabriccode = entities.Fabric_UnitID.FirstOrDefault(w => w.Iserial == item.ItemCode);
                        AxaptaRecord.set_Field("TRANSID", row.Iserial);
                        AxaptaRecord.set_Field("RAWID", fabriccode.Fabric_Code);
                        AxaptaRecord.set_Field("RAWQTY", item.Qty);
                        AxaptaRecord.set_Field("UNITID", fabriccode.UnitID);
                        if (locationLoc != null)
                        {
                            AxaptaRecord.set_Field("FROMSITE", locationLoc.INVENTSITEID);
                        }
                        AxaptaRecord.set_Field("FROMLOCATION", item.Location);
                        AxaptaRecord.set_Field("FROMWAREHOUSE", item.Location);
                        AxaptaRecord.set_Field("FROMBATCH", item.Size ?? "Free");
                        AxaptaRecord.set_Field("FROMCONFIG",
                                               entities.TblColors.FirstOrDefault(x => x.Iserial == item.TblColor).Code);
                        if (vendorLoc != null)
                        {
                            AxaptaRecord.set_Field("TOSITE", vendorLoc.INVENTSITEID);
                        }
                        if (vendorWmsLocation != null)
                        {
                            AxaptaRecord.set_Field("TOLOCATION", vendorWmsLocation.WMSLOCATIONID);
                            AxaptaRecord.set_Field("TOWAREHOUSE", vendorWmsLocation.INVENTLOCATIONID);
                        }
                        AxaptaRecord.set_Field("TOBATCH", item.Size ?? item.BatchNo ?? "Free");
                        AxaptaRecord.set_Field("TOCONFIG",
                                               entities.TblColors.FirstOrDefault(x => x.Iserial == item.TblColor).Code);
                        AxaptaRecord.set_Field("TRANSTYPE", Convert.ToInt64(0));
                        AxaptaRecord.set_Field("JOURNALLINKID", row.Iserial);
                        AxaptaRecord.set_Field("TransactionGuid", transactionGuid);
                        AxaptaRecord.Insert();
                    }
                    var import = axapta.CreateAxaptaObject("CLEDyeProcesse");
                    try
                    {
                        var transfer = import.Call("run", row.Iserial, row.Iserial, 0, "Name", 1, DateTime.UtcNow.ToUniversalTime());
                        row.AxTransaction = transfer.ToString();
                        row.IsPosted      = true;
                        entities.SaveChanges();
                    }
                    catch (Exception)
                    {
                        throw;
                    }

                    SharedOperation.ClearAxTable("PRODCONNECTION", axapta, transactionGuid);
                    axapta.Logoff();
                }
                else
                {
                    row.AxTransaction = "1111";
                    row.IsPosted      = true;
                    entities.SaveChanges();
                }
            }
        }
コード例 #30
0
        public void PostRoutCardToAx(int routeCardHeaderIserial, int postPostOrNo) // posted=1
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                //int _TransID, string _WorkStationID, string _OperationID, int JournalType
                var routeHeaderRow = context
                                     .RouteCardHeaders.SingleOrDefault(x => x.Iserial == routeCardHeaderIserial);

                var operation = context.WF_RouteGroup.Where(x => x.iSerial == routeHeaderRow.RoutGroupID).Select(x => x.Code).SingleOrDefault();

                var workStation = context.WF_Route.Where(x => x.iSerial == routeHeaderRow.RoutID).Select(x => x.Code).SingleOrDefault();

                var detailsObjToPost = context
                                       .RealRoutCards
                                       .Where(x => x.TransID == routeHeaderRow.TransID &&
                                              x.Operation == operation &&
                                              x.WorkStation == workStation).ToList();

                var axapta     = new Axapta();
                var credential = new NetworkCredential("bcproxy", "around1");
                axapta.LogonAs("osama.gamal", "ccasual.loc", credential, "ccm", null, null, null);

                AxaptaRecord salesRecord = axapta.CreateAxaptaRecord("SalesLine"), invent = axapta.CreateAxaptaRecord("InventDim");

                const string tableName = "AutoRoute";
                //List<string> _TempinventDimIDList = new List<string>();
                //_TempinventDimIDList.Add("00008851_086");
                //_TempinventDimIDList.Add("00012748_086");
                //_TempinventDimIDList.Add("00008851_086");
                bool posted = false;

                try
                {
                    if (detailsObjToPost.Count > 0)
                    {
                        foreach (var item in detailsObjToPost)
                        {
                            axapta.ExecuteStmt("select * from %1 "
                                               + "JOIN %2"
                                               + " where %1.InventDimId == %2.InventDimId"
                                               + " && %2.ConfigID =='" + item.Color + "'"
                                               + " && %1.SalesId == '" + item.SalesOrder + "'", salesRecord, invent);
                            var inventDim = salesRecord.get_Field("InventDimID").ToString();

                            var axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                            axaptaRecord.Clear();
                            axaptaRecord.InitValue();

                            axaptaRecord.set_Field("TransId", routeCardHeaderIserial);
                            if (item.StyleHeader != null)
                            {
                                axaptaRecord.set_Field("ItemID", item.StyleHeader);
                            }
                            if (item.SalesOrder != null)
                            {
                                axaptaRecord.set_Field("SalesId", item.SalesOrder);
                            }
                            if (item.Color != null)
                            {
                                axaptaRecord.set_Field("Colour", item.Color);
                            }
                            if (item.WorkStation != null)
                            {
                                axaptaRecord.set_Field("Machine", item.WorkStation);
                            }
                            if (item.Qty != null)
                            {
                                axaptaRecord.set_Field("Qty", Convert.ToDecimal(item.Qty.ToString()));
                            }
                            if (item.Operation != null)
                            {
                                axaptaRecord.set_Field("Operation", item.Operation);
                            }
                            if (item.DocDate != null)
                            {
                                axaptaRecord.set_Field("DocDate", item.DocDate);
                            }
                            axaptaRecord.set_Field("WhareHouse", "");
                            axaptaRecord.set_Field("Site", "");
                            if (inventDim != null)
                            {
                                axaptaRecord.set_Field("InventDimID", inventDim);
                            }
                            axaptaRecord.set_Field("JournalType", 5);
                            if ((routeHeaderRow.RouteType == 5))
                            {
                                axaptaRecord.set_Field("BatchId", "1");
                                axaptaRecord.set_Field("JournalType", 5);
                            }

                            axaptaRecord.Insert();
                        }
                        var import = axapta.CreateAxaptaObject("CreateProductionJournals");

                        var retval = import.Call("CreateRouteJournal", routeCardHeaderIserial, workStation, operation, 5, postPostOrNo);

                        if (retval.ToString() == "0")
                        {
                            throw new Exception("Error While Posting To AX");
                        }
                        else
                        {
                            routeHeaderRow.AxRouteCardJournalId = retval.ToString();

                            if (postPostOrNo == 1)
                            {
                                posted = true;
                            }
                            routeHeaderRow.IsPosted = posted;
                        }

                        ClearAxTable(tableName, axapta);

                        context.SaveChanges();
                    }
                }
                catch (Exception ex)
                {
                    //There was some errors, Abort transaction and Raise error!
                    //Axapta.TTSAbort();
                    throw new Exception(ex.Message);
                }
                finally
                {
                    //Finally logoff the Axapta Session
                    axapta.Logoff();
                }

                if (routeHeaderRow.RouteType == 3) // Report AS a Finish
                {
                    PostReportAsAFinish(routeHeaderRow.TransID, 3, routeCardHeaderIserial, postPostOrNo);
                }

                if (routeHeaderRow.Direction == 0)
                {
                    PurchaseRouteServicesToAx(routeHeaderRow, postPostOrNo);
                }

                PickingList(routeCardHeaderIserial, postPostOrNo);
            }
        }
コード例 #31
0
        public void PurchaseRouteServicesToAx(RouteCardHeader headerObjToPost, int postPostOrNo)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                var detailsObjToPost = context.RouteCardFabrics.Where(x => x.RouteCardHeaderIserial == headerObjToPost.Iserial);

                using (var axapta = new Axapta())
                {
                    var credential = new NetworkCredential("bcproxy", "around1");

                    axapta.LogonAs("osama.gamal", "ccasual.loc", credential, "ccm", null, null, null);

                    var inventTable = axapta.CreateAxaptaRecord("InventDim");
                    try
                    {
                        var purchId          = "Rc_ " + headerObjToPost.Iserial.ToString();
                        var tableName        = "PurchTable";
                        var purchTableRecord = axapta.CreateAxaptaRecord(tableName);
                        purchTableRecord.Clear();
                        purchTableRecord.InitValue();

                        purchTableRecord.set_Field("PurchId", purchId);
                        purchTableRecord.set_Field("DeliveryDate", headerObjToPost.DeliveryDate);
                        //   axaptaRecord.set_Field("PurchId", _PurchID);

                        var header = axapta.CallStaticRecordMethod("VendTable", "find", headerObjToPost.Vendor) as AxaptaRecord;
                        purchTableRecord.Call("initFromVendTable", header);

                        purchTableRecord.Insert();

                        tableName = "PurchLine";
                        foreach (var item in detailsObjToPost)
                        {
                            var axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                            axaptaRecord.Clear();
                            axaptaRecord.InitValue();

                            inventTable.Clear();
                            inventTable.set_Field("InventLocationId", item.Warehouse);
                            if (item.FabricColor != null)
                            {
                                inventTable.set_Field("InventColorId", item.FabricColor);
                            }
                            if (item.Size != null)
                            {
                                inventTable.set_Field("InventSizeId", item.Size);
                            }

                            var importNew        = axapta.CreateAxaptaObject("CreateProductionJournals");
                            var producationOrder = importNew.Call("GetProdIdFromSalesorderAndColor", item.Style, item.StyleColor, item.SalesOrder);

                            if (producationOrder == null || (string)producationOrder == "")
                            {
                                producationOrder = "Free";
                            }

                            var config = importNew.Call("CreateConfig", item.ItemId, "Free");
                            var batch  = importNew.Call("CreateBatch", item.ItemId, producationOrder);
                            inventTable.set_Field("configId", "Free");
                            inventTable.set_Field("inventBatchId", producationOrder);
                            inventTable = axapta.CallStaticRecordMethod("InventDim", "findOrCreate", inventTable) as AxaptaRecord;

                            if (inventTable != null)
                            {
                                var tempx = inventTable.get_Field("inventDimId").ToString();
                                axaptaRecord.set_Field("InventDimId", tempx);
                            }

                            axaptaRecord.set_Field("ItemId", item.ItemId);
                            axaptaRecord.set_Field("ItemId", item.ItemId);
                            axaptaRecord.set_Field("purchId", purchId);
                            axaptaRecord.set_Field("QtyOrdered", Convert.ToDecimal(item.Qty.ToString()));
                            //  axaptaRecord.set_Field("PurchPrice", item.Qty);
                            axaptaRecord.set_Field("PurchQty", Convert.ToDecimal(item.Qty.ToString()));
                            axaptaRecord.set_Field("LineAmount", Convert.ToDecimal(item.Qty.ToString()));
                            axaptaRecord.Call("createLine", true, true, true, true, true, true);
                        }
                        //No errors occured, Commit!
                        //Axapta.TTSCommit();

                        if (postPostOrNo == 1)
                        {
                            var importNew = axapta.CreateAxaptaObject("CreateProductionJournals");
                            importNew.Call("PostPurchaseOrder", purchId, headerObjToPost.DocDate);
                        }
                    }

                    catch (Exception ex)
                    {
                        //There was some errors, Abort transaction and Raise error!
                        //Axapta.TTSAbort();
                        throw new Exception(ex.Message);
                    }
                    finally
                    {
                        //Finally logoff the Axapta Session
                        axapta.Logoff();
                    }
                }
            }
        }
コード例 #32
0
        public DataTable GetCustomerAddressList(string customerAccount, string userName)
        {
            Axapta ax = null;
            ax = new Axapta();
            DataTable addressTable = new DataTable();
            addressTable.Columns.Add("AddressID", typeof(String));
            addressTable.Columns.Add("AddressDesc", typeof(String));
            addressTable.Columns.Add("Address", typeof(String));
            addressTable.Columns.Add("IsBilling", typeof(String));
            addressTable.Columns.Add("IsShipping", typeof(String));
            try
            {
                ax.LogonAs(userName.Trim(), "", networkCredentials, axCompany, "", "", "");
                AxaptaRecord axRecord;
                axRecord = (AxaptaRecord)ax.CallStaticClassMethod("ServiceOrderManagement", "getSMACustomerAddresses", customerAccount);
                axRecord.ExecuteStmt("select * from %1");

                while (axRecord.Found)
                {
                    DataRow row = addressTable.NewRow();
                    row["AddressID"] = axRecord.get_Field("AddressID");
                    row["AddressDesc"] = axRecord.get_Field("AddressDesc");
                    row["Address"] = axRecord.get_Field("Address");
                    row["IsBilling"] = axRecord.get_Field("IsBilling");
                    row["IsShipping"] = axRecord.get_Field("Isshipping");
                    addressTable.Rows.Add(row);
                    axRecord.Next();

                }
            }
            catch (Exception e)
            {
                throw e;
                // Take other error action as needed.
            }
            finally
            {
                if (ax != null) ax.Logoff();
            }
            return addressTable;
        }
コード例 #33
0
        public DataTable GetSpecialityCodeList(string userName, string transactionId)
        {
            DataTable resultTable = new DataTable();
            Axapta ax = null;
            AxaptaRecord axRecord;
            try
            {
                // Login to Microsoft Dynamics AX.
                ax = new Axapta();
                ax.LogonAs(userName.Trim(), "", networkCredentials, axCompany, "", "", "");
                resultTable.Columns.Add("SpecialityCode", typeof(String));
                resultTable.Columns.Add("SpecialityDescription", typeof(String));
                using (axRecord = ax.CreateAxaptaRecord("CategoryTable"))
                {
                    // Execute the query on the table.e
                    //axRecord.ExecuteStmt("select CategoryID, CategoryName from %1 where %1.DataAreaID=='" + axCompany + "'");
                    axRecord = (AxaptaRecord)ax.CallStaticClassMethod("ServiceOrderManagement", "getSMACategoryTable", transactionId);
                    axRecord.ExecuteStmt("select * from %1");

                    // Loop through the set of retrieved records.
                    while (axRecord.Found)
                    {

                        DataRow row = resultTable.NewRow();
                        row["SpecialityCode"] = axRecord.get_Field("CategoryId");
                        row["SpecialityDescription"] = axRecord.get_Field("CategoryName");
                        resultTable.Rows.Add(row);
                        axRecord.Next();

                    }

                }
            }
            catch (Exception e)
            {
                throw e;
                // Take other error action as needed.
            }
            finally
            {
                if (ax != null) ax.Logoff();
            }
            return resultTable;
        }
コード例 #34
0
        public DataTable GetCustomers(string userName)
        {
            Axapta ax = null;

            ax = new Axapta();
            DataTable customerTable = new DataTable();
            customerTable.Columns.Add("CustomerAccount", typeof(String));
            customerTable.Columns.Add("CustomerName", typeof(String));
            try
            {
                ax.LogonAs(userName.Trim(), "", networkCredentials, axCompany, "", "", "");
                AxaptaRecord axRecord;
                axRecord = (AxaptaRecord)ax.CallStaticClassMethod("ServiceOrderManagement", "getSMACustomers");
                axRecord.ExecuteStmt("select * from %1");
                while (axRecord.Found)
                {
                    DataRow row = customerTable.NewRow();
                    row["CustomerAccount"] = axRecord.get_Field("CustAccount");
                    row["CustomerName"] = axRecord.get_Field("custName");
                    customerTable.Rows.Add(row);
                    axRecord.Next();

                }

            }
            catch (Exception e)
            {
                throw e;
                // Take other error action as needed.
            }
            finally
            {
                if (ax != null) ax.Logoff();
            }
            return customerTable;
        }
コード例 #35
0
        public List <IntershopWebService.ProductStock> GetItemsStockSize(List <IntershopWebService.ProductStockIn> products, string company)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            if (products.Count == 1)
            {
                MessageLogger.info(string.Format("GetItemsStockSize(itemId={0}, company={1})", products[0].itemId, company));
            }
            else
            {
                MessageLogger.info(string.Format("GetItemsStockSize(count={0}, company={1})", products.Count, company));
            }

            Axapta axapta = (Axapta)null;
            List <IntershopWebService.ProductStock> productStockList = new List <IntershopWebService.ProductStock>();

            try
            {
                axapta = this.axLogon(company);
                foreach (IntershopWebService.ProductStockIn product in products)
                {
                    IntershopWebService.ProductStockIn productIn    = product;
                    IntershopWebService.ProductStock   productStock = new IntershopWebService.ProductStock();
                    productStock.itemId = productIn.itemId;
                    string str1 = string.Empty;
                    productIn.size  = this.normalizeXmlString(productIn.size);
                    productIn.color = this.normalizeXmlString(productIn.color);
                    List <IntershopWebService.SizeStock> itemDims = this.getItemDims(productIn.itemId, company);
                    if (itemDims.Count > 0 && (!string.IsNullOrEmpty(productIn.size) || !string.IsNullOrEmpty(productIn.color)))
                    {
                        if (itemDims.FindIndex((Predicate <IntershopWebService.SizeStock>)(f => f.size == productIn.size)) >= 0)
                        {
                            str1 = productIn.size;
                        }
                        if (itemDims.FindIndex((Predicate <IntershopWebService.SizeStock>)(f => f.color == productIn.color)) >= 0)
                        {
                            str1 = productIn.color;
                        }
                    }
                    string str2 = Convert.ToString(axapta.CallStaticClassMethod("BTX_ISHItemDescriptionProxy", "GetOnHandUrl", (object)productIn.itemId, (object)str1));
                    productStock.stockLevel = str2;
                    productStockList.Add(productStock);
                    stopwatch.Stop();
                    MessageLogger.info(string.Format("GetItemsStockSize({0}, {1}, {2}, {3}) -> {4}, exec time: {5} ms", (object)productIn.itemId, (object)productIn.size, (object)productIn.color, (object)company, (object)productStock.stockLevel, (object)stopwatch.ElapsedMilliseconds));
                }
                return(productStockList);
            }
            catch (Exception ex)
            {
                if (products.Count == 1)
                {
                    MessageLogger.info(string.Format("GetItemsPriceSize(itemId={0}, company={1}) -> error: {2}", products[0].itemId, company, ex.Message));
                }
                else
                {
                    MessageLogger.info(string.Format("GetItemsPriceSize(count={0}, company={1}) -> error: {2}", products.Count, company, ex.Message));
                }

                MessageLogger.info(string.Format("Stack trace: {0}", ex.StackTrace.ToString()));

                return((List <IntershopWebService.ProductStock>)null);
            }
            finally
            {
                axapta.Logoff();
            }
        }
コード例 #36
0
        public DataTable GetLocations(string itemNumber, string site, string wareHouse, string userName)
        {
            DataTable resultTable = new DataTable();
            Axapta ax = null;
            AxaptaRecord axRecord;
            try
            {
                // Login to Microsoft Dynamics AX.
                ax = new Axapta();
                ax.LogonAs(userName.Trim(), "", networkCredentials, axCompany, "", "", "");
                resultTable.Columns.Add("LocationID", typeof(String));
                resultTable.Columns.Add("LocationName", typeof(String));
                resultTable.Columns.Add("PhysicalQty", typeof(String));
                axRecord = (AxaptaRecord)ax.CallStaticClassMethod("ServiceOrderManagement", "getSMAWMSLocationNew", site, wareHouse, itemNumber);                    // Loop through the set of retrieved records.
                axRecord.ExecuteStmt("select * from %1");
                while (axRecord.Found)
                {

                    DataRow row = resultTable.NewRow();
                    row["LocationID"] = axRecord.get_Field("wMSLocationId");
                    //row["LocationName"] = axRecord.get_Field("locationType");
                    row["PhysicalQty"] = axRecord.get_Field("AvaiPhysicalQty");
                    resultTable.Rows.Add(row);
                    axRecord.Next();

                }

            }

            catch (Exception e)
            {
                throw e;
                // Take other error action as needed.
            }
            finally
            {
                if (ax != null) ax.Logoff();
            }
            return resultTable;
        }
コード例 #37
0
        public DataTable GetTransactionSerialNumberList(string itemNumber, string site, string wareHouse, string locationId, string userName)
        {
            Axapta ax = null;
            AxaptaRecord axRecord;
            DataTable serialTable = new DataTable();

            serialTable.Columns.Add("SerialNumber", typeof(String));

            try
            {

                ax = new Axapta();
                ax.LogonAs(userName.Trim(), "", networkCredentials, axCompany, "", "", "");

                axRecord = (AxaptaRecord)ax.CallStaticClassMethod("ServiceOrderManagement", "getSMATransactionSerialNumbersLocation", itemNumber, wareHouse, site, locationId);
                axRecord.ExecuteStmt("select * from %1");

                while (axRecord.Found)
                {
                    DataRow row = serialTable.NewRow();
                    row["SerialNumber"] = axRecord.get_Field("SerialNumber");
                    serialTable.Rows.Add(row);
                    axRecord.Next();
                }

            }
            catch (Exception e)
            {
                throw e;
                // Take other error action as needed.
            }
            finally
            {
                if (ax != null) ax.Logoff();
            }
            return serialTable;
        }
コード例 #38
0
        public string CreateServiceOrder(string siteId, string customerAccount, string AddressId, string CustomerPO, string ServiceTechnicianNo, string responsibleNo, string woClassification, string customerComments, string userName)
        {
            Axapta ax = null;
            object[] param = new object[8];
            string serviceOrderId;
            try
            {
                ax = new Axapta();
                ax.LogonAs(userName.Trim(), "", networkCredentials, axCompany, "", "", "");

                param[0] = siteId;
                param[1] = customerAccount;
                param[2] = AddressId;
                param[3] = CustomerPO;
                param[4] = ServiceTechnicianNo;
                param[5] = responsibleNo;
                param[6] = woClassification;
                param[7] = customerComments;
                serviceOrderId = ax.CallStaticClassMethod("ServiceOrderManagement", "createSMAServiceOrder", param).ToString();

                if (serviceOrderId == "")
                {
                    string parameterString = "";
                    for (int i = 0; i < param.Length; i++)
                    {
                        parameterString += "param[" + i + "]" + param[i].ToString() + "; ";
                    }

                    throw new Exception(String.Format("AX Failure:- Method='{0}' Parameters:Values = {1} - ", "createSMAServiceOrder", parameterString));
                }
            }
            catch (Exception e)
            {
                throw e;
                // Take other error action as needed.
            }
            finally
            {
                if (ax != null) ax.Logoff();
            }
            return serviceOrderId;
        }
コード例 #39
0
        public bool UpdateServiceOrderPartLines(string uniqueId, string serviceOrderNo, string transactionType, string serviceTechnicianCode, string quantity, string specialityCode, string failureCode, string serviceType, string serviceOrderRelation, string description, string serviceComments, string itemNumber, string site, string wareHouse, string transSerialCodeNo, string colorId, string sizeId, string configId, string locationId, string userName)
        {
            Axapta ax = null;
            object[] param = new object[20];
            object axObject;
            bool flagValue;
            bool isSuccess = false;
            string salesPrice = "0.00";
            try
            {
                ax = new Axapta();
                ax.LogonAs(userName.Trim(), "", networkCredentials, axCompany, "", "", "");
                param[0] = uniqueId;
                param[1] = serviceOrderNo;

                param[2] = transactionType;
                param[3] = serviceTechnicianCode;
                param[4] = quantity;
                param[5] = salesPrice;
                param[6] = specialityCode;
                param[7] = failureCode;
                param[8] = serviceType;
                param[9] = serviceOrderRelation;
                param[10] = description;
                param[11] = serviceComments;
                param[12] = itemNumber;
                param[13] = site;
                param[14] = wareHouse;
                param[15] = transSerialCodeNo;
                param[16] = colorId;
                param[17] = sizeId;
                param[18] = configId;
                param[19] = locationId;

                axObject = ax.CallStaticClassMethod("ServiceOrderManagement", "updateSMAServiceOrderLine", param).ToString();
                if (bool.TryParse(axObject.ToString(), out flagValue))
                {
                    isSuccess = flagValue;
                }
                if (!isSuccess)
                {
                    string parameterString = "";
                    for (int i = 0; i < param.Length; i++)
                    {
                        parameterString += "param[" + i + "]" + param[i].ToString() + "; ";
                    }

                    throw new Exception(String.Format("AX Failure:- Method='{0}' Parameters:Values = {1} - ", "updateSMAServiceOrderLine", parameterString));
                }

            }
            catch (Exception e)
            {
                throw e;
                // Take other error action as needed.
            }
            finally
            {
                if (ax != null) ax.Logoff();
            }
            return isSuccess;
        }
コード例 #40
0
        public DataTable GetSalesInformation(string salesSerialNumber, string userName)
        {
            Axapta ax = null;
            AxaptaRecord axRecord;
            DataTable salesTable = new DataTable();

            salesTable.Columns.Add("SalesNumber", typeof(String));
            salesTable.Columns.Add("InvoiceNumber", typeof(String));
            salesTable.Columns.Add("InvoiceDate", typeof(String));
            salesTable.Columns.Add("Name", typeof(String));
            salesTable.Columns.Add("ItemNumber", typeof(String));

            try
            {

                ax = new Axapta();
                ax.LogonAs(userName.Trim(), "", networkCredentials, axCompany, "", "", "");

                axRecord = (AxaptaRecord)ax.CallStaticClassMethod("ServiceOrderManagement", "getSMASalesInformation", salesSerialNumber);
                axRecord.ExecuteStmt("select * from %1");

                while (axRecord.Found)
                {
                    DataRow row = salesTable.NewRow();

                    row["SalesNumber"] = axRecord.get_Field("OrigSalesId");
                    row["InvoiceNumber"] = axRecord.get_Field("InvoiceId");
                    row["InvoiceDate"] = axRecord.get_Field("InvoiceDate");
                    row["Name"] = axRecord.get_Field("Name");
                    row["ItemNumber"] = axRecord.get_Field("ItemId");

                    salesTable.Rows.Add(row);
                    axRecord.Next();
                }

            }

            catch (Exception e)
            {
                throw e;
                // Take other error action as needed.
            }
            finally
            {
                if (ax != null) ax.Logoff();
            }
            return salesTable;
        }
コード例 #41
0
        public bool CreateServiceOrderLinesList(string serviceOrderNo, string serialNumber, string partNumber, string partType, string quantity, string repairType, string warranty, string comments, string userName)
        {
            bool isSuccess = false;
            Axapta ax = null;

            object retval;
            try
            {
                ax = new Axapta();
                ax.LogonAs(userName.Trim(), "", networkCredentials, axCompany, "", "", "");
                bool flagValue;
                object[] param = new object[4];

                param[0] = serviceOrderNo;
                param[1] = partNumber;
                param[2] = serialNumber;
                param[3] = comments;

                retval = ax.CallStaticClassMethod("ServiceOrderManagement", "createSMAServiceObjectRelation", param).ToString();

                if (bool.TryParse(retval.ToString(), out flagValue))
                {
                    isSuccess = flagValue;
                }

                if (!isSuccess)
                {
                    string parameterString = "";
                    for (int i = 0; i < param.Length; i++)
                    {
                        parameterString += "param[" + i + "]" + param[i].ToString() + "; ";
                    }

                    throw new Exception(String.Format("AX Failure:- Method='{0}' Parameters:Values = {1} - ", "createSMAServiceObjectRelation", parameterString));
                }

            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                if (ax != null) ax.Logoff();
            }
            return isSuccess;
        }
コード例 #42
0
        private void InsertAllNewAccessoryToAx(IEnumerable <tbl_AccessoryAttributesDetails> listObjToPost
                                               , tbl_AccessoryAttributesHeader objToPost, bool isSizeInCode, int userIserial)
        {
            try
            {
                using (var context = new WorkFlowManagerDBEntities())
                {
                    var axapta = new Axapta();//Ready To be Dependent from Ax;

                    var credential = new NetworkCredential("bcproxy", "around1");

                    TblAuthUser userToLogin;
                    using (var model = new WorkFlowManagerDBEntities())
                    {
                        userToLogin = model.TblAuthUsers.SingleOrDefault(x => x.Iserial == userIserial);
                    }
                    axapta.LogonAs(userToLogin.User_Win_Login, userToLogin.User_Domain, credential, "Ccm", null, null, null);
                    var itemId    = objToPost.Code.Trim();
                    var tableName = "InventTable";

                    var axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();
                    var tblLkpItemGroupType = context.tbl_lkp_ItemGroupType.FirstOrDefault(x => x.Iserial ==
                                                                                           context.tbl_lkp_AccessoryGroup
                                                                                           .FirstOrDefault(
                                                                                               g =>
                                                                                               g.Iserial ==
                                                                                               objToPost.AccGroup)
                                                                                           .tbl_lkp_ItemGroupType);
                    if (tblLkpItemGroupType != null)
                    {
                        var itmGroup = tblLkpItemGroupType.Code;
                        axaptaRecord.set_Field("ItemGroupId", itmGroup);
                    }
                    else
                    {
                        axaptaRecord.set_Field("ItemGroupId", "ACCESSORIES");
                    }
                    axaptaRecord.set_Field("ItemId", itemId);
                    axaptaRecord.set_Field("ItemName", objToPost.Descreption ?? itemId);
                    axaptaRecord.set_Field("ModelGroupID", "STD");
                    axaptaRecord.set_Field("ItemType", 0);
                    axaptaRecord.set_Field("DimGroupId", "ACC");
                    //Commit the record to the database.
                    axaptaRecord.Insert();
                    tableName    = "InventTableModule";
                    axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();

                    axaptaRecord.set_Field("ItemId", itemId);
                    axaptaRecord.set_Field("ModuleType", 0);
                    if (objToPost.UoMID != null)
                    {
                        axaptaRecord.set_Field
                            ("UnitId",
                            context.tbl_lkp_UoM
                            .Where(x => x.Iserial == objToPost.UoMID)
                            .Select(x => x.Ename)
                            .SingleOrDefault()
                            );
                    }
                    //
                    axaptaRecord.Insert();

                    axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();

                    axaptaRecord.set_Field("ItemId", itemId);
                    axaptaRecord.set_Field("ModuleType", 1);

                    //
                    axaptaRecord.Insert();

                    axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();

                    axaptaRecord.set_Field("ItemId", itemId);
                    axaptaRecord.set_Field("ModuleType", 2);

                    //
                    axaptaRecord.Insert();

                    tableName = "InventItemLocation";

                    axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();

                    axaptaRecord.set_Field("ItemId", itemId);
                    axaptaRecord.set_Field("InventDIMID", "AllBlank");

                    // Commit the record to the database.
                    axaptaRecord.Insert();
                    foreach (var item in listObjToPost)
                    {
                        try
                        {
                            var importNew = axapta.CreateAxaptaObject("CreateProductionJournals");
                            importNew.Call("CreateConfig", listObjToPost.Select(x => x.Code).FirstOrDefault(), item);
                        }
                        catch (Exception)
                        {
                        }
                        //    if (!isSizeInCode)
                        //      {
                        try
                        {
                            var importNew = axapta.CreateAxaptaObject("CreateProductionJournals");
                            importNew.Call("CreateSize", listObjToPost.Select(x => x.Code).FirstOrDefault(), item);
                        }
                        catch (Exception)
                        {
                        }

                        //--------------------------------------------//
                        //--------------------------------------------//
                        //--------------------------------------------//
                        try
                        {
                            tableName    = "InventDimCombination";
                            axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                            axaptaRecord.Clear();
                            axaptaRecord.InitValue();

                            axaptaRecord.set_Field("ItemId", itemId);
                            axaptaRecord.set_Field("InventSizeID", item.Size);
                            axaptaRecord.set_Field("ConfigId", item.Configuration);
                            //Commit the record to the database.
                            axaptaRecord.Insert();
                        }
                        catch (Exception)
                        {
                        }

                        //--------------------------------------------//
                        //--------------------------------------------//
                        //--------------------------------------------//
                        //      }
                    }
                    axapta.Logoff();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #43
0
        public bool DeleteServiceOrderPartLines(string uniqueId, string userName)
        {
            Axapta ax = null;
            object[] param = new object[1];
            object axObject;
            bool flagValue;
            bool isSuccess = false;
            try
            {
                ax = new Axapta();
                ax.LogonAs(userName.Trim(), "", networkCredentials, axCompany, "", "", "");
                param[0] = uniqueId;
                axObject = ax.CallStaticClassMethod("ServiceOrderManagement", "deleteSMAServiceOrderLine", param).ToString();
                if (bool.TryParse(axObject.ToString(), out flagValue))
                {
                    isSuccess = flagValue;
                }
                if (!isSuccess)
                {
                    string parameterString = "";
                    for (int i = 0; i < param.Length; i++)
                    {
                        parameterString += "param[" + i + "]" + param[i].ToString() + "; ";
                    }

                    throw new Exception(String.Format("AX Failure:- Method='{0}' Parameters:Values = {1} - ", "deleteSMAServiceOrderLine", parameterString));
                }

            }
            catch (Exception e)
            {
                throw e;
                // Take other error action as needed.
            }
            finally
            {
                if (ax != null) ax.Logoff();
            }
            return isSuccess;
        }
コード例 #44
0
        //  Get technicians for service order process
        public DataTable GetTechniciansServiceOrderProcess(string transactionType, string specialityCode, string userName)
        {
            Axapta ax = null;

            ax = new Axapta();
            DataTable techniciansTable = new DataTable();
            techniciansTable.Columns.Add("Name", typeof(String));
            techniciansTable.Columns.Add("Number", typeof(String));
            try
            {
                ax.LogonAs(userName.Trim(), "", networkCredentials, axCompany, "", "", "");
                AxaptaRecord axRecord;
                axRecord = (AxaptaRecord)ax.CallStaticClassMethod("ServiceOrderManagement", "getSMATechniciansParts", transactionType, specialityCode);
                axRecord.ExecuteStmt("select * from %1");

                while (axRecord.Found)
                {
                    DataRow row = techniciansTable.NewRow();
                    row["Name"] = axRecord.get_Field("Name");
                    row["Number"] = axRecord.get_Field("Number");
                    techniciansTable.Rows.Add(row);
                    axRecord.Next();

                }
            }
            catch (Exception e)
            {
                throw e;
                // Take other error action as needed.
            }
            finally
            {
                if (ax != null) ax.Logoff();
            }

            return techniciansTable;
        }
コード例 #45
0
        private void PickingList(int routeCardHeaderIserial, int postPostOrNo)
        {
            using (var entities = new WorkFlowManagerDBEntities())
            {
                var routeHeaderRow = entities
                                     .RouteCardHeaders.SingleOrDefault(x => x.Iserial == routeCardHeaderIserial);

                var pickingList = entities.RouteCardFabrics.Where(x => x.RouteCardHeaderIserial == routeHeaderRow.Iserial).ToList();

                try
                {
                    if (pickingList.Count() != 0)
                    {
                        var axapta     = new Axapta();
                        var credential = new NetworkCredential("bcproxy", "around1");
                        axapta.LogonAs("osama.gamal", "ccasual.loc", credential, "ccm", null, null, null);
                        const string tableName = "AutoPICKING";

                        foreach (var item in pickingList)
                        {
                            var site = entities.GetLocations.Where(x => x.INVENTLOCATIONID == item.Warehouse).Select(x => x.INVENTSITEID).FirstOrDefault();

                            var axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                            axaptaRecord.Clear();
                            axaptaRecord.InitValue();
                            axaptaRecord.set_Field("DATAAREAID", "CCM");
                            if (item != null)
                            {
                                if (item.SalesOrder != null)
                                {
                                    axaptaRecord.set_Field("SALESORDER", item.SalesOrder);
                                }
                                if (item.ItemId != null)
                                {
                                    axaptaRecord.set_Field("FABRICID", item.ItemId);
                                }
                                if (item.FabricColor != null)
                                {
                                    axaptaRecord.set_Field("FABRIC_COLOR", item.FabricColor);
                                }
                                if (item.Style != null)
                                {
                                    axaptaRecord.set_Field("STYLEID", item.Style);
                                }
                                if (item.StyleColor != null)
                                {
                                    axaptaRecord.set_Field("STYLECOLOR", item.StyleColor);
                                }
                                if (site != null)
                                {
                                    axaptaRecord.set_Field("FABRICSITEID", site);
                                }
                                if (item.Warehouse != null)
                                {
                                    axaptaRecord.set_Field("FABRICLOCATION", item.Warehouse);
                                    axaptaRecord.set_Field("FABRICWAREHOUSES", item.Warehouse);
                                }
                                if (item.Barcode != null)
                                {
                                    axaptaRecord.set_Field("FABRICBATCHNUMBER", item.Barcode.ToString());
                                }
                                axaptaRecord.set_Field("TRANSDATE", routeHeaderRow.DocDate);
                                axaptaRecord.set_Field("QTY", item.Qty);
                            }
                            axaptaRecord.set_Field("VENDOR", routeHeaderRow.Vendor);
                            axaptaRecord.set_Field("WORKFLOWJOURID", routeHeaderRow.Iserial);

                            axaptaRecord.Insert();
                        }

                        var importNew = axapta.CreateAxaptaObject("CreateProductionJournals");
                        var retval    = importNew.Call("CreatePicking", routeHeaderRow.Iserial, 0, postPostOrNo);
                        routeHeaderRow.AxRouteCardFabricsJournalId = retval.ToString();

                        ClearAxTable(tableName, axapta);

                        entities.SaveChanges();
                        axapta.Logoff();
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
コード例 #46
0
        public void ProducationConnectionAcc(int dyeingProductionOrder, int transId, int transactionType, int userIserial)
        {
            using (var entities = new WorkFlowManagerDBEntities())
            {
                var header     = entities.TblDyeingOrdersHeaderAccs.SingleOrDefault(x => x.DyeingProductionOrder == dyeingProductionOrder);
                var mainDetail = entities.TblDyeingOrdersMainDetailsACCs.Include("TblDyeingOrdersDetailsAccs.DyeingOrderDetailsServicesAccs").SingleOrDefault(x => x.DyeingProductionOrder == dyeingProductionOrder &&
                                                                                                                                                              x.TransId == transId && x.TransactionType == transactionType);
                var locationLoc = entities.GetLocations.SingleOrDefault(x => x.INVENTLOCATIONID == mainDetail.WareHouse);

                var vendorWmsLocation = entities.GetWmsLocations.SingleOrDefault(x => x.VENDID == header.Vendor);

                var vendorLoc  = entities.GetLocations.SingleOrDefault(x => x.INVENTLOCATIONID == vendorWmsLocation.INVENTLOCATIONID);
                var axapta     = new Axapta();
                var credential = new NetworkCredential("bcproxy", "around1");

                TblAuthUser userToLogin;
                using (var model = new WorkFlowManagerDBEntities())
                {
                    userToLogin = model.TblAuthUsers.SingleOrDefault(x => x.Iserial == userIserial);
                }
                axapta.LogonAs(userToLogin.User_Win_Login, userToLogin.User_Domain, credential, "Ccm", null, null, null);
                var tableName       = "PRODCONNECTION";
                var transactionGuid = Guid.NewGuid().ToString();
                foreach (var item in mainDetail.TblDyeingOrdersDetailsAccs)
                {
                    try
                    {
                        AxaptaRecord AxaptaRecord;

                        #region TransactionType0  Transfer To Vendor's Location And ProductionOrder And PickingList

                        AxaptaRecord = axapta.CreateAxaptaRecord(tableName);
                        AxaptaRecord.Clear();
                        AxaptaRecord.InitValue();

                        if (item.TransactionType == 0)
                        {
                            //Transfer To Vendor's Location

                            AxaptaRecord.set_Field("TRANSID", item.DyeingProductionOrder);
                            AxaptaRecord.set_Field("RAWID", item.FabricCode);
                            AxaptaRecord.set_Field("RAWQTY", item.CalculatedTotalQty);
                            AxaptaRecord.set_Field("UNITID", item.Unit);
                            AxaptaRecord.set_Field("FROMSITE", locationLoc.INVENTSITEID);
                            AxaptaRecord.set_Field("FROMLOCATION", mainDetail.WareHouse);
                            AxaptaRecord.set_Field("FROMWAREHOUSE", mainDetail.WareHouse);
                            AxaptaRecord.set_Field("FROMBATCH", "Free");
                            AxaptaRecord.set_Field("FROMCONFIG", item.Color);
                            AxaptaRecord.set_Field("TOSITE", vendorLoc.INVENTSITEID);
                            AxaptaRecord.set_Field("TOLOCATION", vendorWmsLocation.WMSLOCATIONID);
                            AxaptaRecord.set_Field("TOWAREHOUSE", vendorWmsLocation.INVENTLOCATIONID);
                            //AxaptaRecord.set_Field("TOBATCH", item.BatchNo.ToString());
                            AxaptaRecord.set_Field("TOCONFIG", item.Color);
                            AxaptaRecord.set_Field("TRANSTYPE", Convert.ToInt64(0));
                            AxaptaRecord.set_Field("JOURNALLINKID", transId);
                            AxaptaRecord.set_Field("TransactionGuid", transactionGuid);
                            AxaptaRecord.Insert();

                            //  //   ProductionOrder

                            AxaptaRecord = axapta.CreateAxaptaRecord(tableName);
                            AxaptaRecord.Clear();
                            AxaptaRecord.InitValue();

                            AxaptaRecord.set_Field("TRANSID", item.DyeingProductionOrder);
                            AxaptaRecord.set_Field("DYEDITEM", item.DyedFabric);
                            AxaptaRecord.set_Field("DYEDQTY", item.CalculatedTotalQty);
                            AxaptaRecord.set_Field("UNITID", item.Unit);
                            AxaptaRecord.set_Field("JOURNALLINKID", transId);
                            AxaptaRecord.set_Field("FROMSITE", vendorLoc.INVENTSITEID);
                            AxaptaRecord.set_Field("TOSITE", vendorLoc.INVENTSITEID);
                            AxaptaRecord.set_Field("FROMLOCATION", vendorWmsLocation.WMSLOCATIONID);
                            AxaptaRecord.set_Field("TOLOCATION", vendorWmsLocation.WMSLOCATIONID);
                            AxaptaRecord.set_Field("TRANSTYPE", Convert.ToInt64(1));
                            AxaptaRecord.set_Field("FROMCONFIG", item.Color);
                            AxaptaRecord.set_Field("TOCONFIG", item.Color);
                            //  AxaptaRecord.set_Field("FROMBATCH", item.BatchNo.ToString());
                            //   AxaptaRecord.set_Field("TOBATCH", item.BatchNo.ToString());
                            AxaptaRecord.set_Field("FROMWAREHOUSE", vendorWmsLocation.INVENTLOCATIONID);
                            AxaptaRecord.set_Field("TOWAREHOUSE", vendorWmsLocation.INVENTLOCATIONID);
                            AxaptaRecord.set_Field("TransactionGuid", transactionGuid);
                            AxaptaRecord.Insert();

                            ////     PickingList
                            AxaptaRecord = axapta.CreateAxaptaRecord(tableName);
                            AxaptaRecord.Clear();
                            AxaptaRecord.InitValue();
                            AxaptaRecord.set_Field("TRANSID", item.DyeingProductionOrder);
                            AxaptaRecord.set_Field("RAWID", item.FabricCode);
                            AxaptaRecord.set_Field("DYEDITEM", item.DyedFabric);
                            AxaptaRecord.set_Field("RAWQTY", item.CalculatedTotalQty);
                            AxaptaRecord.set_Field("DYEDQTY", item.CalculatedTotalQty);
                            AxaptaRecord.set_Field("UNITID", item.Unit);
                            AxaptaRecord.set_Field("FROMSITE", vendorLoc.INVENTSITEID);
                            AxaptaRecord.set_Field("TOSITE", vendorLoc.INVENTSITEID);
                            AxaptaRecord.set_Field("FROMLOCATION", vendorWmsLocation.WMSLOCATIONID);
                            AxaptaRecord.set_Field("TOLOCATION", vendorWmsLocation.WMSLOCATIONID);
                            AxaptaRecord.set_Field("TRANSTYPE", Convert.ToInt64(2));
                            AxaptaRecord.set_Field("FROMCONFIG", item.Color);
                            AxaptaRecord.set_Field("TOCONFIG", item.Color);
                            //AxaptaRecord.set_Field("FROMBATCH", item.BatchNo.ToString());
                            //AxaptaRecord.set_Field("TOBATCH", item.BatchNo.ToString());
                            AxaptaRecord.set_Field("FROMWAREHOUSE", vendorWmsLocation.INVENTLOCATIONID);
                            AxaptaRecord.set_Field("TOWAREHOUSE", vendorWmsLocation.INVENTLOCATIONID);
                            AxaptaRecord.set_Field("JOURNALLINKID", transId);
                            AxaptaRecord.set_Field("TransactionGuid", transactionGuid);
                            AxaptaRecord.Insert();
                        }

                        #endregion TransactionType0  Transfer To Vendor's Location And ProductionOrder And PickingList

                        #region TransactionType3 ReportAsFinished

                        else if (item.TransactionType == 1)
                        {
                            AxaptaRecord = axapta.CreateAxaptaRecord(tableName);
                            AxaptaRecord.Clear();
                            AxaptaRecord.InitValue();

                            AxaptaRecord.set_Field("TRANSID", item.DyeingProductionOrder);
                            AxaptaRecord.set_Field("DYEDITEM", item.DyedFabric);
                            AxaptaRecord.set_Field("DYEDQTY", item.CalculatedTotalQty);
                            AxaptaRecord.set_Field("UNITID", item.Unit);
                            AxaptaRecord.set_Field("FROMSITE", vendorLoc.INVENTSITEID);
                            AxaptaRecord.set_Field("TOSITE", locationLoc.INVENTSITEID);
                            AxaptaRecord.set_Field("FROMLOCATION", vendorWmsLocation.WMSLOCATIONID);
                            AxaptaRecord.set_Field("TOLOCATION", mainDetail.WareHouse);
                            AxaptaRecord.set_Field("TRANSTYPE", Convert.ToInt64(3));
                            AxaptaRecord.set_Field("FROMCONFIG", item.Color);
                            AxaptaRecord.set_Field("TOCONFIG", item.Color);
                            // AxaptaRecord.set_Field("FROMBATCH", item.BatchNo.ToString());
                            // AxaptaRecord.set_Field("TOBATCH", item.BatchNo.ToString());
                            AxaptaRecord.set_Field("JOURNALLINKID", transId);
                            AxaptaRecord.set_Field("TOWAREHOUSE", mainDetail.WareHouse);
                            AxaptaRecord.set_Field("FROMWAREHOUSE", vendorWmsLocation.INVENTLOCATIONID);

                            AxaptaRecord.Insert();
                        }

                        #endregion TransactionType3 ReportAsFinished
                    }
                    catch (Exception)
                    {
                    }
                }
                var import = axapta.CreateAxaptaObject("CLEDyeProcesse");
                try
                {
                    if (transactionType == 0)
                    {
                        //public ProdJournalId run(int transId,int journalId,int WhatToDo,str JourName,int PostorNo)
                        var Production  = import.Call("run", dyeingProductionOrder, transId, 1, "", 1);
                        var Transfer    = import.Call("run", dyeingProductionOrder, transId, 0, "Name", 1);
                        var PickingList = import.Call("run", dyeingProductionOrder, transId, 2, "Name", 1);
                        PurchaseDyeingServicesToAxAcc(header, mainDetail, 0, userIserial, transactionGuid);
                    }
                    else if (transactionType == 1)
                    {
                        var ReportAsFinished = import.Call("run", dyeingProductionOrder, transId, 3, "Name", 1);
                    }

                    mainDetail.Posted = true;
                    entities.SaveChanges();
                }
                catch (Exception)
                {
                    throw;
                }

                Operations.SharedOperation.ClearAxTable("PRODCONNECTION", axapta, transactionGuid);
                axapta.Logoff();
            }
        }
コード例 #47
0
        //- Get the Service Order Line Details by Serial Number or Item Number in Service Order Process
        public DataTable GetServiceOrderLinesDetailsBySerialNumber(string serialId, string itemNumber, string userName)
        {
            Axapta ax = null;
            AxaptaRecord axRecord;
            DataTable serialTable = new DataTable();
            serialTable.Columns.Add("SerialNumber", typeof(String));
            serialTable.Columns.Add("PartNumber", typeof(String));
            serialTable.Columns.Add("PartType", typeof(String));
            serialTable.Columns.Add("Quantity", typeof(String));
            serialTable.Columns.Add("Warranty", typeof(String));
            serialTable.Columns.Add("RepairType", typeof(String));
            serialTable.Columns.Add("LineProperty", typeof(String));
            object[] param = new object[2];
            try
            {

                ax = new Axapta();
                ax.LogonAs(userName.Trim(), "", networkCredentials, axCompany, "", "", "");
                param[0] = serialId;
                param[1] = itemNumber;

                axRecord = (AxaptaRecord)ax.CallStaticClassMethod("ServiceOrderManagement", "getSMASerialNumberDetails", param);
                axRecord.ExecuteStmt("select * from %1");

                while (axRecord.Found)
                {
                    DataRow row = serialTable.NewRow();
                    row["SerialNumber"] = axRecord.get_Field("SerialNumber");
                    row["PartNumber"] = axRecord.get_Field("ItemID");
                    row["PartType"] = axRecord.get_Field("ItemGroup");
                    row["Quantity"] = axRecord.get_Field("Quantity");
                    row["Warranty"] = axRecord.get_Field("Warranty");
                    row["RepairType"] = axRecord.get_Field("RepairType");
                    row["LineProperty"] = axRecord.get_Field("LineProperty");
                    serialTable.Rows.Add(row);
                    axRecord.Next();
                }

            }
            catch (Exception e)
            {
                throw e;
                // Take other error action as needed.
            }
            finally
            {
                if (ax != null) ax.Logoff();
            }
            return serialTable;
        }
コード例 #48
0
        private void PickingListForAxServicesAcc(TblDyeingOrdersHeaderAcc objToPost, TblDyeingOrdersMainDetailsACC headerObjToPost,
                                                 int postPostOrNo, int userIserial, string transactionGuid)
        {
            using (var entities = new WorkFlowManagerDBEntities())
            {
                var          axapta = new Axapta();
                AxaptaRecord AxaptaRecord;
                var          credential = new NetworkCredential("bcproxy", "around1");
                var          tableName  = "PRODCONNECTION";
                TblAuthUser  userToLogin;
                using (var model = new WorkFlowManagerDBEntities())
                {
                    userToLogin = model.TblAuthUsers.SingleOrDefault(x => x.Iserial == userIserial);
                }
                axapta.LogonAs(userToLogin.User_Win_Login, userToLogin.User_Domain, credential, "Ccm", null, null, null);

                var vendorWmsLocation = entities.GetWmsLocations.SingleOrDefault(x => x.VENDID == objToPost.Vendor);

                var vendorLoc =
                    entities.GetLocations.SingleOrDefault(x => x.INVENTLOCATIONID == vendorWmsLocation.INVENTLOCATIONID);

                try
                {
                    foreach (var item in headerObjToPost.TblDyeingOrdersDetailsAccs)
                    {
                        foreach (var service in item.DyeingOrderDetailsServicesAccs)
                        {
                            AxaptaRecord = axapta.CreateAxaptaRecord(tableName);
                            AxaptaRecord.Clear();
                            AxaptaRecord.InitValue();
                            AxaptaRecord.set_Field("TRANSID", item.DyeingProductionOrder);
                            AxaptaRecord.set_Field("RAWID", service.ServiceCode);
                            AxaptaRecord.set_Field("DYEDITEM", service.ServiceCode);
                            AxaptaRecord.set_Field("RAWQTY", item.CalculatedTotalQty);
                            AxaptaRecord.set_Field("DYEDQTY", item.CalculatedTotalQty);
                            //AxaptaRecord.set_Field("UNITID", item.Unit);
                            AxaptaRecord.set_Field("FROMSITE", vendorLoc.INVENTSITEID);
                            AxaptaRecord.set_Field("TOSITE", vendorLoc.INVENTSITEID);
                            AxaptaRecord.set_Field("FROMLOCATION", vendorWmsLocation.WMSLOCATIONID);
                            AxaptaRecord.set_Field("TOLOCATION", vendorWmsLocation.WMSLOCATIONID);
                            AxaptaRecord.set_Field("TRANSTYPE", Convert.ToInt64(2));
                            AxaptaRecord.set_Field("FROMCONFIG", item.Color);
                            AxaptaRecord.set_Field("TOCONFIG", item.Color);
                            // AxaptaRecord.set_Field("FROMBATCH", item.BatchNo.ToString());
                            //AxaptaRecord.set_Field("TOBATCH", item.BatchNo.ToString());
                            AxaptaRecord.set_Field("FROMWAREHOUSE", vendorWmsLocation.INVENTLOCATIONID);
                            AxaptaRecord.set_Field("TOWAREHOUSE", vendorWmsLocation.INVENTLOCATIONID);
                            AxaptaRecord.set_Field("JOURNALLINKID", headerObjToPost.TransId);
                            AxaptaRecord.set_Field("TransactionGuid", transactionGuid);
                            AxaptaRecord.Insert();
                        }
                    }
                    //public ProdJournalId run(int transId,int journalId,int WhatToDo,str JourName,int PostorNo)
                    var import      = axapta.CreateAxaptaObject("CLEDyeProcesse");
                    var PickingList = import.Call("run", headerObjToPost.DyeingProductionOrder, headerObjToPost.TransId, 2, "Name", postPostOrNo);

                    axapta.Logoff();
                }

                catch (Exception)
                {
                    axapta.Logoff();
                    throw;
                }
            }
        }
コード例 #49
0
        // Get Service Order Part lines by service order for service order process
        public DataTable GetServiceOrderPartLineByServiceOrder(string serviceOrderId, string userName)
        {
            Axapta ax = null;
            AxaptaRecord axRecord;
            DataTable serviceOrderLineTable = new DataTable();
            serviceOrderLineTable.Columns.Add("SerialNumber", typeof(String));
            serviceOrderLineTable.Columns.Add("SORelationID", typeof(String));
            serviceOrderLineTable.Columns.Add("TransactionType", typeof(String));
            serviceOrderLineTable.Columns.Add("Description", typeof(String));
            serviceOrderLineTable.Columns.Add("SpecialityCode", typeof(String));
            serviceOrderLineTable.Columns.Add("FailureCode", typeof(String));
            serviceOrderLineTable.Columns.Add("LineProperty", typeof(String));
            serviceOrderLineTable.Columns.Add("Qty", typeof(String));
            serviceOrderLineTable.Columns.Add("SalesPrice", typeof(String));
            serviceOrderLineTable.Columns.Add("TechnicianNo", typeof(String));
            serviceOrderLineTable.Columns.Add("Technician", typeof(String));
            serviceOrderLineTable.Columns.Add("ServiceComments", typeof(String));
            serviceOrderLineTable.Columns.Add("UniqueId", typeof(String));
            serviceOrderLineTable.Columns.Add("ItemNumber", typeof(String));
            serviceOrderLineTable.Columns.Add("Status", typeof(String));
            serviceOrderLineTable.Columns.Add("Site", typeof(String));
            serviceOrderLineTable.Columns.Add("WareHouse", typeof(String));
            serviceOrderLineTable.Columns.Add("Size", typeof(String));
            serviceOrderLineTable.Columns.Add("Color", typeof(String));
            serviceOrderLineTable.Columns.Add("Config", typeof(String));
            serviceOrderLineTable.Columns.Add("LocationId", typeof(String));
            serviceOrderLineTable.Columns.Add("TransSerialNumber", typeof(String));

            try
            {

                ax = new Axapta();
                ax.LogonAs(userName.Trim(), "", networkCredentials, axCompany, "", "", "");

                axRecord = (AxaptaRecord)ax.CallStaticClassMethod("ServiceOrderManagement", "getSMASOLineDetails", serviceOrderId);
                axRecord.ExecuteStmt("select * from %1 order by %1.UniqueID desc");

                while (axRecord.Found)
                {
                    DataRow row = serviceOrderLineTable.NewRow();
                    row["SerialNumber"] = axRecord.get_Field("SerialNumber");
                    row["SORelationID"] = axRecord.get_Field("ServiceObjectRelationId");
                    row["TransactionType"] = axRecord.get_Field("TransactionType");
                    row["Description"] = axRecord.get_Field("Description");
                    row["SpecialityCode"] = axRecord.get_Field("ProjCategoryId");
                    row["FailureCode"] = axRecord.get_Field("SMAFailureCode");
                    row["LineProperty"] = axRecord.get_Field("ProjLinePropertyId");
                    row["Qty"] = axRecord.get_Field("Qty");
                    row["SalesPrice"] = axRecord.get_Field("ProjSalesPrice");
                    row["TechnicianNo"] = axRecord.get_Field("Worker");
                    row["Technician"] = axRecord.get_Field("WorkerName");
                    row["ServiceComments"] = axRecord.get_Field("DescriptionService");
                    row["ItemNumber"] = axRecord.get_Field("ItemId");
                    row["Status"] = axRecord.get_Field("ServiceOrderStatus");
                    row["UniqueId"] = axRecord.get_Field("UniqueID");
                    row["Site"] = axRecord.get_Field("InventSiteId");
                    row["WareHouse"] = axRecord.get_Field("InventLocationId");
                    row["Size"] = axRecord.get_Field("InventSizeId");
                    row["Color"] = axRecord.get_Field("InventColorId");
                    row["Config"] = axRecord.get_Field("configId");
                    row["LocationId"] = axRecord.get_Field("WMSLocationid");
                    row["TransSerialNumber"] = axRecord.get_Field("InventSerialId");

                    serviceOrderLineTable.Rows.Add(row);
                    axRecord.Next();
                }

            }

            catch (Exception e)
            {
                throw e;
                // Take other error action as needed.
            }
            finally
            {
                if (ax != null) ax.Logoff();
            }
            return serviceOrderLineTable;
        }