public DC_Message Pentaho_SupplierApiCall_Remove(Guid PentahoCall_Id, string CalledBy) { try { DC_Message dc = new DataContracts.DC_Message(); if (PentahoCall_Id != Guid.Empty) { string endpointurl = "removeTrans?id=" + PentahoCall_Id.ToString(); object result; DHSVCProxy.GetData(ProxyFor.Pentaho, endpointurl, typeof(void), out result); using (ConsumerEntities context = new ConsumerEntities()) { List <Supplier_ApiCallLog> results = (from p in context.Supplier_ApiCallLog where p.PentahoCall_Id == PentahoCall_Id select p).ToList(); foreach (Supplier_ApiCallLog p in results) { p.Status = "REMOVED"; p.Edit_User = CalledBy; p.Edit_Date = DateTime.Now; p.Message = "Transformation Queue has been removed from Server."; } context.SaveChanges(); } dc.StatusMessage = "The transformation was removed successfully."; dc.StatusCode = ReadOnlyMessage.StatusCode.Success; } else { dc.StatusMessage = "Invalid Transformation Call Id !"; dc.StatusCode = ReadOnlyMessage.StatusCode.Danger; } return(dc); } catch (Exception e) { return(new DC_Message { StatusCode = ReadOnlyMessage.StatusCode.Danger, StatusMessage = e.Message }); } }
public DataContracts.FileTransfer.DC_UploadResponse TransferFileInChunks(DataContracts.FileTransfer.DC_FileData request) { try { DHSVC.DC_FileData file = new DHSVC.DC_FileData(); file.FileName = request.FileName; file.FilePostition = request.FilePostition; file.BufferData = request.BufferData; object result = null; DHSVCProxy.PostData(ProxyFor.DataHandler, System.Configuration.ConfigurationManager.AppSettings["Data_Handler_Upload_File_InChunks"], file, file.GetType(), typeof(DataContracts.FileTransfer.DC_UploadResponse), out result); file = null; return(result as DataContracts.FileTransfer.DC_UploadResponse); } catch (Exception e) { return(new DataContracts.FileTransfer.DC_UploadResponse { UploadedPath = string.Empty, UploadSucceeded = false }); } }
public DataContracts.Pentaho.DC_PentahoTransStatus_TransStatus Pentaho_SupplierApiCall_ViewDetails(Guid PentahoCall_Id) { try { if (PentahoCall_Id == Guid.Empty) { return(null); } else { string endpointurl = "transStatus/?xml=y&id=" + PentahoCall_Id.ToString(); object result; DHSVCProxy.GetData(ProxyFor.Pentaho, endpointurl, typeof(DataContracts.Pentaho.DC_PentahoTransStatus_TransStatus), out result); DataContracts.Pentaho.DC_PentahoTransStatus_TransStatus status = result as DataContracts.Pentaho.DC_PentahoTransStatus_TransStatus; return(status); } } catch (Exception e) { return(null); } }
public DC_Message Pentaho_SupplierApi_Call(Guid ApiLocationId, string CalledBy) { DC_Message dc = new DataContracts.DC_Message(); try { using (ConsumerEntities context = new ConsumerEntities()) { var iCount = (from dlr in context.Supplier_ApiCallLog where dlr.Status == "RUNNING" && dlr.SupplierApiCallLog_Id == ApiLocationId select true).Count(); if (iCount > 0) { return(new DC_Message { StatusMessage = "Transformation for GeoCode is already running.", StatusCode = ReadOnlyMessage.StatusCode.Information }); } else { var apilocation = (from a in context.Supplier_APILocation where a.Supplier_APILocation_Id == ApiLocationId && a.STATUS.ToUpper() == "ACTIVE" select a.API_Path).FirstOrDefault(); if (!string.IsNullOrWhiteSpace(apilocation)) { var ApiCallId = Guid.NewGuid(); Guid PentahoCallId = Guid.Empty; context.Supplier_ApiCallLog.Add(new Supplier_ApiCallLog { SupplierApiCallLog_Id = ApiCallId, SupplierApiLocation_Id = ApiLocationId, PentahoCall_Id = PentahoCallId, Create_Date = DateTime.Now, Create_User = CalledBy, Message = "Transformation Called.", Status = "SENT TO CARTE" }); context.SaveChanges(); var getInsertedRow = context.Supplier_ApiCallLog.Find(ApiCallId); string endpointurl = "runTrans/?trans=" + apilocation + "&api_call_id=" + ApiCallId.ToString(); object result; DHSVCProxy.GetData(ProxyFor.Pentaho, endpointurl, typeof(DataContracts.Pentaho.DC_PentahoApiCallResult), out result); DataContracts.Pentaho.DC_PentahoApiCallResult callResult = result as DataContracts.Pentaho.DC_PentahoApiCallResult; if (callResult != null) { if (callResult.result.ToUpper() == "OK") { dc.StatusMessage = callResult.message; dc.StatusCode = ReadOnlyMessage.StatusCode.Success; } else { dc.StatusMessage = callResult.message; dc.StatusCode = ReadOnlyMessage.StatusCode.Danger; } Guid.TryParse(callResult.id, out PentahoCallId); getInsertedRow.PentahoCall_Id = PentahoCallId; getInsertedRow.Message = callResult.message; if (PentahoCallId == Guid.Empty) { getInsertedRow.Status = "ERROR"; } context.SaveChanges(); return(dc); } else { getInsertedRow.PentahoCall_Id = Guid.Empty; getInsertedRow.Message = "Api Call failed."; getInsertedRow.Status = "FAILED"; context.SaveChanges(); return(new DC_Message { StatusMessage = "Api Call failed.", StatusCode = ReadOnlyMessage.StatusCode.Failed }); } } else { context.Supplier_ApiCallLog.Add(new Supplier_ApiCallLog { SupplierApiCallLog_Id = Guid.NewGuid(), SupplierApiLocation_Id = ApiLocationId, PentahoCall_Id = null, Create_Date = DateTime.Now, Create_User = CalledBy, Message = "Api Location is not found.", Status = "INVALID" }); context.SaveChanges(); return(new DC_Message { StatusMessage = "Api Location is not found.", StatusCode = ReadOnlyMessage.StatusCode.Warning }); } } } } catch (Exception ex) { return(new DC_Message { StatusMessage = ex.Message, StatusCode = ReadOnlyMessage.StatusCode.Danger }); } }