This commit is contained in:
2024-03-26 15:56:31 +08:00
parent 634e8b71ab
commit 0855ae42cd
547 changed files with 94818 additions and 60463 deletions

View File

@ -1,14 +1,20 @@
using Foresight.Data;
using FI.FIC.Contracts.DataObjects.BLObject;
using Foresight.Data;
using Foresight.Fleet.Services.Asset;
using Foresight.Fleet.Services.AssetHealth;
using Foresight.Fleet.Services.AssetHealth.WorkOrder;
using Foresight.Fleet.Services.Device;
using Foresight.Fleet.Services.JobSite;
using Foresight.Fleet.Services.User;
using Foresight.ServiceModel;
using IronIntel.Contractor.ExportExcel;
using IronIntel.Contractor.Machines;
using IronIntel.Contractor.Maintenance;
using Microsoft.SqlServer.Server;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -64,6 +70,9 @@ namespace IronIntel.Contractor.Site.Maintenance
case "GETJOBSITES":
result = GetJobsites();
break;
case "GETALERTCATEGORY":
result = GetAlertCategory();
break;
case "SAVEAUTOACKNOWLEDGEALERTTYPES":
result = SaveAutoAcknowledgeAlertTypes();
break;
@ -85,6 +94,42 @@ namespace IronIntel.Contractor.Site.Maintenance
case "GETASSIGNTOS":
result = GetAssignTos();
break;
case "GETALERTMAPPINGS":
result = GetAlertMappings();
break;
case "SAVEALERTMAPPING":
result = SaveAlertMapping();
break;
case "DELETEALERTMAPPING":
result = DeleteAlertMapping();
break;
case "SAVEALERTMAPPINGITEM":
result = SaveAlertMappingItem();
break;
case "DELETEALERTMAPPINGITEM":
result = DeleteAlertMappingItem();
break;
case "GETALLALERTMAPPINGDATASOURCE":
result = GetAllAlertMappingDataSource();
break;
case "ADDALERTMAPPINGSOURCE":
result = AddAlertMappingSource();
break;
case "GETIMPORTALERTMAPPINGSCOLUMNS":
result = GetImportAlertMappingsColumns();
break;
case "IMPORTALERTMAPPINGS":
result = ImportAlertMappings();
break;
case "GETALERTMAPPINGDEFAULTCATEGORY":
result = GetAlertMappingDefaultCategory();
break;
case "SETALERTMAPPINGDEFAULTCATEGORY":
result = SetAlertMappingDefaultCategory();
break;
case "UPDATEALERTCOMMENT":
result = UpdateAlertComment();
break;
}
}
}
@ -98,6 +143,566 @@ namespace IronIntel.Contractor.Site.Maintenance
Response.End();
}
#region Alert Mappings
private object GetAlertMappings()
{
try
{
var session = GetCurrentLoginSession();
if (session != null)
{
var clientdata = Request.Form["ClientData"];
var searchtxt = HttpUtility.HtmlDecode(clientdata);
AlertMappingInfo[] mappings = CreateClient<AlertProvider>().GetAlertMappings(SystemParams.CompanyID, searchtxt, true);
if (mappings == null || mappings.Length == 0)
return new AlertMappingInfo[0];
return mappings;
}
else
return new AlertMappingInfo[0];
}
catch (Exception ex)
{
return ex.Message;
}
}
private object SaveAlertMapping()
{
try
{
LoginSession se = GetCurrentLoginSession();
if (se != null)
{
var clientdata = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
AlertMappingInfo ami = JsonConvert.DeserializeObject<AlertMappingInfo>(clientdata);
long id = CreateClient<AlertProvider>().SaveAlertMapping(SystemParams.CompanyID, ami);
return id;
}
else
return FailedResult;
}
catch (Foresight.Standard.BusinessException ex)
{
return -1;
}
catch (Exception ex)
{
return ex.Message;
}
}
private string DeleteAlertMapping()
{
try
{
LoginSession se = GetCurrentLoginSession();
if (se != null)
{
var clientdata = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
CreateClient<AlertProvider>().DeleteAlertMapping(SystemParams.CompanyID, Convert.ToInt64(clientdata));
return "";
}
else
return FailedResult;
}
catch (Exception ex)
{
return ex.Message;
}
}
private object SaveAlertMappingItem()
{
try
{
LoginSession se = GetCurrentLoginSession();
if (se != null)
{
var clientdata = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
AlertMappingItem ami = JsonConvert.DeserializeObject<AlertMappingItem>(clientdata);
long itemid = CreateClient<AlertProvider>().SaveAlertMappingItem(SystemParams.CompanyID, ami);
return itemid;
}
else
return FailedResult;
}
catch (Foresight.Standard.BusinessException ex)
{
return -1;
}
catch (Exception ex)
{
return ex.Message;
}
}
private string DeleteAlertMappingItem()
{
try
{
LoginSession se = GetCurrentLoginSession();
if (se != null)
{
var clientdata = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
CreateClient<AlertProvider>().DeleteAlertMappingItem(SystemParams.CompanyID, Convert.ToInt64(clientdata));
return "";
}
else
return FailedResult;
}
catch (Exception ex)
{
return ex.Message;
}
}
private object AddAlertMappingSource()
{
try
{
LoginSession se = GetCurrentLoginSession();
if (se != null)
{
var clientdata = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
AlertMappingSourceInfo source = JsonConvert.DeserializeObject<AlertMappingSourceInfo>(clientdata);
long id = CreateClient<AlertProvider>().AddAlertMappingSource(SystemParams.CompanyID, source);
return id;
}
else
return FailedResult;
}
catch (Exception ex)
{
return ex.Message;
}
}
private object GetAlertMappingDefaultCategory()
{
try
{
var session = GetCurrentLoginSession();
if (session != null)
{
return SystemParams.GetStringParam(SystemParams.AlertMappingDefaultCategory);
}
return "";
}
catch (Exception ex)
{
return ex.Message;
}
}
private object SetAlertMappingDefaultCategory()
{
try
{
var session = GetCurrentLoginSession();
if (session != null)
{
string clientdata = Request.Form["ClientData"];
clientdata = HttpUtility.HtmlDecode(clientdata);
SystemParams.SetStringParam(SystemParams.AlertMappingDefaultCategory, clientdata);
return "";
}
return FailedResult;
}
catch (Exception ex)
{
return ex.Message;
}
}
private object GetAllAlertMappingDataSource()
{
try
{
var session = GetCurrentLoginSession();
if (session != null)
{
var ap = CreateClient<AssetClassProvider>();
AssetMake[] makes = ap.GetAssetMakes("");
AssetModel[] models = ap.GetAssetModels(-1, "");
StringBuilder sbmake = new StringBuilder();
foreach (var m in makes)
{
sbmake.Append(SPLIT_CHAR180 + m.ID.ToString() + SPLIT_CHAR175 + m.Name);
}
if (sbmake.Length > 0)
sbmake = sbmake.Remove(0, 1);
StringBuilder sbmodel = new StringBuilder();
foreach (var m in models)
{
sbmodel.Append(SPLIT_CHAR180 + m.ID.ToString() + SPLIT_CHAR175 + m.Name + SPLIT_CHAR175 + m.MakeId);
}
if (sbmodel.Length > 0)
sbmodel = sbmodel.Remove(0, 1);
AlertMappingSourceInfo[] amsources = CreateClient<AlertProvider>().GetAlertMappingSource(SystemParams.CompanyID, -1);
AlertMappingSourceInfo[] descs = amsources.Where(d => d.Type == 1).OrderBy(d => d.Value).ToArray();
AlertMappingSourceInfo[] categories = amsources.Where(d => d.Type == 2).OrderBy(c => c.Value).ToArray();
StringBuilder sbdescs = new StringBuilder();
foreach (var d in descs)
{
sbdescs.Append(SPLIT_CHAR180 + d.ToString());
}
if (sbdescs.Length > 0)
sbdescs = sbdescs.Remove(0, 1);
StringBuilder sbcategorys = new StringBuilder();
foreach (var c in categories)
{
sbcategorys.Append(SPLIT_CHAR180 + c.ToString());
}
if (sbcategorys.Length > 0)
sbcategorys = sbcategorys.Remove(0, 1);
return new
{
Makes = sbmake.ToString(),
Models = sbmodel.ToString(),
Descriptions = sbdescs.ToString(),
Categories = sbcategorys.ToString()
};
}
else
return null;
}
catch (Exception ex)
{
return ex.Message;
}
}
private object GetImportAlertMappingsColumns()
{
try
{
var session = GetCurrentLoginSession();
if (session != null)
{
string woid = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
HttpPostedFile uploadFile = null;
byte[] iconfilebyte = null;
if (Request.Files.Count > 0)
{
uploadFile = Request.Files[0];
iconfilebyte = ConvertFile2bytes(uploadFile);
}
if (iconfilebyte != null)
{
string[] columns = new ImportFromExcel().LoadExcelColumnHead(iconfilebyte);
if (columns != null && columns.Length > 0)
return columns;
}
}
return new string[0];
}
catch (Exception ex)
{
return ex.Message;
}
}
public class ImportResult
{
public int Count = -1;
public List<AlertMappingClient> Datas = new List<AlertMappingClient>();
}
private object ImportAlertMappings()
{
try
{
int count = 0;
var session = GetCurrentLoginSession();
ImportResult result = new ImportResult();
if (session != null)
{
string p = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
bool getData = Convert.ToBoolean(HttpUtility.HtmlDecode(Request.Form["Get"]));
string selected = HttpUtility.HtmlDecode(Request.Form["SelectedData"]);
StringKeyValue[] kvs = JsonConvert.DeserializeObject<StringKeyValue[]>(p);
HttpPostedFile uploadFile = null;
byte[] iconfilebyte = null;
if (Request.Files.Count > 0)
{
uploadFile = Request.Files[0];
iconfilebyte = ConvertFile2bytes(uploadFile);
}
if (iconfilebyte != null)
{
if (!CheckRight(SystemParams.CompanyID, Feature.ALERTS_MANAGEMENT))
return 0;
DataTable dt = new ImportFromExcel().LoadExcelData(iconfilebyte);
if (dt != null && dt.Rows.Count > 0)
{
List<string> sels = new List<string>();
if (!string.IsNullOrEmpty(selected))
{
string[] ss = selected.Split(',');
sels = ss.ToList();
}
int index = 0;
AlertProvider client = CreateClient<AlertProvider>();
string[] alerttypes = new string[] { "", "Red", "Yellow", "Info" };
var ap = CreateClient<AssetClassProvider>();
AssetMake[] makes = ap.GetAssetMakes("");
List<AssetMake> tempmakes = new List<AssetMake>();
tempmakes.Add(new AssetMake() { ID = -1, Name = "(All)" });
tempmakes.AddRange(makes);
makes = tempmakes.ToArray();
AssetModel[] models = ap.GetAssetModels(-1, "");
List<AssetModel> tempmodels = new List<AssetModel>();
tempmodels.Add(new AssetModel() { ID = -1, Name = "(All)", MakeId = -1 });
tempmodels.AddRange(models);
models = tempmodels.ToArray();
AlertMappingInfo[] allmappings = client.GetAlertMappings(SystemParams.CompanyID, string.Empty, true);
var sources = client.GetAlertMappingSource(SystemParams.CompanyID, -1);
List<AlertMappingSourceInfo> all_source = new List<AlertMappingSourceInfo>();
all_source.AddRange(sources);
foreach (DataRow dr in dt.Rows)
{
if (!getData && sels.Count > 0 && sels.Count >= index + 1 && (sels[index] == "false"))
{
index++;
continue;
}
index++;
AlertMappingClient mappinginfo = null;
try
{
mappinginfo = ConvertToImportAlertMappingInfo(dr, kvs, makes, models);
if (!getData)
{
if (allmappings == null || allmappings.Length == 0)
{
result.Datas.Add(mappinginfo);
continue;
}
if (string.IsNullOrEmpty(mappinginfo.Source) || string.IsNullOrEmpty(mappinginfo.Description))
{
result.Datas.Add(mappinginfo);
continue;
}
if (mappinginfo.Make >= -1 && mappinginfo.Models != null && mappinginfo.Models.Length > 0)
{
if (!alerttypes.Contains(mappinginfo.AlertType))
{
result.Datas.Add(mappinginfo);
continue;
}
AlertMappingInfo ami = allmappings.FirstOrDefault(m => string.Compare(m.Source, mappinginfo.Source, true) == 0
&& string.Compare(m.SPN, mappinginfo.SPN, true) == 0 && string.Compare(m.FMI, mappinginfo.FMI, true) == 0
&& string.Compare(m.Description.Replace("\r", "").Replace("\n", ""), mappinginfo.Description.Replace("\r", "").Replace("\n", ""), true) == 0);
if (ami == null)
{
result.Datas.Add(mappinginfo);
continue;
}
else
{
if (ami.Items == null || ami.Items.Count == 0)
{
result.Datas.Add(mappinginfo);
continue;
}
else
{
string new_modelstr = string.Join(",", mappinginfo.Models.OrderBy(m => m));
AlertMappingItem[] mitems = ami.Items.Where(m => m.Make == mappinginfo.Make).ToArray();
AlertMappingItem newitem = null;
foreach (AlertMappingItem item in mitems)
{
string old_modelstr = string.Join(",", item.Models.OrderBy(m => m));
if (string.Compare(new_modelstr, old_modelstr, true) == 0)
{
newitem = item;
break;
}
}
if (newitem == null)
{
result.Datas.Add(mappinginfo);
continue;
}
else
{
newitem.AlertType = mappinginfo.AlertType;
newitem.Category = mappinginfo.Category;
AddAlertMappingItem(client, all_source, newitem);
}
}
}
}
count++;
}
else
{
result.Datas.Add(mappinginfo);
}
}
catch (Exception e)
{
if (mappinginfo != null)
{
result.Datas.Add(mappinginfo);
}
}
}
}
}
if (!getData)
{
result.Count = count;
}
}
return JsonConvert.SerializeObject(result);
}
catch (Exception ex)
{
return ex.Message;
}
}
private void AddAlertMappingItem(AlertProvider client, List<AlertMappingSourceInfo> all_source, AlertMappingItem item)
{
if (!string.IsNullOrWhiteSpace(item.Category))
{
AlertMappingSourceInfo oldsource = all_source.FirstOrDefault(m => m.Type == 2 && string.Compare(m.Value, item.Category, true) == 0);
if (oldsource == null)
{
AlertMappingSourceInfo newsource = new AlertMappingSourceInfo();
newsource.Type = 2;
newsource.Value = item.Category;
newsource.Id = client.AddAlertMappingSource(SystemParams.CompanyID, newsource);
all_source.Add(newsource);
item.CategoryId = newsource.Id;
}
else
item.CategoryId = oldsource.Id;
}
else
{
item.CategoryId = -1;
}
item.Id = client.SaveAlertMappingItem(SystemParams.CompanyID, item);
}
private AlertMappingClient ConvertToImportAlertMappingInfo(DataRow dr, StringKeyValue[] kvs, AssetMake[] makes, AssetModel[] models)
{
AlertMappingClient mapping = new AlertMappingClient();
foreach (StringKeyValue kv in kvs)
{
if (string.IsNullOrEmpty(kv.Key) || string.IsNullOrEmpty(kv.Value))
{
continue;
}
if (dr[kv.Value] == DBNull.Value || dr[kv.Value] == null)
{
continue;
}
if (string.Compare(kv.Key, "Source", true) == 0)
{
string s = dr[kv.Value].ToString().Trim();
mapping.Source = s;
}
if (string.Compare(kv.Key, "SPN", true) == 0)
{
string s = dr[kv.Value].ToString().Trim();
mapping.SPN = s;
}
if (string.Compare(kv.Key, "FMI", true) == 0)
{
string s = dr[kv.Value].ToString().Trim();
mapping.FMI = s;
}
else if (string.Compare(kv.Key, "Description", true) == 0)
{
mapping.Description = dr[kv.Value].ToString().Trim();
}
else if (string.Compare(kv.Key, "Make", true) == 0)
{
string s = dr[kv.Value].ToString().Trim();
mapping.MakeName = s;
if (!string.IsNullOrWhiteSpace(s))
{
if (string.Compare("(All)", s, true) == 0)
mapping.Make = -1;
else
{
AssetMake make = makes.FirstOrDefault(m => string.Compare(m.Name, s, true) == 0);
if (make != null)
mapping.Make = make.ID;
}
}
}
else if (string.Compare(kv.Key, "Models", true) == 0)
{
string s = dr[kv.Value].ToString().Trim();
if (!string.IsNullOrWhiteSpace(s))
{
mapping.ModelNames = s;
string[] modelsstr = s.Split(',');
if (modelsstr != null && modelsstr.Length > 0)
{
List<int> lsmodel = new List<int>();
foreach (string str in modelsstr)
{
if (!string.IsNullOrWhiteSpace(str))
{
if (string.Compare("(All)", str, true) == 0)
lsmodel.Add(-1);
else
{
AssetModel model = models.FirstOrDefault(m => mapping.Make == m.MakeId && string.Compare(m.Name, str, true) == 0);
if (model != null)
lsmodel.Add(model.ID);
}
}
}
mapping.Models = lsmodel.ToArray();
}
}
}
else if (string.Compare(kv.Key, "AlertType", true) == 0)
{
mapping.AlertType = dr[kv.Value].ToString().Trim();
}
else if (string.Compare(kv.Key, "Category", true) == 0)
{
mapping.Category = dr[kv.Value].ToString().Trim();
}
}
return mapping;
}
#endregion
private object GetAlerts()
{
try
@ -134,27 +739,33 @@ namespace IronIntel.Contractor.Site.Maintenance
AssetAlertGridViewItem[] assetalerts = null;
if (alertparam.AssetID > 0)
assetalerts = CreateClient<WorkOrderProvider>().GetAssetAlertGridViewItemsByAsset(SystemParams.CompanyID, alertparam.AssetID, beginDate, endDate, alertparam.AlertTypes, alertparam.JobSites, assigned, completed, alertparam.SearchText, alertparam.IncludeunCompleted);
assetalerts = CreateClient<WorkOrderProvider>().GetAssetAlertGridViewItemsByAsset(SystemParams.CompanyID, alertparam.AssetID, beginDate, endDate, alertparam.AlertTypes, alertparam.JobSites, assigned, completed, alertparam.SearchText, alertparam.IncludeunCompleted, alertparam.Category);
else
assetalerts = CreateClient<AlertProvider>().GetAssetAlertGridViewItems(SystemParams.CompanyID, beginDate, endDate, alertparam.AlertTypes, alertparam.AssetGroups, alertparam.JobSites, assigned, completed, alertparam.SearchText, session.User.UID, alertparam.IncludeunCompleted);
assetalerts = CreateClient<AlertProvider>().GetAssetAlertGridViewItems(SystemParams.CompanyID, beginDate, endDate, alertparam.AlertTypes, alertparam.AssetGroups, alertparam.JobSites, assigned, completed, alertparam.SearchText, session.User.UID, alertparam.IncludeunCompleted, alertparam.Category);
if (assetalerts == null || assetalerts.Length == 0)
return new AlertInfo[0];
List<AlertInfo> list = new List<AlertInfo>();
return string.Empty;
StringBuilder sb = new StringBuilder();
foreach (AssetAlertGridViewItem item in assetalerts)
{
AlertInfo ai = ConvertAlertObj(item);
list.Add(ai);
sb.Append(SPLIT_CHAR180 + ai.ToString());
}
return list.ToArray();
if (sb.Length > 0)
{
return sb.ToString().Substring(1);
}
return string.Empty;
}
else
return new AlertInfo[0];
return string.Empty;
}
catch (Exception ex)
{
AddLog("ERROR", "AlertsBasePage.GetAlerts", ex.Message, ex.ToString());
return ex.Message;
return new string[] { ex.Message };
}
}
@ -195,12 +806,12 @@ namespace IronIntel.Contractor.Site.Maintenance
AssetAlertGridViewItem[] assetalerts = null;
if (alertparam.AssetID > 0)
assetalerts = CreateClient<WorkOrderProvider>().GetAssetAlertGridViewItemsByAsset(SystemParams.CompanyID, alertparam.AssetID, beginDate, endDate, alertparam.AlertTypes, alertparam.JobSites, assigned, completed, alertparam.SearchText, alertparam.IncludeunCompleted);
assetalerts = CreateClient<WorkOrderProvider>().GetAssetAlertGridViewItemsByAsset(SystemParams.CompanyID, alertparam.AssetID, beginDate, endDate, alertparam.AlertTypes, alertparam.JobSites, assigned, completed, alertparam.SearchText, alertparam.IncludeunCompleted, alertparam.Category);
else
assetalerts = CreateClient<AlertProvider>().GetAssetAlertGridViewItems(SystemParams.CompanyID, beginDate, endDate, alertparam.AlertTypes, alertparam.AssetGroups, alertparam.JobSites, assigned, completed, alertparam.SearchText, session.User.UID, alertparam.IncludeunCompleted);
assetalerts = CreateClient<AlertProvider>().GetAssetAlertGridViewItems(SystemParams.CompanyID, beginDate, endDate, alertparam.AlertTypes, alertparam.AssetGroups, alertparam.JobSites, assigned, completed, alertparam.SearchText, session.User.UID, alertparam.IncludeunCompleted, alertparam.Category);
if (assetalerts == null || assetalerts.Length == 0)
return new MachineInfoForAlert[0];
return string.Empty;
List<MachineInfoForAlert> machinealerts = new List<MachineInfoForAlert>();
foreach (AssetAlertGridViewItem item in assetalerts)
@ -236,15 +847,24 @@ namespace IronIntel.Contractor.Site.Maintenance
mi.LatestAlertDateTime = ai.AlertLocalTime;
}
return machinealerts.ToArray();
StringBuilder sb = new StringBuilder();
foreach (MachineInfoForAlert mi in machinealerts)
{
sb.Append(SPLIT_CHAR183 + mi.ToString());
}
if (sb.Length > 0)
{
return sb.ToString().Substring(1);
}
return string.Empty;
}
else
return new MachineInfoForAlert[0];
return string.Empty;
}
catch (Exception ex)
{
AddLog("ERROR", "AlertsBasePage.GetAlerts", ex.Message, ex.ToString());
return ex.Message;
return new string[] { ex.Message };
}
}
@ -291,6 +911,7 @@ namespace IronIntel.Contractor.Site.Maintenance
ai.Recurring = item.Recurring;
ai.Priority = item.Priority;
ai.ExpectedCost = item.ExpectedCost;
ai.Comment = item.Comment;
return ai;
}
@ -300,6 +921,7 @@ namespace IronIntel.Contractor.Site.Maintenance
AlertInfo ai = new AlertInfo();
ai.AlertID = item.ID;
ai.WorkOrderID = item.WorkOrderId;
ai.WorkOrderNumber = item.WorkOrderNumber;
ai.WorkOrderStatus = item.WorkOrderStatus;
ai.AlertType = item.AlertType;
ai.AlertTime_UTC = item.LastAlertTime;
@ -325,6 +947,7 @@ namespace IronIntel.Contractor.Site.Maintenance
//ai.Recurring = item.Recurring;
//ai.Priority = item.Priority;
//ai.ExpectedCost = item.ExpectedCost;
ai.Comment = item.Comment;
return ai;
}
@ -351,6 +974,7 @@ namespace IronIntel.Contractor.Site.Maintenance
ai.AcknowledgedTime_UTC = item.AcknowledgedTime;
ai.AcknowledgedTime_Local = item.AcknowledgedLocalTime;
ai.AcknowledgedComment = item.AcknowledgedComment;
ai.Comment = item.Comment;
return ai;
}
@ -377,27 +1001,34 @@ namespace IronIntel.Contractor.Site.Maintenance
alertparam.AlertStatus = new string[0];
AcknowledgedAlertItem[] ackalerts = CreateClient<AlertProvider>().GetAcknowledgedAlerts(SystemParams.CompanyID, beginDate, endDate, alertparam.AlertTypes, alertparam.AssetGroups, alertparam.SearchText);
if (ackalerts == null || ackalerts.Length == 0)
return new AlertInfo[0];
List<AlertInfo> list = new List<AlertInfo>();
return string.Empty;
if (alertparam.AssetID > 0)
ackalerts = ackalerts.Where(m => m.AssetID == alertparam.AssetID).ToArray();
if (ackalerts == null || ackalerts.Length == 0)
return string.Empty;
StringBuilder sb = new StringBuilder();
foreach (AcknowledgedAlertItem item in ackalerts)
{
AlertInfo ai = ConvertAlertObj2(item);
list.Add(ai);
sb.Append(SPLIT_CHAR180 + ai.ToString());
}
if (sb.Length > 0)
{
return sb.ToString().Substring(1);
}
if (list == null)
return new AlertInfo[0];
if (alertparam.AssetID > 0)
list = list.Where(m => m.MachineID == alertparam.AssetID).ToList();
return list.ToArray();
return string.Empty;
}
else
return new AlertInfo[0];
return string.Empty;
}
catch (Exception ex)
{
AddLog("ERROR", "AlertsBasePage.GetAcknowledgedAlerts", ex.Message, ex.ToString());
return ex.Message;
return new string[] { ex.Message };
}
}
@ -439,10 +1070,10 @@ namespace IronIntel.Contractor.Site.Maintenance
long[] list = JsonConvert.DeserializeObject<long[]>(ids);
AlertManager am = new AlertManager(SystemParams.DataDbConnectionString);
am.AcknowledgeAlert(se.User.UID, list, acknowledgmentcomment);
return "OK";
return OkResult;
}
else
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -471,10 +1102,10 @@ namespace IronIntel.Contractor.Site.Maintenance
wp.AddOrRemoveAlertsFromWorkOrder(SystemParams.CompanyID, workorderid, added, true);
if (deleted.Length > 0)
wp.AddOrRemoveAlertsFromWorkOrder(SystemParams.CompanyID, workorderid, deleted, false);
return "OK";
return OkResult;
}
else
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -618,10 +1249,10 @@ namespace IronIntel.Contractor.Site.Maintenance
string[] alerttypes = JsonConvert.DeserializeObject<string[]>(clientdata);
CreateClient<WorkOrderProvider>().SaveAutoAcknowledgeAlertTypes(SystemParams.CompanyID, alerttypes, session.User.UID);
return "OK";
return OkResult;
}
else
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -735,7 +1366,7 @@ namespace IronIntel.Contractor.Site.Maintenance
var session = GetCurrentLoginSession();
if (session != null)
{
var users = Users.UserManagement.GetActiveUsers(session.SessionID, SystemParams.CompanyID);
var users = Users.UserManagement.GetActiveUsers(GetLanguageCookie(), session.SessionID, SystemParams.CompanyID);
List<StringKeyValue> list = new List<StringKeyValue>();
foreach (var u in users)
{
@ -788,6 +1419,34 @@ namespace IronIntel.Contractor.Site.Maintenance
return ex.Message;
}
}
private object GetAlertCategory()
{
try
{
var session = GetCurrentLoginSession();
if (session != null)
{
AlertMappingSourceInfo[] sources = CreateClient<AlertProvider>().GetAlertMappingSource(SystemParams.CompanyID, 2);
List<StringKeyValue> list = new List<StringKeyValue>();
foreach (AlertMappingSourceInfo si in sources)
{
StringKeyValue kv = new StringKeyValue();
kv.Key = si.Id.ToString();
kv.Value = si.Value;
list.Add(kv);
}
return list.OrderBy((m) => m.Value).ToArray();
}
else
return new StringKeyValue[0];
}
catch (Exception ex)
{
AddLog("ERROR", "AlertsBasePage.GetAlertCategory", ex.Message, ex.ToString());
return ex.Message;
}
}
private object GetAlertTypes()
{
@ -795,8 +1454,16 @@ namespace IronIntel.Contractor.Site.Maintenance
{
if (GetCurrentLoginSession() != null)
{
AlertManager am = new AlertManager(SystemParams.DataDbConnectionString);
return am.GetAlertTypes(); ;
Foresight.Standard.StringKeyValue[] types = CreateClient<AlertProvider>().GetAlertTypes(SystemParams.CompanyID);
List<StringKeyValue> list = new List<StringKeyValue>();
foreach (var t in types)
{
StringKeyValue kv = new StringKeyValue();
kv.Key = t.Key;
kv.Value = t.Value;
list.Add(kv);
}
return list.ToArray();
}
else
return new StringKeyValue[0];
@ -854,7 +1521,7 @@ namespace IronIntel.Contractor.Site.Maintenance
return new string[] { generator.Id.ToString(), "" };
}
else
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -875,7 +1542,7 @@ namespace IronIntel.Contractor.Site.Maintenance
return new string[0];
}
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -885,6 +1552,33 @@ namespace IronIntel.Contractor.Site.Maintenance
}
#endregion
private object UpdateAlertComment()
{
try
{
if (GetCurrentLoginSession() != null)
{
var clientdata = HttpUtility.UrlDecode(Request.Form["ClientData"]);
string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata);
if (ps.Length < 2)
{
throw new ArgumentOutOfRangeException();
}
var ids = ps[0].Split(',').Select(s => long.Parse(s)).ToArray();
var provider = CreateClient<AlertProvider>();
provider.SetAlertComment(SystemParams.CompanyID, ids, ps[1]);
return OkResult;
}
throw new UnauthorizedAccessException();
}
catch (Exception ex)
{
AddLog("ERROR", "AlertsBasePage.UpdateAlertComment", ex.Message, ex.ToString());
return ex.Message;
}
}
}
public class AlertsLisenceItem

View File

@ -180,7 +180,7 @@ namespace IronIntel.Contractor.Site.Maintenance
return fuleid;
}
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -200,9 +200,9 @@ namespace IronIntel.Contractor.Site.Maintenance
CreateClient<FuelManagementClient>().DeleteFuelRecord(SystemParams.CompanyID, fuleid, session.User.UID);
return "OK";
return OkResult;
}
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -344,9 +344,9 @@ namespace IronIntel.Contractor.Site.Maintenance
string FileName = uploadFile == null ? "" : uploadFile.FileName;
long attid = CreateClient<AttachmentProvider>().AddAttachment(SystemParams.CompanyID, "FuelRecord", fuleid, FileName, "", iconfilebyte);
return "OK";
return OkResult;
}
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -364,9 +364,9 @@ namespace IronIntel.Contractor.Site.Maintenance
string attachid = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
CreateClient<AttachmentProvider>().DeleteAttachment(SystemParams.CompanyID, long.Parse(attachid));
return "OK";
return OkResult;
}
return "Failed";
return FailedResult;
}
catch (Exception ex)
{

View File

@ -330,7 +330,7 @@ namespace IronIntel.Contractor.Site.Maintenance
private void GetUsersData()
{
UserInfo[] user = UserManagement.GetUsers();
UserInfo[] user = UserManagement.GetUsers(string.Empty, string.Empty, GetLanguageCookie());
user = user.OrderBy((u) => u.DisplayName).ToArray();
string json = JsonConvert.SerializeObject(user);
Response.Write(json);
@ -416,9 +416,9 @@ namespace IronIntel.Contractor.Site.Maintenance
string FileName = uploadFile == null ? "" : uploadFile.FileName;
long attid = CreateClient<AttachmentProvider>().AddAttachment(SystemParams.CompanyID, "MaintenanceLog", woid, FileName, "", iconfilebyte);
return "OK";
return OkResult;
}
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -436,9 +436,9 @@ namespace IronIntel.Contractor.Site.Maintenance
string attachid = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
CreateClient<AttachmentProvider>().DeleteAttachment(SystemParams.CompanyID, long.Parse(attachid));
return "OK";
return OkResult;
}
return "Failed";
return FailedResult;
}
catch (Exception ex)
{

View File

@ -49,6 +49,11 @@ namespace IronIntel.Contractor.Site.Maintenance
{
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_alertsmanagement");
list.Remove(item);
item = list.FirstOrDefault(m => m.ID == "nav_alertsmappings");
list.Remove(item);
MaintenanceNavigateItem item1 = list.FirstOrDefault(m => m.ID == "nav_alertsmappings");
list.Remove(item1);
}
var fuelitem = license.Items.FirstOrDefault(m => m.Key == "FuelRecords");
if (fuelitem == null || !Helper.IsTrue(fuelitem.Value))
@ -85,6 +90,12 @@ namespace IronIntel.Contractor.Site.Maintenance
}
var user = GetCurrentUser();
if (user.UserType != Users.UserTypes.SupperAdmin)
{
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_alertsmappings");
if (item != null)
list.Remove(item);
}
if (user.UserType == Users.UserTypes.Common)
{
var client = CreateClient<PermissionProvider>();
@ -108,6 +119,11 @@ namespace IronIntel.Contractor.Site.Maintenance
{
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_alertsmanagement");
list.Remove(item);
item = list.FirstOrDefault(m => m.ID == "nav_alertsmappings");
list.Remove(item);
MaintenanceNavigateItem item1 = list.FirstOrDefault(m => m.ID == "nav_alertsmappings");
list.Remove(item1);
}
Tuple<Feature, Permissions> pmpm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.PREVENTATIVE_MAINTENANCE);
if (pmpm == null)
@ -175,6 +191,13 @@ namespace IronIntel.Contractor.Site.Maintenance
item1.IconPath = "img/alert.png";
list.Add(item1);
MaintenanceNavigateItem alertmappingsitem = new MaintenanceNavigateItem();
alertmappingsitem.ID = "nav_alertsmappings";
alertmappingsitem.Title = "Alert Mappings";
alertmappingsitem.Url = "AlertMappingManagement.aspx";
alertmappingsitem.IconPath = "img/alert.png";
list.Add(alertmappingsitem);
MaintenanceNavigateItem item3 = new MaintenanceNavigateItem();
item3.ID = "nav_maintenanceschedule";
item3.Title = "Maintenance Schedules";

View File

@ -190,7 +190,7 @@ namespace IronIntel.Contractor.Site.Maintenance
return string.Empty;
}
else
return "Failed";
return FailedResult;
}
catch (Exception ex)
@ -235,14 +235,15 @@ namespace IronIntel.Contractor.Site.Maintenance
PmScheduleType = item.Type,
PmScheduleUom = item.ScheduleUom,
Notes = item.Notes,
Intervals = item.Intervals
Intervals = item.Intervals,
Enabled = item.Enabled
};
MaintenanceManagement.UpdatePmSchedule(session.SessionID, si, session.User.UID);
return si.PmScheduleID;
}
else
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -278,7 +279,7 @@ namespace IronIntel.Contractor.Site.Maintenance
return string.Empty;
}
else
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -310,7 +311,7 @@ namespace IronIntel.Contractor.Site.Maintenance
return string.Empty;
}
else
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -330,7 +331,7 @@ namespace IronIntel.Contractor.Site.Maintenance
return string.Empty;
}
else
return "Failed";
return FailedResult;
}
catch (Exception ex)
@ -465,6 +466,7 @@ namespace IronIntel.Contractor.Site.Maintenance
}
public double? StartHours { get; set; }
public DateTime? StartDate { get; set; }
public int TypeID { get; set; }
public string TypeName { get; set; }
public int AlertsCount { get; set; }
public int UnMaintainedAlert { get; set; }
@ -512,6 +514,7 @@ namespace IronIntel.Contractor.Site.Maintenance
public string Notes { get; set; }
public PmIntervalItem[] Intervals { get; set; }
public bool Enabled { get; set; }
}
}
}

File diff suppressed because it is too large Load Diff