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