public void GetDocumentParameter(KnowageResult result, string DocumentLabel) { try { IRestResponse response = knowageServer.GetDocumentParameters(DocumentLabel, out int outResult); if (outResult == Output.SUCCESSFUL) { result.Result = Result.SUCCESSFUL; result.Response = response; KnowageService.Models.Knowage.DocumentParameters.RootObject rootObject = new KnowageService.Models.Knowage.DocumentParameters.RootObject(); result.DocumentParameters = JsonConvert.DeserializeObject <KnowageService.Models.Knowage.DocumentParameters.RootObject>(response.Content.ToString()); } else if (outResult == Output.EMPTY) { result.Result = Result.FAILED; result.Message = Messages.RESPONSE_CONTENT_IS_EMPTY; } else { result.Result = Result.FAILED; result.Message = Messages.RESPONSE_CONTAINS_ERROR; result.ErrorMessage = response.Content.ToString(); } } catch (Exception ex) { result.Result = Result.EXCEPTION; result.ErrorMessage = ex.Message; result.ObjectException = ex; } }
public void GetDocumentContent(KnowageResult result, string DocumentLabel, string DocumentParameters) { try { IRestResponse response = knowageServer.GetDocumentContent(DocumentLabel, DocumentParameters, out int outResult); if (outResult == Output.SUCCESSFUL) { result.Result = Result.SUCCESSFUL; result.Response = response; } else if (outResult == Output.EMPTY) { result.Result = Result.FAILED; result.Message = Messages.RESPONSE_CONTENT_IS_EMPTY; } else { result.Result = Result.FAILED; result.Message = Messages.RESPONSE_CONTAINS_ERROR; result.ErrorMessage = response.Content.ToString(); } } catch (Exception ex) { result.Result = Result.EXCEPTION; result.ErrorMessage = ex.Message; result.ObjectException = ex; } }
public void ExportReport(string DocumentLabel) { KnowageBLL bll = new KnowageBLL(); KnowageResult result = new KnowageResult(); KnowageService.Models.Knowage.DocumentParameters.RootObject DocumentParameters = new KnowageService.Models.Knowage.DocumentParameters.RootObject(); Document document = new Document(); string parameter1 = "value1"; string parameter2 = "value2"; string parameter3 = "value3"; string parameter4 = "value4"; string parameter5 = "value5"; string documentParameter = ""; documentParameter = JsonConvert.SerializeObject(document); GetDocumentParameter(bll, result, DocumentLabel); SetDocumentParameter(document, bll, DocumentParameters, parameter1, parameter2); GetDocumentContent(bll, result, DocumentLabel, documentParameter); string htmlString = result.Response.Content.ToString(); if (!htmlString.Contains("Error")) { //Convert htmlString to PDF //Send as email attachment to receipients; } }
private void GetDocumentParameter(KnowageBLL bll, KnowageResult result, string DocumentLabel) { bll.GetDocumentParameter(result, DocumentLabel); if (result.Message == Result.SUCCESSFUL) { //log succesfull } else if (result.Message == Result.FAILED) { //log failed; } else if (result.Message == Result.EXCEPTION) { string logMessage = string.Concat("Excption occured:", MethodBase.GetCurrentMethod(), " - ", result.ObjectException); _logger.LogError(logMessage); } }
public KnowageResult GetLOV(string DataSetLabel, string DataSetParameter) { /* There really is no API method for LOV * create a DataSet in knowage that returns a list of value for your parameter */ KnowageResult knowageResult = new KnowageResult(); try { IRestResponse response = knowageServer.GetDatasetContent(DataSetLabel, DataSetParameter, out int outResult); if (outResult == Output.SUCCESSFUL) { knowageResult.Result = Result.SUCCESSFUL; knowageResult.Response = response; KnowageService.Models.Knowage.LOV.RootObject rootObject = new KnowageService.Models.Knowage.LOV.RootObject(); knowageResult.LOV = JsonConvert.DeserializeObject <KnowageService.Models.Knowage.LOV.RootObject>(response.Content.ToString()); } else if (outResult == Output.EMPTY) { knowageResult.Result = Result.FAILED; knowageResult.Message = Messages.RESPONSE_CONTENT_IS_EMPTY; } else { knowageResult.Result = Result.FAILED; knowageResult.Message = Messages.RESPONSE_CONTAINS_ERROR; knowageResult.ErrorMessage = response.Content.ToString(); } } catch (Exception ex) { knowageResult.Result = Result.EXCEPTION; knowageResult.ErrorMessage = ex.Message; knowageResult.ObjectException = ex; } return(knowageResult); }
public KnowageResult GetDataSetSchema(string DataSetLabel) { KnowageResult knowageResult = new KnowageResult(); try { IRestResponse response = knowageServer.GetDatasetSchema(DataSetLabel, out int outResult); if (outResult == Output.SUCCESSFUL) { knowageResult.Result = Result.SUCCESSFUL; knowageResult.Response = response; KnowageService.Models.Knowage.DataSetSchema.RootObject rootObject = new KnowageService.Models.Knowage.DataSetSchema.RootObject(); knowageResult.DataSetSchema = JsonConvert.DeserializeObject <KnowageService.Models.Knowage.DataSetSchema.RootObject>(response.Content.ToString()); } else if (outResult == Output.EMPTY) { knowageResult.Result = Result.FAILED; knowageResult.Message = Messages.RESPONSE_CONTENT_IS_EMPTY; } else { knowageResult.Result = Result.FAILED; knowageResult.Message = Messages.RESPONSE_CONTAINS_ERROR; knowageResult.ErrorMessage = response.Content.ToString(); } } catch (Exception ex) { knowageResult.Result = Result.EXCEPTION; knowageResult.ErrorMessage = ex.Message; knowageResult.ObjectException = ex; } return(knowageResult); }