initial version with inspection edition
This commit is contained in:
711
IronIntelContractorSiteLib/Asset/AssetBasePage.cs
Normal file
711
IronIntelContractorSiteLib/Asset/AssetBasePage.cs
Normal file
@ -0,0 +1,711 @@
|
||||
using Foresight.Data;
|
||||
using Foresight.Fleet.Services;
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using Foresight.Fleet.Services.AssetHealth;
|
||||
using Foresight.Fleet.Services.Device;
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Contractor.Machines;
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
using IronIntel.Contractor.Users;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Asset
|
||||
{
|
||||
public class AssetBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest(string method)
|
||||
{
|
||||
object result = null;
|
||||
string methodName = Request.Params["MethodName"];
|
||||
try
|
||||
{
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName.ToUpper())
|
||||
{
|
||||
case "GETMACHINESBYCOMPANY":
|
||||
result = GetMachinesByCompany();
|
||||
break;
|
||||
case "GETMACHINEINFO":
|
||||
result = GetMachineInfo();
|
||||
break;
|
||||
case "SAVEMACHINE":
|
||||
result = SaveMachine();
|
||||
break;
|
||||
case "CHANGEMACHINEICONFILE":
|
||||
result = ChangeMachineIconFile();
|
||||
break;
|
||||
case "GETMACHINEATTRIBUTES":
|
||||
result = GetMachineAttributes();
|
||||
break;
|
||||
case "GETCUSTOMERTIMEZONE":
|
||||
result = GetCustomerTimeZone();
|
||||
break;
|
||||
case "GETODOMETERADJUSTMENTHISTORY":
|
||||
result = GetOdometerAdjustmentHistory();
|
||||
break;
|
||||
case "GETENGINEHOURSADJUSTMENTHISTORY":
|
||||
result = GetEngineHoursAdjustmentHistory();
|
||||
break;
|
||||
case "GETPMSCHEDULESBYASSET":
|
||||
result = GetPMSchedulesByAsset();
|
||||
break;
|
||||
case "ADDASSETTOPMSCHEDULE":
|
||||
result = AddAssetToPMSchedule();
|
||||
break;
|
||||
case "REMOVEASSETFROMPMSCHEDULE":
|
||||
result = RemoveAssetFromPMSchedule();
|
||||
break;
|
||||
case "CHANGEASSETPROPERTY":
|
||||
result = ChangeAssetProperty();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "AssetBasePage", ex.Message, ex.ToString());
|
||||
throw ex;
|
||||
}
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
private object GetMachinesByCompany()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var companyid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
bool showHidden = HttpUtility.HtmlDecode(clientdata[1]) == "1";
|
||||
var searchtxt = HttpUtility.HtmlDecode(clientdata[2]);
|
||||
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(companyid) && SystemParams.IsDealer)
|
||||
return new MachineItem[0];
|
||||
|
||||
//GpsDeviceInfo[] devs = SystemParams.DeviceProvider.GetDeviceItems(contractorid, "");
|
||||
|
||||
AssetBasicInfo[] assets = CreateClient<AssetQueryClient>(companyid).GetAssetBasicInfoByUser(companyid, searchtxt, session.User.UID);
|
||||
List<AssetBasicItem> list = new List<AssetBasicItem>();
|
||||
foreach (var a in assets)
|
||||
{
|
||||
if (!showHidden && a.Hide) continue;
|
||||
AssetBasicItem asset = new AssetBasicItem();
|
||||
Helper.CloneProperty(asset, a);
|
||||
list.Add(asset);
|
||||
}
|
||||
return list.OrderBy((m) => m.VIN).ToArray();
|
||||
}
|
||||
else
|
||||
return new MachineItem[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AssetBasePage.GetMachinesByCompany", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetMachineInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var companyid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var mid = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
long machineid = -1;
|
||||
long.TryParse(mid, out machineid);
|
||||
|
||||
string connectionStr = string.Empty;
|
||||
if (!SystemParams.IsDealer)
|
||||
{
|
||||
companyid = SystemParams.CompanyID;
|
||||
connectionStr = SystemParams.DataDbConnectionString;
|
||||
}
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(companyid);
|
||||
connectionStr = connetionstring;
|
||||
}
|
||||
|
||||
var client = CreateClient<AssetDataAdjustClient>(companyid);
|
||||
AssetDetailInfo2 assetDetail = client.GetAssetDetailInfo2(companyid, machineid);
|
||||
MachineOtherInfo mother = client.GetMachineOtherInfo(companyid, machineid);
|
||||
|
||||
AssetDetailItem2 assetItem = new AssetDetailItem2();
|
||||
Helper.CloneProperty(assetItem, assetDetail);
|
||||
|
||||
assetItem.OnSiteJobsiteID = mother.JobSiteID;
|
||||
assetItem.ContactIDs = string.IsNullOrEmpty(mother.ContactIDs) ? new string[0] : mother.ContactIDs.Split(',');
|
||||
assetItem.MachineGroupIDs = string.IsNullOrEmpty(mother.GroupIDs) ? new string[0] : mother.GroupIDs.Split(',');
|
||||
|
||||
//MachineRentalInfo[] machinerentals = new RentalManagement(connectionStr).SearchRentalsByAsset(machineid);
|
||||
//if (machinerentals != null && machinerentals.Length > 0)
|
||||
//{
|
||||
// DateTime nowdate = DateTime.Now;
|
||||
// //当前时间所在的rental
|
||||
// MachineRentalInfo rental = machinerentals.FirstOrDefault(m => m.RentalDate <= nowdate && nowdate.Date <= ((m.ReturnDate ?? m.ProjectReturnDate ?? DateTime.MaxValue)));
|
||||
// if (rental == null)//当前时间的下一个rental
|
||||
// rental = machinerentals.Where(m => m.RentalDate >= nowdate.Date).OrderBy(m => m.RentalDate).FirstOrDefault();
|
||||
// if (rental == null)//最新rental
|
||||
// rental = machinerentals[0];
|
||||
|
||||
// assetItem.MachineRental = rental;
|
||||
//}
|
||||
|
||||
if (assetItem.UnderCarriageHours != null)
|
||||
assetItem.UnderCarriageHours = Math.Round(assetItem.UnderCarriageHours.Value, 2);
|
||||
|
||||
return assetItem;
|
||||
}
|
||||
else
|
||||
return new AssetDetailItem2();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "AssetBasePage.GetMachineInfo", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object SaveMachine()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
|
||||
AssetDetailItem2 asset = JsonConvert.DeserializeObject<AssetDetailItem2>(clientdata);
|
||||
|
||||
if (SystemParams.IsDealer && string.IsNullOrWhiteSpace(asset.ContractorID))
|
||||
return "Failed";
|
||||
|
||||
string connectionStr = string.Empty;
|
||||
string customerid = string.Empty;
|
||||
if (SystemParams.IsDealer)
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(asset.ContractorID);
|
||||
connectionStr = connetionstring;
|
||||
customerid = asset.ContractorID;
|
||||
}
|
||||
else
|
||||
{
|
||||
connectionStr = SystemParams.DataDbConnectionString;
|
||||
customerid = SystemParams.CompanyID;
|
||||
}
|
||||
|
||||
AssetDataAdjustClient client = CreateClient<AssetDataAdjustClient>(customerid);
|
||||
if (asset.ID > 0)
|
||||
{
|
||||
//没有权限修改的,保持原来的值
|
||||
var oldMachine = client.GetAssetDetailInfo2(customerid, asset.ID);
|
||||
asset.EngineHours = oldMachine.EngineHours;//EngineHours单独保存
|
||||
var user = UserManagement.GetUserByIID(session.User.UID);
|
||||
if (user.UserType < UserTypes.Admin)
|
||||
{
|
||||
asset.VIN = oldMachine.VIN;
|
||||
asset.MakeID = oldMachine.MakeID;
|
||||
asset.MakeName = oldMachine.MakeName;
|
||||
asset.ModelID = oldMachine.ModelID;
|
||||
asset.ModelName = oldMachine.ModelName;
|
||||
asset.Odometer = oldMachine.Odometer;
|
||||
asset.OdometerUnits = oldMachine.OdometerUnits;
|
||||
}
|
||||
}
|
||||
else if (!asset.IgnoreDuplicate)
|
||||
{
|
||||
long[] dupassets = client.FindAssetsByVIN(customerid, asset.VIN);
|
||||
|
||||
if (dupassets.Length > 0)
|
||||
{
|
||||
return new
|
||||
{
|
||||
Result = 0,
|
||||
Data = dupassets
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
AssetDetailInfo2 a = new AssetDetailInfo2();
|
||||
Helper.CloneProperty(a, asset);
|
||||
a.ID = client.UpdateAssetInfo(customerid, a, asset.ContactIDs, asset.MachineGroupIDs, (int)asset.OnSiteJobsiteID, session.User.UID);
|
||||
|
||||
UpdateMachineAttributes(a.ID, asset.ContractorID, asset.MachineAttributes, session.User.UID);
|
||||
if (asset.VisibleOnWorkOrders != null)
|
||||
{
|
||||
foreach (StringKeyValue kv in asset.VisibleOnWorkOrders)
|
||||
{
|
||||
CreateClient<AssetAttachmentProvider>(customerid).ChangeVisibleOnWorkOrder(customerid, Convert.ToInt32(kv.Key), Helper.IsTrue(kv.Value));
|
||||
}
|
||||
|
||||
}
|
||||
long rentalID = -1;
|
||||
if (asset.MachineRental != null)
|
||||
{
|
||||
asset.MachineRental.MachineID = a.ID;
|
||||
AssetRentalInfo rentalinfo = new AssetRentalInfo();
|
||||
Helper.CloneProperty(rentalinfo, asset.MachineRental);
|
||||
rentalinfo.RentalRate = (double)asset.MachineRental.RentalRate;
|
||||
rentalID = CreateClient<AssetQueryClient>(customerid).SaveAssetRental(customerid, rentalinfo, session.User.UID);
|
||||
}
|
||||
return new
|
||||
{
|
||||
Result = 1,
|
||||
Data = new long[] { a.ID, rentalID }
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (BusinessException bex)
|
||||
{
|
||||
return bex.Message;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "AssetBasePage.SaveMachine", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string ChangeAssetProperty()
|
||||
{
|
||||
try
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata);
|
||||
var contractorid = ps[0];
|
||||
if (string.IsNullOrWhiteSpace(contractorid))
|
||||
contractorid = SystemParams.CompanyID;
|
||||
long assetid = 0;
|
||||
long.TryParse(ps[1], out assetid);
|
||||
var name = ps[2];
|
||||
bool value = Helper.IsTrue(ps[3]);
|
||||
|
||||
switch (name)
|
||||
{
|
||||
case "Hide":
|
||||
CreateClient<AssetDataAdjustClient>(contractorid).ChangeAssetHideProperty(contractorid, assetid, value, "", user.IID);
|
||||
break;
|
||||
case "OnRoad":
|
||||
CreateClient<AssetDataAdjustClient>(contractorid).ChangeAssetOnRoadProperty(contractorid, assetid, value, "", user.IID);
|
||||
break;
|
||||
case "TelematicsEnabled":
|
||||
CreateClient<AssetDataAdjustClient>(contractorid).ChangeAssetTelematicsProperty(contractorid, assetid, value, "", user.IID);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
#region Machine Attributes
|
||||
|
||||
private object GetMachineAttributes()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var companyid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var id = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
long machineid = Convert.ToInt64(id);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(companyid))
|
||||
{
|
||||
if (SystemParams.IsDealer)
|
||||
return new MachineAttributeCategoryClient[0];
|
||||
companyid = SystemParams.CompanyID;
|
||||
}
|
||||
|
||||
MachineAttributes abt = CreateClient<AssetDataAdjustClient>(companyid).GetMachineAttributes(companyid, machineid);
|
||||
|
||||
List<MachineAttributeCategoryClient> list = new List<MachineAttributeCategoryClient>();
|
||||
if (abt != null && abt.Category.Count > 0)
|
||||
{
|
||||
ConvertMachineAttributesCategory(abt, ref list);
|
||||
}
|
||||
return list.OrderBy(m => m.OrderIndex);
|
||||
}
|
||||
else
|
||||
return new MachineAttributeCategoryClient[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateMachineAttributes(long machineid, string companyid, MachineAttributeClient[] attributes, string useriid)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (attributes != null && attributes.Length > 0)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
|
||||
List<MachineAttributeItem> attritems = new List<MachineAttributeItem>();
|
||||
foreach (MachineAttributeClient attclient in attributes)
|
||||
{
|
||||
MachineAttributeItem machineattributeitem = new MachineAttributeItem();
|
||||
Helper.CloneProperty(machineattributeitem, attclient);
|
||||
attritems.Add(machineattributeitem);
|
||||
}
|
||||
|
||||
List<MachineAttributeCategory> listcate = new List<MachineAttributeCategory>();
|
||||
MachineAttributeCategory category = new MachineAttributeCategory();
|
||||
category.Attributes.AddRange(attritems);
|
||||
listcate.Add(category);
|
||||
|
||||
MachineAttributes att = new MachineAttributes();
|
||||
att.Category.AddRange(listcate);
|
||||
CreateClient<AssetDataAdjustClient>(companyid).UpdateMachineAttributes(companyid, machineid, att, useriid);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AssetBasePage.UpdateMachineAttributes", ex.Message, ex.ToString());
|
||||
throw new Exception(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ConvertMachineAttributesCategory(MachineAttributes abtc, ref List<MachineAttributeCategoryClient> list)
|
||||
{
|
||||
if (abtc != null && abtc.Category.Count > 0)
|
||||
{
|
||||
foreach (MachineAttributeCategory cateitem in abtc.Category)
|
||||
{
|
||||
MachineAttributeCategoryClient cateclt = new MachineAttributeCategoryClient();
|
||||
Helper.CloneProperty(cateclt, cateitem);
|
||||
|
||||
var tab = abtc.Tabs.FirstOrDefault(m => m.ID == cateitem.TabID);
|
||||
if (tab == null)
|
||||
continue;
|
||||
else
|
||||
{
|
||||
cateclt.TabName = tab.Name;
|
||||
cateclt.OrderIndex = abtc.Tabs.IndexOf(tab);
|
||||
}
|
||||
cateclt.MachineAttributes = new List<MachineAttributeClient>();
|
||||
|
||||
foreach (MachineAttributeItem attitem in cateitem.Attributes)
|
||||
{
|
||||
MachineAttributeClient attclt = new MachineAttributeClient();
|
||||
Helper.CloneProperty(attclt, attitem);
|
||||
cateclt.MachineAttributes.Add(attclt);
|
||||
}
|
||||
list.Add(cateclt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void ConvertMachineAttributes(MachineAttributes abtc, ref List<MachineAttributeClient> list)
|
||||
{
|
||||
if (abtc != null && abtc.Category.Count > 0)
|
||||
{
|
||||
foreach (MachineAttributeCategory cateitem in abtc.Category)
|
||||
{
|
||||
foreach (MachineAttributeItem attitem in cateitem.Attributes)
|
||||
{
|
||||
MachineAttributeClient attclt = new MachineAttributeClient();
|
||||
Helper.CloneProperty(attclt, attitem);
|
||||
list.Add(attclt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Odometer Adjustment History
|
||||
|
||||
private object GetOdometerAdjustmentHistory()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var customerid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var assetid = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
var sdate = HttpUtility.HtmlDecode(clientdata[2]);
|
||||
var edate = HttpUtility.HtmlDecode(clientdata[3]);
|
||||
if (string.IsNullOrEmpty(customerid))
|
||||
customerid = SystemParams.CompanyID;
|
||||
|
||||
DateTime starttime = Helper.DBMinDateTime;
|
||||
DateTime endtime = DateTime.MaxValue;
|
||||
if (!DateTime.TryParse(sdate, out starttime))
|
||||
starttime = Helper.DBMinDateTime;
|
||||
|
||||
if (!DateTime.TryParse(edate, out endtime))
|
||||
endtime = DateTime.MaxValue;
|
||||
else
|
||||
endtime = endtime.Date.AddDays(1).AddSeconds(-1);
|
||||
|
||||
AssetOdometerAdjustInfo[] odos = CreateClient<AssetDataAdjustClient>(customerid).GetOdometerAdjustmentHistory(customerid, Convert.ToInt64(assetid), starttime, endtime);
|
||||
if (odos == null || odos.Length == 0)
|
||||
return new AssetOdometerAdjustItem[0];
|
||||
|
||||
List<AssetOdometerAdjustItem> list = new List<AssetOdometerAdjustItem>();
|
||||
foreach (AssetOdometerAdjustInfo odo in odos)
|
||||
{
|
||||
AssetOdometerAdjustItem item = new AssetOdometerAdjustItem();
|
||||
Helper.CloneProperty(item, odo);
|
||||
list.Add(item);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
else
|
||||
return new AssetOdometerAdjustItem[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Engine Hours Adjustment History
|
||||
private object GetEngineHoursAdjustmentHistory()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var customerid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var assetid = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
var sdate = HttpUtility.HtmlDecode(clientdata[2]);
|
||||
var edate = HttpUtility.HtmlDecode(clientdata[3]);
|
||||
if (string.IsNullOrEmpty(customerid))
|
||||
customerid = SystemParams.CompanyID;
|
||||
|
||||
DateTime starttime = Helper.DBMinDateTime;
|
||||
DateTime endtime = DateTime.MaxValue;
|
||||
if (!DateTime.TryParse(sdate, out starttime))
|
||||
starttime = Helper.DBMinDateTime;
|
||||
|
||||
if (!DateTime.TryParse(edate, out endtime))
|
||||
endtime = DateTime.MaxValue;
|
||||
else
|
||||
endtime = endtime.Date.AddDays(1).AddSeconds(-1);
|
||||
|
||||
AssetEngineHoursAdjustInfo[] hours = CreateClient<AssetDataAdjustClient>(customerid).GetEngineHoursAdjustmentHistory(customerid, Convert.ToInt64(assetid), starttime, endtime);
|
||||
if (hours == null || hours.Length == 0)
|
||||
return new AssetEngineHoursAdjustItem[0];
|
||||
|
||||
List<AssetEngineHoursAdjustItem> list = new List<AssetEngineHoursAdjustItem>();
|
||||
foreach (AssetEngineHoursAdjustInfo hour in hours)
|
||||
{
|
||||
AssetEngineHoursAdjustItem item = new AssetEngineHoursAdjustItem();
|
||||
Helper.CloneProperty(item, hour);
|
||||
list.Add(item);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
else
|
||||
return new AssetEngineHoursAdjustItem[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
private object GetCustomerTimeZone()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string custid = Request.Form["ClientData"];
|
||||
FISqlConnection db = null;
|
||||
if (SystemParams.IsDealer)
|
||||
{
|
||||
if (string.IsNullOrEmpty(custid))
|
||||
custid = SystemParams.CompanyID;
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(custid);
|
||||
db = new FISqlConnection(connetionstring);
|
||||
}
|
||||
else
|
||||
custid = SystemParams.CompanyID;
|
||||
|
||||
StringKeyValue kv = new StringKeyValue();
|
||||
kv.Key = SystemParams.GetStringParam("CustomerTimeZone", false, db);
|
||||
TimeZoneInfo tz = SystemParams.GetTimeZoneInfo(custid, db);
|
||||
DateTime time = TimeZoneInfo.ConvertTimeFromUtc(DateTime.Now.ToUniversalTime(), tz);
|
||||
kv.Value = time.ToString("MM/dd/yyyy HH:mm:ss");
|
||||
return kv;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("not login.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object ChangeMachineIconFile()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
|
||||
StringKeyValue kv = JsonConvert.DeserializeObject<StringKeyValue>(clientdata);
|
||||
|
||||
HttpPostedFile uploadFile = null;
|
||||
byte[] iconfilebyte = null;
|
||||
if (Request.Files.Count > 0)
|
||||
{
|
||||
uploadFile = Request.Files[0];
|
||||
iconfilebyte = ConvertFile2bytes(uploadFile);
|
||||
}
|
||||
FISqlConnection db = null;
|
||||
if (SystemParams.IsDealer)
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(kv.Key);
|
||||
db = new FISqlConnection(connetionstring);
|
||||
}
|
||||
MachineManagement.ChangeMachineIconFile(Convert.ToInt64(kv.Value), uploadFile == null ? "" : uploadFile.FileName, iconfilebyte, db);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetPMSchedulesByAsset()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
|
||||
long assetid = 0;
|
||||
long.TryParse(clientdata, out assetid);
|
||||
return MaintenanceManagement.GetPmScheduleByAsset(session.SessionID, assetid);
|
||||
}
|
||||
else
|
||||
return new PmScheduleInfo[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AssetBasePage.GetPmSchedules", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object AddAssetToPMSchedule()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
|
||||
PMScheduleAssetItem p = JsonConvert.DeserializeObject<PMScheduleAssetItem>(clientdata);
|
||||
|
||||
PMAssetInfo pmAsset = new PMAssetInfo();
|
||||
pmAsset.AssetId = p.AssetId;
|
||||
pmAsset.StartHours = p.StartHours;
|
||||
pmAsset.StartOdometer = p.StartOdometer;
|
||||
pmAsset.StartDate = p.StartDate;
|
||||
pmAsset.StartIntervalValue = p.StartIntervalValue;
|
||||
|
||||
var client = CreateClient<PMClient>();
|
||||
client.UpdatePMScheduleAsset(SystemParams.CompanyID, p.PmScheduleID, pmAsset, session.User.UID);
|
||||
if (!string.IsNullOrEmpty(p.SelectedIntervalID))
|
||||
{
|
||||
//SystemParams.PMClient.TriggerPMAlert(SystemParams.CompanyID, p.PmScheduleID, pmAsset.AssetId);
|
||||
client.GenerateMissedPMAlert(SystemParams.CompanyID, p.SelectedIntervalID, pmAsset.AssetId);
|
||||
}
|
||||
}
|
||||
return "OK";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AssetBasePage.GetPmSchedules", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object RemoveAssetFromPMSchedule()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
|
||||
string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata);
|
||||
long assetid = 0;
|
||||
long.TryParse(ps[0], out assetid);
|
||||
|
||||
CreateClient<PMClient>().DeleteAssetsFromSchedule(SystemParams.CompanyID, ps[1], new long[] { assetid }, session.User.UID);
|
||||
}
|
||||
return "OK";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AssetBasePage.GetPmSchedules", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
class PMScheduleAssetItem
|
||||
{
|
||||
public long AssetId { get; set; }
|
||||
public string PmScheduleID { get; set; }
|
||||
public double? StartHours { get; set; }
|
||||
public double? StartOdometer { get; set; }
|
||||
public DateTime? StartDate { get; set; }
|
||||
public int? StartIntervalValue { get; set; }
|
||||
public string SelectedIntervalID { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
60
IronIntelContractorSiteLib/ChangePasswordBasePage.cs
Normal file
60
IronIntelContractorSiteLib/ChangePasswordBasePage.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services;
|
||||
using IronIntel.Services.Users;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace IronIntel.Contractor.Site
|
||||
{
|
||||
public class ChangePasswordBasePage : ContractorBasePage
|
||||
{
|
||||
protected string UserID;
|
||||
|
||||
protected void ProcessRequest()
|
||||
{
|
||||
string methodName = Request.Params["MethodName"];
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName.ToUpper())
|
||||
{
|
||||
case "CHANGEPASSWORD":
|
||||
ChangePassword();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangePassword()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session == null)
|
||||
{
|
||||
Response.Write("\"Please login.\"");
|
||||
Response.End();
|
||||
return;
|
||||
}
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var oldpass = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var newpass = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
try
|
||||
{
|
||||
var client = CreateClient<Foresight.Fleet.Services.User.UserQueryClient>();
|
||||
client.SessionID = session.SessionID;
|
||||
client.ClientHost = Request.UserHostName;
|
||||
client.ChangePassword(session.User.UID, oldpass, newpass, session.SessionID);
|
||||
Response.Write(string.Empty);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Response.Write(JsonConvert.SerializeObject(ex.Message));
|
||||
}
|
||||
Response.End();
|
||||
}
|
||||
}
|
||||
}
|
182
IronIntelContractorSiteLib/CommonHttpRequestHandler.cs
Normal file
182
IronIntelContractorSiteLib/CommonHttpRequestHandler.cs
Normal file
@ -0,0 +1,182 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using Newtonsoft.Json;
|
||||
using IronIntel.Services;
|
||||
using IronIntel.Site;
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services.Customers;
|
||||
|
||||
namespace IronIntel.Contractor.Site
|
||||
{
|
||||
public class CommonHttpRequestHandler : IronIntelHttpHandlerBase
|
||||
{
|
||||
public static byte[] GetCompanyLOGO(string companyid)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(companyid))
|
||||
{
|
||||
return SystemParams.GetCompanyLOGO(CompanyInfo.FORESIGHT);
|
||||
}
|
||||
else
|
||||
{
|
||||
return SystemParams.GetCompanyLOGO(companyid);
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] GetForesightLOGOInMainStyle()
|
||||
{
|
||||
return SystemParams.GetForesightLOGOInMainStyle();
|
||||
}
|
||||
|
||||
public static byte[] GetCompanyLocationLOGO(string companyid)
|
||||
{
|
||||
return SystemParams.GetCompanyLocationLOGO(companyid);
|
||||
}
|
||||
public static byte[] GetLocationLOGO(string companyid)
|
||||
{
|
||||
return SystemParams.GetCompanyLocationLOGO(companyid);
|
||||
}
|
||||
|
||||
public static byte[] GetCustomerLocationLOGO(int locationid)
|
||||
{
|
||||
CustomerProvider ic = SystemParams.GetCustomerProvider();
|
||||
return ic.GetCustomerLocationLOGO(locationid);
|
||||
}
|
||||
public override string GetIronSystemServiceAddress()
|
||||
{
|
||||
return SystemParams.SystemServiceAddresses[0];
|
||||
}
|
||||
|
||||
public CommonHttpRequestHandler(HttpContext context)
|
||||
: base(context)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ProcessRequest()
|
||||
{
|
||||
string s = ReadTextFromStream(Context.Request.InputStream);
|
||||
if (string.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
Context.Response.StatusCode = 204;
|
||||
Context.Response.End();
|
||||
return;
|
||||
}
|
||||
CommonRequestObject req = null;
|
||||
try
|
||||
{
|
||||
req = JsonConvert.DeserializeObject<CommonRequestObject>(s);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Context.Response.StatusCode = 400;
|
||||
Context.Response.End();
|
||||
return;
|
||||
}
|
||||
if (req == null)
|
||||
{
|
||||
Context.Response.StatusCode = 204;
|
||||
Context.Response.End();
|
||||
return;
|
||||
}
|
||||
ProcessRequest(req);
|
||||
}
|
||||
|
||||
private void ProcessRequest(CommonRequestObject req)
|
||||
{
|
||||
switch (req.Method)
|
||||
{
|
||||
case CommonRequestMethods.IamAlive:
|
||||
IamAlive();
|
||||
return;
|
||||
case CommonRequestMethods.GetAppModules:
|
||||
GetAppModules();
|
||||
return;
|
||||
case CommonRequestMethods.GetCurrentLoginName:
|
||||
GetCurrentLoginName();
|
||||
return;
|
||||
case CommonRequestMethods.AddLog:
|
||||
AddLog(req.ClientData);
|
||||
return;
|
||||
default:
|
||||
Context.Response.StatusCode = 204;
|
||||
Context.Response.End();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void IamAlive()
|
||||
{
|
||||
if (LoginSession == null)
|
||||
{
|
||||
Context.Response.StatusCode = 401;
|
||||
}
|
||||
else
|
||||
{
|
||||
Context.Response.Write("\"OK\"");
|
||||
Context.Response.StatusCode = 200;
|
||||
}
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
private void GetAppModules()
|
||||
{
|
||||
if (LoginSession == null)
|
||||
{
|
||||
Context.Response.StatusCode = 401;
|
||||
Context.Response.End();
|
||||
return;
|
||||
}
|
||||
AppModuleInfo[] items = Acl.GetAvailableAppModuleInfos(LoginSession.User.UID);
|
||||
string json = JsonConvert.SerializeObject(items);
|
||||
Context.Response.Write(json);
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
private void GetCurrentLoginName()
|
||||
{
|
||||
string s = LoginSession == null ? string.Empty : LoginSession.User.Name;
|
||||
|
||||
Context.Response.Write(s);
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
private void AddLog(string clientdata)
|
||||
{
|
||||
const char SPLITCHAR = (char)170;
|
||||
|
||||
Context.Response.StatusCode = 200;
|
||||
try
|
||||
{
|
||||
string[] s = clientdata.Split(new char[] { SPLITCHAR });
|
||||
SystemParams.WriteLog(s[0], s[1], s[2], s[3]);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
Context.Response.End();
|
||||
}
|
||||
}
|
||||
|
||||
sealed class CommonRequestObject
|
||||
{
|
||||
public int MethodID { get; set; }
|
||||
public string ClientData { get; set; }
|
||||
public CommonRequestMethods Method
|
||||
{
|
||||
get { return (CommonRequestMethods)MethodID; }
|
||||
}
|
||||
}
|
||||
|
||||
enum CommonRequestMethods
|
||||
{
|
||||
IamAlive = 0,
|
||||
GetAppModules = 1,
|
||||
GetCurrentLoginName = 2,
|
||||
AddLog = 3,
|
||||
GetMachineMapPinItem = 4,
|
||||
GetJobSiteMapItem = 5
|
||||
}
|
||||
}
|
290
IronIntelContractorSiteLib/Contact/ContactBasePage.cs
Normal file
290
IronIntelContractorSiteLib/Contact/ContactBasePage.cs
Normal file
@ -0,0 +1,290 @@
|
||||
using Foresight.Fleet.Services.JobSite;
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Contractor.Contact;
|
||||
using IronIntel.Contractor.JobSites;
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
using IronIntel.Contractor.MapView;
|
||||
using IronIntel.Contractor.Users;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Contact
|
||||
{
|
||||
public class ContactBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
object result = null;
|
||||
try
|
||||
{
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName)
|
||||
{
|
||||
case "GetContacts":
|
||||
result = GetContacts();
|
||||
break;
|
||||
case "SaveContact":
|
||||
result = SaveContact();
|
||||
break;
|
||||
case "GetUsers":
|
||||
result = GetUsers();
|
||||
break;
|
||||
case "DeleteContact":
|
||||
result = DeleteContact();
|
||||
break;
|
||||
case "GetSelectedMachines":
|
||||
result = GetSelectedMachines();
|
||||
break;
|
||||
case "SaveContactMachines":
|
||||
result = SaveContactMachines();
|
||||
break;
|
||||
case "GetJobsiteList":
|
||||
result = GetJobsiteList();
|
||||
break;
|
||||
case "GetSelectedJobsites":
|
||||
result = GetSelectedJobsites();
|
||||
break;
|
||||
case "SaveContactJobsites":
|
||||
result = SaveContactJobsites();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "ContactBasePage", ex.Message, ex.ToString());
|
||||
throw ex;
|
||||
}
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private object GetContacts()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
ContactInfo[] items = null;
|
||||
if (session != null)
|
||||
{
|
||||
var s = Request.Form["ClientData"];
|
||||
s = HttpUtility.HtmlDecode(s);
|
||||
|
||||
items = ContactManagement.GetContacts(session.SessionID);
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new ContactInfo[0];
|
||||
}
|
||||
return items.OrderBy(m => m.ContactName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string SaveContact()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var s = Request.Form["ClientData"];
|
||||
s = HttpUtility.HtmlDecode(s);
|
||||
|
||||
var ci = JsonConvert.DeserializeObject<ContactInfo>(s);
|
||||
if (string.IsNullOrWhiteSpace(ci.ContactID))
|
||||
{
|
||||
ci.ContactID = Guid.NewGuid().ToString();
|
||||
}
|
||||
|
||||
ContactManagement.SaveContact(ci, GetCurrentLoginSession().User.UID);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetUsers()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
UserInfo[] items = null;
|
||||
if (session != null)
|
||||
{
|
||||
items = UserManagement.GetUsers();
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new UserInfo[0];
|
||||
}
|
||||
return items.OrderBy(m => m.ID);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string DeleteContact()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var contactid = Request.Form["ClientData"];
|
||||
contactid = HttpUtility.HtmlDecode(contactid);
|
||||
ContactManagement.DeleteContact(contactid);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private MaintenanceMachineInfo[] GetSelectedMachines()
|
||||
{
|
||||
var contactid = Request.Form["ClientData"];
|
||||
var machines = ContactManagement.GetContactMachinesByID(contactid);
|
||||
|
||||
return machines.OrderBy(m => m.VIN).ToArray();
|
||||
}
|
||||
|
||||
private string SaveContactMachines()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var contactid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var machineids = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
string[] ids = JsonConvert.DeserializeObject<string[]>(machineids);
|
||||
|
||||
ContactManagement.SaveContactMachines(contactid, SystemParams.CompanyID, ids);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetJobsiteList()
|
||||
{
|
||||
try
|
||||
{
|
||||
JobSiteViewItem[] items = null;
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var s = Request.Form["ClientData"];
|
||||
s = HttpUtility.UrlDecode(s);
|
||||
|
||||
var jss = CreateClient<JobSiteProvider>().GetJobSiteItems(SystemParams.CompanyID, "", false);
|
||||
List<JobSiteViewItem> list = new List<JobSiteViewItem>();
|
||||
foreach (var js in jss)
|
||||
{
|
||||
JobSiteViewItem item = new JobSiteViewItem();
|
||||
item.ID = js.ID;
|
||||
item.Name = js.Name;
|
||||
|
||||
list.Add(item);
|
||||
}
|
||||
items = list.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new JobSiteViewItem[0];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private object GetSelectedJobsites()
|
||||
{
|
||||
try
|
||||
{
|
||||
JobSiteViewItem[] items = null;
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var contactid = Request.Form["ClientData"];
|
||||
contactid = HttpUtility.UrlDecode(contactid);
|
||||
|
||||
items = ContactManagement.GetContactJobsitesByID(contactid);
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new JobSiteViewItem[0];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string SaveContactJobsites()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var contactid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var jobsiteids = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
string[] ids = JsonConvert.DeserializeObject<string[]>(jobsiteids);
|
||||
|
||||
ContactManagement.SaveContactJobsites(contactid, SystemParams.CompanyID, ids);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
217
IronIntelContractorSiteLib/ContractorBasePage.cs
Normal file
217
IronIntelContractorSiteLib/ContractorBasePage.cs
Normal file
@ -0,0 +1,217 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using IronIntel.Services;
|
||||
using IronIntel.Services.Users;
|
||||
using IronIntel.Site;
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services.Customers;
|
||||
using System.Web;
|
||||
using Foresight.Fleet.Services;
|
||||
|
||||
namespace IronIntel.Contractor.Site
|
||||
{
|
||||
public class ContractorBasePage : IronIntelBasePage
|
||||
{
|
||||
public static string AppVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return SystemParams.AppVersion;
|
||||
}
|
||||
}
|
||||
|
||||
new public string PageTitle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (MainStyleObj != null && !string.IsNullOrWhiteSpace(MainStyleObj.PageTitle))
|
||||
return MainStyleObj.PageTitle;
|
||||
return base.PageTitle;
|
||||
}
|
||||
}
|
||||
|
||||
private MainStyle _MainStyleObj;
|
||||
protected MainStyle MainStyleObj
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_MainStyleObj == null)
|
||||
{
|
||||
_MainStyleObj = SystemParams.GetMainStyle();
|
||||
}
|
||||
return _MainStyleObj;
|
||||
}
|
||||
}
|
||||
|
||||
protected IronIntel.Contractor.Users.UserInfo GetCurrentUser()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return UserManagement.GetUserByIID(session.User.UID);
|
||||
}
|
||||
|
||||
protected bool IsAdminOrSuper
|
||||
{
|
||||
get
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return (user.UserType == UserTypes.Admin || user.UserType == UserTypes.SupperAdmin);
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetIronSystemServiceAddress()
|
||||
{
|
||||
return SystemParams.SystemServiceAddresses[0];
|
||||
}
|
||||
|
||||
protected virtual bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (string.Compare(session.User.CompanyID, SystemParams.CompanyID, true) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (string.Compare(session.User.CompanyID, CompanyInfo.FORESIGHT, true) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return CreateClient<Foresight.Fleet.Services.User.UserQueryClient>().CanEnterSite(session.SessionID, SystemParams.CompanyID);
|
||||
}
|
||||
|
||||
protected virtual bool ThrowIfNotAllowed { get { return false; } }
|
||||
|
||||
protected bool CheckLoginSession()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session == null)
|
||||
{
|
||||
RedirectToLoginPage();
|
||||
return false;
|
||||
}
|
||||
if (!AllowCurrentLoginSessionEnter())
|
||||
{
|
||||
if (ThrowIfNotAllowed)
|
||||
{
|
||||
throw new Exception("The user was not allowed to enter this page.");
|
||||
}
|
||||
else
|
||||
{
|
||||
string entry = GetUserDefaultEntryPageUrl(session.User);
|
||||
if (string.IsNullOrEmpty(entry))
|
||||
Response.Redirect(entry, true);
|
||||
else
|
||||
Response.Redirect(LoginPageUrl, true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void DoLogout()
|
||||
{
|
||||
string sid = null;
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
sid = session.SessionID;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
try
|
||||
{
|
||||
ClearLoginSessionCookie();
|
||||
}
|
||||
catch { }
|
||||
if (sid != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
CreateClient<Foresight.Fleet.Services.User.UserQueryClient>().LogoutWithSessionID(sid);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
|
||||
RedirectToLoginPage();
|
||||
}
|
||||
|
||||
protected void AddLog(string type, string source, string message, string detail)
|
||||
{
|
||||
try
|
||||
{
|
||||
SystemParams.WriteLog(type, source, message, detail);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
|
||||
protected string GenerateUrl(string file)
|
||||
{
|
||||
string url;
|
||||
System.Web.UI.Page page = System.Web.HttpContext.Current.Handler as System.Web.UI.Page;
|
||||
if (page != null)
|
||||
{
|
||||
// Use page instance.
|
||||
url = page.ResolveUrl("~/") + file;
|
||||
}
|
||||
else
|
||||
{
|
||||
// avoid duplicate operation
|
||||
url = System.Web.HttpContext.Current.Request.ApplicationPath + "/" + file;
|
||||
}
|
||||
try
|
||||
{
|
||||
var path = System.IO.Path.Combine(System.Web.HttpContext.Current.Request.PhysicalApplicationPath, file);
|
||||
if (System.IO.File.Exists(path))
|
||||
{
|
||||
url += "?t=" + System.IO.File.GetLastWriteTimeUtc(path).Ticks;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// cant read file
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
protected byte[] ConvertFile2bytes(HttpPostedFile uploadFile)
|
||||
{
|
||||
byte[] dataBuffer = new byte[uploadFile.InputStream.Length];
|
||||
uploadFile.InputStream.Position = 0;
|
||||
uploadFile.InputStream.Read(dataBuffer, 0, dataBuffer.Length);
|
||||
uploadFile.InputStream.Close();
|
||||
return dataBuffer;
|
||||
}
|
||||
|
||||
public virtual string JQueryVersion
|
||||
{
|
||||
get { return "1.8.0"; }
|
||||
}
|
||||
|
||||
protected T CreateClient<T>(string companyid = null) where T : RemoteClientBase
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
return FleetServiceClientHelper.CreateClient<T>(companyid, session == null ? "" : session.SessionID);
|
||||
}
|
||||
}
|
||||
}
|
333
IronIntelContractorSiteLib/CredentialEntryBasePage.cs
Normal file
333
IronIntelContractorSiteLib/CredentialEntryBasePage.cs
Normal file
@ -0,0 +1,333 @@
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services;
|
||||
using IronIntel.Services.CredentialObjects;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace IronIntel.Contractor.Site
|
||||
{
|
||||
public class CredentialEntryBasePage : ContractorBasePage
|
||||
{
|
||||
private const string AEMP = "AEMPFLEET";
|
||||
private const string JDAPI = "JDAPI";
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName)
|
||||
{
|
||||
case "GetCredentials":
|
||||
GetCredentials();
|
||||
break;
|
||||
case "SaveCredential":
|
||||
SaveCredential(true);
|
||||
break;
|
||||
case "DeleteCredential":
|
||||
DeleteCredential();
|
||||
break;
|
||||
case "GetAEMPSources":
|
||||
GetAEMPSources();
|
||||
break;
|
||||
case "GetJDLinkCredentials":
|
||||
GetJDLinkCredentials();
|
||||
break;
|
||||
case "AuthorizeRequestToken":
|
||||
AuthorizeRequestToken();
|
||||
break;
|
||||
case "FinishJDLinkOAuthRequest":
|
||||
FinishJDLinkOAuthRequest();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Response.End();
|
||||
}
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// check whether you are admin.
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session == null || session.User == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var ui = UserManagement.GetUserByIID(session.User.UID);
|
||||
return ui != null && ui.UserType >= UserTypes.Admin;
|
||||
}
|
||||
|
||||
protected override bool ThrowIfNotAllowed { get { return true; } }
|
||||
|
||||
private void GetCredentials()
|
||||
{
|
||||
string type = Request.Form["ClientData"];
|
||||
string creType = "";
|
||||
switch (type)
|
||||
{
|
||||
case "AEMP":
|
||||
creType = AEMP;
|
||||
break;
|
||||
}
|
||||
CredentialManagementClient crd = SystemParams.GetServiceClient<CredentialManagementClient>();
|
||||
CredentialInfo[] creInfos = crd.GetCredentialByCompanyID(SystemParams.CompanyID, creType);
|
||||
|
||||
List<CredentialObj> creObjs = new List<CredentialObj>();
|
||||
foreach (var cre in creInfos)
|
||||
{
|
||||
creObjs.Add(ConvertFromAEMP(cre));
|
||||
}
|
||||
var items = creObjs.OrderBy((c) => c.UserName).ToArray();
|
||||
string json = JsonConvert.SerializeObject(items);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private void SaveCredential(bool adduser)
|
||||
{
|
||||
var content = Request.Form["ClientData"];
|
||||
content = HttpUtility.HtmlDecode(content);
|
||||
var item = JsonConvert.DeserializeObject<CredentialObj>(content);
|
||||
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(item.ID))
|
||||
item.ID = Guid.NewGuid().ToString();
|
||||
CredentialInfo creInfo = null;
|
||||
switch (item.CredentialType)
|
||||
{
|
||||
case "AEMP":
|
||||
creInfo = ConvertToAEMP(item);
|
||||
break;
|
||||
}
|
||||
if (creInfo != null)
|
||||
{
|
||||
CredentialManagementClient crd = SystemParams.GetServiceClient<CredentialManagementClient>();
|
||||
crd.UpdateCredential(creInfo);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Response.Write(JsonConvert.SerializeObject(ex.Message));
|
||||
return;
|
||||
}
|
||||
|
||||
Response.Write("\"OK\"");
|
||||
}
|
||||
|
||||
private void DeleteCredential()
|
||||
{
|
||||
var iid = Request.Form["ClientData"];
|
||||
Guid guid;
|
||||
if (!Guid.TryParse(iid, out guid))
|
||||
{
|
||||
throw new ArgumentException("Credential IID is not valid.");
|
||||
}
|
||||
CredentialManagementClient crd = SystemParams.GetServiceClient<CredentialManagementClient>();
|
||||
crd.DeleteCredential(iid);
|
||||
}
|
||||
|
||||
private void GetAEMPSources()
|
||||
{
|
||||
IronSysServiceClient ic = SystemParams.GetIronSystemServiceClient();
|
||||
AEMPSourceInfo[] sources = ic.GetAEMPSourceInfo();
|
||||
|
||||
List<AEMPSourceItem> list = new List<AEMPSourceItem>();
|
||||
foreach (var source in sources)
|
||||
{
|
||||
AEMPSourceItem item = new AEMPSourceItem();
|
||||
Helper.CloneProperty(item, source);
|
||||
list.Add(item);
|
||||
}
|
||||
var items = list.OrderBy((c) => c.ManufactureName).ToArray();
|
||||
string json = JsonConvert.SerializeObject(items);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
#region AEMP
|
||||
|
||||
private CredentialObj ConvertFromAEMP(CredentialInfo cre)
|
||||
{
|
||||
CredentialObj result = new CredentialObj();
|
||||
result.ID = cre.ID;
|
||||
result.CredentialType = cre.CredentialType;
|
||||
|
||||
AEMPCredential aemp = new AEMPCredential();
|
||||
aemp.FillFromXml(cre.Credential);
|
||||
if (aemp != null)
|
||||
{
|
||||
result.Manufacture = aemp.ManufactureID;
|
||||
result.UserName = aemp.UserName;
|
||||
result.Password = aemp.Password;
|
||||
result.Enabled = aemp.Enabled;
|
||||
result.UrlKey = aemp.UrlKey;
|
||||
result.OrgnizationID = aemp.OrgnizationID;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private CredentialInfo ConvertToAEMP(CredentialObj cre)
|
||||
{
|
||||
CredentialInfo result = new CredentialInfo();
|
||||
result.ID = cre.ID;
|
||||
result.CredentialType = AEMP;
|
||||
result.CompanyID = SystemParams.CompanyID;
|
||||
|
||||
AEMPCredential aemp = new AEMPCredential();
|
||||
aemp.ManufactureID = cre.Manufacture;
|
||||
aemp.UserName = cre.UserName;
|
||||
aemp.Password = cre.Password;
|
||||
aemp.Enabled = cre.Enabled;
|
||||
aemp.UrlKey = cre.UrlKey;
|
||||
aemp.OrgnizationID = cre.OrgnizationID;
|
||||
|
||||
result.Credential = aemp.ToString();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region JDLink credential
|
||||
private void GetJDLinkCredentials()
|
||||
{
|
||||
CredentialManagementClient client = SystemParams.GetServiceClient<CredentialManagementClient>();
|
||||
JDCredential[] jds = client.GetJDLinkCredentials(SystemParams.CompanyID);
|
||||
List<JDCredentialObj> list = new List<JDCredentialObj>();
|
||||
foreach (var jd in jds)
|
||||
{
|
||||
JDCredentialObj item = new JDCredentialObj();
|
||||
item.ID = jd.ID;
|
||||
item.UserName = jd.Credential.UserName;
|
||||
item.ExpirationDateUtc = jd.Credential.ExpirationDateUtc;
|
||||
item.ConsumerKey = jd.Credential.ConsumerKey;
|
||||
item.AuthorityUrl = jd.Credential.AuthorityUrl;
|
||||
list.Add(item);
|
||||
}
|
||||
var items = list.OrderBy(m => m.UserName).ToArray();
|
||||
string json = JsonConvert.SerializeObject(items);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private void AuthorizeRequestToken()
|
||||
{
|
||||
string username = Request.Form["ClientData"];
|
||||
username = HttpUtility.HtmlDecode(username);
|
||||
CredentialManagementClient client = SystemParams.GetServiceClient<CredentialManagementClient>();
|
||||
JDCredential[] jds = client.GetJDLinkCredentials(SystemParams.CompanyID);
|
||||
JDCredential jd = jds.FirstOrDefault(m => m.Credential.UserName == username);
|
||||
if (jd != null)
|
||||
{
|
||||
Response.Write(JsonConvert.SerializeObject("User name already exists."));
|
||||
Response.End();
|
||||
}
|
||||
StringKeyValue kv = GetJDLinkApiKey();
|
||||
if (kv == null)
|
||||
{
|
||||
Response.Write(JsonConvert.SerializeObject("The JDLink Key does not exist,Please contact the administrator."));
|
||||
Response.End();
|
||||
}
|
||||
JDOAuthData data = client.GetJDLinkAuthorizeRequestOAuth(kv.Key, kv.Value);
|
||||
string json = JsonConvert.SerializeObject(data);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
public void FinishJDLinkOAuthRequest()
|
||||
{
|
||||
try
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var authordata = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
string virifier = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
JDOAuthData oriauthdata = JsonConvert.DeserializeObject<JDOAuthData>(authordata);
|
||||
CredentialManagementClient client = SystemParams.GetServiceClient<CredentialManagementClient>();
|
||||
JDOAuthData data = client.FinishJDLinkOAuthRequest(oriauthdata, virifier);
|
||||
CredentialInfo ci = new CredentialInfo();
|
||||
ci.ID = Guid.NewGuid().ToString().ToUpper();
|
||||
ci.CompanyID = SystemParams.CompanyID;
|
||||
ci.CredentialType = "JDLINK";
|
||||
JDCredential jd = new JDCredential();
|
||||
jd.Credential = data;
|
||||
jd.Enabled = true;
|
||||
ci.Credential = jd.ToString();
|
||||
client.UpdateCredential(ci);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Response.Write(JsonConvert.SerializeObject(ex.Message));
|
||||
return;
|
||||
}
|
||||
|
||||
Response.Write("\"OK\"");
|
||||
}
|
||||
|
||||
private StringKeyValue GetJDLinkApiKey()
|
||||
{
|
||||
string key = SystemParams.GetStringParam("JDAPIConsumerKey");
|
||||
if (string.IsNullOrWhiteSpace(key))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string sec = SystemParams.GetStringParam("JDAPIConsumerSecret");
|
||||
if (string.IsNullOrWhiteSpace(sec))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
StringKeyValue kv = new StringKeyValue();
|
||||
kv.Key = key;
|
||||
kv.Value = sec;
|
||||
return kv;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 用于传输的临时Credential类
|
||||
/// </summary>
|
||||
public class CredentialObj
|
||||
{
|
||||
public string ID { get; set; }
|
||||
public string CredentialType { get; set; }
|
||||
public string Manufacture { get; set; }
|
||||
public string UrlKey { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string Password { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
public string OrgnizationID { get; set; }
|
||||
}
|
||||
|
||||
public class AEMPSourceItem
|
||||
{
|
||||
public string ManufactureID { get; set; }
|
||||
public string ManufactureName { get; set; }
|
||||
public string FleetUrl { get; set; }
|
||||
public string AutoServiceClass { get; set; }
|
||||
}
|
||||
|
||||
public class JDCredentialObj
|
||||
{
|
||||
public string ID { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string ConsumerKey { get; set; }
|
||||
public string AuthorityUrl { get; set; }
|
||||
public DateTime ExpirationDateUtc { get; set; }
|
||||
public string ExpirationDateUtcStr { get { return ExpirationDateUtc == DateTime.MinValue ? "" : ExpirationDateUtc.ToShortDateString(); } }
|
||||
}
|
||||
}
|
||||
}
|
259
IronIntelContractorSiteLib/FITrackerBasePage.cs
Normal file
259
IronIntelContractorSiteLib/FITrackerBasePage.cs
Normal file
@ -0,0 +1,259 @@
|
||||
using Foresight.Fleet.Services.FITracker;
|
||||
using Foresight.Fleet.Services.JobSite;
|
||||
using IronIntel.Contractor.FITracker;
|
||||
using IronIntel.Contractor.JobSites;
|
||||
using IronIntel.Contractor.MapView;
|
||||
using IronIntel.Services;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace IronIntel.Contractor.Site
|
||||
{
|
||||
public class FITrackerBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest()
|
||||
{
|
||||
object result = null;
|
||||
try
|
||||
{
|
||||
string methodName = Request.Params["MethodName"];
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName)
|
||||
{
|
||||
case "GetTrackers":
|
||||
result = GetTrackers();
|
||||
break;
|
||||
case "GetMessages":
|
||||
result = GetMessages();
|
||||
break;
|
||||
case "PostMessage":
|
||||
result = PostMessage();
|
||||
break;
|
||||
case "GetJobsites":
|
||||
result = GetJobsites();
|
||||
break;
|
||||
case "ChangeAcceptableAccuracy":
|
||||
result = ChangeAcceptableAccuracy();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "FITrackerBasePage", ex.Message, ex.ToString());
|
||||
throw ex;
|
||||
}
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private object GetTrackers()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
TrackerDeviceItem[] items = null;
|
||||
if (session != null)
|
||||
{
|
||||
var s = Request.Form["ClientData"];
|
||||
s = HttpUtility.HtmlDecode(s);
|
||||
|
||||
List<TrackerDeviceItem> result = new List<TrackerDeviceItem>();
|
||||
var ds = FITrackerManagement.GetTrackerDevices(session.SessionID, "");
|
||||
foreach (MobileDeviceInfo di in ds)
|
||||
{
|
||||
TrackerDeviceItem d = new TrackerDeviceItem();
|
||||
Helper.CloneProperty(d, di);
|
||||
result.Add(d);
|
||||
}
|
||||
items = result.OrderBy(d => d.DeviceName).ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new TrackerDeviceItem[0];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
private object GetMessages()
|
||||
{
|
||||
TrackerChatMessage[] items = null;
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string s = Request.Form["ClientData"];
|
||||
var obj = JsonConvert.DeserializeObject<string[]>(s);
|
||||
string deviceid = obj[0];
|
||||
long lastmsgid = -1;
|
||||
if (!long.TryParse(obj[1], out lastmsgid))
|
||||
lastmsgid = -1;
|
||||
|
||||
List<TrackerChatMessage> result = new List<TrackerChatMessage>();
|
||||
var msgs = FITrackerManagement.GetMessages(session.SessionID, deviceid, lastmsgid);
|
||||
double hourOffset = SystemParams.GetHoursOffset();
|
||||
foreach (ChatMessageInfo msginfo in msgs)
|
||||
{
|
||||
TrackerChatMessage msg = new TrackerChatMessage();
|
||||
Helper.CloneProperty(msg, msginfo);
|
||||
if (msg.Time != DateTime.MinValue)
|
||||
msg.Time = msg.Time.AddHours(hourOffset);
|
||||
msg.IsSelf = session.User.UID.Equals(msg.SenderID, StringComparison.OrdinalIgnoreCase);
|
||||
result.Add(msg);
|
||||
}
|
||||
items = result.ToArray();
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
private object PostMessage()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var s = Request.Form["ClientData"];
|
||||
s = HttpUtility.HtmlDecode(s);
|
||||
var obj = JsonConvert.DeserializeObject<string[]>(s);
|
||||
int type = 0;
|
||||
int.TryParse(obj[2], out type);
|
||||
var msginfo = FITrackerManagement.PostMessage(session.SessionID, obj[0], session.User.UID, session.User.Name, obj[1], type);
|
||||
double hourOffset = SystemParams.GetHoursOffset();
|
||||
|
||||
TrackerChatMessage msg = new TrackerChatMessage();
|
||||
Helper.CloneProperty(msg, msginfo);
|
||||
if (msg.Time != DateTime.MinValue)
|
||||
msg.Time = msg.Time.AddHours(hourOffset);
|
||||
msg.IsSelf = session.User.UID.Equals(msg.SenderID, StringComparison.OrdinalIgnoreCase);
|
||||
return msg;
|
||||
}
|
||||
return "Failed";
|
||||
}
|
||||
|
||||
private object ChangeAcceptableAccuracy()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var s = Request.Form["ClientData"];
|
||||
s = HttpUtility.HtmlDecode(s);
|
||||
var obj = JsonConvert.DeserializeObject<string[]>(s);
|
||||
double accuracy = 0;
|
||||
double.TryParse(obj[1], out accuracy);
|
||||
FITrackerManagement.ChangeAcceptableAccuracy(session.SessionID, obj[0], accuracy, obj[2], session.User.UID);
|
||||
return "";
|
||||
}
|
||||
return "Failed";
|
||||
}
|
||||
|
||||
private object GetJobsites()
|
||||
{
|
||||
try
|
||||
{
|
||||
JobSiteViewItem[] items = null;
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var jss = CreateClient<JobSiteProvider>().GetJobSiteItems(SystemParams.CompanyID, "", false);
|
||||
List<JobSiteViewItem> list = new List<JobSiteViewItem>();
|
||||
foreach (var js in jss)
|
||||
{
|
||||
JobSiteViewItem item = new JobSiteViewItem();
|
||||
item.ID = js.ID;
|
||||
item.Name = js.Name;
|
||||
item.BaseOnMachineID = js.BaseonMachineID;
|
||||
item.Code = js.Code;
|
||||
item.Types = new string[] { js.JobSiteTypes };
|
||||
item.ColorString = js.Color;
|
||||
System.Drawing.Color color = System.Drawing.Color.Orange;
|
||||
try
|
||||
{
|
||||
color = System.Drawing.ColorTranslator.FromHtml(item.ColorString);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
item.Color = new IIColor() { Alpha = color.A, Red = color.R, Green = color.G, Blue = color.B };
|
||||
|
||||
item.Latitude = js.Latitude;
|
||||
item.Longitude = js.Longitude;
|
||||
item.StartDate = js.StartDate == null ? DateTime.MinValue : js.StartDate.Value;
|
||||
item.EndDate = js.EndDate == null ? DateTime.MinValue : js.EndDate.Value;
|
||||
item.Radius = js.Radius;
|
||||
item.Radius_UOM = js.RadiusUOM;
|
||||
if (js.Polygon != null && js.Polygon.Length > 0)
|
||||
{
|
||||
List<PostionItem> temps = new List<PostionItem>();
|
||||
foreach (var p in js.Polygon)
|
||||
{
|
||||
temps.Add(new PostionItem(p.Latitude, p.Longtitude));
|
||||
}
|
||||
item.Polygon = temps.ToArray();
|
||||
}
|
||||
|
||||
list.Add(item);
|
||||
}
|
||||
items = list.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new JobSiteViewItem[0];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
public class TrackerDeviceItem
|
||||
{
|
||||
public string DeviceID { get; set; }
|
||||
public string DeviceName { get; set; }
|
||||
public string DeviceType { get; set; }
|
||||
public long AssetID { get; set; }
|
||||
public string VIN { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Make { get; set; }
|
||||
public string Model { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string ContractorID { get; set; }
|
||||
public string DealerID { get; set; }
|
||||
public long ShiftHistoryID { get; set; }
|
||||
public bool ThirdPartyMode { get; set; }
|
||||
public double AcceptableAccuracy { get; set; }
|
||||
}
|
||||
|
||||
public class TrackerChatMessage
|
||||
{
|
||||
public long AssetID { get; set; }
|
||||
public string ReceiverName { get; set; }
|
||||
public string ReceiverID { get; set; }
|
||||
public string SenderType { get; set; }
|
||||
public string SenderName { get; set; }
|
||||
public string SenderID { get; set; }
|
||||
public string ContractorID { get; set; }
|
||||
public string TextMessage { get; set; }
|
||||
public int MessageType { get; set; }
|
||||
public DateTime Time { get; set; }
|
||||
public long ID { get; set; }
|
||||
public string ReceiverType { get; set; }
|
||||
public bool IsSelf { get; set; }
|
||||
public string TimeText
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Time != DateTime.MinValue)
|
||||
{
|
||||
return Time.ToString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
338
IronIntelContractorSiteLib/FilterQBasePage.cs
Normal file
338
IronIntelContractorSiteLib/FilterQBasePage.cs
Normal file
@ -0,0 +1,338 @@
|
||||
using IronIntel.Contractor.FilterQ;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.Site
|
||||
{
|
||||
public class FilterQBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest()
|
||||
{
|
||||
string methodName = Request.QueryString["method"];
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName.ToUpper())
|
||||
{
|
||||
case "GETFILTERQGROUPS":
|
||||
GetFilterQGroups();
|
||||
break;
|
||||
|
||||
case "SAVEFILTERQ":
|
||||
SaveFilterQ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private FilterQItem ConvertToFilterQItem(MachineTasksNotificationInfo c, bool isdealer)
|
||||
{
|
||||
var item = new FilterQItem
|
||||
{
|
||||
TaskID = c.TaskID,
|
||||
JobContact = c.JobContact,
|
||||
JobContactNumber = c.JobContactNumber,
|
||||
JobAddress1 = c.JobAddress1,
|
||||
JobAddress2 = c.JobAddress2,
|
||||
JobAddressCity = c.JobAddressCity,
|
||||
JobAddressState = c.JobAddressState,
|
||||
JobAddressZip = c.JobAddressZip,
|
||||
|
||||
MachineID = c.MachineID,
|
||||
CurrentJob = c.CurrentJob,
|
||||
OrgMachineCode = c.OrgMachineCode,
|
||||
ManufactuerMake = c.ManufactuerMake,
|
||||
Model = c.Model,
|
||||
SN = (c.SN != null && c.SN.Length > 6) ? c.SN.Substring(c.SN.Length - 6) : c.SN,
|
||||
CumulativeHours = c.CumulativeHours,
|
||||
MachineTaskHourCheck = c.MachineTaskHourCheck,
|
||||
DiffToService = c.DiffToService,
|
||||
EstDueDate = c.ESTServiceNeededBy.ToString("MM/dd/yyyy"),
|
||||
EstShipDate = c.ESTShopDate.ToString("MM/dd/yyyy"),
|
||||
|
||||
TaskComplete = c.TaskComplete,
|
||||
UPSTrackingNumber = c.UPSTrackingNumber,
|
||||
TaskCompletedHours = c.TaskCompletedHours,
|
||||
RequestJREToService = c.RequestJREToService,
|
||||
Approved = c.Approved,
|
||||
Priority = c.Priority,
|
||||
CustomerPO = c.CustomerPO,
|
||||
CustomerWO = c.CustomerWO,
|
||||
AlternateAddress1 = c.AlternateAddress1,
|
||||
AlternateAddress2 = c.AlternateAddress2,
|
||||
AlternateAddressCity = c.AlternateAddressCity,
|
||||
AlternateAddressState = c.AlternateAddressState,
|
||||
AlternateAddressZip = c.AlternateAddressZip,
|
||||
AltJob = c.AltJob,
|
||||
AltJobSiteContact = c.AltJobSiteContact,
|
||||
ShipNotes = c.ShipNotes
|
||||
};
|
||||
if (isdealer)
|
||||
{
|
||||
item.OrganizationName = c.OrganizationName;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
private void GetFilterQGroups()
|
||||
{
|
||||
try
|
||||
{
|
||||
// query shipdates
|
||||
var s = Request.Form["ClientData"];
|
||||
var query = JsonConvert.DeserializeObject<FilterQueryParam>(s);
|
||||
|
||||
|
||||
FilterQGroupByShipDate[] items;
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var isdealer = SystemParams.CustomerDetail.IsDealer;
|
||||
var datas = FilterQManagememt.GetTasksNotofications().ToList();
|
||||
// sort datas
|
||||
var comparer = new FilterQItemComparer { Query = query };
|
||||
if (string.IsNullOrWhiteSpace(query.ColumnSort))
|
||||
{
|
||||
// default sort: Est Ship Date desc
|
||||
datas.Sort((m1, m2) => m2.ESTShopDate.CompareTo(m1.ESTShopDate));
|
||||
}
|
||||
else
|
||||
{
|
||||
datas.Sort(comparer);
|
||||
}
|
||||
|
||||
var lst = new List<FilterQGroupByShipDate>();
|
||||
|
||||
// 组织 shipdates
|
||||
var shipdates = datas.Distinct(new ShipDateEqualityComparer())
|
||||
.Select(m => m.ESTShopDate.ToString("MM/dd/yyyy"))
|
||||
.OrderBy(d => d);
|
||||
var shipgroup = new FilterQGroupByShipDate
|
||||
{
|
||||
ShipDates = shipdates.ToArray(),
|
||||
SelectedShipDates = query.ShipDates
|
||||
};
|
||||
IEnumerable<MachineTasksNotificationInfo> dts = datas;
|
||||
if (query.ShipDates != null && query.ShipDates.Length > 0)
|
||||
{
|
||||
dts = datas.Where(m => query.ShipDates.Contains(m.ESTShopDate.ToString("MM/dd/yyyy")));
|
||||
}
|
||||
else
|
||||
{
|
||||
dts = datas;
|
||||
}
|
||||
|
||||
var notifications = dts.ToArray();
|
||||
var result = notifications.GroupBy(g => g.CurrentJob);
|
||||
var list = new List<FilterQGroup>();
|
||||
foreach (var g in result)
|
||||
{
|
||||
var subresult = g.GroupBy(gr => gr.OrganizationName);
|
||||
foreach (var og in subresult)
|
||||
{
|
||||
var ogs = og.ToArray();
|
||||
|
||||
var group = new FilterQGroup
|
||||
{
|
||||
JobSite = g.Key,
|
||||
OrganizationName = og.Key,
|
||||
};
|
||||
var children = new List<FilterQItem>();
|
||||
// combine address
|
||||
for (int i = 0; i < ogs.Length; i++)
|
||||
{
|
||||
var c = ogs[i];
|
||||
if (query.TaskComplete >= 0 && query.TaskComplete == (c.TaskComplete ? 0 : 1))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
children.Add(ConvertToFilterQItem(c, isdealer));
|
||||
if (group.JobContact == null)
|
||||
{
|
||||
group.JobContact = c.JobContact;
|
||||
}
|
||||
}
|
||||
group.Children = children.ToArray();
|
||||
list.Add(group);
|
||||
}
|
||||
}
|
||||
shipgroup.Groups = list.ToArray();
|
||||
|
||||
lst.Add(shipgroup);
|
||||
//}
|
||||
items = lst.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("not login.");
|
||||
}
|
||||
string json = JsonConvert.SerializeObject(items);
|
||||
Response.Write(json);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Response.Write(JsonConvert.SerializeObject(ex.Message));
|
||||
AddLog("ERROR", "FilterQBasePage.GetFilterQGroups", ex.Message, ex.ToString());
|
||||
}
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private void SaveFilterQ()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
//var s = new System.IO.StreamReader(Request.InputStream).ReadToEnd();
|
||||
//int i = s.IndexOf("&ClientData=");
|
||||
//if (i < 0)
|
||||
//{
|
||||
// Response.Write("false");
|
||||
//}
|
||||
//else
|
||||
{
|
||||
//s = s.Substring(i + 12);
|
||||
//s = System.Web.HttpUtility.UrlDecode(s);
|
||||
|
||||
var s = Request.Form["ClientData"];
|
||||
s = System.Web.HttpUtility.HtmlDecode(s);
|
||||
|
||||
var array = JsonConvert.DeserializeObject<MachineTasksNotificationInfo[]>(s);
|
||||
FilterQManagememt.SaveMachineTasks(array, GetCurrentLoginSession().User.UID);
|
||||
|
||||
Response.Write("true");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.Write("false");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Response.Write(JsonConvert.SerializeObject(ex.Message));
|
||||
}
|
||||
Response.End();
|
||||
}
|
||||
}
|
||||
|
||||
public class ShipDateEqualityComparer : IEqualityComparer<MachineTasksNotificationInfo>
|
||||
{
|
||||
public bool Equals(MachineTasksNotificationInfo x, MachineTasksNotificationInfo y)
|
||||
{
|
||||
if (x == null || y == null)
|
||||
{
|
||||
return x == y;
|
||||
}
|
||||
return x.ESTShopDate == y.ESTShopDate;
|
||||
}
|
||||
|
||||
public int GetHashCode(MachineTasksNotificationInfo obj)
|
||||
{
|
||||
return obj == null ? 0 : obj.ESTShopDate.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
public class FilterQItemComparer : IComparer<MachineTasksNotificationInfo>
|
||||
{
|
||||
public FilterQueryParam Query { get; set; }
|
||||
|
||||
public int Compare(MachineTasksNotificationInfo m1, MachineTasksNotificationInfo m2)
|
||||
{
|
||||
switch (Query.ColumnSort)
|
||||
{
|
||||
case "ORGANIZATION NAME":
|
||||
return Query.IsAsc
|
||||
? string.Compare(m1.OrganizationName, m2.OrganizationName, true)
|
||||
: string.Compare(m2.OrganizationName, m1.OrganizationName, true);
|
||||
case "EQUIPMENT CODE":
|
||||
return Query.IsAsc
|
||||
? string.CompareOrdinal(m1.OrgMachineCode, m2.OrgMachineCode)
|
||||
: string.CompareOrdinal(m2.OrgMachineCode, m1.OrgMachineCode);
|
||||
case "CURRENT JOBSITE":
|
||||
return Query.IsAsc
|
||||
? string.CompareOrdinal(m1.CurrentJob, m2.CurrentJob)
|
||||
: string.CompareOrdinal(m2.CurrentJob, m1.CurrentJob);
|
||||
case "JOBSITE CONTACT":
|
||||
return Query.IsAsc
|
||||
? string.CompareOrdinal(m1.JobContact, m2.JobContact)
|
||||
: string.CompareOrdinal(m2.JobContact, m1.JobContact);
|
||||
case "INFO":
|
||||
return Query.IsAsc
|
||||
? string.CompareOrdinal(m1.ManufactuerMake, m2.ManufactuerMake)
|
||||
: string.CompareOrdinal(m2.ManufactuerMake, m1.ManufactuerMake);
|
||||
case "ESTIMATED SHIP DATE":
|
||||
return Query.IsAsc
|
||||
? DateTime.Compare(m1.ESTShopDate, m2.ESTShopDate)
|
||||
: DateTime.Compare(m2.ESTShopDate, m1.ESTShopDate);
|
||||
case "HOURS TO SERVICE":
|
||||
return Query.IsAsc
|
||||
? m1.DiffToService.CompareTo(m2.DiffToService)
|
||||
: m2.DiffToService.CompareTo(m1.DiffToService);
|
||||
case "TASK COMPLETE?":
|
||||
return Query.IsAsc
|
||||
? m1.TaskComplete.CompareTo(m2.TaskComplete)
|
||||
: m2.TaskComplete.CompareTo(m1.TaskComplete);
|
||||
case "UPS TRACKING NUMBER":
|
||||
return Query.IsAsc
|
||||
? string.CompareOrdinal(m1.UPSTrackingNumber, m2.UPSTrackingNumber)
|
||||
: string.CompareOrdinal(m2.UPSTrackingNumber, m1.UPSTrackingNumber);
|
||||
case "REQUEST JRE TO SERVICE":
|
||||
return Query.IsAsc
|
||||
? m1.RequestJREToService.CompareTo(m2.RequestJREToService)
|
||||
: m2.RequestJREToService.CompareTo(m1.RequestJREToService);
|
||||
case "APPROVED":
|
||||
return Query.IsAsc
|
||||
? m1.Approved.CompareTo(m2.Approved)
|
||||
: m2.Approved.CompareTo(m1.Approved);
|
||||
case "WONUMBER":
|
||||
return Query.IsAsc
|
||||
? string.CompareOrdinal(m1.CustomerWO, m2.CustomerWO)
|
||||
: string.CompareOrdinal(m2.CustomerWO, m1.CustomerWO);
|
||||
case "SHIP NOTES":
|
||||
return Query.IsAsc
|
||||
? string.CompareOrdinal(m1.ShipNotes, m2.ShipNotes)
|
||||
: string.CompareOrdinal(m2.ShipNotes, m1.ShipNotes);
|
||||
case "PO":
|
||||
return Query.IsAsc
|
||||
? string.Compare(m1.CustomerPO, m2.CustomerPO)
|
||||
: string.Compare(m2.CustomerPO, m1.CustomerPO);
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class FilterQGroupByShipDate
|
||||
{
|
||||
public string[] ShipDates { get; set; }
|
||||
public string[] SelectedShipDates { get; set; }
|
||||
public FilterQGroup[] Groups { get; set; }
|
||||
}
|
||||
|
||||
public class FilterQGroup
|
||||
{
|
||||
public string JobSite { get; set; }
|
||||
public string JobContact { get; set; }
|
||||
public string OrganizationName { get; set; }
|
||||
public FilterQItem[] Children { get; set; }
|
||||
}
|
||||
|
||||
public class FilterQItem : MachineTasksNotificationInfo
|
||||
{
|
||||
public string EstDueDate { get; set; }
|
||||
public string EstShipDate { get; set; }
|
||||
}
|
||||
|
||||
public class FilterQueryParam
|
||||
{
|
||||
public string ColumnSort { get; set; }
|
||||
public bool IsAsc { get; set; }
|
||||
// -1: All, 0: No, 1: Yes
|
||||
public int TaskComplete { get; set; }
|
||||
public string[] ShipDates { get; set; }
|
||||
}
|
||||
}
|
1147
IronIntelContractorSiteLib/InspectionBasePage.cs
Normal file
1147
IronIntelContractorSiteLib/InspectionBasePage.cs
Normal file
File diff suppressed because it is too large
Load Diff
220
IronIntelContractorSiteLib/IronIntelContractorSiteLib.csproj
Normal file
220
IronIntelContractorSiteLib/IronIntelContractorSiteLib.csproj
Normal file
@ -0,0 +1,220 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{9D398985-9424-4FC7-A637-6B5B204D8F7C}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>IronIntel.Contractor.Site</RootNamespace>
|
||||
<AssemblyName>iicontractorsitelib</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>LHBIS.snk</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="FICBLC">
|
||||
<HintPath>..\Reflib\FIC\FICBLC.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FICIntf, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b006d6021b5c4397, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Reflib\FIC\FICIntf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FICIntfAdv, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b006d6021b5c4397, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Reflib\FIC\FICIntfAdv.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FICore">
|
||||
<HintPath>..\Reflib\FICore.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FICore.std">
|
||||
<HintPath>..\Reflib\FICore.std.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FIWinLib">
|
||||
<HintPath>..\Reflib\FIWinLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FleetClientBase">
|
||||
<HintPath>..\Reflib\FleetClientBase.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FleetServiceClient">
|
||||
<HintPath>..\Reflib\FleetServiceClient.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="iisitebase">
|
||||
<HintPath>..\Reflib\iisitebase.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="iisyslib">
|
||||
<HintPath>..\Reflib\iisyslib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ironcontractorwinlib">
|
||||
<HintPath>..\Reflib\ironcontractorwinlib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="IronIntel.Services.Contractor">
|
||||
<HintPath>..\Site\Bin\IronIntel.Services.Contractor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="IronIntel.Services.CredentialObjects">
|
||||
<HintPath>..\Reflib\IronIntel.Services.CredentialObjects.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="IronIntelServiceModel">
|
||||
<HintPath>..\Reflib\IronIntelServiceModel.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\Reflib\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Asset\AssetBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ChangePasswordBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="CommonHttpRequestHandler.cs" />
|
||||
<Compile Include="Contact\ContactBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ContractorBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="CredentialEntryBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FITrackerBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="InspectionBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="JobSitesBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FilterQBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MachineDeviceBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Maintenance\AlertsBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Maintenance\FuelRecordBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Maintenance\MaintanceRecordsBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Maintenance\MaintenanceBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Maintenance\PreventativeMaintenanceBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Maintenance\WorkOrderBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MapViewBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MainBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MapView\MapViewHandler.cs" />
|
||||
<Compile Include="OTRConfig\OTRConfigBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="PrintBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Security\JobsiteLimitBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Security\CurfewBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Security\FilterBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Security\SecurityBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Security\DataTablePermissionBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Security\UserGroupBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Security\UserToContractorPage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SingleAssetViewBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SystemSettings\CustomerProviderBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SystemSettings\SystemSettingsBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UserManageBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="WorkspaceBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\IronIntelContractorBusiness\IronIntelContractorBusiness.csproj">
|
||||
<Project>{515fb61f-f032-4a48-8f32-93b59b9d37f8}</Project>
|
||||
<Name>IronIntelContractorBusiness</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="LHBIS.snk" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy "$(TargetFileName)" "$(ProjectDir)\..\Site\Bin\$(TargetFileName)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
497
IronIntelContractorSiteLib/JobSitesBasePage.cs
Normal file
497
IronIntelContractorSiteLib/JobSitesBasePage.cs
Normal file
@ -0,0 +1,497 @@
|
||||
using Foresight.Fleet.Services.JobSite;
|
||||
using Foresight.Standard;
|
||||
using IronIntel.Contractor.FilterQ;
|
||||
using IronIntel.Contractor.JobSites;
|
||||
using IronIntel.Contractor.Machines;
|
||||
using IronIntel.Contractor.MapView;
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace IronIntel.Contractor.Site
|
||||
{
|
||||
public class JobSitesBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest()
|
||||
{
|
||||
object result = null;
|
||||
try
|
||||
{
|
||||
string methodName = Request.Params["MethodName"];
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName)
|
||||
{
|
||||
case "GetJobSites":
|
||||
result = GetJobSites();
|
||||
break;
|
||||
case "SaveJobSite":
|
||||
result = SaveJobSite();
|
||||
break;
|
||||
case "DeleteJobSite":
|
||||
result = DeleteJobSite();
|
||||
break;
|
||||
case "SaveJobSiteMachines":
|
||||
result = SaveJobSiteMachines();
|
||||
break;
|
||||
case "GetMachines":
|
||||
result = GetMachines();
|
||||
break;
|
||||
case "GetSelectedAssets":
|
||||
result = GetSelectedAssets();
|
||||
break;
|
||||
case "AddAssetToJobSite":
|
||||
result = AddAssetToJobSite();
|
||||
break;
|
||||
case "RemoveAssetFromJobSite":
|
||||
result = RemoveAssetFromJobSite();
|
||||
break;
|
||||
case "ChangeAssetOnSiteState":
|
||||
result = ChangeAssetOnSiteState();
|
||||
break;
|
||||
case "GetMachineTypes":
|
||||
result = GetMachineTypes();
|
||||
break;
|
||||
case "GetMachinesByType":
|
||||
result = GetMachinesByType();
|
||||
break;
|
||||
case "GetBindingMachines":
|
||||
result = GetBindingMachines();
|
||||
break;
|
||||
case "ImportJobsitePolygon":
|
||||
result = ImportJobsitePolygon();
|
||||
break;
|
||||
case "GetJobSiteUsers":
|
||||
result = GetJobSiteUsers();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "JobSitesBasePage", ex.Message, ex.ToString());
|
||||
throw ex;
|
||||
}
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private object GetJobSites()
|
||||
{
|
||||
try
|
||||
{
|
||||
JobSiteViewItem[] items = null;
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var s = Request.Form["ClientData"];
|
||||
s = HttpUtility.HtmlDecode(s);
|
||||
|
||||
var jss = CreateClient<JobSiteProvider>().GetJobSiteItems(SystemParams.CompanyID, s);
|
||||
List<JobSiteViewItem> list = new List<JobSiteViewItem>();
|
||||
|
||||
foreach (var js in jss)
|
||||
{
|
||||
JobSiteViewItem item = new JobSiteViewItem();
|
||||
item.ID = js.ID;
|
||||
item.Name = js.Name;
|
||||
item.BaseOnMachineID = js.BaseonMachineID;
|
||||
item.Code = js.Code;
|
||||
item.Types = new string[] { js.JobSiteTypes };
|
||||
item.ColorString = js.Color;
|
||||
System.Drawing.Color color = System.Drawing.Color.Orange;
|
||||
try
|
||||
{
|
||||
color = System.Drawing.ColorTranslator.FromHtml(item.ColorString);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
item.Color = new IIColor() { Alpha = color.A, Red = color.R, Green = color.G, Blue = color.B };
|
||||
|
||||
item.Latitude = js.Latitude;
|
||||
item.Longitude = js.Longitude;
|
||||
item.StartDate = js.StartDate == null ? DateTime.MinValue : js.StartDate.Value;
|
||||
item.EndDate = js.EndDate == null ? DateTime.MinValue : js.EndDate.Value;
|
||||
item.Radius = js.Radius;
|
||||
item.Radius_UOM = js.RadiusUOM;
|
||||
if (js.Polygon != null && js.Polygon.Length > 0)
|
||||
{
|
||||
List<PostionItem> temps = new List<PostionItem>();
|
||||
foreach (var p in js.Polygon)
|
||||
{
|
||||
temps.Add(new PostionItem(p.Latitude, p.Longtitude));
|
||||
}
|
||||
item.Polygon = temps.ToArray();
|
||||
}
|
||||
|
||||
list.Add(item);
|
||||
}
|
||||
items = list.ToArray();
|
||||
//items = JobSitesManagement.GetJobSite(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new JobSiteViewItem[0];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object SaveJobSite()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var s = Request.Form["ClientData"];
|
||||
s = HttpUtility.HtmlDecode(s);
|
||||
|
||||
var js = JsonConvert.DeserializeObject<JobSiteViewItem>(s);
|
||||
JobSiteItem jobsite = new JobSiteItem();
|
||||
Helper.CloneProperty(jobsite, js);
|
||||
jobsite.RadiusUOM = js.Radius_UOM;
|
||||
jobsite.BaseonMachineID = js.BaseOnMachineID;
|
||||
jobsite.Color = js.ColorString;
|
||||
jobsite.JobSiteTypes = string.Join(",", js.Types);
|
||||
if (js.StartDate > Helper.DBMinDateTime)
|
||||
jobsite.StartDate = js.StartDate;
|
||||
if (js.EndDate > Helper.DBMinDateTime)
|
||||
jobsite.EndDate = js.EndDate;
|
||||
if (js.Polygon != null && js.Polygon.Length > 0)
|
||||
{
|
||||
List<Position> list = new List<Position>();
|
||||
foreach (PostionItem pi in js.Polygon)
|
||||
{
|
||||
Position p = new Position(pi.Latitude, pi.Longitude);
|
||||
list.Add(p);
|
||||
}
|
||||
jobsite.Polygon = list.ToArray();
|
||||
}
|
||||
|
||||
long jobsiteid = CreateClient<JobSiteProvider>().SaveJobSite(SystemParams.CompanyID, jobsite, GetCurrentLoginSession().User.UID);
|
||||
|
||||
JobSitesManagement.RefreshJobsiteAssets(session.SessionID, jobsiteid);
|
||||
|
||||
return new string[] { jobsiteid.ToString(), "Saved successfully." };
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string DeleteJobSite()
|
||||
{
|
||||
try
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var s = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
long jsid = Convert.ToInt64(s);
|
||||
var notes = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
CreateClient<JobSiteProvider>().DeleteJobSite(SystemParams.CompanyID, jsid, notes, user.IID);
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private string SaveJobSiteMachines()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var s = Request.Form["ClientData"];
|
||||
s = HttpUtility.HtmlDecode(s);
|
||||
var jobsite = JsonConvert.DeserializeObject<JobSiteViewItem>(s);
|
||||
|
||||
JobSitesManagement.AddMachinesToJobSite(jobsite);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private AssetViewItem[] GetMachines()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
AssetViewItem[] items = AssetMapViewManagement.GetAssets(session.SessionID, SystemParams.CompanyID, session.User.UID, "", -1, null, false);
|
||||
return items;
|
||||
}
|
||||
return new AssetViewItem[0];
|
||||
}
|
||||
|
||||
private object[] GetSelectedAssets()
|
||||
{
|
||||
var u = GetCurrentUser();
|
||||
if (u != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var companyid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
{
|
||||
companyid = SystemParams.CompanyID;
|
||||
}
|
||||
var jobsiteid = long.Parse(clientdata[1]);
|
||||
var jobsites = CreateClient<JobSiteProvider>(companyid).GetAssetsCurrentInJobSite(companyid, jobsiteid);
|
||||
return jobsites.Select(i => new
|
||||
{
|
||||
i.AssetId,
|
||||
i.OnSite,
|
||||
Name = string.IsNullOrEmpty(i.AssetName2) ? i.AssetName : i.AssetName2,
|
||||
i.VIN,
|
||||
i.MakeName,
|
||||
i.ModelName,
|
||||
i.TypeName
|
||||
}).ToArray();
|
||||
}
|
||||
return new object[0];
|
||||
}
|
||||
|
||||
private string AddAssetToJobSite()
|
||||
{
|
||||
try
|
||||
{
|
||||
var u = GetCurrentUser();
|
||||
if (u != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var companyId = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
if (string.IsNullOrEmpty(companyId))
|
||||
{
|
||||
companyId = SystemParams.CompanyID;
|
||||
}
|
||||
var jobsiteid = long.Parse(clientdata[1]);
|
||||
var machineids = HttpUtility.HtmlDecode(clientdata[2]);
|
||||
|
||||
var ids = JsonConvert.DeserializeObject<long[]>(machineids);
|
||||
|
||||
var client = CreateClient<JobSiteProvider>(companyId);
|
||||
foreach (var id in ids)
|
||||
{
|
||||
client.AddAssetToJobSite(companyId, jobsiteid, id, false, u.IID);
|
||||
}
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "JobSitesBasePage.AddAssetToJobSite", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string RemoveAssetFromJobSite()
|
||||
{
|
||||
try
|
||||
{
|
||||
var u = GetCurrentUser();
|
||||
if (u != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var companyId = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
if (string.IsNullOrEmpty(companyId))
|
||||
{
|
||||
companyId = SystemParams.CompanyID;
|
||||
}
|
||||
var jobsiteid = long.Parse(clientdata[1]);
|
||||
var machineids = HttpUtility.HtmlDecode(clientdata[2]);
|
||||
|
||||
var ids = JsonConvert.DeserializeObject<long[]>(machineids);
|
||||
|
||||
var client = CreateClient<JobSiteProvider>(companyId);
|
||||
foreach (var id in ids)
|
||||
{
|
||||
client.RemoveAssetFromJobSite(companyId, jobsiteid, id, u.IID);
|
||||
}
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "JobSitesBasePage.RemoveAssetFromJobSite", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string ChangeAssetOnSiteState()
|
||||
{
|
||||
try
|
||||
{
|
||||
var u = GetCurrentUser();
|
||||
if (u != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var companyId = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
if (string.IsNullOrEmpty(companyId))
|
||||
{
|
||||
companyId = SystemParams.CompanyID;
|
||||
}
|
||||
var jobsiteid = long.Parse(clientdata[1]);
|
||||
var assetid = long.Parse(clientdata[2]);
|
||||
var onsite = (clientdata[3] == "1");
|
||||
|
||||
CreateClient<JobSiteProvider>(companyId).ChangeAssetOnSiteState(companyId, jobsiteid, assetid, onsite, u.IID);
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "JobSitesBasePage.ChangeAssetOnSiteState", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private MachineViewItem[] GetBindingMachines()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
MachineViewItem[] items = JobSitesManagement.GetBindingMachines(session.SessionID, session.User.UID);
|
||||
if (items != null)
|
||||
{
|
||||
items = items.OrderBy((m) => m.ShowName).ToArray();
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
private MachineTypeItem[] GetMachineTypes()
|
||||
{
|
||||
MachineTypeItem[] types = JobSitesManagement.GetMachineTypes();
|
||||
if (types != null)
|
||||
{
|
||||
types = types.OrderBy((t) => t.Name).ToArray();
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
private AvailableMachines GetMachinesByType()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
var p = Request.Form["ClientData"];
|
||||
p = HttpUtility.HtmlDecode(p);
|
||||
var param = JsonConvert.DeserializeObject<JobSiteMahcineQueryItem>(p);
|
||||
|
||||
AvailableMachines machines = JobSitesManagement.GetMachineViewItemByType(session.SessionID, param.JobSiteID, param.MachineTypeID, param.SearchText, session.User.UID);
|
||||
return machines;
|
||||
}
|
||||
|
||||
private object ImportJobsitePolygon()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
|
||||
string fileName = clientdata;
|
||||
|
||||
HttpPostedFile uploadFile = null;
|
||||
byte[] buffer = null;
|
||||
if (Request.Files.Count > 0)
|
||||
{
|
||||
uploadFile = Request.Files[0];
|
||||
buffer = ConvertFile2bytes(uploadFile);
|
||||
}
|
||||
|
||||
return JobSitesManagement.ImportJobsitePolygon(fileName, buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetJobSiteUsers()
|
||||
{
|
||||
try
|
||||
{
|
||||
UserNameInfoItem[] items = null;
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var data = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
|
||||
var jobsiteid = long.Parse(data);
|
||||
var users = CreateClient<JobSiteProvider>().GetJobisteUserNamesList(SystemParams.CompanyID, jobsiteid);
|
||||
|
||||
List<UserNameInfoItem> list = new List<UserNameInfoItem>();
|
||||
foreach (var user in users)
|
||||
{
|
||||
UserNameInfoItem ui = new UserNameInfoItem();
|
||||
Helper.CloneProperty(ui, user);
|
||||
list.Add(ui);
|
||||
}
|
||||
items = list.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new UserNameInfoItem[0];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private class JobSiteMahcineQueryItem
|
||||
{
|
||||
public string JobSiteID { get; set; }
|
||||
public string MachineTypeID { get; set; }
|
||||
public string SearchText { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
BIN
IronIntelContractorSiteLib/LHBIS.snk
Normal file
BIN
IronIntelContractorSiteLib/LHBIS.snk
Normal file
Binary file not shown.
2419
IronIntelContractorSiteLib/MachineDeviceBasePage.cs
Normal file
2419
IronIntelContractorSiteLib/MachineDeviceBasePage.cs
Normal file
File diff suppressed because it is too large
Load Diff
130
IronIntelContractorSiteLib/MainBasePage.cs
Normal file
130
IronIntelContractorSiteLib/MainBasePage.cs
Normal file
@ -0,0 +1,130 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Foresight;
|
||||
using IronIntel.Services;
|
||||
using IronIntel.Contractor.Users;
|
||||
|
||||
namespace IronIntel.Contractor.Site
|
||||
{
|
||||
public class MainBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest()
|
||||
{
|
||||
string methidName = Request.Params["MethodName"];
|
||||
switch (methidName)
|
||||
{
|
||||
case "GetUserName":
|
||||
GetUserName();
|
||||
break;
|
||||
case "GetAppModules":
|
||||
GetAppModules();
|
||||
break;
|
||||
case "GetVersions":
|
||||
GetVersions();
|
||||
break;
|
||||
case "GetSiteHeaderNote":
|
||||
GetSiteHeaderNote();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//TODO
|
||||
}
|
||||
|
||||
private void GetUserName()
|
||||
{
|
||||
string userName = "";
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null && session.User != null)
|
||||
{
|
||||
userName = session.User.Name;
|
||||
}
|
||||
|
||||
userName = JsonConvert.SerializeObject(userName);
|
||||
Response.Write(userName);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private void GetAppModules()
|
||||
{
|
||||
try
|
||||
{
|
||||
AppModuleInfo[] items = null;
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
List<AppModuleInfo> list = Acl.GetAvailableAppModuleInfos(session.User.UID).ToList();
|
||||
LicenseInfo license = SystemParams.GetLicense();
|
||||
if (license != null && license.Items.Count > 0)
|
||||
{
|
||||
LicenseItem lijl = license.Items.FirstOrDefault(m => m.Key == "JOBSITELIMIT");
|
||||
if (lijl == null || !Helper.IsTrue(lijl.Value))
|
||||
{
|
||||
AppModuleInfo item = list.FirstOrDefault(m => m.ID == "JOBSITELIMIT");
|
||||
list.Remove(item);
|
||||
}
|
||||
}
|
||||
if (!session.User.IsForesightUser)
|
||||
{
|
||||
bool isallowed = UserManagement.CheckUserPermission(session.SessionID, session.User.UID, 30);
|
||||
if (!isallowed)
|
||||
{
|
||||
AppModuleInfo item = list.FirstOrDefault(m => m.ID == "OTRConfig");
|
||||
list.Remove(item);
|
||||
}
|
||||
}
|
||||
items = list.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new AppModuleInfo[0];
|
||||
}
|
||||
string json = JsonConvert.SerializeObject(items);
|
||||
Response.Write(json);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("Error", "GetAppModules", ex.Message, ex.ToString());
|
||||
Response.Write(JsonConvert.SerializeObject(ex.Message));
|
||||
}
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private void GetVersions()
|
||||
{
|
||||
List<string> versions = new List<string>();
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null && session.User != null)
|
||||
{
|
||||
versions.Add(SystemParams.GetVersion());
|
||||
versions.Add(SystemParams.GetFICVersion());
|
||||
}
|
||||
|
||||
string json = JsonConvert.SerializeObject(versions.ToArray());
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
private void GetSiteHeaderNote()
|
||||
{
|
||||
string siteheadernote = "";
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null && session.User != null)
|
||||
{
|
||||
siteheadernote = UserManagement.GetSiteHeaderNote(session.User.UID);
|
||||
if (string.IsNullOrEmpty(siteheadernote))
|
||||
{
|
||||
var cust = FleetServiceClientHelper.CreateClient<Foresight.Fleet.Services.Customer.CustomerProvider>().GetCustomerDetail(SystemParams.CompanyID);
|
||||
if (cust != null)
|
||||
siteheadernote = cust.SiteHeaderNotes;
|
||||
}
|
||||
}
|
||||
string json = JsonConvert.SerializeObject(siteheadernote);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
}
|
||||
}
|
611
IronIntelContractorSiteLib/Maintenance/AlertsBasePage.cs
Normal file
611
IronIntelContractorSiteLib/Maintenance/AlertsBasePage.cs
Normal file
@ -0,0 +1,611 @@
|
||||
using Foresight.Data;
|
||||
using Foresight.Fleet.Services.AssetHealth;
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Contractor.Machines;
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Maintenance
|
||||
{
|
||||
public class AlertsBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest(string method)
|
||||
{
|
||||
object result = null;
|
||||
try
|
||||
{
|
||||
string methodName = Request.Params["MethodName"];
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName.ToUpper())
|
||||
{
|
||||
case "GETALERTS":
|
||||
result = GetAlerts();
|
||||
break;
|
||||
case "GETMACHINEALERTS":
|
||||
result = GetMachineAlerts();
|
||||
break;
|
||||
case "SAVEACKNOWLEDGEALERT":
|
||||
result = SaveAcknowledgeAlert();
|
||||
break;
|
||||
case "ASSIGNEDALERTSTOWORKORDER":
|
||||
result = AssignedAlertsToWorkOrder();
|
||||
break;
|
||||
case "GETALERTSBYWORKORDER":
|
||||
result = GetAlertsByWorkOrder();
|
||||
break;
|
||||
case "GETALERTSLISENCE":
|
||||
result = GetAlertsLisence();
|
||||
break;
|
||||
case "GETWORKORDERALERTS":
|
||||
result = GetWorkOrderAlerts();
|
||||
break;
|
||||
case "GETASSETALERTS":
|
||||
result = GetAssetAlerts();
|
||||
break;
|
||||
case "GETASSETGROUPS":
|
||||
result = GetAssetGroups();
|
||||
break;
|
||||
case "GETALERTTYPES":
|
||||
result = GetAlertTypes();
|
||||
break;
|
||||
case "GETACKNOWLEDGEDALERTS":
|
||||
result = GetAcknowledgedAlerts();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "AlertsBasePage", ex.Message, ex.ToString());
|
||||
throw ex;
|
||||
}
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private object GetAlerts()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Context.Request.Params["ClientData"];
|
||||
AlertQueryParams alertparam = JsonConvert.DeserializeObject<AlertQueryParams>(clientdata);
|
||||
DateTime beginDate = Helper.DBMinDateTime;
|
||||
DateTime endDate = DateTime.MaxValue;
|
||||
if (!DateTime.TryParse(alertparam.BeginDate, out beginDate))
|
||||
beginDate = Helper.DBMinDateTime;
|
||||
//else
|
||||
// beginDate = beginDate.ToUniversalTime();
|
||||
if (!DateTime.TryParse(alertparam.EndDate, out endDate))
|
||||
endDate = DateTime.MaxValue;
|
||||
else
|
||||
endDate = endDate.Date.AddDays(1).AddSeconds(-1);
|
||||
|
||||
int assigned = -1;
|
||||
int completed = -1;
|
||||
if (alertparam.AlertStatus != null && alertparam.AlertStatus.Length > 0)
|
||||
{
|
||||
if (alertparam.AlertStatus.Contains("Unassigned") && !alertparam.AlertStatus.Contains("Assigned"))
|
||||
assigned = 0;
|
||||
if (!alertparam.AlertStatus.Contains("Unassigned") && alertparam.AlertStatus.Contains("Assigned"))
|
||||
assigned = 1;
|
||||
|
||||
if (alertparam.AlertStatus.Contains("Completed") && !alertparam.AlertStatus.Contains("Uncompleted"))
|
||||
assigned = 1;
|
||||
if (!alertparam.AlertStatus.Contains("Completed") && alertparam.AlertStatus.Contains("Uncompleted"))
|
||||
assigned = 0;
|
||||
}
|
||||
AssetAlertGridViewItem[] assetalerts = CreateClient<WorkOrderClient>().GetAssetAlertGridViewItems(SystemParams.CompanyID, beginDate, endDate, alertparam.AlertTypes, alertparam.AssetGroups, assigned, completed, alertparam.SearchText, session.User.UID);
|
||||
if (assetalerts == null || assetalerts.Length == 0)
|
||||
return new AlertInfo[0];
|
||||
List<AlertInfo> list = new List<AlertInfo>();
|
||||
foreach (AssetAlertGridViewItem item in assetalerts)
|
||||
{
|
||||
AlertInfo ai = ConvertAlertObj(item);
|
||||
ai.AlertTime_UTC = item.LastAlertLocalTime;
|
||||
list.Add(ai);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
else
|
||||
return new AlertInfo[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AlertsBasePage.GetAlerts", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetMachineAlerts()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Context.Request.Params["ClientData"];
|
||||
AlertQueryParams alertparam = JsonConvert.DeserializeObject<AlertQueryParams>(clientdata);
|
||||
DateTime beginDate = Helper.DBMinDateTime;
|
||||
DateTime endDate = DateTime.MaxValue;
|
||||
if (!DateTime.TryParse(alertparam.BeginDate, out beginDate))
|
||||
beginDate = Helper.DBMinDateTime;
|
||||
//else
|
||||
// beginDate = beginDate.ToUniversalTime();
|
||||
if (!DateTime.TryParse(alertparam.EndDate, out endDate))
|
||||
endDate = DateTime.MaxValue;
|
||||
else
|
||||
endDate = endDate.Date.AddDays(1).AddSeconds(-1);
|
||||
|
||||
int assigned = -1;
|
||||
int completed = -1;
|
||||
if (alertparam.AlertStatus != null && alertparam.AlertStatus.Length > 0)
|
||||
{
|
||||
if (alertparam.AlertStatus.Contains("Unassigned") && !alertparam.AlertStatus.Contains("Assigned"))
|
||||
assigned = 0;
|
||||
if (!alertparam.AlertStatus.Contains("Unassigned") && alertparam.AlertStatus.Contains("Assigned"))
|
||||
assigned = 1;
|
||||
|
||||
if (alertparam.AlertStatus.Contains("Completed") && !alertparam.AlertStatus.Contains("Uncompleted"))
|
||||
assigned = 1;
|
||||
if (!alertparam.AlertStatus.Contains("Completed") && alertparam.AlertStatus.Contains("Uncompleted"))
|
||||
assigned = 0;
|
||||
}
|
||||
|
||||
AssetAlertGridViewItem[] assetalerts = CreateClient<WorkOrderClient>().GetAssetAlertGridViewItems(SystemParams.CompanyID, beginDate, endDate, alertparam.AlertTypes, alertparam.AssetGroups, assigned, completed, alertparam.SearchText, session.User.UID);
|
||||
|
||||
if (assetalerts == null || assetalerts.Length == 0)
|
||||
return new MachineInfoForAlert[0];
|
||||
|
||||
List<MachineInfoForAlert> machinealerts = new List<MachineInfoForAlert>();
|
||||
foreach (AssetAlertGridViewItem item in assetalerts)
|
||||
{
|
||||
AlertInfo ai = ConvertAlertObj(item);
|
||||
MachineInfoForAlert mi = machinealerts.FirstOrDefault((i) => i.MachineID == ai.MachineID);
|
||||
if (mi == null)
|
||||
{
|
||||
mi = new MachineInfoForAlert();
|
||||
mi.MachineID = ai.MachineID;
|
||||
mi.MachineName = ai.MachineName;
|
||||
mi.VIN = ai.VIN;
|
||||
mi.Make = ai.Make;
|
||||
mi.Model = ai.Model;
|
||||
mi.EngineHours = ai.CurrentHours;
|
||||
mi.OpenWorkOrders = ai.OpenWorkOrderCount;
|
||||
|
||||
machinealerts.Add(mi);
|
||||
}
|
||||
mi.Alerts.Add(ai);
|
||||
|
||||
int count = ai.RepeatedAlerts.Count + 1;
|
||||
|
||||
if (ai.AlertType == "Preventative Maintenance"
|
||||
|| ai.AlertType == "PM_ALERT" || ai.AlertType == "TBM_ALERT" || ai.AlertType == "HM_ALERT"
|
||||
|| ai.AlertType == "RDM_ALERT" || ai.AlertType == "ADM_ALERT")
|
||||
mi.PMAlertCount += count;
|
||||
else if (INSPECT.Contains(ai.AlertType, StringComparer.OrdinalIgnoreCase))
|
||||
mi.InspectAlertCount += count;
|
||||
else
|
||||
mi.DTCAlertCount += count;
|
||||
if (ai.AlertTime_UTC > mi.LatestAlertDateTime)
|
||||
mi.LatestAlertDateTime = ai.AlertTime_UTC;
|
||||
}
|
||||
|
||||
return machinealerts.ToArray();
|
||||
}
|
||||
else
|
||||
return new MachineInfoForAlert[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AlertsBasePage.GetAlerts", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private AlertInfo ConvertAlertObj(AssetAlertGridViewItem item)
|
||||
{
|
||||
AlertInfo ai = new AlertInfo();
|
||||
ai.AlertID = item.ID;
|
||||
ai.WorkOrderID = item.WorkOrderId;
|
||||
ai.WorkOrderStatus = item.WorkOrderStatus;
|
||||
ai.AlertType = item.AlertType;
|
||||
ai.AlertTime_UTC = item.LastAlertTime;
|
||||
ai.Completed = item.Completed;
|
||||
ai.MachineID = item.AssetID;
|
||||
//ai.ModelID = item.ModelName;
|
||||
ai.Model = item.ModelName;
|
||||
//ai.MakeID = item.MakeName;
|
||||
ai.Make = item.MakeName;
|
||||
ai.VIN = item.VIN;
|
||||
ai.MachineName = item.AssetName;
|
||||
ai.EngineHours = item.EngineHours;
|
||||
ai.CurrentHours = item.CurrentEngineHours;
|
||||
ai.Description = item.Description;
|
||||
ai.ServiceDescription = item.ServiceDescription;
|
||||
ai.RepeatedAlerts = item.RepeatedAlerts;
|
||||
ai.AlertCount = item.RepeatedAlerts.Count + 1;
|
||||
ai.OpenWorkOrderCount = item.OpenWorkOrderCount;
|
||||
|
||||
return ai;
|
||||
}
|
||||
|
||||
private object GetAcknowledgedAlerts()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Context.Request.Params["ClientData"];
|
||||
AlertQueryParams alertparam = JsonConvert.DeserializeObject<AlertQueryParams>(clientdata);
|
||||
DateTime beginDate = Helper.DBMinDateTime;
|
||||
DateTime endDate = DateTime.MaxValue;
|
||||
if (!DateTime.TryParse(alertparam.BeginDate, out beginDate))
|
||||
beginDate = Helper.DBMinDateTime;
|
||||
//else
|
||||
// beginDate = beginDate.ToUniversalTime();
|
||||
if (!DateTime.TryParse(alertparam.EndDate, out endDate))
|
||||
endDate = DateTime.MaxValue;
|
||||
else
|
||||
endDate = endDate.Date.AddDays(1).AddSeconds(-1);
|
||||
|
||||
alertparam.AlertStatus = new string[0];
|
||||
AlertManager am = new AlertManager(SystemParams.DataDbConnectionString);
|
||||
AlertInfo[] alerts = am.SearchAcknowledgedAlerts(session.SessionID, alertparam.SearchText, alertparam.AlertStatus, alertparam.AlertTypes, alertparam.AssetGroups, beginDate, endDate, session.User.UID);
|
||||
if (alerts == null)
|
||||
return new AlertInfo[0];
|
||||
return alerts.ToArray();
|
||||
}
|
||||
else
|
||||
return new AlertInfo[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AlertsBasePage.GetAcknowledgedAlerts", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetAlertsLisence()
|
||||
{
|
||||
try
|
||||
{
|
||||
AlertsLisenceItem result = new AlertsLisenceItem();
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
LicenseInfo license = SystemParams.GetLicense();
|
||||
if (license != null && license.Items.Count > 0)
|
||||
{
|
||||
var woitem = license.Items.FirstOrDefault(m => m.Key == "WorkOrder");
|
||||
if (woitem != null && Helper.IsTrue(woitem.Value))
|
||||
result.WorkOrder = true;
|
||||
}
|
||||
result.AcknowledgingAlerts = Helper.IsTrue(SystemParams.GetStringParam("AcknowledgingAlerts"));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AlertsBasePage.GetAlertsLisence", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string SaveAcknowledgeAlert()
|
||||
{
|
||||
try
|
||||
{
|
||||
Services.Users.LoginSession se = GetCurrentLoginSession();
|
||||
if (se != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var ids = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var acknowledgmentcomment = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
long[] list = JsonConvert.DeserializeObject<long[]>(ids);
|
||||
AlertManager am = new AlertManager(SystemParams.DataDbConnectionString);
|
||||
am.AcknowledgeAlert(se.User.UID, list, acknowledgmentcomment);
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private string AssignedAlertsToWorkOrder()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var id = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var ids = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
long workorderid = Convert.ToInt64(id);
|
||||
long[] alertids = JsonConvert.DeserializeObject<long[]>(ids);
|
||||
if (alertids != null && alertids.Length == 0)
|
||||
alertids = null;
|
||||
AlertManager am = new AlertManager(SystemParams.DataDbConnectionString);
|
||||
am.AssignedAlertsToWorkOrder(workorderid, alertids);
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetAlertsByWorkOrder()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var woid = Request.Form["ClientData"];
|
||||
long workorderid = Convert.ToInt64(woid);
|
||||
AlertManager am = new AlertManager(SystemParams.DataDbConnectionString);
|
||||
AlertInfo[] alerts = am.GetAlertsByWorkOrder(workorderid);
|
||||
if (alerts == null)
|
||||
return new AlertInfo[0];
|
||||
return alerts;
|
||||
}
|
||||
else
|
||||
return new AlertInfo[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AlertsBasePage.GetAlertsByWorkOrder", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private object GetWorkOrderAlerts()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
|
||||
long workorderid = 0;
|
||||
long.TryParse(clientdata, out workorderid);
|
||||
|
||||
AssetAlertItem[] alerts = CreateClient<WorkOrderClient>().GetAssignedAlerts(SystemParams.CompanyID, workorderid);
|
||||
|
||||
AlertItems items = new AlertItems();
|
||||
if (alerts != null)
|
||||
{
|
||||
var dtcalerts = new List<AlertInfo>();
|
||||
var pmaalerts = new List<AlertInfo>();
|
||||
var inspectalerts = new List<AlertInfo>();
|
||||
var oilalerts = new List<AlertInfo>();
|
||||
foreach (AssetAlertItem alertitem in alerts.OrderByDescending(ai => ai.AlertTime))
|
||||
{
|
||||
List<AlertInfo> tempList = null;
|
||||
if (alertitem.Category == AssetAlertCategory.PMAlert)
|
||||
tempList = pmaalerts;
|
||||
else if (alertitem.Category == AssetAlertCategory.InspectAlert)
|
||||
tempList = inspectalerts;
|
||||
else if (alertitem.Category == AssetAlertCategory.OilSampleAlert)
|
||||
tempList = oilalerts;
|
||||
else
|
||||
tempList = dtcalerts;
|
||||
|
||||
var existalert = tempList.FirstOrDefault((ai) => ai.Description == alertitem.Description);
|
||||
if (existalert != null)
|
||||
{
|
||||
existalert.AlertCount++;
|
||||
if (existalert.RepeatedAlerts == null)
|
||||
existalert.RepeatedAlerts = new List<long>();
|
||||
existalert.RepeatedAlerts.Add(alertitem.ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
var a = ConvertAlert(alertitem);
|
||||
a.AlertCount = 1;
|
||||
tempList.Add(a);
|
||||
}
|
||||
}
|
||||
items.DTCAlerts = dtcalerts.ToArray();
|
||||
items.PMAlerts = pmaalerts.ToArray();
|
||||
items.InspectAlerts = inspectalerts.ToArray();
|
||||
items.OilAlerts = oilalerts.ToArray();
|
||||
}
|
||||
return items;
|
||||
}
|
||||
else
|
||||
return new AlertInfo[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AlertsBasePage.GetWorkOrderAlerts", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetAssetAlerts()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var mid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var ids = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
long machineid = 0;
|
||||
long.TryParse(mid, out machineid);
|
||||
|
||||
long[] alertids = JsonConvert.DeserializeObject<long[]>(ids);
|
||||
|
||||
AssetAlertGridViewItem[] alerts = CreateClient<WorkOrderClient>().GetAssetAlertGridViewItemsByAsset(SystemParams.CompanyID, machineid, Helper.DBMinDateTime, DateTime.MaxValue, null, -1, -1, "");
|
||||
AlertItems items = new AlertItems();
|
||||
if (alerts != null)
|
||||
{
|
||||
var dtcalerts = new List<AlertInfo>();
|
||||
var pmaalerts = new List<AlertInfo>();
|
||||
var inspectalerts = new List<AlertInfo>();
|
||||
var oilalerts = new List<AlertInfo>();
|
||||
foreach (AssetAlertGridViewItem alertitem in alerts.OrderByDescending(ai => ai.AlertTime))
|
||||
{
|
||||
if (alertids != null && alertids.Length > 0 && !alertids.Contains(alertitem.ID))
|
||||
continue;
|
||||
if (alertitem.Completed || alertitem.Acknowledged || alertitem.WorkOrderId > 0)
|
||||
continue;
|
||||
|
||||
List<AlertInfo> tempList = null;
|
||||
var category = DetermineAlertCategory(alertitem.AlertType);
|
||||
if (category == AssetAlertCategory.PMAlert)
|
||||
tempList = pmaalerts;
|
||||
else if (category == AssetAlertCategory.InspectAlert)
|
||||
tempList = inspectalerts;
|
||||
else if (category == AssetAlertCategory.OilSampleAlert)
|
||||
tempList = oilalerts;
|
||||
else
|
||||
tempList = dtcalerts;
|
||||
|
||||
var a = ConvertAlertObj(alertitem);
|
||||
a.RepeatedAlerts = alertitem.RepeatedAlerts;
|
||||
a.AlertCount = alertitem.RepeatedAlerts.Count + 1;
|
||||
tempList.Add(a);
|
||||
}
|
||||
items.DTCAlerts = dtcalerts.ToArray();
|
||||
items.PMAlerts = pmaalerts.ToArray();
|
||||
items.InspectAlerts = inspectalerts.ToArray();
|
||||
items.OilAlerts = oilalerts.ToArray();
|
||||
}
|
||||
return items;
|
||||
}
|
||||
else
|
||||
return new AlertInfo[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AlertsBasePage.GetAssetAlerts", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly string[] PMALERTS = new string[] { "Preventative Maintenance" };
|
||||
private static readonly string[] INSPECT = new string[] { "Red-Inspect", "Yellow-Inspect", "Green-Inspect", "Info-Inspect" };
|
||||
private static readonly string[] OILSAMPLE = new string[] { "Oil Sample Result" };
|
||||
private static AssetAlertCategory DetermineAlertCategory(string alerttype)
|
||||
{
|
||||
if (PMALERTS.Contains(alerttype, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return AssetAlertCategory.PMAlert;
|
||||
}
|
||||
if (INSPECT.Contains(alerttype, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return AssetAlertCategory.InspectAlert;
|
||||
}
|
||||
if (OILSAMPLE.Contains(alerttype, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return AssetAlertCategory.OilSampleAlert;
|
||||
}
|
||||
|
||||
return AssetAlertCategory.DTCAlert;
|
||||
}
|
||||
|
||||
private object GetAssetGroups()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var groups = MachineManagement.GetMachineGroupsByUser(session.User.UID, null);
|
||||
List<StringKeyValue> list = new List<StringKeyValue>();
|
||||
foreach (var gp in groups)
|
||||
{
|
||||
StringKeyValue kv = new StringKeyValue();
|
||||
kv.Key = gp.GroupID;
|
||||
kv.Value = gp.GroupName;
|
||||
list.Add(kv);
|
||||
}
|
||||
|
||||
return list.OrderBy((m) => m.Value).ToArray();
|
||||
}
|
||||
else
|
||||
return new StringKeyValue[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AlertsBasePage.GetAssetGroups", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetAlertTypes()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
AlertManager am = new AlertManager(SystemParams.DataDbConnectionString);
|
||||
return am.GetAlertTypes(); ;
|
||||
}
|
||||
else
|
||||
return new StringKeyValue[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AlertsBasePage.GetAlertTypes", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private AlertInfo ConvertAlert(AssetAlertItem alertitem)
|
||||
{
|
||||
AlertInfo ai = new AlertInfo();
|
||||
ai.AlertID = alertitem.ID;
|
||||
ai.MachineID = alertitem.AssetID;
|
||||
ai.AlertType = alertitem.AlertType;
|
||||
ai.Description = alertitem.Description;
|
||||
ai.AlertTime_UTC = alertitem.AlertTime;
|
||||
ai.EngineHours = alertitem.EngineHours;
|
||||
|
||||
return ai;
|
||||
}
|
||||
}
|
||||
public class AlertItems
|
||||
{
|
||||
public AlertInfo[] DTCAlerts { get; set; }
|
||||
public AlertInfo[] PMAlerts { get; set; }
|
||||
public AlertInfo[] InspectAlerts { get; set; }
|
||||
public AlertInfo[] OilAlerts { get; set; }
|
||||
}
|
||||
public class AlertQueryParams
|
||||
{
|
||||
public string SearchText { get; set; }
|
||||
public string[] AlertStatus { get; set; }
|
||||
public string[] AssetGroups { get; set; }
|
||||
public string[] AlertTypes { get; set; }
|
||||
public string BeginDate { get; set; }
|
||||
public string EndDate { get; set; }
|
||||
}
|
||||
|
||||
public class AlertsLisenceItem
|
||||
{
|
||||
public bool WorkOrder = false;
|
||||
public bool AcknowledgingAlerts = false;
|
||||
}
|
||||
}
|
228
IronIntelContractorSiteLib/Maintenance/FuelRecordBasePage.cs
Normal file
228
IronIntelContractorSiteLib/Maintenance/FuelRecordBasePage.cs
Normal file
@ -0,0 +1,228 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using IronIntel.Contractor.Machines;
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using System.Web;
|
||||
using IronIntel.Contractor.Users;
|
||||
using Foresight.ServiceModel;
|
||||
using Foresight.Fleet.Services.AssetHealth;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Maintenance
|
||||
{
|
||||
public class FuelRecordBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
object result = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName.ToUpper())
|
||||
{
|
||||
case "GETFUELRECORDS":
|
||||
result = GetFuelRecords();
|
||||
break;
|
||||
case "GETFUELRECORDCHANGEHISTORY":
|
||||
result = GetFuelRecordChangeHistory();
|
||||
break;
|
||||
case "SAVEFUELRECORD":
|
||||
result = SaveFuelRecord();
|
||||
break;
|
||||
case "DELETEFUELRECORD":
|
||||
result = DeleteFuelRecord();
|
||||
break;
|
||||
case "GETFUELTYPES":
|
||||
result = GetFuelTypes();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Threading.ThreadAbortException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "FuelRecordsBasePage" + methodName, ex.Message, ex.ToString());
|
||||
}
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
|
||||
private object GetFuelRecords()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var type = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var sdatestr = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
var edatestr = HttpUtility.HtmlDecode(clientdata[2]);
|
||||
var searchtxt = HttpUtility.HtmlDecode(clientdata[3]);
|
||||
|
||||
DateTime beginDate = DateTime.MinValue;
|
||||
DateTime endDate = DateTime.MaxValue;
|
||||
if (!DateTime.TryParse(sdatestr, out beginDate))
|
||||
beginDate = DateTime.MinValue;
|
||||
if (!DateTime.TryParse(edatestr, out endDate))
|
||||
endDate = DateTime.MaxValue;
|
||||
|
||||
FuelRecord[] fuels = CreateClient<FuelManagementClient>().GetFuelRecords(SystemParams.CompanyID, Convert.ToInt64(type), beginDate, endDate, searchtxt);
|
||||
|
||||
List<FuelRecordInfo> list = new List<FuelRecordInfo>();
|
||||
foreach (FuelRecord fuel in fuels)
|
||||
{
|
||||
FuelRecordInfo fi = new FuelRecordInfo();
|
||||
Helper.CloneProperty(fi, fuel);
|
||||
fi.TransactionDate = fi.TransactionDate.ToLocalTime();
|
||||
list.Add(fi);
|
||||
}
|
||||
|
||||
return list.ToArray();
|
||||
}
|
||||
else
|
||||
return new FuelRecordInfo[0];
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "FuelRecordBasePage.GetFuelRecords", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetFuelRecordChangeHistory()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string clientdata = Request.Form["ClientData"];
|
||||
long fuleid = Convert.ToInt64(HttpUtility.HtmlDecode(clientdata));
|
||||
|
||||
FuelRecordAuditInfo[] fuels = CreateClient<FuelManagementClient>().GetFuelRecordAuditItems(SystemParams.CompanyID, fuleid);
|
||||
|
||||
List<FuelRecordAuditItem> list = new List<FuelRecordAuditItem>();
|
||||
foreach (FuelRecordAuditInfo fuel in fuels)
|
||||
{
|
||||
FuelRecordAuditItem fi = new FuelRecordAuditItem();
|
||||
Helper.CloneProperty(fi, fuel);
|
||||
fi.TransactionDate = fi.TransactionDate.ToLocalTime();
|
||||
fi.AddedOn = fi.AddedOn.ToLocalTime();
|
||||
fi.LastUpdatedOn = fi.LastUpdatedOn.ToLocalTime();
|
||||
list.Add(fi);
|
||||
}
|
||||
|
||||
return list.ToArray();
|
||||
}
|
||||
else
|
||||
return new FuelRecordInfo[0];
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "FuelRecordBasePage.GetFuelRecords", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object SaveFuelRecord()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
|
||||
FuelRecordInfo fuelrecord = JsonConvert.DeserializeObject<FuelRecordInfo>(clientdata);
|
||||
|
||||
FuelRecord record = new FuelRecord();
|
||||
Helper.CloneProperty(record, fuelrecord);
|
||||
record.TransactionDate = record.TransactionDate.ToUniversalTime();
|
||||
long fuleid = record.FuelID;
|
||||
if (record.FuelID == -1)
|
||||
{
|
||||
FuelRecord fr = CreateClient<FuelManagementClient>().AddNewFuelRecord(SystemParams.CompanyID, record, session.User.UID);
|
||||
fuleid = fr.FuelID;
|
||||
}
|
||||
else
|
||||
{
|
||||
CreateClient<FuelManagementClient>().UpdateFuelRecord(SystemParams.CompanyID, record, session.User.UID);
|
||||
}
|
||||
|
||||
return fuleid;
|
||||
}
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object DeleteFuelRecord()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string clientdata = Request.Form["ClientData"];
|
||||
long fuleid = Convert.ToInt64(HttpUtility.HtmlDecode(clientdata));
|
||||
|
||||
CreateClient<FuelManagementClient>().DeleteFuelRecord(SystemParams.CompanyID, fuleid, session.User.UID);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetFuelTypes()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
List<KeyValuePair<string, string>> list = FuelManagementClient.FuelTypes.OrderBy(m => m.Value).ToList();
|
||||
var type1 = list.FirstOrDefault(m => m.Value == "Unleaded Regular");
|
||||
var type2 = list.FirstOrDefault(m => m.Value == "Unleaded Plus");
|
||||
var type3 = list.FirstOrDefault(m => m.Value == "Diesel #1");
|
||||
list.Remove(type1);
|
||||
list.Remove(type2);
|
||||
list.Remove(type3);
|
||||
list = list.OrderBy(m => m.Value).ToList();
|
||||
list.Insert(0, type1);
|
||||
list.Insert(1, type2);
|
||||
list.Insert(2, type3);
|
||||
return list.ToArray();
|
||||
}
|
||||
else
|
||||
return new StringKeyValue[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "FuelRecordBasePage.GetFuelTypes", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,458 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using IronIntel.Contractor.Machines;
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using System.Web;
|
||||
using IronIntel.Contractor.Users;
|
||||
using Foresight.ServiceModel;
|
||||
using Foresight.Fleet.Services.Attachment;
|
||||
using IronIntel.Contractor.Attachment;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Maintenance
|
||||
{
|
||||
public class MaintanceRecordsBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
object result = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName.ToUpper())
|
||||
{
|
||||
case "GETTYPESDATA":
|
||||
GetTypesData();
|
||||
break;
|
||||
case "GETRECORDS":
|
||||
GetRecords();
|
||||
break;
|
||||
case "GETMACHINES":
|
||||
Getmachines();
|
||||
break;
|
||||
case "GETMACHINEINFO":
|
||||
GetmachineInfo();
|
||||
break;
|
||||
case "SEARCHMACHINELIST":
|
||||
SearchmachineList();
|
||||
break;
|
||||
case "ADDMAINTENANCE":
|
||||
result = Addmaintenance();
|
||||
break;
|
||||
case "GETRECORDSBYMACHINEID":
|
||||
GetRecordsbymachineID();
|
||||
break;
|
||||
case "DELETEMAINTENANCE":
|
||||
Deletemaintenance();
|
||||
break;
|
||||
case "GETUNCOMPLETEDPMALERTS":
|
||||
result = GetUnCompletedPMAlerts();
|
||||
break;
|
||||
case "GETUSERSDATA":
|
||||
GetUsersData();
|
||||
break;
|
||||
case "GETMAINTANENCELOGATTACHLIST":
|
||||
result = GetMaintanenceLogAttachList();
|
||||
break;
|
||||
case "GETMAINTENANCEINFO":
|
||||
result = GetMaintenanceInfo();
|
||||
break;
|
||||
case "GETATTACHMENTS":
|
||||
result = GetAttachments();
|
||||
break;
|
||||
case "ADDATTACHMENT":
|
||||
result = AddAttachment();
|
||||
break;
|
||||
case "DELETEATTACHMENT":
|
||||
result = DeleteAttachment();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Threading.ThreadAbortException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "MaintanceRecordsBasePage" + methodName, ex.Message, ex.ToString());
|
||||
}
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
private void GetTypesData()
|
||||
{
|
||||
string json = "";
|
||||
List<KeyValuePair<int, string>> typeskeypair = new List<KeyValuePair<int, string>>();
|
||||
MachineServiceClient2 mc = new MachineServiceClient2(SystemParams.SystemServiceAddresses[0]);
|
||||
MachineType[] types = mc.GetMachineTypes();
|
||||
foreach (MachineType item in types)
|
||||
{
|
||||
typeskeypair.Add(new KeyValuePair<int, string>(item.ID, item.Name));
|
||||
}
|
||||
if (typeskeypair.Count > 0)
|
||||
{
|
||||
typeskeypair = typeskeypair.OrderBy(t => t.Value).ToList();
|
||||
}
|
||||
json += JsonConvert.SerializeObject(typeskeypair);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private void GetRecords()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
string json = "";
|
||||
long assetid = -1;
|
||||
long.TryParse(Request.Params["assetid"], out assetid);
|
||||
string maintenanceType = Request.Params["maintenancetype"];
|
||||
string mtype = Request.Params["type"];
|
||||
string searchtxt = HttpUtility.UrlDecode(Request.Params["searchtxt"]);
|
||||
string sortype = HttpUtility.UrlDecode(Request.Params["sortype"]);
|
||||
string sortdata = HttpUtility.UrlDecode(Request.Params["sortdata"]);
|
||||
MaintenanceLogInfo[] logs = MaintenanceManagement.GetMaintenanceLog(session.SessionID, assetid, maintenanceType, string.IsNullOrWhiteSpace(mtype) ? -1 : Convert.ToInt32(mtype), searchtxt, session.User.UID);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(sortype))
|
||||
{
|
||||
if (string.Compare(sortype, "1", true) == 0)
|
||||
{
|
||||
if (string.Compare(sortdata, "DESC", true) == 0)
|
||||
{
|
||||
logs = logs.OrderByDescending(m => m.MaintenanceDate).ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
logs = logs.OrderBy(m => m.MaintenanceDate).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
if (string.Compare(sortype, "2", true) == 0)
|
||||
{
|
||||
if (string.Compare(sortdata, "DESC", true) == 0)
|
||||
{
|
||||
logs = logs.OrderByDescending(m => m.AlertTime).ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
logs = logs.OrderBy(m => m.AlertTime).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
json += JsonConvert.SerializeObject(logs);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private object GetMaintenanceInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var id = Request.Form["ClientData"];
|
||||
|
||||
MaintenanceLogInfo ml = MaintenanceManagement.GetMaintenanceInfo(id);
|
||||
return ml;
|
||||
}
|
||||
else
|
||||
return new MaintenanceLogInfo();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "MaintanceRecordsBasePage.GetMaintenanceInfo", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void GetRecordsbymachineID()
|
||||
{
|
||||
string json = "";
|
||||
long mid = -1;
|
||||
long.TryParse(Request.Params["machineID"].ToString(), out mid);
|
||||
string maintenanceType = Request.Params["maintenancetype"];
|
||||
MaintenanceLogInfo[] logs = MaintenanceManagement.GetMaintenanceLogByMachineID(mid, maintenanceType).OrderByDescending(log => log.MaintenanceDate).ToArray();
|
||||
json += JsonConvert.SerializeObject(logs);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
private void GetmachineInfo()
|
||||
{
|
||||
string json = "";
|
||||
long mid = -1;
|
||||
long.TryParse(Request.Params["machineID"].ToString(), out mid);
|
||||
MaintenanceMachineInfo machine = MaintenanceManagement.GetmachineByMachineID(mid);
|
||||
json += JsonConvert.SerializeObject(machine);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
private void Getmachines()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
string json = "";
|
||||
string mtype = Request.Params["type"];
|
||||
string searchtxt = HttpUtility.UrlDecode(Request.Params["searchtxt"]);
|
||||
MaintenanceMachineInfo[] machines = MaintenanceManagement.GetMaintenanceMachines(session.SessionID, string.IsNullOrWhiteSpace(mtype) ? -1 : Convert.ToInt32(mtype), searchtxt, session.User.UID).OrderBy(t => t.VIN).ToArray();
|
||||
json += JsonConvert.SerializeObject(machines);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
private void SearchmachineList()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
string json = "";
|
||||
string mtype = Request.Params["type"];
|
||||
string searchtxt = HttpUtility.UrlDecode(Request.Params["searchtxt"]);
|
||||
|
||||
MaintenanceMachineInfo[] machines = MaintenanceManagement.GetMaintenanceMachines(session.SessionID, string.IsNullOrWhiteSpace(mtype) ? -1 : Convert.ToInt32(mtype), searchtxt, session.User.UID);
|
||||
if (machines.Length > 0)
|
||||
{
|
||||
json = JsonConvert.SerializeObject(machines);
|
||||
}
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private object Addmaintenance()
|
||||
{
|
||||
try
|
||||
{
|
||||
UserInfo u = GetCurrentUser();
|
||||
if (u != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
MaintenanceLogInfo m = JsonConvert.DeserializeObject<MaintenanceLogInfo>(clientdata);
|
||||
|
||||
MaintenanceLogInfo oldinfo = null;
|
||||
if (!string.IsNullOrEmpty(m.MaintenanceID))
|
||||
{
|
||||
oldinfo = MaintenanceManagement.GetMaintenanceLogByMaintenanceID(m.MaintenanceID);
|
||||
}
|
||||
if (oldinfo == null)
|
||||
{
|
||||
oldinfo = new MaintenanceLogInfo();
|
||||
oldinfo.MaintenanceID = Guid.NewGuid().ToString().ToUpper();
|
||||
}
|
||||
oldinfo.MachineID = m.MachineID;
|
||||
oldinfo.MaintenanceDate = m.MaintenanceDate;
|
||||
oldinfo.MaintenanceHours = m.MaintenanceHours;
|
||||
oldinfo.ODOMeter = m.ODOMeter;
|
||||
oldinfo.ODOMemterUOM = m.ODOMemterUOM;
|
||||
oldinfo.Notes = HttpUtility.UrlDecode(m.Notes);
|
||||
oldinfo.LogType = m.LogType;
|
||||
oldinfo.Cost = m.Cost;
|
||||
oldinfo.InvoiceNumber = m.InvoiceNumber;
|
||||
oldinfo.AttachmentIDs = m.AttachmentIDs;
|
||||
|
||||
if (oldinfo.AlertID != m.AlertID && oldinfo.AlertID > 0)
|
||||
{//取消旧的Alert Completed状态
|
||||
MaintenanceManagement.SetPMAlertCompleted(oldinfo.AlertID, false, "");
|
||||
}
|
||||
if (m.AlertID > 0)//对于Alert,关联了Maintenance Rocord才认为是完成
|
||||
{//更新新的Alert Completed状态
|
||||
MaintenanceManagement.SetPMAlertCompleted(m.AlertID, true, m.CompletedByName);
|
||||
}
|
||||
|
||||
oldinfo.CompletedByName = m.CompletedByName;
|
||||
oldinfo.Completed = !string.IsNullOrWhiteSpace(m.CompletedByName);//对于Maintenance Rocord选择了Completed By就认为是完成
|
||||
oldinfo.AlertID = m.AlertID;
|
||||
|
||||
MaintenanceManagement.UpdateMaintenanceLog(oldinfo, u.IID);
|
||||
AttachmentsManagement.SaveAttach(oldinfo.MaintenanceID, u.IID, oldinfo.AttachmentIDs, AttachmentType.MaintenanceLog);
|
||||
|
||||
return new string[] { oldinfo.MaintenanceID, "Saved Successfully." };
|
||||
}
|
||||
else
|
||||
return "Failed to save,The user is not logged.";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void Deletemaintenance()
|
||||
{
|
||||
string maintenanceID = Request.Params["maintenanceid"].ToString();
|
||||
UserInfo u = GetCurrentUser();
|
||||
if (u != null)
|
||||
{
|
||||
MaintenanceLogInfo m = MaintenanceManagement.GetMaintenanceLogByMaintenanceID(maintenanceID);
|
||||
if (m.AlertID > 0)//取消Alert Completed状态
|
||||
MaintenanceManagement.SetPMAlertCompleted(m.AlertID, false, "");
|
||||
MaintenanceManagement.DeleteMaintenanceLog(maintenanceID);
|
||||
Response.Write(JsonConvert.SerializeObject("Deleted Successfully."));
|
||||
}
|
||||
else
|
||||
Response.Write(JsonConvert.SerializeObject("Failed to delete record."));
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private object GetUnCompletedPMAlerts()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
long machineid = -1;
|
||||
long.TryParse(clientdata[0], out machineid);
|
||||
string maintenanceid = clientdata[1];
|
||||
|
||||
PMAlert[] pmalerts = MaintenanceManagement.GetUnCompletedPMAlerts(machineid, maintenanceid);
|
||||
|
||||
return pmalerts;
|
||||
}
|
||||
else
|
||||
return new PMAlert[0];
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "MaintanceRecordsBasePage.GetUnCompletedPMAlerts", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private void GetUsersData()
|
||||
{
|
||||
UserInfo[] user = UserManagement.GetUsers();
|
||||
user = user.OrderBy((u) => u.DisplayName).ToArray();
|
||||
string json = JsonConvert.SerializeObject(user);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private object GetMaintanenceLogAttachList()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var id = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var type = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
StringKeyValue[] attas = AttachmentsManagement.GetAttachList(id, type);
|
||||
|
||||
return attas;
|
||||
}
|
||||
else
|
||||
return new StringKeyValue[0];
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "MaintanceRecordsBasePage.GetMaintanenceLogAttachList", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Attachment
|
||||
|
||||
private object GetAttachments()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var woid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
|
||||
AttachmentInfo[] atts = CreateClient<AttachmentClient>().GetAttachments(SystemParams.CompanyID, "MaintenanceLog", woid);
|
||||
if (atts == null || atts.Length <= 0)
|
||||
return new AttachmentItem[0];
|
||||
|
||||
List<AttachmentItem> list = new List<AttachmentItem>();
|
||||
foreach (AttachmentInfo att in atts)
|
||||
{
|
||||
AttachmentItem item = new AttachmentItem();
|
||||
Helper.CloneProperty(item, att);
|
||||
item.AddedOn = item.AddedOn.ToLocalTime();
|
||||
list.Add(item);
|
||||
}
|
||||
return list.OrderBy(m => m.AddedOn).ToArray();
|
||||
}
|
||||
else
|
||||
return new AttachmentItem[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object AddAttachment()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string woid = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
|
||||
|
||||
HttpPostedFile uploadFile = null;
|
||||
byte[] iconfilebyte = null;
|
||||
if (Request.Files.Count > 0)
|
||||
{
|
||||
uploadFile = Request.Files[0];
|
||||
iconfilebyte = ConvertFile2bytes(uploadFile);
|
||||
}
|
||||
|
||||
AttachmentInfo attachment = new AttachmentInfo();
|
||||
attachment.StringID = Guid.NewGuid().ToString().ToUpper();
|
||||
attachment.FileName = uploadFile == null ? "" : uploadFile.FileName;
|
||||
attachment.Source = "MaintenanceLog";
|
||||
attachment.SourceID = woid;
|
||||
attachment.FileData = iconfilebyte;
|
||||
attachment.AddedByUserIID = session.User.UID;
|
||||
|
||||
string attid = CreateClient<AttachmentClient>().AddAttachmentLegacy(SystemParams.CompanyID, attachment);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object DeleteAttachment()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string attachid = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
|
||||
|
||||
CreateClient<AttachmentClient>().DeleteAttachmentLegacy(SystemParams.CompanyID, attachid, session.User.UID);
|
||||
return "OK";
|
||||
}
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
138
IronIntelContractorSiteLib/Maintenance/MaintenanceBasePage.cs
Normal file
138
IronIntelContractorSiteLib/Maintenance/MaintenanceBasePage.cs
Normal file
@ -0,0 +1,138 @@
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Services;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Maintenance
|
||||
{
|
||||
public class MaintenanceBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
object result = null;
|
||||
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName.ToUpper())
|
||||
{
|
||||
case "GETNAVS":
|
||||
result = GetNavigations();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
private MaintenanceNavigateItem[] GetNavigations()
|
||||
{
|
||||
List<MaintenanceNavigateItem> list = GetNavigateItems();
|
||||
LicenseInfo license = SystemParams.GetLicense();
|
||||
if (license != null && license.Items.Count > 0)
|
||||
{
|
||||
var alitem = license.Items.FirstOrDefault(m => m.Key == "AlertsManagement");
|
||||
if (alitem == null || !Helper.IsTrue(alitem.Value))
|
||||
{
|
||||
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_alertsmanagement");
|
||||
list.Remove(item);
|
||||
}
|
||||
var woitem = license.Items.FirstOrDefault(m => m.Key == "WorkOrder");
|
||||
if (woitem == null || !Helper.IsTrue(woitem.Value))
|
||||
{
|
||||
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_workorder");
|
||||
list.Remove(item);
|
||||
}
|
||||
var fuelitem = license.Items.FirstOrDefault(m => m.Key == "FuelRecords");
|
||||
if (fuelitem == null || !Helper.IsTrue(fuelitem.Value))
|
||||
{
|
||||
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_fuelrecord");
|
||||
list.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
|
||||
private static List<MaintenanceNavigateItem> GetNavigateItems()
|
||||
{
|
||||
List<MaintenanceNavigateItem> list = new List<MaintenanceNavigateItem>();
|
||||
|
||||
MaintenanceNavigateItem item1 = new MaintenanceNavigateItem();
|
||||
item1.ID = "nav_alertsmanagement";
|
||||
item1.Title = "Alerts Management **New**";
|
||||
item1.Url = "AlertsManagement.aspx";
|
||||
item1.IconPath = "img/alert.png";
|
||||
list.Add(item1);
|
||||
|
||||
MaintenanceNavigateItem item6 = new MaintenanceNavigateItem();
|
||||
item6.ID = "nav_workorder";
|
||||
item6.Title = "Work Order **New**";
|
||||
item6.Url = "WorkOrderMaintenance.aspx";
|
||||
item6.IconPath = "img/workorder.png";
|
||||
list.Add(item6);
|
||||
|
||||
MaintenanceNavigateItem item3 = new MaintenanceNavigateItem();
|
||||
item3.ID = "nav_preventative";
|
||||
item3.Title = "Absolute Hours Maintenance";
|
||||
item3.Url = "PreventativeMaintenance.aspx";
|
||||
item3.IconPath = "img/preventative.png";
|
||||
list.Add(item3);
|
||||
|
||||
MaintenanceNavigateItem item4 = new MaintenanceNavigateItem();
|
||||
item4.ID = "nav_timebased";
|
||||
item4.Title = "Relative Time Maintenance";
|
||||
item4.Url = "TimeBasedMaintenance.aspx";
|
||||
item4.IconPath = "img/timebased.png";
|
||||
list.Add(item4);
|
||||
|
||||
MaintenanceNavigateItem item7 = new MaintenanceNavigateItem();
|
||||
item7.ID = "nav_hours";
|
||||
item7.Title = "Relative Hours Maintenance";
|
||||
item7.Url = "HoursMaintenance.aspx";
|
||||
item7.IconPath = "img/hours.png";
|
||||
list.Add(item7);
|
||||
|
||||
MaintenanceNavigateItem item5 = new MaintenanceNavigateItem();
|
||||
item5.ID = "nav_absolutedistance";
|
||||
item5.Title = "Absolute Distance Maintenance";
|
||||
item5.Url = "AbsoluteDistanceMaintenance.aspx";
|
||||
item5.IconPath = "img/preventative.png";
|
||||
list.Add(item5);
|
||||
|
||||
MaintenanceNavigateItem item8 = new MaintenanceNavigateItem();
|
||||
item8.ID = "nav_relativedistance";
|
||||
item8.Title = "Relative Distance Maintenance";
|
||||
item8.Url = "RelativeDistanceMaintenance.aspx";
|
||||
item8.IconPath = "img/hours.png";
|
||||
list.Add(item8);
|
||||
|
||||
MaintenanceNavigateItem item2 = new MaintenanceNavigateItem();
|
||||
item2.ID = "nav_record";
|
||||
item2.Title = "Maintenance Record **Legacy**";
|
||||
item2.Url = "MaintanceRecordsManagement.aspx";
|
||||
item2.IconPath = "img/record.png";
|
||||
list.Add(item2);
|
||||
|
||||
MaintenanceNavigateItem item9 = new MaintenanceNavigateItem();
|
||||
item9.ID = "nav_fuelrecord";
|
||||
item9.Title = "Fuel Records";
|
||||
item9.Url = "FuelRecordManagement.aspx";
|
||||
item9.IconPath = "img/fuelrecord.png";
|
||||
list.Add(item9);
|
||||
return list;
|
||||
}
|
||||
public class MaintenanceNavigateItem
|
||||
{
|
||||
public string ID { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Url { get; set; }
|
||||
public string IconPath { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
26
IronIntelContractorSiteLib/Maintenance/MaintenanceParams.cs
Normal file
26
IronIntelContractorSiteLib/Maintenance/MaintenanceParams.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Maintenance
|
||||
{
|
||||
public class ScheduleSaveArgs
|
||||
{
|
||||
public string IID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string ScheduleUom { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string Notes { get; set; }
|
||||
|
||||
public PmIntervalItem[] Intervals { get; set; }
|
||||
}
|
||||
|
||||
public class ScheduleMachineArgs
|
||||
{
|
||||
public string IID { get; set; }
|
||||
public MaintenanceMachineInfo[] Machines { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,449 @@
|
||||
using Foresight.Fleet.Services.AssetHealth;
|
||||
using IronIntel.Contractor.Machines;
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Maintenance
|
||||
{
|
||||
public class PreventativeMaintenanceBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
object result = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName.ToUpper())
|
||||
{
|
||||
case "GETPMSCHEDULE":
|
||||
result = GetPmSchedule();
|
||||
break;
|
||||
case "DELETEPMSCHEDULE":
|
||||
result = DeletePmScheule();
|
||||
break;
|
||||
case "SAVEPMSCHEDULE":
|
||||
result = SavePmSchedule();
|
||||
break;
|
||||
case "ADDPMINTERVAL":
|
||||
result = AddPmInterval();
|
||||
break;
|
||||
case "UPDATEPMINTERVAL":
|
||||
result = UpdatePmInterval();
|
||||
break;
|
||||
case "DELETEPMINTERVAL":
|
||||
result = DeletePmInterval();
|
||||
break;
|
||||
|
||||
case "GETMACHINETYPES":
|
||||
Machines.MachineManagement.RefreshMachineTypes();
|
||||
result = MachineManagement.GetMachineTypes().OrderBy(m => m.Name).Select(t => new
|
||||
{
|
||||
ID = t.ID,
|
||||
Name = t.Name
|
||||
});
|
||||
break;
|
||||
case "GETMACHINELIST":
|
||||
result = GetMachineList();
|
||||
break;
|
||||
case "GETSELECTEDMACHINES":
|
||||
result = GetSelectedMachines();
|
||||
break;
|
||||
case "SAVEMACHINES":
|
||||
result = SaveMachines();
|
||||
break;
|
||||
case "REMOVEPMASSETS":
|
||||
result = RemovePMAssets();
|
||||
break;
|
||||
case "GETPMINTERVALBYSCHEDULEID":
|
||||
result = GetPmIntervalByScheduleID();
|
||||
break;
|
||||
case "GETPMSCHEDULEBYID":
|
||||
result = GetPMScheduleByID();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result = ex.Message;
|
||||
SystemParams.WriteLog("Error", "PreventativeMaintenanceBasePage.ProcessRequest", ex.Message, ex.ToString());
|
||||
}
|
||||
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private object GetPmIntervalByScheduleID()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
|
||||
string scheduleid = Request.Form["ClientData"];
|
||||
return MaintenanceManagement.GetPmInterval(session.SessionID, scheduleid);
|
||||
}
|
||||
else
|
||||
return new PmIntervalItem[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "PreventativeMaintenanceBasePage.GetPmIntervalByScheduleID", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private object GetPmSchedule()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string pmtype = Request.Form["ClientData"];
|
||||
if (string.IsNullOrWhiteSpace(pmtype))
|
||||
pmtype = "PM";
|
||||
|
||||
return MaintenanceManagement.GetPmSchedule(session.SessionID, pmtype);
|
||||
}
|
||||
else
|
||||
return new PmScheduleInfo[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "PreventativeMaintenanceBasePage.GetPmSchedule", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private object GetPMScheduleByID()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string scheduleid = Request.Form["ClientData"];
|
||||
|
||||
return MaintenanceManagement.GetPMScheduleByID(session.SessionID, scheduleid);
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "PreventativeMaintenanceBasePage.GetPMScheduleByID", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object DeletePmScheule()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
|
||||
var iid = Request.Form["ClientData"];
|
||||
CreateClient<PMClient>().DeletePMSchedule(SystemParams.CompanyID, iid, session.User.UID);
|
||||
return string.Empty;
|
||||
}
|
||||
else
|
||||
return "Failed";
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return "Failed to delete schedule: " + ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object SavePmSchedule()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var s = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
|
||||
var item = JsonConvert.DeserializeObject<ScheduleSaveArgs>(s);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(item.Name))
|
||||
{
|
||||
return "The schedule name cannot be empty or just whitespaces.";
|
||||
}
|
||||
|
||||
PmScheduleInfo si;
|
||||
if (item.Intervals == null)
|
||||
{
|
||||
item.Intervals = new PmIntervalItem[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < item.Intervals.Length; i++)
|
||||
{
|
||||
if (string.IsNullOrEmpty(item.Intervals[i].PmIntervalID))
|
||||
item.Intervals[i].PmIntervalID = Guid.NewGuid().ToString();
|
||||
item.Intervals[i].ServiceName = item.Intervals[i].ServiceName.Trim();
|
||||
}
|
||||
}
|
||||
si = new PmScheduleInfo
|
||||
{
|
||||
PmScheduleID = string.IsNullOrWhiteSpace(item.IID) ? Guid.NewGuid().ToString() : item.IID,
|
||||
PmScheduleName = item.Name.Trim(),
|
||||
PmScheduleType = item.Type,
|
||||
PmScheduleUom = item.ScheduleUom,
|
||||
Notes = item.Notes,
|
||||
Intervals = item.Intervals
|
||||
};
|
||||
MaintenanceManagement.UpdatePmSchedule(session.SessionID, si, session.User.UID);
|
||||
|
||||
return si.PmScheduleID;
|
||||
}
|
||||
else
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string AddPmInterval()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var s = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
|
||||
PmScheduleInfo item;
|
||||
item = JsonConvert.DeserializeObject<PmScheduleInfo>(s);
|
||||
PmIntervalItem piclient = item.Intervals[0];
|
||||
piclient.PmIntervalID = Guid.NewGuid().ToString();
|
||||
piclient.ScheduleId = item.PmScheduleID;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(piclient.ServiceName))
|
||||
{
|
||||
return "Service Name cannot be empty.";
|
||||
}
|
||||
else
|
||||
{
|
||||
piclient.ServiceName = piclient.ServiceName.Trim();
|
||||
}
|
||||
|
||||
MaintenanceManagement.UpdatePmInterval(session.SessionID, piclient, session.User.UID);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
else
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object UpdatePmInterval()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var s = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
|
||||
PmIntervalItem item = JsonConvert.DeserializeObject<PmIntervalItem>(s);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(item.ServiceName))
|
||||
{
|
||||
return "Service Name cannot be empty.";
|
||||
}
|
||||
else
|
||||
{
|
||||
item.ServiceName = item.ServiceName.Trim();
|
||||
}
|
||||
|
||||
MaintenanceManagement.UpdatePmInterval(session.SessionID, item, session.User.UID);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
else
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string DeletePmInterval()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var iid = Request.Form["ClientData"];
|
||||
CreateClient<PMClient>().DeletePMIntervals(SystemParams.CompanyID, new string[] { iid }, session.User.UID);
|
||||
return string.Empty;
|
||||
}
|
||||
else
|
||||
return "Failed";
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return "Failed to delete interval: " + ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private MaintenanceMachineInfo[] GetMachineList()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
var s = Request.Form["ClientData"];
|
||||
var type = JsonConvert.DeserializeObject<MachineItem>(s);
|
||||
|
||||
//MaintenanceMachineInfo[] selected;
|
||||
//if (!string.IsNullOrWhiteSpace(type.VIN))
|
||||
//{
|
||||
// selected = MaintenanceManagement.GetPmMachinesByScheduleId(type.VIN);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// selected = new MaintenanceMachineInfo[0];
|
||||
//}
|
||||
|
||||
var machines = MaintenanceManagement.GetMaintenanceMachines1(session.SessionID, (int)type.MachineID, type.Name, session.User.UID)
|
||||
//.Where(m => !selected.Any(t => t.MachineID == m.MachineID))
|
||||
.OrderBy(m => m.VIN)
|
||||
.ToArray();
|
||||
|
||||
return machines;
|
||||
}
|
||||
|
||||
private PMAssetItem[] GetSelectedMachines()
|
||||
{
|
||||
var iid = Request.Form["ClientData"];
|
||||
List<PMAssetItem> result = new List<PMAssetItem>();
|
||||
var assets = CreateClient<PMClient>().GetPMAssets(SystemParams.CompanyID, iid);
|
||||
foreach (var asset in assets)
|
||||
{
|
||||
PMAssetItem a = new PMAssetItem();
|
||||
Helper.CloneProperty(a, asset);
|
||||
a.EngineHours = asset.CurrentEngineHours;
|
||||
a.Odometer = asset.CurrentOdometer;
|
||||
result.Add(a);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
private string SaveMachines()
|
||||
{
|
||||
var u = GetCurrentUser();
|
||||
if (u != null)
|
||||
{
|
||||
var s = Request.Form["ClientData"];
|
||||
var p = JsonConvert.DeserializeObject<ScheduleAssetArgs>(s);
|
||||
//MaintenanceManagement.UpdatePmMachines(ids.IID, ids.Assets);
|
||||
List<PMAssetInfo> assets = new List<PMAssetInfo>();
|
||||
if (p.Assets != null)
|
||||
{
|
||||
foreach (var a in p.Assets)
|
||||
{
|
||||
PMAssetInfo pmAsset = new PMAssetInfo();
|
||||
pmAsset.AssetId = a.AssetId;
|
||||
pmAsset.StartHours = a.StartHours;
|
||||
pmAsset.StartOdometer = a.StartOdometer;
|
||||
pmAsset.StartDate = a.StartDate;
|
||||
pmAsset.StartIntervalValue = a.StartIntervalValue;
|
||||
assets.Add(pmAsset);
|
||||
}
|
||||
}
|
||||
CreateClient<PMClient>().UpdatePMScheduleAssets(SystemParams.CompanyID, p.IID, assets.ToArray(), u.IID);
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private string RemovePMAssets()
|
||||
{
|
||||
var u = GetCurrentUser();
|
||||
if (u != null)
|
||||
{
|
||||
var s = Request.Form["ClientData"];
|
||||
var p = JsonConvert.DeserializeObject<RemovePMAssetsArgs>(s);
|
||||
|
||||
CreateClient<PMClient>().DeleteAssetsFromSchedule(SystemParams.CompanyID, p.ScheduleID, p.Assets, u.IID);
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
class RemovePMAssetsArgs
|
||||
{
|
||||
public string ScheduleID { get; set; }
|
||||
public long[] Assets { get; set; }
|
||||
}
|
||||
|
||||
class ScheduleAssetArgs
|
||||
{
|
||||
public string IID { get; set; }
|
||||
public PMAssetItem[] Assets { get; set; }
|
||||
}
|
||||
|
||||
|
||||
class PMAssetItem
|
||||
{
|
||||
public string ModelName { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public double? StartOdometer { get; set; }
|
||||
public double? StartHours { get; set; }
|
||||
public DateTime? StartDate { get; set; }
|
||||
public string TypeName { get; set; }
|
||||
public int AlertsCount { get; set; }
|
||||
public int UnMaintainedAlert { get; set; }
|
||||
public string MakeName { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string VIN { get; set; }
|
||||
public long AssetId { get; set; }
|
||||
public double? EngineHours { get; set; }
|
||||
public double? Odometer { get; set; }
|
||||
public string PMScheduleId { get; set; }
|
||||
public int? StartIntervalValue { get; set; }
|
||||
public string StartDateString
|
||||
{
|
||||
get
|
||||
{
|
||||
if (StartDate == null)
|
||||
return "";
|
||||
else
|
||||
return StartDate.Value.ToString("MM/dd/yyyy");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ScheduleSaveArgs
|
||||
{
|
||||
public string IID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string ScheduleUom { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string Notes { get; set; }
|
||||
|
||||
public PmIntervalItem[] Intervals { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
879
IronIntelContractorSiteLib/Maintenance/WorkOrderBasePage.cs
Normal file
879
IronIntelContractorSiteLib/Maintenance/WorkOrderBasePage.cs
Normal file
@ -0,0 +1,879 @@
|
||||
using Foresight.Data;
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using Foresight.Fleet.Services.AssetHealth;
|
||||
using Foresight.Fleet.Services.Attachment;
|
||||
using Foresight.Fleet.Services.JobSite;
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Contractor.Attachment;
|
||||
using IronIntel.Contractor.JobSites;
|
||||
using IronIntel.Contractor.Machines;
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
using IronIntel.Contractor.MapView;
|
||||
using IronIntel.Contractor.Users;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Maintenance
|
||||
{
|
||||
public class WorkOrderBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
object result = null;
|
||||
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName.ToUpper())
|
||||
{
|
||||
case "GETWORKORDERS":
|
||||
result = GetWorkOrders();
|
||||
break;
|
||||
case "SAVEWORKORDER":
|
||||
result = SaveWorkOrder();
|
||||
break;
|
||||
case "DELETEWORKORDER":
|
||||
result = DeleteWorkOrder();
|
||||
break;
|
||||
case "GETCONTACTS":
|
||||
result = GetContacts();
|
||||
break;
|
||||
case "GETMACHINES":
|
||||
result = GetMachines();
|
||||
break;
|
||||
case "GETWORKORDERINFO":
|
||||
result = GetWorkOrderInfo();
|
||||
break;
|
||||
case "GETOPENWORKORDERID":
|
||||
result = GetOpenWorkOrderID();
|
||||
break;
|
||||
case "GETSEGMENTS":
|
||||
result = GetSegments();
|
||||
break;
|
||||
case "SAVESEGMENT":
|
||||
result = SaveSegment();
|
||||
break;
|
||||
case "DELETESEGMENT":
|
||||
result = DeleteSegment();
|
||||
break;
|
||||
case "GETSEGMENTCLIENT":
|
||||
result = GetSegmentClient();
|
||||
break;
|
||||
case "GETNONEASSIGNEDALERTS":
|
||||
result = GetNoneAssignedAlerts();
|
||||
break;
|
||||
case "ADDORREMOVEALERTSFROMWORKORDER":
|
||||
result = AddOrRemoveAlertsFromWorkOrder();
|
||||
break;
|
||||
case "GETATTACHMENTS":
|
||||
result = GetAttachments();
|
||||
break;
|
||||
case "ADDATTACHMENT":
|
||||
result = AddAttachment();
|
||||
break;
|
||||
case "DELETEATTACHMENT":
|
||||
result = DeleteAttachment();
|
||||
break;
|
||||
case "GETASSETATTACHMENTS":
|
||||
result = GetAssetAttachments();
|
||||
break;
|
||||
case "GETMACHINECONTACTS":
|
||||
result = GetMachineContacts();
|
||||
break;
|
||||
case "SENDWORKORDER":
|
||||
result = SendWorkOrder();
|
||||
break;
|
||||
case "GETINVOICENUMBER":
|
||||
result = GetInvoiceNumber();
|
||||
break;
|
||||
case "GETALERTSFORWORKORDER":
|
||||
result = GetAlertsForWorkOrder();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private object GetWorkOrders()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
clientdata = HttpUtility.HtmlDecode(clientdata);
|
||||
WorkOrderQueryParams p = JsonConvert.DeserializeObject<WorkOrderQueryParams>(clientdata);
|
||||
|
||||
WorkOrderItem[] workorders = null;
|
||||
if (p.AssetID > 0)
|
||||
workorders = CreateClient<WorkOrderClient>().GetWorkOrderItemsByAsset(SystemParams.CompanyID, p.AssetID);
|
||||
else
|
||||
workorders = CreateClient<WorkOrderClient>().GetWorkOrderItems(SystemParams.CompanyID, p.Contacts, p.Status, p.AssetGroups, p.SearchText, session.User.UID);
|
||||
|
||||
WorkOrderInfo[] maintenanceworkorders = null;//
|
||||
if (p.ShowMaintenance)
|
||||
maintenanceworkorders = MaintenanceManagement.GetMaintenanceWorkOrders(session.SessionID, SystemParams.CompanyID, p.Contacts, p.AssetGroups, p.SearchText, session.User.UID);
|
||||
|
||||
//普通用户机器权限过滤
|
||||
var user = GetCurrentUser();
|
||||
long[] availableAssetsids = null;
|
||||
if (user.UserType < UserTypes.Admin)
|
||||
availableAssetsids = CreateClient<AssetQueryClient>().GetAvailableAssetsForUsers(SystemParams.CompanyID, session.User.UID);
|
||||
|
||||
List<WorkOrderInfo> list = new List<WorkOrderInfo>();
|
||||
|
||||
if (maintenanceworkorders != null)
|
||||
{
|
||||
foreach (WorkOrderInfo wi in maintenanceworkorders)
|
||||
{
|
||||
if (availableAssetsids != null && !availableAssetsids.Contains(wi.AssetID))
|
||||
continue;
|
||||
|
||||
list.Add(wi);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (WorkOrderItem wo in workorders)
|
||||
{
|
||||
WorkOrderInfo wi = new WorkOrderInfo();
|
||||
Helper.CloneProperty(wi, wo);
|
||||
if (availableAssetsids != null && !availableAssetsids.Contains(wi.AssetID))
|
||||
continue;
|
||||
|
||||
list.Add(wi);
|
||||
}
|
||||
|
||||
return list.OrderBy(m => m.ID).ToArray();
|
||||
}
|
||||
else
|
||||
return new WorkOrderInfo[0];
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "WorkOrderBasePage.GetWorkOrders", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private object GetWorkOrderInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var woid = Request.Form["ClientData"];
|
||||
|
||||
WorkOrderDetail wod = CreateClient<WorkOrderClient>().GetWorkOrderDetail(SystemParams.CompanyID, Convert.ToInt64(woid));
|
||||
|
||||
WorkOrderDetailInfo wo = new WorkOrderDetailInfo();
|
||||
Helper.CloneProperty(wo, wod);
|
||||
return wo;
|
||||
}
|
||||
else
|
||||
return new WorkOrderDetailInfo();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "WorkOrderBasePage.GetWorkOrderInfo", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetAlertsForWorkOrder()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
clientdata = HttpUtility.HtmlDecode(clientdata);
|
||||
string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata);
|
||||
|
||||
var woid = ps[0];
|
||||
var aid = ps[1];
|
||||
long workorderid = Convert.ToInt64(woid);
|
||||
long assetid = Convert.ToInt64(aid);
|
||||
AlertManager am = new AlertManager(SystemParams.DataDbConnectionString);
|
||||
AlertInfo[] alerts = am.GetAlertsByWorkOrder(workorderid);
|
||||
|
||||
AssetAlertItem[] aAlerts = CreateClient<WorkOrderClient>().GetNoneAssignedAlerts(SystemParams.CompanyID, assetid);
|
||||
List<AlertInfo> assetAlerts = new List<AlertInfo>();
|
||||
if (aAlerts != null)
|
||||
{
|
||||
foreach (var aa in aAlerts)
|
||||
{
|
||||
AlertInfo ai = new AlertInfo();
|
||||
ai.AlertID = aa.ID;
|
||||
ai.MachineID = aa.AssetID;
|
||||
ai.AlertType = aa.AlertType;
|
||||
ai.Description = aa.Description;
|
||||
ai.AlertTime_UTC = aa.AlertTime;
|
||||
assetAlerts.Add(ai);
|
||||
}
|
||||
}
|
||||
|
||||
WorkorderAlerts wa = new WorkorderAlerts();
|
||||
wa.Alerts = alerts;
|
||||
wa.AssetAlerts = assetAlerts.ToArray(); ;
|
||||
|
||||
return wa;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AlertsBasePage.GetAlertsByWorkOrder", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetOpenWorkOrderID()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var mid = Request.Form["ClientData"];
|
||||
long aid = 0;
|
||||
long.TryParse(mid, out aid);
|
||||
|
||||
var wos = CreateClient<WorkOrderClient>().GetWorkOrderItemsByAsset(SystemParams.CompanyID, aid);
|
||||
List<long> workorderids = new List<long>();
|
||||
foreach (var wo in wos)
|
||||
{
|
||||
if (!wo.Completed)
|
||||
workorderids.Add(wo.ID);
|
||||
}
|
||||
//WorkOrderManager workordermanager = new WorkOrderManager(SystemParams.DataDbConnectionString);
|
||||
//long[] workorderids = workordermanager.GetOpenWorkOrderID(mid);
|
||||
string ids = string.Join(", ", workorderids);
|
||||
ids = mid + "|" + ids;
|
||||
return ids;
|
||||
}
|
||||
else
|
||||
return new WorkOrderInfo();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "WorkOrderBasePage.GetOpenWorkOrderID", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object SaveWorkOrder()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var workorderitem = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var ids = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
long[] alertids = JsonConvert.DeserializeObject<long[]>(ids);
|
||||
|
||||
WorkOrderDetailInfo wdi = JsonConvert.DeserializeObject<WorkOrderDetailInfo>(workorderitem);
|
||||
if (wdi.CompleteDate != null)
|
||||
wdi.Status = "Completed";
|
||||
|
||||
WorkOrderDetail wo = new WorkOrderDetail();
|
||||
Helper.CloneProperty(wo, wdi);
|
||||
|
||||
long workorderid = wo.ID;
|
||||
if (wo.ID == -1)
|
||||
{
|
||||
wo = CreateClient<WorkOrderClient>().AddNewWorkOrder(SystemParams.CompanyID, wo, alertids, session.User.UID);
|
||||
workorderid = wo.ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
WorkOrderDetail oldwo = CreateClient<WorkOrderClient>().GetWorkOrderDetail(SystemParams.CompanyID, workorderid);
|
||||
var user = UserManagement.GetUserByIID(session.User.UID);
|
||||
if (oldwo.Status == "Completed" && user.UserType < UserTypes.Admin)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
CreateClient<WorkOrderClient>().UpdateWorkOrder(SystemParams.CompanyID, wo, session.User.UID);
|
||||
}
|
||||
|
||||
return workorderid;
|
||||
}
|
||||
else
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object DeleteWorkOrder()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string clientdata = Request.Form["ClientData"];
|
||||
int id = Convert.ToInt32(HttpUtility.HtmlDecode(clientdata));
|
||||
|
||||
CreateClient<WorkOrderClient>().DeleteWorkOrder(SystemParams.CompanyID, id, session.User.UID);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message; ;
|
||||
}
|
||||
}
|
||||
|
||||
private UserInfo[] GetContacts()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
UserInfo[] users = null;
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
//contact = ContactManagement.GetContacts();
|
||||
users = UserManagement.GetActiveUsers(session.SessionID);
|
||||
users = users.OrderBy(u => u.DisplayName).ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
users = new UserInfo[0];
|
||||
}
|
||||
return users;
|
||||
}
|
||||
|
||||
private MachineItem[] GetMachines()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
MachineItem[] machines = null;
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
machines = MachineManagement.GetMachines(session.SessionID, session.User.UID, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
machines = new MachineItem[0];
|
||||
}
|
||||
return machines.Where(m => m.Hide == false).OrderBy(m => m.ShowName).ToArray();
|
||||
}
|
||||
|
||||
|
||||
private object GetNoneAssignedAlerts()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var id = Request.Form["ClientData"];
|
||||
long assetid = Convert.ToInt64(id);
|
||||
|
||||
AssetAlertItem[] alerts = CreateClient<WorkOrderClient>().GetNoneAssignedAlerts(SystemParams.CompanyID, assetid);
|
||||
if (alerts == null || alerts.Length == 0)
|
||||
return new AssetAlertInfo[0];
|
||||
|
||||
List<AssetAlertInfo> list = new List<AssetAlertInfo>();
|
||||
foreach (AssetAlertItem alert in alerts)
|
||||
{
|
||||
AssetAlertInfo ai = new AssetAlertInfo();
|
||||
Helper.CloneProperty(ai, alert);
|
||||
ai.AlertTime = ai.AlertTime.ToLocalTime();
|
||||
ai.CompletedDate = ai.AlertTime.ToLocalTime();
|
||||
list.Add(ai);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
else
|
||||
return new AssetAlertInfo[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AlertsBasePage.GetNoneAssignedAlerts", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object AddOrRemoveAlertsFromWorkOrder()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var woid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var ids = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
var isaddstr = HttpUtility.HtmlDecode(clientdata[2]);
|
||||
bool isadd = Helper.IsTrue(isaddstr);
|
||||
long[] alertids = JsonConvert.DeserializeObject<long[]>(ids);
|
||||
|
||||
|
||||
CreateClient<WorkOrderClient>().AddOrRemoveAlertsFromWorkOrder(SystemParams.CompanyID, Convert.ToInt64(woid), alertids, isadd, session.User.UID);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Segment
|
||||
|
||||
private object GetSegmentClient()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
SegmentClient client = new SegmentClient();
|
||||
|
||||
client.Users = UserManagement.GetUsers();
|
||||
if (client.Users == null)
|
||||
client.Users = new UserInfo[0];
|
||||
|
||||
var jss = CreateClient<JobSiteProvider>().GetJobSiteItems(SystemParams.CompanyID, "", false);
|
||||
List<JobSiteViewItem> list = new List<JobSiteViewItem>();
|
||||
foreach (var js in jss)
|
||||
{
|
||||
JobSiteViewItem item = new JobSiteViewItem();
|
||||
item.ID = js.ID;
|
||||
item.Name = js.Name;
|
||||
|
||||
list.Add(item);
|
||||
}
|
||||
|
||||
client.JobSites = list.ToArray();
|
||||
if (client.JobSites == null)
|
||||
client.JobSites = new JobSiteViewItem[0];
|
||||
|
||||
return client;
|
||||
}
|
||||
else
|
||||
return new SegmentClient();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "WorkOrderBasePage.GetSegmentClient", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetSegments()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string clientdata = Request.Form["ClientData"];
|
||||
long woid = Convert.ToInt64(HttpUtility.HtmlDecode(clientdata));
|
||||
|
||||
WorkOrderSegmentItem[] segments = CreateClient<WorkOrderClient>().GetSegments(SystemParams.CompanyID, woid);
|
||||
if (segments == null || segments.Length == 0)
|
||||
return new SegmentInfo[0];
|
||||
|
||||
List<SegmentInfo> list = new List<SegmentInfo>();
|
||||
foreach (WorkOrderSegmentItem se in segments)
|
||||
{
|
||||
SegmentInfo si = new SegmentInfo();
|
||||
Helper.CloneProperty(si, se);
|
||||
list.Add(si);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
else
|
||||
return new SegmentInfo[0];
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "WorkOrderBasePage.GetSegments", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object SaveSegment()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string clientdata = Request.Form["ClientData"];
|
||||
SegmentInfo si = JsonConvert.DeserializeObject<SegmentInfo>(clientdata);
|
||||
if (si.CompletedDate != null)
|
||||
si.Completed = true;
|
||||
|
||||
WorkOrderSegmentItem segment = new WorkOrderSegmentItem();
|
||||
Helper.CloneProperty(segment, si);
|
||||
|
||||
long segmentid = segment.SegmentID;
|
||||
if (segmentid == -1)
|
||||
{
|
||||
segment = CreateClient<WorkOrderClient>().AddSegment(SystemParams.CompanyID, segment, session.User.UID);
|
||||
segmentid = segment.SegmentID;
|
||||
}
|
||||
else
|
||||
{
|
||||
CreateClient<WorkOrderClient>().UpdateSegment(SystemParams.CompanyID, segment, session.User.UID);
|
||||
}
|
||||
|
||||
return segmentid;
|
||||
}
|
||||
else
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object DeleteSegment()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string clientdata = Request.Form["ClientData"];
|
||||
int id = Convert.ToInt32(HttpUtility.HtmlDecode(clientdata));
|
||||
|
||||
CreateClient<WorkOrderClient>().DeleteSegment(SystemParams.CompanyID, id, session.User.UID);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message; ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Attachment
|
||||
|
||||
private object GetAttachments()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var woid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
|
||||
AttachmentInfo[] atts = CreateClient<AttachmentClient>().GetAttachments(SystemParams.CompanyID, "WorkOrder", woid);
|
||||
if (atts == null || atts.Length <= 0)
|
||||
return new AttachmentItem[0];
|
||||
|
||||
List<AttachmentItem> list = new List<AttachmentItem>();
|
||||
foreach (AttachmentInfo att in atts)
|
||||
{
|
||||
AttachmentItem item = new AttachmentItem();
|
||||
Helper.CloneProperty(item, att);
|
||||
item.AddedOn = item.AddedOn.AddHours(SystemParams.GetHoursOffset());
|
||||
list.Add(item);
|
||||
}
|
||||
return list.OrderBy(m => m.AddedOn).ToArray();
|
||||
}
|
||||
else
|
||||
return new AttachmentItem[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object AddAttachment()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string woid = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
|
||||
|
||||
HttpPostedFile uploadFile = null;
|
||||
byte[] iconfilebyte = null;
|
||||
if (Request.Files.Count > 0)
|
||||
{
|
||||
uploadFile = Request.Files[0];
|
||||
iconfilebyte = ConvertFile2bytes(uploadFile);
|
||||
}
|
||||
|
||||
AttachmentInfo attachment = new AttachmentInfo();
|
||||
attachment.StringID = Guid.NewGuid().ToString().ToUpper();
|
||||
attachment.FileName = uploadFile == null ? "" : uploadFile.FileName;
|
||||
attachment.Source = "WorkOrder";
|
||||
attachment.SourceID = woid;
|
||||
attachment.FileData = iconfilebyte;
|
||||
attachment.AddedByUserIID = session.User.UID;
|
||||
|
||||
string attid = CreateClient<AttachmentClient>().AddAttachmentLegacy(SystemParams.CompanyID, attachment);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object DeleteAttachment()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string attachid = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
|
||||
|
||||
CreateClient<AttachmentClient>().DeleteAttachmentLegacy(SystemParams.CompanyID, attachid, session.User.UID);
|
||||
return "OK";
|
||||
}
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private object GetAssetAttachments()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var assetid = Request.Form["ClientData"];
|
||||
AssetAttachmentInfo[] atts = CreateClient<AssetAttachmentProvider>().GetAttachments(SystemParams.CompanyID, Convert.ToInt64(assetid)).Where(m => m.VisibleOnWorkOrder == true).ToArray();
|
||||
if (atts == null || atts.Length <= 0)
|
||||
return new AssetAttachmentItem[0];
|
||||
|
||||
List<AssetAttachmentItem> list = new List<AssetAttachmentItem>();
|
||||
foreach (AssetAttachmentInfo att in atts)
|
||||
{
|
||||
AssetAttachmentItem item = new AssetAttachmentItem();
|
||||
Helper.CloneProperty(item, att);
|
||||
item.AddedOn = item.AddedOn.AddHours(SystemParams.GetHoursOffset());
|
||||
list.Add(item);
|
||||
}
|
||||
return list.OrderBy(m => m.AddedOn).ToArray();
|
||||
}
|
||||
else
|
||||
return new AssetAttachmentInfo[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Sned Email
|
||||
private object GetMachineContacts()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var assetid = Request.Form["ClientData"];
|
||||
return UserManagement.GetUsersByAssetID(session.SessionID, Convert.ToInt64(assetid), SystemParams.CompanyID);
|
||||
}
|
||||
else
|
||||
return new UserInfo[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object SendWorkOrder()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var woid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var address = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
var desc = HttpUtility.HtmlDecode(clientdata[2]);
|
||||
string[] emailaddress = JsonConvert.DeserializeObject<string[]>(address);
|
||||
|
||||
WorkOrderDetail wod = CreateClient<WorkOrderClient>().GetWorkOrderDetail(SystemParams.CompanyID, Convert.ToInt64(woid));
|
||||
WorkOrderDetailInfo wo = new WorkOrderDetailInfo();
|
||||
Helper.CloneProperty(wo, wod);
|
||||
SendMail(wo, emailaddress, desc, session.User);
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private void SendMail(WorkOrderDetailInfo wo, string[] emailaddress, string desc, Services.Users.UserInfoEx user)
|
||||
{
|
||||
if (emailaddress == null || emailaddress.Length == 0)
|
||||
return;
|
||||
|
||||
string Subject = "Work Order " + wo.ID;
|
||||
string Body = OrdinaryEmailFormat(wo, desc, user.ID);
|
||||
|
||||
CreateClient<AttachmentClient>().SendWorkOrderEmail(SystemParams.CompanyID, wo.ID, Subject, Body, emailaddress.ToArray(), user.UID);
|
||||
}
|
||||
|
||||
private string OrdinaryEmailFormat(WorkOrderDetailInfo wo, string desc, string userid)
|
||||
{
|
||||
string EmailFormat = "<table>";
|
||||
EmailFormat += "<tr><td><span>Details for work order <lable style=\"color:red;\"> <{3}> </lable> are listed below.To view or edit this work order,please click the below link:<br/></span><a href=\"{4}\">Link</a></td></tr>";
|
||||
EmailFormat += "<tr><td><span style=\"font-weight:bold;\">Message from: </span>{0}</td></tr>";
|
||||
EmailFormat += "<tr><td style=\"font-weight:700;\">Description: </td></tr>";
|
||||
EmailFormat += "<tr><td style=\"padding-left:30px;padding-right:20px;\">{1}</td></tr>";
|
||||
|
||||
EmailFormat += "<tr><td style=\"font-weight:700;\">Work Order Information: </td></tr>";
|
||||
EmailFormat += "<tr><td style=\"padding-left:30px;\">{2}</td></tr>";
|
||||
|
||||
EmailFormat += "</table>";
|
||||
|
||||
string absuri = Context.Request.Url.AbsoluteUri;
|
||||
string wourl = absuri.Substring(0, absuri.LastIndexOf("/Maintenance", StringComparison.OrdinalIgnoreCase));
|
||||
wourl = wourl + "/jump.aspx?p=" + Convert.ToBase64String(Encoding.UTF8.GetBytes("jt=woe;woid=" + wo.ID));
|
||||
|
||||
return string.Format(EmailFormat, userid, desc.Replace("\n", "<br>"), WorkOrderFormat(wo), wo.ID, wourl);
|
||||
}
|
||||
|
||||
public static string WorkOrderFormat(WorkOrderDetailInfo wo)
|
||||
{
|
||||
string EmailFormat = "<table>";
|
||||
EmailFormat += "<tr><td><span style=\"font-weight:700;\">Work Order Type: </span>{0}</td></tr>";
|
||||
EmailFormat += "<tr><td><span style=\"font-weight:700;\">Assigned To: </span>{1}</td></tr>";
|
||||
EmailFormat += "<tr><td><span style=\"font-weight:700;\">Status: </span>{2}</td></tr>";
|
||||
EmailFormat += "<tr><td><span style=\"font-weight:700;\">Due Date: </span>{3}</td></tr>";
|
||||
EmailFormat += "<tr><td><span style=\"font-weight:700;\">Description: </span>{4}</td></tr>";
|
||||
EmailFormat += "<tr><td><span style=\"font-weight:700;\">Meter Type: </span>{5}</td></tr>";
|
||||
if (string.Compare(wo.MeterType, "HourMeter", true) == 0 || string.Compare(wo.MeterType, "Both", true) == 0)
|
||||
EmailFormat += "<tr><td><span style=\"font-weight:700;\">Hour Meter: </span>{6}</td></tr>";
|
||||
if (string.Compare(wo.MeterType, "Odometer", true) == 0 || string.Compare(wo.MeterType, "Both", true) == 0)
|
||||
EmailFormat += "<tr><td><span style=\"font-weight:700;\">Odometer: </span>{7} {8}</td></tr>";
|
||||
EmailFormat += "<tr><td><span style=\"font-weight:700;\">Work Order Total Costs ($): </span>{9}</td></tr>";
|
||||
|
||||
EmailFormat += "<tr><td><span style=\"font-weight:700;\">Other Cost ($): </span>{19}</td></tr>";
|
||||
EmailFormat += "<tr><td><span style=\"font-weight:700;\">Parts Cost ($): </span>{14}</td></tr>";
|
||||
EmailFormat += "<tr><td><span style=\"font-weight:700;\">Travel Time Cost ($): </span>{15}</td></tr>";
|
||||
EmailFormat += "<tr><td><span style=\"font-weight:700;\">Labor Cost ($): </span>{16}</td></tr>";
|
||||
EmailFormat += "<tr><td><span style=\"font-weight:700;\">Hourly Rate: </span>{17}</td></tr>";
|
||||
|
||||
EmailFormat += "<tr><td><span style=\"font-weight:700;\">Time To Complete(Hrs): </span>{10}</td></tr>";
|
||||
EmailFormat += "<tr><td><span style=\"font-weight:700;\">Completed Date: </span>{11}</td></tr>";
|
||||
EmailFormat += "<tr><td><span style=\"font-weight:700;\">Internal ID: </span>{12}</td></tr>";
|
||||
|
||||
EmailFormat += "<tr><td><span style=\"font-weight:700;\">Invoice Number: </span>{18}</td></tr>";
|
||||
|
||||
EmailFormat += "<tr><td><span style=\"font-weight:700;\">Notes: </span>{13}</td></tr>";
|
||||
EmailFormat += "</table>";
|
||||
|
||||
string SendStr = string.Format(EmailFormat,
|
||||
HttpUtility.HtmlEncode(wo.WorkOrderType),
|
||||
HttpUtility.HtmlEncode(wo.AssignedToName),
|
||||
HttpUtility.HtmlEncode(wo.Status),
|
||||
HttpUtility.HtmlEncode(wo.DueDateStr),
|
||||
HttpUtility.HtmlEncode(wo.Description).Replace("\n", "<br>"),
|
||||
HttpUtility.HtmlEncode(wo.MeterType),
|
||||
HttpUtility.HtmlEncode(wo.HourMeter),
|
||||
HttpUtility.HtmlEncode(wo.Odometer),
|
||||
HttpUtility.HtmlEncode(wo.OdometerUnits),
|
||||
HttpUtility.HtmlEncode(wo.WorkOrderTotalCost),
|
||||
HttpUtility.HtmlEncode(wo.HoursToComplete),
|
||||
HttpUtility.HtmlEncode(wo.CompleteDateStr),
|
||||
HttpUtility.HtmlEncode(wo.InternalID),
|
||||
HttpUtility.HtmlEncode(wo.Notes).Replace("\n", "<br>"),
|
||||
HttpUtility.HtmlEncode(wo.PartsCost),
|
||||
HttpUtility.HtmlEncode(wo.TravelTimeCost),
|
||||
HttpUtility.HtmlEncode(wo.LaborCost),
|
||||
HttpUtility.HtmlEncode(wo.HourlyRate),
|
||||
HttpUtility.HtmlEncode(wo.InvoiceNumber),
|
||||
HttpUtility.HtmlEncode(wo.OtherCost));
|
||||
return SendStr;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private object GetInvoiceNumber()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var woid = Request.Form["ClientData"];
|
||||
return new WorkOrderManager(SystemParams.DataDbConnectionString).GetInvoiceNumber(woid);
|
||||
}
|
||||
else
|
||||
return new string[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class SegmentClient
|
||||
{
|
||||
public UserInfo[] Users { get; set; }
|
||||
public JobSiteViewItem[] JobSites { get; set; }
|
||||
}
|
||||
|
||||
public class WorkOrderQueryParams
|
||||
{
|
||||
public long AssetID { get; set; }
|
||||
public string SearchText { get; set; }
|
||||
public string[] Contacts { get; set; }
|
||||
public string[] Status { get; set; }
|
||||
public string[] AssetGroups { get; set; }
|
||||
public bool ShowMaintenance { get; set; }
|
||||
}
|
||||
|
||||
class WorkorderAlerts
|
||||
{
|
||||
public AlertInfo[] Alerts { get; set; }
|
||||
public AlertInfo[] AssetAlerts { get; set; }
|
||||
}
|
||||
}
|
698
IronIntelContractorSiteLib/MapView/MapViewHandler.cs
Normal file
698
IronIntelContractorSiteLib/MapView/MapViewHandler.cs
Normal file
@ -0,0 +1,698 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using Newtonsoft.Json;
|
||||
using IronIntel.Site;
|
||||
using IronIntel.Contractor.MapView;
|
||||
using IronIntel.Contractor.Users;
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Contractor.Contact;
|
||||
using Foresight.Fleet.Services.Attachment;
|
||||
using Foresight.Fleet.Services.JobSite;
|
||||
using Foresight.Fleet.Services.MapView;
|
||||
|
||||
namespace IronIntel.Contractor.Site.MapView
|
||||
{
|
||||
public class MapViewHandler : IronIntelHttpHandlerBase
|
||||
{
|
||||
public override string GetIronSystemServiceAddress()
|
||||
{
|
||||
return SystemParams.SystemServiceAddresses[0];
|
||||
}
|
||||
|
||||
public MapViewHandler(HttpContext context)
|
||||
: base(context)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ProcessRequest()
|
||||
{
|
||||
object result = "\"OK\"";
|
||||
string methidName = Context.Request.Params["MethodName"];
|
||||
try
|
||||
{
|
||||
switch (methidName)
|
||||
{
|
||||
case "GetAssets":
|
||||
result = GetAssets();
|
||||
break;
|
||||
case "GetAssetGroups":
|
||||
result = GetAssetGroups();
|
||||
break;
|
||||
case "GetContractors":
|
||||
result = GetContractors();
|
||||
break;
|
||||
case "GetHistoryLocation":
|
||||
result = GetHistoryLocation();
|
||||
break;
|
||||
case "GetJobSites":
|
||||
result = GetJobSites();
|
||||
break;
|
||||
case "GetCompanyLocations":
|
||||
result = GetCompanyLocations();
|
||||
break;
|
||||
case "GetMapAlertLayers":
|
||||
result = GetMapAlertLayers();
|
||||
break;
|
||||
case "GetUserParams":
|
||||
result = GetUserParams();
|
||||
break;
|
||||
case "SetUserParams":
|
||||
result = SetUserParams();
|
||||
break;
|
||||
case "GetServerVersion":
|
||||
result = GetServerVersion();
|
||||
break;
|
||||
case "GetMachineContacts":
|
||||
result = GetMachineContacts();
|
||||
break;
|
||||
case "SendLocation":
|
||||
result = SendLocation();
|
||||
break;
|
||||
case "SaveMapViewSearch":
|
||||
result = SaveMapViewSearch();
|
||||
break;
|
||||
case "DeleteMapViewSearch":
|
||||
result = DeleteMapViewSearch();
|
||||
break;
|
||||
case "GetShapeFileInfos":
|
||||
result = GetShapeFileInfos();
|
||||
break;
|
||||
case "GetShapeData":
|
||||
result = GetShapeData();
|
||||
break;
|
||||
case "ImportShape":
|
||||
result = ImportShape();
|
||||
break;
|
||||
case "UpdateShapeName":
|
||||
result = UpdateShapeName();
|
||||
break;
|
||||
case "DeleteShape":
|
||||
result = DeleteShape();
|
||||
break;
|
||||
case "GetAssetByID":
|
||||
result = GetAssetByID();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "MapViewHandler", ex.Message, ex.ToString());
|
||||
throw ex;
|
||||
}
|
||||
string json = JsonConvert.SerializeObject(result, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore });
|
||||
Context.Response.Write(json);
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
private string GetServerVersion()
|
||||
{
|
||||
string serverVersion = SystemParams.GetVersion();
|
||||
return serverVersion;
|
||||
}
|
||||
private AssetViewItem[] GetAssets()
|
||||
{
|
||||
AssetViewItem[] assets = null;
|
||||
if (LoginSession != null)
|
||||
{
|
||||
var clientdata = Context.Request.Params["ClientData"];
|
||||
|
||||
GetMachineParameterItem p = JsonConvert.DeserializeObject<GetMachineParameterItem>(clientdata);
|
||||
p.SearchText = HttpUtility.HtmlDecode(p.SearchText);
|
||||
|
||||
MachineAlertViewQueryParameter viewqueryparam = null;
|
||||
if (!string.IsNullOrWhiteSpace(p.ViewID))
|
||||
{
|
||||
viewqueryparam = ConvertToMachineAlertViewQueryParameter(p);
|
||||
}
|
||||
|
||||
assets = AssetMapViewManagement.GetAssets(LoginSession.SessionID, p.ContractorID, LoginSession.User.UID, p.SearchText, p.Onroad, viewqueryparam, !p.ExcludeNoLocation);
|
||||
SystemParams.WriteRefreshLog(LoginSession.User.UID, UserHostAddress, "Assets", p.IsAutoRefresh ? "Auto" : "Manual");
|
||||
}
|
||||
else
|
||||
assets = new AssetViewItem[0];
|
||||
|
||||
return assets;
|
||||
}
|
||||
|
||||
private AssetGroupViewItem[] GetAssetGroups()
|
||||
{
|
||||
AssetGroupViewItem[] groups = null;
|
||||
if (LoginSession != null)
|
||||
{
|
||||
var clientdata = Context.Request.Params["ClientData"];
|
||||
|
||||
GetMachineParameterItem p = JsonConvert.DeserializeObject<GetMachineParameterItem>(clientdata);
|
||||
p.SearchText = HttpUtility.HtmlDecode(p.SearchText);
|
||||
|
||||
string companyid = p.ContractorID;
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
|
||||
List<AssetGroupViewItem> temp = new List<AssetGroupViewItem>();
|
||||
groups = AssetMapViewManagement.GetAssetGroups(LoginSession.SessionID, companyid, LoginSession.User.UID, p.SearchText);
|
||||
temp.AddRange(groups);
|
||||
|
||||
AssetGroupViewItem eg = new AssetGroupViewItem() { ID = "-1", Name = "No Asset Group Assigned" };
|
||||
//eg.Assets = AssetMapViewManagement.GetNoGroupAssets(companyid);
|
||||
temp.Add(eg);
|
||||
groups = temp.ToArray();
|
||||
}
|
||||
else
|
||||
groups = new AssetGroupViewItem[0];
|
||||
|
||||
return groups;
|
||||
}
|
||||
|
||||
private MachineAlertViewQueryParameter ConvertToMachineAlertViewQueryParameter(GetMachineParameterItem machineparam)
|
||||
{
|
||||
MachineAlertViewQueryParameter viewqueryparam = new MachineAlertViewQueryParameter();
|
||||
viewqueryparam.ViewID = machineparam.ViewID;
|
||||
if (machineparam.Layers != null && machineparam.Layers.Length > 0)
|
||||
{
|
||||
List<MachineAlertLayerQueryParameter> layerlist = new List<MachineAlertLayerQueryParameter>();
|
||||
foreach (var la in machineparam.Layers)
|
||||
{
|
||||
MachineAlertLayerQueryParameter layer = new MachineAlertLayerQueryParameter();
|
||||
layer.LayerID = la.ID;
|
||||
if (la.Pivots != null && la.Pivots.Length > 0)
|
||||
{
|
||||
foreach (var pa in la.Pivots)
|
||||
{
|
||||
if (pa.IsCriteriaSQL)
|
||||
layer.CriteriaParameters.Add(pa.Name, pa.ParameterValue);
|
||||
else
|
||||
layer.AlertDescriptionParameters.Add(pa.Name, pa.ParameterValue);
|
||||
}
|
||||
}
|
||||
|
||||
layerlist.Add(layer);
|
||||
}
|
||||
viewqueryparam.Layers.AddRange(layerlist);
|
||||
}
|
||||
return viewqueryparam;
|
||||
|
||||
}
|
||||
|
||||
private AssetDetailViewItem GetAssetByID()
|
||||
{
|
||||
if (LoginSession != null)
|
||||
{
|
||||
var clientdata = Context.Request.Params["ClientData"];
|
||||
string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata);
|
||||
long assetid = 0;
|
||||
long.TryParse(ps[0], out assetid);
|
||||
|
||||
string companyid = ps[1];
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
|
||||
return AssetMapViewManagement.GetAssetDetailItem(LoginSession.SessionID, companyid, assetid);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private KeyValuePair<string, string>[] GetContractors()
|
||||
{
|
||||
KeyValuePair<string, string>[] result;
|
||||
if (LoginSession != null)
|
||||
{
|
||||
result = MapViewer.GetContractors(LoginSession.User.UID);
|
||||
result = result.OrderBy(kv => kv.Value).ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
result = new KeyValuePair<string, string>[0];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private AssetLocationHistoryViewItem GetHistoryLocation()
|
||||
{
|
||||
AssetLocationHistoryViewItem item = null;
|
||||
if (LoginSession != null)
|
||||
{
|
||||
string p = Context.Request.Params["ClientData"];
|
||||
string[] ps = p.Split(';');
|
||||
//if (ps.Length != 6) return item;
|
||||
DateTime dtFrom = DateTime.Now;
|
||||
DateTime dtTo = DateTime.Now;
|
||||
if (!DateTime.TryParse(ps[1], out dtFrom) || !DateTime.TryParse(ps[2], out dtTo))
|
||||
return item;
|
||||
string companyid = ps[3].Trim();//companyid
|
||||
bool notShow00loc = ps[4] == "1";
|
||||
string datasource = "";
|
||||
if (ps.Length > 5)
|
||||
datasource = ps[5];
|
||||
|
||||
item = AssetMapViewManagement.GetMachineLocationHistory(LoginSession.SessionID, ps[0], dtFrom, dtTo, companyid, notShow00loc, datasource);
|
||||
}
|
||||
else
|
||||
{
|
||||
item = new AssetLocationHistoryViewItem();
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
private JobSiteViewItem[] GetJobSites()
|
||||
{
|
||||
JobSiteViewItem[] items = null;
|
||||
if (LoginSession != null)
|
||||
{
|
||||
var clientdata = Context.Request.Params["ClientData"];
|
||||
|
||||
GetJobsiteParameterItem p = JsonConvert.DeserializeObject<GetJobsiteParameterItem>(clientdata);
|
||||
p.SearchText = HttpUtility.HtmlDecode(p.SearchText);
|
||||
|
||||
string companyid = p.ContractorID;
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
|
||||
items = AssetMapViewManagement.GetJobsites(LoginSession.SessionID, companyid, LoginSession.User.UID, p.SearchText);
|
||||
|
||||
|
||||
List<JobSiteViewItem> temp = new List<JobSiteViewItem>();
|
||||
items = AssetMapViewManagement.GetJobsites(LoginSession.SessionID, companyid, LoginSession.User.UID, p.SearchText);
|
||||
temp.AddRange(items);
|
||||
|
||||
JobSiteViewItem js = new JobSiteViewItem() { ID = -1, Name = "No Jobsite Assigned" };
|
||||
temp.Add(js);
|
||||
items = temp.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new JobSiteViewItem[0];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
private CompanyLocationViewItem[] GetCompanyLocations()
|
||||
{
|
||||
CompanyLocationViewItem[] items = null;
|
||||
if (LoginSession != null)
|
||||
{
|
||||
string p = Context.Request.Params["ClientData"];
|
||||
string companyid = p;
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
|
||||
var client = FleetServiceClientHelper.CreateClient<MapViewQueryClient>(companyid, LoginSession.SessionID);
|
||||
CustomerLocation[] locs = client.GetContractorAndDealerLocations(companyid);
|
||||
List<CompanyLocationViewItem> temps = new List<CompanyLocationViewItem>();
|
||||
foreach (var loc in locs)
|
||||
{
|
||||
CompanyLocationViewItem l = new CompanyLocationViewItem();
|
||||
l.ID = loc.ID;
|
||||
l.Latitude = loc.Latitude;
|
||||
l.Longitude = loc.Longitude;
|
||||
l.LocationName = loc.Name;
|
||||
l.Notes = loc.Notes;
|
||||
l.IconUrl = loc.IconUrl;
|
||||
temps.Add(l);
|
||||
}
|
||||
items = temps.ToArray();
|
||||
|
||||
//items = LocationManagement.GetCompanyLocations("");
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new CompanyLocationViewItem[0];
|
||||
}
|
||||
return items.ToArray();
|
||||
}
|
||||
|
||||
private MapAlertViewDefinitionItem[] GetMapAlertLayers()
|
||||
{
|
||||
MapAlertViewDefinitionItem[] items = null;
|
||||
if (LoginSession != null)
|
||||
{
|
||||
string p = Context.Request.Params["ClientData"];
|
||||
p = HttpUtility.HtmlDecode(p);
|
||||
int index = p.IndexOf(";");
|
||||
string companyid = p.Substring(0, index);
|
||||
string selectedViewID = p.Substring(index + 1);
|
||||
|
||||
items = AssetMapViewManagement.GetMapAlertViews(LoginSession.SessionID, companyid, selectedViewID);
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new MapAlertViewDefinitionItem[0];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
private UserParamInfo GetUserParams()
|
||||
{
|
||||
UserParamInfo up = new UserParamInfo();
|
||||
up.AutoRecenterMap = true;
|
||||
if (LoginSession != null)
|
||||
{
|
||||
up = UserParams.GetUserParams(LoginSession.SessionID, LoginSession.User.UID);
|
||||
}
|
||||
return up;
|
||||
}
|
||||
|
||||
private string SetUserParams()
|
||||
{
|
||||
if (LoginSession != null)
|
||||
{
|
||||
string p = Context.Request.Params["ClientData"];
|
||||
|
||||
UserParamInfo up = JsonConvert.DeserializeObject<UserParamInfo>(p);
|
||||
UserParams.SetUserParams(LoginSession.User.UID, up);
|
||||
}
|
||||
return "OK";
|
||||
}
|
||||
|
||||
private object SaveMapViewSearch()
|
||||
{
|
||||
if (LoginSession != null)
|
||||
{
|
||||
string data = Context.Request.Params["ClientData"];
|
||||
|
||||
MapViewSearchItem item = JsonConvert.DeserializeObject<MapViewSearchItem>(data);
|
||||
return UserParams.SaveMapViewSearch(LoginSession.SessionID, LoginSession.User.UID, item);
|
||||
}
|
||||
|
||||
return new MapViewSearchItem[0];
|
||||
}
|
||||
|
||||
private object DeleteMapViewSearch()
|
||||
{
|
||||
if (LoginSession != null)
|
||||
{
|
||||
string p = Context.Request.Params["ClientData"];
|
||||
p = HttpUtility.HtmlDecode(p);
|
||||
|
||||
return UserParams.DeleteMapViewSearch(LoginSession.SessionID, LoginSession.User.UID, p);
|
||||
}
|
||||
return new MapViewSearchItem[0];
|
||||
}
|
||||
|
||||
#region Send Location
|
||||
private UserInfo[] GetMachineContacts()
|
||||
{
|
||||
UserInfo[] items = null;
|
||||
if (LoginSession != null)
|
||||
{
|
||||
string p = Context.Request.Params["ClientData"];
|
||||
p = HttpUtility.HtmlDecode(p);
|
||||
int index = p.IndexOf(";");
|
||||
string contractorid = p.Substring(0, index);
|
||||
string assetid = p.Substring(index + 1);
|
||||
|
||||
items = UserManagement.GetUsersByAssetID(LoginSession.SessionID, Convert.ToInt64(assetid), contractorid);
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new UserInfo[0];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
private string SendLocation()
|
||||
{
|
||||
if (LoginSession != null)
|
||||
{
|
||||
string p = Context.Request.Params["ClientData"];
|
||||
p = HttpUtility.HtmlDecode(p);
|
||||
|
||||
SendLocationInfo si = JsonConvert.DeserializeObject<SendLocationInfo>(p);
|
||||
if (string.IsNullOrEmpty(si.CompanyID))
|
||||
si.CompanyID = SystemParams.CompanyID;
|
||||
|
||||
AssetDetailViewItem asset = AssetMapViewManagement.GetAssetDetailItem(LoginSession.SessionID, si.CompanyID, si.AssetID);
|
||||
SendMail(asset, si);
|
||||
}
|
||||
return "OK";
|
||||
}
|
||||
|
||||
private void SendMail(AssetDetailViewItem asset, SendLocationInfo si)
|
||||
{
|
||||
string[] emailaddress = si.EmailAddress;
|
||||
string[] textaddress = si.TextAddress;
|
||||
string Subject = "Location of Asset: " + asset.Name2 + " " + asset.Name + " " + asset.Make + " " + asset.Model + " " + asset.VIN + " " + (asset.MakeYear > 0 ? asset.MakeYear.ToString() : "");
|
||||
var useriid = LoginSession.User.UID;
|
||||
if (emailaddress != null && emailaddress.Length > 0)
|
||||
{
|
||||
string Body = OrdinaryEmailFormat(asset, si.Description);
|
||||
FleetServiceClientHelper.CreateClient<AttachmentClient>().SendAssetLoationEmail(si.CompanyID, si.AssetID, Subject, Body, emailaddress.ToArray(), useriid);
|
||||
}
|
||||
if (textaddress != null && textaddress.Length > 0)
|
||||
{
|
||||
string Body = OrdinaryTextFormat(asset, si.Description);
|
||||
Subject = "";//短信暂时不发Subject 8897反馈
|
||||
FleetServiceClientHelper.CreateClient<AttachmentClient>().SendAssetLoationEmail(si.CompanyID, si.AssetID, Subject, Body, textaddress.ToArray(), useriid);
|
||||
}
|
||||
}
|
||||
|
||||
private string OrdinaryEmailFormat(AssetDetailViewItem asset, string desc)
|
||||
{
|
||||
string EmailFormat = "Location of Asset: {0} {1} {2} {3} {4} {5}</br></br>";
|
||||
EmailFormat += "Description:</br>";
|
||||
EmailFormat += "{6}</br><br/>";
|
||||
EmailFormat += "Click the link below to view directions to this asset:</br>";
|
||||
EmailFormat += "<a href=\"{7}\">{7}</a>";
|
||||
if (asset.Location == null)
|
||||
asset.Location = new LocationViewItem();
|
||||
return string.Format(EmailFormat,
|
||||
HttpUtility.HtmlEncode(asset.Name2),
|
||||
HttpUtility.HtmlEncode(asset.Name),
|
||||
HttpUtility.HtmlEncode(asset.Make),
|
||||
HttpUtility.HtmlEncode(asset.Model),
|
||||
HttpUtility.HtmlEncode(asset.VIN),
|
||||
HttpUtility.HtmlEncode(asset.MakeYear > 0 ? asset.MakeYear.ToString() : ""),
|
||||
HttpUtility.HtmlEncode(desc ?? "").Replace("\n", "<br>"),
|
||||
"https://www.google.com/maps/dir/?api=1&destination=" + asset.Location.Latitude + "," + asset.Location.Longitude + "&travelmode=driving");
|
||||
}
|
||||
|
||||
private string OrdinaryTextFormat(AssetDetailViewItem asset, string desc)
|
||||
{
|
||||
string EmailFormat = "Location of Asset: {0} {1} {2} {3} {4} {5}</br></br>";
|
||||
EmailFormat += "Description:</br>";
|
||||
EmailFormat += "{6}</br><br/>";
|
||||
EmailFormat += "Click the link below to view directions to this asset:</br>";
|
||||
EmailFormat += "{7}";
|
||||
if (asset.Location == null)
|
||||
asset.Location = new LocationViewItem();
|
||||
return string.Format(EmailFormat,
|
||||
HttpUtility.HtmlEncode(asset.Name2),
|
||||
HttpUtility.HtmlEncode(asset.Name),
|
||||
HttpUtility.HtmlEncode(asset.Make),
|
||||
HttpUtility.HtmlEncode(asset.Model),
|
||||
HttpUtility.HtmlEncode(asset.VIN),
|
||||
HttpUtility.HtmlEncode(asset.MakeYear > 0 ? asset.MakeYear.ToString() : ""),
|
||||
HttpUtility.HtmlEncode(desc ?? "").Replace("\n", "<br>"),
|
||||
"https://www.google.com/maps/dir/?api=1&destination=" + asset.Location.Latitude + "," + asset.Location.Longitude + "&travelmode=driving");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Shape File
|
||||
private object GetShapeFileInfos()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (LoginSession != null)
|
||||
{
|
||||
string clientdata = HttpUtility.HtmlDecode(Context.Request.Params["ClientData"]);
|
||||
StringKeyValue kv = JsonConvert.DeserializeObject<StringKeyValue>(clientdata);
|
||||
string customerid = kv.Key;
|
||||
if (string.IsNullOrEmpty(customerid))
|
||||
customerid = SystemParams.CompanyID;
|
||||
|
||||
ShapeFileInfo[] files = FleetServiceClientHelper.CreateClient<ShapeFileProvider>(customerid, LoginSession.SessionID).GetShapeFileInfos(customerid, kv.Value);
|
||||
if (files == null || files.Length == 0)
|
||||
return new ShapeFileItem[0];
|
||||
|
||||
List<ShapeFileItem> list = new List<ShapeFileItem>();
|
||||
foreach (ShapeFileInfo fi in files)
|
||||
{
|
||||
ShapeFileItem item = new ShapeFileItem();
|
||||
Helper.CloneProperty(item, fi);
|
||||
list.Add(item);
|
||||
}
|
||||
return list.OrderBy(m => m.Name).ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ShapeFileItem[0];
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object ImportShape()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (LoginSession != null)
|
||||
{
|
||||
string clientdata = HttpUtility.HtmlDecode(Context.Request.Params["ClientData"]);
|
||||
StringKeyValue kv = JsonConvert.DeserializeObject<StringKeyValue>(clientdata);
|
||||
string customerid = kv.Key;
|
||||
if (string.IsNullOrEmpty(customerid))
|
||||
customerid = SystemParams.CompanyID;
|
||||
|
||||
HttpPostedFile uploadFile = null;
|
||||
byte[] iconfilebyte = null;
|
||||
if (Context.Request.Files.Count > 0)
|
||||
{
|
||||
uploadFile = Context.Request.Files[0];
|
||||
iconfilebyte = ConvertFile2bytes(uploadFile);
|
||||
}
|
||||
|
||||
FleetServiceClientHelper.CreateClient<ShapeFileProvider>(customerid, LoginSession.SessionID).ImportShape(customerid, kv.Value, kv.Tag1, LoginSession.User.UID, iconfilebyte);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetShapeData()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
string clientdata = HttpUtility.HtmlDecode(Context.Request.Params["ClientData"]);
|
||||
StringKeyValue kv = JsonConvert.DeserializeObject<StringKeyValue>(clientdata);
|
||||
string customerid = kv.Key;
|
||||
if (string.IsNullOrEmpty(customerid))
|
||||
customerid = SystemParams.CompanyID;
|
||||
|
||||
byte[] buffer = FleetServiceClientHelper.CreateClient<ShapeFileProvider>(customerid, LoginSession.SessionID).GetShapeData(customerid, Convert.ToInt64(kv.Value));
|
||||
Shape.Shape shape = new Shape.Shape();
|
||||
Shape.ShapeFileParser.ParseFromShapeFile(buffer, shape);
|
||||
Shape.SimpleShape ss = new Shape.SimpleShape();
|
||||
ss.FromShapeObj(shape);
|
||||
|
||||
return ss;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object UpdateShapeName()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (LoginSession != null)
|
||||
{
|
||||
var clientdata = Context.Request.Form["ClientData"].Split((char)170);
|
||||
var customerid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var data = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
ShapeFileItem shape = JsonConvert.DeserializeObject<ShapeFileItem>(data);
|
||||
if (string.IsNullOrEmpty(customerid))
|
||||
customerid = SystemParams.CompanyID;
|
||||
|
||||
FleetServiceClientHelper.CreateClient<ShapeFileProvider>(customerid, LoginSession.SessionID).UpdateShapeName(customerid, shape.ID, shape.Name, shape.Notes);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private object DeleteShape()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (LoginSession != null)
|
||||
{
|
||||
string clientdata = HttpUtility.HtmlDecode(Context.Request.Params["ClientData"]);
|
||||
StringKeyValue kv = JsonConvert.DeserializeObject<StringKeyValue>(clientdata);
|
||||
string customerid = kv.Key;
|
||||
if (string.IsNullOrEmpty(customerid))
|
||||
customerid = SystemParams.CompanyID;
|
||||
|
||||
FleetServiceClientHelper.CreateClient<ShapeFileProvider>(customerid, LoginSession.SessionID).DeleteShape(customerid, Convert.ToInt64(kv.Value), LoginSession.User.UID);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] ConvertFile2bytes(HttpPostedFile uploadFile)
|
||||
{
|
||||
byte[] dataBuffer = new byte[uploadFile.InputStream.Length];
|
||||
uploadFile.InputStream.Position = 0;
|
||||
uploadFile.InputStream.Read(dataBuffer, 0, dataBuffer.Length);
|
||||
uploadFile.InputStream.Close();
|
||||
return dataBuffer;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public class SendLocationInfo
|
||||
{
|
||||
public string CompanyID { get; set; }
|
||||
public long AssetID { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string[] EmailAddress { get; set; }
|
||||
public string[] TextAddress { get; set; }
|
||||
}
|
||||
|
||||
public class GetMachineParameterItem
|
||||
{
|
||||
public bool IsAutoRefresh { get; set; }
|
||||
public string ViewID { get; set; }
|
||||
public string ContractorID { get; set; }
|
||||
public int Onroad { get; set; }
|
||||
public string SearchText { get; set; }
|
||||
public MapAlertLayerDefinitionItem[] Layers { get; set; }
|
||||
public string MachineIDs { get; set; }
|
||||
public bool ExcludeNoLocation { get; set; }
|
||||
}
|
||||
|
||||
public class GetJobsiteParameterItem
|
||||
{
|
||||
public bool IsAutoRefresh { get; set; }
|
||||
public string ContractorID { get; set; }
|
||||
public int Onroad { get; set; }
|
||||
public string SearchText { get; set; }
|
||||
}
|
||||
|
||||
public class MachineQueryResult
|
||||
{
|
||||
public MachineViewItem[] Machines { get; set; }
|
||||
public AssetGroupViewItem[] Groups { get; set; }
|
||||
}
|
||||
public class MapViewSearchClient
|
||||
{
|
||||
public string SearchName { get; set; }
|
||||
public bool IsDefault { get; set; }
|
||||
public int Type { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
19
IronIntelContractorSiteLib/MapViewBasePage.cs
Normal file
19
IronIntelContractorSiteLib/MapViewBasePage.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using IronIntel.Services;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace IronIntel.Contractor.Site
|
||||
{
|
||||
public class MapViewBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
162
IronIntelContractorSiteLib/OTRConfig/OTRConfigBasePage.cs
Normal file
162
IronIntelContractorSiteLib/OTRConfig/OTRConfigBasePage.cs
Normal file
@ -0,0 +1,162 @@
|
||||
using Foresight.Fleet.Services.OTRConfig;
|
||||
using IronIntel.Contractor.OTRConfig;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace IronIntel.Contractor.Site.OTRConfig
|
||||
{
|
||||
public class OTRConfigBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest(string method)
|
||||
{
|
||||
object result = null;
|
||||
try
|
||||
{
|
||||
string methodName = Request.Params["MethodName"];
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName.ToUpper())
|
||||
{
|
||||
case "GETSPEEDINGEVENTS":
|
||||
result = GetSpeedingEvents();
|
||||
break;
|
||||
case "EXCLUDEDSPEEDINGEVENTS":
|
||||
result = ExcludedSpeedingEvents();
|
||||
break;
|
||||
case "GETHARSHDRIVINGEVENTS":
|
||||
result = GetHarshDrivingEvents();
|
||||
break;
|
||||
case "EXCLUDEDHARSHDRIVINGEVENTS":
|
||||
result = ExcludedHarshDrivingEvents();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "OTRConfigBasePage", ex.Message, ex.ToString());
|
||||
throw ex;
|
||||
}
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
#region Speeding
|
||||
|
||||
private object GetSpeedingEvents()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var sdatestr = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var edatestr = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
List<SpeedingItem> list = new List<SpeedingItem>();
|
||||
return list.ToArray(); ;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "OTRConfigBasePage.GetSpeedingList", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object ExcludedSpeedingEvents()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var id = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var notes = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message; ;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Harsh Driving
|
||||
|
||||
private object GetHarshDrivingEvents()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var sdatestr = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var edatestr = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
var searchtxt = HttpUtility.HtmlDecode(clientdata[2]);
|
||||
|
||||
DateTime startdate = DateTime.MinValue;
|
||||
DateTime enddate = DateTime.MaxValue;
|
||||
if (!DateTime.TryParse(sdatestr, out startdate))
|
||||
startdate = DateTime.MinValue;
|
||||
if (!DateTime.TryParse(edatestr, out enddate))
|
||||
enddate = DateTime.MaxValue;
|
||||
else
|
||||
enddate = enddate.Date.AddDays(1).AddSeconds(-1);
|
||||
|
||||
double timeOffset = SystemParams.GetHoursOffset();
|
||||
startdate = startdate.AddHours(-timeOffset);
|
||||
enddate = enddate.AddHours(-timeOffset);
|
||||
|
||||
return HarshDrivingManagement.GetHarshDrivingEvents(session.SessionID, startdate, enddate, searchtxt, session.User.UID);
|
||||
}
|
||||
|
||||
return new HarshDrivingItem[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "OTRConfigBasePage.GetHarshDrivingEvents", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object ExcludedHarshDrivingEvents()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
|
||||
HarshDrivintClient hd = JsonConvert.DeserializeObject<HarshDrivintClient>(clientdata);
|
||||
|
||||
HarshDrivingManagement.ExcludedHarshDrivingEvents(session.SessionID, hd, session.User.UID);
|
||||
return "OK";
|
||||
}
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message; ;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
48
IronIntelContractorSiteLib/PrintBasePage.cs
Normal file
48
IronIntelContractorSiteLib/PrintBasePage.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using Foresight.Fleet.Services.AssetHealth;
|
||||
using IronIntel.Contractor.FilterQ;
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.Site
|
||||
{
|
||||
public class PrintBasePage : ContractorBasePage
|
||||
{
|
||||
protected string ProcessRequest()
|
||||
{
|
||||
int printType = -1;
|
||||
string pt = Request.Params["pt"];
|
||||
if (!int.TryParse(pt, out printType))
|
||||
return "";
|
||||
|
||||
string result = "";
|
||||
switch (printType)
|
||||
{
|
||||
case (int)PrintType.WorkOrder:
|
||||
result = PrintWorkOrder();
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private string PrintWorkOrder()
|
||||
{
|
||||
string woidstr = Request.Params["wo"];
|
||||
long woid = -1;
|
||||
if (!long.TryParse(woidstr, out woid) || woid <= 0)
|
||||
return "";
|
||||
|
||||
return WorkOrderManager.GenerateWorkOrderPrintHtml(GetCurrentLoginSession().SessionID, SystemParams.CompanyID, woid);
|
||||
}
|
||||
|
||||
protected enum PrintType
|
||||
{
|
||||
WorkOrder = 1
|
||||
}
|
||||
}
|
||||
}
|
36
IronIntelContractorSiteLib/Properties/AssemblyInfo.cs
Normal file
36
IronIntelContractorSiteLib/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("IronIntelContractorSiteLib")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Foresight Intelligence")]
|
||||
[assembly: AssemblyProduct("IronIntelContractorSiteLib")]
|
||||
[assembly: AssemblyCopyright("Copyright © Foresight Intelligence 2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("9d398985-9424-4fc7-a637-6b5b204d8f7c")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("2.20.429")]
|
619
IronIntelContractorSiteLib/Security/CurfewBasePage.cs
Normal file
619
IronIntelContractorSiteLib/Security/CurfewBasePage.cs
Normal file
@ -0,0 +1,619 @@
|
||||
using Foresight.Data;
|
||||
using Foresight.Fleet.Services.AssetHealth;
|
||||
using Foresight.Fleet.Services.JobSite;
|
||||
using Foresight.Fleet.Services.SystemOption;
|
||||
using IronIntel.Contractor.JobSites;
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
using IronIntel.Contractor.MapView;
|
||||
using IronIntel.Contractor.Security;
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services.Customers;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Security
|
||||
{
|
||||
public class CurfewBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
object result = null;
|
||||
try
|
||||
{
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName)
|
||||
{
|
||||
case "GetCurfews":
|
||||
result = GetCurfews();
|
||||
break;
|
||||
case "GetCurfewInfo":
|
||||
result = GetCurfewInfo();
|
||||
break;
|
||||
case "SaveCurfew":
|
||||
result = SaveCurfew();
|
||||
break;
|
||||
case "GetUsers":
|
||||
result = GetUsers();
|
||||
break;
|
||||
case "DeleteCurfew":
|
||||
result = DeleteCurfew();
|
||||
break;
|
||||
case "GetSelectedMachines":
|
||||
result = GetSelectedMachines();
|
||||
break;
|
||||
case "SaveCurfewMachines":
|
||||
result = SaveCurfewMachines();
|
||||
break;
|
||||
case "GetSelectedAssets":
|
||||
result = GetSelectedAssets();
|
||||
break;
|
||||
case "AssignAssetsToUser":
|
||||
result = AssignAssetsToUser();
|
||||
break;
|
||||
case "RemoveAssignedAssetsFromUser":
|
||||
result = RemoveAssignedAssetsFromUser();
|
||||
break;
|
||||
case "GetJobsiteList":
|
||||
result = GetJobsiteList();
|
||||
break;
|
||||
case "GetSelectedJobsites":
|
||||
result = GetSelectedJobsites();
|
||||
break;
|
||||
case "SaveCurfewJobsites":
|
||||
result = SaveCurfewJobsites();
|
||||
break;
|
||||
case "GetMachineList":
|
||||
result = GetMachineList();
|
||||
break;
|
||||
case "GetCurfewMovementTolerance":
|
||||
result = GetCurfewMovementTolerance();
|
||||
break;
|
||||
case "UpdateCurfewMovementTolerance":
|
||||
result = UpdateCurfewMovementTolerance();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "CurfewBasePage", ex.Message, ex.ToString());
|
||||
throw ex;
|
||||
}
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private object GetCurfews()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
CurfewInfo[] items = null;
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var contractorid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var searchtext = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
FISqlConnection contractordb = null;
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(contractorid);
|
||||
contractordb = new FISqlConnection(connetionstring);
|
||||
}
|
||||
|
||||
items = CurfewManagement.GetCurfews(session.SessionID, searchtext, contractordb);
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new CurfewInfo[0];
|
||||
}
|
||||
return items.OrderBy(m => m.Title);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private object GetCurfewInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var contractorid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var curfewid = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
FISqlConnection contractordb = null;
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(contractorid);
|
||||
contractordb = new FISqlConnection(connetionstring);
|
||||
}
|
||||
|
||||
return CurfewManagement.GetCurfewInfo(curfewid, contractordb);
|
||||
}
|
||||
else
|
||||
return new CurfewInfo();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private object SaveCurfew()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var contractorid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var data = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
var ci = JsonConvert.DeserializeObject<CurfewInfo>(data);
|
||||
if (string.IsNullOrWhiteSpace(ci.CurfewID))
|
||||
{
|
||||
ci.CurfewID = Guid.NewGuid().ToString();
|
||||
}
|
||||
|
||||
FISqlConnection contractordb = null;
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(contractorid);
|
||||
contractordb = new FISqlConnection(connetionstring);
|
||||
}
|
||||
|
||||
CurfewManagement.SaveCurfew(ci, GetCurrentLoginSession().User.UID, contractordb);
|
||||
|
||||
return new string[] { ci.CurfewID, "OK" };
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetUsers()
|
||||
{
|
||||
try
|
||||
{
|
||||
UserInfo[] items = null;
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
items = UserManagement.GetUsers();
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new UserInfo[0];
|
||||
}
|
||||
return items.OrderBy(m => m.ID);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string DeleteCurfew()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var contractorid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var curfewid = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
FISqlConnection contractordb = null;
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(contractorid);
|
||||
contractordb = new FISqlConnection(connetionstring);
|
||||
}
|
||||
|
||||
CurfewManagement.DeleteCurfew(curfewid, contractordb);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private MaintenanceMachineInfo[] GetSelectedMachines()
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var contractorid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var curfewid = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
FISqlConnection contractordb = null;
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(contractorid);
|
||||
contractordb = new FISqlConnection(connetionstring);
|
||||
}
|
||||
|
||||
var machines = CurfewManagement.GetCurfewMachinesByID(curfewid, contractordb);
|
||||
|
||||
return machines.OrderBy(m => m.VIN).ToArray();
|
||||
}
|
||||
|
||||
private string SaveCurfewMachines()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var contractorid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var curfewid = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
var machineids = HttpUtility.HtmlDecode(clientdata[2]);
|
||||
if (string.IsNullOrWhiteSpace(contractorid))
|
||||
contractorid = SystemParams.CompanyID;
|
||||
|
||||
string[] ids = JsonConvert.DeserializeObject<string[]>(machineids);
|
||||
|
||||
FISqlConnection contractordb = null;
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(contractorid);
|
||||
contractordb = new FISqlConnection(connetionstring);
|
||||
}
|
||||
CurfewManagement.SaveCurfewMachines(curfewid, contractorid, ids, contractordb);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object[] GetSelectedAssets()
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var companyId = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
if (string.IsNullOrEmpty(companyId))
|
||||
{
|
||||
companyId = SystemParams.CompanyID;
|
||||
}
|
||||
var uid = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
var machines = CreateClient<CurfewClient>(companyId).GetAssetsAssignedToCurfew(companyId, uid);
|
||||
|
||||
return machines.OrderBy(m => m.VIN).Select(m => new
|
||||
{
|
||||
ID = m.Id,
|
||||
Name = string.IsNullOrEmpty(m.Name2) ? m.Name : m.Name2,
|
||||
m.VIN,
|
||||
m.MakeName,
|
||||
m.ModelName,
|
||||
m.TypeName
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
private string AssignAssetsToUser()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var companyId = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
if (string.IsNullOrEmpty(companyId))
|
||||
{
|
||||
companyId = SystemParams.CompanyID;
|
||||
}
|
||||
var uid = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
var machineids = HttpUtility.HtmlDecode(clientdata[2]);
|
||||
|
||||
var ids = JsonConvert.DeserializeObject<long[]>(machineids);
|
||||
|
||||
CreateClient<CurfewClient>(companyId).AssignAssetsToCurfew(companyId, uid, ids, session.User.UID);
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string RemoveAssignedAssetsFromUser()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var companyId = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
if (string.IsNullOrEmpty(companyId))
|
||||
{
|
||||
companyId = SystemParams.CompanyID;
|
||||
}
|
||||
var uid = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
var machineids = HttpUtility.HtmlDecode(clientdata[2]);
|
||||
|
||||
var ids = JsonConvert.DeserializeObject<long[]>(machineids);
|
||||
|
||||
CreateClient<CurfewClient>(companyId).RemoveAssetsFromCurfew(companyId, uid, ids, session.User.UID);
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private MaintenanceMachineInfo[] GetMachineList()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
string contractorid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
string type = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
string searchtxt = HttpUtility.HtmlDecode(clientdata[2]);
|
||||
|
||||
int typeid = 0;
|
||||
int.TryParse(type, out typeid);
|
||||
|
||||
FISqlConnection contractordb = null;
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(contractorid);
|
||||
contractordb = new FISqlConnection(connetionstring);
|
||||
}
|
||||
|
||||
var machines = MaintenanceManagement.GetMaintenanceMachines(session.SessionID, typeid, searchtxt, session.User.UID, contractorid)
|
||||
.OrderBy(m => m.VIN)
|
||||
.ToArray();
|
||||
|
||||
return machines;
|
||||
}
|
||||
|
||||
private object GetJobsiteList()
|
||||
{
|
||||
try
|
||||
{
|
||||
JobSiteViewItem[] items = null;
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
string contractorid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
string searchtxt = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
FISqlConnection contractordb = null;
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(contractorid);
|
||||
contractordb = new FISqlConnection(connetionstring);
|
||||
}
|
||||
|
||||
var jss = CreateClient<JobSiteProvider>(contractorid).GetJobSiteItems(contractorid, "", false);
|
||||
List<JobSiteViewItem> list = new List<JobSiteViewItem>();
|
||||
foreach (var js in jss)
|
||||
{
|
||||
JobSiteViewItem item = new JobSiteViewItem();
|
||||
item.ID = js.ID;
|
||||
item.Name = js.Name;
|
||||
|
||||
list.Add(item);
|
||||
}
|
||||
items = list.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new JobSiteViewItem[0];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private object GetSelectedJobsites()
|
||||
{
|
||||
try
|
||||
{
|
||||
JobSiteViewItem[] items = null;
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var contractorid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var curfewid = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
FISqlConnection contractordb = null;
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(contractorid);
|
||||
contractordb = new FISqlConnection(connetionstring);
|
||||
}
|
||||
|
||||
items = CurfewManagement.GetCurfewJobsitesByID(curfewid, contractordb);
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new JobSiteViewItem[0];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string SaveCurfewJobsites()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var contractorid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var curfewid = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
var jobsiteids = HttpUtility.HtmlDecode(clientdata[2]);
|
||||
if (string.IsNullOrWhiteSpace(contractorid))
|
||||
contractorid = SystemParams.CompanyID;
|
||||
|
||||
string[] ids = JsonConvert.DeserializeObject<string[]>(jobsiteids);
|
||||
|
||||
FISqlConnection contractordb = null;
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(contractorid);
|
||||
contractordb = new FISqlConnection(connetionstring);
|
||||
}
|
||||
|
||||
CurfewManagement.SaveCurfewJobsites(curfewid, contractorid, ids, contractordb);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Curfew Movement Tolerance
|
||||
|
||||
private object GetCurfewMovementTolerance()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
CurfewMovementTolerance tolerance = CreateClient<SystemOptionProvider>().GetCurfewMovementTolerance(SystemParams.CompanyID);
|
||||
if (tolerance == null)
|
||||
{
|
||||
return new CurfewMovementToleranceInfo();
|
||||
}
|
||||
|
||||
CurfewMovementToleranceInfo toleranceinfo = new CurfewMovementToleranceInfo();
|
||||
toleranceinfo.DefaultTolerance = tolerance.DefaultTolerance;
|
||||
if (tolerance.JobSites != null && tolerance.JobSites.Count > 0)
|
||||
{
|
||||
toleranceinfo.JobSites = new List<JobSiteCurfewMovementToleranceInfo>();
|
||||
foreach (var js in tolerance.JobSites)
|
||||
{
|
||||
JobSiteCurfewMovementToleranceInfo jsi = new JobSiteCurfewMovementToleranceInfo();
|
||||
Helper.CloneProperty(jsi, js);
|
||||
toleranceinfo.JobSites.Add(jsi);
|
||||
}
|
||||
}
|
||||
|
||||
return toleranceinfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new CurfewMovementToleranceInfo();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private string UpdateCurfewMovementTolerance()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
clientdata = HttpUtility.HtmlDecode(clientdata);
|
||||
|
||||
CurfewMovementToleranceInfo toleranceinfo = JsonConvert.DeserializeObject<CurfewMovementToleranceInfo>(clientdata);
|
||||
|
||||
CurfewMovementTolerance tolerance = new CurfewMovementTolerance();
|
||||
tolerance.DefaultTolerance = toleranceinfo.DefaultTolerance;
|
||||
foreach (JobSiteCurfewMovementToleranceInfo jsi in toleranceinfo.JobSites)
|
||||
{
|
||||
JobSiteCurfewMovementTolerance js = new JobSiteCurfewMovementTolerance();
|
||||
Helper.CloneProperty(js, jsi);
|
||||
tolerance.JobSites.Add(js);
|
||||
}
|
||||
|
||||
CreateClient<SystemOptionProvider>().UpdateCurfewMovementTolerance(SystemParams.CompanyID, tolerance, session.User.UID);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
using IronIntel.Contractor.Users;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Security
|
||||
{
|
||||
public class DataTablePermissionBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
object result = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName.ToUpper())
|
||||
{
|
||||
case "GETUSERS":
|
||||
result = GetUsers();
|
||||
break;
|
||||
case "GETUSERGROUPS":
|
||||
result = GetUserGroups();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result = ex.Message;
|
||||
SystemParams.WriteLog("Error", "UserGroupBasePage.ProcessRequest", ex.Message, ex.ToString());
|
||||
}
|
||||
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// check whether you are admin.
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session == null || session.User == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var ui = UserManagement.GetUserByIID(session.User.UID);
|
||||
return ui != null && ui.UserType >= UserTypes.Admin;
|
||||
}
|
||||
|
||||
protected override bool ThrowIfNotAllowed { get { return true; } }
|
||||
|
||||
private UserInfo[] GetUsers()
|
||||
{
|
||||
var users = UserManagement.GetUnmanagementUsers().OrderBy(u => u.DisplayName).ToArray();
|
||||
return users;
|
||||
}
|
||||
|
||||
private UserGroupInfo[] GetUserGroups()
|
||||
{
|
||||
var groups = UserManagement.GetGroups();
|
||||
return groups;
|
||||
}
|
||||
}
|
||||
}
|
651
IronIntelContractorSiteLib/Security/FilterBasePage.cs
Normal file
651
IronIntelContractorSiteLib/Security/FilterBasePage.cs
Normal file
@ -0,0 +1,651 @@
|
||||
using FI.FIC.Contracts.DataObjects.BLObject;
|
||||
using FI.FIC.Models;
|
||||
using IronIntel.Contractor.Users;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Security
|
||||
{
|
||||
public class FilterBasePage : ContractorBasePage
|
||||
{
|
||||
private const string sqlIn = "In";
|
||||
private const string isnull = "Is Null";
|
||||
private const string isnotnull = "Is Not Null";
|
||||
private const string defaultLanageCode = "en-us";
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
object result = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName.ToUpper())
|
||||
{
|
||||
case "GETFILTEROBJECT":
|
||||
result = GetFilterObject();
|
||||
break;
|
||||
case "SAVEFILTER":
|
||||
result = SaveFilter();
|
||||
break;
|
||||
case "GETDATASOURCE":
|
||||
result = GetDataSource();
|
||||
break;
|
||||
case "GETTABLEFILTERS":
|
||||
result = GetTableFilters();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result = ex.Message;
|
||||
SystemParams.WriteLog("Error", "FilterBasePage.ProcessRequest", ex.Message, ex.ToString());
|
||||
}
|
||||
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// check whether you are admin.
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session == null || session.User == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var ui = UserManagement.GetUserByIID(session.User.UID);
|
||||
return ui != null && ui.UserType >= UserTypes.Admin;
|
||||
}
|
||||
|
||||
protected override bool ThrowIfNotAllowed { get { return true; } }
|
||||
|
||||
private FilterObject GetFilterObject()
|
||||
{
|
||||
var p = Request.Form["ClientData"];
|
||||
p = HttpUtility.HtmlDecode(p);
|
||||
int index = p.IndexOf(";");
|
||||
string iid = p.Substring(0, index);
|
||||
string type = p.Substring(index + 1);//1为Group 2为User
|
||||
|
||||
GlobalFilterAuthorize[] globalFilters = null;
|
||||
List<DataTableInfo> tableList = null;
|
||||
TableFilterAuthorize[] tableFilters = null;
|
||||
List<FI.FIC.Contracts.DataObjects.BaseObject.Plugin> pluginList = PluginManager.GetPlugin();
|
||||
if (type == "1")
|
||||
{
|
||||
globalFilters = GlobalFilterManager.GetGlobalFilterAuthorizeForGroup(iid);
|
||||
tableList = DataTableManager.GetHaveTableFilterDataTableListForUserGroup(iid, defaultLanageCode);
|
||||
if (tableList != null && tableList.Count > 0)
|
||||
{
|
||||
tableFilters = GlobalFilterManager.GetTableFilterAuthorizeForGroup(iid, tableList[0].IID);
|
||||
}
|
||||
}
|
||||
else if (type == "2")
|
||||
{
|
||||
globalFilters = GlobalFilterManager.GetGlobalFilterAuthorizeForUser(iid);
|
||||
tableList = DataTableManager.GetHaveTableFilterDataTableList(iid, defaultLanageCode);
|
||||
if (tableList != null && tableList.Count > 0)
|
||||
{
|
||||
tableFilters = GlobalFilterManager.GetTableFilterAuthorizeForUser(iid, tableList[0].IID);
|
||||
}
|
||||
}
|
||||
|
||||
FilterObject filterObj = new FilterObject();
|
||||
|
||||
if (globalFilters != null)
|
||||
{
|
||||
List<Filter> gfs = new List<Filter>();
|
||||
foreach (var item in globalFilters)
|
||||
{
|
||||
Filter gf = new Filter();
|
||||
gf.FilterName = item.FilterName;
|
||||
gf.FilterCondition = item.FilterCondition ?? " ";
|
||||
gf.FilterDataType = (int)item.FilterDataType;
|
||||
gf.FilterType = (int)item.FilterType;
|
||||
if (gf.FilterType == 0)
|
||||
gf.FilterTypeString = "Single Value";
|
||||
else
|
||||
gf.FilterTypeString = getPluginName(item.PluginID, pluginList);
|
||||
gf.FilterValue = item.FilterValue;
|
||||
gf.IID = item.IID;
|
||||
gf.PluginID = item.PluginID;
|
||||
|
||||
gfs.Add(gf);
|
||||
}
|
||||
filterObj.GlobalFilters = gfs.ToArray();
|
||||
}
|
||||
|
||||
if (tableList != null)
|
||||
{
|
||||
List<KeyValuePair<string, string>> dts = new List<KeyValuePair<string, string>>();
|
||||
foreach (var item in tableList)
|
||||
{
|
||||
KeyValuePair<string, string> kv = new KeyValuePair<string, string>(item.IID, item.DataTableName);
|
||||
dts.Add(kv);
|
||||
}
|
||||
filterObj.DataTableList = dts.ToArray();
|
||||
}
|
||||
|
||||
if (tableFilters != null)
|
||||
{
|
||||
List<Filter> tfs = new List<Filter>();
|
||||
foreach (var item in tableFilters)
|
||||
{
|
||||
Filter tf = new Filter();
|
||||
tf.FieldName = item.FieldName;
|
||||
tf.FilterName = item.FilterName;
|
||||
tf.FilterCondition = item.FilterCondition ?? " ";
|
||||
tf.FilterDataType = (int)item.FilterDataType;
|
||||
tf.FilterType = (int)item.FilterType;
|
||||
if (tf.FilterType == 0)
|
||||
tf.FilterTypeString = "Single Value";
|
||||
else
|
||||
tf.FilterTypeString = getPluginName(item.PluginID, pluginList);
|
||||
tf.FilterValue = item.FilterValue;
|
||||
tf.IID = item.IID;
|
||||
tf.PluginID = item.PluginID;
|
||||
|
||||
tfs.Add(tf);
|
||||
}
|
||||
filterObj.FirstTableFilters = tfs.ToArray();
|
||||
}
|
||||
|
||||
return filterObj;
|
||||
}
|
||||
|
||||
private string getPluginName(string iid, List<FI.FIC.Contracts.DataObjects.BaseObject.Plugin> pluginList)
|
||||
{
|
||||
string result = "";
|
||||
if (pluginList != null)
|
||||
{
|
||||
var plugin = pluginList.FirstOrDefault((p) => p.IID.Equals(iid, StringComparison.OrdinalIgnoreCase));
|
||||
if (plugin != null)
|
||||
result = plugin.PluginName;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private object SaveFilter()
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var s = Request.Form["ClientData"];
|
||||
s = HttpUtility.HtmlDecode(s);
|
||||
SaveFilterObject item = JsonConvert.DeserializeObject<SaveFilterObject>(s);
|
||||
|
||||
if (item.Type == 2)
|
||||
{
|
||||
var user = UserManagement.GetUserByIID(item.UserIID);
|
||||
if (user.UserType == UserTypes.Admin)//Admin用户不需要修改
|
||||
return "\"OK\"";
|
||||
}
|
||||
string error = "";
|
||||
if (!Validate(ref error, item))
|
||||
{
|
||||
return new ErrorObject() { ErrorCode = 1, ErrorMessage = error };
|
||||
}
|
||||
DoSaveFilter(item);
|
||||
return "\"OK\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "\"Failed\"";
|
||||
}
|
||||
}
|
||||
|
||||
private void DoSaveFilter(SaveFilterObject filterObject)
|
||||
{
|
||||
List<GlobalFilterAuthorize> globalFilter = new List<GlobalFilterAuthorize>();
|
||||
if (filterObject.GlobalFilter != null)
|
||||
{
|
||||
foreach (var item in filterObject.GlobalFilter)
|
||||
{
|
||||
GlobalFilterAuthorize gf = new GlobalFilterAuthorize();
|
||||
gf.FilterName = item.FilterName;
|
||||
gf.FilterCondition = item.FilterCondition;
|
||||
gf.FilterDataType = (FI.FIC.Contracts.DataObjects.Enumeration.DBDataType)item.FilterDataType;
|
||||
gf.FilterType = (FI.FIC.Contracts.DataObjects.Enumeration.FilterType)item.FilterType;
|
||||
gf.FilterValue = item.FilterValue;
|
||||
gf.IID = item.IID;
|
||||
gf.PluginID = item.PluginID;
|
||||
|
||||
globalFilter.Add(gf);
|
||||
}
|
||||
}
|
||||
|
||||
List<TableFilterAuthorize> tableFilter = new List<TableFilterAuthorize>();
|
||||
if (filterObject.TableFilters != null)
|
||||
{
|
||||
foreach (var tfobj in filterObject.TableFilters)
|
||||
{
|
||||
foreach (var item in tfobj.Filters)
|
||||
{
|
||||
TableFilterAuthorize tf = new TableFilterAuthorize();
|
||||
tf.FilterName = item.FilterName;
|
||||
tf.FilterCondition = item.FilterCondition;
|
||||
tf.FilterDataType = (FI.FIC.Contracts.DataObjects.Enumeration.DBDataType)item.FilterDataType;
|
||||
tf.FilterType = (FI.FIC.Contracts.DataObjects.Enumeration.FilterType)item.FilterType;
|
||||
tf.FilterValue = item.FilterValue;
|
||||
tf.IID = item.IID;
|
||||
tf.PluginID = item.PluginID;
|
||||
|
||||
tableFilter.Add(tf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (filterObject.Type == 1)//1为Group,2为User
|
||||
{
|
||||
GlobalFilterManager.SaveGlobalFilterAuthorizeForGroup(filterObject.UserIID, globalFilter.ToArray(), tableFilter.ToArray());
|
||||
}
|
||||
else if (filterObject.Type == 2)
|
||||
{
|
||||
GlobalFilterManager.SaveGlobalFilterAuthorizeForUser(filterObject.UserIID, globalFilter.ToArray(), tableFilter.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
private DataSourceObject GetDataSource()
|
||||
{
|
||||
DataSourceObject result = new DataSourceObject();
|
||||
var s = Request.Form["ClientData"];
|
||||
string dsiid = HttpUtility.HtmlDecode(s);
|
||||
PluginStructure dsStructure = PluginManager.GetPluginStructure(dsiid);
|
||||
PluginManager pm = new PluginManager();
|
||||
DataTable dt = pm.GetSourceData(dsiid, null);
|
||||
|
||||
int indexOfName = dt.Columns.IndexOf(dsStructure.DataImport.DisplayField);
|
||||
int indexOfID = dt.Columns.IndexOf(dsStructure.DataImport.ValueField);
|
||||
int indexOfPID = dt.Columns.IndexOf(dsStructure.DataImport.ParentField);
|
||||
if (indexOfName < 0)
|
||||
indexOfName = dt.Columns.IndexOf("Name");
|
||||
if (indexOfID < 0)
|
||||
indexOfID = dt.Columns.IndexOf("ID");
|
||||
if (indexOfPID < 0)
|
||||
indexOfPID = dt.Columns.IndexOf("PID");
|
||||
|
||||
result.IID = dsStructure.IID;
|
||||
result.IsFlat = dsStructure.IsFlat == 1;
|
||||
if (!result.IsFlat)
|
||||
result.IsFlat = IsFlat(dt, indexOfPID);
|
||||
result.Name = dsStructure.PluginName;
|
||||
result.DisplayField = dsStructure.DataImport.DisplayField;
|
||||
result.ValueField = dsStructure.DataImport.ValueField;
|
||||
|
||||
List<DataSourceData> datas = new List<DataSourceData>();
|
||||
if (result.IsFlat)
|
||||
{
|
||||
foreach (DataRow dr in dt.Select("", dt.Columns[indexOfID].ColumnName + " asc"))
|
||||
{
|
||||
DataSourceData ds = new DataSourceData();
|
||||
ds.ID = dr[indexOfID].ToString();
|
||||
ds.Description = dr[indexOfName].ToString();
|
||||
if (indexOfPID >= 0)
|
||||
ds.PID = dr[indexOfPID].ToString();
|
||||
datas.Add(ds);
|
||||
}
|
||||
//datas = datas.OrderBy((d) => d.ID).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
Dictionary<string, DataSourceData> nodes = new Dictionary<string, DataSourceData>();
|
||||
foreach (DataRow dr in dt.Select("", dt.Columns[indexOfID].ColumnName + " asc"))
|
||||
{
|
||||
DataSourceData ds = new DataSourceData();
|
||||
ds.ID = dr[indexOfID].ToString();
|
||||
ds.Description = dr[indexOfName].ToString();
|
||||
if (indexOfPID >= 0)
|
||||
ds.PID = dr[indexOfPID].ToString();
|
||||
//if (nodes.ContainsKey(ds.PID))
|
||||
//{
|
||||
// DataSourceData pnode = nodes[ds.PID];
|
||||
// List<DataSourceData> subNodes = new List<DataSourceData>();
|
||||
// if (pnode.SubData != null)
|
||||
// subNodes.AddRange(pnode.SubData);
|
||||
// subNodes.Add(ds);
|
||||
// pnode.SubData = subNodes.ToArray();
|
||||
//}
|
||||
nodes[ds.ID] = ds;
|
||||
}
|
||||
|
||||
foreach (var kv in nodes)
|
||||
{
|
||||
if (nodes.ContainsKey(kv.Value.PID))
|
||||
{
|
||||
DataSourceData pnode = nodes[kv.Value.PID];
|
||||
List<DataSourceData> subNodes = new List<DataSourceData>();
|
||||
if (pnode.SubData != null)
|
||||
subNodes.AddRange(pnode.SubData);
|
||||
subNodes.Add(kv.Value);
|
||||
pnode.SubData = subNodes.ToArray();
|
||||
}
|
||||
else
|
||||
datas.Add(kv.Value);
|
||||
}
|
||||
}
|
||||
result.Data = datas.ToArray();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private Filter[] GetTableFilters()
|
||||
{
|
||||
var p = Request.Form["ClientData"];
|
||||
p = HttpUtility.HtmlDecode(p);
|
||||
int index = p.IndexOf(";");
|
||||
string iid = p.Substring(0, index);
|
||||
int index1 = p.IndexOf(";", index + 1);
|
||||
string type = p.Substring(index + 1, index1 - index - 1);//1为Group 2为User
|
||||
string dtiid = p.Substring(index1 + 1);
|
||||
|
||||
TableFilterAuthorize[] tableFilters = null;
|
||||
List<FI.FIC.Contracts.DataObjects.BaseObject.Plugin> pluginList = PluginManager.GetPlugin();
|
||||
if (type == "1")
|
||||
{
|
||||
tableFilters = GlobalFilterManager.GetTableFilterAuthorizeForGroup(iid, dtiid);
|
||||
}
|
||||
else if (type == "2")
|
||||
{
|
||||
tableFilters = GlobalFilterManager.GetTableFilterAuthorizeForUser(iid, dtiid);
|
||||
}
|
||||
|
||||
List<Filter> filters = new List<Filter>();
|
||||
|
||||
if (tableFilters != null)
|
||||
{
|
||||
foreach (var item in tableFilters)
|
||||
{
|
||||
Filter tf = new Filter();
|
||||
tf.FieldName = item.FieldName;
|
||||
tf.FilterName = item.FilterName;
|
||||
tf.FilterCondition = item.FilterCondition ?? " ";
|
||||
tf.FilterDataType = (int)item.FilterDataType;
|
||||
tf.FilterType = (int)item.FilterType;
|
||||
if (tf.FilterType == 0)
|
||||
tf.FilterTypeString = "Single Value";
|
||||
else
|
||||
tf.FilterTypeString = getPluginName(item.PluginID, pluginList);
|
||||
tf.FilterValue = item.FilterValue;
|
||||
tf.IID = item.IID;
|
||||
tf.PluginID = item.PluginID;
|
||||
|
||||
filters.Add(tf);
|
||||
}
|
||||
}
|
||||
return filters.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断数据源的数据是否是树形结构
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private bool IsFlat(DataTable dt, int pidIndex)
|
||||
{
|
||||
if (pidIndex < 0) return true;
|
||||
|
||||
List<string> ids = new List<string>();
|
||||
List<string> pids = new List<string>();
|
||||
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
string id = dr[pidIndex].ToString();
|
||||
if (pids.IndexOf(id) >= 0)
|
||||
return false;
|
||||
|
||||
string pid = dr[pidIndex].ToString();
|
||||
if (ids.IndexOf(pid) >= 0)
|
||||
return false;
|
||||
|
||||
ids.Add(id);
|
||||
pids.Add(pid);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool Validate(ref string error, SaveFilterObject FilterObj)
|
||||
{
|
||||
string msg = "";
|
||||
if (FilterObj.GlobalFilter != null && FilterObj.GlobalFilter.Length > 0)
|
||||
{
|
||||
Filter errorObj = null;
|
||||
if (!ValidateFilter(ref msg, FilterObj.GlobalFilter, out errorObj))
|
||||
{
|
||||
//string TableFilterError = CommonHelper.GetLangauge("LHBIS.FIC.Client.Modules.FilterManagement.A016") + "\n";
|
||||
error = "Filter '{0}' in global filter:" + "\n";
|
||||
error = string.Format(error, errorObj.FilterName);
|
||||
error = error + msg;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (FilterObj.TableFilters != null && FilterObj.TableFilters.Length > 0)
|
||||
{
|
||||
foreach (var tf in FilterObj.TableFilters)
|
||||
{
|
||||
Filter errorObj = null;
|
||||
if (!ValidateFilter(ref msg, tf.Filters, out errorObj))
|
||||
{
|
||||
//string TableFilterError = CommonHelper.GetLangauge("LHBIS.FIC.Client.Modules.FilterManagement.A017") + "\n";
|
||||
error = "Filter '{0}' in the data Table '{1}':" + "\n";
|
||||
error = string.Format(error, errorObj.FilterName, tf.TableName);
|
||||
error = error + msg;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ValidateFilter(ref string error, Filter[] Filters, out Filter errorObj)
|
||||
{
|
||||
errorObj = null;
|
||||
for (int i = 0; i < Filters.Length; i++)
|
||||
{
|
||||
Filter item = Filters[i];
|
||||
if (!string.IsNullOrWhiteSpace(item.FilterCondition))
|
||||
{
|
||||
if ((item.FilterCondition == isnull) || (item.FilterCondition == isnotnull))
|
||||
{
|
||||
item.FilterValue = "";
|
||||
}
|
||||
else if (item.FilterCondition != sqlIn)
|
||||
{
|
||||
bool returnValue = true;
|
||||
switch (item.FilterDataType)
|
||||
{
|
||||
case (int)FI.FIC.Contracts.DataObjects.Enumeration.DBDataType.dtBoolean:
|
||||
try
|
||||
{
|
||||
bool.Parse(item.FilterValue);
|
||||
}
|
||||
catch
|
||||
{
|
||||
error = "The Filter value must be True/False.";// CommonHelper.GetLangauge("LHBIS.FIC.Client.Modules.FilterManagement.A012");
|
||||
returnValue = false;
|
||||
}
|
||||
break;
|
||||
case (int)FI.FIC.Contracts.DataObjects.Enumeration.DBDataType.dtDate:
|
||||
try
|
||||
{
|
||||
//必须要满足(月日年)或(年月日)的格式
|
||||
DateTime t = DateTime.Now;
|
||||
try
|
||||
{
|
||||
t = DateTime.Parse(item.FilterValue, new System.Globalization.DateTimeFormatInfo());
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
string tFilterValue = item.FilterValue.Replace(".", "-").Replace("/", "-");
|
||||
if (!tFilterValue.StartsWith(t.ToString("MM-dd-yyyy"))
|
||||
&& !tFilterValue.StartsWith(t.ToString("MM-d-yyyy"))
|
||||
&& !tFilterValue.StartsWith(t.ToString("M-dd-yyyy"))
|
||||
&& !tFilterValue.StartsWith(t.ToString("M-d-yyyy"))
|
||||
&& !tFilterValue.StartsWith(t.ToString("yyyy-MM-dd"))
|
||||
&& !tFilterValue.StartsWith(t.ToString("yyyy-MM-d"))
|
||||
&& !tFilterValue.StartsWith(t.ToString("yyyy-M-dd"))
|
||||
&& !tFilterValue.StartsWith(t.ToString("yyyy-M-d")))
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
error = "The Filter value must be a date.";// CommonHelper.GetLangauge("LHBIS.FIC.Client.Modules.FilterManagement.A013");
|
||||
error += " " + "Date format must be 'MM/dd/yyyy' or 'yyyy-MM-dd'";// CommonHelper.GetLangauge("LHBIS.FIC.Client.Wizard.ChartWizardHelper.A286");
|
||||
returnValue = false;
|
||||
}
|
||||
break;
|
||||
case (int)FI.FIC.Contracts.DataObjects.Enumeration.DBDataType.dtFloat:
|
||||
try
|
||||
{
|
||||
float.Parse(item.FilterValue);
|
||||
}
|
||||
catch
|
||||
{
|
||||
error = "The Filter value must be a floating point.";//CommonHelper.GetLangauge("LHBIS.FIC.Client.Modules.FilterManagement.A014");
|
||||
returnValue = false;
|
||||
}
|
||||
break;
|
||||
case (int)FI.FIC.Contracts.DataObjects.Enumeration.DBDataType.dtInteger:
|
||||
try
|
||||
{
|
||||
int.Parse(item.FilterValue);
|
||||
}
|
||||
catch
|
||||
{
|
||||
error = "The Filter Value must be an integer.";// CommonHelper.GetLangauge("LHBIS.FIC.Client.Modules.FilterManagement.A015");
|
||||
returnValue = false;
|
||||
}
|
||||
break;
|
||||
case (int)FI.FIC.Contracts.DataObjects.Enumeration.DBDataType.dtGuid:
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(item.FilterValue))
|
||||
item.FilterValue = Guid.Empty.ToString();
|
||||
else
|
||||
new Guid(item.FilterValue);
|
||||
}
|
||||
catch
|
||||
{
|
||||
error = "The Filter Value must be a GUID.";// CommonHelper.GetLangauge("LHBIS.FIC.Client.Modules.FilterManagement.A018");
|
||||
returnValue = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (returnValue == false)
|
||||
{
|
||||
errorObj = item;
|
||||
return returnValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.FilterValue.Length > 2000)
|
||||
{
|
||||
errorObj = item;
|
||||
error = "The length of the Filter Value must be less than 2000.";// 没有资源号
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#region Model
|
||||
public class Filter
|
||||
{
|
||||
public string IID { get; set; }
|
||||
public string FilterName { get; set; }
|
||||
public int FilterType { get; set; }
|
||||
public string FilterTypeString { get; set; }
|
||||
public string FieldName { get; set; }
|
||||
public int FilterDataType { get; set; }
|
||||
public string FilterDataTypeString
|
||||
{
|
||||
get
|
||||
{
|
||||
string dataType = Enum.GetName(typeof(FI.FIC.Contracts.DataObjects.Enumeration.DBDataType), FilterDataType);
|
||||
if (dataType == null) return null;
|
||||
if (dataType.StartsWith("dt"))
|
||||
{
|
||||
return dataType.Substring(2, dataType.Length - 2);
|
||||
}
|
||||
return dataType;
|
||||
}
|
||||
}
|
||||
public string FilterCondition { get; set; }
|
||||
public string FilterValue { get; set; }
|
||||
public string PluginID { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 包含Global Filter, DataTable List和第一个DataTable的Filter
|
||||
/// </summary>
|
||||
public class FilterObject
|
||||
{
|
||||
public Filter[] GlobalFilters { get; set; }
|
||||
|
||||
public KeyValuePair<string, string>[] DataTableList { get; set; }//IID/Name
|
||||
|
||||
public Filter[] FirstTableFilters { get; set; }//第一个DataTable的Filter
|
||||
}
|
||||
|
||||
public class TableFilterObject
|
||||
{
|
||||
public string TableIID { get; set; }
|
||||
public string TableName { get; set; }
|
||||
public Filter[] Filters { get; set; }
|
||||
}
|
||||
|
||||
public class SaveFilterObject
|
||||
{
|
||||
public string UserIID { get; set; }//用户或用户组的IID
|
||||
public int Type { get; set; }//1
|
||||
public Filter[] GlobalFilter { get; set; }
|
||||
public TableFilterObject[] TableFilters { get; set; }
|
||||
}
|
||||
public class DataSourceObject
|
||||
{
|
||||
public string IID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool IsFlat { get; set; }
|
||||
|
||||
public string DisplayField { get; set; }
|
||||
public string ValueField { get; set; }
|
||||
|
||||
|
||||
public DataSourceData[] Data { get; set; }
|
||||
}
|
||||
|
||||
public class DataSourceData
|
||||
{
|
||||
public string ID { get; set; }
|
||||
public string PID { get; set; }
|
||||
public string Description { get; set; }
|
||||
public DataSourceData[] SubData { get; set; }
|
||||
}
|
||||
|
||||
public class ErrorObject
|
||||
{
|
||||
public int ErrorCode { get; set; }
|
||||
public string ErrorMessage { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
252
IronIntelContractorSiteLib/Security/JobsiteLimitBasepage.cs
Normal file
252
IronIntelContractorSiteLib/Security/JobsiteLimitBasepage.cs
Normal file
@ -0,0 +1,252 @@
|
||||
using Foresight.Data;
|
||||
using Foresight.Fleet.Services.JobSite;
|
||||
using IronIntel.Contractor.Security;
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using IronIntel.Services.Customers;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Security
|
||||
{
|
||||
public class JobsiteLimitBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
object result = null;
|
||||
try
|
||||
{
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName)
|
||||
{
|
||||
case "GetJobsiteLimits":
|
||||
result = GetJobsiteLimits();
|
||||
break;
|
||||
case "SaveJobsiteLimit":
|
||||
result = SaveJobsiteLimit();
|
||||
break;
|
||||
case "DeleteJobsiteLimit":
|
||||
result = DeleteJobsiteLimit();
|
||||
break;
|
||||
case "GetContactList":
|
||||
result = GetContactList();
|
||||
break;
|
||||
case "GetSelectedContacts":
|
||||
result = GetSelectedContacts();
|
||||
break;
|
||||
case "SaveSubscribeContacts":
|
||||
result = SaveSubscribeContacts();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "CurfewBasePage", ex.Message, ex.ToString());
|
||||
throw ex;
|
||||
}
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private object GetJobsiteLimits()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var contractorid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var searchtext = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
|
||||
JobSiteLimitItem[] items = CreateClient<JobSiteProvider>(contractorid).GetJobSiteLimitItems(contractorid, searchtext);
|
||||
if (items == null || items.Length == 0)
|
||||
return new JobsiteLimitInfo[0];
|
||||
|
||||
MachineType[] alltypes = Machines.MachineManagement.GetMachineTypes();
|
||||
List<JobsiteLimitInfo> list = new List<JobsiteLimitInfo>();
|
||||
foreach (JobSiteLimitItem item in items)
|
||||
{
|
||||
JobsiteLimitInfo jl = new JobsiteLimitInfo();
|
||||
Helper.CloneProperty(jl, item);
|
||||
string[] typeids = jl.AssetTypes.Split(',');
|
||||
if (typeids != null)
|
||||
{
|
||||
foreach (string tyid in typeids)
|
||||
{
|
||||
MachineType type = alltypes.FirstOrDefault(m => m.ID == Convert.ToInt32(tyid));
|
||||
if (type != null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(jl.AssetTypeNames))
|
||||
jl.AssetTypeNames = type.Name;
|
||||
else
|
||||
jl.AssetTypeNames += "," + type.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(searchtext))
|
||||
{
|
||||
if (Helper.Contains(jl.JobSiteName, searchtext) || Helper.Contains(jl.AssetTypeNames, searchtext) || Helper.Contains(jl.Notes, searchtext))
|
||||
list.Add(jl);
|
||||
}
|
||||
else
|
||||
list.Add(jl);
|
||||
}
|
||||
|
||||
return list.OrderBy(m => m.ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new JobsiteLimitInfo[0];
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object SaveJobsiteLimit()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var contractorid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var data = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
var jl = JsonConvert.DeserializeObject<JobsiteLimitInfo>(data);
|
||||
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
|
||||
JobSiteLimitItem item = new JobSiteLimitItem();
|
||||
Helper.CloneProperty(item, jl);
|
||||
var client = CreateClient<JobSiteProvider>(contractorid);
|
||||
jl.ID = client.SaveJobSiteLimit(contractorid, item, session.User.UID);
|
||||
|
||||
if (jl.Active)
|
||||
client.CheckOverUnderTruckingAlert(contractorid, jl.JobSiteID);
|
||||
|
||||
return new string[] { jl.ID.ToString(), "OK" };
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string DeleteJobsiteLimit()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var contractorid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var idstr = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
long id = Convert.ToInt64(idstr);
|
||||
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
|
||||
CreateClient<JobSiteProvider>(contractorid).DeleteJobSiteLimit(contractorid, id, string.Empty, session.User.UID);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private UserInfo[] GetContactList()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
UserInfo[] users = null;
|
||||
if (session != null)
|
||||
{
|
||||
//contact = ContactManagement.GetContacts();
|
||||
users = UserManagement.GetActiveUsers(session.SessionID);
|
||||
users = users.OrderBy(u => u.DisplayName).ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
users = new UserInfo[0];
|
||||
}
|
||||
return users;
|
||||
}
|
||||
private object GetSelectedContacts()
|
||||
{
|
||||
try
|
||||
{
|
||||
UserInfo[] items = null;
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
long id = Convert.ToInt64(clientdata);
|
||||
|
||||
items = JobsiteLimitManagement.GetSubscribeContacts(id);
|
||||
items = items.OrderBy(u => u.DisplayName).ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new UserInfo[0];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object SaveSubscribeContacts()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var jlid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var contactids = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
string[] ids = JsonConvert.DeserializeObject<string[]>(contactids);
|
||||
|
||||
JobsiteLimitManagement.SaveSubscribeContacts(jlid, ids);
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
63
IronIntelContractorSiteLib/Security/SecurityBasePage.cs
Normal file
63
IronIntelContractorSiteLib/Security/SecurityBasePage.cs
Normal file
@ -0,0 +1,63 @@
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Security
|
||||
{
|
||||
public class SecurityBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
object result = null;
|
||||
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName.ToUpper())
|
||||
{
|
||||
case "GETNAVS":
|
||||
result = GetNavigations();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private SecurityNavigateItem[] GetNavigations()
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
List<SecurityNavigateItem> list = Acl.GetSecurityNavigateItems(user).ToList();
|
||||
LicenseInfo license = SystemParams.GetLicense();
|
||||
if (license != null && license.Items.Count > 0)
|
||||
{
|
||||
LicenseItem li = license.Items.FirstOrDefault(m => m.Key == "CurfewConfiguration");
|
||||
if (li == null || !Helper.IsTrue(li.Value))
|
||||
{
|
||||
SecurityNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_curfew");
|
||||
if (item != null)
|
||||
list.Remove(item);
|
||||
item = list.FirstOrDefault(m => m.ID == "nav_curfewmt");
|
||||
if (item != null)
|
||||
list.Remove(item);
|
||||
}
|
||||
|
||||
if (user.UserType != UserTypes.SupperAdmin)
|
||||
{
|
||||
SecurityNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_curfewmt");
|
||||
if (item != null)
|
||||
list.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
155
IronIntelContractorSiteLib/Security/UserGroupBasePage.cs
Normal file
155
IronIntelContractorSiteLib/Security/UserGroupBasePage.cs
Normal file
@ -0,0 +1,155 @@
|
||||
using IronIntel.Contractor.Users;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Security
|
||||
{
|
||||
public class UserGroupBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
object result = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName.ToUpper())
|
||||
{
|
||||
case "GETGROUPS":
|
||||
result = GetGroups();
|
||||
break;
|
||||
case "GETGROUPINFO":
|
||||
result = GetGroupInfo();
|
||||
break;
|
||||
case "SAVEGROUP":
|
||||
result = SaveGroup();
|
||||
break;
|
||||
case "DELETEGROUP":
|
||||
result = DeleteGroup();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result = ex.Message;
|
||||
SystemParams.WriteLog("Error", "UserGroupBasePage.ProcessRequest", ex.Message, ex.ToString());
|
||||
}
|
||||
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// check whether you are admin.
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session == null || session.User == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var ui = UserManagement.GetUserByIID(session.User.UID);
|
||||
return ui != null && ui.UserType >= UserTypes.Admin;
|
||||
}
|
||||
|
||||
protected override bool ThrowIfNotAllowed { get { return true; } }
|
||||
|
||||
public UserGroupInfo[] GetGroups()
|
||||
{
|
||||
var groups = UserManagement.GetGroups().ToArray();
|
||||
return groups;
|
||||
}
|
||||
|
||||
public GroupDetail GetGroupInfo()
|
||||
{
|
||||
var iid = Request.Form["ClientData"];
|
||||
UserGroupInfo group;
|
||||
if (string.IsNullOrEmpty(iid))
|
||||
{
|
||||
group = new UserGroupInfo();
|
||||
}
|
||||
else
|
||||
{
|
||||
Guid guid;
|
||||
if (!Guid.TryParse(iid, out guid))
|
||||
{
|
||||
throw new ArgumentException("Group ID is not valid.");
|
||||
}
|
||||
|
||||
// 返回带 Users 数据的详细用户组对象
|
||||
group = UserManagement.GetGroup(guid.ToString());
|
||||
}
|
||||
var users = UserManagement.GetUsers().OrderBy(u => u.ID).ToArray();
|
||||
|
||||
return new GroupDetail
|
||||
{
|
||||
GroupInfo = group,
|
||||
Users = users
|
||||
};
|
||||
}
|
||||
|
||||
public string SaveGroup()
|
||||
{
|
||||
var content = Request.Form["ClientData"];
|
||||
content = HttpUtility.HtmlDecode(content);
|
||||
var item = JsonConvert.DeserializeObject<UserGroupInfo>(content);
|
||||
|
||||
// 保存组基本信息,与包含的全部用户
|
||||
if (string.IsNullOrWhiteSpace(item.Name))
|
||||
{
|
||||
throw new ArgumentException("Group Name cannot be empty.");
|
||||
}
|
||||
item.Name = item.Name.Trim();
|
||||
if (string.IsNullOrEmpty(item.ID))
|
||||
{
|
||||
// add
|
||||
item.ID = Guid.NewGuid().ToString();
|
||||
UserManagement.AddGroup(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
UserManagement.UpdateGroup(item);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public string DeleteGroup()
|
||||
{
|
||||
var iid = Request.Form["ClientData"];
|
||||
Guid guid;
|
||||
if (!Guid.TryParse(iid, out guid))
|
||||
{
|
||||
throw new ArgumentException("Group ID is not valid.");
|
||||
}
|
||||
try
|
||||
{
|
||||
UserManagement.DeleteGroup(guid.ToString());
|
||||
return "";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("Error", "DeleteGroup", ex.Message, ex.ToString());
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class GroupDetail
|
||||
{
|
||||
public UserGroupInfo GroupInfo { get; set; }
|
||||
public UserInfo[] Users { get; set; }
|
||||
}
|
||||
}
|
98
IronIntelContractorSiteLib/Security/UserToContractorPage.cs
Normal file
98
IronIntelContractorSiteLib/Security/UserToContractorPage.cs
Normal file
@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using IronIntel.Contractor.Users;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Security
|
||||
{
|
||||
public class UserToContractorPage : ContractorBasePage
|
||||
{
|
||||
public const char splitChar = (char)170;
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName.ToUpper())
|
||||
{
|
||||
case "GETUSERS":
|
||||
GetUsers();
|
||||
break;
|
||||
case "GETGROUPS":
|
||||
GetGroups();
|
||||
break;
|
||||
case "GETCONTRACTORS":
|
||||
GetContractors();
|
||||
break;
|
||||
case "SAVECONTRACTOR":
|
||||
SaveContractor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
Response.End();
|
||||
}
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// check whether you are admin.
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session == null || session.User == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var ui = UserManagement.GetUserByIID(session.User.UID);
|
||||
return ui != null && ui.UserType >= UserTypes.Admin;
|
||||
}
|
||||
|
||||
private void GetUsers()
|
||||
{
|
||||
string json = "";
|
||||
var users = UserManagement.GetUnmanagementUsers().OrderBy(u => u.DisplayName).ToArray();
|
||||
json = JsonConvert.SerializeObject(users);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private void GetGroups()
|
||||
{
|
||||
string json = "";
|
||||
var groups = UserManagement.GetGroups().OrderBy(u => u.Name).ToArray();
|
||||
json = JsonConvert.SerializeObject(groups);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
private void GetContractors()
|
||||
{
|
||||
string iid = Request.Params["uiid"] == null ? string.Empty : Request.Params["uiid"];
|
||||
int flag = Int32.Parse(Request.Params["Flag"]);
|
||||
string json = "";
|
||||
UserToContractorInfo[] contractors = UserManagement.GetContractorsByIId(iid, flag);
|
||||
var cntractrssort = contractors.OrderBy(c => c.Name).ToArray();
|
||||
json = JsonConvert.SerializeObject(cntractrssort);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
private void SaveContractor()
|
||||
{
|
||||
string iid = Request.Params["id"];
|
||||
string contractorstr = Request.Params["contractors"];
|
||||
string[] contractors = JsonConvert.DeserializeObject<string[]>(contractorstr);
|
||||
for (int i = 0; i < contractors.Length; i++)
|
||||
{
|
||||
contractors[i] = HttpUtility.UrlDecode(contractors[i]);
|
||||
}
|
||||
UserManagement.AddUserToContractor(iid, contractors);
|
||||
Response.Write("Save contractors info successfully.");
|
||||
Response.End();
|
||||
}
|
||||
}
|
||||
}
|
383
IronIntelContractorSiteLib/SingleAssetViewBasePage.cs
Normal file
383
IronIntelContractorSiteLib/SingleAssetViewBasePage.cs
Normal file
@ -0,0 +1,383 @@
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using IronIntel.Contractor.Machines;
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace IronIntel.Contractor.Site
|
||||
{
|
||||
public class SingleAssetViewBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest(string method)
|
||||
{
|
||||
object result = null;
|
||||
try
|
||||
{
|
||||
string methodName = Request.Params["MethodName"];
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName.ToUpper())
|
||||
{
|
||||
case "GETASSETDETAILINFO":
|
||||
result = GetAssetDetailInfo();
|
||||
break;
|
||||
case "GETPMINFO":
|
||||
result = GetPMInfo();
|
||||
break;
|
||||
case "GETASSETRENTAL":
|
||||
result = GetAssetRental();
|
||||
break;
|
||||
case "GETASSETDETAILWORKSPACECONFIG":
|
||||
result = GetAssetDetailWorkspaceConfig();
|
||||
break;
|
||||
case "GETASSETONOFFTIMELINE":
|
||||
result = GetAssetOnOffTimeline();
|
||||
break;
|
||||
case "ISCALAMPPRIMARYLOCATION":
|
||||
result = IsCalampPrimaryLocation();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "SingleAssetViewBasePage", ex.Message, ex.ToString());
|
||||
throw ex;
|
||||
}
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private object GetAssetDetailInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var custid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var assetidstr = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
long assetid = -1;
|
||||
long.TryParse(assetidstr, out assetid);
|
||||
if (string.IsNullOrWhiteSpace(custid))
|
||||
custid = SystemParams.CompanyID;
|
||||
|
||||
AssetDetailInfo info = CreateClient<AssetQueryClient>(custid).GetAssetDetailInfo(custid, assetid);
|
||||
|
||||
AssetDetailItem assetdetail = new AssetDetailItem();
|
||||
Helper.CloneProperty(assetdetail, info);
|
||||
if (info.CurrentLocation != null)
|
||||
{
|
||||
assetdetail.CurrentLocation = new AssetAddressItem();
|
||||
Helper.CloneProperty(assetdetail.CurrentLocation, info.CurrentLocation);
|
||||
}
|
||||
if (info.CurrentHours != null)
|
||||
{
|
||||
assetdetail.CurrentHours = new AssetEngineHoursItem();
|
||||
Helper.CloneProperty(assetdetail.CurrentHours, info.CurrentHours);
|
||||
}
|
||||
if (info.CurrentIdleHours != null)
|
||||
{
|
||||
assetdetail.CurrentIdleHours = new AssetIdlehoursItem();
|
||||
Helper.CloneProperty(assetdetail.CurrentIdleHours, info.CurrentIdleHours);
|
||||
}
|
||||
if (info.CurrentOdometer != null)
|
||||
{
|
||||
assetdetail.CurrentOdometer = new AssetOdometerItem();
|
||||
Helper.CloneProperty(assetdetail.CurrentOdometer, info.CurrentOdometer);
|
||||
}
|
||||
|
||||
return assetdetail;
|
||||
}
|
||||
else
|
||||
return new AssetDetailItem();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private object GetPMInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
PMInfo ominfo = new PMInfo();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var custid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var assetidstr = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
long assetid = -1;
|
||||
long.TryParse(assetidstr, out assetid);
|
||||
if (string.IsNullOrWhiteSpace(custid))
|
||||
custid = SystemParams.CompanyID;
|
||||
|
||||
var client = CreateClient<AssetQueryClient>(custid);
|
||||
var names = client.GetAssetPMScheduleNames(custid, assetid);
|
||||
ominfo.ScheduleNames = string.Join(", ", names);
|
||||
ominfo.AlertMessages = client.GetAssetPMAlertMessagess(custid, assetid);
|
||||
}
|
||||
return ominfo;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private object GetAssetRental()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var custid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var assetidstr = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
long assetid = -1;
|
||||
long.TryParse(assetidstr, out assetid);
|
||||
if (string.IsNullOrWhiteSpace(custid))
|
||||
custid = SystemParams.CompanyID;
|
||||
|
||||
var temp = CreateClient<AssetQueryClient>(custid).GetAssetCurrentRentalSimpleInfo(custid, assetid);
|
||||
if (temp != null)
|
||||
{
|
||||
MachineRentalInfo rental = new MachineRentalInfo();
|
||||
rental.RentalID = temp.ID;
|
||||
rental.ProjectReturnDate = temp.PrjReturnDate;
|
||||
rental.RentalRate = (decimal)temp.Rate;
|
||||
rental.RentalDate = temp.RentalDate;
|
||||
rental.ReturnDate = temp.ReturnDate;
|
||||
rental.Term = temp.Term;
|
||||
rental.TermUnit = temp.TermUnit;
|
||||
return rental;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetAssetOnOffTimeline()
|
||||
{
|
||||
try
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var companyid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
{
|
||||
companyid = SystemParams.CompanyID;
|
||||
}
|
||||
var assetid = long.Parse(clientdata[1]);
|
||||
var date = DateTime.Parse(clientdata[2]);
|
||||
return CreateClient<AssetQueryClient>(companyid).GetAssetOnOffTimeline(companyid, assetid, date).Select(s =>
|
||||
{
|
||||
double off;
|
||||
if (s.Off != null)
|
||||
{
|
||||
off = s.Off.Value.TimeOfDay.TotalSeconds;
|
||||
}
|
||||
else
|
||||
{
|
||||
var now = CreateClient<Foresight.Fleet.Services.SystemUtil>().GetCustomerDateTimeNow(companyid);
|
||||
if (now.Date == date.Date && (s.On == null || now > s.On.Value))
|
||||
{
|
||||
off = now.TimeOfDay.TotalSeconds;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 23:59:59
|
||||
off = 24 * 60 * 60 - 1;
|
||||
}
|
||||
}
|
||||
return new
|
||||
{
|
||||
HasOn = s.On != null,
|
||||
Start = s.On?.TimeOfDay.TotalSeconds ?? 0,
|
||||
HasOff = s.Off != null,
|
||||
End = off
|
||||
};
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string IsCalampPrimaryLocation()
|
||||
{
|
||||
try
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var companyid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
{
|
||||
companyid = SystemParams.CompanyID;
|
||||
}
|
||||
var assetid = long.Parse(clientdata[1]);
|
||||
return CreateClient<AssetQueryClient>(companyid).IsCalampPrimaryLocation(companyid, assetid) ? "1" : "0";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetAssetDetailWorkspaceConfig()
|
||||
{
|
||||
return MachineDetailWorkspace.GetConfig();
|
||||
}
|
||||
|
||||
class AssetDetailItem
|
||||
{
|
||||
public long ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Name2 { get; set; }
|
||||
public string VIN { get; set; }
|
||||
public int MakeID { get; set; }
|
||||
public int TypeID { get; set; }
|
||||
public int ModelID { get; set; }
|
||||
public string MakeName { get; set; }
|
||||
public string ModelName { get; set; }
|
||||
public string TypeName { get; set; }
|
||||
public int MakeYear { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string AquisitionType { get; set; }
|
||||
public string CostCenter { get; set; }
|
||||
public DateTime? DateAddedUtc { get; set; }
|
||||
public string DateAddedUtcStr { get { return DateAddedUtc.ToString(); } }
|
||||
public DateTime? DateAddedLocal { get; set; }
|
||||
public string DateAddedLocalStr { get { return DateAddedLocal.ToString(); } }
|
||||
public string GroupNames { get; set; }
|
||||
public string CurrentJobSiteNames { get; set; }
|
||||
public string LastForeman { get; set; }
|
||||
public string AssetIconUrl { get; set; }
|
||||
public string MapViewIconUrl { get; set; }
|
||||
public bool OnRoad { get; set; }
|
||||
public bool TelematicsEnabled { get; set; }
|
||||
|
||||
public AssetAddressItem CurrentLocation { get; set; }
|
||||
public AssetEngineHoursItem CurrentHours { get; set; }
|
||||
public AssetIdlehoursItem CurrentIdleHours { get; set; }
|
||||
public AssetOdometerItem CurrentOdometer { get; set; }
|
||||
public string DisplayName
|
||||
{
|
||||
get
|
||||
{
|
||||
//DisplayName取值顺序为Name2,Name,VIN,ID用于前端显示
|
||||
string name = Name2;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
name = Name;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
name = VIN;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
name = ID.ToString();
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AssetAttributeItemBase
|
||||
{
|
||||
public long AssetID { get; set; }
|
||||
public DateTime AsofTime { get; set; }//utc time
|
||||
public string AsofTimeStr { get { return AsofTime.ToString(); } }
|
||||
public DateTime AsofTimeLocal { get; set; }//AsOftime的用户本地时间表示
|
||||
public string AsofTimeLocalStr { get { return AsofTimeLocal.ToString(); } }
|
||||
public string DataSource { get; set; }
|
||||
public string SubSource { get; set; }
|
||||
public string DataSourceName { get; set; }
|
||||
}
|
||||
|
||||
class AssetAddressItem : AssetAttributeItemBase
|
||||
{
|
||||
public double Latitude { get; set; }
|
||||
public double Longitude { get; set; }
|
||||
public string Street { get; set; }
|
||||
public string City { get; set; }
|
||||
public string State { get; set; }
|
||||
public string PostalCode { get; set; }
|
||||
public string Country { get; set; }
|
||||
public bool IsPrimary { get; set; }
|
||||
public string Address { get; set; }
|
||||
}
|
||||
|
||||
class AssetEngineHoursItem : AssetAttributeItemBase
|
||||
{
|
||||
public double Hours { get; set; }
|
||||
|
||||
private double _Corrected;
|
||||
public double Corrected
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Corrected;
|
||||
}
|
||||
set
|
||||
{
|
||||
value = value > 0 ? value : 0;
|
||||
_Corrected = Math.Round(value, 2);
|
||||
}
|
||||
}
|
||||
public bool IsPrimary { get; set; }
|
||||
}
|
||||
class AssetIdlehoursItem : AssetAttributeItemBase
|
||||
{
|
||||
public double Hours { get; set; }
|
||||
public bool IsPrimary { get; set; }
|
||||
}
|
||||
class AssetOdometerItem : AssetAttributeItemBase
|
||||
{
|
||||
public string UOM { get; set; }
|
||||
|
||||
private double _Odometer;
|
||||
public double Odometer
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Odometer;
|
||||
}
|
||||
set
|
||||
{
|
||||
value = value > 0 ? value : 0;
|
||||
_Odometer = Math.Round(value, 2);
|
||||
}
|
||||
}
|
||||
private double _Corrected;
|
||||
public double Corrected
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Corrected;
|
||||
}
|
||||
set
|
||||
{
|
||||
value = value > 0 ? value : 0;
|
||||
_Corrected = Math.Round(value, 2);
|
||||
}
|
||||
}
|
||||
public bool IsPrimary { get; set; }
|
||||
}
|
||||
|
||||
class PMInfo
|
||||
{
|
||||
public string ScheduleNames { get; set; }
|
||||
public string[] AlertMessages { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,149 @@
|
||||
using Foresight.Fleet.Services.Customer;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace IronIntel.Contractor.Site.SystemSettings
|
||||
{
|
||||
public class CustomerProviderBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
object result = null;
|
||||
try
|
||||
{
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName.ToUpper())
|
||||
{
|
||||
case "GETCUSTOMERLOCATIONS":
|
||||
result = GetCustomerLocations();
|
||||
break;
|
||||
case "SAVECUSTOMERLOCATION":
|
||||
result = SaveCustomerLocation();
|
||||
break;
|
||||
case "DELETECUSTOMERLOCATION":
|
||||
result = DeleteCustomerLocation();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result = ex.Message;
|
||||
SystemParams.WriteLog("Error", "CustomerProvider.ProcessRequest", ex.Message, ex.ToString());
|
||||
}
|
||||
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
private object GetCustomerLocations()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
CustomerLocation[] locations = CreateClient<CustomerProvider>().GetCustomerLocations(SystemParams.CompanyID);
|
||||
|
||||
List<CustomerLocationItem> list = new List<CustomerLocationItem>();
|
||||
foreach (CustomerLocation lc in locations)
|
||||
{
|
||||
CustomerLocationItem item = new CustomerLocationItem();
|
||||
Helper.CloneProperty(item, lc);
|
||||
list.Add(item);
|
||||
}
|
||||
if (list.Count() > 0)
|
||||
return list.ToArray().OrderBy(m => m.Name);
|
||||
else
|
||||
return new CustomerLocationItem[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("not login.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private object SaveCustomerLocation()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
string data = HttpUtility.UrlDecode(Request.Params["ClientData"]);
|
||||
HttpPostedFile uploadFile = null;
|
||||
byte[] logobyte = null;
|
||||
if (Request.Files.Count > 0)
|
||||
{
|
||||
uploadFile = Request.Files[0];
|
||||
logobyte = ConvertFile2bytes(uploadFile);
|
||||
}
|
||||
|
||||
CustomerLocationItem item = JsonConvert.DeserializeObject<CustomerLocationItem>(data);
|
||||
CustomerLocation location = new CustomerLocation();
|
||||
Helper.CloneProperty(location, item);
|
||||
var cp = CreateClient<CustomerProvider>();
|
||||
int locationid = location.ID;
|
||||
if (locationid == -1)
|
||||
locationid = cp.AddCustomerLocation(SystemParams.CompanyID, location);
|
||||
else
|
||||
cp.UpdateCustomerLocation(location);
|
||||
|
||||
if (logobyte != null)
|
||||
cp.ChangeLocationLOGO(locationid, logobyte);
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("not login.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string DeleteCustomerLocation()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
string id = HttpUtility.UrlDecode(Request.Params["ClientData"]);
|
||||
int locationid = -1;
|
||||
int.TryParse(id, out locationid);
|
||||
CreateClient<CustomerProvider>().DeleteCustomerLocation(locationid);
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("not login.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
public class CustomerLocationItem
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public double Latitude { get; set; }
|
||||
public double Longitude { get; set; }
|
||||
public string Address { get; set; }
|
||||
public string Notes { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,292 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using System.Xml;
|
||||
using System.Web;
|
||||
using IronIntel.Services;
|
||||
using IronIntel.Contractor.Users;
|
||||
using Foresight.ServiceModel;
|
||||
|
||||
namespace IronIntel.Contractor.Site.SystemSettings
|
||||
{
|
||||
public class SystemSettingsBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
object result = null;
|
||||
try
|
||||
{
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName.ToUpper())
|
||||
{
|
||||
case "GETCOMPANYUISTYLES":
|
||||
result = GetCompanyUIStyles();
|
||||
break;
|
||||
case "SETCOMPANYUISTYLE":
|
||||
result = SetCompanyUIStyle();
|
||||
break;
|
||||
case "DELETECOMPANYUISTYLE":
|
||||
result = DeleteCompanyUIStyle();
|
||||
break;
|
||||
case "GETUSEROPTIONS":
|
||||
result = GetUserOptions();
|
||||
break;
|
||||
case "SAVEUSEROPTIONS":
|
||||
result = SaveUserOptions();
|
||||
break;
|
||||
case "GETTIMEZONES":
|
||||
result = GetTimeZones();
|
||||
break;
|
||||
case "GETSYSTEMOPTIONS":
|
||||
result = GetSystemOptions();
|
||||
break;
|
||||
case "SAVESYSTEMOPTIONS":
|
||||
result = SaveSystemOptions();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result = ex.Message;
|
||||
SystemParams.WriteLog("Error", "Settingcolor.ProcessRequest", ex.Message, ex.ToString());
|
||||
}
|
||||
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private object GetCompanyUIStyles()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
IronSysServiceClient ic = SystemParams.GetIronSystemServiceClient();
|
||||
CustUIStyleList uis = ic.GetCompanyUIStyles(SystemParams.CompanyID);
|
||||
|
||||
List<CustUIStyleItem> list = new List<CustUIStyleItem>();
|
||||
foreach (CustUIStyle ui in uis)
|
||||
{
|
||||
CustUIStyleItem item = new CustUIStyleItem();
|
||||
Helper.CloneProperty(item, ui);
|
||||
list.Add(item);
|
||||
}
|
||||
if (list.Count() > 0)
|
||||
return list.ToArray();
|
||||
else
|
||||
return new CustUIStyleItem[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("not login.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string SetCompanyUIStyle()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string uidata = Request.Params["ClientData"];
|
||||
CustUIStyleItem item = JsonConvert.DeserializeObject<CustUIStyleItem>(uidata);
|
||||
item.UIStyleName = HttpUtility.UrlDecode(item.UIStyleName);
|
||||
CustUIStyle ui = new CustUIStyle();
|
||||
Helper.CloneProperty(ui, item);
|
||||
IronSysServiceClient ic = SystemParams.GetIronSystemServiceClient();
|
||||
ic.SetCompanyUIStyle(SystemParams.CompanyID, ui);
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "User being not logged in.";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string DeleteCompanyUIStyle()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string uistyleid = HttpUtility.UrlDecode(Request.Params["ClientData"]);
|
||||
int styleid = -1;
|
||||
int.TryParse(uistyleid, out styleid);
|
||||
IronSysServiceClient ic = SystemParams.GetIronSystemServiceClient();
|
||||
ic.DeleteCompanyUIStyle(SystemParams.CompanyID, styleid);
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("not login.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetUserOptions()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var up = UserParams.GetUserParams(session.SessionID, session.User.UID);
|
||||
return up;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("not login.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object SaveUserOptions()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string options = HttpUtility.UrlDecode(Request.Params["ClientData"]);
|
||||
UserParamInfo upi = JsonConvert.DeserializeObject<UserParamInfo>(options);
|
||||
UserParams.SetUserParams(session.User.UID, upi);
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("not login.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetTimeZones()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var timezones = SystemParams.GetTimeZones();
|
||||
return timezones;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("not login.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetSystemOptions()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string af = SystemParams.GetStringParam("AccuracyFilter");
|
||||
double accuracyfilter = 0;
|
||||
double.TryParse(af, out accuracyfilter);
|
||||
|
||||
SystemOptionInfo soi = new SystemOptionInfo();
|
||||
soi.TimeZone = SystemParams.GetStringParam("CustomerTimeZone", false);
|
||||
soi.AccuracyFilter = accuracyfilter;
|
||||
soi.UnitOfOdometer = SystemParams.GetStringParam("UnitOfOdometer");
|
||||
soi.AcknowledgingAlerts = SystemParams.GetStringParam("AcknowledgingAlerts");
|
||||
return soi;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("not login.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object SaveSystemOptions()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string options = HttpUtility.UrlDecode(Request.Params["ClientData"]);
|
||||
SystemOptionInfo upi = JsonConvert.DeserializeObject<SystemOptionInfo>(options);
|
||||
|
||||
SystemParams.SetStringParam("CustomerTimeZone", upi.TimeZone);
|
||||
SystemParams.SetStringParam("CustomerTimeZoneOffset", upi.Offset.ToString());
|
||||
SystemParams.SetStringParam("AccuracyFilter", upi.AccuracyFilter.ToString());
|
||||
SystemParams.SetStringParam("UnitOfOdometer", upi.UnitOfOdometer);
|
||||
SystemParams.SetStringParam("AcknowledgingAlerts", upi.AcknowledgingAlerts);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("not login.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private class CustUIStyleItem
|
||||
{
|
||||
public int UIStyleID { get; set; }
|
||||
public string UIStyleName { get; set; }
|
||||
public bool IsDefault { get; set; }
|
||||
public string TitleBarColor { get; set; }
|
||||
public string MenuBackgroundColor { get; set; }
|
||||
public string ChartTitleBackgroundColor { get; set; }
|
||||
public string ChartBorderColor { get; set; }
|
||||
}
|
||||
|
||||
private class SystemOptionInfo
|
||||
{
|
||||
public string TimeZone { get; set; }
|
||||
public int Offset { get; set; }
|
||||
public double AccuracyFilter { get; set; }
|
||||
public string UnitOfOdometer { get; set; }
|
||||
public string AcknowledgingAlerts { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
599
IronIntelContractorSiteLib/UserManageBasePage.cs
Normal file
599
IronIntelContractorSiteLib/UserManageBasePage.cs
Normal file
@ -0,0 +1,599 @@
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using Foresight.Fleet.Services.JobSite;
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Contractor.Contact;
|
||||
using IronIntel.Contractor.JobSites;
|
||||
using IronIntel.Contractor.Machines;
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
using IronIntel.Contractor.MapView;
|
||||
using IronIntel.Contractor.Users;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace IronIntel.Contractor.Site
|
||||
{
|
||||
public class UserManageBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
object result = null;
|
||||
try
|
||||
{
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName.ToUpper())
|
||||
{
|
||||
case "GETUSERS":
|
||||
result = GetUsers();
|
||||
break;
|
||||
case "ADDUSER":
|
||||
result = SaveUser(true);
|
||||
break;
|
||||
case "EDITUSER":
|
||||
result = SaveUser(false);
|
||||
break;
|
||||
case "DELETEUSER":
|
||||
result = DeleteUser();
|
||||
break;
|
||||
case "RESETPASSWORD":
|
||||
result = ResetPassword();
|
||||
break;
|
||||
case "GETUSERMACHINEGROUP":
|
||||
result = GetUserMachineGroup();
|
||||
break;
|
||||
case "SAVEUSERMACHINEGROUP":
|
||||
result = SaveUserMachineGroup();
|
||||
break;
|
||||
case "GETUSERINFO":
|
||||
result = GetUserInfo();
|
||||
break;
|
||||
case "GETALLGROUPS":
|
||||
result = GetAllGroups();
|
||||
break;
|
||||
case "GETGROUPSBYUSER":
|
||||
result = GetGroupsByUser();
|
||||
break;
|
||||
case "GETSELECTEDMACHINES":
|
||||
result = GetSelectedMachines();
|
||||
break;
|
||||
case "GETSELECTEDASSETS":
|
||||
result = GetSelectedAssets();
|
||||
break;
|
||||
case "ASSIGNASSETSTOUSER":
|
||||
result = AssignAssetsToUser();
|
||||
break;
|
||||
case "REMOVEASSIGNEDASSETSFROMUSER":
|
||||
result = RemoveAssignedAssetsFromUser();
|
||||
break;
|
||||
case "SAVECONTACTMACHINES":
|
||||
result = SaveContactMachines();
|
||||
break;
|
||||
case "GETJOBSITELIST":
|
||||
result = GetJobsiteList();
|
||||
break;
|
||||
case "GETSELECTEDJOBSITES":
|
||||
result = GetSelectedJobsites();
|
||||
break;
|
||||
case "SAVECONTACTJOBSITES":
|
||||
result = SaveContactJobsites();
|
||||
break;
|
||||
case "GETMACHINETYPES":
|
||||
Machines.MachineManagement.RefreshMachineTypes();
|
||||
result = MachineManagement.GetMachineTypes().OrderBy(m => m.Name).Select(t => new
|
||||
{
|
||||
ID = t.ID,
|
||||
Name = t.Name
|
||||
});
|
||||
break;
|
||||
case "GETMACHINELIST":
|
||||
result = GetMachineList();
|
||||
break;
|
||||
case "GETAVAILABLEFEATURES":
|
||||
result = GetAvailableFeatures();
|
||||
break;
|
||||
case "GETFEATURESDEFINEDONUSER":
|
||||
result = GetFeaturesDefinedOnUser();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "ContactBasePage", ex.Message, ex.ToString());
|
||||
throw ex;
|
||||
}
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
#region Security
|
||||
|
||||
private object GetAvailableFeatures()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var client = CreateClient<Foresight.Fleet.Services.User.PermissionProvider>();
|
||||
Foresight.Fleet.Services.User.Feature[] features = client.GetAvailableFeatures(SystemParams.CompanyID);
|
||||
if (features == null || features.Length == 0)
|
||||
return new FeatureModuleItem[0];
|
||||
|
||||
List<FeatureModuleItem> list = new List<FeatureModuleItem>();
|
||||
foreach (var feature in features)
|
||||
{
|
||||
FeatureModuleItem fmi = list.FirstOrDefault(m => m.Module.Id == feature.ModuleId);
|
||||
|
||||
if (fmi == null)
|
||||
{
|
||||
fmi = new FeatureModuleItem();
|
||||
fmi.Module = Foresight.Fleet.Services.User.FeatureModule.GetModule(feature.ModuleId);
|
||||
fmi.Features.Add(feature);
|
||||
list.Add(fmi);
|
||||
}
|
||||
else
|
||||
fmi.Features.Add(feature);
|
||||
}
|
||||
|
||||
return list.ToArray();
|
||||
}
|
||||
else
|
||||
return new FeatureModuleItem[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetFeaturesDefinedOnUser()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var useriid = Request.Form["ClientData"];
|
||||
var client = CreateClient<Foresight.Fleet.Services.User.PermissionProvider>();
|
||||
KeyValuePair<int, Foresight.Fleet.Services.User.Permissions[]>[] pms = client.GetFeaturesDefinedOnUser(SystemParams.CompanyID, useriid);
|
||||
|
||||
return pms;
|
||||
}
|
||||
else
|
||||
return new KeyValuePair<int, Foresight.Fleet.Services.User.Permissions[]>[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// check whether you are admin.
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session == null || session.User == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var ui = UserManagement.GetUserByIID(session.User.UID);
|
||||
return ui != null && ui.UserType >= UserTypes.Admin;
|
||||
}
|
||||
|
||||
protected override bool ThrowIfNotAllowed { get { return true; } }
|
||||
|
||||
private object GetUsers()
|
||||
{
|
||||
var items = UserManagement.GetUsers().OrderBy(u => u.ID).ToArray();
|
||||
return items;
|
||||
}
|
||||
|
||||
private object GetUserInfo()
|
||||
{
|
||||
var uid = Request.Form["ClientData"];
|
||||
var user = UserManagement.GetUserByIID(uid);
|
||||
if (user == null)
|
||||
user = new UserInfo();
|
||||
return user;
|
||||
}
|
||||
|
||||
private object SaveUser(bool adduser)
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session == null) return "";
|
||||
|
||||
var content = Request.Form["ClientData"];
|
||||
content = HttpUtility.HtmlDecode(content);
|
||||
var user = JsonConvert.DeserializeObject<UserObject>(content);
|
||||
var item = user.UserInfo;
|
||||
|
||||
try
|
||||
{
|
||||
if (adduser)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(item.ID))
|
||||
{
|
||||
throw new ArgumentException("User ID cannot be empty.");
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(item.DisplayName))
|
||||
{
|
||||
throw new ArgumentException("User name cannot be empty.");
|
||||
}
|
||||
item.Active = true;
|
||||
item.IID = UserManagement.AddUser(item, item.TransPass, session.User.UID, session.SessionID, Request.UserHostName);
|
||||
}
|
||||
else
|
||||
{
|
||||
UserManagement.UpdateUserInfo(item, session.User.UID, session.SessionID, Request.UserHostName);
|
||||
UserManagement.SaveUserGroups(item.IID, item.GroupIDs);
|
||||
// save subscribe message
|
||||
if (user.Subscribe != null)
|
||||
{
|
||||
user.Subscribe.UserIID = item.IID;
|
||||
FI.FIC.Models.WorkspaceManager.SaveSubscribeMessageByEmail(user.Subscribe, item.IID);
|
||||
}
|
||||
|
||||
if (user.Features != null && user.Features.Length > 0)
|
||||
{
|
||||
var client = CreateClient<Foresight.Fleet.Services.User.PermissionProvider>();
|
||||
client.UpdateFeaturesForUser(SystemParams.CompanyID, item.IID, user.Features, session.User.UID);
|
||||
}
|
||||
if (SystemParams.HasLicense("EmailSubscribe") && user.Schedule != null)
|
||||
{
|
||||
FI.FIC.Models.Schedule.ScheduleManager.SaveEmailScheduleItems(item.IID, user.Schedule, "en-us");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
|
||||
return new string[] { item.IID, "Saved successfully." };
|
||||
}
|
||||
|
||||
private string DeleteUser()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session == null) return "";
|
||||
|
||||
var iid = Request.Form["ClientData"];
|
||||
Guid guid;
|
||||
if (!Guid.TryParse(iid, out guid))
|
||||
{
|
||||
throw new ArgumentException("User IID is not valid.");
|
||||
}
|
||||
else if (!UserManagement.CanDeleteUser(iid))
|
||||
{
|
||||
throw new Exception("This user cannot be deleted.");
|
||||
}
|
||||
CreateClient<Foresight.Fleet.Services.User.UserQueryClient>().DeleteUser(iid, session.User.UID, "");
|
||||
return "OK";
|
||||
}
|
||||
|
||||
private object ResetPassword()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session == null) return "";
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var iid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var password = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
Guid guid;
|
||||
if (!Guid.TryParse(iid, out guid))
|
||||
{
|
||||
throw new ArgumentException("User IID is not valid.");
|
||||
}
|
||||
|
||||
UserManagement.ResetPassword(iid, password, session.User.UID, session.SessionID, Request.UserHostName);
|
||||
return "OK";
|
||||
}
|
||||
|
||||
private object GetUserMachineGroup()
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
var useriid = HttpUtility.HtmlDecode(clientdata);
|
||||
|
||||
var allMachines = MachineManagement.GetMachineGroups("");
|
||||
var machines = MachineManagement.GetMachineGroupByUser(useriid);
|
||||
UserMachineGroupInfoItem mgi = new UserMachineGroupInfoItem();
|
||||
mgi.AllMachineGroups = allMachines.OrderBy((m) => m.GroupName).ToArray();
|
||||
mgi.MachineGroups = machines.OrderBy((m) => m.GroupName).ToArray();
|
||||
|
||||
return mgi;
|
||||
}
|
||||
else
|
||||
return "OK";
|
||||
}
|
||||
private object SaveUserMachineGroup()
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
string clientdata = Request.Form["ClientData"];
|
||||
clientdata = HttpUtility.HtmlDecode(clientdata);
|
||||
UserMachineGroupSaveItem umg = JsonConvert.DeserializeObject<UserMachineGroupSaveItem>(clientdata);
|
||||
|
||||
MachineManagement.SaveUserMachineGroup(umg.UserIID, umg.GroupIDs);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
return "Failed";
|
||||
}
|
||||
|
||||
private object GetAllGroups()
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var groups = UserManagement.GetGroups();
|
||||
return groups;
|
||||
}
|
||||
return "Failed";
|
||||
}
|
||||
|
||||
private object GetGroupsByUser()
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
string clientdata = Request.Form["ClientData"];
|
||||
clientdata = HttpUtility.HtmlDecode(clientdata);
|
||||
|
||||
var groups = UserManagement.GetGroupsByUser(clientdata);
|
||||
return groups;
|
||||
}
|
||||
return "Failed";
|
||||
}
|
||||
|
||||
private MaintenanceMachineInfo[] GetSelectedMachines()
|
||||
{
|
||||
var contactid = Request.Form["ClientData"];
|
||||
var machines = MachineManagement.GetContactMachinesByID(contactid);
|
||||
|
||||
return machines.OrderBy(m => m.VIN).ToArray();
|
||||
}
|
||||
|
||||
private object[] GetSelectedAssets()
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var companyId = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
if (string.IsNullOrEmpty(companyId))
|
||||
{
|
||||
companyId = SystemParams.CompanyID;
|
||||
}
|
||||
var uid = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
var machines = CreateClient<AssetDataAdjustClient>(companyId).GetAssetsAssignedToUser(companyId, uid);
|
||||
|
||||
return machines.OrderBy(m => m.VIN).Select(m => new
|
||||
{
|
||||
ID = m.Id,
|
||||
Name = string.IsNullOrEmpty(m.Name2) ? m.Name : m.Name2,
|
||||
m.VIN,
|
||||
m.MakeName,
|
||||
m.ModelName,
|
||||
m.TypeName
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
private string AssignAssetsToUser()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var companyId = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
if (string.IsNullOrEmpty(companyId))
|
||||
{
|
||||
companyId = SystemParams.CompanyID;
|
||||
}
|
||||
var uid = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
var machineids = HttpUtility.HtmlDecode(clientdata[2]);
|
||||
|
||||
var ids = JsonConvert.DeserializeObject<long[]>(machineids);
|
||||
|
||||
CreateClient<AssetDataAdjustClient>(companyId).AssignAssetsToUser(companyId, uid, ids);
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string RemoveAssignedAssetsFromUser()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var companyId = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
if (string.IsNullOrEmpty(companyId))
|
||||
{
|
||||
companyId = SystemParams.CompanyID;
|
||||
}
|
||||
var uid = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
var machineids = HttpUtility.HtmlDecode(clientdata[2]);
|
||||
|
||||
var ids = JsonConvert.DeserializeObject<long[]>(machineids);
|
||||
|
||||
CreateClient<AssetDataAdjustClient>(companyId).RemoveAssignedAssetsFromUser(companyId, uid, ids);
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string SaveContactMachines()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var contactid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var machineids = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
string[] ids = JsonConvert.DeserializeObject<string[]>(machineids);
|
||||
|
||||
UserManagement.SaveUserMachines(contactid, ids);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetJobsiteList()
|
||||
{
|
||||
try
|
||||
{
|
||||
JobSiteViewItem[] items = null;
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var s = Request.Form["ClientData"];
|
||||
s = HttpUtility.UrlDecode(s);
|
||||
|
||||
var jss = CreateClient<JobSiteProvider>().GetJobSiteItems(SystemParams.CompanyID, "", false);
|
||||
List<JobSiteViewItem> list = new List<JobSiteViewItem>();
|
||||
foreach (var js in jss)
|
||||
{
|
||||
JobSiteViewItem item = new JobSiteViewItem();
|
||||
item.ID = js.ID;
|
||||
item.Name = js.Name;
|
||||
|
||||
list.Add(item);
|
||||
}
|
||||
items = list.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new JobSiteViewItem[0];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private object GetSelectedJobsites()
|
||||
{
|
||||
try
|
||||
{
|
||||
JobSiteViewItem[] items = null;
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var contactid = Request.Form["ClientData"];
|
||||
contactid = HttpUtility.UrlDecode(contactid);
|
||||
|
||||
items = JobSitesManagement.GetUserJobsites(contactid);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new JobSiteViewItem[0];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string SaveContactJobsites()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var contactid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var jobsiteids = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
string[] ids = JsonConvert.DeserializeObject<string[]>(jobsiteids);
|
||||
|
||||
UserManagement.SaveUserJobsites(contactid, ids);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private MaintenanceMachineInfo[] GetMachineList()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
var s = Request.Form["ClientData"];
|
||||
var p = JsonConvert.DeserializeObject<StringKeyValue>(s);
|
||||
|
||||
var machines = MaintenanceManagement.GetMaintenanceMachines(session.SessionID, int.Parse(p.Key), p.Value, session.User.UID)
|
||||
.OrderBy(m => m.ShowName)
|
||||
.ToArray();
|
||||
|
||||
return machines;
|
||||
}
|
||||
|
||||
private class UserMachineGroupInfoItem
|
||||
{
|
||||
public MachineGroup[] AllMachineGroups { get; set; }
|
||||
public MachineGroup[] MachineGroups { get; set; }
|
||||
}
|
||||
private class UserMachineGroupSaveItem
|
||||
{
|
||||
public string UserIID { get; set; }
|
||||
public string[] GroupIDs { get; set; }
|
||||
}
|
||||
|
||||
public class FeatureModuleItem
|
||||
{
|
||||
public Foresight.Fleet.Services.User.FeatureModule Module { get; set; }
|
||||
public List<Foresight.Fleet.Services.User.Feature> Features { get; set; } = new List<Foresight.Fleet.Services.User.Feature>();
|
||||
}
|
||||
}
|
||||
}
|
21
IronIntelContractorSiteLib/WorkspaceBasePage.cs
Normal file
21
IronIntelContractorSiteLib/WorkspaceBasePage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.Site
|
||||
{
|
||||
public class WorkspaceBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest(string method)
|
||||
{
|
||||
Response.End();
|
||||
}
|
||||
|
||||
public override string JQueryVersion
|
||||
{
|
||||
get { return "1.12.4"; }
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user