コード例 #1
0
        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);
        }
コード例 #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
ファイル: LeaveApp.cs プロジェクト: HosamKhalifa/ESS
        public void Insert()
        {
            Axapta       ax;
            AxaptaRecord axRecord;

            try
            {
                ax = new Axapta();
                ax.Logon(null, null, null, null);
                using (axRecord = ax.CreateAxaptaRecord(TABLE_NAME))
                {
                    ax.TTSBegin();

                    axRecord.Call("ESS_WriteValues",
                                  this.LeaveApplicationType,
                                  this.EmplId,
                                  this.RequestedBy,
                                  this.ScheduledLeaveDate,
                                  this.ScheduledReturnDate,
                                  this.ApprovalStatus,
                                  this.ExitVisaType,
                                  this.Comments,
                                  this.CommentsApproval);
                    axRecord.Insert();
                    ax.TTSCommit();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw;
            }
        }
コード例 #4
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();
            }
        }
コード例 #5
0
ファイル: LeaveApp.cs プロジェクト: HosamKhalifa/ESS
        public void Update()
        {
            Axapta       ax;
            AxaptaRecord axRecord;

            try
            {
                ax = new Axapta();
                ax.Logon(null, null, null, null);
                using (axRecord = ax.CreateAxaptaRecord(TABLE_NAME))
                {
                    string sql = string.Format("select forupdate * from %1 where %1.{0} == '{1}'", APPLICATION_ID, this.ApplicationId);
                    axRecord.ExecuteStmt(sql);
                    if (axRecord.Found)
                    {
                        ax.TTSBegin();
                        axRecord.set_Field(LEAVE_APP_TYPE, this.LeaveApplicationType);
                        axRecord.set_Field(SCH_LEAVE_DATE, this.ScheduledLeaveDate);
                        axRecord.set_Field(SCH_RETURN_DATE, this.ScheduledReturnDate);
                        axRecord.set_Field(APPROVAL_STATUS, this.ApprovalStatus);
                        axRecord.set_Field(EXIT_VISA_TYPE, this.ExitVisaType);
                        axRecord.set_Field(COMMENTS, this.Comments);
                        axRecord.set_Field(COMMENTS_APPROVAL, this.CommentsApproval);
                        axRecord.Update();
                        ax.TTSCommit();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw;
            }
        }
コード例 #6
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();
            }
        }
コード例 #7
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();
            }
        }
コード例 #8
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"));
            }
        }
コード例 #9
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();
            }
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: pimphongphat/AxRest
        static void Main(string[] args)
        {
            Axapta Ax = new Axapta();

            Ax.Logon(null, null, null, null);
            string className  = "ZFS_TestXML";
            string methodName = "getResultTable";
            string paramList  = null;

            AxaptaObject axObj = Ax.CreateAxaptaObject(className);
            AxaptaRecord ret   = null;

            if (paramList != null)
            {
                ret = (AxaptaRecord)axObj.Call(methodName, paramList);
            }
            else
            {
                ret = (AxaptaRecord)axObj.Call(methodName);
            }

            while (ret.Found)
            {
                ret.get_Field(2);
            }

            axObj.Dispose();
        }
コード例 #11
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);
        }
コード例 #12
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));
        }
コード例 #13
0
            /// <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);
            }
コード例 #14
0
        private void ClearAxTable(string tableName, Axapta axapta)
        {
            var axRecord = axapta.CreateAxaptaRecord(tableName);

            axRecord.Clear();
            axRecord.InitValue();

            using (axRecord = axapta.CreateAxaptaRecord(tableName))
            {
                // Execute a query to retrieve an editable record where the StatGroupName is “High Priority Customer”.

                string query = "select forupdate * from %1";
                //    " %1.WORKFLOWJOURID ==  " + iserial + "";
                axRecord.ExecuteStmt(query);
                // If the record is found then delete the record.
                if (axRecord.Found)
                {
                    // Start a transaction that can be committed.
                    axapta.TTSBegin();
                    axRecord.Delete();
                    // Commit the transaction.
                    axapta.TTSCommit();
                    axRecord.Next();
                }
            }
        }
コード例 #15
0
ファイル: ReadResultTable.cs プロジェクト: MaKeBits/AxRest
    static void Main(string[] args)
    {
        // Create the .NET Business Connector objects.
        Axapta ax;
        AxaptaRecord axRecord;
        string tableName = "LabX_ResultTable";

        // The Table field names for calls to
        // the AxRecord.get_field method.
        string strSampleField = "SampleID";
        string strDescriptionField = "Description";

        // The output variables for calls to the
        // AxRecord.get_Field method.
        object fieldSampleId, fieldDescription;

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

            // Create a query using the AxaptaRecord class
            // for the StateAddress table.
            using (axRecord = ax.CreateAxaptaRecord(tableName))
            {

                // Execute the query on the table.
                axRecord.ExecuteStmt("select * from %1");
                // Create output with a title and column headings
                // for the returned records.
                Console.WriteLine("List of selected records from {0}",
                    tableName);
                Console.WriteLine("{0}\t{1}", strSampleField, strDescriptionField);

                // Loop through the set of retrieved records.
                while (axRecord.Found)
                {
                    // Retrieve the record data for the specified fields.
                    fieldSampleId = axRecord.get_Field(strSampleField);
                    fieldDescription = axRecord.get_Field(strDescriptionField);

                    // Display the retrieved data.
                    Console.WriteLine(fieldSampleId + "\t" + fieldDescription);

                    // Advance to the next row.
                    axRecord.Next();
                }
            }
        }

        catch (Exception e)
        {
            Console.WriteLine("Error encountered: {0}", e.Message);
            // Take other error action as needed.
        }

        Console.Read();
    }
コード例 #16
0
    static void Main(string[] args)
    {
        // Create the .NET Business Connector objects.
        Axapta       ax;
        AxaptaRecord axRecord;
        string       tableName = "LabX_ResultTable";

        // The Table field names for calls to
        // the AxRecord.get_field method.
        string strSampleField      = "SampleID";
        string strDescriptionField = "Description";

        // The output variables for calls to the
        // AxRecord.get_Field method.
        object fieldSampleId, fieldDescription;

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

            // Create a query using the AxaptaRecord class
            // for the StateAddress table.
            using (axRecord = ax.CreateAxaptaRecord(tableName))
            {
                // Execute the query on the table.
                axRecord.ExecuteStmt("select * from %1");
                // Create output with a title and column headings
                // for the returned records.
                Console.WriteLine("List of selected records from {0}",
                                  tableName);
                Console.WriteLine("{0}\t{1}", strSampleField, strDescriptionField);

                // Loop through the set of retrieved records.
                while (axRecord.Found)
                {
                    // Retrieve the record data for the specified fields.
                    fieldSampleId    = axRecord.get_Field(strSampleField);
                    fieldDescription = axRecord.get_Field(strDescriptionField);

                    // Display the retrieved data.
                    Console.WriteLine(fieldSampleId + "\t" + fieldDescription);

                    // Advance to the next row.
                    axRecord.Next();
                }
            }
        }

        catch (Exception e)
        {
            Console.WriteLine("Error encountered: {0}", e.Message);
            // Take other error action as needed.
        }

        Console.Read();
    }
コード例 #17
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);
        }
コード例 #18
0
ファイル: IssueJournal.cs プロジェクト: Osama91/CCWFM
        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();
                    }
                }
            }
        }
コード例 #19
0
 /// <summary>
 ///   Default Constructor.
 ///   <para>
 ///     Creates a new instance of Microsoft.Dynamics.BusinessConnectorNext.Axapta object.
 ///   </para>
 /// </summary>
 /// <exception cref = "AxException">Thrown when an exception occurs trying to create an instance of the Axapta object</exception>
 public AxBusinessConnectorNet()
 {
     try
     {
         _axaptaAdapter = new Axapta();
     }
     catch (AxaptaException exception)
     {
         throw new AxException(string.Format("Can't create Axapta BC object: {0}", exception),
                               exception.InnerException);
     }
 }
コード例 #20
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;
        }
コード例 #21
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();
            }
        }
コード例 #22
0
ファイル: PurchaseOrderRequest.cs プロジェクト: Osama91/CCWFM
        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);
        }
コード例 #23
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));
        }
コード例 #24
0
        private IntershopWebService.TotalDetails extractTotalDetails(Axapta ax, AxaptaContainer totalContainer)
        {
            IEnumerator enumerator = totalContainer.GetEnumerator();

            IntershopWebService.TotalDetails totalDetails = new IntershopWebService.TotalDetails();
            int num = 0;

            while (enumerator.MoveNext())
            {
                switch (num++)
                {
                case 0:
                    totalDetails.IshBasketID = Convert.ToString(enumerator.Current);
                    break;

                case 1:
                    totalDetails.AxBasketID = Convert.ToString(enumerator.Current);
                    break;

                case 2:
                    totalDetails.TotalAmount = Math.Round(Convert.ToDouble(enumerator.Current), 2);
                    break;

                case 3:
                    totalDetails.Currency = Convert.ToString(enumerator.Current);
                    break;

                case 4:
                    totalDetails.TotalNetAmount = Math.Round(Convert.ToDouble(enumerator.Current), 2);
                    break;

                case 5:
                    totalDetails.VatTotal = Math.Round(Convert.ToDouble(enumerator.Current), 2);
                    break;

                case 6:
                    totalDetails.MiscCharges = this.ExtractMiscChargesTotal(ax, (AxaptaContainer)enumerator.Current);
                    break;

                case 7:
                    totalDetails.Discounts = this.ExtractDiscountsTotal(ax, (AxaptaContainer)enumerator.Current);
                    break;

                case 8:
                    totalDetails.OrderLines = this.ExtractOrderLinesTotal(ax, (AxaptaContainer)enumerator.Current);
                    break;
                }
            }
            return(totalDetails);
        }
コード例 #25
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
        }
コード例 #26
0
ファイル: LeaveApp.cs プロジェクト: HosamKhalifa/ESS
        public static List <LeaveApp> GetLeaveApps()
        {
            var          leaveApps = new List <LeaveApp>();
            Axapta       ax;
            AxaptaRecord axRecord;

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

                // Create a query using the AxaptaRecord class
                using (axRecord = ax.CreateAxaptaRecord(TABLE_NAME))
                {
                    // Execute the query on the table.
                    axRecord.ExecuteStmt("select * from %1 ");

                    while (axRecord.Found)
                    {
                        var leaveApp = new LeaveApp()
                        {
                            ApplicationId        = axRecord.get_Field(APPLICATION_ID).ToString(),
                            CreatedDateTime      = (DateTime)axRecord.get_Field(CREATE_DATETIME),
                            LeaveApplicationType = axRecord.get_Field(LEAVE_APP_TYPE).ToString(),
                            DefaultLeaveCode     = axRecord.get_Field(LEAVE_CODE).ToString(),
                            EmplId              = axRecord.get_Field(EMPLOYEE_ID).ToString(),
                            RequestedBy         = (long)axRecord.get_Field(REQUESTED_BY),
                            ScheduledLeaveDate  = (DateTime)axRecord.get_Field(SCH_LEAVE_DATE),
                            ScheduledReturnDate = (DateTime)axRecord.get_Field(SCH_RETURN_DATE),
                            Days             = (int)axRecord.get_Field(DAYS),
                            ApprovalStatus   = axRecord.get_Field(APPROVAL_STATUS).ToString(),
                            ExitVisaType     = axRecord.get_Field(EXIT_VISA_TYPE).ToString(),
                            Comments         = axRecord.get_Field(COMMENTS).ToString(),
                            CommentsApproval = axRecord.get_Field(COMMENTS_APPROVAL).ToString()
                        };
                        leaveApps.Add(leaveApp);
                        axRecord.Next();
                    }
                    return(leaveApps);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error encountered: {0}", ex.Message);
                throw;
            }
        }
コード例 #27
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));
            }
        }
コード例 #28
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);
        }
コード例 #29
0
        private List <IntershopWebService.TotalDetailsLine> ExtractOrderLinesTotal(Axapta ax, AxaptaContainer orderLineCont)
        {
            List <IntershopWebService.TotalDetailsLine> totalDetailsLineList = new List <IntershopWebService.TotalDetailsLine>();
            IEnumerator enumerator1 = orderLineCont.GetEnumerator();

            while (enumerator1.MoveNext())
            {
                IntershopWebService.TotalDetailsLine totalDetailsLine = new IntershopWebService.TotalDetailsLine();
                IEnumerator enumerator2 = ((AxaptaContainer)enumerator1.Current).GetEnumerator();
                int         num         = 0;
                while (enumerator2.MoveNext())
                {
                    switch (num++)
                    {
                    case 0:
                        totalDetailsLine.ItemID = Convert.ToString(enumerator2.Current);
                        break;

                    case 1:
                        totalDetailsLine.Qty = Math.Round(Convert.ToDouble(enumerator2.Current), 2);
                        break;

                    case 2:
                        totalDetailsLine.SalesUnit = Convert.ToString(enumerator2.Current);
                        break;

                    case 3:
                        totalDetailsLine.UnitPrice = Math.Round(Convert.ToDouble(enumerator2.Current), 2);
                        break;

                    case 4:
                        totalDetailsLine.LineNetAmount = Math.Round(Convert.ToDouble(enumerator2.Current), 2);
                        break;

                    case 5:
                        totalDetailsLine.Discounts = this.ExtractDiscountsTotalLine(ax, (AxaptaContainer)enumerator2.Current);
                        break;

                    case 6:
                        totalDetailsLine.MiscCharges = this.ExtractMiscChargesTotal(ax, (AxaptaContainer)enumerator2.Current);
                        break;
                    }
                }
                totalDetailsLineList.Add(totalDetailsLine);
            }
            return(totalDetailsLineList);
        }
コード例 #30
0
ファイル: Revervation.cs プロジェクト: Osama91/CCWFM
        public void DeleteReservationOrder(Tbl_ReservationHeader reservationHeader, int userIserial)
        {
            var axapta = new Axapta();//Ready To be Dependent from Ax

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

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

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

                entities.DeleteObject(headerRow);
                entities.SaveChanges();
            }
            if (SharedOperation.UseAx())
            {
                axapta.Logoff();
            }
        }
コード例 #31
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();
            }
        }
コード例 #32
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();
        }
コード例 #33
0
ファイル: EmployeeShift.cs プロジェクト: Osama91/CCWFM
        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();
                }
            }
        }
コード例 #34
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();
        }
コード例 #35
0
ファイル: Program.cs プロジェクト: MaKeBits/AxRest
        static void Main(string[] args)
        {
            Axapta Ax = new Axapta();
            Ax.Logon(null, null, null, null);
            string className = "ZFS_TestXML";
            string methodName = "getResultTable";
            string paramList = null;

            AxaptaObject axObj = Ax.CreateAxaptaObject(className);
            AxaptaRecord ret = null;
            if (paramList != null)
                ret = (AxaptaRecord)axObj.Call(methodName, paramList);
            else
                ret = (AxaptaRecord)axObj.Call(methodName);

            while (ret.Found)
            {
                ret.get_Field(2);
            }

            axObj.Dispose();
        }
コード例 #36
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;
        }
コード例 #37
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;
        }
コード例 #38
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;
        }
コード例 #39
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;
        }
コード例 #40
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;
        }
コード例 #41
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;
        }
コード例 #42
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;
        }
コード例 #43
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;
        }
コード例 #44
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;
        }
コード例 #45
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;
        }
コード例 #46
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;
        }
コード例 #47
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;
        }
コード例 #48
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;
        }
コード例 #49
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;
        }
コード例 #50
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;
        }
コード例 #51
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;
        }
コード例 #52
0
ファイル: AxConnectorServer.cs プロジェクト: MaKeBits/AxRest
        /// <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
        }
コード例 #53
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;
        }
コード例 #54
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;
        }
コード例 #55
0
ファイル: AxConnectorServer.cs プロジェクト: MaKeBits/AxRest
        /// <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
        }
コード例 #56
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;
        }