sync
This commit is contained in:
@ -3,6 +3,7 @@ using Foresight.Fleet.Services;
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using Foresight.Fleet.Services.AssetHealth;
|
||||
using Foresight.Fleet.Services.Device;
|
||||
using Foresight.Fleet.Services.User;
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Contractor.Machines;
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
@ -189,6 +190,8 @@ namespace IronIntel.Contractor.Site.Asset
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
if (!CheckRight(SystemParams.CompanyID, Foresight.Fleet.Services.User.Feature.MANAGE_ASSETS))
|
||||
return "";
|
||||
string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
|
||||
AssetDetailItem2 asset = JsonConvert.DeserializeObject<AssetDetailItem2>(clientdata);
|
||||
|
||||
@ -216,7 +219,8 @@ namespace IronIntel.Contractor.Site.Asset
|
||||
var oldMachine = client.GetAssetDetailInfo2(customerid, asset.ID);
|
||||
asset.EngineHours = oldMachine.EngineHours;//EngineHours单独保存
|
||||
var user = UserManagement.GetUserByIID(session.User.UID);
|
||||
if (user.UserType < UserTypes.Admin)
|
||||
bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
if (!permission)
|
||||
{
|
||||
asset.VIN = oldMachine.VIN;
|
||||
asset.MakeID = oldMachine.MakeID;
|
||||
|
@ -10,6 +10,7 @@ using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services.Customers;
|
||||
using System.Web;
|
||||
using Foresight.Fleet.Services;
|
||||
using Foresight.Fleet.Services.User;
|
||||
|
||||
namespace IronIntel.Contractor.Site
|
||||
{
|
||||
@ -65,7 +66,7 @@ namespace IronIntel.Contractor.Site
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return (user.UserType == UserTypes.Admin || user.UserType == UserTypes.SupperAdmin);
|
||||
return (user.UserType == Users.UserTypes.Admin || user.UserType == Users.UserTypes.SupperAdmin);
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,12 +95,59 @@ namespace IronIntel.Contractor.Site
|
||||
|
||||
protected virtual bool ThrowIfNotAllowed { get { return false; } }
|
||||
|
||||
protected virtual bool CanDirectAccess { get { return false; } }
|
||||
|
||||
protected bool CheckUserToken()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)//已经登录
|
||||
{
|
||||
return true;
|
||||
}
|
||||
string tkstring = Request.Params["tk"];
|
||||
if (string.IsNullOrEmpty(tkstring))
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
var sc = new FI.FIC.Models.Security.SymmetricCrypt(FI.FIC.Models.Security.CryptType.DES);
|
||||
tkstring = sc.Decrypt(tkstring,
|
||||
FI.FIC.DataProviders.ChartDataProvider.DES_Key,
|
||||
FI.FIC.DataProviders.ChartDataProvider.DES_IV);
|
||||
|
||||
string[] temps = tkstring.Split('|');
|
||||
if (temps.Length != 2)
|
||||
return false;
|
||||
|
||||
string timestring = temps[0];
|
||||
DateTime time = DateTime.MinValue;
|
||||
if (!DateTime.TryParse(timestring, out time)
|
||||
|| time < DateTime.UtcNow.AddMinutes(-5))
|
||||
return false;
|
||||
|
||||
var sessionid = temps[1];
|
||||
var c = CreateClient<UserQueryClient>();
|
||||
//通过手机SessionID获取新的Web Session
|
||||
var newsession = c.GetNewLoginSession(sessionid, APPNAME);
|
||||
SetLoginSessionCookie(newsession.SessionID);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected bool CheckLoginSession()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session == null)
|
||||
{
|
||||
RedirectToLoginPage();
|
||||
if (CanDirectAccess)
|
||||
RedirectToLoginPageWithUrl();
|
||||
else
|
||||
RedirectToLoginPage();
|
||||
return false;
|
||||
}
|
||||
if (!AllowCurrentLoginSessionEnter())
|
||||
@ -121,6 +169,13 @@ namespace IronIntel.Contractor.Site
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void RedirectToLoginPageWithUrl()
|
||||
{
|
||||
string url = Request.Url.ToString();
|
||||
url = HttpUtility.UrlEncode(url);
|
||||
Response.Redirect(LoginPageUrl + "?f=" + url);
|
||||
}
|
||||
|
||||
protected void DoLogout()
|
||||
{
|
||||
string sid = null;
|
||||
@ -213,5 +268,28 @@ namespace IronIntel.Contractor.Site
|
||||
var session = GetCurrentLoginSession();
|
||||
return FleetServiceClientHelper.CreateClient<T>(companyid, session == null ? "" : session.SessionID);
|
||||
}
|
||||
|
||||
protected bool CheckRight(string custid, int featureid)
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user == null)
|
||||
return false;
|
||||
|
||||
if (user.UserType == Users.UserTypes.SupperAdmin)
|
||||
return true;
|
||||
|
||||
if (user.UserType == Users.UserTypes.Common || user.UserType == Users.UserTypes.Admin)
|
||||
{
|
||||
var client = FleetServiceClientHelper.CreateClient<PermissionProvider>();
|
||||
Tuple<Feature, Permissions>[] pmss = client.GetUserPermissions(custid, user.IID);
|
||||
if (pmss.Length > 0)
|
||||
{
|
||||
Tuple<Feature, Permissions> permission = pmss.FirstOrDefault(m => m.Item1.Id == featureid);
|
||||
if (permission != null)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using Foresight.Fleet.Services.AssetHealth;
|
||||
using Foresight.Fleet.Services.Inspection;
|
||||
using Foresight.Fleet.Services.User;
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Contractor.FilterQ;
|
||||
using IronIntel.Contractor.Machines;
|
||||
@ -151,6 +152,29 @@ namespace IronIntel.Contractor.Site
|
||||
Response.End();
|
||||
}
|
||||
|
||||
protected object GetInspectItem(string inspectionid)
|
||||
{//只有id,不知道类型
|
||||
var sesstion = GetCurrentLoginSession();
|
||||
|
||||
AssetInspectClient aclient = CreateClient<AssetInspectClient>();
|
||||
AssetInspectItem aitem = aclient.GetInspectItem(SystemParams.CompanyID, inspectionid, sesstion.User.UID);
|
||||
if (aitem != null)
|
||||
{
|
||||
if (!CheckRight(SystemParams.CompanyID, Foresight.Fleet.Services.User.Feature.INSPECTION_REPORTS))
|
||||
return null;
|
||||
else
|
||||
return aitem;
|
||||
}
|
||||
|
||||
TeamIntelligenceClient tclient = CreateClient<TeamIntelligenceClient>();
|
||||
TeamInspectItem titem = tclient.GetInspectItem(SystemParams.CompanyID, inspectionid, sesstion.User.UID);
|
||||
|
||||
if (!CheckRight(SystemParams.CompanyID, Foresight.Fleet.Services.User.Feature.TEAM_REPORTS))
|
||||
return null;
|
||||
else
|
||||
return titem;
|
||||
}
|
||||
|
||||
private object GetInspectItems()
|
||||
{
|
||||
try
|
||||
@ -469,25 +493,26 @@ namespace IronIntel.Contractor.Site
|
||||
{
|
||||
foreach (var q in s.Questions)
|
||||
{
|
||||
var qType =ConvertQuestionType(q);
|
||||
foreach (var a in ir.Answers)
|
||||
{
|
||||
if (q.Id.Equals(a.QuestionId, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (q.QuestionType == QuestionTypes.Date || q.QuestionType == QuestionTypes.DateAndTime)
|
||||
if (qType == QuestionTypes.Date || qType == QuestionTypes.DateAndTime)
|
||||
{
|
||||
DateTime dt = DateTime.Now;
|
||||
if (DateTime.TryParse(a.Result, out dt))
|
||||
{
|
||||
if (q.QuestionType == QuestionTypes.Date)
|
||||
if (qType == QuestionTypes.Date)
|
||||
a.Result = dt.ToString("M/d/yyyy tt");
|
||||
else if (q.QuestionType == QuestionTypes.DateAndTime)
|
||||
else if (qType == QuestionTypes.DateAndTime)
|
||||
a.Result = dt.ToString("M/d/yyyy h:mm:ss tt");
|
||||
}
|
||||
}
|
||||
else if (q.QuestionType == QuestionTypes.Number
|
||||
|| q.QuestionType == QuestionTypes.Integer
|
||||
|| q.QuestionType == QuestionTypes.EngingHours
|
||||
|| q.QuestionType == QuestionTypes.Odometer)
|
||||
else if (qType == QuestionTypes.Number
|
||||
|| qType == QuestionTypes.Integer
|
||||
|| qType == QuestionTypes.EngingHours
|
||||
|| qType == QuestionTypes.Odometer)
|
||||
{
|
||||
double tn = 0;
|
||||
if (double.TryParse(a.Result, out tn))
|
||||
@ -495,13 +520,13 @@ namespace IronIntel.Contractor.Site
|
||||
}
|
||||
|
||||
//IdentifiedQuestion
|
||||
if (q.QuestionType != QuestionTypes.DropDown
|
||||
&& q.QuestionType != QuestionTypes.YesOrNo
|
||||
&& q.QuestionType != QuestionTypes.List)
|
||||
if (qType != QuestionTypes.DropDown
|
||||
&& qType != QuestionTypes.YesOrNo
|
||||
&& qType != QuestionTypes.List)
|
||||
{
|
||||
if (a.SeverityLevel != SeverityLeveles.None)
|
||||
{
|
||||
if (q.QuestionType == QuestionTypes.Picture)
|
||||
if (qType == QuestionTypes.Picture)
|
||||
{
|
||||
var ms = ir.Medias.FirstOrDefault(m => m.AnswerId.ToString() == a.Id.ToString());
|
||||
if (ms == null)
|
||||
@ -571,6 +596,37 @@ namespace IronIntel.Contractor.Site
|
||||
}
|
||||
}
|
||||
|
||||
private QuestionTypes ConvertQuestionType(Question q)
|
||||
{
|
||||
var questionType = q.QuestionType;
|
||||
if (questionType == QuestionTypes.FuelRecords)
|
||||
{
|
||||
switch (q.SubType)
|
||||
{
|
||||
case (int)FuelRecordTypes.TransactionDate:
|
||||
questionType = QuestionTypes.DateAndTime;
|
||||
break;
|
||||
case (int)FuelRecordTypes.Odometer:
|
||||
case (int)FuelRecordTypes.Quantity:
|
||||
case (int)FuelRecordTypes.UnitCost:
|
||||
case (int)FuelRecordTypes.TotalCost:
|
||||
questionType = QuestionTypes.Odometer;
|
||||
break;
|
||||
case (int)FuelRecordTypes.FuelType:
|
||||
case (int)FuelRecordTypes.State:
|
||||
questionType = QuestionTypes.DropDown;
|
||||
break;
|
||||
case (int)FuelRecordTypes.Picture:
|
||||
questionType = QuestionTypes.Picture;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return questionType;
|
||||
}
|
||||
|
||||
private byte[] GetInspectionPDF(out string fileName)
|
||||
{
|
||||
fileName = "";
|
||||
@ -768,8 +824,25 @@ namespace IronIntel.Contractor.Site
|
||||
FormTemplateInfo templateinfo = JsonConvert.DeserializeObject<FormTemplateInfo>(HttpUtility.HtmlDecode(data));
|
||||
|
||||
var user = UserManagement.GetUserByIID(session.User.UID);
|
||||
if (user.UserType != UserTypes.SupperAdmin && user.UserType != UserTypes.Admin)
|
||||
if (user.UserType == Users.UserTypes.Readonly)
|
||||
return "";
|
||||
else if (user.UserType == Users.UserTypes.Common)
|
||||
{
|
||||
var pc = FleetServiceClientHelper.CreateClient<PermissionProvider>();
|
||||
Tuple<Feature, Permissions>[] pmss = pc.GetUserPermissions(SystemParams.CompanyID, user.IID);
|
||||
if (pmss.Length > 0)
|
||||
{
|
||||
int pkey = teamintelligence ? Feature.TEAM_TEMPLATES : Feature.INSPECTION_TEMPLATES;
|
||||
Tuple<Feature, Permissions> pm = pmss.FirstOrDefault(m => m.Item1.Id == pkey);
|
||||
if (pm.Equals(default(KeyValuePair<int, Permissions>))
|
||||
|| pm.Item2 != Permissions.FullControl)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
if (templateinfo != null)
|
||||
{
|
||||
|
@ -574,6 +574,9 @@ namespace IronIntel.Contractor.Site
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
if (!CheckRight(SystemParams.CompanyID, Foresight.Fleet.Services.User.Feature.MANAGE_DEVICES))
|
||||
return "";
|
||||
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
var data = HttpUtility.HtmlDecode(clientdata);
|
||||
DeviceItem deviceitem = JsonConvert.DeserializeObject<DeviceItem>(data);
|
||||
@ -935,6 +938,8 @@ namespace IronIntel.Contractor.Site
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
if (!CheckRight(SystemParams.CompanyID, Foresight.Fleet.Services.User.Feature.MANAGE_ASSETS))
|
||||
return "";
|
||||
string clientdata = Request.Form["ClientData"];
|
||||
clientdata = HttpUtility.HtmlDecode(clientdata);
|
||||
MachineGroup mg = JsonConvert.DeserializeObject<MachineGroup>(clientdata);
|
||||
@ -1325,7 +1330,8 @@ namespace IronIntel.Contractor.Site
|
||||
try
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user != null)
|
||||
bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
if (user != null && (user.UserType == Users.UserTypes.SupperAdmin || user.UserType == Users.UserTypes.Admin))
|
||||
{
|
||||
string clientdata = Request.Form["ClientData"];
|
||||
clientdata = HttpUtility.HtmlDecode(clientdata);
|
||||
@ -1804,7 +1810,8 @@ namespace IronIntel.Contractor.Site
|
||||
|
||||
bool isallowed = false;
|
||||
if (!loginsession.User.IsForesightUser)
|
||||
isallowed = UserManagement.CheckUserPermission(loginsession.SessionID, loginsession.User.UID, 20);
|
||||
isallowed = CheckRight(SystemParams.CompanyID, Foresight.Fleet.Services.User.Feature.ASSET_ATTRIBUTE_ADJUSTMENT);
|
||||
//isallowed = UserManagement.CheckUserPermission(loginsession.SessionID, loginsession.User.UID, 20);
|
||||
|
||||
if (loginsession.User.IsForesightUser || isallowed)
|
||||
CreateClient<AssetDataAdjustClient>(odo.CustomerID).AdjustOdometer(odo.CustomerID, odo.AssetID, localtime, utctime, odo.Odometer, odo.UOM, odo.Notes, loginsession.User.UID);
|
||||
@ -1838,7 +1845,8 @@ namespace IronIntel.Contractor.Site
|
||||
|
||||
bool isallowed = false;
|
||||
if (!loginsession.User.IsForesightUser)
|
||||
isallowed = UserManagement.CheckUserPermission(loginsession.SessionID, loginsession.User.UID, 20);
|
||||
isallowed = CheckRight(SystemParams.CompanyID, Foresight.Fleet.Services.User.Feature.ASSET_ATTRIBUTE_ADJUSTMENT);
|
||||
//isallowed = UserManagement.CheckUserPermission(loginsession.SessionID, loginsession.User.UID, 20);
|
||||
|
||||
if (loginsession.User.IsForesightUser || isallowed)
|
||||
CreateClient<AssetDataAdjustClient>(odo.CustomerID).AddManuallyInputOdometer(odo.CustomerID, odo.AssetID, loginsession.User.UID, odo.Odometer, odo.UOM, utctime, odo.Notes);
|
||||
@ -2057,7 +2065,8 @@ namespace IronIntel.Contractor.Site
|
||||
|
||||
bool isallowed = false;
|
||||
if (!loginsession.User.IsForesightUser)
|
||||
isallowed = UserManagement.CheckUserPermission(loginsession.SessionID, loginsession.User.UID, 20);
|
||||
isallowed = CheckRight(SystemParams.CompanyID, Foresight.Fleet.Services.User.Feature.ASSET_ATTRIBUTE_ADJUSTMENT);
|
||||
//isallowed = UserManagement.CheckUserPermission(loginsession.SessionID, loginsession.User.UID, 20);
|
||||
if (loginsession.User.IsForesightUser || isallowed)
|
||||
CreateClient<AssetDataAdjustClient>(eng.CustomerID).AdjustEngineHours(eng.CustomerID, eng.AssetID, localtime, utctime, eng.EngineHours, eng.Notes, loginsession.User.UID);
|
||||
return "OK";
|
||||
@ -2090,7 +2099,8 @@ namespace IronIntel.Contractor.Site
|
||||
|
||||
bool isallowed = false;
|
||||
if (!loginsession.User.IsForesightUser)
|
||||
isallowed = UserManagement.CheckUserPermission(loginsession.SessionID, loginsession.User.UID, 20);
|
||||
isallowed = CheckRight(SystemParams.CompanyID, Foresight.Fleet.Services.User.Feature.ASSET_ATTRIBUTE_ADJUSTMENT);
|
||||
//isallowed = UserManagement.CheckUserPermission(loginsession.SessionID, loginsession.User.UID, 20);
|
||||
if (loginsession.User.IsForesightUser || isallowed)
|
||||
CreateClient<AssetDataAdjustClient>(eng.CustomerID).AddManuallyInputEngineHours(eng.CustomerID, eng.AssetID, loginsession.User.UID, eng.EngineHours, utctime, eng.Notes);
|
||||
return "OK";
|
||||
@ -2235,7 +2245,8 @@ namespace IronIntel.Contractor.Site
|
||||
|
||||
bool isallowed = false;
|
||||
if (!loginsession.User.IsForesightUser)
|
||||
isallowed = UserManagement.CheckUserPermission(loginsession.SessionID, loginsession.User.UID, 20);
|
||||
isallowed = CheckRight(SystemParams.CompanyID, Foresight.Fleet.Services.User.Feature.ASSET_ATTRIBUTE_ADJUSTMENT);
|
||||
//isallowed = UserManagement.CheckUserPermission(loginsession.SessionID, loginsession.User.UID, 20);
|
||||
if (loginsession.User.IsForesightUser || isallowed)
|
||||
{
|
||||
if (item.Type == 0)
|
||||
@ -2394,7 +2405,8 @@ namespace IronIntel.Contractor.Site
|
||||
bool result = false;
|
||||
if (session != null)
|
||||
{
|
||||
result = UserManagement.CheckUserPermission(session.SessionID, session.User.UID, 20);
|
||||
result = CheckRight(SystemParams.CompanyID, Foresight.Fleet.Services.User.Feature.ASSET_ATTRIBUTE_ADJUSTMENT);
|
||||
//result = UserManagement.CheckUserPermission(session.SessionID, session.User.UID, 20);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -58,25 +58,25 @@ namespace IronIntel.Contractor.Site
|
||||
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);
|
||||
}
|
||||
}
|
||||
//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
|
||||
|
@ -11,6 +11,10 @@ using System.Web;
|
||||
using IronIntel.Contractor.Users;
|
||||
using Foresight.ServiceModel;
|
||||
using Foresight.Fleet.Services.AssetHealth;
|
||||
using Foresight.Fleet.Services.Device;
|
||||
using Foresight.Fleet.Services;
|
||||
using Foresight.Fleet.Services.Attachment;
|
||||
using IronIntel.Contractor.Attachment;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Maintenance
|
||||
{
|
||||
@ -41,6 +45,21 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
case "GETFUELTYPES":
|
||||
result = GetFuelTypes();
|
||||
break;
|
||||
case "GETFUELRECORDCOMMENTS":
|
||||
result = GetFuelRecordComments();
|
||||
break;
|
||||
case "ADDFUELRECORDCOMMENT":
|
||||
result = AddFuelRecordComment();
|
||||
break;
|
||||
case "GETATTACHMENTS":
|
||||
result = GetAttachments();
|
||||
break;
|
||||
case "ADDATTACHMENT":
|
||||
result = AddAttachment();
|
||||
break;
|
||||
case "DELETEATTACHMENT":
|
||||
result = DeleteAttachment();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -224,5 +243,149 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
}
|
||||
}
|
||||
|
||||
private object GetFuelRecordComments()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
string fuleid = Request.Form["ClientData"];
|
||||
|
||||
CommentInfo[] comments = CreateClient<DocCommentProvider>().GetComments(SystemParams.CompanyID, "FuelRecord", fuleid);
|
||||
List<CommentItem> list = new List<CommentItem>();
|
||||
foreach (var c in comments)
|
||||
{
|
||||
CommentItem citem = new CommentItem();
|
||||
Helper.CloneProperty(citem, c);
|
||||
|
||||
list.Add(citem);
|
||||
}
|
||||
|
||||
return list.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new CommentItem[0];
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private object AddFuelRecordComment()
|
||||
{
|
||||
try
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user != null)
|
||||
{
|
||||
string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
|
||||
string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata);
|
||||
string fuleid = ps[0];
|
||||
string comment = ps[1];
|
||||
|
||||
CreateClient<DocCommentProvider>().SubmitComment(SystemParams.CompanyID, user.IID, "FuelRecord", fuleid.ToString(), comment, false);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
#region Attachment
|
||||
|
||||
private object GetAttachments()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
string fuleid = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
|
||||
|
||||
AttachmentInfo[] atts = CreateClient<AttachmentClient>().GetAttachments(SystemParams.CompanyID, "FuelRecord", fuleid);
|
||||
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 fuleid = 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 = "FuelRecord";
|
||||
attachment.SourceID = fuleid;
|
||||
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
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Foresight.ServiceModel;
|
||||
using Foresight.Fleet.Services.User;
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Services;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
@ -55,6 +56,50 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
}
|
||||
}
|
||||
|
||||
var user = GetCurrentUser();
|
||||
if (user.UserType == Users.UserTypes.Common)
|
||||
{
|
||||
var client = FleetServiceClientHelper.CreateClient<PermissionProvider>();
|
||||
Tuple<Feature, Permissions>[] pmss = client.GetUserPermissions(SystemParams.CompanyID, user.IID);
|
||||
if (pmss.Length > 0)
|
||||
{
|
||||
Tuple<Feature, Permissions> alertpm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.ALERTS_MANAGEMENT);
|
||||
if (alertpm == null)
|
||||
{
|
||||
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_alertsmanagement");
|
||||
list.Remove(item);
|
||||
}
|
||||
Tuple<Feature, Permissions> wopm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.WORK_ORDER);
|
||||
if (wopm == null)
|
||||
{
|
||||
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_workorder");
|
||||
list.Remove(item);
|
||||
}
|
||||
Tuple<Feature, Permissions> pmpm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.PREVENTATIVE_MAINTENANCE);
|
||||
if (pmpm == null)
|
||||
{
|
||||
MaintenanceNavigateItem item1 = list.FirstOrDefault(m => m.ID == "nav_preventative");
|
||||
list.Remove(item1);
|
||||
MaintenanceNavigateItem item2 = list.FirstOrDefault(m => m.ID == "nav_timebased");
|
||||
list.Remove(item2);
|
||||
MaintenanceNavigateItem item3 = list.FirstOrDefault(m => m.ID == "nav_hours");
|
||||
list.Remove(item3);
|
||||
MaintenanceNavigateItem item4 = list.FirstOrDefault(m => m.ID == "nav_absolutedistance");
|
||||
list.Remove(item4);
|
||||
MaintenanceNavigateItem item5 = list.FirstOrDefault(m => m.ID == "nav_relativedistance");
|
||||
list.Remove(item5);
|
||||
MaintenanceNavigateItem item6 = list.FirstOrDefault(m => m.ID == "nav_record");
|
||||
list.Remove(item6);
|
||||
}
|
||||
Tuple<Feature, Permissions> fuelpm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.FUEL_RECORDS);
|
||||
if (fuelpm == null)
|
||||
{
|
||||
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_fuelrecord");
|
||||
list.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
|
@ -33,4 +33,4 @@ using System.Runtime.InteropServices;
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("2.20.430")]
|
||||
[assembly: AssemblyFileVersion("2.20.525")]
|
||||
|
@ -103,9 +103,11 @@ namespace IronIntel.Contractor.Site.Security
|
||||
|
||||
public string SaveGroup()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
var content = Request.Form["ClientData"];
|
||||
content = HttpUtility.HtmlDecode(content);
|
||||
var item = JsonConvert.DeserializeObject<UserGroupInfo>(content);
|
||||
var group = JsonConvert.DeserializeObject<GroupObject>(content);
|
||||
var item = group.GroupInfo;
|
||||
|
||||
// 保存组基本信息,与包含的全部用户
|
||||
if (string.IsNullOrWhiteSpace(item.Name))
|
||||
@ -122,6 +124,11 @@ namespace IronIntel.Contractor.Site.Security
|
||||
else
|
||||
{
|
||||
UserManagement.UpdateGroup(item);
|
||||
if (group.Features != null && group.Features.Length > 0)
|
||||
{
|
||||
var client = CreateClient<Foresight.Fleet.Services.User.PermissionProvider>();
|
||||
client.UpdateFeaturesForUser(SystemParams.CompanyID, item.ID, group.Features, session.User.UID);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@ -152,4 +159,9 @@ namespace IronIntel.Contractor.Site.Security
|
||||
public UserGroupInfo GroupInfo { get; set; }
|
||||
public UserInfo[] Users { get; set; }
|
||||
}
|
||||
public class GroupObject
|
||||
{
|
||||
public UserGroupInfo GroupInfo { get; set; }
|
||||
public KeyValuePair<int, Foresight.Fleet.Services.User.Permissions[]>[] Features { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -93,9 +93,6 @@ namespace IronIntel.Contractor.Site
|
||||
case "GETMACHINELIST":
|
||||
result = GetMachineList();
|
||||
break;
|
||||
case "GETAVAILABLEFEATURES":
|
||||
result = GetAvailableFeatures();
|
||||
break;
|
||||
case "GETFEATURESDEFINEDONUSER":
|
||||
result = GetFeaturesDefinedOnUser();
|
||||
break;
|
||||
@ -114,27 +111,42 @@ namespace IronIntel.Contractor.Site
|
||||
|
||||
#region Security
|
||||
|
||||
private object GetAvailableFeatures()
|
||||
private object GetFeaturesDefinedOnUser()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var useriid = Request.Form["ClientData"];
|
||||
var client = CreateClient<Foresight.Fleet.Services.User.PermissionProvider>();
|
||||
Foresight.Fleet.Services.User.Feature[] features = client.GetAvailableFeatures(SystemParams.CompanyID);
|
||||
Tuple<Foresight.Fleet.Services.User.Feature, Foresight.Fleet.Services.User.Permissions[]>[] features = client.GetFeaturesDefinedOnUser(SystemParams.CompanyID, useriid);
|
||||
|
||||
if (features == null || features.Length == 0)
|
||||
return new FeatureModuleItem[0];
|
||||
|
||||
List<FeatureModuleItem> list = new List<FeatureModuleItem>();
|
||||
List<int> exceptModules = new List<int>()
|
||||
{
|
||||
Foresight.Fleet.Services.User.FeatureModule.MODULE_MAPVIEW,
|
||||
//Foresight.Fleet.Services.User.FeatureModule.MODULE_JOBSITES,
|
||||
Foresight.Fleet.Services.User.FeatureModule.MODULE_CREDENTIAL,
|
||||
Foresight.Fleet.Services.User.FeatureModule.MODULE_SECURITY,
|
||||
Foresight.Fleet.Services.User.FeatureModule.MODULE_FICMANAGEMENT
|
||||
};
|
||||
List<int> exceptFeatures = new List<int>() { Foresight.Fleet.Services.User.Feature.ASSET_GROUP };
|
||||
foreach (var feature in features)
|
||||
{
|
||||
FeatureModuleItem fmi = list.FirstOrDefault(m => m.Module.Id == feature.ModuleId);
|
||||
if (exceptModules.Contains(feature.Item1.ModuleId))
|
||||
continue;
|
||||
if (exceptFeatures.Contains(feature.Item1.Id))
|
||||
continue;
|
||||
FeatureModuleItem fmi = list.FirstOrDefault(m => m.Module.Id == feature.Item1.ModuleId);
|
||||
|
||||
if (fmi == null)
|
||||
{
|
||||
fmi = new FeatureModuleItem();
|
||||
fmi.Module = Foresight.Fleet.Services.User.FeatureModule.GetModule(feature.ModuleId);
|
||||
fmi.Module = Foresight.Fleet.Services.User.FeatureModule.GetModule(feature.Item1.ModuleId);
|
||||
fmi.Features.Add(feature);
|
||||
list.Add(fmi);
|
||||
}
|
||||
@ -153,28 +165,6 @@ namespace IronIntel.Contractor.Site
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
@ -216,6 +206,7 @@ namespace IronIntel.Contractor.Site
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session == null) return "";
|
||||
var ui = UserManagement.GetUserByIID(session.User.UID);
|
||||
|
||||
var content = Request.Form["ClientData"];
|
||||
content = HttpUtility.HtmlDecode(content);
|
||||
@ -248,7 +239,8 @@ namespace IronIntel.Contractor.Site
|
||||
FI.FIC.Models.WorkspaceManager.SaveSubscribeMessageByEmail(user.Subscribe, item.IID);
|
||||
}
|
||||
|
||||
if (user.Features != null && user.Features.Length > 0)
|
||||
if (user.Features != null && user.Features.Length > 0
|
||||
&& (user.UserInfo.UserType < UserTypes.Admin || ui.UserType == UserTypes.SupperAdmin))
|
||||
{
|
||||
var client = CreateClient<Foresight.Fleet.Services.User.PermissionProvider>();
|
||||
client.UpdateFeaturesForUser(SystemParams.CompanyID, item.IID, user.Features, session.User.UID);
|
||||
@ -593,7 +585,8 @@ namespace IronIntel.Contractor.Site
|
||||
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>();
|
||||
public List<Tuple<Foresight.Fleet.Services.User.Feature, Foresight.Fleet.Services.User.Permissions[]>> Features { get; set; } = new List<Tuple<Foresight.Fleet.Services.User.Feature, Foresight.Fleet.Services.User.Permissions[]>>();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user