sync
This commit is contained in:
@ -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();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user