コード例 #1
0
        // GET /Download/InvoicePath
        public ContentResult InvoicePath(string companyid, string invoiceid, string invoiceType)
        {
            string filePath  = "";
            string sessionId = "";
            Axapta axESP     = new Axapta();

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

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

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

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

            return(Content(filePath));
        }
コード例 #2
0
        public ContentResult OrderConfirmationPath(string companyId, string orderConfirmation)
        {
            string filePath  = "";
            string sessionId = "";
            Axapta axDB1     = new Axapta();

            System.Net.NetworkCredential ncDB1 = new System.Net.NetworkCredential("EP_AX2012", "VendTable1", "RIWAL01");
            axDB1.LogonAs(ConfigurationManager.AppSettings["User"], ConfigurationManager.AppSettings["Domain"], ncDB1, companyId, ConfigurationManager.AppSettings["Language"], ConfigurationManager.AppSettings["AOS"], "");
            sessionId = axDB1.CallStaticClassMethod("LNIDocuAction", "SessionId").ToString();
            System.IO.File.Delete(@"\\Lasernet2\OUT\Batch\" + sessionId + "_" + companyId + "_Confirmation_AX40_DB1_Live.pdf");
            filePath = axDB1.CallStaticClassMethod("LNIDocuAction", "PrintDocumentExternal_Confirm", orderConfirmation).ToString();
            axDB1.Logoff();
            return(Content(filePath));
        }
コード例 #3
0
        public List <IntershopWebService.ProductPrice> GetItemsPrice(List <IntershopWebService.ProductPriceIn> products, string company, string customerID)
        {
            Stopwatch stopwatch = new Stopwatch();

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

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

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

            IntershopWebService.ProductPrice productPrice = new IntershopWebService.ProductPrice();
            try
            {
                double num = Convert.ToDouble(ax.CallStaticClassMethod("BTX_ISHItemDescriptionProxy", "GetSalesPrice", new object[4]
                {
                    (object)customerID,
                    (object)itemId,
                    (object)Unit,
                    (object)""
                }));
                productPrice.itemId      = itemId;
                productPrice.price       = num;
                productPrice.miscCharges = this.ExtractMiscCharges(ax, productPrice.itemId, customerID, productPrice.price, 1, Unit);
                stopwatch.Stop();
                MessageLogger.info(string.Format("GetItemPrice({0}, {1}, {2}, {3}) -> {4} , exec time -> {5} ms", (object)itemId, (object)customerID, (object)Unit, (object)company, (object)productPrice.price, (object)stopwatch.ElapsedMilliseconds));
                return(productPrice);
            }
            catch (Exception ex)
            {
                return((IntershopWebService.ProductPrice)null);
            }
            finally
            {
                ax.Logoff();
            }
        }
コード例 #5
0
        public List <IntershopWebService.ProductStock> GetItemsStock(List <IntershopWebService.ProductStockIn> products, string company)
        {
            Stopwatch stopwatch = new Stopwatch();

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

            try
            {
                axapta = this.axLogon(company);
                foreach (IntershopWebService.ProductStockIn product in products)
                {
                    string str = Convert.ToString(axapta.CallStaticClassMethod("BTX_ISHItemDescriptionProxy", "GetOnHandUrl", (object)product.itemId, (object)string.Empty));
                    IntershopWebService.ProductStock productStock = new IntershopWebService.ProductStock();
                    productStock.itemId     = product.itemId;
                    productStock.stockLevel = str;
                    productStockList.Add(productStock);
                    stopwatch.Stop();
                    MessageLogger.info(string.Format("GetItemsStock({0}, {1}, {2}, {3}) -> {4} , exec time -> {5} ms", (object)product.itemId, (object)product.size, (object)product.color, (object)company, (object)productStock.stockLevel, (object)stopwatch.ElapsedMilliseconds));
                }
                return(productStockList);
            }
            catch (Exception ex)
            {
                return((List <IntershopWebService.ProductStock>)null);
            }
            finally
            {
                axapta.Logoff();
            }
        }
コード例 #6
0
        private List <IntershopWebService.MiscCharge> ExtractMiscCharges(Axapta ax, string itemId, string custAccount, double salesPrice, int qty, string inventSizeId, string unit)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            IEnumerator enumerator1 = ((AxaptaContainer)ax.CallStaticClassMethod("BTX_ISHItemDescriptionProxy", "GetMiscCharges", new object[6]
            {
                (object)custAccount,
                (object)itemId,
                (object)salesPrice,
                (object)qty,
                (object)inventSizeId,
                (object)unit
            })).GetEnumerator();
            List <IntershopWebService.MiscCharge> miscChargeList = new List <IntershopWebService.MiscCharge>();

            if (enumerator1.MoveNext())
            {
                double current = (double)enumerator1.Current;
            }
            if (enumerator1.MoveNext())
            {
                IEnumerator enumerator2 = ((AxaptaContainer)enumerator1.Current).GetEnumerator();
                IntershopWebService.MiscCharge miscCharge = new IntershopWebService.MiscCharge();
                while (enumerator2.MoveNext())
                {
                    IEnumerator enumerator3 = ((AxaptaContainer)enumerator2.Current).GetEnumerator();
                    int         num         = 0;
                    while (enumerator3.MoveNext())
                    {
                        switch (num++)
                        {
                        case 0:
                            miscCharge.code = (string)enumerator3.Current;
                            break;

                        case 1:
                            miscCharge.description = (string)enumerator3.Current;
                            break;

                        case 2:
                            miscCharge.value = Math.Round(Convert.ToDouble(enumerator3.Current), 2);
                            break;

                        case 3:
                            miscCharge.currency = (string)enumerator3.Current;
                            break;
                        }
                    }
                    miscChargeList.Add(miscCharge);
                }
            }
            stopwatch.Stop();
            MessageLogger.info(string.Format("ExtractMiscCharges({0}, {1}, {2}, {3}, {4}, {5}) -> {6} ms", (object)itemId, (object)custAccount, (object)salesPrice, (object)qty, (object)inventSizeId, (object)unit, (object)stopwatch.ElapsedMilliseconds));
            return(miscChargeList);
        }
コード例 #7
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;
        }
コード例 #8
0
        public IntershopWebService.TotalDetails OrderTotalAmountDetails(string customerID, List <IntershopWebService.IshOrderLine> orderLines, string IshBasketID, string company)
        {
            MessageLogger.info(string.Format("OrderTotalAmountDetails(company={0}, customerID={1})", (object)company, (object)customerID));
            Stopwatch stopwatch = new Stopwatch();

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

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

            using (Axapta ax = AxaptaInstanceContainer.GetInstance(userName, new SecurityHelper().Decrypt(password, true), domain, ""))
            {
                List <WorkType> list = new List <WorkType>();
                if (companies != null && companies.Length > 0)
                {
                    using (AxaptaRecord workflowWorkItemTableRecord = ax.CreateAxaptaRecord("WorkflowWorkItemTable"))
                    {
                        using (AxaptaRecord workflowTrackingStatusTableRecord = ax.CreateAxaptaRecord("WorkflowTrackingStatusTable"))
                        {
                            string query = "select RecId from %1 " +
                                           "where %1.UserId == curUserId() && %1.Status == WorkflowWorkItemStatus::Pending " +
                                           "join DocumentType, ContextTableId, count(RecId) from %2 group by DocumentType, ContextTableId " +
                                           "where %1.CorrelationId == %2.CorrelationId " +
                                           "&& %2.TrackingStatus == WorkflowTrackingStatus::Pending";

                            ax.ExecuteStmt(query, workflowWorkItemTableRecord, workflowTrackingStatusTableRecord);
                            string axRecCount = ax.ToString();
                            while (workflowWorkItemTableRecord.Found == true)
                            {
                                string empty = string.Empty;
                                if (workflowTrackingStatusTableRecord.Found == true)
                                {
                                    empty = workflowTrackingStatusTableRecord.get_Field("ContextTableId").ToString();
                                }
                                if (DataAreaIncluding.Check(empty, companies))
                                {
                                    object contextTableId = workflowTrackingStatusTableRecord.get_Field("ContextTableId");
                                    object documentType   = workflowTrackingStatusTableRecord.get_Field("DocumentType");
                                    object recId          = workflowTrackingStatusTableRecord.get_Field("RecId");
                                    object tblName        = ax.CallStaticClassMethod("Global", "tableId2Name", recId);

                                    list.Add(new WorkType()
                                    {
                                        WorkTypeName = documentType.ToString(), WorkTypeCount = Convert.ToInt32(recId)
                                    });
                                    workflowWorkItemTableRecord.Next();
                                }
                            }
                        }
                    }
                }
                return(Json(list, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #10
0
ファイル: BusinessLogic.cs プロジェクト: MaKeBits/AxRest
        static void Main(string[] args)
        {
            // Create the .NET Business Connector objects.
            Axapta ax;
            string sID = "@SYS21669";
            object o;
            bool b;

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

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

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

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

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

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

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

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

            // Log off from Microsoft Dynamics AX.
            b = ax.Logoff();
        }
コード例 #12
0
        public string GetItemStockSize(string itemId, string size, string company)
        {
            Stopwatch stopwatch = new Stopwatch();

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

            try
            {
                axapta = this.axLogon(company);
                object obj = axapta.CallStaticClassMethod("BTX_ISHItemDescriptionProxy", "GetOnHandUrl", (object)itemId, (object)size);
                stopwatch.Stop();
                MessageLogger.info(string.Format("GetItemStock({0}, {1}, {2}) -> {3} , exec time -> {5} ms", (object)itemId, (object)size, (object)company, (object)Convert.ToString(obj), (object)stopwatch.ElapsedMilliseconds));
                return(Convert.ToString(obj));
            }
            catch (Exception ex)
            {
                return("An error occured: " + ex.Message);
            }
            finally
            {
                axapta.Logoff();
            }
        }
コード例 #13
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;
        }
コード例 #14
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;
        }
コード例 #15
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;
        }
コード例 #16
0
ファイル: IssueJournal.cs プロジェクト: Osama91/CCWFM
        private void IssueJournalTransfer(TblIssueJournalHeader row, int userIserial)
        {
            using (var entities = new WorkFlowManagerDBEntities())
            {
                if (SharedOperation.UseAx())
                {
                    var          transactionGuid   = Guid.NewGuid().ToString();
                    var          vendorWmsLocation = entities.GetWmsLocations.SingleOrDefault(x => x.VENDID == row.Vendor);
                    const string tableName         = "PRODCONNECTION";
                    var          vendorLoc         = entities.GetLocations.SingleOrDefault(x => x.INVENTLOCATIONID == vendorWmsLocation.INVENTLOCATIONID);
                    var          axapta            = new Axapta();
                    var          credential        = new NetworkCredential("bcproxy", "around1");
                    var          detail            = entities.TblIssueJournalDetails.Where(w => w.TblIssueJournalHeader == row.Iserial).ToList();

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

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

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

                    SharedOperation.ClearAxTable("PRODCONNECTION", axapta, transactionGuid);
                    axapta.Logoff();
                }
                else
                {
                    row.AxTransaction = "1111";
                    row.IsPosted      = true;
                    entities.SaveChanges();
                }
            }
        }
コード例 #17
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;
        }
コード例 #18
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;
        }
コード例 #19
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;
        }
コード例 #20
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;
        }
コード例 #21
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;
        }
コード例 #22
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;
        }
コード例 #23
0
        public List <IntershopWebService.ProductStock> GetItemsStockSize(List <IntershopWebService.ProductStockIn> products, string company)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

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

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

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

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

                return((List <IntershopWebService.ProductStock>)null);
            }
            finally
            {
                axapta.Logoff();
            }
        }
コード例 #24
0
        public List <IntershopWebService.ProductPrice> GetItemsPriceSize(List <IntershopWebService.ProductPriceIn> products, string company, string customerID)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            Axapta ax = null;

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

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

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

                return((List <IntershopWebService.ProductPrice>)null);
            }
            finally
            {
                ax.Logoff();
            }
        }
コード例 #25
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;
        }
コード例 #26
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;
        }
コード例 #27
0
        public IntershopWebService.TrackInfo GetTrackInfo(string company, string customerID, string salesID)
        {
            MessageLogger.info(string.Format("GetTrackInfo(company={0}, customerID={1}, salesID={2})", (object)company, (object)customerID, (object)salesID));
            Stopwatch stopwatch = new Stopwatch();

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

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

                stopwatch.Stop();
                MessageLogger.info(string.Format("GetTrackInfo() -> {0} ms", (object)stopwatch.ElapsedMilliseconds));
                return(trackInfo);
            }
            catch (Exception ex)
            {
                MessageLogger.info(string.Format("GetTrackInfo() -> error: {0}", (object)ex.Message));
                return((IntershopWebService.TrackInfo)null);
            }
            finally
            {
                axapta.Logoff();
            }
        }
コード例 #28
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;
        }
コード例 #29
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;
        }
コード例 #30
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;
        }
コード例 #31
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;
        }
コード例 #32
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;
        }
コード例 #33
0
 public static int GetTableId(this Axapta ax, string table)
 {
     return((int)ax.CallStaticClassMethod("Global", "tableName2Id", table));
 }