using Foresight.Fleet.Services.User; using IronIntel.Contractor; using IronIntel.Contractor.Site.Maintenance; using Newtonsoft.Json; using System; using System.Linq; using System.Net; public partial class Maintenance_SurveyTemplatePrint : WorkOrderBasePage { protected void Page_Load(object sender, EventArgs e) { if (!CheckLoginSession()) { // TODO: sub page //RedirectToLoginPage(); } else if (!IsPostBack) { Title = PageTitle; bool license = SystemParams.HasLicense("CustomerRecord"); if (!license) { RedirectToLoginPage(); } bool permission = CheckRight(SystemParams.CompanyID, Feature.CUSTOMER_RECORD); bool permission1 = CheckRight(SystemParams.CompanyID, Feature.WORKORDERSURVEYS); if (!permission || !permission1) { RedirectToLoginPage(); } var template = Request.QueryString["tid"]; templatename.InnerText = WebUtility.UrlDecode(Request.QueryString["tname"]); var start = WebUtility.UrlDecode(Request.QueryString["start"]); var end = WebUtility.UrlDecode(Request.QueryString["end"]); if (string.IsNullOrEmpty(start)) { startdate_span.Visible = false; } else { startdate.InnerText = start; } if (string.IsNullOrEmpty(end)) { enddate_span.Visible = false; } else { enddate.InnerText = end; } string[] locids; string[] advids; var locs = WebUtility.UrlDecode(Request.QueryString["locs"]); if (string.IsNullOrEmpty(locs)) { locids = new string[0]; locations_span.Visible = false; } else { var array = locs.Split(','); locids = array.Select(loc => loc.Split(';').FirstOrDefault()).ToArray(); locations.InnerText = string.Join(", ", array.Select(loc => loc.Split(';').LastOrDefault())); } var advs = WebUtility.UrlDecode(Request.QueryString["advs"]); if (string.IsNullOrEmpty(advs)) { advids = new string[0]; advisors_span.Visible = false; } else { var array = advs.Split(','); advids = array.Select(a => a.Split(';').FirstOrDefault()).ToArray(); advisors.InnerText = string.Join(", ", array.Select(a => a.Split(';').LastOrDefault())); } @params.Value = JsonConvert.SerializeObject(new[] { template, start, end, JsonConvert.SerializeObject(locids), JsonConvert.SerializeObject(advids) }); } } }