using Neo.LegitimateLicences.Api.Helpers; using Neo.LegitimateLicences.Common; using Neo.LegitimateLicences.Data.Models; using Newtonsoft.Json.Linq; using Neo.Afx.Services.Documents; using Neo.Afx.Services.Documents.Entities; using Neo.Afx.Services.Security; using Neo.Afx.Services.Workflows; using Neo.Afx.Utilities; using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Security.Claims; using System.Threading; using System.Web.Http; using System.Web.Http.Cors; using DPUruNet; using Newtonsoft.Json; namespace Neo.LegitimateLicences.Api { public partial class LegitimateLicencesApiController { #region GetPrintoutData [Route("~/1.0/Printing/GetPrintoutData")] [HttpGet] public JsonBaseResult GetPrintoutData(string verificationToken) { var response = new JsonBaseResult(); if (!IsValidClaim) { string error = Error_ClaimDetailsNotFound.Replace("#EXPOSE_ERROR#", ""); throw new Exception(error); } var db = new LegitimateDatabase(); var printout = db.GetVerifiedPrintoutByToken(verificationToken, UserID); var desktopAppVersion = db.GetSystemSetting("DesktopAppVersion"); if (printout != null) { if (printout.EntityID == (short)EntityEnum.ReceiptDetails) { response.Result = new { printout = printout, data = db.GetReceipt(printout.ItemID, UserID), desktopAppVersion = desktopAppVersion }; } else if (printout.EntityID == (short)EntityEnum.OperatingLicences) { response.Result = new { printout = printout, data = db.GetVerifiedOperatingLicence(printout.ItemID), desktopAppVersion = desktopAppVersion }; } else if (printout.EntityID == (short)EntityEnum.Accreditation) { response.Result = new { printout = printout, data = db.GetVerifiedAccreditation(printout.ItemID), desktopAppVersion = desktopAppVersion }; } else if (printout.EntityID == (short)EntityEnum.ApplicationLicenceTemporaryReplacement) { response.Result = new { printout = printout, data = db.GetApplicationLicenceTemporaryReplacement(printout.ItemID, UserID), desktopAppVersion = desktopAppVersion }; } response.Success = true; } else { response.Success = false; } var json = Newtonsoft.Json.JsonConvert.SerializeObject(response.Result, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore}); db.SavePrintoutData(verificationToken, json, UserID); return response; } #endregion } }