// 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));
        }
示例#2
0
        public void UpdateFabItem(tbl_FabricAttriputes objToPost, int userIserial)
        {
            var axapta = new Axapta();

            try
            {
                using (var context = new WorkFlowManagerDBEntities())
                {
                    var credential = new NetworkCredential("bcproxy", "around1");
                    var user       = context.TblAuthUsers.FirstOrDefault(x => x.Iserial == userIserial);

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

                    axapta.TTSBegin();
                    var itemId    = objToPost.FabricID;
                    var tableName = "InventTable";

                    var axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();
                    var header = axapta.CallStaticRecordMethod("InventTable", "find", itemId, true) as AxaptaRecord;
                    header.set_Field("ItemName", objToPost.FabricDescription);

                    context.SaveChanges();
                    axapta.TTSCommit();
                }
            }
            catch (Exception ex)
            {
                axapta.TTSAbort();
                throw ex;
            }
        }
示例#3
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);
        }
        private Axapta axLogon(string company)
        {
            Axapta axapta = new Axapta();

            axapta.LogonAs("sa_axproxy", "BCE.Local", null, company, (string)null, (string)null, (string)null);
            return(axapta);
        }
            /// <summary>
            /// Instanciated Axapta and get instance
            /// </summary>
            /// <param name="userName"></param>
            /// <param name="password"></param>
            /// <param name="domain"></param>
            /// <param name="company"></param>
            /// <returns></returns>
            public Axapta Get(string userName, string password, string domain, string company)
            {
                if (String.IsNullOrEmpty(userName))
                {
                    throw new Exception("Username is null.");
                }
                if (String.IsNullOrEmpty(password))
                {
                    throw new Exception("Password is null.");
                }
                if (String.IsNullOrEmpty(domain))
                {
                    throw new Exception("Domain is null.");
                }


                Axapta            axapta            = new Axapta();
                NetworkCredential networkCredential = new NetworkCredential(userName, password, domain);

                if (company == "Organization-Wide")
                {
                    company = string.Empty;
                }
                axapta.LogonAs(userName, domain, networkCredential, company, ConfigurationManager.AppSettings["language"], ConfigurationManager.AppSettings["objectServer"], ConfigurationManager.AppSettings["configuration"]);
                return(axapta);
            }
示例#6
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"));
            }
        }
示例#7
0
        public void PostIssueHeader(int iserial, int userIserial)
        {
            using (var entities = new WorkFlowManagerDBEntities())
            {
                var axapta     = new Axapta();
                var credential = new NetworkCredential("bcproxy", "around1");

                TblAuthUser userToLogin;
                using (var model = new WorkFlowManagerDBEntities())
                {
                    userToLogin = model.TblAuthUsers.FirstOrDefault(x => x.Iserial == userIserial);
                }
                var header = entities.TblIssueJournalHeaders.Include("TblIssueJournalDetails").FirstOrDefault(x => x.Iserial == iserial);

                var vendorWmsLocation = entities.GetWmsLocations.FirstOrDefault(x => x.VENDID == header.Vendor);
                var vendorLoc         = entities.GetLocations.FirstOrDefault(x => x.INVENTLOCATIONID == vendorWmsLocation.INVENTLOCATIONID);
                axapta.LogonAs(userToLogin.User_Win_Login, userToLogin.User_Domain, credential, "Ccm", null, null, null);
                const string tableName       = "PRODCONNECTION";
                var          transactionGuid = Guid.NewGuid().ToString();

                if (header != null)
                {
                    foreach (var item in header.TblIssueJournalDetails)
                    {
                        var locationLoc = entities.GetLocations.FirstOrDefault(x => x.INVENTLOCATIONID == item.Location);

                        AxaptaRecord axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                        axaptaRecord.Clear();
                        axaptaRecord.InitValue();
                        //Transfer To Vendor's Location

                        var itemcode = GetItemCode(item.ItemCode, item.ItemType);
                        axaptaRecord.set_Field("DYEDITEM", itemcode.Code);
                        axaptaRecord.set_Field("TRANSID", item.TblIssueJournalHeader);
                        axaptaRecord.set_Field("RAWID", itemcode.Code);
                        axaptaRecord.set_Field("RAWQTY", item.Qty);
                        axaptaRecord.set_Field("DYEDQTY", item.Qty);
                        axaptaRecord.set_Field("UNITID", itemcode.Unit);
                        axaptaRecord.set_Field("FROMSITE", locationLoc.INVENTSITEID);
                        axaptaRecord.set_Field("FROMLOCATION", item.Location);
                        axaptaRecord.set_Field("FROMWAREHOUSE", item.Location);
                        axaptaRecord.set_Field("FROMBATCH", item.BatchNo);
                        axaptaRecord.set_Field("FROMCONFIG", item.TblColor1.Code);
                        axaptaRecord.set_Field("TOSITE", vendorLoc.INVENTSITEID);
                        axaptaRecord.set_Field("TOLOCATION", vendorWmsLocation.WMSLOCATIONID);
                        axaptaRecord.set_Field("TOWAREHOUSE", vendorWmsLocation.INVENTLOCATIONID);
                        axaptaRecord.set_Field("TOBATCH", item.BatchNo);
                        axaptaRecord.set_Field("TOCONFIG", item.TblColor1.Code);
                        axaptaRecord.set_Field("TRANSTYPE", Convert.ToInt64(0));
                        axaptaRecord.set_Field("JOURNALLINKID", item.TblIssueJournalHeader);
                        axaptaRecord.set_Field("TransactionGuid", transactionGuid);
                        axaptaRecord.Insert();
                    }
                }
            }
        }
示例#8
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;
        }
示例#9
0
        private void ReceivepackingSlip(int Iserial, int userIserial)
        {
            var axapta          = new Axapta();
            var transactionGuid = Guid.NewGuid().ToString();
            var credential      = new NetworkCredential("bcproxy", "around1");
            var header          = new TblPurchaseReceiveHeader();

            using (var model = new WorkFlowManagerDBEntities())
            {
                header =
                    model.TblPurchaseReceiveHeaders.Include("TblPurchaseOrderHeaderRequest1")
                    .Include("TblPurchaseReceiveDetails.TblPurchaseOrderDetailRequest1")
                    .FirstOrDefault(w => w.Iserial == Iserial);

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

                var warehouse = model.TblWarehouses.FirstOrDefault(w => w.Iserial == header.TblWarehouse);
                if (userToLogin != null)
                {
                    axapta.LogonAs(userToLogin.User_Win_Login, userToLogin.User_Domain, credential, "Ccm", null, null, null);
                }
                const string tableName    = "AutoPICKING";
                var          axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                foreach (var variable in header.TblPurchaseReceiveDetails)
                {
                    var color = model.TblColors.FirstOrDefault(e => e.Iserial == variable.TblPurchaseOrderDetailRequest1.FabricColor).Code;

                    var purchdim = model.PurchlineInventDimWithoutRecs.Where(w => w.ITEMID == variable.TblPurchaseOrderDetailRequest1.ItemId &&
                                                                             w.CONFIGID == color && w.PURCHID == header.TblPurchaseOrderHeaderRequest1.AxPurchase);

                    if (variable.TblPurchaseOrderDetailRequest1.BatchNo != null)
                    {
                        purchdim = purchdim.Where(x => x.INVENTBATCHID == variable.TblPurchaseOrderDetailRequest1.BatchNo);
                    }
                    if (variable.TblPurchaseOrderDetailRequest1.Size != null)
                    {
                        purchdim = purchdim.Where(x => x.INVENTSIZEID == variable.TblPurchaseOrderDetailRequest1.Size);
                    }
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();
                    axaptaRecord.set_Field("DATAAREAID", "Ccm");
                    axaptaRecord.set_Field("TransactionGuid", transactionGuid);
                    axaptaRecord.set_Field("FABRICLOCATION", warehouse.Code);
                    axaptaRecord.set_Field("QTY", Convert.ToDecimal(variable.Qty));
                    axaptaRecord.set_Field("WORKFLOWJOURID", header.Iserial);
                    axaptaRecord.set_Field("LineNum", purchdim.OrderByDescending(w => w.LINENUM).FirstOrDefault().LINENUM);
                    axaptaRecord.Insert();
                }
            }
            CreatePackingSlip(header.DocCode + "_" + header.RefNo, header.TblPurchaseOrderHeaderRequest1.AxPurchase, transactionGuid, userIserial);
        }
示例#10
0
        /// <summary>
        /// Login to AX using current User Identity
        /// </summary>
        private void AxLogin()
        {
            string company       = ConfigurationManager.AppSettings["Ax_Company"];
            string configuration = ConfigurationManager.AppSettings["Ax_Configuration"];

            Ax = new Axapta();

            string[] array = userIdentity.Name.Split(new char[] { '\\' });
            Ax.LogonAs(array[1], array[0], null, company, "", "", configuration);

#if DEBUG
            Ax.Refresh();
#endif
        }
        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));
        }
示例#12
0
        public Axapta AxaptaObject()
        {
            try
            {
                var nc = new NetworkCredential(UserName, Password, Domain);
                Ax = new Axapta();
                Ax.LogonAs(UserName, Domain, nc, Company, "", Aos, "");
            }
            catch (Exception ex)
            {
                Ax = null;
                throw ex;
            }

            return(Ax);
        }
示例#13
0
        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
        private void TerminateEmp(string emp)
        {
            if (SharedOperation.UseAx())
            {
                var Axapta     = new Axapta();
                var credential = new NetworkCredential("bcproxy", "around1");
                Axapta.LogonAs("Osama.Gamal", "ccasual.loc", credential, "Ccm", "", "", "");
                var AxaptaRecord = Axapta.CreateAxaptaRecord("EMPLTABLE");
                AxaptaRecord.Clear();
                AxaptaRecord.InitValue();

                AxaptaRecord.ExecuteStmt("select forupdate * from %1 where %1.Emplid == '" + emp + "");
                if (AxaptaRecord.Found)
                {
                    AxaptaRecord.set_Field("CSPPeriodID", "2012");
                    AxaptaRecord.Update();
                    Axapta.TTSCommit();
                }
            }
        }
示例#16
0
        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();
        }
示例#17
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"));
            }
        }
示例#18
0
        /// <summary>
        /// Login to AX using credentials specified in the web.config
        /// </summary>
        private void AxLoginAs()
        {
            ConfigurationBase cb = ConfigurationProvider.getConfiguration();

            string Ax_UserName        = cb.getStringValue("Ax_UserName");
            string Ax_UserDomain      = cb.getStringValue("Ax_UserDomain");
            string company            = cb.getStringValue("Ax_Company");
            string configuration      = cb.getStringValue("Ax_Configuration");
            string Ax_ProxyUserName   = cb.getStringValue("Ax_ProxyUserName");
            string Ax_ProxyUserPwd    = cb.getStringValue("Ax_ProxyUserPwd");
            string Ax_ProxyUserDomain = cb.getStringValue("Ax_ProxyUserDomain");

            NetworkCredential nc = new NetworkCredential(Ax_ProxyUserName, Ax_ProxyUserPwd, Ax_ProxyUserDomain);

            Ax = new Axapta();

            Ax.LogonAs(Ax_UserName, Ax_UserDomain, nc, company, "", "", configuration);

#if DEBUG
            Ax.Refresh();
#endif
        }
示例#19
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;
        }
示例#20
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;
        }
示例#21
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;
        }
示例#22
0
        /// <summary>
        /// Login to AX using credentials specified in the web.config
        /// </summary>
        private void AxLoginAs()
        {
            ConfigurationBase cb = ConfigurationProvider.getConfiguration();

            string Ax_UserName = cb.getStringValue("Ax_UserName");
            string Ax_UserDomain = cb.getStringValue("Ax_UserDomain");
            string company = cb.getStringValue("Ax_Company");
            string configuration = cb.getStringValue("Ax_Configuration");
            string Ax_ProxyUserName = cb.getStringValue("Ax_ProxyUserName");
            string Ax_ProxyUserPwd = cb.getStringValue("Ax_ProxyUserPwd");
            string Ax_ProxyUserDomain = cb.getStringValue("Ax_ProxyUserDomain");

            NetworkCredential nc = new NetworkCredential(Ax_ProxyUserName, Ax_ProxyUserPwd, Ax_ProxyUserDomain);

            Ax = new Axapta();

            Ax.LogonAs(Ax_UserName, Ax_UserDomain, nc, company, "", "", configuration);

            #if DEBUG
            Ax.Refresh();
            #endif
        }
示例#23
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();
                }
            }
        }
示例#24
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;
        }
示例#25
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;
        }
示例#26
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;
            }
        }
示例#27
0
        private Axapta Login()
        {
            var ax = new Axapta();
            var adUser = "******";
            var adPass = "******";
            var aos = "ContosoSample2@CDAX01:2714";
            aos = "CandyDirectAx@CDAX01:2715";

            if(adUser == null || adPass == null)
                throw new ArgumentNullException("AxUserName or AxUserPass is missing from <appsettings> in the config file");

            if(aos == null)
                throw new ArgumentNullException("AxObjectServer is missing from <appsettings> in the config file. Sample: 'company1@AOS:2713'");

            System.Net.NetworkCredential creds = new System.Net.NetworkCredential(
                adUser,adPass, "candydirect.com");
                ax.LogonAs(adUser,"candydirect.com",creds,null,null,aos,null);
            //ax.Logon(null, null, null, null);
            return ax;
        }
示例#28
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();
                    }
                }
            }
        }
示例#29
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;
                }
            }
        }
示例#30
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;
        }
示例#31
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;
        }
示例#32
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;
        }
示例#33
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;
        }
示例#34
0
        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();
                }
            }
        }
示例#35
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;
        }
示例#36
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);
            }
        }
示例#37
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;
        }
示例#38
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();
                    }
                }
            }
        }
示例#39
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;
        }
示例#40
0
        public Axapta Login()
        {
            var ax = new Axapta();
            var adUser = System.Configuration.ConfigurationManager.AppSettings["AxUserName"];
            var adPass = System.Configuration.ConfigurationManager.AppSettings["AxUserPass"];
            var aos = System.Configuration.ConfigurationManager.AppSettings["AxObjectServer"];
            if(adUser == null || adPass == null)
                throw new ArgumentNullException("AxUserName or AxUserPass is missing from <appsettings> in the config file");

            if(aos == null)
                throw new ArgumentNullException("AxObjectServer is missing from <appsettings> in the config file. Sample: 'company1@AOS:2713'");

            System.Net.NetworkCredential creds = new System.Net.NetworkCredential(
                adUser,adPass, "candydirect.com");
                ax.LogonAs(adUser,"candydirect.com",creds,null,null,aos,null);
            //ax.Logon(null, null, null, null);
            return ax;
        }
示例#41
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();
            }
        }
示例#42
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;
        }
示例#43
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();
        }
示例#44
0
        public void InsertFabItem(tbl_FabricAttriputes objToPost, string categoryName, string fabricType, int userIserial)
        {
            var axapta = new Axapta();

            try
            {
                using (var context = new WorkFlowManagerDBEntities())
                {
                    var credential = new NetworkCredential("bcproxy", "around1");
                    var user       = context.TblAuthUsers.FirstOrDefault(x => x.Iserial == userIserial);

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

                    axapta.TTSBegin();
                    var itemId    = objToPost.FabricID;
                    var tableName = "InventTable";

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

                    if (fabricType != null)
                    {
                        axaptaRecord.set_Field("ItemGroupId",
                                               fabricType.ToUpper() == "KNITTED"
                                ? "KNITTED-FABRIC"
                                : "FINISHED-FABRIC");
                    }
                    else
                    {
                        axaptaRecord.set_Field("ItemGroupId",
                                               categoryName.ToUpper() == "FINISHED"
                                ? "FINISHED-FABRIC"
                                : categoryName.ToUpper() == "RAW"
                                    ? "KNITTED-FABRIC"
                                    : categoryName == "DYINGWOVEN"
                                        ? "FINISHED-FABRIC"
                                        : categoryName == "DYINGKNITED"
                                            ? "FINISHED-FABRIC"
                                            : categoryName == "Accessories"
                                                ? "ACCESSORIES"
                                                : "YARN"
                                               );
                    }
                    if (objToPost.Notes != null)
                    {
                        axaptaRecord.set_Field("Notes", objToPost.Notes);
                    }
                    axaptaRecord.set_Field("ItemId", itemId);
                    axaptaRecord.set_Field("ItemName", objToPost.FabricDescription);
                    axaptaRecord.set_Field("ModelGroupID", "STD");
                    axaptaRecord.set_Field("ItemType",
                                           categoryName.ToUpper() == "FINISHED"
                            ? 0
                            : categoryName.ToUpper() == "RAW"
                                ? 1
                                : categoryName.ToUpper() == "DYINGWOVEN"
                                    ? 1
                                    : categoryName.ToUpper() == "DYINGKNITED"
                                        ? 1
                                        : 0);

                    if (objToPost.DyingClassificationID != null)
                    {
                        //DyedGroup
                        axaptaRecord.set_Field("DyedGroup", objToPost.DyingClassificationID.ToString());
                    }
                    axaptaRecord.set_Field("DimGroupId", "FABRIC");
                    //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);
                    axaptaRecord.set_Field("Price", 0.00);
                    if (objToPost.UoMID != null)
                    {
                        var tempu = context.tbl_lkp_UoM
                                    .Where(x => x.Iserial == objToPost.UoMID)
                                    .Select(x => x.Ename)
                                    .SingleOrDefault();
                        axaptaRecord.set_Field("UnitId", tempu);
                        //axaptaRecord.set_Field("PriceUnit", tempu);
                    }
                    //
                    axaptaRecord.Insert();

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

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

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

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

                    tableName = "InventItemLocation";

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

                    axaptaRecord.set_Field("ItemId", itemId);
                    axaptaRecord.set_Field("InventDIMID", "AllBlank");
                    axaptaRecord.Insert();
                    try
                    {
                        tableName    = "ConfigTable";
                        axaptaRecord = axapta.CreateAxaptaRecord(tableName);
                        axaptaRecord.Clear();
                        axaptaRecord.InitValue();

                        axaptaRecord.set_Field("ItemId", itemId);
                        axaptaRecord.set_Field("ConfigId", "Free");
                        axaptaRecord.set_Field("Name", "Free");
                        //Commit the record to the database.
                        axaptaRecord.Insert();
                    }
                    catch
                    {
                        //if record exists do nothing and continue
                    }

                    // Commit the record to the database.
                    var categ = (from x in context.tbl_FabricCategories
                                 where x.Iserial == objToPost.FabricCategoryID
                                 select x).FirstOrDefault();
                    if (categ != null)
                    {
                        try
                        {
                            axapta.CallStaticRecordMethod("TblFabricCategory", "findOrCreate", categ.Iserial, categ.Code,
                                                          categ.Ename, categ.Aname);
                        }
                        catch
                        {
                            //if record exists do nothing and continue
                        }
                    }

                    var temp = (from x in context.tbl_FabricAttriputes
                                .Include("tbl_lkp_FabricDesignes").Include("tbl_lkp_FabricFinish").Include("tbl_lkp_FabricMaterials")
                                .Include("tbl_lkp_FabricStructure").Include("tbl_lkp_FabricTypes").Include("tbl_lkp_Inch").Include("tbl_lkp_Gauges")
                                .Include("tbl_lkp_ThreadNumbers").Include("tbl_lkp_YarnSource").Include("tbl_lkp_YarnCount").Include("tbl_lkp_YarnFinish")
                                .Include("tbl_lkp_YarnStatus")
                                where x.FabricCategoryID == objToPost.FabricCategoryID &&
                                x.FabricID == objToPost.FabricID
                                select x).FirstOrDefault();

                    if (temp != null)
                    {
                        if (temp.tbl_lkp_FabricDesignes != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblFabricDesign", "findOrCreate", temp.tbl_lkp_FabricDesignes.Iserial, temp.tbl_lkp_FabricDesignes.Code,
                                                              temp.tbl_lkp_FabricDesignes.Ename, temp.tbl_lkp_FabricDesignes.Aname);
                            }
                            catch
                            {
                            }
                        }

                        if (temp.tbl_lkp_FabricFinish != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblFabricFinish", "findOrCreate", temp.tbl_lkp_FabricFinish.Iserial, temp.tbl_lkp_FabricFinish.Code,
                                                              temp.tbl_lkp_FabricFinish.Ename, temp.tbl_lkp_FabricFinish.Aname);
                            }
                            catch
                            {
                            }
                        }
                        if (temp.tbl_lkp_FabricMaterials != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblFabricMaterial", "findOrCreate", temp.tbl_lkp_FabricMaterials.Iserial, temp.tbl_lkp_FabricMaterials.Code,
                                                              temp.tbl_lkp_FabricMaterials.Ename, temp.tbl_lkp_FabricMaterials.Aname);
                            }
                            catch
                            {
                            }
                        }

                        if (temp.tbl_lkp_FabricStructure != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblFabricStructure", "findOrCreate", temp.tbl_lkp_FabricStructure.Iserial, temp.tbl_lkp_FabricStructure.Code,
                                                              temp.tbl_lkp_FabricStructure.Ename, temp.tbl_lkp_FabricStructure.Aname);
                            }
                            catch
                            {
                            }
                        }

                        if (temp.tbl_lkp_FabricTypes != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblFabricType", "findOrCreate", temp.tbl_lkp_FabricTypes.Iserial, temp.tbl_lkp_FabricTypes.Code,
                                                              temp.tbl_lkp_FabricTypes.Ename, temp.tbl_lkp_FabricTypes.Aname);
                            }
                            catch
                            {
                            }
                        }

                        if (temp.tbl_lkp_Inch != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblInch", "findOrCreate", temp.tbl_lkp_Inch.Iserial, temp.tbl_lkp_Inch.Code,
                                                              temp.tbl_lkp_Inch.Ename, temp.tbl_lkp_Inch.Aname);
                            }
                            catch
                            {
                            }
                        }

                        if (temp.tbl_lkp_Gauges != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblGuage", "findOrCreate", temp.tbl_lkp_Gauges.Iserial, temp.tbl_lkp_Gauges.Code,
                                                              temp.tbl_lkp_Gauges.Ename, temp.tbl_lkp_Gauges.Aname);
                            }
                            catch
                            {
                            }
                        }
                        if (temp.tbl_lkp_ThreadNumbers != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblThread", "findOrCreate", temp.tbl_lkp_ThreadNumbers.Iserial, temp.tbl_lkp_ThreadNumbers.Code,
                                                              temp.tbl_lkp_ThreadNumbers.Ename, temp.tbl_lkp_ThreadNumbers.Aname);
                            }
                            catch
                            {
                            }
                        }

                        if (temp.tbl_lkp_YarnSource != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblYarnSource", "findOrCreate", temp.tbl_lkp_YarnSource.Iserial, temp.tbl_lkp_YarnSource.Code,
                                                              temp.tbl_lkp_YarnSource.Ename, temp.tbl_lkp_YarnSource.Aname);
                            }
                            catch
                            {
                            }
                        }

                        if (temp.tbl_lkp_YarnCount != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblYarnCount", "findOrCreate", temp.tbl_lkp_YarnCount.Iserial, temp.tbl_lkp_YarnCount.Code,
                                                              temp.tbl_lkp_YarnCount.Ename, temp.tbl_lkp_YarnCount.Aname);
                            }
                            catch
                            {
                            }
                        }

                        if (temp.tbl_lkp_YarnFinish != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblYarnFinish", "findOrCreate", temp.tbl_lkp_YarnFinish.Iserial, temp.tbl_lkp_YarnFinish.Code,
                                                              temp.tbl_lkp_YarnFinish.Ename, temp.tbl_lkp_YarnFinish.Aname);
                            }
                            catch
                            {
                            }
                        }

                        if (temp.tbl_lkp_YarnStatus != null)
                        {
                            try
                            {
                                axapta.CallStaticRecordMethod("TblYarnStatus", "findOrCreate", temp.tbl_lkp_YarnStatus.Iserial, temp.tbl_lkp_YarnStatus.Code,
                                                              temp.tbl_lkp_YarnStatus.Ename, temp.tbl_lkp_YarnStatus.Aname);
                            }
                            catch
                            {
                            }
                        }

                        axapta.CallStaticRecordMethod("TblFabricDetail", "findOrCreate", temp.FabricID, temp.YarnStatusID ?? 0, temp.YarnFinishesID ?? 0, temp.YarnCountID ?? 0, temp.YarnSource ?? 0, temp.ThreadNumbersID ?? 0, temp.GaugesID ?? 0,
                                                      temp.InchesID ?? 0, temp.FabricTypesID ?? 0, temp.FabricStructuresID ?? 0, temp.FabricMaterialsID ?? 0, temp.FabricFinishesID ?? 0, temp.FabricDesignsID ?? 0, temp.FabricCategoryID
                                                      );

                        temp.Status = 2;
                    }

                    context.SaveChanges();
                    axapta.TTSCommit();
                }
            }
            catch (Exception ex)
            {
                axapta.TTSAbort();
                throw ex;
            }
        }
示例#45
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;
        }
示例#46
0
        public bool DeleteAxFabItem(tbl_FabricAttriputes objToPost, bool deleteColors, int userIserial)
        {
            var axapta = new Axapta();

            try
            {
                var credential = new NetworkCredential("bcproxy", "around1");
                var user       = new TblAuthUser();
                using (var context = new WorkFlowManagerDBEntities())
                {
                    user = context.TblAuthUsers.FirstOrDefault(x => x.Iserial == userIserial);
                }

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

                axapta.TTSBegin();
                var          itemId = objToPost.FabricID;
                AxaptaRecord axaptaRecord;

                var tableName = "InventTable";
                using (axaptaRecord = axapta.CreateAxaptaRecord(tableName))
                {
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();

                    // Execute a query to retrieve an editable record where the StatGroupName is “High Priority Customer”.
                    axaptaRecord.ExecuteStmt("select forupdate * from %1 where %1.ItemId =='" + itemId + "'");
                    // If the record is found then delete the record.
                    if (axaptaRecord.Found)
                    {
                        // Start a transaction that can be committed.
                        axapta.TTSBegin();
                        if (objToPost.Notes != null)
                        {
                            axaptaRecord.set_Field("Notes", objToPost.Notes);
                        }
                        // Commit the transaction.
                        axapta.TTSCommit();
                    }
                }

                //tableName = "TblFabricDetail";
                //using (axaptaRecord = axapta.CreateAxaptaRecord(tableName))
                //{
                //    axaptaRecord.Clear();
                //    axaptaRecord.InitValue();

                //    // Execute a query to retrieve an editable record where the StatGroupName is “High Priority Customer”.
                //    axaptaRecord.ExecuteStmt("select forupdate * from %1 where %1.ItemId =='" + itemId + "'");
                //    // If the record is found then delete the record.
                //    if (axaptaRecord.Found)
                //    {
                //        // Start a transaction that can be committed.
                //        axapta.TTSBegin();
                //        if (objToPost.Notes != null) axaptaRecord.set_Field("Notes", objToPost.Notes);
                //        // Commit the transaction.
                //        axapta.TTSCommit();
                //    }
                //}
                tableName = "INVENTTRANS";
                bool inventTransExists = false;
                using (axaptaRecord = axapta.CreateAxaptaRecord(tableName))
                {
                    axaptaRecord.Clear();
                    axaptaRecord.InitValue();

                    // Execute a query to retrieve an editable record where the StatGroupName is “High Priority Customer”.
                    axaptaRecord.ExecuteStmt("select  * from %1 where %1.ItemId =='" + itemId + "'");
                    // If the record is found then delete the record.
                    if (axaptaRecord.Found)
                    {
                        return(inventTransExists = true);
                    }
                }
                if (!inventTransExists)
                {
                    tableName = "InventTableModule";
                    using (axaptaRecord = axapta.CreateAxaptaRecord(tableName))
                    {
                        axaptaRecord.Clear();
                        axaptaRecord.InitValue();

                        // Execute a query to retrieve an editable record where the StatGroupName is “High Priority Customer”.
                        axaptaRecord.ExecuteStmt("select forupdate * from %1 where %1.ItemId =='" + itemId + "'");
                        // If the record is found then delete the record.
                        if (axaptaRecord.Found)
                        {
                            // Start a transaction that can be committed.
                            axapta.TTSBegin();
                            axaptaRecord.Delete();
                            // Commit the transaction.
                            axapta.TTSCommit();
                        }
                    }

                    tableName = "InventItemLocation";

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

                        // Execute a query to retrieve an editable record where the StatGroupName is “High Priority Customer”.
                        axaptaRecord.ExecuteStmt("select forupdate * from %1 where %1.ItemId =='" + itemId + "'");
                        // If the record is found then delete the record.
                        if (axaptaRecord.Found)
                        {
                            // Start a transaction that can be committed.
                            axapta.TTSBegin();
                            axaptaRecord.Delete();
                            // Commit the transaction.
                            axapta.TTSCommit();
                        }
                    }

                    if (deleteColors)
                    {
                        tableName = "ConfigTable";
                        using (axaptaRecord = axapta.CreateAxaptaRecord(tableName))
                        {
                            axaptaRecord.Clear();
                            axaptaRecord.InitValue();

                            // Execute a query to retrieve an editable record where the StatGroupName is “High Priority Customer”.
                            axaptaRecord.ExecuteStmt("select forupdate * from %1 where %1.ItemId =='" + itemId + "'");
                            // If the record is found then delete the record.
                            if (axaptaRecord.Found)
                            {
                                // Start a transaction that can be committed.
                                axapta.TTSBegin();
                                axaptaRecord.Delete();
                                // Commit the transaction.
                                axapta.TTSCommit();
                            }
                        }
                    }

                    tableName = "InventTable";
                    using (axaptaRecord = axapta.CreateAxaptaRecord(tableName))
                    {
                        axaptaRecord.Clear();
                        axaptaRecord.InitValue();

                        // Execute a query to retrieve an editable record where the StatGroupName is “High Priority Customer”.
                        axaptaRecord.ExecuteStmt("select forupdate * from %1 where %1.ItemId =='" + itemId + "'");
                        // If the record is found then delete the record.
                        if (axaptaRecord.Found)
                        {
                            // Start a transaction that can be committed.
                            axapta.TTSBegin();
                            axaptaRecord.Delete();
                            // Commit the transaction.
                            axapta.TTSCommit();
                        }
                    }
                    // Commit the record to the database.
                    axapta.TTSCommit();
                }
            }
            catch (Exception ex)
            {
                axapta.TTSAbort();
                throw ex;
            }
            return(false);
        }
示例#47
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;
        }
示例#48
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;
        }
示例#49
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();
            }
        }
示例#50
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;
        }
示例#51
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;
                }
            }
        }
示例#52
0
        /// <summary>
        /// Login to AX using current User Identity
        /// </summary>
        private void AxLogin()
        {
            string company          = ConfigurationManager.AppSettings["Ax_Company"];
            string configuration    = ConfigurationManager.AppSettings["Ax_Configuration"];

            Ax = new Axapta();

            string[] array = userIdentity.Name.Split(new char[] { '\\' });
            Ax.LogonAs(array[1], array[0], null, company, "", "", configuration);

            #if DEBUG
            Ax.Refresh();
            #endif
        }