fleet-contractor/Site/ExportToFile.aspx.cs
2023-04-28 12:22:26 +08:00

681 lines
32 KiB
C#

using FI.FIC;
using Foresight.Fleet.Services.Asset;
using IronIntel.Contractor;
using IronIntel.Contractor.Machines;
using IronIntel.Contractor.Site;
using IronIntel.Contractor.Site.Maintenance;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class ExportToFile : ContractorBasePage
{
protected void Page_Load(object sender, EventArgs e)
{
if (GetCurrentLoginSession() != null)
{
byte[] buffer = null;
string title = "";
string fileType = "xlsx";
try
{
string type = Request.Params["type"];
switch (type)
{
case "set":
SetExportParams();
break;
case "exp":
buffer = ExportByParams(ref title, ref fileType);
break;
case "devicesexcel":
buffer = ExportDeviceErrorList(ref title);
break;
case "assetsexcel":
buffer = ExportAssetErrorList(ref title);
break;
default:
buffer = Export(type, ref title, ref fileType);
break;
}
}
catch (Exception ex)
{
SystemParams.WriteLog("error", "ExportToFile", ex.Message, ex.ToString());
}
if (string.Equals(fileType, "xlsx", StringComparison.OrdinalIgnoreCase))
{
title = title + ".xlsx";
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
}
Response.BufferOutput = false;
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(title, System.Text.Encoding.UTF8));
if (buffer != null)
{
Response.AddHeader("Content-Length", buffer.Length.ToString());
Response.BinaryWrite(buffer);
}
Response.Flush();
Response.End();
}
}
private void SetExportParams()
{
var clientdata = Request.Form["ClientData"];
string key = ExportExcelManager.SetExprotParams(clientdata);
Response.Write(JsonConvert.SerializeObject(key));
Response.End();
}
private byte[] ExportDeviceErrorList(ref string title)
{
string key = Request.Params["key"];
title = "Import Devices Error List";
string p = ExportExcelManager.GetExportParams(key);
if (string.IsNullOrEmpty(p))
return null;
DeviceItem[] ds = JsonConvert.DeserializeObject<DeviceItem[]>(p);
IronIntel.Contractor.Users.UserInfo u = GetCurrentUser();
string lang = GetLanguageCookie();
ExportToExcel ete = new ExportToExcel();
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_SOURCE", "Source"), Caption = "SourceName" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_SN", "Air ID or SN"), Caption = "SerialNumber" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_ESN", "ESN"), Caption = "AlternativeSerialNumber" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_DEVICETYPE", "Device Type"), Caption = "DeviceType" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_STATUS", "Status"), Caption = "Status" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_INVOICEDATE", "Invoice Date"), Caption = "InvoiceDate" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_INVOICENUMBER", "Invoice #"), Caption = "InvoiceNumber" });
if (u.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin)
{
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_XXXXXX", "Sales Order #"), Caption = "SalesOrderNumber" });
}
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_SERVICESTATDATE", "Service Start Date"), Caption = "ServiceStartDate" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_ASSETVINSN", "Asset VIN/SN"), Caption = "VIN" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_TAMPERALERTS", "Tamper Alerts"), Caption = "TamperAlerts" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_UTILIZATION", "Utilization"), Caption = "Utilization" });
if (u.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin)
{
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_FIINSTALLATION", "FI Install"), Caption = "FIInstalltion" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_INSTALLER", "Installer"), Caption = "Installer" });
}
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_NOTES", "Notes"), Caption = "Notes" });
if (ds != null && ds.Length > 0)
{
foreach (var r in ds)
{
int index = 0;
var dr = dt.NewRow();
dr[index] = r.SourceName;
dr[++index] = r.SerialNumber;
dr[++index] = r.AlternativeSerialNumber;
dr[++index] = r.DeviceType;
dr[++index] = r.Status == 1 ? "Active" : "Inactive";
dr[++index] = r.InvoiceDateStr;
dr[++index] = r.InvoiceNumber;
if (u.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin)
{
dr[++index] = r.SalesOrderNumber;
}
dr[++index] = r.ServiceStartDateStr;
dr[++index] = r.PairedAsset == null ? "" : r.PairedAsset.VIN;
dr[++index] = r.Tamper ? "Yes" : "No";
dr[++index] = r.Utilization ? "Yes" : "No";
if (u.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin)
{
dr[++index] = r.FIInstalltion ? "Yes" : "No";
dr[++index] = r.Installer;
}
dr[++index] = r.Notes;
dt.Rows.Add(dr);
}
}
double[] widths;
if (u.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin)
{
widths = new double[] { 120, 120, 120, 120, 120, 120, 120, 120, 150, 120, 120, 120, 120, 120, 120 };
}
else
{
widths = new double[] { 120, 120, 120, 120, 120, 120, 120, 150, 120, 120, 120, 120 };
}
byte[] data = ete.CreateExcel(dt, null, widths, null);
return data;
}
private byte[] ExportAssetErrorList(ref string title)
{
string key = Request.Params["key"];
title = "Import Assets Error List";
string p = ExportExcelManager.GetExportParams(key);
if (string.IsNullOrEmpty(p))
return null;
AssetDetailInfo2[] ds = JsonConvert.DeserializeObject<AssetDetailInfo2[]>(p);
IronIntel.Contractor.Users.UserInfo u = GetCurrentUser();
string lang = GetLanguageCookie();
ExportToExcel ete = new ExportToExcel();
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_VINSN", "SN/VIN"), Caption = "VIN" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_ASSETNAME", "Asset Name"), Caption = "Asset Name" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_ASSETNAME2", "Asset Name(Custom)"), Caption = "Asset Name(Custom)" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_YEAR", "Year"), Caption = "Year" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_TYPE", "Asset Type"), Caption = "Asset Type" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_MAKE", "Make"), Caption = "Make" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_MODEL", "Model"), Caption = "Model" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_EQCLASS", "Eq.Class"), Caption = "Eq.Class" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_DESCRIPTION", "Description"), Caption = "Description" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_URINTERVAL", "Undercarriage Replacement Interval(Hours)"), Caption = "Undercarriage Replacement Interval(Hours)" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_ACQUISITIONTYPE", "Acquisition Type"), Caption = "Acquisition Type" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_COSTCENTER", "Cost Center"), Caption = "Cost Center" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_HIDE", "Hide/Hidden"), Caption = "Hide/Hidden" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_ONROAD", "On-Road"), Caption = "On-Road" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_TELEMATICSENABLED", "Telematics Enabled"), Caption = "Telematics Enabled" });
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_ATTACHMENT", "Attachment"), Caption = "Attachment" });
if (u.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin)
{
dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_PRELOADED", "Preloaded"), Caption = "Preloaded" });
}
if (ds != null && ds.Length > 0)
{
foreach (var r in ds)
{
int index = 0;
var dr = dt.NewRow();
dr[index] = r.VIN;
dr[++index] = r.Name;
dr[++index] = r.Name2;
dr[++index] = r.MakeYear == -1 ? "" : r.MakeYear.ToString();
dr[++index] = r.TypeName;
dr[++index] = r.MakeName;
dr[++index] = r.ModelName;
dr[++index] = r.EQClass;
dr[++index] = r.Description;
dr[++index] = r.UnderCarriageHours == null ? "" : r.UnderCarriageHours.ToString();
dr[++index] = r.AquisitionType;
dr[++index] = r.CostCenter;
dr[++index] = r.Hidden ? "Yes" : "No";
dr[++index] = r.OnRoad ? "Yes" : "No";
dr[++index] = r.TelematicsEnabled ? "Yes" : "No";
dr[++index] = r.Attachment ? "Yes" : "No";
if (u.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin)
{
dr[++index] = r.Preloaded ? "Yes" : "No";
}
dt.Rows.Add(dr);
}
}
double[] widths;
if (u.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin)
{
widths = new double[] { 120, 120, 150, 120, 120, 120, 120, 120, 120, 200, 120, 120, 120, 120, 160, 120, 120 };
}
else
{
widths = new double[] { 120, 120, 150, 120, 120, 120, 120, 120, 120, 200, 120, 120, 120, 120, 160, 120 };
}
byte[] data = ete.CreateExcel(dt, null, widths, null);
return data;
}
private byte[] ExportByParams(ref string title, ref string fileType)
{
string key = Request.Params["key"];
string p = ExportExcelManager.GetExportParams(key);
if (string.IsNullOrEmpty(p))
return null;
return ExportByParams(p, ref title, ref fileType);
}
private byte[] ExportByParams(string p, ref string title, ref string fileType)
{
string[] ps = JsonConvert.DeserializeObject<string[]>(p);
byte[] buffer = null;
switch (ps[0])
{
case "timeline":
buffer = ExportAssetsTimeLine(ps, ref title, ref fileType);
break;
case "workorders":
buffer = ExportWorkOrders(ps, ref title, ref fileType);
break;
case "manageassets":
buffer = ExportManageAssets(ps, ref title, ref fileType);
break;
case "jobsites":
buffer = ExportJobSites(ps, ref title, ref fileType);
break;
case "users":
buffer = ExportUsers(ps, ref title, ref fileType);
break;
}
return buffer;
}
private byte[] Export(string type, ref string title, ref string fileType)
{
byte[] buffer = null;
switch (type)
{
case "rentals":
buffer = ExportRentals(ref title, ref fileType);
break;
case "rentalchg":
buffer = ExportRentalChanges(ref title, ref fileType);
break;
case "odoadjusthis":
buffer = ExportOdometerAdjustHistory(ref title, ref fileType);
break;
case "ehadjusthis":
buffer = ExportEngineHoursAdjustHistory(ref title, ref fileType);
break;
case "alerts":
buffer = ExportAlertsManagement(ref title, ref fileType);
break;
case "autoackhis":
buffer = ExportAutoAcknowledChangeHistory(ref title, ref fileType);
break;
case "requirements":
buffer = ExportRequirements(ref title, ref fileType);
break;
case "custrecord":
buffer = ExportCustomerRecords(ref title, ref fileType);
break;
case "assetgroups":
buffer = ExportAssetGroups(ref title, ref fileType);
break;
case "managedevices":
buffer = ExportManageDevices(ref title, ref fileType);
break;
case "maintenancerecords":
buffer = ExportMaintenanceRecords(ref title, ref fileType);
break;
case "fuelrecordmanagement":
buffer = ExportFuelRecordManagement(ref title, ref fileType);
break;
case "dispatchrequests":
buffer = ExportDispatchRequests(ref title, ref fileType);
break;
case "inspecthis":
buffer = ExportInspectChanges(ref title, ref fileType);
break;
case "wohis":
buffer = ExportWorkOrderHistory(ref title, ref fileType);
break;
}
return buffer;
}
private byte[] ExportRentals(ref string title, ref string fileType)
{
var lang = GetLanguageCookie();
title = SystemParams.GetTextByKey(lang, "P_MA_RENTAL", "Rental");
string companyid = Request.Params["cid"];
string mid = Request.Params["mid"];
string from = Request.Params["from"];
string to = Request.Params["to"];
string searchtext = Request.Params["t"];
searchtext = HttpUtility.HtmlDecode(searchtext);
string sortpath = Request.Params["sp"];
bool desc = Request.Params["desc"].ToLower() == "true";
long machineid = 0;
long.TryParse(mid, out machineid);
DateTime fromDate = DateTime.MinValue;
if (!DateTime.TryParse(from, out fromDate))
fromDate = DateTime.MinValue;
DateTime toDate = DateTime.MaxValue;
if (!DateTime.TryParse(to, out toDate))
toDate = DateTime.MaxValue;
else
toDate = toDate.AddDays(1).AddSeconds(-1);
var session = GetCurrentLoginSession();
var data = ExportExcelManager.ExportRentals(lang, GetCurrentLoginSession().SessionID, companyid, machineid, fromDate, toDate, searchtext, session.User.UID, sortpath, desc);
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "Rentals", "", "", title + ".xlsx", ".xlsx", data);
return data;
}
private byte[] ExportRentalChanges(ref string title, ref string fileType)
{
var lang = GetLanguageCookie();
title = SystemParams.GetTextByKey(lang, "P_MA_RENTALCHANGEHISTORY", "Rental Change History");
string companyid = Request.Params["cid"];//CompanyID
string mid = Request.Params["mid"];//MachineID
string rid = Request.Params["rid"];//RentalID
string from = Request.Params["from"];
string to = Request.Params["to"];
string searchtext = Request.Params["t"];
searchtext = HttpUtility.HtmlDecode(searchtext);
string sortpath = Request.Params["sp"];
bool desc = Request.Params["desc"].ToLower() == "true";
long machineid = 0;
long.TryParse(mid, out machineid);
long rentalid = 0;
long.TryParse(rid, out rentalid);
DateTime fromDate = DateTime.MinValue;
if (!DateTime.TryParse(from, out fromDate))
fromDate = DateTime.MinValue;
DateTime toDate = DateTime.MaxValue;
if (!DateTime.TryParse(to, out toDate))
toDate = DateTime.MaxValue;
else
toDate = toDate.AddDays(1).AddSeconds(-1);
var session = GetCurrentLoginSession();
var data = ExportExcelManager.ExportRentalChanges(lang, session.SessionID, companyid, machineid, rentalid, fromDate, toDate, searchtext, session.User.UID, sortpath, desc);
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "RentalChangeHistory", "", "", title + ".xlsx", ".xlsx", data);
return data;
}
private byte[] ExportOdometerAdjustHistory(ref string title, ref string fileType)
{
var lang = GetLanguageCookie();
title = SystemParams.GetTextByKey(lang, "P_MA_ODOMETERADJUSTMENTHISTORY", "Odometer Adjustment History");
string companyid = Request.Params["cid"];//CompanyID
string mid = Request.Params["mid"];//MachineID
string from = Request.Params["from"];
string to = Request.Params["to"];
string sortpath = Request.Params["sp"];
bool desc = Request.Params["desc"].ToLower() == "true";
long machineid = 0;
long.TryParse(mid, out machineid);
DateTime fromDate = Helper.DBMinDateTime;
DateTime toDate = DateTime.MaxValue;
if (!DateTime.TryParse(from, out fromDate))
fromDate = DateTime.MinValue;
if (!DateTime.TryParse(to, out toDate))
toDate = DateTime.MaxValue;
var session = GetCurrentLoginSession();
var data = ExportExcelManager.ExportOdometerAdjustHistory(lang, session.SessionID, companyid, machineid, fromDate, toDate, sortpath, desc);
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "OdometerAdjustmentHistory", "", "", title + ".xlsx", ".xlsx", data);
return data;
}
private byte[] ExportEngineHoursAdjustHistory(ref string title, ref string fileType)
{
var lang = GetLanguageCookie();
title = SystemParams.GetTextByKey(lang, "P_MA_ENGINEHOURSADJUSTMENTHISTORY", "Engine Hours Adjustment History");
string companyid = Request.Params["cid"];//CompanyID
string mid = Request.Params["mid"];//MachineID
string from = Request.Params["from"];
string to = Request.Params["to"];
string sortpath = Request.Params["sp"];
bool desc = Request.Params["desc"].ToLower() == "true";
long machineid = 0;
long.TryParse(mid, out machineid);
DateTime fromDate = Helper.DBMinDateTime;
DateTime toDate = DateTime.MaxValue;
if (!DateTime.TryParse(from, out fromDate))
fromDate = DateTime.MinValue;
if (!DateTime.TryParse(to, out toDate))
toDate = DateTime.MaxValue;
var session = GetCurrentLoginSession();
var data = ExportExcelManager.ExportEngineHoursAdjustHistory(lang, session.SessionID, companyid, machineid, fromDate, toDate, sortpath, desc);
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "EngineHoursAdjustmentHistory", "", "", title + ".xlsx", ".xlsx", data);
return data;
}
private byte[] ExportAlertsManagement(ref string title, ref string fileType)
{
string tabstr = Request.Params["tab"];
int tabindex = 0;
Int32.TryParse(tabstr, out tabindex);
string clientdata = Request.Params["param"];
var session = GetCurrentLoginSession();
var useriid = session.User.UID;
var lang = GetLanguageCookie();
if (tabindex == 1)
{
title = SystemParams.GetTextByKey(lang, "P_AM_ASSETVIEW", "Asset View");
var data = ExportExcelManager.ExportAssetView(clientdata, session.SessionID, useriid, lang);
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "AssetView", "", "", title + ".xlsx", ".xlsx", data);
return data;
}
else if (tabindex == 2)
{
title = SystemParams.GetTextByKey(lang, "P_AM_ACKNOWLEDGEDALERTS", "Acknowledged Alerts");
var data = ExportExcelManager.ExportAcknowledgedAlerts(clientdata, session.SessionID, useriid, lang);
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "AcknowledgedAlerts", "", "", title + ".xlsx", ".xlsx", data);
return data;
}
else
{
title = SystemParams.GetTextByKey(lang, "P_AM_ALERTVIEW", "Alert View");
var data = ExportExcelManager.ExportAlertsView(clientdata, session.SessionID, useriid, lang);
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "AlertView", "", "", title + ".xlsx", ".xlsx", data);
return data;
}
}
private byte[] ExportAutoAcknowledChangeHistory(ref string title, ref string fileType)
{
var session = GetCurrentLoginSession();
var lang = GetLanguageCookie();
title = SystemParams.GetTextByKey(lang, "P_AM_AUTOACKNOWLEDGECHANGEHISTORY", "Auto-Acknowledge Change History");
var data = ExportExcelManager.ExportAutoAcknowledChangeHistory(session.SessionID, session.User.UID, lang);
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "Auto-AcknowledgeChangeHistory", "", "", title + ".xlsx", ".xlsx", data);
return data;
}
private byte[] ExportUsers(string[] ps, ref string title, ref string fileType)
{
var lang = GetLanguageCookie();
title = SystemParams.GetTextByKey(lang, "P_USERMANAGEMENT", "User Management");
string searchtext = ps[1];
searchtext = HttpUtility.HtmlDecode(searchtext);
var session = GetCurrentLoginSession();
var data = ExportExcelManager.ExportUsers(lang, searchtext, ps[2]);
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "Users", "", "", title + ".xlsx", ".xlsx", data);
return data;
}
private byte[] ExportJobSites(string[] ps, ref string title, ref string fileType)
{
var session = GetCurrentLoginSession();
var lang = GetLanguageCookie();
title = SystemParams.GetTextByKey(lang, "P_JOBSITES", "Jobsites");
string searchtext = ps[1];
string typesdata = ps[2];
bool active = Helper.IsTrue(ps[3]);
var data = ExportExcelManager.ExportJobSites(lang, session.SessionID, session.User.UID, searchtext, typesdata, active, ps[4]);
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "JobSites", "", "", title + ".xlsx", ".xlsx", data);
return data;
}
private byte[] ExportRequirements(ref string title, ref string fileType)
{
var lang = GetLanguageCookie();
title = SystemParams.GetTextByKey(lang, "P_JS_JOBSITEREQUIREMENTS", "Jobsite Requirements");
string clientdata = Request.Params["param"];
var session = GetCurrentLoginSession();
var data = ExportExcelManager.ExportRequirements(lang, session.SessionID, clientdata);
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "JobsiteRequirements", "", "", title + ".xlsx", ".xlsx", data);
return data;
}
private byte[] ExportCustomerRecords(ref string title, ref string fileType)
{
var lang = GetLanguageCookie();
title = SystemParams.GetTextByKey(lang, "P_CUSTOMERRECORD", "Customer Record");
string clientdata = Request.Params["param"];
var searchtext = HttpUtility.HtmlDecode(clientdata);
var session = GetCurrentLoginSession();
var data = ExportExcelManager.ExportCustomerRecords(lang, session.SessionID, searchtext);
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "CustomerRecords", "", "", title + ".xlsx", ".xlsx", data);
return data;
}
private byte[] ExportWorkOrders(string[] ps, ref string title, ref string fileType)
{
var lang = GetLanguageCookie();
title = SystemParams.GetTextByKey(lang, "P_WORKORDER", "Work Order");
string clientdata = ps[1];
string layout = ps[2];
var session = GetCurrentLoginSession();
var data = ExportExcelManager.ExportWorkOrders(lang, session.User, session.SessionID, clientdata, layout);
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "WorkOrders", "", "", title + ".xlsx", ".xlsx", data);
return data;
}
private byte[] ExportManageAssets(string[] ps, ref string title, ref string fileType)
{
var session = GetCurrentLoginSession();
var lang = GetLanguageCookie();
title = SystemParams.GetTextByKey(lang, "P_MANAGEASSETS", "Manage Assets");
string clientdata = ps[1];
var data = ExportExcelManager.ExportManageAssets(lang, session.SessionID, session.User.UID, clientdata, ps[2], session.User);
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "Assets", "", "", title + ".xlsx", ".xlsx", data);
return data;
}
private byte[] ExportAssetGroups(ref string title, ref string fileType)
{
var session = GetCurrentLoginSession();
var lang = GetLanguageCookie();
title = SystemParams.GetTextByKey(lang, "P_ASSETGROUPS", "Asset Groups");
string clientdata = Request.Params["param"];
var searchtext = HttpUtility.HtmlDecode(clientdata);
var data = ExportExcelManager.ExportAssetGroups(lang, session.SessionID, session.User.UID, searchtext);
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "AssetGroups", "", "", title + ".xlsx", ".xlsx", data);
return data;
}
private byte[] ExportManageDevices(ref string title, ref string fileType)
{
var lang = GetLanguageCookie();
var session = GetCurrentLoginSession();
title = SystemParams.GetTextByKey(lang, "P_MANAGEDEVICES", "Manage Devices");
string clientdata = Request.Params["param"];
clientdata = HttpUtility.HtmlDecode(clientdata);
var data = ExportExcelManager.ExportManageDevices(lang, session.SessionID, clientdata, session.User);
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "Devices", "", "", title + ".xlsx", ".xlsx", data);
return data;
}
private byte[] ExportMaintenanceRecords(ref string title, ref string fileType)
{
var lang = GetLanguageCookie();
title = SystemParams.GetTextByKey(lang, "P_MAINTENANCERECORDSMANAGEMENT", "Maintenance Records Management");
string clientdata = Request.Params["param"];
clientdata = HttpUtility.HtmlDecode(clientdata);
var session = GetCurrentLoginSession();
var data = ExportExcelManager.ExportMaintenanceRecords(lang, session.SessionID, session.User.UID, clientdata);
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "MaintenanceRecords", "", "", title + ".xlsx", ".xlsx", data);
return data;
}
private byte[] ExportFuelRecordManagement(ref string title, ref string fileType)
{
var lang = GetLanguageCookie();
title = SystemParams.GetTextByKey(lang, "P_FUELRECORDS", "Fuel Records");
string clientdata = Request.Params["t"];
var searchtext = HttpUtility.HtmlDecode(clientdata);
string from = Request.Params["from"];
string to = Request.Params["to"];
string type = Request.Params["tp"];
long assetid = Convert.ToInt64(HttpUtility.HtmlDecode(Request.Params["aid"]));
DateTime beginDate = Helper.DBMinDateTime;
DateTime endDate = DateTime.MaxValue;
if (!DateTime.TryParse(from, out beginDate))
beginDate = Helper.DBMinDateTime;
if (!DateTime.TryParse(to, out endDate))
endDate = DateTime.MaxValue;
var session = GetCurrentLoginSession();
var data = ExportExcelManager.ExportFuelRecordManagement(lang, session.SessionID, searchtext, beginDate, endDate, type, assetid);
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "FuelRecords", "", "", title + ".xlsx", ".xlsx", data);
return data;
}
private byte[] ExportDispatchRequests(ref string title, ref string fileType)
{
var lang = GetLanguageCookie();
title = SystemParams.GetTextByKey(lang, "P_JS_DISPATCHREQUESTS", "Dispatch Requests");
string clientdata = Request.Params["t"];
var p = HttpUtility.HtmlDecode(clientdata);
var session = GetCurrentLoginSession();
var data = ExportExcelManager.ExportDispatchRequests(lang, session.SessionID, p);
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "DispatchRequests", "", "", title + ".xlsx", ".xlsx", data);
return data;
}
private byte[] ExportInspectChanges(ref string title, ref string fileType)
{
var lang = GetLanguageCookie();
title = SystemParams.GetTextByKey(lang, "P_IPT_INSPECTIONCHANGEHISTORY", "Inspection Change History");
string clientdata = Request.Params["t"];
var p = HttpUtility.HtmlDecode(clientdata);
var session = GetCurrentLoginSession();
var data = ExportExcelManager.ExportInspectChanges(lang, session.SessionID, p);
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "InspectionChangeHistory", "", "", title + ".xlsx", ".xlsx", data);
return data;
}
private byte[] ExportWorkOrderHistory(ref string title, ref string fileType)
{
var lang = GetLanguageCookie();
title = SystemParams.GetTextByKey(lang, "P_XXXXXX", "Work Order History");
string clientdata = Request.Params["t"];
var searchtext = HttpUtility.HtmlDecode(clientdata);
string from = Request.Params["from"];
string to = Request.Params["to"];
long woid = Convert.ToInt64(HttpUtility.HtmlDecode(Request.Params["woid"]));
DateTime beginDate = Helper.DBMinDateTime;
DateTime endDate = DateTime.MaxValue;
if (!DateTime.TryParse(from, out beginDate))
beginDate = Helper.DBMinDateTime;
if (!DateTime.TryParse(to, out endDate))
endDate = DateTime.MaxValue;
var session = GetCurrentLoginSession();
var data = ExportExcelManager.ExportWorkOrderHistory(lang, session.SessionID, "", woid, beginDate, endDate, searchtext);
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "WorkOrderHistory", "", "", title + ".xlsx", ".xlsx", data);
return data;
}
private byte[] ExportAssetsTimeLine(string[] ps, ref string title, ref string fileType)
{
var lang = GetLanguageCookie();
title = SystemParams.GetTextByKey(lang, "P_XXXXXX", "Time Line");
string cid = ps[1];
long[] asseids = JsonConvert.DeserializeObject<long[]>(ps[2]);
string d = ps[3];
DateTime date = Helper.DBMinDateTime;
if (!DateTime.TryParse(d, out date))
return null;
var session = GetCurrentLoginSession();
var data = ExportExcelManager.ExportAssetsTimeLine(lang, session.SessionID, cid, asseids, date);
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "AssetsTimeLine", "", "", title + ".xlsx", ".xlsx", data);
return data;
}
}