public HttpResponseMessage Post(afs_shipment_h post_afs_shipment_h) { try { using (var context = new SAPContext()) { afs_shipment_h data = new afs_shipment_h(); data.CLIENT = post_afs_shipment_h.CLIENT; data.SHIPMENT_NUMBER = post_afs_shipment_h.SHIPMENT_NUMBER; data.TRANSPORT_DATE = post_afs_shipment_h.TRANSPORT_DATE; data.CARGROUP_CODE = post_afs_shipment_h.CARGROUP_CODE; data.DRIVER_ID = post_afs_shipment_h.DRIVER_ID; data.REMARK = post_afs_shipment_h.REMARK; data.DRIVER_ID = post_afs_shipment_h.DRIVER_ID; data.STAFF1_ID = post_afs_shipment_h.STAFF1_ID; data.STAFF2_ID = post_afs_shipment_h.STAFF2_ID; data.STATUS = post_afs_shipment_h.STATUS; data.POINT_ID = post_afs_shipment_h.POINT_ID; data.CREATED_BY = post_afs_shipment_h.CREATED_BY; data.CREATED_DATE = DateTime.Now; data.UPDATE_BY = post_afs_shipment_h.UPDATE_BY; data.UPDATE_DATE = DateTime.Now; context.afs_shipment_h.Add(data); context.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, data)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public HttpResponseMessage Get(string id) { try { using (var context = new SAPContext()) { var t173t = context.T173T.Where(t => t.MANDT == client && t.SPRAS == "2" && t.VSART == id).FirstOrDefault(); ShipmentTypeModel ShipmentType = new ShipmentTypeModel(); if (t173t != null) { ShipmentType.client = t173t.MANDT; ShipmentType.lang_code = t173t.SPRAS; ShipmentType.shipmenttype_code = t173t.VSART; ShipmentType.shipmenttype_desc = t173t.BEZEI; } ; return(ShipmentType.shipmenttype_code == null ? Request.CreateErrorResponse(HttpStatusCode.NotFound, "Shipment Type not found") : Request.CreateResponse(HttpStatusCode.OK, ShipmentType)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
//[Authorize] public async Task <IActionResult> Post([FromBody] Codebar codebar) { SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext; SAPbobsCOM.CompanyService services = context.oCompany.GetCompanyService(); SAPbobsCOM.BarCodesService barCodesService = (SAPbobsCOM.BarCodesService)services.GetBusinessService(SAPbobsCOM.ServiceTypes.BarCodesService); SAPbobsCOM.BarCode barCode = (SAPbobsCOM.BarCode)barCodesService.GetDataInterface(SAPbobsCOM.BarCodesServiceDataInterfaces.bsBarCode); SAPbobsCOM.Recordset oRecSet = (SAPbobsCOM.Recordset)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); oRecSet.DoQuery($@" Select ""BcdEntry"", ""BcdCode"", ""BcdName"", ""ItemCode"", ""UomEntry"" From OBCD Where ""BcdCode"" = '{codebar.Barcode}';"); if (oRecSet.RecordCount != 0) { string itemcode = context.XMLTOJSON(oRecSet.GetAsXML())["OBCD"][0]["ItemCode"].ToString(); return(BadRequest("Ya Existe Codigo de Barra Registrado. Producto: " + itemcode)); } barCode.ItemNo = codebar.ItemCode; barCode.BarCode = codebar.Barcode; barCode.UoMEntry = codebar.UOMEntry; try { SAPbobsCOM.BarCodeParams result = barCodesService.Add(barCode); return(Ok(result.AbsEntry)); } catch (Exception x) { return(BadRequest(x.Message)); } }
public HttpResponseMessage GetShipmentType() { var ShipmentTypes = new List <ShipmentTypeModel>(); try { using (var context = new SAPContext()) { var t173ts = context.T173T.Where(t => t.MANDT == client && t.SPRAS == "2").ToList(); foreach (var r in t173ts) { var ShipmentType = new ShipmentTypeModel(); ShipmentType.client = r.MANDT; ShipmentType.lang_code = r.SPRAS; ShipmentType.shipmenttype_code = r.VSART; ShipmentType.shipmenttype_desc = r.BEZEI; ShipmentTypes.Add(ShipmentType); } return(ShipmentTypes == null ? Request.CreateErrorResponse(HttpStatusCode.NotFound, "Shipment Type not found") : Request.CreateResponse(HttpStatusCode.OK, ShipmentTypes)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
private List <ShipmentDetailModel> MappingShipmentDetail(List <VTTK> vttks) { var Shipments = new List <ShipmentDetailModel>(); using (var context = new SAPContext()) { foreach (var r in vttks) { var shipment = new ShipmentDetailModel(); shipment.client = r.MANDT; shipment.shipment_number = r.TKNUM; shipment.shipment_date = DateTime.ParseExact(r.ERDAT, "yyyyMMdd", null); shipment.shipmenttype_code = r.VSART; if (r.VSART != " ") { var shipmenttype = context.T173T.Where(t => t.MANDT == r.MANDT && t.SPRAS == "2" && t.VSART == r.VSART).FirstOrDefault(); shipment.shipmenttype_desc = shipmenttype.BEZEI; } shipment.route = r.ROUTE; if (r.ROUTE != " ") { var route = context.TVROT.Where(t => t.MANDT == r.MANDT && t.SPRAS == "2" && t.ROUTE == r.ROUTE).FirstOrDefault(); shipment.route_desc = route.BEZEI; } shipment.container_id = r.SIGNI; shipment.car_license = r.ADD01; shipment.forwarding = r.TDLNR; Shipments.Add(shipment); } return(Shipments); } }
public async Task <IActionResult> GetTSRList() { SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext; SAPbobsCOM.Recordset oRecSet = (SAPbobsCOM.Recordset)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); // Release WMS //oRecSet.DoQuery(@" // Select // warehouse.""WhsCode"" as ""WhsCodeTSR"", // warehouse2.""WhsCode"" as ""WhsCode"", // warehouse.""WhsName"" // From OWHS warehouse // JOIN OWHS warehouse2 ON warehouse.""WhsName"" = warehouse2.""WhsName"" AND warehouse.""WhsCode"" != warehouse2.""WhsCode"" // Where warehouse.""WhsCode"" LIKE 'TSR%'"); oRecSet.DoQuery(@" Select warehouse.""WhsCode"" as WhsTSRCode, warehouse2.""WhsCode"" as WhsCode, warehouse.""WhsName"" From OWHS warehouse JOIN OWHS warehouse2 ON warehouse.""WhsName"" = warehouse2.""WhsName"" AND warehouse.""WhsCode"" != warehouse2.""WhsCode"" Where warehouse.""WhsCode"" LIKE 'TSR%'"); oRecSet.MoveFirst(); JToken warehouseList = context.XMLTOJSON(oRecSet.GetAsXML())["OWHS"]; return(Ok(warehouseList)); }
public async Task <IActionResult> GetList(string date) { SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext; SAPbobsCOM.Recordset oRecSet = (SAPbobsCOM.Recordset)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); oRecSet.DoQuery(@" Select ""DocEntry"", ""DocNum"", ""DocDate"", ""CANCELED"", ""DocStatus"" From OWTQ Where ""DocDate"" = '" + date + "'"); int rc = oRecSet.RecordCount; if (rc == 0) { return(NotFound()); } JToken request = context.XMLTOJSON(oRecSet.GetAsXML())["OWTQ"]; return(Ok(request)); }
public HttpResponseMessage Put(afs_authority put_afs_authority) { try { using (var context = new SAPContext()) { var existing = context.afs_authority.Where(t => t.USER_ID == put_afs_authority.USER_ID).FirstOrDefault(); if (existing == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "afs_authority not found")); } else { context.Entry(existing).State = EntityState.Modified; } existing.SALE_FLAG = put_afs_authority.SALE_FLAG; existing.AFTERSALE_FLAG = put_afs_authority.AFTERSALE_FLAG; existing.PURCHASE_FLAG = put_afs_authority.PURCHASE_FLAG; context.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, put_afs_authority)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public HttpResponseMessage Post(afs_shipment_carries post_afs_shipment_carries) { try { using (var context = new SAPContext()) { afs_shipment_carries data = new afs_shipment_carries(); data.CLIENT = post_afs_shipment_carries.CLIENT; data.SHIPMENT_NUMBER = post_afs_shipment_carries.SHIPMENT_NUMBER; data.SALEORDER_NUMBER = post_afs_shipment_carries.SALEORDER_NUMBER; data.DRIVER_AMOUNT = post_afs_shipment_carries.DRIVER_AMOUNT; data.STAFF_AMOUNT = post_afs_shipment_carries.STAFF_AMOUNT; data.TIME_RANGE = post_afs_shipment_carries.TIME_RANGE; data.CREATED_BY = post_afs_shipment_carries.CREATED_BY; data.CREATED_DATE = DateTime.Now; data.UPDATE_BY = post_afs_shipment_carries.UPDATE_BY; data.UPDATE_DATE = DateTime.Now; context.afs_shipment_carries.Add(data); context.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, data)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public async Task <IActionResult> GetCRMProviderToBuy(string CardCode) { SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext; SAPbobsCOM.Recordset oRecSet = (SAPbobsCOM.Recordset)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); oRecSet.DoQuery(@" Select ""CardCode"", ""CardName"", ""CardFName"", ""Currency"" From OCRD Where ""CardCode"" = '" + CardCode + "'"); if (oRecSet.RecordCount == 0) { return(NoContent()); } JToken contact = context.XMLTOJSON(oRecSet.GetAsXML())["OCRD"][0]; //Force Garbage Collector. Recommendation by InterLatin Dude. SDK Problem with memory. GC.Collect(); GC.WaitForPendingFinalizers(); return(Ok(contact)); }
public async Task <IActionResult> Get(int id) { SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext; SAPbobsCOM.StockTransfer transfer = (SAPbobsCOM.StockTransfer)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer); SAPbobsCOM.Recordset oRecSet = (SAPbobsCOM.Recordset)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); oRecSet.DoQuery("Select * From OWTR WHERE \"DocNum\" = " + id); int rc = oRecSet.RecordCount; if (rc == 0) { return(NotFound()); } transfer.Browser.Recordset = oRecSet; transfer.Browser.MoveFirst(); JToken temp = context.XMLTOJSON(transfer.GetAsXML()); temp["OWTR"] = temp["OWTR"][0]; temp["AdmInfo"]?.Parent.Remove(); temp["WTR12"]?.Parent.Remove(); temp["BTNT"]?.Parent.Remove(); return(Ok(temp)); }
public async Task <IActionResult> GetAPPCRM(int id) { SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext; SAPbobsCOM.Recordset oRecSet = (SAPbobsCOM.Recordset)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); oRecSet.DoQuery($@" Select ""CardCode"", ""CardName"", ""CardFName"", ""Address"", ""ZipCode"", ""Country"", ""Block"", ""GroupNum"", ""ListNum"" From OCRD employeeSales JOIN OHEM employee ON ""SlpCode"" = ""salesPrson"" Where ""CardType"" = 'C' AND ""empID"" = {id} AND ""CardCode"" NOT LIKE '%-D'"); if (oRecSet.RecordCount == 0) { return(Ok(new List <string>())); } JToken contacts = context.XMLTOJSON(oRecSet.GetAsXML())["OCRD"]; GC.Collect(); GC.WaitForPendingFinalizers(); return(Ok(contacts)); }
public HttpResponseMessage Put(afs_carries_point put_afs_carries_point) { try { using (var context = new SAPContext()) { var existing = context.afs_carries_point.Where(t => t.POINT_ID == put_afs_carries_point.POINT_ID).FirstOrDefault(); if (existing == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "afs_carries_point not found")); } context.afs_carries_point.Remove(existing); put_afs_carries_point.UPDATE_DATE = DateTime.Now; context.afs_carries_point.Add(put_afs_carries_point); context.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, put_afs_carries_point)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public HttpResponseMessage Post(afs_shipment_expense post_afs_shipment_expense) { try { using (var context = new SAPContext()) { afs_shipment_expense data = new afs_shipment_expense(); data.CLIENT = post_afs_shipment_expense.CLIENT; data.SHIPMENT_NUMBER = post_afs_shipment_expense.SHIPMENT_NUMBER; data.EXPENSE_ID = post_afs_shipment_expense.EXPENSE_ID; data.EXPENSE_AMOUNT = post_afs_shipment_expense.EXPENSE_AMOUNT; data.REMARK = post_afs_shipment_expense.REMARK; data.CREATED_BY = post_afs_shipment_expense.CREATED_BY; data.CREATED_DATE = DateTime.Now; data.UPDATE_BY = post_afs_shipment_expense.UPDATE_BY; data.UPDATE_DATE = DateTime.Now; context.afs_shipment_expense.Add(data); context.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, data)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public async Task <IActionResult> GetAPPCRMs() { SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext; SAPbobsCOM.Recordset oRecSet = (SAPbobsCOM.Recordset)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); oRecSet.DoQuery(@" Select ""CardCode"", ""CardName"", ""CardFName"", ""Address"", ""ZipCode"", ""Country"", ""Block"", ""GroupNum"", ""ListNum"" From OCRD Where ""CardType"" = 'C' AND ""CardCode"" NOT LIKE '%-D'"); JToken contacts = context.XMLTOJSON(oRecSet.GetAsXML())["OCRD"]; GC.Collect(); GC.WaitForPendingFinalizers(); return(Ok(contacts)); }
public HttpResponseMessage Post(afs_carries_point post_afs_carries_point) { try { using (var context = new SAPContext()) { afs_carries_point data = new afs_carries_point(); data.POINT_ID = post_afs_carries_point.POINT_ID; data.CARGROUP_CODE = post_afs_carries_point.CARGROUP_CODE; data.TIER_DESC = post_afs_carries_point.TIER_DESC; data.DPOINT1_AMOUNT = post_afs_carries_point.DPOINT1_AMOUNT; data.DPOINT2_AMOUNT = post_afs_carries_point.DPOINT2_AMOUNT; data.SPOINT1_AMOUNT = post_afs_carries_point.SPOINT1_AMOUNT; data.SPOINT2_AMOUNT = post_afs_carries_point.SPOINT2_AMOUNT; data.CREATED_BY = post_afs_carries_point.CREATED_BY; data.CREATED_DATE = DateTime.Now; data.UPDATE_BY = post_afs_carries_point.UPDATE_BY; data.UPDATE_DATE = DateTime.Now; context.afs_carries_point.Add(data); context.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, data)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public IActionResult GetInvoiceCodeBar(string Codebar) { int FinalDocNum = Codebar.IndexOf("C"); string DocEntry = Codebar.Substring(0, FinalDocNum); SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext; SAPbobsCOM.Recordset oRecSet = (SAPbobsCOM.Recordset)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); JToken invoice; oRecSet.DoQuery(@" Select Invoice.""DocEntry"", Invoice.""DocNum"", Invoice.""DocDate"", Invoice.""CardCode"", Client.""CardName"", Client.""CardFName"", Invoice.""DocCur"", Invoice.""DocRate"", Invoice.""DocNum""|| Invoice.""CardCode"" || to_char(Invoice.""DocDate"", 'YYYYMMDD') as ""CodBar"", Invoice.""DocTotalSy"", Invoice.""Series"" From OINV Invoice JOIN OCRD Client ON Client.""CardCode""= Invoice.""CardCode"" Where Invoice.""DocNum""|| Invoice.""CardCode"" || to_char(Invoice.""DocDate"", 'YYYYMMDD') = '" + Codebar + "'" + @"and Invoice.""CANCELED""='N'"); if (oRecSet.RecordCount == 0) { // Handle no Existing Invoice return(NotFound(@"La factura con el numero " + DocEntry + " No existe")); } invoice = context.XMLTOJSON(oRecSet.GetAsXML())["OINV"][0]; return(Ok(invoice)); }
public HttpResponseMessage Confirm(List <ShipmentConfirmModeal> postdata) { try { foreach (var item in postdata) { using (var context = new SAPContext()) { var shiph = context.afs_shipment_h.Where(t => t.CLIENT == item.client && t.SHIPMENT_NUMBER == item.shipment_number).FirstOrDefault(); if (shiph != null) { context.Entry(shiph).State = EntityState.Modified; shiph.STATUS = "03"; shiph.CONFIRM_BY = item.confirm_by; shiph.CONFIRM_DATE = DateTime.Now; } context.SaveChanges(); } } return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex)); } }
public async Task <IActionResult> GetList(string date) { SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext; SAPbobsCOM.Documents items = (SAPbobsCOM.Documents)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseDeliveryNotes); SAPbobsCOM.Recordset oRecSet = (SAPbobsCOM.Recordset)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); List <Object> list = new List <Object>(); oRecSet.DoQuery("Select * From OPDN Where \"DocDate\" = '" + date + "'"); int rc = oRecSet.RecordCount; if (rc == 0) { return(NotFound()); } items.Browser.Recordset = oRecSet; items.Browser.MoveFirst(); while (items.Browser.EoF == false) { JToken temp = context.XMLTOJSON(items.GetAsXML()); temp["OPDN"] = temp["OPDN"][0]; temp["PDN4"]?.Parent.Remove(); temp["PDN12"]?.Parent.Remove(); temp["BTNT"]?.Parent.Remove(); list.Add(temp); items.Browser.MoveNext(); } return(Ok(list)); }
public HttpResponseMessage RemoveRaw(double raw_id) { try { using (var context = new SAPContext()) { afs_repair_raw v = new afs_repair_raw(); v = context.afs_repair_raw.Where(t => t.REPAIR_RAW_ID == raw_id).FirstOrDefault(); if (v != null) { context.Entry(v).State = EntityState.Deleted; context.SaveChanges(); } else { return(Request.CreateResponse(HttpStatusCode.NotFound, "Raw id is not found")); } } return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.InnerException.Message)); } }
public HttpResponseMessage Post(afs_car_identity_card post_afs_car_identity_card) { try { using (var context = new SAPContext()) { afs_car_identity_card data = new afs_car_identity_card(); data.PEOPLE_ID = post_afs_car_identity_card.PEOPLE_ID; data.NAME = post_afs_car_identity_card.NAME; data.CARD_CODE = post_afs_car_identity_card.CARD_CODE; data.PASSPORT_CODE = post_afs_car_identity_card.PASSPORT_CODE; data.NATION = post_afs_car_identity_card.NATION; data.DRIVER_FLAG = post_afs_car_identity_card.DRIVER_FLAG; data.STAFF_FLAG = post_afs_car_identity_card.STAFF_FLAG; context.afs_car_identity_card.Add(data); context.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, data)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public async Task <IActionResult> GetCRMID(string id) { SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext; SAPbobsCOM.BusinessPartners items = (SAPbobsCOM.BusinessPartners)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners); SAPbobsCOM.SalesPersons seller = (SAPbobsCOM.SalesPersons)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oSalesPersons); SAPbobsCOM.PaymentTermsTypes payment = (SAPbobsCOM.PaymentTermsTypes)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPaymentTermsTypes); SAPbobsCOM.UserTable sboTable = (SAPbobsCOM.UserTable)context.oCompany.UserTables.Item("SO1_01FORMAPAGO"); JToken pagos = context.XMLTOJSON(sboTable.GetAsXML())["OCRD"]; if (items.GetByKey(id)) { JToken temp = context.XMLTOJSON(items.GetAsXML()); temp["OCRD"] = temp["OCRD"][0]; if (seller.GetByKey(temp["OCRD"]["SlpCode"].ToObject <int>())) { JToken temp2 = context.XMLTOJSON(seller.GetAsXML()); temp["OSLP"] = temp2["OSLP"][0]; } if (payment.GetByKey(temp["OCRD"]["GroupNum"].ToObject <int>())) { JToken temp3 = context.XMLTOJSON(payment.GetAsXML()); temp["OCTG"] = temp3["OCTG"][0]; } temp["PAGO"] = pagos; return(Ok(temp)); } return(NotFound("No Existe Contacto")); }
public void Init() { for (int i = 0; i < SAPContextList.Length; i++) { Console.WriteLine($"No. Instancia Inicializada: {i}"); SAPContextList[i] = new SAPContext(); } }
public async Task <IActionResult> Post([FromBody] TransferRequest value) { SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext; SAPbobsCOM.StockTransfer newRequest = (SAPbobsCOM.StockTransfer)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryTransferRequest); SAPbobsCOM.Recordset oRecSet = (SAPbobsCOM.Recordset)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); oRecSet.DoQuery(@" Select warehouse.""WhsCode"", warehouse.""WhsName"", serie.""Series"" From OWHS warehouse LEFT JOIN NNM1 serie ON serie.""SeriesName"" = warehouse.""WhsCode"" Where serie.""ObjectCode"" = 1250000001 AND warehouse.""WhsCode"" = '" + value.towhs.whscode + "'"); oRecSet.MoveFirst(); JToken warehouseList = context.XMLTOJSON(oRecSet.GetAsXML())["OWHS"]; int warehouseSerie = warehouseList[0]["Series"].ToObject <int>(); newRequest.Series = warehouseSerie; newRequest.FromWarehouse = value.fromwhs.whscode; newRequest.ToWarehouse = value.towhs.whscode; for (int i = 0; i < value.rows.Count; i++) { newRequest.Lines.ItemCode = value.rows[i].code; if (value.rows[i].uom == -2) { newRequest.Lines.UoMEntry = 185; newRequest.Lines.UserFields.Fields.Item("U_CjsPsVr").Value = value.rows[i].quantity; newRequest.Lines.Quantity = value.rows[i].quantity * value.rows[i].equivalentePV; newRequest.Lines.UseBaseUnits = SAPbobsCOM.BoYesNoEnum.tYES; } else { newRequest.Lines.Quantity = value.rows[i].quantity; newRequest.Lines.UoMEntry = value.rows[i].uom; newRequest.Lines.UseBaseUnits = (SAPbobsCOM.BoYesNoEnum)value.rows[i].uomBase; } newRequest.Lines.FromWarehouseCode = value.fromwhs.whscode; newRequest.Lines.WarehouseCode = value.towhs.whstsrcode; newRequest.Lines.Add(); } int result = newRequest.Add(); if (result != 0) { string error = context.oCompany.GetLastErrorDescription(); return(BadRequest(error)); } return(Ok(context.oCompany.GetNewObjectKey())); }
public async Task<IActionResult> GetCRMList() { SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext; SAPbobsCOM.Recordset oRecSet = (SAPbobsCOM.Recordset)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); oRecSet.DoQuery("Select \"GroupNum\", \"PymntGroup\" From OCTG"); oRecSet.MoveFirst(); JToken paymentTermsList = context.XMLTOJSON(oRecSet.GetAsXML())["OCTG"]; return Ok(paymentTermsList); }
public async Task <IActionResult> Get(uint DocEntry) { SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext; SAPbobsCOM.Recordset oRecSet = (SAPbobsCOM.Recordset)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); oRecSet.DoQuery($@" SELECT document.""DocEntry"", document.""DocNum"", to_char(to_date(SUBSTRING(document.""DocDate"", 0, 10), 'YYYY-MM-DD'), 'DD-MM-YYYY') as ""DocDate"", (case when document.""CANCELED"" = 'Y' then 'Cancelado' when document.""DocStatus"" = 'O' then 'Abierto' when document.""DocStatus"" = 'C' then 'Cerrado' else document.""DocStatus"" end) AS ""DocStatus"", warehouse.""WhsName"" FROM OIGN document LEFT JOIN NNM1 series ON series.""Series"" = document.""Series"" LEFT JOIN OWHS warehouse ON warehouse.""WhsCode"" = series.""SeriesName"" WHERE document.""DocEntry"" = '{DocEntry}';"); int rc = oRecSet.RecordCount; if (rc == 0) { return(NoContent()); } JToken temp = context.XMLTOJSON(oRecSet.GetAsXML())["OIGN"][0]; oRecSet.DoQuery($@" Select ""ItemCode"", ""Dscription"", ""Quantity"", ""UomCode"", ""InvQty"", ""UomCode2"" From IGN1 Where ""DocEntry"" = '{DocEntry}';"); oRecSet.MoveFirst(); temp["Lines"] = context.XMLTOJSON(oRecSet.GetAsXML())["IGN1"]; GoodsReceiptDetail output = temp.ToObject <GoodsReceiptDetail>(); //Force Garbage Collector. Recommendation by InterLatin Dude. SDK Problem with memory. GC.Collect(); GC.WaitForPendingFinalizers(); //var s1 = Stopwatch.StartNew(); //s1.Stop(); //const int _max = 1000000; //Console.WriteLine(((double)(s1.Elapsed.TotalMilliseconds * 1000 * 1000) / _max).ToString("0.00 ns")); return(Ok(output)); }
public async Task <IActionResult> GetByWarehouseGroupDate(string warehouseCode, int group, string fromDate, string toDate) { SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext; SAPbobsCOM.Recordset oRecSet = (SAPbobsCOM.Recordset)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); oRecSet.DoQuery(@" (Select ""ItemCode"", ""Dscription"", SUM(""Quantity"") as Quantity, ""UomCode"", SUM(""LineTotal"") as LineTotal, ""Currency"" From INV1 Where ""Currency"" = 'MXN' AND ""ItemCode"" in ( Select ""ItemCode"" From OITM Where ""QryGroup" + group + @""" = 'Y') AND ""DocEntry"" in ( Select ""DocEntry"" From OINV Where ""DocStatus"" = 'C' AND ""CANCELED"" = 'N' AND ""DocDate"" >= to_timestamp('" + fromDate + @"', 'yyyy-mm-dd') AND ""DocDate"" <= to_timestamp('" + toDate + @"', 'yyyy-mm-dd') AND ""Series"" = (Select ""Series"" From NNM1 Where ""ObjectCode"" = 13 AND ""SeriesName"" = '" + warehouseCode + @"')) GROUP BY ""ItemCode"", ""Dscription"", ""UomCode"", ""Currency"") UNION ( Select ""ItemCode"", ""Dscription"", SUM(""Quantity"") as Quantity, ""UomCode"", SUM(""TotalFrgn"") as LineTotal, ""Currency"" From INV1 Where ""Currency"" = 'USD' AND ""ItemCode"" in ( Select ""ItemCode"" From OITM Where ""QryGroup" + group + @""" = 'Y') AND ""DocEntry"" in ( Select ""DocEntry"" From OINV Where ""DocStatus"" = 'C' AND ""CANCELED"" = 'N' AND ""DocDate"" >= to_timestamp('" + fromDate + @"', 'yyyy-mm-dd') AND ""DocDate"" <= to_timestamp('" + toDate + @"', 'yyyy-mm-dd') AND ""Series"" = (Select ""Series"" From NNM1 Where ""ObjectCode"" = 13 AND ""SeriesName"" = '" + warehouseCode + @"')) GROUP BY ""ItemCode"", ""Dscription"", ""UomCode"", ""Currency"");"); oRecSet.MoveFirst(); JToken result = context.XMLTOJSON(oRecSet.GetAsXML())["INV1"]; return(Ok(result)); }
public async Task <IActionResult> GetCRMList() { SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext; SAPbobsCOM.Recordset oRecSet = (SAPbobsCOM.Recordset)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); oRecSet.DoQuery("Select \"ListName\", \"ListNum\" From OPLN"); oRecSet.MoveFirst(); JToken temp = context.XMLTOJSON(oRecSet.GetAsXML())["OPLN"]; List <PriceListOutput> output = temp.ToObject <List <PriceListOutput> >(); return(Ok(output)); }
public async Task <IActionResult> GetDetail(int id) { SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext; SAPbobsCOM.Recordset oRecSet = (SAPbobsCOM.Recordset)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); oRecSet.DoQuery(@" Select ord.""DocEntry"", ord.""DocNum"", ord.""DocCur"", ord.""DocTotal"", ord.""DocTotalFC"", to_char(to_date(SUBSTRING(ord.""DocDate"", 0, 10), 'YYYY-MM-DD'), 'DD-MM-YYYY') as ""DocDate"", to_char(to_date(SUBSTRING(ord.""DocDueDate"", 0, 10), 'YYYY-MM-DD'), 'DD-MM-YYYY') as ""DocDueDate"", to_char(to_date(SUBSTRING(ord.""CancelDate"", 0, 10), 'YYYY-MM-DD'), 'DD-MM-YYYY') as ""CancelDate"", (case when ord.""CANCELED"" = 'Y' then 'Cancelado' when ord.""DocStatus"" = 'O' then 'Abierto' when ord.""DocStatus"" = 'C' then 'Cerrado' else ord.""DocStatus"" end) AS ""DocStatus"", ord.""Comments"", contact.""CardCode"", contact.""CardName"", contact.""CardFName"", warehouse.""WhsName"" From OPDN ord LEFT JOIN NNM1 serie ON ord.""Series"" = serie.""Series"" LEFT JOIN OWHS warehouse ON serie.""SeriesName"" = warehouse.""WhsCode"" LEFT JOIN OCRD contact ON ord.""CardCode"" = contact.""CardCode"" WHERE ord.""DocEntry"" = '" + id + "'"); oRecSet.MoveFirst(); JToken purchaseOrder = context.XMLTOJSON(oRecSet.GetAsXML())["OPDN"][0]; oRecSet.DoQuery(@" Select ""ItemCode"", ""Dscription"", ""Price"", ""Currency"", ""Quantity"", ""UomCode"", ""InvQty"", ""UomCode2"", ""LineTotal"", ""TotalFrgn"" From PDN1 WHERE ""DocEntry"" = '" + id + "'"); oRecSet.MoveFirst(); purchaseOrder["rows"] = context.XMLTOJSON(oRecSet.GetAsXML())["PDN1"]; return(Ok(purchaseOrder)); }
public async Task <IActionResult> Put(int id, [FromBody] UpdateTransferRequest value) { SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext; SAPbobsCOM.StockTransfer request = (SAPbobsCOM.StockTransfer)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryTransferRequest); if (request.GetByKey(id)) { request.Lines.SetCurrentLine(0); string from = request.Lines.FromWarehouseCode; string to = request.Lines.WarehouseCode; request.Lines.Add(); for (int i = 0; i < value.newProducts.Count; i++) { request.Lines.ItemCode = value.newProducts[i].code; request.Lines.Quantity = value.newProducts[i].quantity; request.Lines.UoMEntry = value.newProducts[i].uom; request.Lines.UseBaseUnits = (SAPbobsCOM.BoYesNoEnum)value.newProducts[i].uomBase; request.Lines.FromWarehouseCode = from; request.Lines.WarehouseCode = to; request.Lines.Add(); } for (int i = 0; i < value.ProductsChanged.Count; i++) { request.Lines.SetCurrentLine(value.ProductsChanged[i].LineNum); if (request.Lines.Quantity != value.ProductsChanged[i].quantity) { request.Lines.Quantity = value.ProductsChanged[i].quantity; } if (request.Lines.UoMEntry != value.ProductsChanged[i].uom) { request.Lines.UseBaseUnits = (SAPbobsCOM.BoYesNoEnum)value.ProductsChanged[i].uomBase; request.Lines.UoMEntry = value.ProductsChanged[i].uom; } } int result = request.Update(); if (result == 0) { return(Ok()); } else { string error = context.oCompany.GetLastErrorDescription(); return(BadRequest(new { error })); } } return(BadRequest(new { error = "No Existe Documento" })); }