initial version with inspection edition
This commit is contained in:
@ -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; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user