コード例 #1
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();
        }
コード例 #2
0
ファイル: DAL.cs プロジェクト: MaKeBits/AxRest
        public void deleteAddress(Address address)
        {
            try
            {

                AxLogon();

                using (axRecord = ax.CreateAxaptaRecord(tableName))
                {
                    // Execute a query to retrieve an editable record
                    // where the name is MyStateUpdated.
                    string stmt = "select forupdate * from %1 where %1.RecId == " + address.recId + "";
                    axRecord.ExecuteStmt(stmt);

                    deleteAxRecord();
                }
                ax.Logoff();
            }
            catch (Exception e)
            {
                throw (e);
            }
            finally
            {
                ax.Logoff();
            }
        }
コード例 #3
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"));
            }
        }
コード例 #4
0
        public void deleteAddress(Address address)
        {
            try
            {
                AxLogon();

                using (axRecord = ax.CreateAxaptaRecord(tableName))
                {
                    // Execute a query to retrieve an editable record
                    // where the name is MyStateUpdated.
                    string stmt = "select forupdate * from %1 where %1.RecId == " + address.recId + "";
                    axRecord.ExecuteStmt(stmt);

                    deleteAxRecord();
                }
                ax.Logoff();
            }
            catch (Exception e)
            {
                throw (e);
            }
            finally
            {
                ax.Logoff();
            }
        }
コード例 #5
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();
                    }
                }
            }
        }
コード例 #6
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));
            }
        }
コード例 #7
0
        public ActionResult CreateTransfer(Transfer transfer)
        {
            try
            {
                Axapta axDB1 = new Axapta();
                System.Net.NetworkCredential ncDB1 = new System.Net.NetworkCredential("EP_AX2012", "VendTable1", "RIWAL01");
                axDB1.LogonAs(ConfigurationManager.AppSettings["User"], ConfigurationManager.AppSettings["Domain"], ncDB1, transfer.DataAreaId, ConfigurationManager.AppSettings["Language"], ConfigurationManager.AppSettings["AOS"], "");

                axDB1.TTSBegin();
                AxaptaRecord transferRequest = axDB1.CreateAxaptaRecord("A4URequests");
                transferRequest.Call("InitValue");
                if (!string.IsNullOrWhiteSpace(transfer.ContactPersonId))
                {
                    transferRequest.set_Field("ContactPersonId", transfer.ContactPersonId);
                }
                transferRequest.set_Field("CustAccount", transfer.CustAccount);
                if (!string.IsNullOrWhiteSpace(transfer.TransferFromContactPersonid))
                {
                    transferRequest.set_Field("TransferFromContactPersonId", transfer.TransferFromContactPersonid);
                }
                transferRequest.set_Field("TransferFromCustAccount", transfer.TransferFromCustAccount);
                transferRequest.set_Field("Type", (Int32)RequestTypes.Transfer);
                transferRequest.set_Field("Status", (Int32)TransferStates.Requested);
                transferRequest.set_Field("TransferfromInventTransId", transfer.TransferfromInventTransId);
                transferRequest.set_Field("DateOnHire", transfer.DateOnHire);
                transferRequest.set_Field("UserId", transfer.UserId);
                transferRequest.set_Field("TransferFromUserId", transfer.TransferFromUserId);
                transferRequest.set_Field("TransferFromSalesName", transfer.TransferFromSalesName);
                transferRequest.set_Field("SalesName", transfer.SalesName);
                transferRequest.Insert();
                axDB1.TTSCommit();
                axDB1.Logoff();
                axDB1.Dispose();
                return(Content("true"));
            }
            catch
            {
                return(Content("false"));
            }
        }
コード例 #8
0
        public void createAddress(Address address)
        {
            try
            {
                AxLogon();

                // Create a new AddressState table record.
                using (axRecord = ax.CreateAxaptaRecord(tableName))
                {
                    createAxRecord(address);
                }
                ax.Logoff();
            }
            catch (Exception e)
            {
                throw (e);
            }
            finally
            {
                ax.Logoff();
            }
        }
コード例 #9
0
ファイル: DAL.cs プロジェクト: MaKeBits/AxRest
        public void createAddress(Address address)
        {
            try
            {
                AxLogon();

                // Create a new AddressState table record.
                using (axRecord = ax.CreateAxaptaRecord(tableName))
                {
                    createAxRecord(address);
                }
                ax.Logoff();
            }
            catch (Exception e)
            {
                throw (e);
            }
            finally
            {
                ax.Logoff();
            }
        }
コード例 #10
0
        public List <IntershopWebService.SizeStock> getItemDims(string itemId, string company)
        {
            List <IntershopWebService.SizeStock> sizeStockList = new List <IntershopWebService.SizeStock>();
            Axapta axapta = (Axapta)null;

            try
            {
                axapta = this.axLogon(company);
                string       str          = "select * from %1 where %1.ItemId == '" + itemId + "'";
                AxaptaRecord axaptaRecord = axapta.CreateAxaptaRecord("InventSize");
                axaptaRecord.ExecuteStmt(str);
                while (axaptaRecord.Found)
                {
                    IntershopWebService.SizeStock sizeStock = new IntershopWebService.SizeStock();
                    if (Convert.ToBoolean(axaptaRecord.get_Field("Color")))
                    {
                        sizeStock.color = Convert.ToString(axaptaRecord.get_Field("InventSizeId"));
                    }
                    else
                    {
                        sizeStock.size = Convert.ToString(axaptaRecord.get_Field("InventSizeId"));
                    }
                    sizeStockList.Add(sizeStock);
                    axaptaRecord.Next();
                }
                return(sizeStockList);
            }
            catch (Exception ex)
            {
                MessageLogger.info(string.Format("getItemDims(itemId={0}, company={1} -> error: {2})", itemId, company, ex.Message));
                return((List <IntershopWebService.SizeStock>)null);
            }
            finally
            {
                axapta.Logoff();
            }
        }
コード例 #11
0
ファイル: AxSalesOrder.cs プロジェクト: czivko/AxIntegrator
        public static string TransTableId = "TransTableId"; //366

        #endregion Fields

        #region Methods

        public static void BuildDefaults(AxaptaRecord rec, string storeName)
        {
            rec.set_Field(AxSalesOrder.CustomerAccountId, storeName);
            rec.set_Field(AxSalesOrder.InvoiceAccountId, storeName);
            rec.set_Field(AxSalesOrder.CurrencyCode, "USD");
            rec.set_Field(AxSalesOrder.Payment, "CBS");
            rec.set_Field(AxSalesOrder.CustomerGroup, "Magento");
            rec.set_Field(AxSalesOrder.SalesType, 3);
            rec.set_Field(AxSalesOrder.InventoryLocationId, "CV");
            rec.set_Field(AxSalesOrder.InventorySiteId, "CV");
            rec.set_Field(AxSalesOrder.SalesStatus, 1);
            rec.set_Field(AxSalesOrder.ShippingDateRequested,DateTime.Now);
            rec.set_Field(AxSalesOrder.LanguageId, "EN-US");
        }
コード例 #12
0
        private void PostReportAsAFinish(int transId, int journalType, int routeCardHeaderIserial, int postPostOrNo)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                var routeCardHeaderRow = context
                                         .RouteCardHeaders.SingleOrDefault(x => x.Iserial == routeCardHeaderIserial);

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

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

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

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

                            #region MyRegion

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

                            #endregion MyRegion

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

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

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

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

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

                        ClearAxTable(tableName, axapta);

                        context.SaveChanges();
                    }
                }
                catch (Exception ex)
                {
                    //There was some errors, Abort transaction and Raise error!
                    //Axapta.TTSAbort();
                    throw new Exception(ex.Message);
                }
                finally
                {
                    //Finally logoff the Axapta Session
                    axapta.Logoff();
                }
            }
        }
コード例 #13
0
        public void PostRoutCardToAx(int routeCardHeaderIserial, int postPostOrNo) // posted=1
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                //int _TransID, string _WorkStationID, string _OperationID, int JournalType
                var routeHeaderRow = context
                                     .RouteCardHeaders.SingleOrDefault(x => x.Iserial == routeCardHeaderIserial);

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

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

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

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

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

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

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

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

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

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

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

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

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

                        ClearAxTable(tableName, axapta);

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

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

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

                PickingList(routeCardHeaderIserial, postPostOrNo);
            }
        }
コード例 #14
0
        public List <Address> getListOfAdresses()
        {
            Addresses addresses = new Addresses();

            // The AddressState field names for calls to
            // the AxRecord.get_field method.
            string strNameField    = "NAME";
            string strStateIdField = "STATEID";
            string strRecIdField   = "RecId";

            // The output variables for calls to the
            // AxRecord.get_Field method.
            string fieldName, fieldStateId, recId;

            try
            {
                AxLogon();

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

                    // Loop through the set of retrieved records.
                    while (axRecord.Found)
                    {
                        // Retrieve the record data for the specified fields.
                        fieldName    = (String)axRecord.get_Field(strNameField);
                        fieldStateId = (String)axRecord.get_Field(strStateIdField);
                        recId        = axRecord.get_Field(strRecIdField).ToString();

                        if (!String.IsNullOrEmpty(fieldName) && !String.IsNullOrEmpty(fieldStateId) && !String.IsNullOrEmpty(recId))
                        {
                            Address address = new Address();
                            address.Name    = fieldName;
                            address.StateId = fieldStateId;
                            address.recId   = recId;
                            addresses.Add(address);
                        }

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

            catch (Exception e)
            {
                throw (e);
            }
            finally
            {
                ax.Logoff();
            }

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

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

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

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

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

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

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

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

                            //  //   ProductionOrder

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

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

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

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

                        #region TransactionType3 ReportAsFinished

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

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

                            AxaptaRecord.Insert();
                        }

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

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

                Operations.SharedOperation.ClearAxTable("PRODCONNECTION", axapta, transactionGuid);
                axapta.Logoff();
            }
        }
コード例 #16
0
ファイル: AxSalesOrder.cs プロジェクト: czivko/AxIntegrator
 public static void MarkupTransBuildDefaults(AxaptaRecord rec)
 {
     rec.set_Field(AxSalesOrder.TransTableId, 366);
     rec.set_Field(AxSalesOrder.LineNum, 1.0);
     rec.set_Field(AxSalesOrder.CurrencyCode, "USD");
     rec.set_Field(AxSalesOrder.ModuleType, 1);
 }
コード例 #17
0
ファイル: AxSalesOrder.cs プロジェクト: czivko/AxIntegrator
 public static void LineBuildDefaults(AxaptaRecord rec, string storeName)
 {
     rec.set_Field(AxSalesOrder.SalesStatus, 1);
     rec.set_Field(AxSalesOrder.CustomerGroup, storeName);
     rec.set_Field(AxSalesOrder.CustomerAccountId, storeName);
     rec.set_Field(AxSalesOrder.LineInvetoryDimId, "000001");
     rec.set_Field(AxSalesOrder.CurrencyCode, "USD");
     rec.set_Field(AxSalesOrder.SalesType, 3);
     rec.set_Field(AxSalesOrder.ShippingDateRequested, DateTime.Now);
     rec.set_Field(AxSalesOrder.LinePriceUnit, 1.00m);
 }
コード例 #18
0
ファイル: DAL.cs プロジェクト: MaKeBits/AxRest
        public List<Address> getListOfAdresses()
        {
            Addresses addresses = new Addresses();

            // The AddressState field names for calls to
            // the AxRecord.get_field method.
            string strNameField = "NAME";
            string strStateIdField = "STATEID";
            string strRecIdField = "RecId";

            // The output variables for calls to the
            // AxRecord.get_Field method.
            string fieldName, fieldStateId, recId;

            try
            {
                AxLogon();

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

                    // Loop through the set of retrieved records.
                    while (axRecord.Found)
                    {
                        // Retrieve the record data for the specified fields.
                        fieldName = (String)axRecord.get_Field(strNameField);
                        fieldStateId = (String)axRecord.get_Field(strStateIdField);
                        recId = axRecord.get_Field(strRecIdField).ToString();

                        if (!String.IsNullOrEmpty(fieldName) && !String.IsNullOrEmpty(fieldStateId) && !String.IsNullOrEmpty(recId))
                        {
                            Address address = new Address();
                            address.Name = fieldName;
                            address.StateId = fieldStateId;
                            address.recId = recId;
                            addresses.Add(address);
                        }

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

            catch (Exception e)
            {
                throw (e);
            }
            finally
            {
                ax.Logoff();
            }

            return addresses;
        }
コード例 #19
0
        private void PickingListForAxServicesAcc(TblDyeingOrdersHeaderAcc objToPost, TblDyeingOrdersMainDetailsACC headerObjToPost,
                                                 int postPostOrNo, int userIserial, string transactionGuid)
        {
            using (var entities = new WorkFlowManagerDBEntities())
            {
                var          axapta = new Axapta();
                AxaptaRecord AxaptaRecord;
                var          credential = new NetworkCredential("bcproxy", "around1");
                var          tableName  = "PRODCONNECTION";
                TblAuthUser  userToLogin;
                using (var model = new WorkFlowManagerDBEntities())
                {
                    userToLogin = model.TblAuthUsers.SingleOrDefault(x => x.Iserial == userIserial);
                }
                axapta.LogonAs(userToLogin.User_Win_Login, userToLogin.User_Domain, credential, "Ccm", null, null, null);

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

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

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

                    axapta.Logoff();
                }

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

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

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

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

                    SharedOperation.ClearAxTable("PRODCONNECTION", axapta, transactionGuid);
                    axapta.Logoff();
                }
                else
                {
                    row.AxTransaction = "1111";
                    row.IsPosted      = true;
                    entities.SaveChanges();
                }
            }
        }