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)); } }
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(); }
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(); } }
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(); } } }
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); } }
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; }
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); }