sync
This commit is contained in:
@ -1,23 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="DbConntionString" value="Data Source=192.168.25.215\ironintel;Initial Catalog=IRONINTEL_IRONDEV;Integrated Security=false;User ID=fi;Password=database"/>
|
||||
<add key="JRE_IronIntelDb" value="Data Source=192.168.25.215\ironintel;Initial Catalog=JRE_IRONINTEL;Integrated Security=false;User ID=fi;Password=database"/>
|
||||
<add key="ClientSettingsProvider.ServiceUri" value=""/>
|
||||
<add key="DbConntionString" value="Data Source=192.168.25.215\ironintel;Initial Catalog=FORESIGHT_FLV_IICON004;Integrated Security=false;User ID=fi;Password=database" />
|
||||
<add key="JRE_IronIntelDb" value="Data Source=192.168.25.215\ironintel;Initial Catalog=JRE_IRONINTEL;Integrated Security=false;User ID=fi;Password=database" />
|
||||
<add key="ClientSettingsProvider.ServiceUri" value="" />
|
||||
</appSettings>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
<system.web>
|
||||
<membership defaultProvider="ClientAuthenticationMembershipProvider">
|
||||
<providers>
|
||||
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri=""/>
|
||||
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
|
||||
</providers>
|
||||
</membership>
|
||||
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
|
||||
<providers>
|
||||
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400"/>
|
||||
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
|
||||
</providers>
|
||||
</roleManager>
|
||||
</system.web>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Data.SqlClient" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.6.1.1" newVersion="4.6.1.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
|
@ -1,23 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.Attachment
|
||||
{
|
||||
public class AttachmentItem
|
||||
{
|
||||
public long ID { get; set; }
|
||||
public string StringID { get; set; }//为了兼容旧数据库中的ATTACHES.ATTACHID字段,旧数据库中的表由Workorder和MaintanceLog在使用
|
||||
public string FileName { get; set; }
|
||||
public string Source { get; set; }
|
||||
public string SourceID { get; set; }
|
||||
public string AddedByUserIID { get; set; }
|
||||
public string AddedByUserName { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public DateTime AddedOn { get; set; }
|
||||
public string AddedOnStr { get { return AddedOn.ToString(); } }
|
||||
public byte[] FileData { get; set; }
|
||||
}
|
||||
}
|
@ -8,8 +8,7 @@ using Foresight.ServiceModel;
|
||||
using Newtonsoft.Json;
|
||||
using Foresight.Data;
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Contractor.Attachment;
|
||||
using Foresight.Fleet.Services.Attachment;
|
||||
using Foresight.Fleet.Services;
|
||||
|
||||
namespace IronIntel.Contractor
|
||||
{
|
||||
@ -152,24 +151,12 @@ namespace IronIntel.Contractor
|
||||
db.ExecSQL(sql);
|
||||
}
|
||||
|
||||
public static AttachmentItem GetAttachment(string sessionid, string custid, long attid)
|
||||
public static Tuple<string, byte[]> GetAttachment(string sessionid, string custid, long attid)
|
||||
{
|
||||
if (string.IsNullOrEmpty(custid))
|
||||
custid = SystemParams.CompanyID;
|
||||
Foresight.Fleet.Services.Attachment.AttachmentInfo att = FleetServiceClientHelper.CreateClient<AttachmentClient>(custid, sessionid).GetAttachment(custid, attid);
|
||||
AttachmentItem item = new AttachmentItem();
|
||||
Helper.CloneProperty(item, att);
|
||||
return item;
|
||||
}
|
||||
|
||||
public static AttachmentItem GetAttachmentLegacy(string sessionid, string custid, string attid)
|
||||
{
|
||||
if (string.IsNullOrEmpty(custid))
|
||||
custid = SystemParams.CompanyID;
|
||||
Foresight.Fleet.Services.Attachment.AttachmentInfo att = FleetServiceClientHelper.CreateClient<AttachmentClient>(custid, sessionid).GetAttachmentLegacy(custid, attid);
|
||||
AttachmentItem item = new AttachmentItem();
|
||||
Helper.CloneProperty(item, att);
|
||||
return item;
|
||||
Tuple<string, byte[]> attr = FleetServiceClientHelper.CreateClient<AttachmentProvider>(custid, sessionid).GetAttachmentData(custid, attid);
|
||||
return attr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,94 +3,29 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Foresight.Cache;
|
||||
using Foresight.Cache.AspNet;
|
||||
using Foresight.Cache.Redis;
|
||||
using Foresight.Service.Cache;
|
||||
using Foresight.Fleet.Services.SystemOption;
|
||||
|
||||
namespace IronIntel.Contractor
|
||||
{
|
||||
public static class CacheManager
|
||||
{
|
||||
public static void Dispose()
|
||||
{
|
||||
if (_Client != null)
|
||||
{
|
||||
_Client.Dispose();
|
||||
_Client = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static CacheClient _Client = null;
|
||||
private static object _sycobj = new object();
|
||||
|
||||
private static FIRedisCacheClient CreateRedisClient()
|
||||
private static CacheClient CreateRedisClient()
|
||||
{
|
||||
string[] servers = FleetServiceClientHelper.CreateClient<Foresight.Fleet.Services.SystemUtil>().GetRedisServers();
|
||||
string[] servers = FleetServiceClientHelper.CreateClient<SystemOptionProvider>().GetCacheServiceAddress(SystemParams.CompanyID);
|
||||
if ((servers == null) || (servers.Length == 0))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<RedisNode> ls = new List<RedisNode>();
|
||||
foreach (string srv in servers)
|
||||
{
|
||||
try
|
||||
{
|
||||
RedisNode node = CreateRedisNode(srv);
|
||||
ls.Add(node);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("Error", typeof(CacheManager).FullName + ".CreateRedisClient", "Create RedisNode failed: " + srv, ex.ToString());
|
||||
}
|
||||
}
|
||||
if (ls.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new FIRedisCacheClient("IRONINTEL_" + SystemParams.CompanyID.ToUpper(), ls);
|
||||
return new CacheClient("IRONINTEL_" + SystemParams.CompanyID.ToUpper(), servers);
|
||||
}
|
||||
}
|
||||
|
||||
private static RedisNode CreateRedisNode(string server)
|
||||
{
|
||||
string[] address = server.Split(new char[] { ':' });
|
||||
int port = -1;
|
||||
if (!int.TryParse(address[1], out port))
|
||||
{
|
||||
port = -1;
|
||||
}
|
||||
int weight = 100;
|
||||
if (!int.TryParse(address[2], out weight))
|
||||
{
|
||||
weight = 100;
|
||||
}
|
||||
RedisNode node = new RedisNode(address[0], port, weight);
|
||||
return node;
|
||||
}
|
||||
|
||||
private static void InitCacheClient()
|
||||
{
|
||||
FIRedisCacheClient fc = null;
|
||||
try
|
||||
{
|
||||
fc = CreateRedisClient();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("Error", typeof(CacheManager).FullName + ".InitCacheClient", "Create Redis client failed", ex.ToString());
|
||||
}
|
||||
if (fc != null)
|
||||
{
|
||||
_Client = fc;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
_Client = new AspNetCacheManager("IRONINTEL_" + SystemParams.CompanyID.ToUpper());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static CacheClient Client
|
||||
{
|
||||
get
|
||||
@ -101,7 +36,7 @@ namespace IronIntel.Contractor
|
||||
{
|
||||
if (_Client == null)
|
||||
{
|
||||
InitCacheClient();
|
||||
_Client = CreateRedisClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
using Foresight.Data;
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Contractor.Machines;
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
using IronIntel.Contractor.MapView;
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using IronIntel.Services.Customers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
@ -84,9 +83,9 @@ namespace IronIntel.Contractor.Contact
|
||||
return new MaintenanceMachineInfo[0];
|
||||
}
|
||||
MachineManagement.RefreshBaseData();
|
||||
MachineMake[] makes = MachineManagement.GetMachineMakes();
|
||||
MachineModel[] models = MachineManagement.GetMachineModels();
|
||||
MachineType[] types = MachineManagement.GetMachineTypes();
|
||||
AssetMake[] makes = MachineManagement.GetMachineMakes();
|
||||
AssetModel[] models = MachineManagement.GetMachineModels();
|
||||
AssetType[] types = MachineManagement.GetMachineTypes();
|
||||
List<MaintenanceMachineInfo> ls = new List<MaintenanceMachineInfo>();
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
@ -113,23 +112,6 @@ namespace IronIntel.Contractor.Contact
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveMachineContacts(FISqlConnection db, string machineid, string contractorid, string[] contactids)
|
||||
{
|
||||
const string SQL_R = "update RELATIONSHIP set REMOVEDON=GETUTCDATE(),REMOVED=1 where RELATIONSHIPTYPEID='MachineContact' and REMOVED<>1 and RELATEDID={0}";
|
||||
const string SQL = @"if exists(select 1 from RELATIONSHIP where RELATIONSHIPTYPEID='MachineContact' and RELATEDID={0} and PRIMARYID={1}) update RELATIONSHIP
|
||||
set REMOVEDON=null,REMOVED=0 where RELATIONSHIPTYPEID='MachineContact' and RELATEDID={0} and PRIMARYID={1} else insert into RELATIONSHIP
|
||||
(RELATIONSHIPID,RELATIONSHIPTYPEID,CONTRACTORID,RELATEDID,PRIMARYID,ADDEDON) values({3},'MachineContact',{2},{0},{1},GETUTCDATE())";
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
db.ExecSQL(SQL_R, machineid);
|
||||
|
||||
foreach (var cid in contactids)
|
||||
{
|
||||
db.ExecSQL(SQL, machineid, cid, contractorid, Guid.NewGuid().ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static ContactInfo ConvertToContactInfo(DataRow dr)
|
||||
{
|
||||
ContactInfo ci = new ContactInfo();
|
||||
@ -143,8 +125,6 @@ namespace IronIntel.Contractor.Contact
|
||||
return ci;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static JobSiteViewItem[] GetContactJobsitesByID(string contactid)
|
||||
{
|
||||
const string SQL = @"select a.RELATEDID as JOBSITEID,JOBSITENAME,LATITUDE,LONGITUDE,RADIUS,RADUIS_UOM,b.CONTRACTORID,COLOR,NOTES,STARTDATE,ENDDATE,POLYGON,BASEONMACHINEID from RELATIONSHIP a,JOBSITES b
|
||||
@ -211,82 +191,5 @@ namespace IronIntel.Contractor.Contact
|
||||
js.BaseOnMachineID = FIDbAccess.GetFieldInt(dr["BASEONMACHINEID"], 0);
|
||||
return js;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取机器Contact和机器的对应关系
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Dictionary<int, List<string>> GetContactMachines(FISqlConnection db)
|
||||
{
|
||||
const string SQL_C = "select PRIMARYID,RELATEDID from RELATIONSHIP where RELATIONSHIPTYPEID='MachineContact' and REMOVED<>1";
|
||||
|
||||
Dictionary<int, List<string>> result = new Dictionary<int, List<string>>();
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
DataTable tb = db.GetDataTableBySQL(SQL_C);
|
||||
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
int machineid = FIDbAccess.GetFieldInt(dr["RELATEDID"], 0);
|
||||
string contactid = FIDbAccess.GetFieldString(dr["PRIMARYID"], "");
|
||||
if (!result.ContainsKey(machineid))
|
||||
result[machineid] = new List<string>();
|
||||
result[machineid].Add(contactid);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取机器对应的ContactID
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string[] GetContactByMachineID(FISqlConnection db, long machineid)
|
||||
{
|
||||
const string SQL_C = "select PRIMARYID from RELATIONSHIP where RELATIONSHIPTYPEID='MachineContact' and REMOVED<>1 and RELATEDID={0}";
|
||||
|
||||
Dictionary<int, List<string>> result = new Dictionary<int, List<string>>();
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
DataTable tb = db.GetDataTableBySQL(SQL_C, machineid);
|
||||
if (tb.Rows.Count <= 0)
|
||||
return new string[0];
|
||||
|
||||
List<string> list = new List<string>();
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
string contactid = FIDbAccess.GetFieldString(dr["PRIMARYID"], "");
|
||||
list.Add(contactid);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
|
||||
public static ContactInfo[] GetContactByAssetID(long assetid, string companyid)
|
||||
{
|
||||
const string SQL = @"select CONTACTID,CONTACTNAME,USERIID,NOTES,CONTACTTYPE,EMAILADDRESS,TEXTADDRESS from CONTACT where
|
||||
CONTACTID in(select PRIMARYID from RELATIONSHIP where RELATIONSHIPTYPEID='MachineContact' and REMOVED<>1 and RELATEDID={0} union all
|
||||
select rs.PRIMARYID from RELATIONSHIP rs left join JOBSITEMACHINES jm on rs.RELATEDID=jm.JOBSITEID where rs.RELATIONSHIPTYPEID='ContactJobsite' and rs.REMOVED<>1 and jm.MACHINEID={0})";
|
||||
|
||||
FISqlConnection db = null;
|
||||
if (string.IsNullOrWhiteSpace(companyid))
|
||||
db = SystemParams.GetDbInstance();
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(companyid);
|
||||
db = new FISqlConnection(connetionstring);
|
||||
}
|
||||
|
||||
List<ContactInfo> list = new List<ContactInfo>();
|
||||
DataTable dt = db.GetDataTableBySQL(SQL, assetid);
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
ContactInfo ci = ConvertToContactInfo(dr);
|
||||
list.Add(ci);
|
||||
}
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,29 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.Device
|
||||
{
|
||||
public class GpsDeviceItem
|
||||
{
|
||||
public long ID { get; set; }
|
||||
public string SN { get; set; }
|
||||
public string Source { get; set; }
|
||||
public string SourceName { get; set; }
|
||||
public string DeviceType { get; set; }
|
||||
public int Status { get; set; }
|
||||
public bool Active { get; set; }
|
||||
public string ContractorID { get; set; }
|
||||
public string Contractor { get; set; }
|
||||
public string InvoiceNumber { get; set; }
|
||||
public DateTime AddDate { get; set; }
|
||||
public string AddDateStr { get { return AddDate == DateTime.MinValue ? "" : AddDate.ToShortDateString(); } }
|
||||
public DateTime? InvoiceDate { get; set; }
|
||||
public string InvoiceDateStr { get { return InvoiceDate == null ? "" : InvoiceDate.Value.ToShortDateString(); } }
|
||||
public DateTime? ServiceStartDate { get; set; }
|
||||
public string ServiceStartDateStr { get { return ServiceStartDate == null ? "" : ServiceStartDate.Value.ToShortDateString(); } }
|
||||
public string Notes { get; set; }
|
||||
}
|
||||
}
|
@ -83,8 +83,11 @@ namespace IronIntel.Contractor
|
||||
{
|
||||
if (s == null) return null;
|
||||
if (s.GetType() != typeof(string)) return s;
|
||||
//const string invalidCharsMatch =
|
||||
// "(?ims)[\x0\x1\x2\x3\x4\x5\x6\x7\x8\x9\xa\xb\xc\xd\xe\xf" +
|
||||
// "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x7f]";
|
||||
const string invalidCharsMatch =
|
||||
"(?ims)[\x0\x1\x2\x3\x4\x5\x6\x7\x8\x9\xa\xb\xc\xd\xe\xf" +
|
||||
"(?ims)[\x0\x1\x2\x3\x4\x5\x6\x7\x8\x9\xb\xc\xe\xf" +
|
||||
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x7f]";
|
||||
|
||||
//取代其中無效字元, 通通換成空字串
|
||||
@ -94,7 +97,7 @@ namespace IronIntel.Contractor
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
private COpenXmlExcelSheet ConvertToOpenXmlObject(DataTable data, string caption, double[] columnWidths, string[] MergeTitles)
|
||||
{
|
||||
try
|
||||
@ -247,7 +250,7 @@ namespace IronIntel.Contractor
|
||||
cellData.FormatCode = "";
|
||||
}
|
||||
|
||||
cellData.Value = rdc.ColumnName;
|
||||
cellData.Value = rdc.Caption;
|
||||
|
||||
rowData.Add(cellData);
|
||||
}
|
||||
@ -269,31 +272,53 @@ namespace IronIntel.Contractor
|
||||
rdc = data.Columns[q];
|
||||
|
||||
string format = "";
|
||||
//if (rdc != null)
|
||||
//{
|
||||
//if (rdc.Attributes != null && rdc.Attributes.ContainsKey("DataFormat"))
|
||||
//{
|
||||
// format = (rdc.Attributes["DataFormat"] == null
|
||||
// ? ""
|
||||
// : rdc.Attributes["DataFormat"].ToString());
|
||||
//}
|
||||
//}
|
||||
if (rdc != null)
|
||||
{
|
||||
if (rdc.ExtendedProperties != null && rdc.ExtendedProperties.ContainsKey("DataFormat"))
|
||||
{
|
||||
format = (rdc.ExtendedProperties["DataFormat"] == null
|
||||
? ""
|
||||
: rdc.ExtendedProperties["DataFormat"].ToString());
|
||||
}
|
||||
}
|
||||
|
||||
cellData = new ChartFormatedData();
|
||||
|
||||
//将特殊格式值处理成字符串显示。
|
||||
CExcelCellValue cExcelValue = null;
|
||||
if (rdr != null)
|
||||
{
|
||||
bool isProcessed = false;
|
||||
object cValue = rdr[q];
|
||||
if (cValue is CExcelCellValue)
|
||||
{
|
||||
cExcelValue = (cValue as CExcelCellValue);
|
||||
cValue = cExcelValue.Value;
|
||||
}
|
||||
cellData.Value =
|
||||
ConvertIvalidChars(
|
||||
ProcessSpecialFormat(rdr[q], format, ref isProcessed));
|
||||
ProcessSpecialFormat(cValue, format, ref isProcessed));
|
||||
if (isProcessed) format = "";
|
||||
}
|
||||
cellData.FormatCode = ProcessFormat(format);
|
||||
cellData.DataType =
|
||||
GetDataType((cellData.Value == null ? typeof(string) : cellData.Value.GetType()));
|
||||
|
||||
//cellData.FormatCode = ProcessFormat(format, cellData.DataType, cellData.Value);
|
||||
//if ((cellData.DataType == CellDataType.Integer || cellData.DataType == CellDataType.Float) && cellData.FormatCode == "{0}")
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// var d = decimal.Parse(cellData.Value.ToString());
|
||||
// var pad = (decimal.GetBits(d)[3] >> 16) & 0x7fff;
|
||||
// if (pad > 0)
|
||||
// {
|
||||
// cellData.FormatCode = "{0:0." + new string('0', pad) + "}";
|
||||
// }
|
||||
// }
|
||||
// catch { }
|
||||
//}
|
||||
|
||||
string alignment = "";
|
||||
if (rdc != null)
|
||||
{
|
||||
@ -304,6 +329,14 @@ namespace IronIntel.Contractor
|
||||
cellData.CAlignment = new CellAlignment();
|
||||
cellData.CAlignment.Align = GetAlignment(alignment);
|
||||
}
|
||||
if (cExcelValue != null)
|
||||
{
|
||||
if (cExcelValue.BackgroundColor != null)
|
||||
{
|
||||
cellData.CFill = new CellFill();
|
||||
cellData.CFill.FillColor = cExcelValue.BackgroundColor.Value;
|
||||
}
|
||||
}
|
||||
|
||||
//如果是合计行则以浅灰色显示。
|
||||
//if (hasTotalRow && k == dataFromClient.Rows.Count - 1)
|
||||
@ -345,6 +378,37 @@ namespace IronIntel.Contractor
|
||||
}
|
||||
}
|
||||
|
||||
private string ProcessFormat(string format, CellDataType cellDataType, object value)
|
||||
{
|
||||
string resultFormat = format;
|
||||
if (string.IsNullOrEmpty(resultFormat)) return resultFormat;
|
||||
if (format.IndexOf("*") >= 0)
|
||||
{
|
||||
resultFormat = resultFormat.Replace("*", "\"*\"");
|
||||
}
|
||||
if (format.IndexOf("@") >= 0)
|
||||
{
|
||||
resultFormat = resultFormat.Replace("@", "\"@\"");
|
||||
}
|
||||
if (cellDataType == CellDataType.Integer && Regex.IsMatch(resultFormat, @"[.][#]+"))
|
||||
{
|
||||
resultFormat = Regex.Replace(resultFormat, @"[.][#]+", "");
|
||||
}
|
||||
else if (cellDataType == CellDataType.Float)
|
||||
{
|
||||
try
|
||||
{
|
||||
var s = string.Format(resultFormat, value);
|
||||
if (s.IndexOf('.') < 0)
|
||||
{
|
||||
resultFormat = Regex.Replace(resultFormat, @"[.][0#]*(.*)[}]", "$1}");
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
return resultFormat;
|
||||
}
|
||||
|
||||
private string ConvertColNumber(int colnum)
|
||||
{
|
||||
string zzz = "Z+";
|
||||
@ -477,6 +541,10 @@ namespace IronIntel.Contractor
|
||||
{
|
||||
resultFormat = resultFormat.Replace("@", "\"@\"");
|
||||
}
|
||||
if (format.IndexOf("\n") >= 0)
|
||||
{
|
||||
resultFormat = resultFormat.Replace("@", "\"@\"");
|
||||
}
|
||||
return resultFormat;
|
||||
}
|
||||
}
|
||||
|
304
IronIntelContractorBusiness/ExportExcel/ImportFromExcel.cs
Normal file
304
IronIntelContractorBusiness/ExportExcel/ImportFromExcel.cs
Normal file
@ -0,0 +1,304 @@
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using Foresight.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.ExportExcel
|
||||
{
|
||||
/// <summary>
|
||||
/// Excel 导入。提供对xlsx文件的解析
|
||||
/// </summary>
|
||||
public class ImportFromExcel
|
||||
{
|
||||
/// <summary>
|
||||
/// 解析excel数据
|
||||
/// </summary>
|
||||
/// <param name="excelBytes">Excel Data</param>
|
||||
/// <returns></returns>
|
||||
public DataTable LoadExcelData(byte[] excelBytes, int headerrowindex = 1)
|
||||
{
|
||||
return LoadExcelData(excelBytes, "", headerrowindex);
|
||||
}
|
||||
|
||||
public DataTable[] LoadAllExcelData(byte[] excelBytes)
|
||||
{
|
||||
MemoryStream stream = null;
|
||||
List<DataTable> list = new List<DataTable>();
|
||||
try
|
||||
{
|
||||
stream = new MemoryStream(excelBytes);
|
||||
using (SpreadsheetDocument sdoc = SpreadsheetDocument.Open(stream, false))
|
||||
{
|
||||
foreach (Sheet sheet in sdoc.WorkbookPart.Workbook.Descendants<Sheet>())
|
||||
{
|
||||
if (sheet != null)
|
||||
{
|
||||
WorksheetPart wsp = (WorksheetPart)sdoc.WorkbookPart.GetPartById(sheet.Id);
|
||||
Worksheet ws = wsp.Worksheet;
|
||||
//取Cell值的时候使用
|
||||
SharedStringTablePart tablePart = sdoc.WorkbookPart.SharedStringTablePart;
|
||||
//得到第一个工作表的所有行
|
||||
IEnumerable<Row> rows = ws.Descendants<Row>();
|
||||
//第一行是标题,标题作为表的列名
|
||||
Row headerRow = rows.First();
|
||||
DataTable excelData = new DataTable(sheet.Name);
|
||||
string columnName = "";
|
||||
foreach (Cell hc in headerRow)
|
||||
{
|
||||
columnName = GetCellValue(hc, tablePart);
|
||||
excelData.Columns.Add(columnName, GetCellDataType(hc));
|
||||
}
|
||||
//装载数据到DataTable里面
|
||||
foreach (Row row in rows)
|
||||
{
|
||||
if (row.RowIndex == 1) continue;
|
||||
DataRow excelRow = excelData.NewRow();
|
||||
int i = 0;
|
||||
foreach (Cell cell in row)
|
||||
{
|
||||
excelRow[i] = GetCellValue(cell, tablePart);
|
||||
i++;
|
||||
}
|
||||
excelData.Rows.Add(excelRow);
|
||||
}
|
||||
list.Add(excelData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
//解析过程中出错误了,TODO
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (stream != null) stream.Close();
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public DataTable LoadExcelDataByClient(byte[] excelBytes)
|
||||
{
|
||||
DataTable[] dts = ExcelClient.GetTables(excelBytes, true, true);
|
||||
|
||||
if(dts != null && dts.Length > 0)
|
||||
{
|
||||
return dts[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析excel数据
|
||||
/// </summary>
|
||||
/// <param name="excelBytes">Excel Data</param>
|
||||
/// <param name="sheetName">Sheet Name</param>
|
||||
/// <returns></returns>
|
||||
public DataTable LoadExcelData(byte[] excelBytes, string sheetName, int headerrowindex)
|
||||
{
|
||||
MemoryStream stream = null;
|
||||
try
|
||||
{
|
||||
stream = new MemoryStream(excelBytes);
|
||||
using (SpreadsheetDocument sdoc = SpreadsheetDocument.Open(stream, false))
|
||||
{
|
||||
Sheet sheet = null;
|
||||
if (string.IsNullOrEmpty(sheetName))//没有特定的sheetname的时候,取第一个sheet
|
||||
sheet = sdoc.WorkbookPart.Workbook.Descendants<Sheet>().FirstOrDefault();
|
||||
else//根据sheetname取特定sheet
|
||||
sheet = sdoc.WorkbookPart.Workbook.Descendants<Sheet>().Where((s) => s.Name == sheetName).First();
|
||||
if (sheet != null)
|
||||
{
|
||||
WorksheetPart wsp = (WorksheetPart)sdoc.WorkbookPart.GetPartById(sheet.Id);
|
||||
WorkbookStylesPart stylepart = sdoc.WorkbookPart.GetPartsOfType<WorkbookStylesPart>().FirstOrDefault();
|
||||
Worksheet ws = wsp.Worksheet;
|
||||
//取Cell值的时候使用
|
||||
SharedStringTablePart tablePart = sdoc.WorkbookPart.SharedStringTablePart;
|
||||
//得到第一个工作表的所有行
|
||||
IEnumerable<Row> rows = ws.Descendants<Row>();
|
||||
//第一行是标题,标题作为表的列名
|
||||
Row headerRow = rows.ElementAt(headerrowindex - 1);//.First();
|
||||
DataTable excelData = new DataTable(sheet.Name);
|
||||
string columnName = "";
|
||||
foreach (Cell hc in headerRow)
|
||||
{
|
||||
columnName = GetCellValue(hc, tablePart);
|
||||
excelData.Columns.Add(columnName, GetCellDataType(hc));
|
||||
if (hc.CellReference != null)
|
||||
{
|
||||
var colref = System.Text.RegularExpressions.Regex.Replace(hc.CellReference.Value, @"\d", "");//C30->C
|
||||
excelData.Columns[excelData.Columns.Count - 1].Caption = colref;
|
||||
}
|
||||
}
|
||||
|
||||
//装载数据到DataTable里面
|
||||
foreach (Row row in rows)
|
||||
{
|
||||
if (row.RowIndex <= headerrowindex) continue;
|
||||
DataRow excelRow = excelData.NewRow();
|
||||
int i = 0;
|
||||
foreach (Cell cell in row)
|
||||
{
|
||||
if (cell.CellReference != null)//row不包含未输入的单元
|
||||
{
|
||||
var colref = System.Text.RegularExpressions.Regex.Replace(cell.CellReference.Value, @"\d", "");//C30->C
|
||||
int j = i;
|
||||
while (j < excelData.Columns.Count && excelData.Columns[j].Caption != colref)
|
||||
{
|
||||
j++;
|
||||
}
|
||||
if (excelData.Columns[j].Caption == colref)
|
||||
{
|
||||
excelRow[j] = GetCellValue(cell, tablePart, stylepart);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
excelRow[i] = GetCellValue(cell, tablePart, stylepart);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
excelData.Rows.Add(excelRow);
|
||||
}
|
||||
return excelData;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//解析过程中出错误了,TODO
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (stream != null) stream.Close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// 得到Excel 中 Cell的值
|
||||
/// </summary>
|
||||
/// <param name="c">Cell</param>
|
||||
/// <param name="stp"></param>
|
||||
/// <returns></returns>
|
||||
private string GetCellValue(Cell cell, SharedStringTablePart stringTablePart, WorkbookStylesPart stylepart = null)
|
||||
{
|
||||
if (cell.ChildElements.Count == 0) return "";
|
||||
string value = cell.CellValue.InnerText;
|
||||
if (cell.DataType != null && cell.DataType == CellValues.SharedString)
|
||||
{
|
||||
value = stringTablePart.SharedStringTable.ChildElements[int.Parse(value)].InnerText;
|
||||
}
|
||||
else if (cell.StyleIndex != null && cell.StyleIndex > 0 && stylepart != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
//int formatStyleIndex = Convert.ToInt32(cell.StyleIndex.Value);
|
||||
//CellFormat cf = (CellFormat)stylepart.Stylesheet.CellFormats.ElementAt(formatStyleIndex);
|
||||
|
||||
//if (cf.NumberFormatId != null)
|
||||
//{
|
||||
// var numberFormatId = cf.NumberFormatId.Value;
|
||||
// if (stylepart.Stylesheet.NumberingFormats != null)
|
||||
// {
|
||||
// var numberingFormat = stylepart.Stylesheet.NumberingFormats.Cast<NumberingFormat>().Single(f => f.NumberFormatId.Value == numberFormatId);
|
||||
// if(numberingFormat != null)
|
||||
// {
|
||||
// double dd = 0;
|
||||
// if (double.TryParse(value, out dd))
|
||||
// {
|
||||
// return dd.ToString(numberingFormat.FormatCode.Value);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// value = cell.InnerText;
|
||||
//}
|
||||
double d = 0;
|
||||
if (double.TryParse(value, out d))
|
||||
{
|
||||
value = d.ToString();
|
||||
CellFormat cf = (CellFormat)stylepart.Stylesheet.CellFormats.ElementAt((int)cell.StyleIndex.Value);
|
||||
if (cf.NumberFormatId >= 14 && cf.NumberFormatId <= 22)//Date
|
||||
{
|
||||
value = DateTime.FromOADate(d).ToString("MM/dd/yyyy");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
return value;
|
||||
}
|
||||
/// <summary>
|
||||
/// 得到单元格类型
|
||||
/// </summary>
|
||||
/// <param name="cell">Cell</param>
|
||||
/// <returns></returns>
|
||||
private Type GetCellDataType(Cell cell)
|
||||
{
|
||||
if (cell.DataType == null) return typeof(string);
|
||||
if (cell.DataType == CellValues.Date)
|
||||
return typeof(DateTime);
|
||||
if (cell.DataType == CellValues.Number)
|
||||
return typeof(decimal);
|
||||
return typeof(string);
|
||||
}
|
||||
public string[] LoadExcelColumnHead(byte[] excelBytes, int headerrowindex = 1)
|
||||
{
|
||||
return LoadExcelColumnHead(excelBytes, "", headerrowindex);
|
||||
}
|
||||
|
||||
public string[] LoadExcelColumnHead(byte[] excelBytes, string sheetName, int headerrowindex)
|
||||
{
|
||||
MemoryStream stream = null;
|
||||
try
|
||||
{
|
||||
stream = new MemoryStream(excelBytes);
|
||||
using (SpreadsheetDocument sdoc = SpreadsheetDocument.Open(stream, false))
|
||||
{
|
||||
Sheet sheet = null;
|
||||
if (string.IsNullOrEmpty(sheetName))//没有特定的sheetname的时候,取第一个sheet
|
||||
sheet = sdoc.WorkbookPart.Workbook.Descendants<Sheet>().FirstOrDefault();
|
||||
else//根据sheetname取特定sheet
|
||||
sheet = sdoc.WorkbookPart.Workbook.Descendants<Sheet>().Where((s) => s.Name == sheetName).First();
|
||||
if (sheet != null)
|
||||
{
|
||||
WorksheetPart wsp = (WorksheetPart)sdoc.WorkbookPart.GetPartById(sheet.Id);
|
||||
Worksheet ws = wsp.Worksheet;
|
||||
//取Cell值的时候使用
|
||||
SharedStringTablePart tablePart = sdoc.WorkbookPart.SharedStringTablePart;
|
||||
//得到第一个工作表的所有行
|
||||
IEnumerable<Row> rows = ws.Descendants<Row>();
|
||||
//第一行是标题,标题作为表的列名
|
||||
Row headerRow = rows.ElementAt(headerrowindex - 1);//.First();
|
||||
List<string> ls = new List<string>();
|
||||
foreach (Cell hc in headerRow)
|
||||
{
|
||||
string columnName = "";
|
||||
columnName = GetCellValue(hc, tablePart);
|
||||
ls.Add(columnName);
|
||||
}
|
||||
|
||||
return ls.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//解析过程中出错误了,TODO
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (stream != null) stream.Close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -70,4 +70,10 @@ namespace IronIntel.Contractor
|
||||
get { return _RowHeightList; }
|
||||
}
|
||||
}
|
||||
|
||||
public class CExcelCellValue
|
||||
{
|
||||
public object Value { get; set; }
|
||||
public System.Drawing.Color? BackgroundColor { get; set; }
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,223 @@
|
||||
using FI.FIC.Extention;
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.FICExtDataTable
|
||||
{
|
||||
public class AssetTripsDataTable : FleetExtDataTable
|
||||
{
|
||||
public override string ID
|
||||
{
|
||||
get
|
||||
{
|
||||
return "32F84217-7F99-438E-9F06-6F238DDA3202";
|
||||
}
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Asset Trips DataTable";
|
||||
}
|
||||
}
|
||||
|
||||
public override string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Asset Trips DataTable";
|
||||
}
|
||||
}
|
||||
|
||||
public override string Version
|
||||
{
|
||||
get
|
||||
{
|
||||
return "1.0.0.0";
|
||||
}
|
||||
}
|
||||
|
||||
private static ExtDataTableParameter[] Params = new ExtDataTableParameter[] {
|
||||
new ExtDataTableParameter(){ID="C854AF5C-2928-43E1-B600-30F0318006FA",
|
||||
Name ="AssetId",DataType=DataTypes.Integer,DefaultValue=0 },
|
||||
new ExtDataTableParameter(){ ID="8573483C-3FD3-42E0-8C80-5DE543183140",
|
||||
Name ="StartDate",DataType=DataTypes.DateTime,DefaultValue=DateTime.Today.ToShortDateString()},
|
||||
new ExtDataTableParameter(){ ID="2C82E11F-2D97-426B-9925-FFB9BA3AF8D0",
|
||||
Name ="EndDate",DataType=DataTypes.DateTime,DefaultValue=DateTime.Today.ToShortDateString()},
|
||||
};
|
||||
|
||||
public override ExtDataTableParameter[] AvailableParameters
|
||||
{
|
||||
get
|
||||
{
|
||||
return Params;
|
||||
}
|
||||
}
|
||||
|
||||
public override DataTable GetData(int maxrows, KeyValuePair<string, object>[] parameters)
|
||||
{
|
||||
DataTable result = GetSchemaTable();
|
||||
string companyid = SystemParams.CompanyID;
|
||||
string assetidStr = "";
|
||||
string dtFromStr = "";
|
||||
string dtToStr = "";
|
||||
|
||||
if (parameters != null)
|
||||
{
|
||||
foreach (var kv in parameters)
|
||||
{
|
||||
if (kv.Key.Equals("AssetId", StringComparison.OrdinalIgnoreCase))
|
||||
assetidStr = kv.Value == null ? "" : kv.Value.ToString();
|
||||
else if (kv.Key.Equals("StartDate", StringComparison.OrdinalIgnoreCase))
|
||||
dtFromStr = kv.Value == null ? "" : kv.Value.ToString();
|
||||
else if (kv.Key.Equals("EndDate", StringComparison.OrdinalIgnoreCase))
|
||||
dtToStr = kv.Value == null ? "" : kv.Value.ToString();
|
||||
}
|
||||
}
|
||||
var user = GetCurrentUser();
|
||||
if (user == null || !user.Active)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
long assetid = 0;
|
||||
if (string.IsNullOrEmpty(assetidStr) || !long.TryParse(assetidStr, out assetid))
|
||||
return result;
|
||||
if (assetid <= 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
DateTime dtFrom = DateTime.Today;
|
||||
DateTime dtTo = DateTime.Now;
|
||||
if (!DateTime.TryParse(dtFromStr, out dtFrom) || !DateTime.TryParse(dtToStr, out dtTo))
|
||||
return result;
|
||||
dtTo = dtTo.Date.AddDays(1).AddSeconds(-1);
|
||||
|
||||
try
|
||||
{
|
||||
var aclient = FleetServiceClientHelper.CreateClient<AssetQueryClient>(companyid, string.Empty);
|
||||
var asset = aclient.GetAssetBasicInfoByID(companyid, assetid);
|
||||
if (asset == null)
|
||||
return result;
|
||||
|
||||
var client = FleetServiceClientHelper.CreateClient<AssetLocationQueryClient>(companyid, string.Empty);
|
||||
AssetTripInfo[] trips = client.GetAssetTripLins(companyid, assetid, dtFrom.Date, dtTo);
|
||||
foreach (AssetTripInfo trip in trips)
|
||||
{
|
||||
DataRow dr = result.NewRow();
|
||||
result.Rows.Add(dr);
|
||||
FillRowData(dr, trip, asset);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteLog(GetType().FullName + ".GetData", ex.Message, ex.ToString());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override DataTable GetSchemaTable()
|
||||
{
|
||||
DataTable result = new DataTable();
|
||||
result.Columns.Add("MachineID", typeof(long));
|
||||
result.Columns.Add("Name", typeof(string));
|
||||
result.Columns.Add("Name2", typeof(string));
|
||||
result.Columns.Add("VIN", typeof(string));
|
||||
result.Columns.Add("MakeID", typeof(int));
|
||||
result.Columns.Add("Make", typeof(string));
|
||||
result.Columns.Add("ModelID", typeof(int));
|
||||
result.Columns.Add("Model", typeof(string));
|
||||
result.Columns.Add("TypeID", typeof(int));
|
||||
result.Columns.Add("Type", typeof(string));
|
||||
|
||||
result.Columns.Add("TripOnLogId", typeof(long));
|
||||
result.Columns.Add("TripOnAsofTime", typeof(DateTime));
|
||||
result.Columns.Add("TripOnLocalAsofTime", typeof(DateTime));
|
||||
result.Columns.Add("TripOnLatitude", typeof(double));
|
||||
result.Columns.Add("TripOnLongitude", typeof(double));
|
||||
result.Columns.Add("TripOnOdometer", typeof(double));
|
||||
result.Columns.Add("TripOnOdometerUnit", typeof(string));
|
||||
result.Columns.Add("TripOnCity", typeof(string));
|
||||
result.Columns.Add("TripOnStreet", typeof(string));
|
||||
result.Columns.Add("TripOnState", typeof(string));
|
||||
|
||||
result.Columns.Add("TripOffLogId", typeof(long));
|
||||
result.Columns.Add("TripOffAsofTime", typeof(DateTime));
|
||||
result.Columns.Add("TripOffLocalAsofTime", typeof(DateTime));
|
||||
result.Columns.Add("TripOffLatitude", typeof(double));
|
||||
result.Columns.Add("TripOffLongitude", typeof(double));
|
||||
result.Columns.Add("TripOffOdometer", typeof(double));
|
||||
result.Columns.Add("TripOffOdometerUnit", typeof(string));
|
||||
result.Columns.Add("TripOffCity", typeof(string));
|
||||
result.Columns.Add("TripOffStreet", typeof(string));
|
||||
result.Columns.Add("TripOffState", typeof(string));
|
||||
|
||||
result.Columns.Add("TripOff", typeof(DateTime));
|
||||
result.Columns.Add("TripTime", typeof(TimeSpan));
|
||||
result.Columns.Add("TripDistance", typeof(double));
|
||||
result.Columns.Add("TripDistanceUnit", typeof(string));
|
||||
|
||||
result.TableName = "AssetTrips";
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void FillRowData(DataRow dr, AssetTripInfo trip, AssetBasicInfo asset)
|
||||
{
|
||||
dr["MachineID"] = asset.ID;
|
||||
dr["Name"] = asset.Name;
|
||||
dr["Name2"] = asset.Name2;
|
||||
dr["VIN"] = asset.VIN;
|
||||
dr["MakeID"] = asset.MakeID;
|
||||
dr["Make"] = asset.MakeName;
|
||||
dr["ModelID"] = asset.ModelID;
|
||||
dr["Model"] = asset.ModelName;
|
||||
dr["TypeID"] = asset.TypeID;
|
||||
dr["Type"] = asset.TypeName;
|
||||
if (trip.TripOn != null)
|
||||
{
|
||||
dr["TripOnLogId"] = trip.TripOn.LogId;
|
||||
dr["TripOnAsofTime"] = trip.TripOn.AsofTime;
|
||||
dr["TripOnLocalAsofTime"] = trip.TripOn.LocalAsofTime;
|
||||
dr["TripOnLatitude"] = trip.TripOn.Latitude;
|
||||
dr["TripOnLongitude"] = trip.TripOn.Longitude;
|
||||
if (trip.TripOn.Odometer != null)
|
||||
{
|
||||
dr["TripOnOdometer"] = trip.TripOn.Odometer;
|
||||
dr["TripOnOdometerUnit"] = trip.TripOn.OdometerUnit;
|
||||
}
|
||||
dr["TripOnCity"] = trip.TripOn.City;
|
||||
dr["TripOnStreet"] = trip.TripOn.Street;
|
||||
dr["TripOnState"] = trip.TripOn.State;
|
||||
}
|
||||
if (trip.TripOff != null)
|
||||
{
|
||||
dr["TripOffLogId"] = trip.TripOff.LogId;
|
||||
dr["TripOffAsofTime"] = trip.TripOff.AsofTime;
|
||||
dr["TripOffLocalAsofTime"] = trip.TripOff.LocalAsofTime;
|
||||
dr["TripOffLatitude"] = trip.TripOff.Latitude;
|
||||
dr["TripOffLongitude"] = trip.TripOff.Longitude;
|
||||
if (trip.TripOff.Odometer != null)
|
||||
{
|
||||
dr["TripOffOdometer"] = trip.TripOff.Odometer;
|
||||
dr["TripOffOdometerUnit"] = trip.TripOff.OdometerUnit;
|
||||
}
|
||||
dr["TripOffCity"] = trip.TripOff.City;
|
||||
dr["TripOffStreet"] = trip.TripOff.Street;
|
||||
dr["TripOffState"] = trip.TripOff.State;
|
||||
}
|
||||
if (trip.TripTime != null)
|
||||
dr["TripTime"] = trip.TripTime;
|
||||
if (trip.TripDistance != null)
|
||||
dr["TripDistance"] = trip.TripDistance;
|
||||
dr["TripDistanceUnit"] = trip.TripDistanceUnit;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FI.FIC.Extention;
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using Foresight.Fleet.Services.User;
|
||||
|
||||
namespace IronIntel.Contractor.FICExtDataTable
|
||||
{
|
||||
public abstract class FleetExtDataTable : IExtDataTable
|
||||
{
|
||||
protected FICContext Context { get; private set; }
|
||||
|
||||
protected string UserIID
|
||||
{
|
||||
get
|
||||
{
|
||||
return Context == null ? string.Empty : Context.UserIID;
|
||||
}
|
||||
}
|
||||
|
||||
public FleetExtDataTable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public abstract string ID { get; }
|
||||
public abstract string Name { get; }
|
||||
public abstract string Description { get; }
|
||||
public abstract string Version { get; }
|
||||
public abstract ExtDataTableParameter[] AvailableParameters { get; }
|
||||
|
||||
public abstract DataTable GetData(int maxrows, KeyValuePair<string, object>[] parameters);
|
||||
public abstract DataTable GetSchemaTable();
|
||||
|
||||
public void Init(FICContext context)
|
||||
{
|
||||
Context = context;
|
||||
}
|
||||
|
||||
protected void WriteLog(string source, string message, string detail)
|
||||
{
|
||||
SystemParams.WriteLog("Error", "FleetExtDt", source, message, detail);
|
||||
}
|
||||
|
||||
protected UserInfo GetCurrentUser()
|
||||
{
|
||||
if (Context == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
UserQueryClient ic = FleetServiceClientHelper.CreateClient<UserQueryClient>();
|
||||
return ic.GetUserByIID(UserIID);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteLog(GetType().FullName + ".GetLoginSession()", "extdt=" + ID + ";useriid=" + UserIID, ex.ToString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
121
IronIntelContractorBusiness/FICSpecialGolbalFilterManager.cs
Normal file
121
IronIntelContractorBusiness/FICSpecialGolbalFilterManager.cs
Normal file
@ -0,0 +1,121 @@
|
||||
using FI.FIC;
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using Foresight.Fleet.Services.JobSite;
|
||||
using Foresight.Fleet.Services.User;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor
|
||||
{
|
||||
public class FICSpecialGolbalFilterManager
|
||||
{
|
||||
const string ASSETID = "00000000-0000-0000-0000-000000000001";
|
||||
const string JOBSITEID = "00000000-0000-0000-0000-000000000002";
|
||||
|
||||
public static readonly SpecialGlobalFilterInfo[] GlobalFilters = new SpecialGlobalFilterInfo[] {
|
||||
new SpecialGlobalFilterInfo(){IID=ASSETID,DisplayName="Available Assets",Description="Available Assets",DataType=FilterDataType.dtInteger},
|
||||
new SpecialGlobalFilterInfo(){IID=JOBSITEID,DisplayName="Available Jobsites",Description="Available Jobsites",DataType=FilterDataType.dtInteger}
|
||||
};
|
||||
|
||||
private static bool IsValidId(string id)
|
||||
{
|
||||
foreach (var f in GlobalFilters)
|
||||
{
|
||||
if (string.Equals(id, f.IID, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static object[] GetSpecialGlobalFilterValuesByUser(string useriid, string filterid)
|
||||
{
|
||||
if (!IsValidId(filterid))
|
||||
{
|
||||
return new object[0];
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(useriid))
|
||||
{
|
||||
return new object[0];
|
||||
}
|
||||
|
||||
if (string.Equals(filterid, ASSETID, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return GetAvailableAssets(useriid);
|
||||
}
|
||||
else if (string.Equals(filterid, JOBSITEID, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return GetAvailableJobSites(useriid);
|
||||
}
|
||||
|
||||
return new object[0];
|
||||
}
|
||||
|
||||
private static object[] GetAvailableAssets(string useriid)
|
||||
{
|
||||
//DateTime dt = DateTime.Now;
|
||||
AssetQueryClient client = FleetServiceClientHelper.CreateClient<AssetQueryClient>();
|
||||
long[] assetids = client.GetAvailableAssetsForUsers(SystemParams.CompanyID, useriid);
|
||||
object[] result = new object[assetids.Length];
|
||||
for (int i = 0; i < assetids.Length; i++)
|
||||
{
|
||||
result[i] = assetids[i];
|
||||
}
|
||||
//TimeSpan sp = DateTime.Now - dt;
|
||||
//SystemParams.WriteLog("DEBUG", "FICSpecialGolbalFilterManager", string.Format("Assets: {0}, {1}",result.Length,sp.ToString()), useriid);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static object[] GetAvailableJobSites(string useriid)
|
||||
{
|
||||
//DateTime dt = DateTime.Now;
|
||||
JobSiteProvider client = FleetServiceClientHelper.CreateClient<JobSiteProvider>();
|
||||
var jobsites = client.GetUserJobsites(SystemParams.CompanyID, useriid);
|
||||
object[] results = new object[jobsites.Length];
|
||||
for (int i = 0; i < jobsites.Length; i++)
|
||||
{
|
||||
results[i] = jobsites[i].ID;
|
||||
}
|
||||
//TimeSpan sp = DateTime.Now - dt;
|
||||
//SystemParams.WriteLog("DEBUG", "FICSpecialGolbalFilterManager", string.Format("Jobsites: {0}, {1}", results.Length, sp.ToString()), useriid);
|
||||
return results;
|
||||
}
|
||||
|
||||
public static FilterTemplateInfo[] GetFilterTemplates(string useriid)
|
||||
{
|
||||
UserFilterProvider f = FleetServiceClientHelper.CreateClient<UserFilterProvider>();
|
||||
var items = f.GetFilterTemplates(SystemParams.CompanyID, useriid);
|
||||
List<FilterTemplateInfo> filters = new List<FilterTemplateInfo>();
|
||||
foreach (var item in items)
|
||||
{
|
||||
FilterTemplateInfo t = new FilterTemplateInfo();
|
||||
t.IID = item.Key;
|
||||
t.DisplayName = item.Value;
|
||||
t.DataType = FilterDataType.dtInteger;
|
||||
filters.Add(t);
|
||||
}
|
||||
|
||||
return filters.ToArray();
|
||||
}
|
||||
|
||||
public static object[] GetFilterValues(string useriid, int filterid)
|
||||
{
|
||||
UserFilterProvider f = FleetServiceClientHelper.CreateClient<UserFilterProvider>();
|
||||
long[] assets = f.GetFilteredAssets(SystemParams.CompanyID, filterid, useriid);
|
||||
if (assets == null || assets.Length == 0)
|
||||
{
|
||||
return new object[0];
|
||||
}
|
||||
object[] results = new object[assets.Length];
|
||||
for (int i = 0; i < assets.Length; i++)
|
||||
{
|
||||
results[i] = assets[i];
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
}
|
@ -5,8 +5,6 @@ using System.Text;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using Foresight.Data;
|
||||
using IronIntel.Services;
|
||||
using IronIntel.Services.Customers;
|
||||
|
||||
namespace IronIntel.Contractor.FilterQ
|
||||
{
|
||||
|
@ -5,6 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Configuration;
|
||||
using Foresight.Fleet.Services;
|
||||
using Foresight.Standard;
|
||||
|
||||
namespace IronIntel.Contractor
|
||||
{
|
||||
|
@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
@ -11,6 +13,33 @@ namespace IronIntel.Contractor
|
||||
{
|
||||
public static readonly DateTime DBMinDateTime = new DateTime(1900, 01, 01);
|
||||
|
||||
static Helper()
|
||||
{
|
||||
FileTypes.Add(".jfif", "image/jpeg");
|
||||
FileTypes.Add(".jpg", "image/jpeg");
|
||||
FileTypes.Add(".jpeg", "image/jpeg");
|
||||
FileTypes.Add(".bmp", "image/jpeg");
|
||||
FileTypes.Add(".gif", "image/jpeg");
|
||||
FileTypes.Add(".png", "image/png");
|
||||
FileTypes.Add(".tiff", "image/tiff");
|
||||
|
||||
FileTypes.Add(".mp4", "video/mp4");
|
||||
FileTypes.Add(".mp3", "audio/mpeg");
|
||||
FileTypes.Add(".mp2", "audio/mp2");
|
||||
|
||||
FileTypes.Add(".m4e", "video/mp4");
|
||||
FileTypes.Add(".mpeg", "video/mpg");
|
||||
FileTypes.Add(".avi", "video/avi");
|
||||
FileTypes.Add(".mov", "video/quicktime");
|
||||
|
||||
FileTypes.Add(".pdf", "application/pdf");
|
||||
}
|
||||
|
||||
public static bool IsNullDateTime(DateTime? dt)
|
||||
{
|
||||
return dt == null || dt.Value < DBMinDateTime;
|
||||
}
|
||||
|
||||
public static bool IsTrue(string s)
|
||||
{
|
||||
const string YES = "Yes";
|
||||
@ -88,5 +117,184 @@ namespace IronIntel.Contractor
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
public static string GetDefaultOdoUnitString()
|
||||
{
|
||||
if (SystemParams.CustomerDetail.OdometerUnit == Foresight.Standard.Units.DistanceUnits.Kilometres)
|
||||
return "Kilometre";
|
||||
else //if (SystemParams.CustomerDetail.OdometerUnit == Foresight.Fleet.Units.DistanceUnits.Miles)
|
||||
return "Mile";
|
||||
}
|
||||
|
||||
public static System.Drawing.Color ConvertHtmlColor(string color, System.Drawing.Color def)
|
||||
{
|
||||
System.Drawing.Color c = def;
|
||||
if (System.Text.RegularExpressions.Regex.IsMatch(color, "#([0-9a-fA-F]{6})"))
|
||||
{
|
||||
try
|
||||
{
|
||||
c = System.Drawing.ColorTranslator.FromHtml(color);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
return c;
|
||||
}
|
||||
public static byte[] GetThumbImg(byte[] buff, int width = 300, int height = 300)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream(buff))
|
||||
{
|
||||
ms.Position = 0;
|
||||
System.Drawing.Image img = RotateImage(ms);
|
||||
var tp = Scale(img.Width, img.Height, width, height);
|
||||
System.Drawing.Image img1 = new System.Drawing.Bitmap(img, tp.Item1, tp.Item2);
|
||||
using (MemoryStream ms1 = new MemoryStream())
|
||||
{
|
||||
img1.Save(ms1, System.Drawing.Imaging.ImageFormat.Png);
|
||||
ms1.Position = 0;
|
||||
return ms1.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return buff;
|
||||
}
|
||||
}
|
||||
|
||||
private static Tuple<int, int> Scale(int src_width, int src_height, int dest_width, int dest_height)
|
||||
{
|
||||
double srcratio = (double)src_width / (double)src_height;
|
||||
double w = dest_width;
|
||||
double h = (w / srcratio);
|
||||
if (h > dest_height)
|
||||
{
|
||||
h = dest_height;
|
||||
w = h * srcratio;
|
||||
}
|
||||
return new Tuple<int, int>((int)w, (int)h);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据图片exif调整方向
|
||||
/// </summary>
|
||||
/// <param name="sm"></param>
|
||||
/// <returns></returns>
|
||||
private static Bitmap RotateImage(Stream sm)
|
||||
{
|
||||
System.Drawing.Image img = System.Drawing.Image.FromStream(sm);
|
||||
var exif = img.PropertyItems;
|
||||
byte orien = 0;
|
||||
var item = exif.Where(m => m.Id == 274).ToArray();
|
||||
if (item.Length > 0 && item[0].Value != null && item[0].Value.Length > 0)
|
||||
orien = item[0].Value[0];
|
||||
switch (orien)
|
||||
{
|
||||
case 2:
|
||||
img.RotateFlip(RotateFlipType.RotateNoneFlipX);//horizontal flip
|
||||
break;
|
||||
case 3:
|
||||
img.RotateFlip(RotateFlipType.Rotate180FlipNone);//right-top
|
||||
break;
|
||||
case 4:
|
||||
img.RotateFlip(RotateFlipType.RotateNoneFlipY);//vertical flip
|
||||
break;
|
||||
case 5:
|
||||
img.RotateFlip(RotateFlipType.Rotate90FlipX);
|
||||
break;
|
||||
case 6:
|
||||
img.RotateFlip(RotateFlipType.Rotate90FlipNone);//right-top
|
||||
break;
|
||||
case 7:
|
||||
img.RotateFlip(RotateFlipType.Rotate270FlipX);
|
||||
break;
|
||||
case 8:
|
||||
img.RotateFlip(RotateFlipType.Rotate270FlipNone);//left-bottom
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return (Bitmap)img;
|
||||
}
|
||||
public static bool IsEmail(string email)
|
||||
{
|
||||
//string s = @"^(([^<>()[\]\\.,;:\s@{qm}]+(\.[^<>()[\]\\.,;:\s@{qm}]+)*)|({qm}.+{qm}))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$";
|
||||
//s = s.Replace("{qm}", "\\\"");
|
||||
string s = @"^\w[-\w.+]*@\w+([-.]\w+)*\.\w+([-.]\w+)*$";
|
||||
|
||||
return new System.Text.RegularExpressions.Regex(s).IsMatch(email);
|
||||
}
|
||||
public static bool IsNumber(string str)
|
||||
{
|
||||
string s = @"^\d+$";
|
||||
return new System.Text.RegularExpressions.Regex(s).IsMatch(str);
|
||||
}
|
||||
public static readonly Dictionary<string, string> FileTypes = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public static readonly string[] ImageTypes = new string[] { ".jfif", ".jpg", ".jpeg", ".bmp", ".png", ".tiff", ".gif" };
|
||||
|
||||
|
||||
public static string GetFileExtention(string filename)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filename))
|
||||
{
|
||||
return ".jpg";
|
||||
}
|
||||
int idx = filename.LastIndexOf('.');
|
||||
if (idx > 0 && idx < (filename.Length - 1))
|
||||
{
|
||||
return filename.Substring(idx);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ".jpg";
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsImage(string filetype)
|
||||
{
|
||||
foreach (var s in ImageTypes)
|
||||
{
|
||||
if (string.Equals(s, filetype, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static double? ConvertToDouble(string d, double? def = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(d))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
double t;
|
||||
if (double.TryParse(d, out t))
|
||||
{
|
||||
return t;
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
public static int ConvertToInt32(string d, int def = 0)
|
||||
{
|
||||
int t;
|
||||
if (int.TryParse(d, out t))
|
||||
{
|
||||
return t;
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
public static readonly string[] DevAccounts = new string[] {
|
||||
"dchu@foresightintelligence.com",
|
||||
"qhong@foresightintelligence.com",
|
||||
"lwang@foresightintelligence.com",
|
||||
"ljzeng@foresightintelligence.com",
|
||||
"llj@foresightintelligence.com"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using IronIntel.Contractor.iisitebase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
@ -21,7 +22,7 @@ namespace IronIntel.Contractor
|
||||
{
|
||||
if (_LoginSessionCookieName == null)
|
||||
{
|
||||
_LoginSessionCookieName = Site.IronIntelBasePage.LOGINSESSION_COOKIENAME;
|
||||
_LoginSessionCookieName = IronIntelBasePage.LOGINSESSION_COOKIENAME;
|
||||
}
|
||||
return _LoginSessionCookieName;
|
||||
}
|
||||
@ -34,7 +35,7 @@ namespace IronIntel.Contractor
|
||||
{
|
||||
if (_LanguageCookieName == null)
|
||||
{
|
||||
_LanguageCookieName = LoginSessionCookieName + "language";
|
||||
_LanguageCookieName = IronIntelBasePage.LANGUAGE_COOKIENAME;
|
||||
}
|
||||
return _LanguageCookieName;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ namespace IronIntel.Contractor
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("ERROR", "DeleteUserGroup", ex.Message, ex.ToString());
|
||||
throw new Exception(ResManager.GetLanguage("LHBIS_EXCEPTION_E0X6502704C")); // "Failed to delete the user group."
|
||||
throw new Exception(ResManager.GetLanguage(ClientLanguage, "LHBIS_EXCEPTION_E0X6502704C")); // "Failed to delete the user group."
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -176,7 +176,7 @@ namespace IronIntel.Contractor
|
||||
if (flag)
|
||||
{
|
||||
SystemParams.WriteLog("ERROR", "SaveUser", "user try to edit user with illegal permission.", string.Format("current user: {0}, {1}", CurrentUserIID, CurrentUserName));
|
||||
return ResManager.GetLanguage("ERROR_LHBIS_FIC_BLC_BLWORKSPACE_A0034"); // "The user does not have the required access rights.";
|
||||
return ResManager.GetLanguage(ClientLanguage, "ERROR_LHBIS_FIC_BLC_BLWORKSPACE_A0034"); // "The user does not have the required access rights.";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -217,19 +217,19 @@ namespace IronIntel.Contractor
|
||||
|
||||
if (string.IsNullOrWhiteSpace(user.ID))
|
||||
{
|
||||
return ResManager.GetLanguage("LHBIS_FIC_CLIENT_MODULES_USERMANAGERCTRL_A023"); // "User ID cannot be empty.";
|
||||
return ResManager.GetLanguage(ClientLanguage, "LHBIS_FIC_CLIENT_MODULES_USERMANAGERCTRL_A023"); // "User ID cannot be empty.";
|
||||
}
|
||||
if (!reg_email.Match(user.ID).Success && !reg_userid.Match(user.ID).Success)
|
||||
{
|
||||
return ResManager.GetLanguage("LHBIS_FIC_CLIENT_MODULES_USERMANAGERCTRL_A056"); // "The user ID must contain only letters, numbers, underlines, minus signs or an email address.";
|
||||
return ResManager.GetLanguage(ClientLanguage, "LHBIS_FIC_CLIENT_MODULES_USERMANAGERCTRL_A056"); // "The user ID must contain only letters, numbers, underlines, minus signs or an email address.";
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(user.DisplayName))
|
||||
{
|
||||
return ResManager.GetLanguage("LHBIS_FIC_CLIENT_MODULES_USERMANAGERCTRL_A024"); // "User name cannot be empty.";
|
||||
return ResManager.GetLanguage(ClientLanguage, "LHBIS_FIC_CLIENT_MODULES_USERMANAGERCTRL_A024"); // "User name cannot be empty.";
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(user.Email) && !reg_email.Match(user.Email).Success)
|
||||
{
|
||||
return ResManager.GetLanguage("LHBIS_FIC_CLIENT_MODULES_USERMANAGERCTRL_A066"); // "Email address is invalid.";
|
||||
return ResManager.GetLanguage(ClientLanguage, "LHBIS_FIC_CLIENT_MODULES_USERMANAGERCTRL_A066"); // "Email address is invalid.";
|
||||
}
|
||||
user.ID = user.ID.Trim();
|
||||
if (user.ID.Length > 100)
|
||||
@ -400,7 +400,7 @@ namespace IronIntel.Contractor
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(group.Name))
|
||||
{
|
||||
return ResManager.GetLanguage("LHBIS_FIC_CLIENT_MODULES_USERADDDIALOG_A004"); // "Group name cannot be empty.";
|
||||
return ResManager.GetLanguage(ClientLanguage, "LHBIS_FIC_CLIENT_MODULES_USERADDDIALOG_A004"); // "Group name cannot be empty.";
|
||||
}
|
||||
|
||||
// users
|
||||
@ -511,7 +511,7 @@ namespace IronIntel.Contractor
|
||||
|
||||
public UserPermissionData[] GetUserOrGroupPermission(string UserOrGroup, string objIID)
|
||||
{
|
||||
return UserManagement.GetUserOrGroupPermission(UserOrGroup, objIID, CurrentUserIID);
|
||||
return UserManagement.GetUserOrGroupPermission(UserOrGroup, objIID, CurrentUserIID, ClientLanguage);
|
||||
}
|
||||
|
||||
#region - System Options -
|
||||
|
27
IronIntelContractorBusiness/InspectionManager.cs
Normal file
27
IronIntelContractorBusiness/InspectionManager.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using Foresight.Fleet.Services.Inspection.Package;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor
|
||||
{
|
||||
public class InspectionManager
|
||||
{
|
||||
public static byte[] GetInspectionPackage(string sessionid, string custid, string pkgid, out string name)
|
||||
{
|
||||
var client = FleetServiceClientHelper.CreateClient<InspectPackageProvider>();
|
||||
client.SessionID = sessionid;
|
||||
byte[] buffer = client._GetPackageContent(custid, pkgid);
|
||||
if (buffer != null)
|
||||
{
|
||||
var pkg = InspectPackage.FromBuffer(buffer);
|
||||
name = pkg.PackageName + ".ins";
|
||||
return buffer;
|
||||
}
|
||||
name = "";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -40,21 +40,15 @@
|
||||
<Reference Include="DocumentFormat.OpenXml">
|
||||
<HintPath>..\Reflib\DocumentFormat.OpenXml.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FIASPNETCache">
|
||||
<HintPath>..\Reflib\FIASPNETCache.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FICacheManager.Redis">
|
||||
<HintPath>..\Reflib\FICacheManager.Redis.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FICachManager">
|
||||
<HintPath>..\Reflib\FICachManager.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FICBLC">
|
||||
<HintPath>..\Reflib\FIC\FICBLC.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FICIntf">
|
||||
<HintPath>..\Reflib\FIC\FICIntf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FIChartLib">
|
||||
<HintPath>..\Reflib\FIC\FIChartLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FICIntfAdv, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b006d6021b5c4397, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Reflib\FIC\FICIntfAdv.dll</HintPath>
|
||||
@ -75,49 +69,34 @@
|
||||
<Reference Include="FIWinLib">
|
||||
<HintPath>..\Reflib\FIWinLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FleetClientBase">
|
||||
<HintPath>..\Reflib\FleetClientBase.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FleetServiceClient">
|
||||
<HintPath>..\Reflib\FleetServiceClient.dll</HintPath>
|
||||
<Reference Include="Foresight.Service.Client">
|
||||
<HintPath>..\Reflib\Foresight.Service.Client.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Foresight.ServiceModel">
|
||||
<HintPath>..\Reflib\Foresight.ServiceModel.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="iisitebase">
|
||||
<HintPath>..\Reflib\iisitebase.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="iisyslib">
|
||||
<HintPath>..\Reflib\iisyslib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ironcontractorwinlib">
|
||||
<HintPath>..\Site\Bin\ironcontractorwinlib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="irondbobjlib">
|
||||
<HintPath>..\Reflib\irondbobjlib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="IronIntel.ServiceModel.Client">
|
||||
<HintPath>..\Reflib\IronIntel.ServiceModel.Client.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="IronIntel.Services.Contractor">
|
||||
<HintPath>..\Site\Bin\IronIntel.Services.Contractor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="IronIntelServiceModel">
|
||||
<HintPath>..\Reflib\IronIntelServiceModel.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="IronIntelSysClient">
|
||||
<HintPath>..\Reflib\IronIntelSysClient.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\Reflib\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.SqlClient, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Data.SqlClient.4.6.0\lib\net461\System.Data.SqlClient.dll</HintPath>
|
||||
<Reference Include="System.Data.SqlClient, Version=4.6.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Data.SqlClient.4.8.1\lib\net461\System.Data.SqlClient.dll</HintPath>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.IO.Compression.FileSystem" />
|
||||
<Reference Include="System.IO.Compression.ZipFile, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.IO.Compression.ZipFile.4.3.0\lib\net46\System.IO.Compression.ZipFile.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
@ -130,16 +109,19 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AttachmentsManagement.cs" />
|
||||
<Compile Include="Attachment\AttachmentItem.cs" />
|
||||
<Compile Include="BusinessBase.cs" />
|
||||
<Compile Include="CacheManager.cs" />
|
||||
<Compile Include="Device\GpsDeviceItem.cs" />
|
||||
<Compile Include="ExportExcel\ImportFromExcel.cs" />
|
||||
<Compile Include="FICSpecialGolbalFilterManager.cs" />
|
||||
<Compile Include="InspectionManager.cs" />
|
||||
<Compile Include="ExportExcelManager.cs" />
|
||||
<Compile Include="ExportExcel\ConvertFormat.cs" />
|
||||
<Compile Include="ExportExcel\ExcelXlsx.cs" />
|
||||
<Compile Include="ExportExcel\ExportToExcel.cs" />
|
||||
<Compile Include="ExportExcel\IOpenXmlExcelStyleAndData.cs" />
|
||||
<Compile Include="ExportExcel\XlsxObj.cs" />
|
||||
<Compile Include="FICExtDataTable\AssetTripsDataTable.cs" />
|
||||
<Compile Include="FICExtDataTable\FleetExtDataTable.cs" />
|
||||
<Compile Include="FITracker\FITrackerManagement.cs" />
|
||||
<Compile Include="FleetServiceClientHelper.cs" />
|
||||
<Compile Include="Host\ClientModels.cs" />
|
||||
@ -149,6 +131,10 @@
|
||||
<Compile Include="Helper.cs" />
|
||||
<Compile Include="Host\HostRequesEntry.cs" />
|
||||
<Compile Include="Host\HostService.cs" />
|
||||
<Compile Include="iisitebase\IronIntelBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="iisitebase\IronIntelHttpHandlerBase.cs" />
|
||||
<Compile Include="MachineDetailWorkspace.cs" />
|
||||
<Compile Include="Machines\FuelusedInfo.cs" />
|
||||
<Compile Include="Machines\IdlehoursInfo.cs" />
|
||||
@ -160,6 +146,7 @@
|
||||
<Compile Include="Machines\OdometerInfo.cs" />
|
||||
<Compile Include="Maintenance\AlertInfo.cs" />
|
||||
<Compile Include="Maintenance\AlertManager.cs" />
|
||||
<Compile Include="Maintenance\AlertQueryParams.cs" />
|
||||
<Compile Include="Maintenance\FuelRecordInfo.cs" />
|
||||
<Compile Include="Maintenance\IATCAlertsSyncService.cs" />
|
||||
<Compile Include="Maintenance\MaintenanceInfo.cs" />
|
||||
@ -172,8 +159,6 @@
|
||||
<Compile Include="OTRConfig\HarshDrivingItem.cs" />
|
||||
<Compile Include="OTRConfig\HarshDrivingManagement.cs" />
|
||||
<Compile Include="OTRConfig\SpeedingItem.cs" />
|
||||
<Compile Include="Security\CurfewInfo.cs" />
|
||||
<Compile Include="Security\CurfewManagement.cs" />
|
||||
<Compile Include="Security\CurfewMovementToleranceInfo.cs" />
|
||||
<Compile Include="Security\JobsiteLimitInfo.cs" />
|
||||
<Compile Include="Security\JobsiteLimitManagement.cs" />
|
||||
@ -186,10 +171,7 @@
|
||||
<Compile Include="IIColor.cs" />
|
||||
<Compile Include="IronintelHost.cs" />
|
||||
<Compile Include="JobSites\JobSitesManagement.cs" />
|
||||
<Compile Include="MapView\JobManagement.cs" />
|
||||
<Compile Include="MapView\LocationManagement.cs" />
|
||||
<Compile Include="MapView\MachineStateInfo.cs" />
|
||||
<Compile Include="MapView\MachinesMapViewerManagement.cs" />
|
||||
<Compile Include="MapView\MapViewer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SystemParams.cs" />
|
||||
@ -209,6 +191,16 @@
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Connected Services\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Service\DataModel\FleetClientBase\FleetClientBase.csproj">
|
||||
<Project>{b0110465-8537-4fe7-bee6-b10faa0ba92d}</Project>
|
||||
<Name>FleetClientBase</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\Service\DataModel\FleetServiceClient\FleetServiceClient.csproj">
|
||||
<Project>{a872b915-d7f0-4e7f-81e7-742dbb4dbbba}</Project>
|
||||
<Name>FleetServiceClient</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy "$(TargetFileName)" "$(ProjectDir)\..\Site\Bin\$(TargetFileName)"</PostBuildEvent>
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -15,6 +16,12 @@ using IronIntel.Contractor.Users;
|
||||
using FI.FIC.Contracts.DataObjects.Enumeration;
|
||||
using System.Web;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using Foresight.Fleet.Services.Styles;
|
||||
using IronIntel.Contractor.iisitebase;
|
||||
using Foresight.Standard.Units;
|
||||
using Foresight.Standard.Data;
|
||||
using Foresight.Fleet.Services;
|
||||
using FleetUser = Foresight.Fleet.Services.User;
|
||||
|
||||
namespace IronIntel.Contractor
|
||||
{
|
||||
@ -60,10 +67,12 @@ namespace IronIntel.Contractor
|
||||
FICHostEnvironment.SetHost(new IronIntelHost());
|
||||
}
|
||||
|
||||
private ConcurrentDictionary<string, Tuple<FICUserInfo, DateTime>> _Users = new ConcurrentDictionary<string, Tuple<FICUserInfo, DateTime>>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public byte[] GetCacheData(string key, bool ignoreExpired, ref DateTime createTime)
|
||||
{
|
||||
byte[] buffer = CacheManager.GetValue(key);
|
||||
if (buffer == null)
|
||||
if (buffer == null || buffer.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@ -81,10 +90,18 @@ namespace IronIntel.Contractor
|
||||
{
|
||||
return null;
|
||||
}
|
||||
//FIDataTable tb = new FIDataTable();
|
||||
//tb.FillFromBuffer(buffer);
|
||||
//return FIDbAccess.ConvertDataTable(tb);
|
||||
return Deserialize(buffer) as DataTable;
|
||||
using (MemoryStream ms = new MemoryStream(buffer, false))
|
||||
{
|
||||
try
|
||||
{
|
||||
TableReader tr = new TableReader(ms);
|
||||
return tr.Read();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FICCompanyInfo GetCompanyInfo()
|
||||
@ -99,7 +116,7 @@ namespace IronIntel.Contractor
|
||||
|
||||
public CompanyLic GetLicense()
|
||||
{
|
||||
IronIntel.Services.LicenseInfo lic = SystemParams.GetLicense();
|
||||
Foresight.Fleet.Services.Customer.LicenseInfo lic = SystemParams.GetLicense();
|
||||
if (lic == null)
|
||||
{
|
||||
return null;
|
||||
@ -108,7 +125,7 @@ namespace IronIntel.Contractor
|
||||
ci.CompanyID = SystemParams.CompanyID;
|
||||
ci.CompanyName = SystemParams.CustomerDetail.Name;
|
||||
|
||||
Foresight.Security.License.LicenseInfo li = new LicenseInfo();
|
||||
LicenseInfo li = new LicenseInfo();
|
||||
ci.Licenses.Add(li);
|
||||
li.CompanyID = ci.CompanyID;
|
||||
li.CompanyName = ci.CompanyName;
|
||||
@ -131,7 +148,7 @@ namespace IronIntel.Contractor
|
||||
return ci;
|
||||
}
|
||||
|
||||
private LicenseAddtionalPropertyObj ConvertLicenseItem(Services.LicenseItem item)
|
||||
private LicenseAddtionalPropertyObj ConvertLicenseItem(Foresight.Fleet.Services.Customer.LicenseItem item)
|
||||
{
|
||||
if (item == null)
|
||||
return null;
|
||||
@ -184,6 +201,8 @@ namespace IronIntel.Contractor
|
||||
//Mobile = ui.Mobile,
|
||||
Mobile = ui.TextAddress,
|
||||
BusinessPhone = ui.BusinessPhone,
|
||||
UserLanguage = ui.PreferredLanguage,
|
||||
UserTimeZone = ui.TimeZone
|
||||
};
|
||||
switch (ui.UserType)
|
||||
{
|
||||
@ -206,14 +225,29 @@ namespace IronIntel.Contractor
|
||||
return user;
|
||||
}
|
||||
|
||||
const int EXPIRESECONDS = 600;
|
||||
|
||||
public FICUserInfo GetUserByIID(string useriid)
|
||||
{
|
||||
Tuple<FICUserInfo, DateTime> tp = null;
|
||||
_Users.TryGetValue(useriid, out tp);
|
||||
if (tp != null)
|
||||
{
|
||||
TimeSpan sp = DateTime.Now - tp.Item2;
|
||||
if (sp.TotalSeconds < EXPIRESECONDS)
|
||||
{
|
||||
return tp.Item1;
|
||||
}
|
||||
}
|
||||
|
||||
UserInfo ui = UserManagement.GetUserByIID(useriid);
|
||||
if (ui == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return ConvertToFICUserInfo(ui);
|
||||
FICUserInfo u = ConvertToFICUserInfo(ui);
|
||||
_Users[u.IID] = new Tuple<FICUserInfo, DateTime>(u, DateTime.Now);
|
||||
return u;
|
||||
}
|
||||
|
||||
public FICUserInfo GetUserByLoginSessionID(string sessionid)
|
||||
@ -223,41 +257,116 @@ namespace IronIntel.Contractor
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return ConvertToFICUserInfo(ui);
|
||||
|
||||
FICUserInfo u = ConvertToFICUserInfo(ui);
|
||||
_Users[u.IID] = new Tuple<FICUserInfo, DateTime>(u, DateTime.Now);
|
||||
return u;
|
||||
}
|
||||
|
||||
public FICUserInfo GetUserByUserID(string userId)
|
||||
{
|
||||
Tuple<FICUserInfo, DateTime>[] users = _Users.Values.ToArray();
|
||||
Tuple<FICUserInfo, DateTime> tp = null;
|
||||
foreach (var user in users)
|
||||
{
|
||||
if (string.Equals(userId, user.Item1.ID, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
tp = user;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tp != null)
|
||||
{
|
||||
TimeSpan sp = DateTime.Now - tp.Item2;
|
||||
if (sp.TotalSeconds < EXPIRESECONDS)
|
||||
{
|
||||
return tp.Item1;
|
||||
}
|
||||
}
|
||||
|
||||
UserInfo ui = UserManagement.GetUserByID(userId);
|
||||
if (ui == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return ConvertToFICUserInfo(ui);
|
||||
FICUserInfo u = ConvertToFICUserInfo(ui);
|
||||
_Users[u.IID] = new Tuple<FICUserInfo, DateTime>(u, DateTime.Now);
|
||||
return u;
|
||||
}
|
||||
|
||||
ConcurrentDictionary<string, FICUserInfo> _ForesightUsers = new ConcurrentDictionary<string, FICUserInfo>(StringComparer.OrdinalIgnoreCase);
|
||||
DateTime _LastRefreshForesightUsers = DateTime.MinValue;
|
||||
DateTime _LastGetAllUsersTime = DateTime.MinValue;
|
||||
|
||||
public FICUserInfo[] GetUsers()
|
||||
{
|
||||
UserInfo[] users = UserManagement.GetUsers();
|
||||
List<FICUserInfo> ls = new List<FICUserInfo>(users.Length);
|
||||
foreach (UserInfo ui in users)
|
||||
TimeSpan sp = DateTime.Now - _LastGetAllUsersTime;
|
||||
if (sp.TotalSeconds >= EXPIRESECONDS)
|
||||
{
|
||||
ls.Add(ConvertToFICUserInfo(ui));
|
||||
UserInfo[] users = UserManagement.GetUsers();
|
||||
foreach (UserInfo ui in users)
|
||||
{
|
||||
FICUserInfo u = ConvertToFICUserInfo(ui);
|
||||
_Users[u.IID] = new Tuple<FICUserInfo, DateTime>(u, DateTime.Now);
|
||||
}
|
||||
_LastGetAllUsersTime = DateTime.Now;
|
||||
}
|
||||
|
||||
var items = _Users.Values.ToArray();
|
||||
List<FICUserInfo> ls = new List<FICUserInfo>();
|
||||
foreach (var u in items)
|
||||
{
|
||||
ls.Add(u.Item1);
|
||||
}
|
||||
return ls.ToArray();
|
||||
}
|
||||
|
||||
private FICUserInfo[] GetForesightUsers()
|
||||
{
|
||||
TimeSpan sp = DateTime.Now - _LastRefreshForesightUsers;
|
||||
if (sp.TotalSeconds >= EXPIRESECONDS)
|
||||
{
|
||||
UserInfo[] foresightusers = UserManagement.GetForesightUsers();
|
||||
_ForesightUsers.Clear();
|
||||
TimeZoneInfo timezone = SystemParams.GetTimeZoneInfo("Foresight");
|
||||
foreach (var u in foresightusers)
|
||||
{
|
||||
FICUserInfo fu = ConvertToFICUserInfo(u);
|
||||
if (string.IsNullOrWhiteSpace(fu.UserTimeZone))
|
||||
{
|
||||
fu.UserTimeZone = timezone.Id;
|
||||
}
|
||||
_ForesightUsers[fu.IID] = fu;
|
||||
}
|
||||
_LastRefreshForesightUsers = DateTime.Now;
|
||||
}
|
||||
return _ForesightUsers.Values.ToArray();
|
||||
}
|
||||
|
||||
public FICUserInfo[] GetUsers(bool hasAdmin)
|
||||
{
|
||||
if (!hasAdmin)
|
||||
{
|
||||
return GetUsers();
|
||||
}
|
||||
|
||||
FICUserInfo[] localusers = GetUsers();
|
||||
FICUserInfo[] foresightusers = GetForesightUsers();
|
||||
List<FICUserInfo> ls = new List<FICUserInfo>();
|
||||
ls.AddRange(localusers);
|
||||
ls.AddRange(foresightusers);
|
||||
return ls.ToArray();
|
||||
}
|
||||
|
||||
public FICUserInfo[] GetSimpleUsers(bool hasAdmin)
|
||||
{
|
||||
return GetUsers(hasAdmin);
|
||||
}
|
||||
|
||||
public string GetUserEmail(string useriid)
|
||||
{
|
||||
UserInfo ui = UserManagement.GetUserByIID(useriid);
|
||||
if (ui == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ui.ID;
|
||||
}
|
||||
FICUserInfo u = GetUserByIID(useriid);
|
||||
return u == null ? null : u.ID;
|
||||
}
|
||||
|
||||
public void PostMessage(int category, string msg)
|
||||
@ -310,9 +419,18 @@ namespace IronIntel.Contractor
|
||||
}
|
||||
else
|
||||
{
|
||||
//FIDataTable tb = FIDbAccess.ConvertDataTable(dt, -1);
|
||||
byte[] buffer = Serialize(dt, createTime);
|
||||
SetCacheData(key, buffer, expirationsecond, slidingExpiration, createTime);
|
||||
if (dt.Rows.Count > 1000000)
|
||||
{
|
||||
return;
|
||||
}
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
TableWriter tw = TableWriter.Create(dt);
|
||||
tw.Write(ms);
|
||||
ms.Position = 0;
|
||||
byte[] buffer = ms.ToArray();
|
||||
SetCacheData(key, buffer, expirationsecond, slidingExpiration, createTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -323,7 +441,7 @@ namespace IronIntel.Contractor
|
||||
|
||||
public void WriteLog(string logType, string category, string source, string message, string detail)
|
||||
{
|
||||
SystemParams.WriteLog(logType, category, source, message, detail);
|
||||
SystemParams.WriteLog(logType, "FIC", source, message, detail);
|
||||
}
|
||||
|
||||
public List<string> GetUserGroupIDByUserIID(string userIID)
|
||||
@ -331,30 +449,12 @@ namespace IronIntel.Contractor
|
||||
return UserManagement.GetUserGroupIDByUserIID(userIID);
|
||||
}
|
||||
|
||||
public FICUserInfo[] GetUsers(bool hasAdmin)
|
||||
{
|
||||
if (!hasAdmin)
|
||||
{
|
||||
return GetUsers();
|
||||
}
|
||||
|
||||
UserInfo[] localusers = UserManagement.GetUsers();
|
||||
UserInfo[] foresightusers = UserManagement.GetForesightUsers();
|
||||
UserInfo[] users = localusers.Union(foresightusers).ToArray();
|
||||
List<FICUserInfo> ls = new List<FICUserInfo>(users.Length);
|
||||
foreach (UserInfo ui in users)
|
||||
{
|
||||
//if (ui.UserType == UserTypes.Admin)
|
||||
//{
|
||||
ls.Add(ConvertToFICUserInfo(ui));
|
||||
//}
|
||||
}
|
||||
return ls.ToArray();
|
||||
}
|
||||
|
||||
|
||||
public LoginContext GetCurrentLoginContext(HttpContext context)
|
||||
{
|
||||
string session = Site.IronIntelBasePage.GetLoginSessionID(context.Request);
|
||||
string session = IronIntelBasePage.GetLoginSessionID(context.Request);
|
||||
if (string.IsNullOrWhiteSpace(session))
|
||||
{
|
||||
return null;
|
||||
@ -415,6 +515,28 @@ namespace IronIntel.Contractor
|
||||
get { return string.Empty; }
|
||||
}
|
||||
|
||||
public PlatForms HostPlatForm
|
||||
{
|
||||
get { return PlatForms.Fleet; }
|
||||
}
|
||||
|
||||
public string DefaultLanguageId
|
||||
{
|
||||
get
|
||||
{
|
||||
string lg = SystemParams.CustomerDetail.LanguageId;
|
||||
return string.IsNullOrWhiteSpace(lg) ? "en-us" : lg;
|
||||
}
|
||||
}
|
||||
|
||||
public KeyValuePair<string, string>[] SupportedLanguages
|
||||
{
|
||||
get
|
||||
{
|
||||
return Foresight.Fleet.Services.CountryAndRegionCode.SupportedLanguages;
|
||||
}
|
||||
}
|
||||
|
||||
public string GetStyleDefines(string useriid)
|
||||
{
|
||||
//StringBuilder s = new StringBuilder();
|
||||
@ -425,7 +547,7 @@ namespace IronIntel.Contractor
|
||||
//s.Append("<Board><Title><Background>#666666</Background><Foreground>#777777</Foreground></Title></Board>");
|
||||
//s.Append("</root>");
|
||||
//return s.ToString();
|
||||
Services.CustUIStyle uistyle = SystemParams.GetUIStyle(useriid);
|
||||
CustUIStyle uistyle = SystemParams.GetUIStyle(useriid);
|
||||
|
||||
StringBuilder s = new StringBuilder();
|
||||
s.Append(@"<?xml version=""1.0"" encoding=""UTF-8""?>");
|
||||
@ -441,20 +563,7 @@ namespace IronIntel.Contractor
|
||||
return SystemParams.GetAdditionalParameter();
|
||||
}
|
||||
|
||||
public FICUserInfo[] GetSimpleUsers(bool hasAdmin)
|
||||
{
|
||||
var users = GetUsers(hasAdmin);
|
||||
List<FICUserInfo> ls = new List<FICUserInfo>();
|
||||
foreach (var user in users)
|
||||
{
|
||||
var us = new FICUserInfo();
|
||||
us.IID = user.IID;
|
||||
us.ID = user.ID;
|
||||
us.DisplayName = user.DisplayName;
|
||||
ls.Add(us);
|
||||
}
|
||||
return ls.ToArray();
|
||||
}
|
||||
|
||||
|
||||
public SpecialDatabaseConnectionInfo[] GetSpecialDatabaseConnections()
|
||||
{
|
||||
@ -542,6 +651,112 @@ namespace IronIntel.Contractor
|
||||
return SystemParams.GetCompanyLOGO(SystemParams.CompanyID);
|
||||
}
|
||||
|
||||
public AreaUnits GetAreaUnit()
|
||||
{
|
||||
var cust = SystemParams.CustomerDetail;
|
||||
if (cust != null)
|
||||
{
|
||||
return cust.AreaUnit;
|
||||
}
|
||||
else
|
||||
{
|
||||
return AreaUnits.Acre;
|
||||
}
|
||||
}
|
||||
|
||||
public DistanceUnits GetDistanceUnit()
|
||||
{
|
||||
var cust = SystemParams.CustomerDetail;
|
||||
if (cust != null)
|
||||
{
|
||||
return cust.OdometerUnit;
|
||||
}
|
||||
else
|
||||
{
|
||||
return DistanceUnits.Kilometres;
|
||||
}
|
||||
}
|
||||
|
||||
public SpeedUnits GetSpeedUnit()
|
||||
{
|
||||
DistanceUnits du = GetDistanceUnit();
|
||||
switch (du)
|
||||
{
|
||||
case DistanceUnits.Kilometres: return SpeedUnits.KPH;
|
||||
case DistanceUnits.Metres: return SpeedUnits.MetersPerSecond;
|
||||
case DistanceUnits.Miles: return SpeedUnits.MPH;
|
||||
default:
|
||||
return SpeedUnits.KPH;
|
||||
}
|
||||
}
|
||||
|
||||
public VolumnUnits GetVolumnUnit()
|
||||
{
|
||||
var cust = SystemParams.CustomerDetail;
|
||||
if (cust != null)
|
||||
{
|
||||
return cust.VolumnUnit;
|
||||
}
|
||||
else
|
||||
{
|
||||
return VolumnUnits.Litre;
|
||||
}
|
||||
}
|
||||
|
||||
public WeightUnits GetWeightUnit()
|
||||
{
|
||||
var cust = SystemParams.CustomerDetail;
|
||||
if (cust != null)
|
||||
{
|
||||
return cust.WeightUnit;
|
||||
}
|
||||
else
|
||||
{
|
||||
return WeightUnits.Kilogram;
|
||||
}
|
||||
}
|
||||
|
||||
public SpecialGlobalFilterInfo[] GetSpecialGlobalFilters()
|
||||
{
|
||||
return FICSpecialGolbalFilterManager.GlobalFilters;
|
||||
}
|
||||
|
||||
public object[] GetSpecialGlobalFilterValuesByUser(string useriid, string filterid)
|
||||
{
|
||||
return FICSpecialGolbalFilterManager.GetSpecialGlobalFilterValuesByUser(useriid, filterid);
|
||||
}
|
||||
|
||||
public FilterTemplateInfo[] GetFilterTemplates(string useriid)
|
||||
{
|
||||
return FICSpecialGolbalFilterManager.GetFilterTemplates(useriid);
|
||||
}
|
||||
|
||||
public object[] GetFilterValues(string useriid, int filterid)
|
||||
{
|
||||
return FICSpecialGolbalFilterManager.GetFilterValues(useriid, filterid);
|
||||
}
|
||||
|
||||
public bool CanExportToFile(string useriid)
|
||||
{
|
||||
var client = FleetServiceClientHelper.CreateClient<FleetUser.UserQueryClient>();
|
||||
var user = client.GetUserByIID(useriid);
|
||||
if (user.UserType < FleetUser.UserTypes.Admin)
|
||||
{
|
||||
var atta = client.GetUserAdditionalAttribute(useriid);
|
||||
if (atta != null)
|
||||
return atta.ExcelExports;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void WriteExportAuditTrail(string useriid, string doctype, string docid, string notes, string filename, string filetype, byte[] filedata)
|
||||
{
|
||||
var client = FleetServiceClientHelper.CreateClient<DocCommentProvider>();
|
||||
client.DocumentExportAuditTrail(SystemParams.CompanyID, useriid, doctype, docid, notes, filename, filetype, filedata);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
@ -6,7 +6,6 @@ using Foresight.ServiceModel;
|
||||
using IronIntel.Contractor.Machines;
|
||||
using IronIntel.Contractor.MapView;
|
||||
using IronIntel.Contractor.Shape;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
@ -21,32 +20,7 @@ namespace IronIntel.Contractor.JobSites
|
||||
{
|
||||
private const string MachineFields = "{0}MACHINEID,{0}MACHINENAME,{0}MAKEID,{0}MODELID,{0}TYPEID,{0}MACHINEICONID,{0}DEVICEID,{0}VIN,{0}MAKEYEAR,{0}NOTES,{0}STATUS,{0}CONTRACTORID,{0}DEALERID,{0}UID,{0}ADDEDON,{0}CUR_LONGITUDE,{0}CUR_LATITUDE,{0}LOCDATE_UTC,{0}ENGINEHOURS,{0}HOURSDATE_UTC,{0}DATASOURCE,{0}HIDE,{0}FUEL_CONSUMED,{0}FUEL_UNITS,{0}FUEL_DATE,{0}ODOMETER,{0}ODODATE_UTC,{0}ODOMETERUOM,{0}FUELCOST,{0}FUELCOSTUOM,{0}MACHINERATE,{0}WORKTYPE,{0}RETIREMENTHOURS,{0}RETIREMENTODO,{0}ALTITUDE,{0}ALTITUDEUNITS,{0}IDLEHOURSUTC,{0}IDLEHOURS,{0}LOADCOUNTUTC,{0}LOADCOUNT,{0}PAYLOADTOTALUTC,{0}PAYLOADTOTAL,{0}PAYLOADTOTALUNITS,{0}DEFREMAININGUTC,{0}DEFREMAINING,{0}FUELREMAININGUTC,{0}FUELREMAININGPERCENT,{0}MACHINENAME2,{0}ONROAD,{0}LEASESTART,{0}LEASEEND,{0}LEASEHOURS,{0}UNDERCARRIAGEHOURS,{0}ODOSTART2,{0}ISDELETED,{0}DELETEDDATE,{0}ODOSTART2DATASOURCE,{0}LOCDATASOURCE,{0}HOURSDATASOURCE,{0}FUELDATASOURCE,{0}AQUISITIONTYPE,{0}ICONFILENAME,{0}STARTINGENGINEHOURS,{0}DISTANCECALCBY,{0}TELEMATICSENABLED,{0}COSTCENTER,{0}EQCLASS,{0}DESCRIPTION";
|
||||
|
||||
|
||||
public static JobSiteViewItem GetJobSiteByID(string jobsiteid)
|
||||
{
|
||||
const string sql = @"select JOBSITEID,JOBSITENAME,LATITUDE,LONGITUDE,RADIUS,RADUIS_UOM,CONTRACTORID,COLOR,NOTES,STARTDATE,ENDDATE,POLYGON,BASEONMACHINEID,ISDELETED from JOBSITES where JOBSITEID={0}";
|
||||
|
||||
FISqlConnection db = SystemParams.GetDbInstance();
|
||||
DataTable dt = db.GetDataTableBySQL(sql, jobsiteid);
|
||||
|
||||
JobSiteViewItem result = null;
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
result = ConvertToJobSiteViewItem(dt.Rows[0]);
|
||||
MachineViewItem[] msiary = GetJobSiteMachines(Convert.ToInt64(jobsiteid));
|
||||
if (msiary.Count() > 0)
|
||||
{
|
||||
result.Machines = msiary.OrderBy((m) => m.VIN).ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Machines = null;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void RefreshJobsiteAssets(string sessionid, long jobsiteid)
|
||||
{
|
||||
System.Threading.ThreadPool.QueueUserWorkItem((object state) =>
|
||||
@ -59,17 +33,6 @@ namespace IronIntel.Contractor.JobSites
|
||||
}, null);
|
||||
}
|
||||
|
||||
public static void DeleteJobSites(long jobsiteid)
|
||||
{
|
||||
const string SQL = "delete from JOBSITES where JOBSITEID={0}"
|
||||
+ " delete from JOBSITETYPE where JOBSITEID={0}"
|
||||
+ " delete from JOBSITEMACHINES where JOBSITEID={0}"
|
||||
+ " delete from RELATIONSHIP where RELATIONSHIPTYPEID='ContactJobsite' and RELATEDID={0}";
|
||||
FIDbAccess db = SystemParams.GetDbInstance();
|
||||
db.ExecSQL(SQL, jobsiteid);
|
||||
}
|
||||
|
||||
|
||||
public static void AddMachinesToJobSite(JobSiteViewItem jobsite)
|
||||
{
|
||||
if (jobsite != null)
|
||||
@ -82,7 +45,7 @@ namespace IronIntel.Contractor.JobSites
|
||||
string ad = string.Empty;
|
||||
if (jobsite.Machines != null && jobsite.Machines.Length > 0)
|
||||
{
|
||||
string machineids = string.Join(",", jobsite.Machines.Select(m => m.ID));
|
||||
string machineids = string.Join(",", jobsite.Machines.Select(m => m.AssetId));
|
||||
ad = " and MACHINEID not in(" + machineids + ")";
|
||||
}
|
||||
|
||||
@ -97,14 +60,14 @@ namespace IronIntel.Contractor.JobSites
|
||||
|
||||
if (jobsite.Machines != null && jobsite.Machines.Length > 0)
|
||||
{
|
||||
foreach (MachineViewItem mac in jobsite.Machines)
|
||||
foreach (var mac in jobsite.Machines)
|
||||
{
|
||||
if (mac.OnSite)
|
||||
{
|
||||
tran.ExecSQL(SQL_upt, jobsite.ID, mac.ID);
|
||||
tran.ExecSQL(SQL_upt, jobsite.ID, mac.AssetId);
|
||||
}
|
||||
|
||||
tran.ExecSQL(SQL_t, jobsite.ID, mac.ID, mac.VIN, mac.OnSite ? 1 : 0);
|
||||
tran.ExecSQL(SQL_t, jobsite.ID, mac.AssetId, mac.VIN, mac.OnSite ? 1 : 0);
|
||||
}
|
||||
}
|
||||
tran.Commit();
|
||||
@ -113,22 +76,6 @@ namespace IronIntel.Contractor.JobSites
|
||||
|
||||
}
|
||||
|
||||
public static void AddMachineOnSiteToJobSite(FISqlConnection db, long machineid, string vin, int jobsiteid)
|
||||
{
|
||||
const string SQL_t = @"if exists(select 1 from JOBSITEMACHINES where JOBSITEID={0} and MACHINEID={1}) update JOBSITEMACHINES set ONSITE={3}
|
||||
where JOBSITEID={0} and MACHINEID = {1} else insert into JOBSITEMACHINES(JOBSITEID,MACHINEID,VIN,ADDEDON,ONSITE) values({0},{1},{2},getutcdate(),{3})";
|
||||
const string SQL_upt = "update JOBSITEMACHINES set ONSITE=0 where JOBSITEID!={0} and MACHINEID={1}";
|
||||
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
|
||||
db.ExecSQL(SQL_upt, jobsiteid, machineid);
|
||||
if (jobsiteid > 0)
|
||||
db.ExecSQL(SQL_t, jobsiteid, machineid, vin, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static JobSiteViewItem ConvertToJobSiteViewItem(DataRow dr)
|
||||
{
|
||||
JobSiteViewItem js = new JobSiteViewItem();
|
||||
@ -183,356 +130,10 @@ namespace IronIntel.Contractor.JobSites
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
private static string ConvertPointItemToPolygon(PostionItem[] points)
|
||||
{
|
||||
string polygon = string.Empty;
|
||||
if (points == null || points.Length < 0)
|
||||
{
|
||||
return polygon;
|
||||
}
|
||||
foreach (var pi in points)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(polygon))
|
||||
polygon += pi.Latitude + "," + pi.Longitude;
|
||||
else
|
||||
polygon += ";" + pi.Latitude + "," + pi.Longitude;
|
||||
}
|
||||
return polygon;
|
||||
}
|
||||
|
||||
|
||||
private static MachineViewItem[] GetJobSiteMachines(long JobSiteId)
|
||||
{
|
||||
const string sql_j = @"select jm.MACHINEID,ISNULL(ONSITE,0) ONSITE,m.VIN,m.MACHINENAME,m.MACHINENAME2,m.TYPEID from JOBSITEMACHINES jm left join machines m on jm.MACHINEID=m.MACHINEID where JOBSITEID={0}";
|
||||
FISqlConnection db = SystemParams.GetDbInstance();
|
||||
DataTable dt = null;
|
||||
dt = db.GetDataTableBySQL(sql_j, JobSiteId);
|
||||
|
||||
if (dt.Rows.Count == 0)
|
||||
{
|
||||
return new MachineViewItem[0];
|
||||
}
|
||||
List<MachineViewItem> list = new List<MachineViewItem>();
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
MachineViewItem mi = new MachineViewItem();
|
||||
mi.ID = FIDbAccess.GetFieldInt64(dr["MACHINEID"], 0);
|
||||
mi.OnSite = FIDbAccess.GetFieldInt(dr["ONSITE"], 0) == 1;
|
||||
mi.Name = FIDbAccess.GetFieldString(dr["MACHINENAME"], string.Empty);
|
||||
mi.Name2 = FIDbAccess.GetFieldString(dr["MACHINENAME2"], string.Empty);
|
||||
mi.VIN = FIDbAccess.GetFieldString(dr["VIN"], string.Empty); ;
|
||||
mi.TypeID = FIDbAccess.GetFieldInt(dr["TYPEID"], 0);
|
||||
list.Add(mi);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取机器OnSite状态的JobSite
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Dictionary<int, int> GetOnSiteMahcines(FISqlConnection db)
|
||||
{
|
||||
const string SQL_J = "select JOBSITEID,MACHINEID from JOBSITEMACHINES where ONSITE=1";
|
||||
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
DataTable tb = db.GetDataTableBySQL(SQL_J);
|
||||
Dictionary<int, int> result = new Dictionary<int, int>();
|
||||
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
int machineid = FIDbAccess.GetFieldInt(dr["MACHINEID"], 0);
|
||||
int jobsiteid = FIDbAccess.GetFieldInt(dr["JOBSITEID"], 0);
|
||||
result[machineid] = jobsiteid;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取机器OnSite状态的JobSite
|
||||
/// </summary>
|
||||
/// <param name="db"></param>
|
||||
/// <param name="machineid"></param>
|
||||
/// <returns></returns>
|
||||
public static int GetOnSiteByMachineID(FISqlConnection db, long machineid)
|
||||
{
|
||||
const string SQL_J = "select JOBSITEID from JOBSITEMACHINES where ONSITE=1 and MACHINEID={0}";
|
||||
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
DataTable tb = db.GetDataTableBySQL(SQL_J, machineid);
|
||||
int jobsiteid = 0;
|
||||
if (tb.Rows.Count > 0)
|
||||
jobsiteid = FIDbAccess.GetFieldInt(tb.Rows[0]["JOBSITEID"], 0);
|
||||
|
||||
return jobsiteid;
|
||||
}
|
||||
|
||||
#region Machines
|
||||
|
||||
public static AvailableMachines GetMachineViewItemByType(string sessionid, string jobsiteid, string typeid, string searchText, string useriid)
|
||||
{
|
||||
AvailableMachines result = new AvailableMachines();
|
||||
string SQL_J = @"select m.*,js.JOBSITEID,js.JOBSITENAME,js.LATITUDE,js.LONGITUDE,jsm.ADDEDON as JSMADDEDON,ONSITE from MACHINES m
|
||||
left join JOBSITEMACHINES as jsm on m.MACHINEID = jsm.MACHINEID and jsm.ONSITE=1
|
||||
left join JOBSITES as js on js.JOBSITEID= jsm.JOBSITEID";
|
||||
|
||||
const string SQL_L = @"select AssetId as MACHINEID,LATITUDE,LONGITUDE,AsofTime as ASOFTIME_UTC,MOVESTATUS,HEADING, Speed,SpeedUnits,PostedSpeedLimit,SpeedLimitUnits,Street from AssetLocation where IsPrimary=1";
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(typeid))
|
||||
{
|
||||
Regex r = new Regex(@"[a-zA-Z]");
|
||||
if (r.IsMatch(typeid))
|
||||
return result;
|
||||
SQL_J += " and m.TYPEID=" + typeid + "";
|
||||
}
|
||||
|
||||
FIDbAccess db = SystemParams.GetDbInstance();
|
||||
DataTable tb = db.GetDataTableBySQL(SQL_J);
|
||||
if (tb.Rows.Count == 0)
|
||||
{
|
||||
result.Assigned = new MachineViewItem[0];
|
||||
result.Unassigned = new MachineViewItem[0];
|
||||
return result;
|
||||
}
|
||||
|
||||
double timeadjust = SystemParams.GetHoursOffset();
|
||||
DataTable tbl = null;
|
||||
string dbString2 = SystemParams.GetIronIntelReportDataDbString();
|
||||
if (!string.IsNullOrWhiteSpace(dbString2))
|
||||
{
|
||||
var db2 = new FISqlConnection(dbString2);
|
||||
tbl = db2.GetDataTableBySQL(SQL_L);
|
||||
}
|
||||
|
||||
Dictionary<long, LocationViewItem> machineLocations = new Dictionary<long, LocationViewItem>();
|
||||
if (tbl != null && tbl.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow dr in tbl.Rows)
|
||||
{
|
||||
long mID = FIDbAccess.GetFieldInt64(dr["MACHINEID"], 0);
|
||||
var l = new LocationViewItem();
|
||||
l.Latitude = FIDbAccess.GetFieldDouble(dr["LATITUDE"], 0);
|
||||
l.Longitude = FIDbAccess.GetFieldDouble(dr["LONGITUDE"], 0);
|
||||
l.LocationTime = FIDbAccess.GetFieldDateTime(dr["ASOFTIME_UTC"], DateTime.MinValue);
|
||||
if (l.LocationTime != DateTime.MinValue)
|
||||
l.LocationTime = l.LocationTime.AddHours(timeadjust);
|
||||
|
||||
machineLocations[mID] = l;
|
||||
}
|
||||
}
|
||||
|
||||
long[] availableAssetsids = null;
|
||||
var user = Users.UserManagement.GetUserByIID(useriid);
|
||||
if (user.UserType < Users.UserTypes.Admin)
|
||||
availableAssetsids = FleetServiceClientHelper.CreateClient<AssetQueryClient>(sessionid).GetAvailableAssetsForUsers(SystemParams.CompanyID, useriid);
|
||||
|
||||
MachineManagement.RefreshBaseData();
|
||||
MachineMake[] makes = MachineManagement.GetMachineMakes();
|
||||
MachineModel[] models = MachineManagement.GetMachineModels();
|
||||
MachineType[] types = MachineManagement.GetMachineTypes();
|
||||
|
||||
List<MachineViewItem> assigned = new List<MachineViewItem>();
|
||||
List<MachineViewItem> unassigned = new List<MachineViewItem>();
|
||||
JobSiteViewItem jobsite = GetJobSiteByID(jobsiteid);
|
||||
if (tb.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
long mid = Convert.ToInt64(dr["MACHINEID"]);
|
||||
if (user.UserType < Users.UserTypes.Admin && !availableAssetsids.Contains(mid))
|
||||
continue;
|
||||
MachineViewItem mi = ConvertToMachineViewItem(dr, makes, models, types, timeadjust);
|
||||
if (machineLocations.ContainsKey(mi.ID))
|
||||
mi.Location = machineLocations[mi.ID];
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchText))
|
||||
{
|
||||
if (!Helper.Contains(mi.VIN, searchText)
|
||||
&& !Helper.Contains(mi.ID.ToString(), searchText)
|
||||
&& !Helper.Contains(mi.Name, searchText)
|
||||
&& !Helper.Contains(mi.Name2, searchText)
|
||||
&& !Helper.Contains(mi.Make, searchText)
|
||||
&& !Helper.Contains(mi.MachineType, searchText)
|
||||
&& !Helper.Contains(mi.Model, searchText))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
mi.JobSiteName = FIDbAccess.GetFieldString(dr["JOBSITENAME"], string.Empty);
|
||||
Postion mPoint = new Postion(mi.Location.Latitude, mi.Location.Longitude);
|
||||
Postion jsPoint = new Postion(jobsite.Latitude, jobsite.Longitude);
|
||||
mi.DistanceFromSite = Foresight.Haversine.GetDistanceKilometers(mPoint, jsPoint);
|
||||
|
||||
if (jobsite.Polygon != null && jobsite.Polygon.Length > 3)//多边形,计算机器是否在Jobsite内
|
||||
mi.WithinSite = Haversine.IsInSide(new Postion(mi.Location.Latitude, mi.Location.Longitude), ConvertToPosition(jobsite.Polygon));//由于FICore.dll中Postion的Longtitude存在拼写错误,在前端容易引起混淆,使用加了PostionItem
|
||||
|
||||
|
||||
if (string.Compare(jobsite.Radius_UOM, "Kilometre", true) != 0)//转换
|
||||
mi.DistanceFromSite = mi.DistanceFromSite * 0.6213712;
|
||||
mi.DistanceFromSite = Math.Round(mi.DistanceFromSite, 2);
|
||||
|
||||
bool hide = FIDbAccess.GetFieldInt(dr["HIDE"], 0) == 1;
|
||||
if (!hide && (dr["JOBSITEID"] is DBNull || string.IsNullOrWhiteSpace(dr["JOBSITEID"].ToString())))
|
||||
unassigned.Add(mi);
|
||||
else
|
||||
assigned.Add(mi);
|
||||
}
|
||||
}
|
||||
if (jobsite.Radius > 0)
|
||||
{
|
||||
result.Assigned = assigned.OrderBy((m) => m.DistanceFromSite).ToArray();
|
||||
result.Unassigned = unassigned.OrderBy((m) => m.DistanceFromSite).ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Assigned = assigned.OrderBy((m) => !m.WithinSite).ThenBy((m) => m.DistanceFromSite).ToArray();
|
||||
result.Unassigned = unassigned.OrderBy((m) => !m.WithinSite).ThenBy((m) => m.DistanceFromSite).ToArray();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取可用于Jobsite 绑定的机器,Calamp和FI Tracker
|
||||
/// </summary>
|
||||
/// <param name="useriid"></param>
|
||||
/// <returns></returns>
|
||||
public static MachineViewItem[] GetBindingMachines(string sessionid, string useriid)
|
||||
{
|
||||
List<MachineViewItem> result = new List<MachineViewItem>();
|
||||
string SQL = @"select " + string.Format(MachineFields, "m.") + @" from MACHINES m order by m.MACHINENAME";
|
||||
|
||||
const string SQL_L = @"select AssetId as MACHINEID,LATITUDE,LONGITUDE,AsofTime as ASOFTIME_UTC,MOVESTATUS,HEADING,Speed,SpeedUnits,PostedSpeedLimit,SpeedLimitUnits,Street from AssetLocation where IsPrimary=1 and Datasource in ('Calamp','FITRACKER')";
|
||||
|
||||
FIDbAccess db = SystemParams.GetDbInstance();
|
||||
DataTable tb = db.GetDataTableBySQL(SQL, useriid);
|
||||
if (tb.Rows.Count == 0)
|
||||
{
|
||||
return new MachineViewItem[0];
|
||||
}
|
||||
|
||||
double timeadjust = SystemParams.GetHoursOffset();
|
||||
DataTable tbl = null;
|
||||
string dbString2 = SystemParams.GetIronIntelReportDataDbString();
|
||||
if (!string.IsNullOrWhiteSpace(dbString2))
|
||||
{
|
||||
var db2 = new FISqlConnection(dbString2);
|
||||
tbl = db2.GetDataTableBySQL(SQL_L);
|
||||
}
|
||||
|
||||
Dictionary<long, LocationViewItem> machineLocations = new Dictionary<long, LocationViewItem>();
|
||||
if (tbl != null && tbl.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow dr in tbl.Rows)
|
||||
{
|
||||
long mID = FIDbAccess.GetFieldInt64(dr["MACHINEID"], 0);
|
||||
var l = new LocationViewItem();
|
||||
l.Latitude = FIDbAccess.GetFieldDouble(dr["LATITUDE"], 0);
|
||||
l.Longitude = FIDbAccess.GetFieldDouble(dr["LONGITUDE"], 0);
|
||||
l.LocationTime = FIDbAccess.GetFieldDateTime(dr["ASOFTIME_UTC"], DateTime.MinValue);
|
||||
if (l.LocationTime != DateTime.MinValue)
|
||||
l.LocationTime = l.LocationTime.AddHours(timeadjust);
|
||||
|
||||
machineLocations[mID] = l;
|
||||
}
|
||||
}
|
||||
|
||||
long[] availableAssetsids = null;
|
||||
var user = Users.UserManagement.GetUserByIID(useriid);
|
||||
if (user.UserType < Users.UserTypes.Admin)
|
||||
availableAssetsids = FleetServiceClientHelper.CreateClient<AssetQueryClient>(sessionid).GetAvailableAssetsForUsers(SystemParams.CompanyID, useriid);
|
||||
|
||||
MachineManagement.RefreshBaseData();
|
||||
MachineMake[] makes = MachineManagement.GetMachineMakes();
|
||||
MachineModel[] models = MachineManagement.GetMachineModels();
|
||||
MachineType[] types = MachineManagement.GetMachineTypes();
|
||||
|
||||
if (tb.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
long mid = FIDbAccess.GetFieldInt64(dr["MACHINEID"], 0);
|
||||
if (user.UserType < Users.UserTypes.Admin && !availableAssetsids.Contains(mid))
|
||||
continue;
|
||||
MachineViewItem mi = ConvertToMachineViewItem(dr, makes, models, types, timeadjust);
|
||||
if (machineLocations.ContainsKey(mi.ID))
|
||||
{
|
||||
mi.Location = machineLocations[mi.ID];
|
||||
result.Add(mi);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
private static MachineViewItem ConvertToMachineViewItem(DataRow dr, MachineMake[] makes, MachineModel[] models, MachineType[] types, double timeadjust)
|
||||
{
|
||||
MachineViewItem mi = new MachineViewItem();
|
||||
mi.ID = FIDbAccess.GetFieldInt64(dr["MACHINEID"], 0);
|
||||
mi.Name = FIDbAccess.GetFieldString(dr["MACHINENAME"], string.Empty);
|
||||
mi.Name2 = FIDbAccess.GetFieldString(dr["MACHINENAME2"], string.Empty);
|
||||
mi.VIN = FIDbAccess.GetFieldString(dr["VIN"], string.Empty);
|
||||
mi.MakeYear = FIDbAccess.GetFieldInt(dr["MAKEYEAR"], 0);
|
||||
mi.EngineHours = FIDbAccess.GetFieldDouble(dr["ENGINEHOURS"], 0);
|
||||
mi.EngineHoursDate = FIDbAccess.GetFieldDateTime(dr["HOURSDATE_UTC"], DateTime.MinValue);
|
||||
if (mi.EngineHoursDate != DateTime.MinValue)
|
||||
mi.EngineHoursDate = mi.EngineHoursDate.AddHours(timeadjust);
|
||||
|
||||
mi.Location = new LocationViewItem();
|
||||
mi.Location.Latitude = FIDbAccess.GetFieldDouble(dr["CUR_LATITUDE"], 0);
|
||||
mi.Location.Longitude = FIDbAccess.GetFieldDouble(dr["CUR_LONGITUDE"], 0);
|
||||
mi.Location.LocationTime = FIDbAccess.GetFieldDateTime(dr["LOCDATE_UTC"], DateTime.MinValue);
|
||||
if (mi.Location.LocationTime != DateTime.MinValue)
|
||||
mi.Location.LocationTime = mi.Location.LocationTime.AddHours(timeadjust);
|
||||
|
||||
mi.Odometer = FIDbAccess.GetFieldDouble(dr["ODOMETER"], 0);
|
||||
mi.OdometerUOM = FIDbAccess.GetFieldString(dr["ODOMETERUOM"], string.Empty);
|
||||
|
||||
int makeid = FIDbAccess.GetFieldInt(dr["MAKEID"], 0);
|
||||
MachineMake make = MachineManagement.GetMachineMake(makes, makeid);
|
||||
mi.Make = make == null ? string.Empty : make.Name;
|
||||
|
||||
int modelid = FIDbAccess.GetFieldInt(dr["MODELID"], 0);
|
||||
MachineModel model = MachineManagement.GetMachineModel(models, modelid);
|
||||
mi.Model = model == null ? string.Empty : model.Name;
|
||||
|
||||
int typeid = FIDbAccess.GetFieldInt(dr["TYPEID"], 0);
|
||||
mi.TypeID = typeid;
|
||||
MachineType mtype = MachineManagement.GetMachineType(types, typeid);
|
||||
if (mtype != null)
|
||||
{
|
||||
mi.MachineType = mtype.Name;
|
||||
mi.IconUrl = mtype.IconUrl;
|
||||
}
|
||||
else
|
||||
{
|
||||
mi.MachineType = string.Empty;
|
||||
mi.IconUrl = MachineManagement.DefaultMachineTypeIconUrl;
|
||||
}
|
||||
return mi;
|
||||
}
|
||||
|
||||
private static Foresight.Postion[] ConvertToPosition(PostionItem[] polygon)
|
||||
{
|
||||
if ((polygon == null) || (polygon.Length == 0))
|
||||
{
|
||||
return new Foresight.Postion[0];
|
||||
}
|
||||
List<Foresight.Postion> ls = new List<Postion>(polygon.Length);
|
||||
foreach (var p in polygon)
|
||||
{
|
||||
ls.Add(new Postion(p.Latitude, p.Longitude));
|
||||
}
|
||||
return ls.ToArray();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public static MachineTypeItem[] GetMachineTypes()
|
||||
{
|
||||
List<MachineTypeItem> mTypes = new List<MachineTypeItem>();
|
||||
MachineType[] types = MachineManagement.GetMachineTypes();
|
||||
AssetType[] types = MachineManagement.GetMachineTypes();
|
||||
if (types != null)
|
||||
{
|
||||
foreach (var t in types)
|
||||
@ -543,64 +144,6 @@ namespace IronIntel.Contractor.JobSites
|
||||
return mTypes.ToArray();
|
||||
}
|
||||
|
||||
private static Dictionary<long, List<string>> GetJobSiteTypes(FISqlConnection db)
|
||||
{
|
||||
|
||||
const string SQL = "select JOBSITEID,JOBSITETYPE from JOBSITETYPE";
|
||||
|
||||
Dictionary<long, List<string>> result = new Dictionary<long, List<string>>();
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
DataTable tb = db.GetDataTableBySQL(SQL);
|
||||
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
long jobsiteid = FIDbAccess.GetFieldInt64(dr["JOBSITEID"], 0);
|
||||
string type = FIDbAccess.GetFieldString(dr["JOBSITETYPE"], string.Empty);
|
||||
if (!result.ContainsKey(jobsiteid))
|
||||
result[jobsiteid] = new List<string>();
|
||||
result[jobsiteid].Add(type);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void SaveJobSiteTypes(FIDbAccess db, long jobsiteid, string[] types)
|
||||
{
|
||||
const string SQL = "insert into JOBSITETYPE(JOBSITEID,JOBSITETYPE) values({0},{1})";
|
||||
const string SQL_DEL = "delete from JOBSITETYPE where JOBSITEID={0}";
|
||||
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
|
||||
db.ExecSQL(SQL_DEL, jobsiteid);
|
||||
if (types != null)
|
||||
{
|
||||
foreach (string type in types)
|
||||
{
|
||||
db.ExecSQL(SQL, jobsiteid, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static JobSiteViewItem[] GetUserJobsites(string uid)
|
||||
{
|
||||
const string SQL = @"select a.JOBSITEID,JOBSITENAME,LATITUDE,LONGITUDE,RADIUS,RADUIS_UOM,b.CONTRACTORID,COLOR,NOTES,STARTDATE,ENDDATE,POLYGON, BASEONMACHINEID,ISDELETED from USERJOBSITEMAP a,JOBSITES b where a.JOBSITEID=b.JOBSITEID and a.USERIID={0}";
|
||||
|
||||
FISqlConnection db = SystemParams.GetDbInstance();
|
||||
DataTable tb = db.GetDataTableBySQL(SQL, uid);
|
||||
if (tb.Rows.Count == 0)
|
||||
{
|
||||
return new JobSiteViewItem[0];
|
||||
}
|
||||
List<JobSiteViewItem> ls = new List<JobSiteViewItem>();
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
JobSiteViewItem js = ConvertToJobSiteViewItem(dr);
|
||||
ls.Add(js);
|
||||
}
|
||||
return ls.ToArray();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从Shape文件导入Jobsite范围
|
||||
/// </summary>
|
||||
@ -610,7 +153,12 @@ namespace IronIntel.Contractor.JobSites
|
||||
public static MapPoint[] ImportJobsitePolygon(string filename, byte[] buffer)
|
||||
{
|
||||
Shape.Shape shape = new Shape.Shape();
|
||||
ShapeFileParser.ParseFromShapeFile(buffer, shape);
|
||||
if (filename.EndsWith(".shp", StringComparison.OrdinalIgnoreCase))
|
||||
ShapeFileParser.ParseFromShapeFile(buffer, shape);
|
||||
else if (filename.EndsWith(".kml", StringComparison.OrdinalIgnoreCase))
|
||||
ShapeFileParser.ParseFromKMLFile(buffer, shape);
|
||||
else if (filename.EndsWith(".kmz", StringComparison.OrdinalIgnoreCase))
|
||||
ShapeFileParser.ParseFromKMZFile(buffer, shape);
|
||||
if (shape.Polygons.Count > 0 && shape.Polygons[0].Rings.Count > 0)
|
||||
{
|
||||
return shape.Polygons[0].Rings[0].Points.ToArray();
|
||||
|
@ -65,6 +65,7 @@ namespace IronIntel.Contractor.Machines
|
||||
/// 前端选择的时区的分钟偏移
|
||||
/// </summary>
|
||||
public int OffsetMinute { get; set; }
|
||||
public string DataSource { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@ -82,15 +83,15 @@ namespace IronIntel.Contractor.Machines
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTime.ToString("MM/dd/yyyy HH:mm");
|
||||
return AsofTime.ToString("M/d/yyyy h:m tt");
|
||||
}
|
||||
}
|
||||
public DateTime AsofTime_Local { get; set; }
|
||||
public DateTime AsofTimeLocal { get; set; }
|
||||
public string EventTimeLocalText
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTime_Local.ToString("MM/dd/yyyy HH:mm");
|
||||
return AsofTimeLocal.ToString("M/d/yyyy h:m tt");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -108,15 +109,39 @@ namespace IronIntel.Contractor.Machines
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTime.ToString("MM/dd/yyyy HH:mm");
|
||||
return AsofTime.ToString("M/d/yyyy h:m tt");
|
||||
}
|
||||
}
|
||||
public DateTime AsofTime_Local { get; set; }
|
||||
public DateTime AsofTimeLocal { get; set; }
|
||||
public string EventTimeLocalText
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTime_Local.ToString("MM/dd/yyyy HH:mm");
|
||||
return AsofTimeLocal.ToString("M/d/yyyy h:m tt");
|
||||
}
|
||||
}
|
||||
}
|
||||
public class OEMDD2EngineHoursInfo
|
||||
{
|
||||
public long AssetId { get; set; }
|
||||
public string SN { get; set; }
|
||||
public DateTime AsofTime { get; set; }
|
||||
public string UOM { get; set; }
|
||||
public double Raw { get; set; }
|
||||
public double Calculated { get; set; }
|
||||
public string EventTimeText
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTime.ToString("M/d/yyyy h:m tt");
|
||||
}
|
||||
}
|
||||
public DateTime AsofTimeLocal { get; set; }
|
||||
public string EventTimeLocalText
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTimeLocal.ToString("M/d/yyyy h:m tt");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -125,14 +150,16 @@ namespace IronIntel.Contractor.Machines
|
||||
{
|
||||
public long LogId { get; set; }
|
||||
public long AssetId { get; set; }
|
||||
public string DisplayName { get; set; }//Asset Name
|
||||
public string VIN { get; set; }
|
||||
public DateTime AdjustmentTime { get; set; }
|
||||
public string AdjustmentTimeText { get { return AdjustmentTime.ToString("MM/dd/yyyy HH:mm"); } }
|
||||
public string AdjustmentTimeText { get { return AdjustmentTime.ToString("M/d/yyyy h:m tt"); } }
|
||||
public DateTime EngineHoursTime { get; set; }
|
||||
public string EngineHoursTimeText { get { return EngineHoursTime.ToString("MM/dd/yyyy HH:mm"); } }
|
||||
public string EngineHoursTimeText { get { return EngineHoursTime.ToString("M/d/yyyy h:m tt"); } }
|
||||
public DateTime AdjustmentLocalTime { get; set; }
|
||||
public string AdjustmentLocalTimeText { get { return AdjustmentLocalTime.ToString("MM/dd/yyyy HH:mm"); } }
|
||||
public string AdjustmentLocalTimeText { get { return AdjustmentLocalTime.ToString("M/d/yyyy h:m tt"); } }
|
||||
public DateTime EngineHoursLocalTime { get; set; }
|
||||
public string EngineHoursLocalTimeText { get { return EngineHoursLocalTime.ToString("MM/dd/yyyy HH:mm"); } }
|
||||
public string EngineHoursLocalTimeText { get { return EngineHoursLocalTime.ToString("M/d/yyyy h:m tt"); } }
|
||||
|
||||
private double _EngineHours;
|
||||
public double EngineHours
|
||||
|
@ -20,6 +20,7 @@ namespace IronIntel.Contractor.Machines
|
||||
public double Amount { get; set; }
|
||||
public double Percent { get; set; }
|
||||
public string UOM { get; set; }
|
||||
public string PercentText { get; set; }
|
||||
public string ReceivedDateStr
|
||||
{
|
||||
get
|
||||
|
@ -1,6 +1,5 @@
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -31,10 +30,13 @@ namespace IronIntel.Contractor.Machines
|
||||
}
|
||||
}
|
||||
|
||||
public string CalampDeviceAirID { get; set; }
|
||||
public string CalampDeviceAirID { get; set; }//PairedDeviceSN
|
||||
public bool TelematicsEnabled { get; set; }
|
||||
public bool Hide { get; set; }
|
||||
public bool OnRoad { get; set; }
|
||||
public bool Attachment { get; set; }
|
||||
|
||||
public bool Preloaded { get; set; }
|
||||
public int MakeYear { get; set; }
|
||||
public string DealerID { get; set; }
|
||||
public string Dealer { get; set; }
|
||||
@ -46,6 +48,19 @@ namespace IronIntel.Contractor.Machines
|
||||
public int MakeID { get; set; }
|
||||
public string VIN { get; set; }
|
||||
public DateTime? EngineHoursDate { get; set; }
|
||||
public AssetShareStatus ShareStatus { get; set; }
|
||||
public DateTime? AddedTime { get; set; }
|
||||
public DateTime? AddedLocalTime { get; set; }
|
||||
|
||||
public double Odometer;
|
||||
public string OdometerUOM { get; set; }
|
||||
public DateTime? OdometerDate { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string AcquisitionType { get; set; }
|
||||
public string PMPlans { get; set; }
|
||||
public string AssetGroups { get; set; }
|
||||
public string Jobsites { get; set; }
|
||||
public AssetCustomStatus CustomStatus { get; set; }
|
||||
public string DisplayName
|
||||
{
|
||||
get
|
||||
@ -61,8 +76,10 @@ namespace IronIntel.Contractor.Machines
|
||||
return name;
|
||||
}
|
||||
}
|
||||
public string EngineHoursDateStr { get { return EngineHoursDate == null ? "" : EngineHoursDate.Value.ToShortDateString(); } }
|
||||
public string EngineHoursDateTimeStr { get { return EngineHoursDate == null ? "" : EngineHoursDate.Value.ToString(); } }
|
||||
public string AddedTimeStr { get { return (AddedLocalTime == null || AddedLocalTime.Value <= Helper.DBMinDateTime) ? "" : AddedLocalTime.Value.ToShortDateString(); } }
|
||||
public string EngineHoursDateStr { get { return (EngineHoursDate == null || EngineHoursDate.Value <= Helper.DBMinDateTime) ? "" : EngineHoursDate.Value.ToShortDateString(); } }
|
||||
public string EngineHoursDateTimeStr { get { return (EngineHoursDate == null || EngineHoursDate.Value <= Helper.DBMinDateTime) ? "" : EngineHoursDate.Value.ToString(); } }
|
||||
public string OdometerDateStr { get { return (OdometerDate == null || OdometerDate.Value <= Helper.DBMinDateTime) ? "" : OdometerDate.Value.ToShortDateString(); } }
|
||||
}
|
||||
|
||||
|
||||
@ -123,6 +140,9 @@ namespace IronIntel.Contractor.Machines
|
||||
public bool TelematicsEnabled { get; set; }
|
||||
public bool Hidden { get; set; }
|
||||
public bool OnRoad { get; set; }
|
||||
public bool Attachment { get; set; }
|
||||
|
||||
public bool Preloaded { get; set; }
|
||||
public string EQClass { get; set; }
|
||||
public string CostCenter { get; set; }
|
||||
public string AquisitionType { get; set; }
|
||||
@ -133,12 +153,16 @@ namespace IronIntel.Contractor.Machines
|
||||
|
||||
public string ContractorID { get; set; }
|
||||
|
||||
public long OnSiteJobsiteID { get; set; }
|
||||
public string[] OnSiteJobsiteIDs { get; set; }
|
||||
public List<AssetJobsiteInfo> JobSites { get; set; }
|
||||
public string[] ContactIDs { get; set; }
|
||||
public string[] MachineGroupIDs { get; set; }
|
||||
public MachineRentalInfo MachineRental { get; set; }
|
||||
public MachineAttributeClient[] MachineAttributes { get; set; }
|
||||
public StringKeyValue[] VisibleOnWorkOrders { get; set; }
|
||||
public AttachmentAttributeInfo AttachmentInfo { get; set; }
|
||||
public AssetShareStatus ShareStatus { get; set; }
|
||||
public AssetCustomStatus CustomStatus { get; set; }
|
||||
|
||||
|
||||
public string AddedOnStr
|
||||
@ -264,14 +288,6 @@ namespace IronIntel.Contractor.Machines
|
||||
}//由于地图显示及排序的名称
|
||||
}
|
||||
|
||||
public class MachineOffsetItem
|
||||
{
|
||||
public Int64 MachineID { get; set; }
|
||||
public double Value { get; set; }
|
||||
public double Offset { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public OffsetTypes Type { get; set; }
|
||||
}
|
||||
|
||||
public class DeviceItem
|
||||
{
|
||||
@ -296,9 +312,14 @@ namespace IronIntel.Contractor.Machines
|
||||
public long DeviceID { get; set; }
|
||||
public bool FIInstalltion { get; set; }
|
||||
public string Installer { get; set; }
|
||||
public bool Tamper { get; set; }
|
||||
public bool Utilization { get; set; }
|
||||
public string SalesOrderNumber { get; set; }
|
||||
public string AddDateStr { get { return AddLocalDate == null ? "" : AddLocalDate.Value.ToShortDateString(); } }
|
||||
public string AddDateStr1 { get { return AddLocalDate == null ? "" : AddLocalDate.Value.ToString("yyyy-MM-dd"); } }
|
||||
public string InvoiceDateStr { get { return InvoiceDate == null ? "" : InvoiceDate.Value.ToShortDateString(); } }
|
||||
public string ServiceStartDateStr { get { return ServiceStartDate == null ? "" : ServiceStartDate.Value.ToShortDateString(); } }
|
||||
public string ServiceStartDateStr1 { get { return ServiceStartDate == null ? "" : ServiceStartDate.Value.ToString("yyyy-MM-dd"); } }
|
||||
}
|
||||
|
||||
public class PairedAssetItem
|
||||
@ -313,15 +334,30 @@ namespace IronIntel.Contractor.Machines
|
||||
public double? EngineHours { get; set; }
|
||||
public DateTime? EngineHoursDate { get; set; }
|
||||
public DateTime? EngineHoursLocalDate { get; set; }
|
||||
public string EngineHoursDateStr { get { return EngineHoursLocalDate == null ? "" : EngineHoursLocalDate.Value.ToShortDateString(); } }
|
||||
public string EngineHoursDateStr { get { return EngineHoursLocalDate == null ? "" : EngineHoursLocalDate.Value.ToString("M/d/yyyy"); } }
|
||||
}
|
||||
public class CommentItem
|
||||
|
||||
public class CommentItem : Foresight.Fleet.Services.CommentInfo
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public DateTime SubmitLocalDate { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string Comment { get; set; }
|
||||
public string SubmitDateStr { get { return SubmitLocalDate == DateTime.MinValue ? "" : SubmitLocalDate.ToString(); } }
|
||||
public string SubmitDateStr { get { return SubmitLocalDate == DateTime.MinValue ? "" : SubmitLocalDate.ToString("M/d/yyyy h:m tt"); } }
|
||||
|
||||
public void FormatFollowUp()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(FollowUp))
|
||||
{
|
||||
string[] fus = FollowUp.Split(';');
|
||||
for (int i = 0; i < fus.Length; i++)
|
||||
{
|
||||
if (!Helper.IsEmail(fus[i]))
|
||||
fus[i] = Foresight.Standard.PhoneNumber.FormatPhoneNumber(fus[i]);
|
||||
}
|
||||
FollowUp = string.Join(";", fus);
|
||||
}
|
||||
}
|
||||
}
|
||||
public class InstallNotesItemC : Foresight.Fleet.Services.Device.InstallNotesItem
|
||||
{
|
||||
public string InstallTimeLocalStr { get { return InstallTimeLocal == DateTime.MinValue ? "" : InstallTimeLocal.ToString("M/d/yyyy h:m:s tt"); } }
|
||||
}
|
||||
|
||||
public class MachineGroup
|
||||
@ -400,15 +436,16 @@ namespace IronIntel.Contractor.Machines
|
||||
|
||||
public class AssetAttachmentItem
|
||||
{
|
||||
public long ID { get; set; }
|
||||
public long AssetId { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public string AddedByUserIID { get; set; }
|
||||
public string AddedByUserName { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public bool VisibleOnWorkOrder { get; set; }
|
||||
public long Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string FileType { get; set; }
|
||||
public DateTime AddedOn { get; set; }
|
||||
public string AddedOnStr { get { return AddedOn.ToString(); } }
|
||||
public byte[] FileData { get; set; }
|
||||
public DateTime AddedOnLocal { get; set; }
|
||||
public string AddedOnLocalStr { get { return AddedOnLocal.ToString(); } }
|
||||
public string AddedBy { get; set; }
|
||||
public string Url { get; set; }
|
||||
public string Description { get; set; }
|
||||
public bool VisibleOnWorkOrder { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,6 @@ using System.Text;
|
||||
using System.Data;
|
||||
using Foresight.Data;
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using IronIntel.Services.MapView;
|
||||
using IronIntel.Services.Customers;
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
|
||||
@ -15,13 +12,13 @@ namespace IronIntel.Contractor.Machines
|
||||
{
|
||||
public class MachineManagement
|
||||
{
|
||||
private static List<MachineMake> _Makes = new List<MachineMake>();
|
||||
private static List<AssetMake> _Makes = new List<AssetMake>();
|
||||
private static object _sycmakes = new object();
|
||||
|
||||
private static List<MachineType> _MachineTypes = new List<MachineType>();
|
||||
private static List<AssetType> _MachineTypes = new List<AssetType>();
|
||||
private static object _syctypes = new object();
|
||||
|
||||
private static List<MachineModel> _MachineModels = new List<MachineModel>();
|
||||
private static List<AssetModel> _MachineModels = new List<AssetModel>();
|
||||
private static object _sycmodels = new object();
|
||||
|
||||
private const string MachineFields = "{0}MACHINEID,{0}MACHINENAME,{0}MAKEID,{0}MODELID,{0}TYPEID,{0}MACHINEICONID,{0}DEVICEID,{0}VIN,{0}MAKEYEAR,{0}NOTES,{0}STATUS,{0}CONTRACTORID,{0}DEALERID,{0}UID,{0}ADDEDON,{0}CUR_LONGITUDE,{0}CUR_LATITUDE,{0}LOCDATE_UTC,{0}ENGINEHOURS,{0}HOURSDATE_UTC,{0}DATASOURCE,{0}HIDE,{0}FUEL_CONSUMED,{0}FUEL_UNITS,{0}FUEL_DATE,{0}ODOMETER,{0}ODODATE_UTC,{0}ODOMETERUOM,{0}FUELCOST,{0}FUELCOSTUOM,{0}MACHINERATE,{0}WORKTYPE,{0}RETIREMENTHOURS,{0}RETIREMENTODO,{0}ALTITUDE,{0}ALTITUDEUNITS,{0}IDLEHOURSUTC,{0}IDLEHOURS,{0}LOADCOUNTUTC,{0}LOADCOUNT,{0}PAYLOADTOTALUTC,{0}PAYLOADTOTAL,{0}PAYLOADTOTALUNITS,{0}DEFREMAININGUTC,{0}DEFREMAINING,{0}FUELREMAININGUTC,{0}FUELREMAININGPERCENT,{0}MACHINENAME2,{0}ONROAD,{0}LEASESTART,{0}LEASEEND,{0}LEASEHOURS,{0}UNDERCARRIAGEHOURS,{0}ODOSTART2,{0}ISDELETED,{0}DELETEDDATE,{0}ODOSTART2DATASOURCE,{0}LOCDATASOURCE,{0}HOURSDATASOURCE,{0}FUELDATASOURCE,{0}AQUISITIONTYPE,{0}ICONFILENAME,{0}STARTINGENGINEHOURS,{0}DISTANCECALCBY,{0}TELEMATICSENABLED,{0}COSTCENTER,{0}EQCLASS,{0}DESCRIPTION,{0}ADDEDBY";
|
||||
@ -40,11 +37,11 @@ namespace IronIntel.Contractor.Machines
|
||||
|
||||
public static void RefreshMakes()
|
||||
{
|
||||
MachineMake[] mks = null;
|
||||
MachineServiceClient2 mc = SystemParams.GetMachineServiceClient();
|
||||
AssetMake[] mks = null;
|
||||
var acp = FleetServiceClientHelper.CreateClient<AssetClassProvider>();
|
||||
try
|
||||
{
|
||||
mks = mc.GetMachineMakes();
|
||||
mks = acp.GetAssetMakes(string.Empty);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -61,11 +58,12 @@ namespace IronIntel.Contractor.Machines
|
||||
|
||||
public static void RefreshMachineTypes()
|
||||
{
|
||||
MachineType[] mks = null;
|
||||
MachineServiceClient2 mc = SystemParams.GetMachineServiceClient();
|
||||
AssetType[] mks = null;
|
||||
|
||||
var acp = FleetServiceClientHelper.CreateClient<AssetClassProvider>();
|
||||
try
|
||||
{
|
||||
mks = mc.GetMachineTypes();
|
||||
mks = acp.GetAssetTypes(string.Empty);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -82,11 +80,11 @@ namespace IronIntel.Contractor.Machines
|
||||
|
||||
public static void RefreshModels()
|
||||
{
|
||||
MachineModel[] mks = null;
|
||||
MachineServiceClient2 mc = SystemParams.GetMachineServiceClient();
|
||||
AssetModel[] mks = null;
|
||||
var acp = FleetServiceClientHelper.CreateClient<AssetClassProvider>();
|
||||
try
|
||||
{
|
||||
mks = mc.GetMachineModels();
|
||||
mks = acp.GetAssetModels(-1, string.Empty);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -101,7 +99,7 @@ namespace IronIntel.Contractor.Machines
|
||||
}
|
||||
}
|
||||
|
||||
public static MachineMake[] GetMachineMakes()
|
||||
public static AssetMake[] GetMachineMakes()
|
||||
{
|
||||
lock (_sycmakes)
|
||||
{
|
||||
@ -109,7 +107,7 @@ namespace IronIntel.Contractor.Machines
|
||||
}
|
||||
}
|
||||
|
||||
public static MachineType[] GetMachineTypes()
|
||||
public static AssetType[] GetMachineTypes()
|
||||
{
|
||||
lock (_syctypes)
|
||||
{
|
||||
@ -117,7 +115,7 @@ namespace IronIntel.Contractor.Machines
|
||||
}
|
||||
}
|
||||
|
||||
public static MachineModel[] GetMachineModels()
|
||||
public static AssetModel[] GetMachineModels()
|
||||
{
|
||||
lock (_sycmodels)
|
||||
{
|
||||
@ -125,7 +123,7 @@ namespace IronIntel.Contractor.Machines
|
||||
}
|
||||
}
|
||||
|
||||
public static MachineMake GetMachineMake(int makeid)
|
||||
public static AssetMake GetMachineMake(int makeid)
|
||||
{
|
||||
var makes = GetMachineMakes();
|
||||
foreach (var make in makes)
|
||||
@ -153,7 +151,7 @@ namespace IronIntel.Contractor.Machines
|
||||
return make == null ? string.Empty : make.Name;
|
||||
}
|
||||
|
||||
public static MachineModel GetMachineModel(int modelid)
|
||||
public static AssetModel GetMachineModel(int modelid)
|
||||
{
|
||||
var models = GetMachineModels();
|
||||
foreach (var model in models)
|
||||
@ -181,7 +179,7 @@ namespace IronIntel.Contractor.Machines
|
||||
return model == null ? string.Empty : model.Name;
|
||||
}
|
||||
|
||||
public static MachineType GetMachineType(int typeid)
|
||||
public static AssetType GetMachineType(int typeid)
|
||||
{
|
||||
var types = GetMachineTypes();
|
||||
foreach (var mtype in types)
|
||||
@ -209,9 +207,9 @@ namespace IronIntel.Contractor.Machines
|
||||
return mtype == null ? string.Empty : mtype.Name;
|
||||
}
|
||||
|
||||
public static MachineMake GetMachineMake(IEnumerable<MachineMake> makes, int id)
|
||||
public static AssetMake GetMachineMake(IEnumerable<AssetMake> makes, int id)
|
||||
{
|
||||
foreach (MachineMake mk in makes)
|
||||
foreach (AssetMake mk in makes)
|
||||
{
|
||||
if (id == mk.ID)
|
||||
{
|
||||
@ -221,9 +219,9 @@ namespace IronIntel.Contractor.Machines
|
||||
return null;
|
||||
}
|
||||
|
||||
public static MachineType GetMachineType(IEnumerable<MachineType> types, int id)
|
||||
public static AssetType GetMachineType(IEnumerable<AssetType> types, int id)
|
||||
{
|
||||
foreach (MachineType mk in types)
|
||||
foreach (AssetType mk in types)
|
||||
{
|
||||
if (id == mk.ID)
|
||||
{
|
||||
@ -233,9 +231,9 @@ namespace IronIntel.Contractor.Machines
|
||||
return null;
|
||||
}
|
||||
|
||||
public static MachineModel GetMachineModel(IEnumerable<MachineModel> models, int id)
|
||||
public static AssetModel GetMachineModel(IEnumerable<AssetModel> models, int id)
|
||||
{
|
||||
foreach (MachineModel mk in models)
|
||||
foreach (AssetModel mk in models)
|
||||
{
|
||||
if (id == mk.ID)
|
||||
{
|
||||
@ -257,8 +255,8 @@ namespace IronIntel.Contractor.Machines
|
||||
{
|
||||
try
|
||||
{
|
||||
MachineServiceClient2 mc = SystemParams.GetMachineServiceClient();
|
||||
_DefaultMachineTypeIconUrl = mc.GetDefaultMachineTypeIconUrl();
|
||||
var acp = FleetServiceClientHelper.CreateClient<AssetClassProvider>();
|
||||
_DefaultMachineTypeIconUrl = acp.GetDefaultMachineTypeIconUrl();
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
@ -267,13 +265,6 @@ namespace IronIntel.Contractor.Machines
|
||||
}
|
||||
}
|
||||
|
||||
public static MachineAlertViewClient GetMachineAlertViewClient()
|
||||
{
|
||||
string[] address = SystemParams.SystemServiceAddresses;
|
||||
MachineAlertViewClient ic = new MachineAlertViewClient(address[0]);
|
||||
return ic;
|
||||
}
|
||||
|
||||
public static bool Contains(string text, string val)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(text))
|
||||
@ -286,50 +277,6 @@ namespace IronIntel.Contractor.Machines
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateMachineHideStatus(IEnumerable<Tuple<long, bool>> machines)
|
||||
{
|
||||
const string SQL = "update MACHINES set HIDE={1} where MACHINEID={0}";
|
||||
FISqlConnection db = SystemParams.GetDbInstance();
|
||||
foreach (Tuple<long, bool> mac in machines)
|
||||
{
|
||||
db.ExecSQL(SQL, mac.Item1, mac.Item2 ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static MachineItem GetMachineByID(string sessionid, long machineid, FIDbAccess db = null)
|
||||
{
|
||||
string SQL = "select " + string.Format(MachineFields, "") + " from MACHINES where MACHINEID={0}";
|
||||
|
||||
if (db == null)
|
||||
{
|
||||
db = SystemParams.GetDbInstance();
|
||||
}
|
||||
DataTable tb = db.GetDataTableBySQL(SQL, machineid);
|
||||
if (tb.Rows.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
MachineManagement.RefreshBaseData();
|
||||
MachineMake[] makes = MachineManagement.GetMachineMakes();
|
||||
MachineModel[] models = MachineManagement.GetMachineModels();
|
||||
MachineType[] types = MachineManagement.GetMachineTypes();
|
||||
|
||||
MachineItem mi = null;
|
||||
if (tb.Rows.Count > 0)
|
||||
{
|
||||
mi = ConvertToMachineItem(tb.Rows[0], makes, models, types);
|
||||
mi.AddedOn = FIDbAccess.GetFieldDateTime(tb.Rows[0]["ADDEDON"], DateTime.MinValue).AddHours(SystemParams.GetHoursOffset());
|
||||
mi.AddedBy = FIDbAccess.GetFieldString(tb.Rows[0]["ADDEDBY"], string.Empty);
|
||||
if (!string.IsNullOrEmpty(mi.AddedBy))
|
||||
{
|
||||
var user = Users.UserManagement.GetUserByIID(mi.AddedBy);
|
||||
mi.AddedByName = user == null ? mi.AddedBy : user.DisplayName;
|
||||
}
|
||||
}
|
||||
return mi;
|
||||
}
|
||||
|
||||
public static MachineItem[] GetMachines(string sessionid, string useriid, string searchtxt, string companyid = null)
|
||||
{
|
||||
string SQL = "select " + string.Format(MachineFields, "") + " from MACHINES order by MACHINENAME";
|
||||
@ -360,10 +307,10 @@ namespace IronIntel.Contractor.Machines
|
||||
availableAssetsids = FleetServiceClientHelper.CreateClient<AssetQueryClient>(companyid, sessionid).GetAvailableAssetsForUsers(companyid, useriid);
|
||||
}
|
||||
|
||||
MachineManagement.RefreshBaseData();
|
||||
MachineMake[] makes = MachineManagement.GetMachineMakes();
|
||||
MachineModel[] models = MachineManagement.GetMachineModels();
|
||||
MachineType[] types = MachineManagement.GetMachineTypes();
|
||||
RefreshBaseData();
|
||||
AssetMake[] makes = GetMachineMakes();
|
||||
AssetModel[] models = GetMachineModels();
|
||||
AssetType[] types = GetMachineTypes();
|
||||
|
||||
List<MachineItem> ls = new List<MachineItem>();
|
||||
if (tb.Rows.Count > 0)
|
||||
@ -425,10 +372,10 @@ namespace IronIntel.Contractor.Machines
|
||||
if (user.UserType < Users.UserTypes.Admin)
|
||||
availableAssetsids = FleetServiceClientHelper.CreateClient<AssetQueryClient>(companyid, sessionid).GetAvailableAssetsForUsers(companyid, useriid);
|
||||
|
||||
MachineManagement.RefreshBaseData();
|
||||
MachineMake[] makes = MachineManagement.GetMachineMakes();
|
||||
MachineModel[] models = MachineManagement.GetMachineModels();
|
||||
MachineType[] types = MachineManagement.GetMachineTypes();
|
||||
RefreshBaseData();
|
||||
AssetMake[] makes = GetMachineMakes();
|
||||
AssetModel[] models = GetMachineModels();
|
||||
AssetType[] types = GetMachineTypes();
|
||||
|
||||
List<MachineItem> ls = new List<MachineItem>();
|
||||
if (tb.Rows.Count > 0)
|
||||
@ -461,7 +408,7 @@ namespace IronIntel.Contractor.Machines
|
||||
return ls.ToArray();
|
||||
}
|
||||
|
||||
private static MachineItem ConvertToMachineItem(DataRow dr, MachineMake[] makes, MachineModel[] models, MachineType[] types)
|
||||
private static MachineItem ConvertToMachineItem(DataRow dr, AssetMake[] makes, AssetModel[] models, AssetType[] types)
|
||||
{
|
||||
MachineItem mi = new MachineItem();
|
||||
mi.MachineID = FIDbAccess.GetFieldInt(dr["MACHINEID"], 0);
|
||||
@ -489,15 +436,15 @@ namespace IronIntel.Contractor.Machines
|
||||
mi.RetirementOdo = FIDbAccess.GetFieldDouble(dr["RETIREMENTODO"], 0);
|
||||
|
||||
mi.MakeID = FIDbAccess.GetFieldInt(dr["MAKEID"], 0);
|
||||
MachineMake make = MachineManagement.GetMachineMake(makes, mi.MakeID);
|
||||
AssetMake make = GetMachineMake(makes, mi.MakeID);
|
||||
mi.Make = make == null ? string.Empty : make.Name;
|
||||
|
||||
mi.ModelID = FIDbAccess.GetFieldInt(dr["MODELID"], 0);
|
||||
MachineModel model = MachineManagement.GetMachineModel(models, mi.ModelID);
|
||||
AssetModel model = GetMachineModel(models, mi.ModelID);
|
||||
mi.Model = model == null ? string.Empty : model.Name;
|
||||
|
||||
mi.TypeID = FIDbAccess.GetFieldInt(dr["TYPEID"], 0);
|
||||
MachineType mtype = MachineManagement.GetMachineType(types, mi.TypeID);
|
||||
AssetType mtype = GetMachineType(types, mi.TypeID);
|
||||
mi.MachineType = mtype == null ? string.Empty : mtype.Name;
|
||||
mi.OnRoad = FIDbAccess.GetFieldInt(dr["ONROAD"], 0) == 1;
|
||||
mi.LeaseStart = FIDbAccess.GetFieldDateTime(dr["LEASESTART"], DateTime.MinValue);
|
||||
@ -554,23 +501,6 @@ namespace IronIntel.Contractor.Machines
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void SaveMachineToMachineGroups(FISqlConnection db, long machineid, string[] groupids)
|
||||
{
|
||||
const string SQL = "insert into MACHINEGROUPMAP(MACHINEID,GROUPID) values({0},{1})";
|
||||
const string SQL_DEL = "delete from MACHINEGROUPMAP where MACHINEID={0}";
|
||||
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
db.ExecSQL(SQL_DEL, machineid);
|
||||
if (groupids != null && groupids.Length > 0)
|
||||
{
|
||||
foreach (var groupid in groupids)
|
||||
{
|
||||
db.ExecSQL(SQL, machineid, groupid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int DeleteMachineGroup(string groupID)
|
||||
{
|
||||
const string SQL_Delete = "delete from MACHINEGROUPS where GROUPID={0} delete from MACHINEGROUPMAP where GROUPID={0} ";
|
||||
@ -631,7 +561,7 @@ namespace IronIntel.Contractor.Machines
|
||||
|
||||
public static MachineItem[] GetMachineByGroup(string groupid)
|
||||
{
|
||||
string SQL = "select " + string.Format(MachineFields, "b.") + " from MACHINEGROUPMAP a left join MACHINES b on a.MACHINEID=b.MACHINEID where a.GROUPID={0} order by MACHINENAME";
|
||||
string SQL = "select " + string.Format(MachineFields, "b.") + " from MACHINEGROUPMAP a with(nolock) left join MACHINES b with(nolock) on a.MACHINEID=b.MACHINEID where a.GROUPID={0} order by MACHINENAME";
|
||||
|
||||
FIDbAccess db = SystemParams.GetDbInstance();
|
||||
if (db == null)
|
||||
@ -645,10 +575,10 @@ namespace IronIntel.Contractor.Machines
|
||||
return new MachineItem[0];
|
||||
}
|
||||
|
||||
MachineManagement.RefreshBaseData();
|
||||
MachineMake[] makes = MachineManagement.GetMachineMakes();
|
||||
MachineModel[] models = MachineManagement.GetMachineModels();
|
||||
MachineType[] types = MachineManagement.GetMachineTypes();
|
||||
RefreshBaseData();
|
||||
AssetMake[] makes = GetMachineMakes();
|
||||
AssetModel[] models = GetMachineModels();
|
||||
AssetType[] types = GetMachineTypes();
|
||||
|
||||
List<MachineItem> ls = new List<MachineItem>();
|
||||
if (tb.Rows.Count > 0)
|
||||
@ -664,7 +594,7 @@ namespace IronIntel.Contractor.Machines
|
||||
|
||||
public static MachineGroup[] GetMachineGroupByUser(string useriid, FISqlConnection db = null)
|
||||
{
|
||||
const string SQL = "select b.* from USERMACHINEGROUPMAP a left join MACHINEGROUPS b on a.GROUPID=b.GROUPID where a.USERIID={0} order by GROUPNAME";
|
||||
const string SQL = "select b.* from USERMACHINEGROUPMAP a with(nolock) left join MACHINEGROUPS b with(nolock) on a.GROUPID=b.GROUPID where a.USERIID={0} order by GROUPNAME";
|
||||
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
@ -682,64 +612,23 @@ namespace IronIntel.Contractor.Machines
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
public static void SaveUserMachineGroup(string useriid, string[] groupids)
|
||||
public static AssetType[] GetMachineTypesByUser(string useriid, FISqlConnection db = null)
|
||||
{
|
||||
const string SQL_DeleteDetail = "delete USERMACHINEGROUPMAP where USERIID={0}";
|
||||
const string SQL_InsertDetail = "insert USERMACHINEGROUPMAP(USERIID,GROUPID) values({0},{1})";
|
||||
FISqlConnection db = SystemParams.GetDbInstance();
|
||||
const string SQL = "select b.* from USERMACHINETYPEMAP a with(nolock) left join MACHINE_TYPE b with(nolock) on a.TYPEID=b.TYPEID where a.USERIID={0} order by TYPENAME";
|
||||
|
||||
db.ExecSQL(SQL_DeleteDetail, useriid);
|
||||
if (groupids != null && groupids.Length > 0)
|
||||
{
|
||||
foreach (string gid in groupids)
|
||||
db.ExecSQL(SQL_InsertDetail, useriid, gid);
|
||||
}
|
||||
}
|
||||
|
||||
public static Dictionary<int, List<StringKeyValue>> GetGroupsAssets(FISqlConnection db = null)
|
||||
{
|
||||
const string SQL_C = "select mgm.MACHINEID,mgm.GROUPID,mg.GROUPNAME from MACHINEGROUPMAP mgm left join MACHINEGROUPS mg on mgm.GROUPID=mg.GROUPID";
|
||||
|
||||
Dictionary<int, List<StringKeyValue>> result = new Dictionary<int, List<StringKeyValue>>();
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
DataTable tb = db.GetDataTableBySQL(SQL_C);
|
||||
DataTable dt = db.GetDataTableBySQL(SQL, useriid);
|
||||
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
List<AssetType> result = new List<AssetType>();
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
int machineid = FIDbAccess.GetFieldInt(dr["MACHINEID"], -1);
|
||||
StringKeyValue kv = new StringKeyValue();
|
||||
kv.Key = FIDbAccess.GetFieldString(dr["GROUPID"], "");
|
||||
kv.Value = FIDbAccess.GetFieldString(dr["GROUPNAME"], ""); ;
|
||||
if (!result.ContainsKey(machineid))
|
||||
result[machineid] = new List<StringKeyValue>();
|
||||
result[machineid].Add(kv);
|
||||
AssetType mg = new AssetType();
|
||||
mg.ID = FIDbAccess.GetFieldInt(dr["TYPEID"], 0);
|
||||
mg.Name = FIDbAccess.GetFieldString(dr["TYPENAME"], "");
|
||||
result.Add(mg);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取机器组和机器的对应关系
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Dictionary<int, List<string>> GetGroupMachines(FISqlConnection db = null)
|
||||
{
|
||||
const string SQL_C = "select MACHINEID,GROUPID from MACHINEGROUPMAP";
|
||||
|
||||
Dictionary<int, List<string>> result = new Dictionary<int, List<string>>();
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
DataTable tb = db.GetDataTableBySQL(SQL_C);
|
||||
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
int machineid = FIDbAccess.GetFieldInt(dr["MACHINEID"], -1);
|
||||
string groupid = FIDbAccess.GetFieldString(dr["GROUPID"], "");
|
||||
if (!result.ContainsKey(machineid))
|
||||
result[machineid] = new List<string>();
|
||||
result[machineid].Add(groupid);
|
||||
}
|
||||
return result;
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -748,7 +637,7 @@ namespace IronIntel.Contractor.Machines
|
||||
/// <returns></returns>
|
||||
public static long[] GetGroupMachines(string[] groupids, FISqlConnection db = null)
|
||||
{
|
||||
const string SQL_C = "select distinct MACHINEID from MACHINEGROUPMAP where GROUPID in ({0})";
|
||||
const string SQL_C = "select distinct MACHINEID from MACHINEGROUPMAP with(nolock) where GROUPID in ({0})";
|
||||
|
||||
List<long> result = new List<long>();
|
||||
if (db == null)
|
||||
@ -763,30 +652,6 @@ namespace IronIntel.Contractor.Machines
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取机器组
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string[] GetGroupByMachineID(FISqlConnection db, long machineid)
|
||||
{
|
||||
const string SQL_C = "select GROUPID from MACHINEGROUPMAP where MACHINEID={0}";
|
||||
|
||||
Dictionary<int, List<string>> result = new Dictionary<int, List<string>>();
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
DataTable tb = db.GetDataTableBySQL(SQL_C, machineid);
|
||||
if (tb.Rows.Count == 0)
|
||||
return new string[0];
|
||||
|
||||
List<string> list = new List<string>();
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
string groupid = FIDbAccess.GetFieldString(dr["GROUPID"], "");
|
||||
list.Add(groupid);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public static void ChangeMachineIconFile(long machineid, string filename, byte[] filebyte, FISqlConnection db = null)
|
||||
{
|
||||
const string SQL_NULL = "update MACHINES set ICONFILENAME=null,ICONDATA=null where MACHINEID={0}";
|
||||
@ -800,37 +665,10 @@ namespace IronIntel.Contractor.Machines
|
||||
db.ExecSQL(SQL_ICON, machineid, filename, filebyte);
|
||||
}
|
||||
|
||||
public static byte[] GetMachineIconFile(string companyid, long machineid)
|
||||
{
|
||||
const string SQL = "select ICONDATA from MACHINES where MACHINEID={0}";
|
||||
FISqlConnection db = null;
|
||||
if (SystemParams.IsDealer)
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(companyid);
|
||||
db = new FISqlConnection(connetionstring);
|
||||
}
|
||||
else
|
||||
db = SystemParams.GetDbInstance();
|
||||
|
||||
object obj = db.GetRC1BySQL(SQL, machineid);
|
||||
return FIDbAccess.GetFieldBytes(obj);
|
||||
}
|
||||
|
||||
public static MachineInfo2 GetMachineByVIN(string vin)
|
||||
{
|
||||
MachineServiceClient2 mc = SystemParams.GetMachineServiceClient();
|
||||
return mc.GetMachineInfoByVIN(vin);
|
||||
}
|
||||
|
||||
public static MachineInfo2 GetMachineByID(long machineid)
|
||||
{
|
||||
MachineServiceClient2 mc = SystemParams.GetMachineServiceClient();
|
||||
return mc.GetMachineInfoByMachineID(machineid);
|
||||
}
|
||||
|
||||
public static string GetMachineIDByVIN(string vin)
|
||||
{
|
||||
const string SQL = "select MACHINEID from MACHINES where VIN={0} and isnull(HIDE,0)=0";
|
||||
const string SQL = "select MACHINEID from MACHINES with(nolock) where VIN={0} and (HIDE is null or HIDE=0)";
|
||||
FISqlConnection db = SystemParams.GetDbInstance();
|
||||
|
||||
object obj = db.GetRC1BySQL(SQL, vin);
|
||||
@ -840,7 +678,7 @@ namespace IronIntel.Contractor.Machines
|
||||
public static MaintenanceMachineInfo[] GetContactMachinesByID(string contactid)
|
||||
{
|
||||
const string SQL = @"select a.MACHINEID,b.MACHINENAME,b.MACHINENAME2,b.VIN,b.MAKEID,b.MODELID,b.TYPEID,b.HIDE,ISNULL(b.ENGINEHOURS,0) as ENGINEHOURS,
|
||||
ISNULL(b.ODOMETER,0) as ODOMETER,ISNULL(b.ODOMETERUOM,'Mile') AS ODOMETERUOM from USERMACHINEMAP a,MACHINES b
|
||||
ISNULL(b.ODOMETER,0) as ODOMETER,ISNULL(b.ODOMETERUOM,'Mile') AS ODOMETERUOM from USERMACHINEMAP a with(nolock),MACHINES b with(nolock)
|
||||
where a.MACHINEID=b.MACHINEID and a.USERIID={0}";
|
||||
|
||||
FISqlConnection db = SystemParams.GetDbInstance();
|
||||
@ -849,10 +687,10 @@ namespace IronIntel.Contractor.Machines
|
||||
{
|
||||
return new MaintenanceMachineInfo[0];
|
||||
}
|
||||
MachineManagement.RefreshBaseData();
|
||||
MachineMake[] makes = MachineManagement.GetMachineMakes();
|
||||
MachineModel[] models = MachineManagement.GetMachineModels();
|
||||
MachineType[] types = MachineManagement.GetMachineTypes();
|
||||
RefreshBaseData();
|
||||
AssetMake[] makes = GetMachineMakes();
|
||||
AssetModel[] models = GetMachineModels();
|
||||
AssetType[] types = GetMachineTypes();
|
||||
List<MaintenanceMachineInfo> ls = new List<MaintenanceMachineInfo>();
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
|
@ -30,12 +30,14 @@ namespace IronIntel.Contractor.Machines
|
||||
public string ReturnDateStr { get { return ReturnDate == null ? "" : ReturnDate.Value.ToShortDateString(); } }
|
||||
public string PONumber { get; set; }
|
||||
public string Comments { get; set; }
|
||||
public double InsuredValue { get; set; }
|
||||
|
||||
public DateTime? RentalTermBillingDate { get; set; }
|
||||
public string RentalTermBillingDateStr { get { return RentalTermBillingDate == null ? "" : RentalTermBillingDate.Value.ToShortDateString(); } }
|
||||
public int BillingCycleDays { get; set; }
|
||||
|
||||
public bool Selected { get; set; }
|
||||
public bool Hide { get; set; }
|
||||
|
||||
public string DisplayName
|
||||
{
|
||||
@ -83,7 +85,7 @@ namespace IronIntel.Contractor.Machines
|
||||
public string LastUpdateUserName { get; set; }
|
||||
public string LastUpdatedBy { get; set; }
|
||||
public DateTime? LastUpdateDate { get; set; }
|
||||
public string LastUpdateDateStr { get { return LastUpdateDate == null ? "" : LastUpdateDate.Value.ToShortDateString(); } }
|
||||
public string LastUpdateDateStr { get { return LastUpdateDate == null ? "" : LastUpdateDate.Value.ToString("M/d/yyyy h:mm tt"); } }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -80,6 +80,7 @@ namespace IronIntel.Contractor.Machines
|
||||
/// 前端选择的时区的分钟偏移
|
||||
/// </summary>
|
||||
public int OffsetMinute { get; set; }
|
||||
public string DataSource { get; set; }
|
||||
}
|
||||
public class CalampOdometerInfo
|
||||
{
|
||||
@ -95,15 +96,15 @@ namespace IronIntel.Contractor.Machines
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTime.ToString("MM/dd/yyyy HH:mm");
|
||||
return AsofTime.ToString("M/d/yyyy h:m tt");
|
||||
}
|
||||
}
|
||||
public DateTime AsofTime_Local { get; set; }
|
||||
public DateTime AsofTimeLocal { get; set; }
|
||||
public string EventTimeLocalText
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTime_Local.ToString("MM/dd/yyyy HH:mm");
|
||||
return AsofTimeLocal.ToString("M/d/yyyy h:m tt");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -123,15 +124,41 @@ namespace IronIntel.Contractor.Machines
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTime.ToString("MM/dd/yyyy HH:mm");
|
||||
return AsofTime.ToString("M/d/yyyy h:m tt");
|
||||
}
|
||||
}
|
||||
public DateTime AsofTime_Local { get; set; }
|
||||
public DateTime AsofTimeLocal { get; set; }
|
||||
public string EventTimeLocalText
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTime_Local.ToString("MM/dd/yyyy HH:mm");
|
||||
return AsofTimeLocal.ToString("M/d/yyyy h:m tt");
|
||||
}
|
||||
}
|
||||
}
|
||||
public class SmartWitnessOdometerInfo
|
||||
{
|
||||
public long AssetId { get; set; }
|
||||
public string DeviceSN { get; set; }
|
||||
public DateTime AsofTime { get; set; }
|
||||
public string UOM { get; set; }
|
||||
public double Gps { get; set; }
|
||||
public double Gps_Calc { get; set; }
|
||||
//public double VBUS { get; set; }
|
||||
//public double VBUS_Calc { get; set; }
|
||||
public string EventTimeText
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTime.ToString("M/d/yyyy h:m tt");
|
||||
}
|
||||
}
|
||||
public DateTime AsofTimeLocal { get; set; }
|
||||
public string EventTimeLocalText
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTimeLocal.ToString("M/d/yyyy h:m tt");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -150,14 +177,16 @@ namespace IronIntel.Contractor.Machines
|
||||
{
|
||||
public long LogId { get; set; }
|
||||
public long AssetId { get; set; }
|
||||
public string DisplayName { get; set; }//Asset Name
|
||||
public string VIN { get; set; }
|
||||
public DateTime AdjustmentTime { get; set; }
|
||||
public string AdjustmentTimeText { get { return AdjustmentTime.ToString("MM/dd/yyyy HH:mm"); } }
|
||||
public string AdjustmentTimeText { get { return AdjustmentTime.ToString("M/d/yyyy h:m tt"); } }
|
||||
public DateTime OdometerTime { get; set; }
|
||||
public string OdometerTimeText { get { return OdometerTime.ToString("MM/dd/yyyy HH:mm"); } }
|
||||
public string OdometerTimeText { get { return OdometerTime.ToString("M/d/yyyy h:m tt"); } }
|
||||
public DateTime AdjustmentLocalTime { get; set; }
|
||||
public string AdjustmentLocalTimeText { get { return AdjustmentLocalTime.ToString("MM/dd/yyyy HH:mm"); } }
|
||||
public string AdjustmentLocalTimeText { get { return AdjustmentLocalTime.ToString("M/d/yyyy h:m tt"); } }
|
||||
public DateTime OdometerLocalTime { get; set; }
|
||||
public string OdometerLocalTimeText { get { return OdometerLocalTime.ToString("MM/dd/yyyy HH:mm"); } }
|
||||
public string OdometerLocalTimeText { get { return OdometerLocalTime.ToString("M/d/yyyy h:m tt"); } }
|
||||
|
||||
private double _Odometer;
|
||||
public double Odometer
|
||||
|
@ -15,6 +15,8 @@ namespace IronIntel.Contractor.Maintenance
|
||||
public string AlertType { get; set; }
|
||||
public DateTime AlertTime_UTC { get; set; }
|
||||
public string AlertTime_UTCStr { get { return AlertTime_UTC == DateTime.MinValue ? "" : AlertTime_UTC.ToString(); } }
|
||||
public DateTime AlertLocalTime { get; set; }
|
||||
public string AlertLocalTimeStr { get { return AlertLocalTime == DateTime.MinValue ? "" : AlertLocalTime.ToString(); } }
|
||||
public bool Completed { get; set; }
|
||||
public long MachineID { get; set; }
|
||||
public int ModelID { get; set; }
|
||||
@ -51,7 +53,23 @@ namespace IronIntel.Contractor.Maintenance
|
||||
}
|
||||
}
|
||||
public string Description { get; set; }
|
||||
public string ServiceDescription { get; set; }
|
||||
public string FormatDescription(string desc)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(desc))
|
||||
{
|
||||
if (desc.IndexOf("\r\n") > 0)
|
||||
desc = desc.Substring(0, desc.IndexOf("\r\n"));
|
||||
if (desc.IndexOf("\n") > 0)
|
||||
desc = desc.Substring(0, desc.IndexOf("\n"));
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
public string ServiceDescription { get; set; } = "";
|
||||
public string ScheduleID { get; set; }
|
||||
public string IntervalID { get; set; }
|
||||
public bool Recurring { get; set; }
|
||||
public int Priority { get; set; }
|
||||
public double ExpectedCost { get; set; }
|
||||
public int AlertCount { get; set; }
|
||||
public List<long> RepeatedAlerts { get; set; }
|
||||
public int OpenWorkOrderCount { get; set; }//针对Alert对应的机器
|
||||
@ -60,6 +78,9 @@ namespace IronIntel.Contractor.Maintenance
|
||||
public string AcknowledgedByName { get; set; }
|
||||
public DateTime AcknowledgedTime_UTC { get; set; }
|
||||
public string AcknowledgedTime_UTCStr { get { return AcknowledgedTime_UTC == DateTime.MinValue ? "" : AcknowledgedTime_UTC.ToString(); } }
|
||||
public DateTime AcknowledgedTime_Local { get; set; }
|
||||
public string AcknowledgedTime_LocalStr { get { return AcknowledgedTime_Local == DateTime.MinValue ? "" : AcknowledgedTime_Local.ToString(); } }
|
||||
|
||||
public string AcknowledgedComment { get; set; }
|
||||
}
|
||||
|
||||
@ -99,9 +120,22 @@ namespace IronIntel.Contractor.Maintenance
|
||||
public long ID { get; set; }
|
||||
public DateTime AlertTime { get; set; }
|
||||
public string AlertTimeStr { get { return AlertTime == DateTime.MinValue ? "" : AlertTime.ToString(); } }
|
||||
public DateTime AlertLocalTime { get; set; }
|
||||
public string AlertLocalTimeStr { get { return AlertLocalTime == DateTime.MinValue ? "" : AlertLocalTime.ToString(); } }
|
||||
public string AlertType { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string FormatDescription(string desc)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(desc))
|
||||
{
|
||||
if (desc.IndexOf("\r\n") > 0)
|
||||
desc = desc.Substring(0, desc.IndexOf("\r\n"));
|
||||
if (desc.IndexOf("\n") > 0)
|
||||
desc = desc.Substring(0, desc.IndexOf("\n"));
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
public long AssetID { get; set; }
|
||||
public string VIN { get; set; }
|
||||
public string AssetName { get; set; }
|
||||
@ -127,5 +161,6 @@ namespace IronIntel.Contractor.Maintenance
|
||||
public string CompletedDateStr { get { return CompletedDate == null ? "" : CompletedDate.ToString(); } }
|
||||
|
||||
public AssetAlertCategory Category { get; set; }
|
||||
public string ServiceDescription { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -2,14 +2,12 @@
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static IronIntel.Contractor.MapView.MachinesMapViewerManagement;
|
||||
|
||||
namespace IronIntel.Contractor.Maintenance
|
||||
{
|
||||
@ -19,282 +17,9 @@ namespace IronIntel.Contractor.Maintenance
|
||||
{
|
||||
}
|
||||
|
||||
const string SEL_ALERT = "select ALERTID,ALERTTYPE,ALERTTIME_UTC,COMPLETED,MACHINEID,VIN,MACHINENAME,ENGINGHOURS,ALERTDESC,PMTYPE from ALERTS";
|
||||
|
||||
public MachineInfoForAlert[] SearchMachineAlerts(string sessionid, string filtertext, string[] alertstatus, string[] alerttypes, string[] assetgroups, DateTime beginDate, DateTime endDate, string useriid)
|
||||
{
|
||||
string SQL = @"select a.ALERTID,w.WORKORDERID,wo.STATUS,ALERTTYPE,a.ALERTTIME_UTC,ISNULL(COMPLETED,0) COMPLETED,a.MACHINEID,a.VIN,a.MACHINENAME,a.ENGINGHOURS,m.ENGINEHOURS as CENGINGHOURS,ALERTDESC,m.MACHINENAME2
|
||||
,a.MAKEID,a.MODELID,pit.SERVICEDESCRIPTION
|
||||
,(select count(1) from WORKORDER wo1 where wo1.MACHINEID=a.MACHINEID and wo1.STATUS<>'Completed') as OpenWorkOrderCount,m.ONROAD,a.PMTYPE from ALERTS a with (nolock)
|
||||
left join WORKORDER_ALERTS w with (nolock) on a.ALERTID=w.ALERTID
|
||||
left join WORKORDER wo with (nolock) on w.WORKORDERID=wo.WORKORDERID
|
||||
left join MACHINES m with (nolock) on a.MACHINEID=m.MACHINEID
|
||||
left join PM_ALERTS pa with (nolock) on a.ALERTID=pa.ALERTID
|
||||
left join PM_INTERAVLS pit with (nolock) on pa.PMINTERVALID=pit.PMINTERVALID
|
||||
where m.MACHINEID is not null and (m.HIDE=0 or m.HIDE is null) and ISNULL(ACKNOWLEDGED,0)<>1 and a.ALERTTIME_UTC>={0} and a.ALERTTIME_UTC<={1} ";
|
||||
|
||||
if (Array.IndexOf(alertstatus, "Completed") >= 0 && Array.IndexOf(alertstatus, "Uncompleted") < 0)
|
||||
SQL = SQL + " and ISNULL(COMPLETED,0)=1 ";
|
||||
if (Array.IndexOf(alertstatus, "Completed") < 0 && Array.IndexOf(alertstatus, "Uncompleted") >= 0)
|
||||
SQL = SQL + " and ISNULL(COMPLETED,0)=0 ";
|
||||
if (Array.IndexOf(alertstatus, "Assigned") >= 0 && Array.IndexOf(alertstatus, "Unassigned") < 0)
|
||||
SQL = SQL + " and w.WORKORDERID is not null ";
|
||||
else if (Array.IndexOf(alertstatus, "Assigned") < 0 && Array.IndexOf(alertstatus, "Unassigned") >= 0)
|
||||
SQL = SQL + " and w.WORKORDERID is null ";
|
||||
|
||||
if (assetgroups.Length > 0)//asset group
|
||||
{
|
||||
SQL = SQL + string.Format(" and exists(select 1 from MACHINEGROUPMAP mg where mg.MACHINEID=m.MACHINEID and GROUPID in ('{0}'))", string.Join("','", assetgroups));
|
||||
}
|
||||
|
||||
string SQL_FILTER = SQL + " and (ALERTTYPE like {0} or a.MACHINEID like {0} or a.VIN like {0} or a.MACHINENAME like {0} or m.MACHINENAME2 like {0} or ALERTDESC like {0} or SERVICEDESCRIPTION like {0})";
|
||||
|
||||
string ORDER_BY = " order by ALERTID";
|
||||
|
||||
double timeadjust = SystemParams.GetHoursOffset();
|
||||
if (beginDate != Helper.DBMinDateTime)
|
||||
beginDate = beginDate.AddHours(-timeadjust);
|
||||
if (endDate != DateTime.MaxValue)
|
||||
endDate = endDate.AddHours(-timeadjust);
|
||||
|
||||
DataTable dt = GetDataTableBySQL(SQL + ORDER_BY, beginDate, endDate);
|
||||
if (dt.Rows.Count == 0)
|
||||
{
|
||||
return new MachineInfoForAlert[0];
|
||||
}
|
||||
|
||||
long[] availableAssetsids = null;
|
||||
var user = Users.UserManagement.GetUserByIID(useriid);
|
||||
if (user.UserType < Users.UserTypes.Admin)
|
||||
availableAssetsids = FleetServiceClientHelper.CreateClient<AssetQueryClient>(sessionid).GetAvailableAssetsForUsers(SystemParams.CompanyID, useriid);
|
||||
|
||||
MachineServiceClient2 mc = SystemParams.GetMachineServiceClient();
|
||||
MachineMake[] _makes = mc.GetMachineMakes();
|
||||
MachineModel[] _models = mc.GetMachineModels();
|
||||
|
||||
List<MachineInfoForAlert> results = new List<MachineInfoForAlert>(dt.Rows.Count);
|
||||
Dictionary<string, AssetEngineHour> machineEngineHours = GetAssetEngineHour();
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
long mid = FIDbAccess.GetFieldInt64(dr["MACHINEID"], 0);
|
||||
if (user.UserType < Users.UserTypes.Admin && !availableAssetsids.Contains(mid))
|
||||
continue;
|
||||
string alerttype = FIDbAccess.GetFieldString(dr["ALERTTYPE"], string.Empty).Trim();
|
||||
if (alerttypes.Length > 0 && !alerttypes.Contains(alerttype))//alerttype
|
||||
continue;
|
||||
|
||||
AlertInfo ai = ConvertToAlertInfo(dr, timeadjust);
|
||||
|
||||
ai.ServiceDescription = FIDbAccess.GetFieldString(dr["SERVICEDESCRIPTION"], string.Empty);
|
||||
ai.WorkOrderID = FIDbAccess.GetFieldInt(dr["WORKORDERID"], 0);
|
||||
ai.WorkOrderStatus = FIDbAccess.GetFieldString(dr["STATUS"], string.Empty);
|
||||
ai.MakeID = FIDbAccess.GetFieldInt(dr["MAKEID"], 0);
|
||||
ai.ModelID = FIDbAccess.GetFieldInt(dr["MODELID"], 0);
|
||||
string name2 = FIDbAccess.GetFieldString(dr["MACHINENAME2"], string.Empty);
|
||||
string showname = name2;
|
||||
if (string.IsNullOrWhiteSpace(showname))
|
||||
showname = ai.MachineName;
|
||||
if (string.IsNullOrWhiteSpace(showname))
|
||||
showname = ai.VIN;
|
||||
if (string.IsNullOrWhiteSpace(showname))
|
||||
showname = ai.MachineID.ToString();
|
||||
ai.MachineName = showname;
|
||||
|
||||
MachineMake mk = _makes.FirstOrDefault(m => m.ID == ai.MakeID);
|
||||
if (mk != null)
|
||||
ai.Make = mk.Name;
|
||||
MachineModel md = _models.FirstOrDefault(m => m.ID == ai.ModelID);
|
||||
if (md != null)
|
||||
ai.Model = md.Name;
|
||||
|
||||
MachineInfoForAlert mi = results.FirstOrDefault((i) => i.MachineID == ai.MachineID);
|
||||
if (mi == null)
|
||||
{
|
||||
mi = new MachineInfoForAlert();
|
||||
mi.MachineID = ai.MachineID;
|
||||
mi.MachineName = ai.MachineName;
|
||||
mi.VIN = ai.VIN;
|
||||
mi.Make = ai.Make;
|
||||
mi.Model = ai.Model;
|
||||
mi.EngineHours = FIDbAccess.GetFieldDouble(dr["CENGINGHOURS"], 0);// ai.EngineHours;
|
||||
if (machineEngineHours.ContainsKey(mi.MachineID.ToString()))
|
||||
{
|
||||
var meh = machineEngineHours[mi.MachineID.ToString()];
|
||||
mi.EngineHours = meh.EngineHours;
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(filtertext))
|
||||
{
|
||||
if (Helper.Contains(ai.AlertType, filtertext)
|
||||
|| Helper.Contains(ai.MachineID.ToString(), filtertext)
|
||||
|| Helper.Contains(ai.VIN, filtertext)
|
||||
|| Helper.Contains(ai.MachineName, filtertext)
|
||||
|| Helper.Contains(ai.Description, filtertext)
|
||||
//|| Helper.Contains(ai.ServiceDescription, filtertext)
|
||||
|| Helper.Contains(mi.Make, filtertext)
|
||||
|| Helper.Contains(mi.Model, filtertext))
|
||||
results.Add(mi);
|
||||
}
|
||||
else
|
||||
results.Add(mi);
|
||||
}
|
||||
|
||||
if (ai.PMType == "PM_ALERT" || ai.PMType == "TBM_ALERT" || ai.PMType == "HM_ALERT"
|
||||
|| ai.PMType == "RDM_ALERT" || ai.PMType == "ADM_ALERT")
|
||||
mi.PMAlertCount++;
|
||||
else if (ai.AlertType == "Red-Inspect" || ai.AlertType == "Yellow-Inspect" || ai.AlertType == "Info-Inspect")
|
||||
mi.InspectAlertCount++;
|
||||
else
|
||||
mi.DTCAlertCount++;
|
||||
|
||||
AlertInfo oildai = mi.Alerts.FirstOrDefault(m => m.Description == ai.Description && m.MachineID == ai.MachineID);
|
||||
if (oildai == null)
|
||||
{
|
||||
ai.AlertCount = 1;
|
||||
mi.Alerts.Add(ai);
|
||||
}
|
||||
else
|
||||
{
|
||||
ai.AlertCount = oildai.AlertCount;
|
||||
int index = mi.Alerts.IndexOf(oildai);
|
||||
if (ai.AlertTime_UTC > oildai.AlertTime_UTC)
|
||||
{
|
||||
ai.AlertCount++;
|
||||
mi.Alerts[index] = ai;
|
||||
}
|
||||
else
|
||||
mi.Alerts[index].AlertCount++;
|
||||
}
|
||||
mi.OpenWorkOrders = FIDbAccess.GetFieldInt(dr["OpenWorkOrderCount"], 0);
|
||||
//mi.OpenWorkOrders = mi.Alerts.Where(m => m.WorkOrderID != 0 && m.WorkOrderStatus != "Completed").Select(m => m.WorkOrderID).Distinct().Count();
|
||||
var timealerts = mi.Alerts.OrderByDescending(m => m.AlertTime_UTC).ToArray();
|
||||
mi.LatestAlertDateTime = timealerts == null ? DateTime.MinValue : timealerts[0].AlertTime_UTC;
|
||||
}
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
public AlertInfo[] SearchAcknowledgedAlerts(string sessionid, string filtertext, string[] alertstatus, string[] alerttypes, string[] assetgroups, DateTime beginDate, DateTime endDate, string useriid)
|
||||
{
|
||||
string SQL = @"select a.ALERTID,w.WORKORDERID,wo.STATUS,ALERTTYPE,a.ALERTTIME_UTC,COMPLETED,a.MACHINEID,a.VIN,a.MACHINENAME, ENGINGHOURS,ALERTDESC,m.MACHINENAME2
|
||||
,a.MAKEID,a.MODELID,pit.SERVICEDESCRIPTION,a.PMTYPE
|
||||
,(select count(1) from WORKORDER wo1 where wo1.MACHINEID=a.MACHINEID and wo1.STATUS<>'Completed') as OpenWorkOrderCount
|
||||
,a.ACKNOWLEDGEDBY,a.ACKNOWLEDGEDDATE_UTC,a.ACKNOWLEDGMENTCOMMENT
|
||||
from ALERTS a with (nolock)
|
||||
left join WORKORDER_ALERTS w with (nolock) on a.ALERTID=w.ALERTID
|
||||
left join WORKORDER wo with (nolock) on w.WORKORDERID=wo.WORKORDERID
|
||||
left join MACHINES m with (nolock) on a.MACHINEID=m.MACHINEID
|
||||
left join PM_ALERTS pa with (nolock) on a.ALERTID=pa.ALERTID
|
||||
left join PM_INTERAVLS pit with (nolock) on pa.PMINTERVALID=pit.PMINTERVALID
|
||||
where m.MACHINEID is not null and (m.HIDE=0 or m.HIDE is null) and ISNULL(ACKNOWLEDGED,0)=1 and a.ALERTTIME_UTC>={0} and a.ALERTTIME_UTC<={1} ";
|
||||
|
||||
if (assetgroups.Length > 0)//asset group
|
||||
{
|
||||
SQL = SQL + string.Format(" and exists(select 1 from MACHINEGROUPMAP mg where mg.MACHINEID=m.MACHINEID and GROUPID in ('{0}'))", string.Join("','", assetgroups));
|
||||
}
|
||||
|
||||
const string ORDER_BY = " order by ALERTID";
|
||||
|
||||
double timeadjust = SystemParams.GetHoursOffset();
|
||||
if (beginDate != Helper.DBMinDateTime)
|
||||
beginDate = beginDate.AddHours(-timeadjust);
|
||||
if (endDate != DateTime.MaxValue)
|
||||
endDate = endDate.AddHours(-timeadjust);
|
||||
|
||||
DataTable dt = GetDataTableBySQL(SQL + ORDER_BY, beginDate, endDate);
|
||||
if (dt.Rows.Count == 0)
|
||||
{
|
||||
return new AlertInfo[0];
|
||||
}
|
||||
|
||||
long[] availableAssetsids = null;
|
||||
var user = Users.UserManagement.GetUserByIID(useriid);
|
||||
if (user.UserType < Users.UserTypes.Admin)
|
||||
availableAssetsids = FleetServiceClientHelper.CreateClient<AssetQueryClient>(sessionid).GetAvailableAssetsForUsers(SystemParams.CompanyID, useriid);
|
||||
|
||||
MachineServiceClient2 mc = SystemParams.GetMachineServiceClient();
|
||||
MachineMake[] _makes = mc.GetMachineMakes();
|
||||
MachineModel[] _models = mc.GetMachineModels();
|
||||
UserInfo[] _users = UserManagement.GetAllAvailableUsers();
|
||||
|
||||
List<AlertInfo> result = new List<AlertInfo>(dt.Rows.Count);
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
long mid = FIDbAccess.GetFieldInt64(dr["MACHINEID"], 0);
|
||||
if (user.UserType < Users.UserTypes.Admin && !availableAssetsids.Contains(mid))
|
||||
continue;
|
||||
string alerttype = FIDbAccess.GetFieldString(dr["ALERTTYPE"], string.Empty).Trim();
|
||||
if (alerttypes.Length > 0 && !alerttypes.Contains(alerttype))//alerttype
|
||||
continue;
|
||||
AlertInfo ai = ConvertToAlertInfo(dr, timeadjust);
|
||||
|
||||
ai.ServiceDescription = FIDbAccess.GetFieldString(dr["SERVICEDESCRIPTION"], string.Empty);
|
||||
ai.WorkOrderID = FIDbAccess.GetFieldInt(dr["WORKORDERID"], 0);
|
||||
ai.WorkOrderStatus = FIDbAccess.GetFieldString(dr["STATUS"], string.Empty);
|
||||
ai.MakeID = FIDbAccess.GetFieldInt(dr["MAKEID"], 0);
|
||||
ai.ModelID = FIDbAccess.GetFieldInt(dr["MODELID"], 0);
|
||||
string name2 = FIDbAccess.GetFieldString(dr["MACHINENAME2"], string.Empty);
|
||||
string showname = name2;
|
||||
if (string.IsNullOrWhiteSpace(showname))
|
||||
showname = ai.MachineName;
|
||||
if (string.IsNullOrWhiteSpace(showname))
|
||||
showname = ai.VIN;
|
||||
if (string.IsNullOrWhiteSpace(showname))
|
||||
showname = ai.MachineID.ToString();
|
||||
ai.MachineName = showname;
|
||||
|
||||
MachineMake mk = _makes.FirstOrDefault(m => m.ID == ai.MakeID);
|
||||
if (mk != null)
|
||||
ai.Make = mk.Name;
|
||||
MachineModel md = _models.FirstOrDefault(m => m.ID == ai.ModelID);
|
||||
if (md != null)
|
||||
ai.Model = md.Name;
|
||||
|
||||
ai.AcknowledgedBy = FIDbAccess.GetFieldString(dr["ACKNOWLEDGEDBY"], string.Empty);
|
||||
ai.AcknowledgedTime_UTC = FIDbAccess.GetFieldDateTime(dr["ACKNOWLEDGEDDATE_UTC"], DateTime.MinValue);
|
||||
if (ai.AcknowledgedTime_UTC != DateTime.MinValue)
|
||||
ai.AcknowledgedTime_UTC = ai.AcknowledgedTime_UTC.AddHours(timeadjust);
|
||||
ai.AcknowledgedComment = FIDbAccess.GetFieldString(dr["ACKNOWLEDGMENTCOMMENT"], string.Empty);
|
||||
if (!string.IsNullOrWhiteSpace(ai.AcknowledgedBy))
|
||||
{
|
||||
UserInfo ui = _users.FirstOrDefault(m => m.IID == ai.AcknowledgedBy);
|
||||
if (ui != null)
|
||||
ai.AcknowledgedByName = ui.DisplayName;
|
||||
}
|
||||
|
||||
ai.OpenWorkOrderCount = FIDbAccess.GetFieldInt(dr["OpenWorkOrderCount"], 0);
|
||||
|
||||
AlertInfo existAlert = result.FirstOrDefault(m => m.Description == ai.Description && m.MachineID == ai.MachineID && m.AcknowledgedComment == ai.AcknowledgedComment);
|
||||
if (existAlert == null)
|
||||
{
|
||||
ai.AlertCount = 1;
|
||||
if (!string.IsNullOrWhiteSpace(filtertext))
|
||||
{
|
||||
if (Helper.Contains(ai.AlertType, filtertext)
|
||||
|| Helper.Contains(ai.MachineID.ToString(), filtertext)
|
||||
|| Helper.Contains(ai.VIN, filtertext)
|
||||
|| Helper.Contains(ai.MachineName, filtertext)
|
||||
|| Helper.Contains(ai.Description, filtertext)
|
||||
//|| Helper.Contains(ai.ServiceDescription, filtertext)
|
||||
|| Helper.Contains(ai.Make, filtertext)
|
||||
|| Helper.Contains(ai.Model, filtertext))
|
||||
result.Add(ai);
|
||||
}
|
||||
else
|
||||
result.Add(ai);
|
||||
}
|
||||
else
|
||||
{
|
||||
existAlert.AlertCount++;
|
||||
if (ai.AlertTime_UTC > existAlert.AlertTime_UTC)
|
||||
existAlert.AlertTime_UTC = ai.AlertTime_UTC;
|
||||
}
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
|
||||
public StringKeyValue[] GetAlertTypes()
|
||||
{
|
||||
const string SQL = "select distinct ltrim(rtrim(ALERTTYPE)) as ALERTTYPE from ALERTS where ISNULL(ALERTTYPE,'')<>'' order by ALERTTYPE";
|
||||
const string SQL = "select distinct ltrim(rtrim(ALERTTYPE)) as ALERTTYPE from ALERTS with(nolock) where ISNULL(ALERTTYPE,'')<>''";
|
||||
DataTable tb = GetDataTableBySQL(SQL);
|
||||
if (tb.Rows.Count == 0)
|
||||
{
|
||||
@ -309,29 +34,10 @@ namespace IronIntel.Contractor.Maintenance
|
||||
kv.Value = type;
|
||||
list.Add(kv);
|
||||
}
|
||||
return list.ToArray();
|
||||
return list.OrderBy(t => t.Key).ToArray();
|
||||
}
|
||||
|
||||
public AlertInfo[] GetAlertByID(long[] alertid)
|
||||
{
|
||||
if (alertid == null || alertid.Length == 0)
|
||||
return new AlertInfo[0];
|
||||
string SQL = SEL_ALERT + string.Format(" where ALERTID in ({0})", string.Join(",", alertid));
|
||||
DataTable tb = GetDataTableBySQL(SQL);
|
||||
if (tb.Rows.Count == 0)
|
||||
{
|
||||
return new AlertInfo[0];
|
||||
}
|
||||
List<AlertInfo> ls = new List<AlertInfo>(tb.Rows.Count);
|
||||
double timeadjust = SystemParams.GetHoursOffset();
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
ls.Add(ConvertToAlertInfo(dr, timeadjust));
|
||||
}
|
||||
return ls.ToArray();
|
||||
}
|
||||
|
||||
public AlertInfo[] GetAlertsByWorkOrder(long workorderid)
|
||||
public AlertInfo[] GetAlertsByWorkOrder(long workorderid, Foresight.Fleet.Services.User.UserInfo user)
|
||||
{
|
||||
const string SQL = @"select a.ALERTID,ALERTTYPE,a.ALERTTIME_UTC,COMPLETED,a.MACHINEID,a.VIN,a.MACHINENAME,a.ENGINGHOURS,a.ALERTDESC,pit.SERVICEDESCRIPTION,a.PMTYPE from ALERTS a
|
||||
left join PM_ALERTS pa on a.ALERTID=pa.ALERTID left join PM_INTERAVLS pit on pa.PMINTERVALID=pit.PMINTERVALID
|
||||
@ -342,73 +48,15 @@ namespace IronIntel.Contractor.Maintenance
|
||||
return new AlertInfo[0];
|
||||
}
|
||||
List<AlertInfo> ls = new List<AlertInfo>(tb.Rows.Count);
|
||||
double timeadjust = SystemParams.GetHoursOffset();
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
AlertInfo ai = ConvertToAlertInfo(dr, timeadjust);
|
||||
AlertInfo ai = ConvertToAlertInfo(dr, user);
|
||||
ai.ServiceDescription = FIDbAccess.GetFieldString(dr["SERVICEDESCRIPTION"], string.Empty);
|
||||
ls.Add(ai);
|
||||
}
|
||||
return ls.ToArray();
|
||||
}
|
||||
|
||||
public AlertInfo[] GetAlertsByAlerts(long[] alertids)
|
||||
{
|
||||
const string SQL = SEL_ALERT + " where ALERTID in ({ALERTIDS}) order by ALERTID";
|
||||
|
||||
string gids = "'" + string.Join("','", alertids) + "'";
|
||||
DataTable tb = GetDataTableBySQL(SQL.Replace("{ALERTIDS}", gids));
|
||||
if (tb.Rows.Count == 0)
|
||||
{
|
||||
return new AlertInfo[0];
|
||||
}
|
||||
List<AlertInfo> ls = new List<AlertInfo>(tb.Rows.Count);
|
||||
double timeadjust = SystemParams.GetHoursOffset();
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
ls.Add(ConvertToAlertInfo(dr, timeadjust));
|
||||
}
|
||||
return ls.ToArray();
|
||||
}
|
||||
|
||||
public AlertInfo[] GetAlertsByMachineID(long machineid)
|
||||
{
|
||||
const string SQL = SEL_ALERT + " where MACHINEID={0} and ISNULL(COMPLETED,0)=0 and ALERTID not in(select ALERTID from WORKORDER_ALERTS)";
|
||||
|
||||
DataTable tb = GetDataTableBySQL(SQL, machineid);
|
||||
if (tb.Rows.Count == 0)
|
||||
{
|
||||
return new AlertInfo[0];
|
||||
}
|
||||
List<AlertInfo> ls = new List<AlertInfo>(tb.Rows.Count);
|
||||
double timeadjust = SystemParams.GetHoursOffset();
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
AlertInfo ai = ConvertToAlertInfo(dr, timeadjust);
|
||||
|
||||
AlertInfo oildai = ls.FirstOrDefault(m => m.Description == ai.Description);
|
||||
if (oildai == null)
|
||||
{
|
||||
ai.AlertCount = 1;
|
||||
ls.Add(ai);
|
||||
}
|
||||
else
|
||||
{
|
||||
ai.AlertCount = oildai.AlertCount;
|
||||
int index = ls.IndexOf(oildai);
|
||||
if (ai.AlertTime_UTC > oildai.AlertTime_UTC)
|
||||
{
|
||||
ai.AlertCount++;
|
||||
ls[index] = ai;
|
||||
}
|
||||
else
|
||||
ls[index].AlertCount++;
|
||||
}
|
||||
}
|
||||
|
||||
return ls.ToArray();
|
||||
}
|
||||
|
||||
public void AcknowledgeAlert(string useriid, long[] alertids, string acknowledgmentcomment)
|
||||
{
|
||||
const string SQL = "update ALERTS set ACKNOWLEDGED=1,ACKNOWLEDGEDBY={1},ACKNOWLEDGMENTCOMMENT={2},ACKNOWLEDGEDDATE_UTC=GETUTCDATE() where ALERTID={0}";
|
||||
@ -446,121 +94,24 @@ namespace IronIntel.Contractor.Maintenance
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddMaintenanceLog(AlertInfo alert, List<Tuple<long, double, double, string>> machines, string useriid, FISqlConnection db)
|
||||
{
|
||||
const string SQL_MR = @" insert into MAINTENANCELOG(MAINTENANCEID,MACHINEID,MAINTENANCEDATE,MAINTENANCEHOURS,NOTES,ADDEDBY,ADDEDON,LASTUPDATEDBY,LASTUPDATEDON,
|
||||
ALERTID,ODOMETER,ODOMETERUOM,LOGTYPE,COMPLETEDBY,COMPLETED,COMPLETEDDATE_UTC) values({0},{1},getdate(),{2},{3},{4},GETUTCDATE(),{4},GETUTCDATE(),{5},{6},{7},{8},{4},1,GETUTCDATE())";
|
||||
|
||||
string logtype = "";
|
||||
double enginehours = 0;
|
||||
double odometer = 0;
|
||||
string odometeruom = "";
|
||||
var machine = machines.FirstOrDefault(m => m.Item1 == alert.MachineID);
|
||||
if (machine != null)
|
||||
{
|
||||
if (string.Compare(alert.PMType, "HM_ALERT", true) == 0
|
||||
|| string.Compare(alert.PMType, "PM_ALERT", true) == 0
|
||||
|| string.Compare(alert.PMType, "TBM_ALERT", true) == 0)
|
||||
{
|
||||
logtype = "Hours";
|
||||
enginehours = machine.Item2;
|
||||
enginehours = enginehours > 0 ? enginehours : 0;
|
||||
}
|
||||
else if (string.Compare(alert.PMType, "ADM_ALERT", true) == 0
|
||||
|| string.Compare(alert.PMType, "RDM_ALERT", true) == 0)
|
||||
{
|
||||
logtype = "Distance";
|
||||
odometer = machine.Item3;
|
||||
odometer = odometer > 0 ? odometer : 0;
|
||||
odometeruom = machine.Item4;
|
||||
}
|
||||
}
|
||||
db.ExecSQL(SQL_MR, Guid.NewGuid().ToString().ToUpper(), alert.MachineID, enginehours, alert.Description, useriid,
|
||||
alert.AlertID, odometer, odometeruom, logtype);
|
||||
}
|
||||
|
||||
private static List<Tuple<long, double, double, string>> GetMachines(FISqlConnection db)
|
||||
{
|
||||
const string SQL = "select MACHINEID,ENGINEHOURS,ODOMETER,ODOMETERUOM from MACHINES";
|
||||
List<Tuple<long, double, double, string>> list = new List<Tuple<long, double, double, string>>();
|
||||
DataTable dt = db.GetDataTableBySQL(SQL);
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
long machineid = FIDbAccess.GetFieldInt(dr["MACHINEID"], 0);
|
||||
double enginhours = FIDbAccess.GetFieldDouble(dr["ENGINEHOURS"], 0);
|
||||
double odometer = FIDbAccess.GetFieldDouble(dr["ODOMETER"], 0);
|
||||
string odometeruom = FIDbAccess.GetFieldString(dr["ODOMETERUOM"], string.Empty);
|
||||
Tuple<long, double, double, string> t = new Tuple<long, double, double, string>(machineid, enginhours, odometer, odometeruom);
|
||||
list.Add(t);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
private static StringKeyValue[] GetMachineJobSites(FISqlConnection db)
|
||||
{
|
||||
const string SQL = "select jm.MACHINEID,j.JOBSITENAME from JOBSITEMACHINES jm left join JOBSITES j on jm.JOBSITEID=j.JOBSITEID";
|
||||
List<StringKeyValue> list = new List<StringKeyValue>();
|
||||
DataTable dt = db.GetDataTableBySQL(SQL);
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
StringKeyValue kv = new StringKeyValue();
|
||||
kv.Key = FIDbAccess.GetFieldInt(dr["MACHINEID"], 0).ToString();
|
||||
kv.Value = FIDbAccess.GetFieldString(dr["JOBSITENAME"], string.Empty);
|
||||
list.Add(kv);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
private static AlertInfo ConvertToAlertInfo(DataRow dr, double timeadjust)
|
||||
private static AlertInfo ConvertToAlertInfo(DataRow dr, Foresight.Fleet.Services.User.UserInfo user)
|
||||
{
|
||||
AlertInfo ai = new AlertInfo();
|
||||
ai.AlertID = FIDbAccess.GetFieldInt(dr["ALERTID"], 0);
|
||||
ai.AlertType = FIDbAccess.GetFieldString(dr["ALERTTYPE"], string.Empty);
|
||||
ai.AlertTime_UTC = FIDbAccess.GetFieldDateTime(dr["ALERTTIME_UTC"], DateTime.MinValue);
|
||||
if (ai.AlertTime_UTC != DateTime.MinValue)
|
||||
ai.AlertTime_UTC = ai.AlertTime_UTC.AddHours(timeadjust);
|
||||
ai.AlertLocalTime = SystemParams.ConvertToUserTimeFromUtc(user, ai.AlertTime_UTC);
|
||||
ai.Completed = FIDbAccess.GetFieldInt(dr["COMPLETED"], 0) == 1;
|
||||
ai.MachineID = FIDbAccess.GetFieldInt(dr["MACHINEID"], 0);
|
||||
ai.VIN = FIDbAccess.GetFieldString(dr["VIN"], string.Empty);
|
||||
ai.MachineName = FIDbAccess.GetFieldString(dr["MACHINENAME"], string.Empty);
|
||||
ai.EngineHours = FIDbAccess.GetFieldDouble(dr["ENGINGHOURS"], 0);
|
||||
ai.Description = FIDbAccess.GetFieldString(dr["ALERTDESC"], string.Empty);
|
||||
ai.Description = ai.FormatDescription(ai.Description);
|
||||
ai.PMType = FIDbAccess.GetFieldString(dr["PMTYPE"], string.Empty);
|
||||
return ai;
|
||||
}
|
||||
|
||||
private static Dictionary<string, AssetEngineHour> GetAssetEngineHour()
|
||||
{
|
||||
const string SQL_EH = @"select * from(select AssetId as MACHINEID,AsofTime as ASOFTIME_UTC,Amount,UOM,ROW_NUMBER() over(partition by AssetId order by AsofTime desc) as RowIndex from AssetEngineHours where Datasource<>'Calamp') t where RowIndex=1";
|
||||
|
||||
DataTable tbeh = null;
|
||||
string dbString2 = SystemParams.GetIronIntelReportDataDbString(SystemParams.CompanyID);
|
||||
if (!string.IsNullOrWhiteSpace(dbString2))
|
||||
{
|
||||
var db2 = new FISqlConnection(dbString2);
|
||||
tbeh = db2.GetDataTableBySQL(SQL_EH);
|
||||
}
|
||||
|
||||
Dictionary<string, AssetEngineHour> machineEngineHours = new Dictionary<string, AssetEngineHour>();
|
||||
if (tbeh != null && tbeh.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow dr in tbeh.Rows)
|
||||
{
|
||||
string mID = FIDbAccess.GetFieldString(dr["MACHINEID"], string.Empty);
|
||||
var meh = new AssetEngineHour();
|
||||
meh.EngineHours = FIDbAccess.GetFieldDouble(dr["Amount"], -1);
|
||||
string uom = FIDbAccess.GetFieldString(dr["UOM"], string.Empty);
|
||||
if (uom.ToLower() == "s")
|
||||
meh.EngineHours = meh.EngineHours / 3600;
|
||||
meh.EngineHoursDate = FIDbAccess.GetFieldDateTime(dr["ASOFTIME_UTC"], DateTime.MinValue);
|
||||
if (meh.EngineHoursDate != DateTime.MinValue)
|
||||
meh.EngineHoursDate = meh.EngineHoursDate.AddHours(SystemParams.GetHoursOffset());
|
||||
|
||||
machineEngineHours[mID] = meh;
|
||||
}
|
||||
}
|
||||
|
||||
return machineEngineHours;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
28
IronIntelContractorBusiness/Maintenance/AlertQueryParams.cs
Normal file
28
IronIntelContractorBusiness/Maintenance/AlertQueryParams.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using Foresight.Fleet.Services.AssetHealth;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.Maintenance
|
||||
{
|
||||
public class AlertQueryParams
|
||||
{
|
||||
public long AssetID { get; set; }
|
||||
public string SearchText { get; set; }
|
||||
public string[] AlertStatus { get; set; }
|
||||
public string[] AssetGroups { get; set; }
|
||||
public string[] AlertTypes { get; set; }
|
||||
public string[] JobSites { get; set; }
|
||||
public string BeginDate { get; set; }
|
||||
public string EndDate { get; set; }
|
||||
public bool IncludeunCompleted { get; set; }
|
||||
}
|
||||
|
||||
public class AutoAcknowledgeInfo : AutoAcknowledgeItem
|
||||
{
|
||||
public DateTime LocalUpdatedOn { get; set; }
|
||||
public string LocalUpdatedOnStr { get { return LocalUpdatedOn.ToString(); } }
|
||||
}
|
||||
}
|
@ -26,7 +26,9 @@ namespace IronIntel.Contractor.Maintenance
|
||||
public string DriverName { get; set; }
|
||||
public string TicketNumber { get; set; }
|
||||
public DateTime TransactionDate { get; set; }
|
||||
public string TransactionDateStr { get { return TransactionDate == DateTime.MinValue ? "" : TransactionDate.ToString("MM/dd/yyyy HH:mm"); } }
|
||||
public string TransactionDateStr { get { return TransactionDate == DateTime.MinValue ? "" : TransactionDate.ToString("M/d/yyyy h:m tt"); } }
|
||||
public DateTime TransactionLocalDate { get; set; }
|
||||
public string TransactionLocalDateStr { get { return TransactionLocalDate == DateTime.MinValue ? "" : TransactionLocalDate.ToString("M/d/yyyy h:m tt"); } }
|
||||
public string AssetModel { get; set; }
|
||||
public string AssetMake { get; set; }
|
||||
public string AssetType { get; set; }
|
||||
@ -36,6 +38,9 @@ namespace IronIntel.Contractor.Maintenance
|
||||
public long FuelID { get; set; }
|
||||
public string DataSource { get; set; }
|
||||
public string BrandName { get; set; }
|
||||
public int DistributedBy { get; set; }//0:Fueling Station 1:Fueling Asset
|
||||
public long FuelingAsset { get; set; }
|
||||
public string FuelingAssetName { get; set; }
|
||||
}
|
||||
|
||||
public class FuelRecordAuditItem : FuelRecordInfo
|
||||
@ -47,9 +52,14 @@ namespace IronIntel.Contractor.Maintenance
|
||||
public string LasetUpdatedBy { get; set; }
|
||||
public string LasetUpdatedByName { get; set; }
|
||||
public DateTime AddedOn { get; set; }
|
||||
public string AddedOnStr { get { return AddedOn == DateTime.MinValue ? "" : AddedOn.ToString("MM/dd/yyyy HH:mm:ss"); } }
|
||||
public string AddedOnStr { get { return AddedOn == DateTime.MinValue ? "" : AddedOn.ToString("M/d/yyyy h:m:s tt"); } }
|
||||
public DateTime LastUpdatedOn { get; set; }
|
||||
public string LastUpdatedOnStr { get { return LastUpdatedOn == DateTime.MinValue ? "" : LastUpdatedOn.ToString("MM/dd/yyyy HH:mm:ss"); } }
|
||||
public string LastUpdatedOnStr { get { return LastUpdatedOn == DateTime.MinValue ? "" : LastUpdatedOn.ToString("M/d/yyyy h:m:s tt"); } }
|
||||
|
||||
public DateTime AddedOn_Local { get; set; }
|
||||
public string AddedOn_LocalStr { get { return AddedOn_Local == DateTime.MinValue ? "" : AddedOn_Local.ToString("M/d/yyyy h:m:s tt"); } }
|
||||
public DateTime LastUpdatedOn_Local { get; set; }
|
||||
public string LastUpdatedOn_LocalStr { get { return LastUpdatedOn_Local == DateTime.MinValue ? "" : LastUpdatedOn_Local.ToString("M/d/yyyy h:m:s tt"); } }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -81,9 +81,9 @@ namespace IronIntel.Contractor.Maintenance
|
||||
|
||||
private Dictionary<long, machinedata> _Machines = new Dictionary<long, machinedata>();
|
||||
|
||||
private machinedata GetMachinedata(long id)
|
||||
private machinedata GetMachinedata(FISqlConnection db, long id)
|
||||
{
|
||||
const string SQL = "select MACHINEID,VIN,MACHINENAME,MACHINENAME2,MAKEID,MODELID,TYPEID from MACHINES where MACHINEID={0}";
|
||||
const string SQL = "select MACHINEID,VIN,MACHINENAME,MACHINENAME2,MAKEID,MODELID,TYPEID from MACHINES with(nolock) where MACHINEID={0}";
|
||||
|
||||
machinedata m = null;
|
||||
if (_Machines.TryGetValue(id, out m))
|
||||
@ -91,7 +91,6 @@ namespace IronIntel.Contractor.Maintenance
|
||||
return m;
|
||||
}
|
||||
|
||||
FISqlConnection db = SystemParams.GetDbInstance();
|
||||
DataTable tb = db.GetDataTableBySQL(SQL, id);
|
||||
if (tb.Rows.Count == 0)
|
||||
{
|
||||
@ -117,7 +116,7 @@ namespace IronIntel.Contractor.Maintenance
|
||||
|
||||
public void SyncAlerts()
|
||||
{
|
||||
const string SQL = "select top 100 * from IATCALERTS where ALERTID>(select isnull(max(IATCALERTID),-1) from ALERTS where SRC='LOCALTABLE_IATCALERTS') order by ALERTID";//process most 100 alerts each time
|
||||
const string SQL = "select top 100 * from IATCALERTS with(nolock) where ALERTID>(select isnull(max(IATCALERTID),-1) from ALERTS where SRC='LOCALTABLE_IATCALERTS') order by ALERTID";//process most 100 alerts each time
|
||||
|
||||
FISqlConnection db = SystemParams.GetDbInstance();
|
||||
DataTable tb = db.GetDataTableBySQL(SQL);
|
||||
@ -137,13 +136,13 @@ namespace IronIntel.Contractor.Maintenance
|
||||
|
||||
private void InsertData(FISqlConnection db, DataRow dr)
|
||||
{
|
||||
const string SQL = "if not exists(select 1 from ALERTS where SRC='LOCALTABLE_IATCALERTS' and IATCALERTID={0}) "
|
||||
const string SQL = "if not exists(select 1 from ALERTS with(nolock) where SRC='LOCALTABLE_IATCALERTS' and IATCALERTID={0}) "
|
||||
+ "insert into ALERTS(ALERTTIME_UTC,ALERTTYPE,ALERTTITLE,ALERTDESC,MACHINEID,VIN,MACHINENAME,MODELID,MODELNAME,"
|
||||
+ "MAKEID,MAKENAME,TYPEID,TYPENAME,ENGINGHOURS,LATITUDE,LONGITUDE,LOCDATE_UTC,SRC,INSERTTIME,REFID,IATCALERTID) "
|
||||
+ " values({1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},'LOCALTABLE_IATCALERTS',getdate(),{0},{0})";
|
||||
+ "MAKEID,MAKENAME,TYPEID,TYPENAME,ENGINGHOURS,LATITUDE,LONGITUDE,LOCDATE_UTC,SRC,INSERTTIME,REFID,IATCALERTID,ACKNOWLEDGED,ACKNOWLEDGEDDATE_UTC) "
|
||||
+ " values({1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},'LOCALTABLE_IATCALERTS',getdate(),{0},{0},{18},(case {18} when 1 then GETUTCDATE() else null end))";
|
||||
|
||||
long machineid = Convert.IsDBNull(dr["MACHINEID"]) ? -1 : Convert.ToInt64(dr["MACHINEID"]);
|
||||
machinedata m = GetMachinedata(machineid);
|
||||
machinedata m = GetMachinedata(db, machineid);
|
||||
if (m == null)
|
||||
{
|
||||
m = new machinedata();
|
||||
@ -166,7 +165,11 @@ namespace IronIntel.Contractor.Maintenance
|
||||
alerttype = DetermineAlertType(alerttype.Trim());
|
||||
if (alerttype == null)
|
||||
return;
|
||||
db.ExecSQL(SQL, alertid, alerttime, alerttype, title, desc, m.ID, m.VIN, m.CustName, m.ModelID, m.ModelName, m.MakeID, m.MakeName, m.TypeID, m.TypeName, hours, lat, lon, locdate);
|
||||
if (string.IsNullOrWhiteSpace(alerttype))
|
||||
alerttype = "";
|
||||
object obj = db.GetRC1BySQL("select isnull((select top 1 1 from AUTOACKNOWLEDGEALERTTYPES where ALERTTYPE={0}),0)", alerttype);
|
||||
bool autoAcknowledge = obj.ToString() == "1";
|
||||
db.ExecSQL(SQL, alertid, alerttime, alerttype, title, desc, m.ID, m.VIN, m.CustName, m.ModelID, m.ModelName, m.MakeID, m.MakeName, m.TypeID, m.TypeName, hours, lat, lon, locdate, autoAcknowledge ? 1 : 0);
|
||||
}
|
||||
|
||||
private string DetermineAlertType(string alerttype)
|
||||
|
@ -14,6 +14,24 @@ namespace IronIntel.Contractor.Maintenance
|
||||
public string PmScheduleUom { get; set; }
|
||||
|
||||
public string PmScheduleType { get; set; } //PM,TBM,HM
|
||||
public string PmScheduleTypeStr
|
||||
{
|
||||
get
|
||||
{
|
||||
var rst = "";
|
||||
if (PmScheduleType == "PM")
|
||||
rst = "Absolute Hours";
|
||||
else if (PmScheduleType == "TBM")
|
||||
rst = "Relative Time";
|
||||
else if (PmScheduleType == "HM")
|
||||
rst = "Relative Hours";
|
||||
else if (PmScheduleType == "ADM")
|
||||
rst = "Absolute Distance";
|
||||
else if (PmScheduleType == "RDM")
|
||||
rst = "Relative Distance";
|
||||
return rst;
|
||||
}
|
||||
}
|
||||
public string Notes { get; set; }
|
||||
|
||||
public PmIntervalItem[] Intervals { get; set; }
|
||||
@ -29,6 +47,7 @@ namespace IronIntel.Contractor.Maintenance
|
||||
|
||||
public string ServiceName { get; set; }
|
||||
public bool Recurring { get; set; }
|
||||
public double ExpectedCost { get; set; }
|
||||
public int Priority { get; set; }
|
||||
|
||||
public string ServiceDescription { get; set; }
|
||||
@ -91,7 +110,7 @@ namespace IronIntel.Contractor.Maintenance
|
||||
{
|
||||
if (AlertTime != DateTime.MinValue)
|
||||
{
|
||||
return AlertTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
return AlertTime.ToString("M/d/yyyy h:m:s tt");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ using Foresight.Fleet.Services.AssetHealth;
|
||||
using Foresight.Fleet.Services.User;
|
||||
using IronIntel.Contractor.Machines;
|
||||
using IronIntel.Services;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
@ -19,11 +18,13 @@ namespace IronIntel.Contractor.Maintenance
|
||||
|
||||
#region PM SCHEDULES
|
||||
|
||||
public static PmScheduleInfo[] GetPmSchedule(string sessionid, string pmtype)
|
||||
public static PmScheduleInfo[] GetPmSchedule(string sessionid, string pmtype, string pmid, string filter)
|
||||
{
|
||||
var items = FleetServiceClientHelper.CreateClient<PMClient>(sessionid).GetPMScheduleItems(SystemParams.CompanyID, pmtype, string.Empty, true);
|
||||
var items = FleetServiceClientHelper.CreateClient<PMClient>(sessionid).GetPMScheduleItems(SystemParams.CompanyID, pmtype, filter, true);
|
||||
if (items == null || items.Length == 0)
|
||||
return new PmScheduleInfo[0];
|
||||
if (!string.IsNullOrEmpty(pmid))
|
||||
items = items.Where(m => m.Id == pmid).ToArray();
|
||||
List<PmScheduleInfo> list = new List<PmScheduleInfo>();
|
||||
foreach (var item in items)
|
||||
{
|
||||
@ -85,48 +86,6 @@ namespace IronIntel.Contractor.Maintenance
|
||||
|
||||
return pm;
|
||||
}
|
||||
//private static int[] GetAllIntervals(PMScheduleItem sc)
|
||||
//{
|
||||
// Dictionary<int, List<PMIntervalItem>> result = new Dictionary<int, List<PMIntervalItem>>();
|
||||
|
||||
// var intervals = sc.Intervals.Where(i => i.Recurring).OrderBy(i => i.Interval).ThenByDescending(i => i.Priority).ToList();
|
||||
// if (intervals.Count == 0)
|
||||
// return new int[0];
|
||||
|
||||
// int maxInterval = intervals[intervals.Count() - 1].Interval;
|
||||
// for (int i = intervals.Count - 1; i >= 0; i--)
|
||||
// {//从最大的Interval开始
|
||||
// PMIntervalItem ia = intervals[i];
|
||||
|
||||
// int tempInterval = ia.Interval;
|
||||
// var existIntervals = result.OrderBy(kv => kv.Key).Select(kv => kv.Key).ToList();
|
||||
|
||||
// if (!result.ContainsKey(tempInterval))//加入自己
|
||||
// {
|
||||
// result[tempInterval] = new List<PMIntervalItem>();
|
||||
// }
|
||||
// result[tempInterval].Add(ia);
|
||||
|
||||
// tempInterval += ia.Interval;
|
||||
// foreach (var ti in existIntervals)
|
||||
// {//result排序后找第一个比tempInterval大的值
|
||||
// while (tempInterval < ti)
|
||||
// {
|
||||
// if (!result.ContainsKey(tempInterval))
|
||||
// {
|
||||
// result[tempInterval] = new List<PMIntervalItem>();
|
||||
// }
|
||||
// result[tempInterval].Add(ia);
|
||||
// tempInterval += ia.Interval;
|
||||
// }
|
||||
|
||||
// tempInterval = ti;
|
||||
// tempInterval += ia.Interval;
|
||||
// }
|
||||
// }
|
||||
|
||||
// return result.Select(r => r.Key).OrderBy(r => r).ToArray();
|
||||
//}
|
||||
|
||||
private static int[] GetAllIntervals(PMScheduleItem sc)
|
||||
{
|
||||
@ -140,11 +99,13 @@ namespace IronIntel.Contractor.Maintenance
|
||||
for (int i = 0; i < intervals.Count; i++)
|
||||
{
|
||||
PMIntervalItem ia = intervals[i];
|
||||
if (maxInterval == 0)
|
||||
if (maxInterval <= 0)
|
||||
maxInterval = ia.Interval;
|
||||
else
|
||||
maxInterval = GetMinCommonMultiple(maxInterval, ia.Interval);
|
||||
}
|
||||
if (maxInterval < 0 || maxInterval > 10240000)//溢出或数据过大
|
||||
maxInterval = intervals.LastOrDefault().Interval;
|
||||
for (int i = 0; i < intervals.Count; i++)
|
||||
{
|
||||
PMIntervalItem ia = intervals[i];
|
||||
@ -198,12 +159,14 @@ namespace IronIntel.Contractor.Maintenance
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public static PMAssetAlertInfo[] GetPmScheduleByAsset(string sessionid, long assetid)
|
||||
public static PMAssetAlertInfo[] GetPmScheduleByAsset(string sessionid, long assetid, bool includeinterval)
|
||||
{
|
||||
List<PMAssetAlertInfo> result = new List<PMAssetAlertInfo>();
|
||||
var client = FleetServiceClientHelper.CreateClient<PMClient>(sessionid);
|
||||
var sches = client.GetPMScheduleItems(SystemParams.CompanyID, "", string.Empty, true);
|
||||
var aas = client.GetPMAssetAlertItems(SystemParams.CompanyID, assetid);
|
||||
PMAssetAlertItem[] aas = null;
|
||||
if (includeinterval)
|
||||
aas = client.GetPMAssetAlertItems(SystemParams.CompanyID, assetid);
|
||||
foreach (var item in sches)
|
||||
{
|
||||
PMAssetAlertInfo pm = new PMAssetAlertInfo();
|
||||
@ -212,7 +175,7 @@ namespace IronIntel.Contractor.Maintenance
|
||||
pm.PmScheduleUom = item.UOM;
|
||||
pm.PmScheduleType = item.ScheduleType;
|
||||
pm.Notes = item.Notes;
|
||||
if (item.Intervals != null || item.Intervals.Count > 0)
|
||||
if (includeinterval && item.Intervals != null || item.Intervals.Count > 0)
|
||||
{
|
||||
List<PmIntervalItem> lsinterval = new List<PmIntervalItem>();
|
||||
foreach (var pi in item.Intervals)
|
||||
@ -230,7 +193,7 @@ namespace IronIntel.Contractor.Maintenance
|
||||
else
|
||||
pm.Intervals = new PmIntervalItem[0];
|
||||
|
||||
if (aas != null)
|
||||
if (includeinterval && aas != null)
|
||||
{
|
||||
var aa = aas.FirstOrDefault(a => a.PMScheduleId.Equals(pm.PmScheduleID, StringComparison.OrdinalIgnoreCase));
|
||||
if (aa != null)
|
||||
@ -254,20 +217,6 @@ namespace IronIntel.Contractor.Maintenance
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
public static PmScheduleInfo GetPmScheduleByID(string sessionid, string scheduleid)
|
||||
{
|
||||
const string SQL = @"select PMSCHEDULEID,SCHEDULENAME,SCHEDULETYPE,NOTES,SCHEDULEUOM from PM_SCHEDULES where PMSCHEDULEID={0}";
|
||||
FISqlConnection db = SystemParams.GetDbInstance();
|
||||
DataTable dt = db.GetDataTableBySQL(SQL, scheduleid);
|
||||
if (dt.Rows.Count == 0)
|
||||
{
|
||||
return new PmScheduleInfo();
|
||||
}
|
||||
PmScheduleInfo si = ConvertPmScheduleInfo(dt.Rows[0]);
|
||||
si.Intervals = GetPmInterval(sessionid, si.PmScheduleID);
|
||||
return si;
|
||||
}
|
||||
|
||||
public static void UpdatePmSchedule(string sessionid, PmScheduleInfo si, string useriid)
|
||||
{
|
||||
PMScheduleItem pm = new PMScheduleItem();
|
||||
@ -300,103 +249,23 @@ namespace IronIntel.Contractor.Maintenance
|
||||
FleetServiceClientHelper.CreateClient<PMClient>(sessionid).UpdatePMInterval(SystemParams.CompanyID, interval, useriid);
|
||||
}
|
||||
|
||||
public static MaintenanceMachineInfo[] GetPmMachinesByScheduleId(string scheduleid)
|
||||
{
|
||||
const string SQL = @"select a.MACHINEID,a.STARTDATE,a.STARTHOURS,a.STARTOTOMETER,b.MACHINENAME,b.MACHINENAME2,b.VIN,b.MAKEID,b.MODELID,b.TYPEID,b.HIDE,
|
||||
ISNULL(b.ENGINEHOURS,0) as ENGINEHOURS,ISNULL(b.ODOMETER,0) as ODOMETER,ISNULL(b.ODOMETERUOM,'Mile') AS ODOMETERUOM
|
||||
from PM_MACHINES a,MACHINES b where a.MACHINEID=b.MACHINEID and a.PMSCHEDULEID={0}";
|
||||
|
||||
FISqlConnection db = SystemParams.GetDbInstance();
|
||||
DataTable tb = db.GetDataTableBySQL(SQL, scheduleid);
|
||||
if (tb.Rows.Count == 0)
|
||||
{
|
||||
return new MaintenanceMachineInfo[0];
|
||||
}
|
||||
MachineManagement.RefreshBaseData();
|
||||
MachineMake[] makes = MachineManagement.GetMachineMakes();
|
||||
MachineModel[] models = MachineManagement.GetMachineModels();
|
||||
MachineType[] types = MachineManagement.GetMachineTypes();
|
||||
List<MaintenanceMachineInfo> ls = new List<MaintenanceMachineInfo>();
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
MaintenanceMachineInfo mi = ConvertToMaintenanceMachineInfo(dr, makes, models, types);
|
||||
ls.Add(mi);
|
||||
}
|
||||
return ls.ToArray();
|
||||
}
|
||||
|
||||
|
||||
private static object GetValueOrNull(DateTime v)
|
||||
{
|
||||
if (v == DateTime.MinValue || v == new DateTime(1900, 1, 1))
|
||||
return null;
|
||||
else
|
||||
return v;
|
||||
}
|
||||
|
||||
public static void DeletePmMachine(string scheduleid, string machineid)
|
||||
{
|
||||
const string SQL = "delete from PM_MACHINES where PMSCHEDULEID={0} and MACHINEID={1}";
|
||||
FISqlConnection db = SystemParams.GetDbInstance();
|
||||
db.ExecSQL(SQL, scheduleid, machineid);
|
||||
}
|
||||
|
||||
private static bool CheckPmScheduleNameRepeat(string scheduleid, string schedulename)
|
||||
{
|
||||
const string SQL = "select COUNT(1) from PM_SCHEDULES where PMSCHEDULEID!={0} and SCHEDULENAME={1}";
|
||||
FIDbAccess db = SystemParams.GetDbInstance();
|
||||
object obj = db.GetRC1BySQL(SQL, scheduleid, schedulename);
|
||||
if (Convert.ToInt32(obj) > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool CheckPmScheduleHasMachine(string scheduleid)
|
||||
{
|
||||
const string SQL_M = "select COUNT(1) from PM_MACHINES where PMSCHEDULEID={0}";
|
||||
FIDbAccess db = SystemParams.GetDbInstance();
|
||||
object objm = db.GetRC1BySQL(SQL_M, scheduleid);
|
||||
if (Convert.ToInt32(objm) > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private static PmScheduleInfo ConvertPmScheduleInfo(DataRow dr)
|
||||
{
|
||||
PmScheduleInfo si = new PmScheduleInfo();
|
||||
si.PmScheduleID = FIDbAccess.GetFieldString(dr["PMSCHEDULEID"], string.Empty);
|
||||
si.PmScheduleName = FIDbAccess.GetFieldString(dr["SCHEDULENAME"], string.Empty);
|
||||
si.PmScheduleType = FIDbAccess.GetFieldString(dr["SCHEDULETYPE"], string.Empty);
|
||||
si.Notes = FIDbAccess.GetFieldString(dr["NOTES"], string.Empty);
|
||||
si.PmScheduleUom = FIDbAccess.GetFieldString(dr["SCHEDULEUOM"], string.Empty);
|
||||
return si;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Maintenance Log
|
||||
|
||||
public static MaintenanceLogInfo[] GetMaintenanceLog(string sessionid, long assetid, string maintenancetype, int machinetype, string searchtxt, string useriid)
|
||||
public static MaintenanceLogInfo[] GetMaintenanceLog(string sessionid, long assetid, string maintenancetype, int machinetype, string searchtxt, DateTime starttime, DateTime endtime, string useriid)
|
||||
{
|
||||
const string SQL = @"select a.MAINTENANCEID,a.MACHINEID,a.MAINTENANCEDATE,a.MAINTENANCEHOURS,a.NOTES,a.ALERTID,b.MACHINENAME,b.MACHINENAME2, b.VIN,b.MAKEID, b.MODELID,b.TYPEID,ISNULL(b.ENGINEHOURS,0) as ENGINEHOURS,
|
||||
t.ALERTTYPE,t.ALERTTITLE,t.ALERTTIME_UTC,ISNULL(a.ODOMETER,0) AS ODOMETER,ISNULL(a.ODOMETERUOM,'Hour') AS ODOMETERUOM, isnull(LOGTYPE,'Hours') AS LOGTYPE ,a.COST,a.INVOICENUMBER,a.COMPLETEDBY,a.COMPLETEDBYUSERNAME,
|
||||
(select top 1 ATTACHID from ATTACHES where SOURCE='MaintenanceLog' and REFID=a.MAINTENANCEID and isnull(DELETED,0)=0) ATTACHID
|
||||
from MAINTENANCELOG a left join ALERTS t on a.ALERTID=t.ALERTID,MACHINES b
|
||||
where a.MACHINEID = b.MACHINEID and ISNULL(b.HIDE,0)<>1";
|
||||
(select top 1 ATTACHID from ATTACHES with(nolock) where SOURCE='MaintenanceLog' and REFID=a.MAINTENANCEID and isnull(DELETED,0)=0) ATTACHID
|
||||
from MAINTENANCELOG a with(nolock) left join ALERTS t with(nolock) on a.ALERTID=t.ALERTID,MACHINES b
|
||||
where a.MACHINEID = b.MACHINEID and ISNULL(b.HIDE,0)<>1 and a.MAINTENANCEDATE>={0} and a.MAINTENANCEDATE<={1} ";
|
||||
const string ORDER_BY = " ORDER BY a.ADDEDON DESC";
|
||||
|
||||
DateTime sttime = new DateTime(starttime.Year, starttime.Month, starttime.Day, 0, 0, 0);
|
||||
DateTime ettime = new DateTime(endtime.Year, endtime.Month, endtime.Day, 23, 59, 59);
|
||||
|
||||
string sql = SQL;
|
||||
//if (string.Compare("Distance", maintenancetype, true) == 0)
|
||||
//{
|
||||
// sql = SQL + " and a.LOGTYPE='" + maintenancetype + "'";
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// sql = SQL + " and a.LOGTYPE='" + maintenancetype + "'";
|
||||
// sql = SQL + " and (a.LOGTYPE='" + maintenancetype + "' or a.LOGTYPE is null)";
|
||||
//}
|
||||
if (assetid > 0)
|
||||
{
|
||||
sql = sql + " and a.MACHINEID=" + assetid;
|
||||
@ -411,7 +280,7 @@ namespace IronIntel.Contractor.Maintenance
|
||||
}
|
||||
|
||||
FISqlConnection db = SystemParams.GetDbInstance();
|
||||
DataTable dt = db.GetDataTableBySQL(sql, useriid);
|
||||
DataTable dt = db.GetDataTableBySQL(sql, sttime, ettime);
|
||||
if (dt.Rows.Count == 0)
|
||||
{
|
||||
return new MaintenanceLogInfo[0];
|
||||
@ -423,9 +292,9 @@ namespace IronIntel.Contractor.Maintenance
|
||||
availableAssetsids = FleetServiceClientHelper.CreateClient<AssetQueryClient>(sessionid).GetAvailableAssetsForUsers(SystemParams.CompanyID, useriid);
|
||||
|
||||
MachineManagement.RefreshBaseData();
|
||||
MachineMake[] makes = MachineManagement.GetMachineMakes();
|
||||
MachineModel[] models = MachineManagement.GetMachineModels();
|
||||
MachineType[] types = MachineManagement.GetMachineTypes();
|
||||
AssetMake[] makes = MachineManagement.GetMachineMakes();
|
||||
AssetModel[] models = MachineManagement.GetMachineModels();
|
||||
AssetType[] types = MachineManagement.GetMachineTypes();
|
||||
|
||||
List<MaintenanceLogInfo> list = new List<MaintenanceLogInfo>();
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
@ -478,9 +347,9 @@ namespace IronIntel.Contractor.Maintenance
|
||||
}
|
||||
|
||||
MachineManagement.RefreshBaseData();
|
||||
MachineMake[] makes = MachineManagement.GetMachineMakes();
|
||||
MachineModel[] models = MachineManagement.GetMachineModels();
|
||||
MachineType[] types = MachineManagement.GetMachineTypes();
|
||||
AssetMake[] makes = MachineManagement.GetMachineMakes();
|
||||
AssetModel[] models = MachineManagement.GetMachineModels();
|
||||
AssetType[] types = MachineManagement.GetMachineTypes();
|
||||
|
||||
MaintenanceLogInfo ml = ConvertToMaintenanceLogInfo(dt.Rows[0], makes, models, types);
|
||||
return ml;
|
||||
@ -501,9 +370,9 @@ namespace IronIntel.Contractor.Maintenance
|
||||
}
|
||||
|
||||
MachineManagement.RefreshBaseData();
|
||||
MachineMake[] makes = MachineManagement.GetMachineMakes();
|
||||
MachineModel[] models = MachineManagement.GetMachineModels();
|
||||
MachineType[] types = MachineManagement.GetMachineTypes();
|
||||
AssetMake[] makes = MachineManagement.GetMachineMakes();
|
||||
AssetModel[] models = MachineManagement.GetMachineModels();
|
||||
AssetType[] types = MachineManagement.GetMachineTypes();
|
||||
|
||||
List<MaintenanceLogInfo> list = new List<MaintenanceLogInfo>();
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
@ -527,9 +396,9 @@ namespace IronIntel.Contractor.Maintenance
|
||||
return new MaintenanceLogInfo();
|
||||
}
|
||||
MachineManagement.RefreshBaseData();
|
||||
MachineMake[] makes = MachineManagement.GetMachineMakes();
|
||||
MachineModel[] models = MachineManagement.GetMachineModels();
|
||||
MachineType[] types = MachineManagement.GetMachineTypes();
|
||||
AssetMake[] makes = MachineManagement.GetMachineMakes();
|
||||
AssetModel[] models = MachineManagement.GetMachineModels();
|
||||
AssetType[] types = MachineManagement.GetMachineTypes();
|
||||
|
||||
MaintenanceLogInfo ml = ConvertToMaintenanceLogInfo(dt.Rows[0], makes, models, types);
|
||||
return ml;
|
||||
@ -538,10 +407,10 @@ namespace IronIntel.Contractor.Maintenance
|
||||
public static void UpdateMaintenanceLog(MaintenanceLogInfo ml, string addedby)
|
||||
{
|
||||
const string SQL = @"if exists(select 1 from MAINTENANCELOG where MAINTENANCEID={0}) update MAINTENANCELOG set MACHINEID ={1},MAINTENANCEDATE ={2},
|
||||
MAINTENANCEHOURS={3},NOTES={4},LASTUPDATEDBY={5},LASTUPDATEDON=GETUTCDATE(),ALERTID={6},ODOMETER={7},ODOMETERUOM={8},LOGTYPE={9},COST={10},INVOICENUMBER={11},COMPLETEDBYUSERNAME={12},COMPLETED={13},COMPLETEDDATE_UTC= (case {13} when 1 then GETUTCDATE() else null end) where MAINTENANCEID={0} else insert into MAINTENANCELOG(MAINTENANCEID,
|
||||
MACHINEID,MAINTENANCEDATE,MAINTENANCEHOURS,NOTES,ADDEDBY,ADDEDON,LASTUPDATEDBY,LASTUPDATEDON,ALERTID,ODOMETER,ODOMETERUOM,LOGTYPE,COST,INVOICENUMBER,COMPLETEDBYUSERNAME,COMPLETED,COMPLETEDDATE_UTC) values({0},{1},{2},{3},{4},{5},GETUTCDATE(),{5},GETUTCDATE(),{6},{7},{8},{9},{10},{11},{12},{13},(case {13} when 1 then GETUTCDATE() else null end))";
|
||||
MAINTENANCEHOURS={3},NOTES={4},LASTUPDATEDBY={5},LASTUPDATEDON=GETUTCDATE(),ALERTID={6},ODOMETER={7},ODOMETERUOM={8},LOGTYPE={9},COST={10},INVOICENUMBER={11},COMPLETEDBYUSERNAME={12},COMPLETED={13},COMPLETEDDATE_UTC= (case {13} when 1 then GETDATE() else null end) where MAINTENANCEID={0} else insert into MAINTENANCELOG(MAINTENANCEID,
|
||||
MACHINEID,MAINTENANCEDATE,MAINTENANCEHOURS,NOTES,ADDEDBY,ADDEDON,LASTUPDATEDBY,LASTUPDATEDON,ALERTID,ODOMETER,ODOMETERUOM,LOGTYPE,COST,INVOICENUMBER,COMPLETEDBYUSERNAME,COMPLETED,COMPLETEDDATE_UTC) values({0},{1},{2},{3},{4},{5},GETUTCDATE(),{5},GETUTCDATE(),{6},{7},{8},{9},{10},{11},{12},{13},(case {13} when 1 then GETDATE() else null end))";
|
||||
FISqlConnection db = SystemParams.GetDbInstance();
|
||||
db.ExecSQL(SQL, ml.MaintenanceID, ml.MachineID, ml.MaintenanceDate, ml.MaintenanceHours, ml.Notes, addedby, ml.AlertID, ml.ODOMeter, ml.ODOMemterUOM, ml.LogType, ml.Cost, ml.InvoiceNumber, ml.CompletedByName, ml.Completed ? 1 : 0);
|
||||
db.ExecSQL(SQL, ml.MaintenanceID, ml.MachineID, ml.MaintenanceDate, ml.MaintenanceHours, ml.Notes, addedby, ml.AlertID, ml.ODOMeter, ml.ODOMemterUOM, ml.LogType, ml.Cost, ml.InvoiceNumber, ml.CompletedByName, ml.Completed ? 1 : 0);//COMPLETEDDATE_UTC保存的GETDATE(),与WorkOrder里面的录入的实际保存一致
|
||||
}
|
||||
|
||||
public static void DeleteMaintenanceLog(string maintencelogid)
|
||||
@ -551,13 +420,6 @@ namespace IronIntel.Contractor.Maintenance
|
||||
db.ExecSQL(SQL, maintencelogid);
|
||||
}
|
||||
|
||||
public static bool HasMaintenanceLog(long machineid)
|
||||
{
|
||||
const string SQL = "SELECT count([MAINTENANCEDATE]) FROM [MAINTENANCELOG] where MACHINEID={0}";
|
||||
var db = SystemParams.GetDbInstance();
|
||||
return (int?)db.GetRC1BySQL(SQL, machineid) > 0;
|
||||
}
|
||||
|
||||
public static PMAlert[] GetUnCompletedPMAlerts(long machineid, string maintencelogid)
|
||||
{
|
||||
List<PMAlert> alerts = new List<PMAlert>();
|
||||
@ -572,7 +434,7 @@ namespace IronIntel.Contractor.Maintenance
|
||||
alert.AlertTitle = FIDbAccess.GetFieldString(dr["ALERTTITLE"], string.Empty);
|
||||
DateTime at = FIDbAccess.GetFieldDateTime(dr["ALERTTIME_UTC"], DateTime.MinValue);
|
||||
if (at != DateTime.MinValue)
|
||||
alert.AlertTime = at.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
alert.AlertTime = at.ToString("M/d/yyyy h:m:s tt");
|
||||
alerts.Add(alert);
|
||||
}
|
||||
return alerts.ToArray();
|
||||
@ -585,7 +447,7 @@ namespace IronIntel.Contractor.Maintenance
|
||||
db.ExecSQL(SQL, completed ? 1 : 0, alertID, completedby);
|
||||
}
|
||||
|
||||
private static MaintenanceLogInfo ConvertToMaintenanceLogInfo(DataRow dr, MachineMake[] makes, MachineModel[] models, MachineType[] types)
|
||||
private static MaintenanceLogInfo ConvertToMaintenanceLogInfo(DataRow dr, AssetMake[] makes, AssetModel[] models, AssetType[] types)
|
||||
{
|
||||
MaintenanceLogInfo ml = new MaintenanceLogInfo();
|
||||
ml.MaintenanceID = FIDbAccess.GetFieldString(dr["MAINTENANCEID"], string.Empty);
|
||||
@ -606,40 +468,40 @@ namespace IronIntel.Contractor.Maintenance
|
||||
ml.CompletedByName = FIDbAccess.GetFieldString(dr["COMPLETEDBYUSERNAME"], "");
|
||||
|
||||
int makeid = FIDbAccess.GetFieldInt(dr["MAKEID"], 0);
|
||||
MachineMake make = MachineManagement.GetMachineMake(makes, makeid);
|
||||
AssetMake make = MachineManagement.GetMachineMake(makes, makeid);
|
||||
ml.MachineMake = make == null ? string.Empty : make.Name;
|
||||
|
||||
int modelid = FIDbAccess.GetFieldInt(dr["MODELID"], 0);
|
||||
MachineModel model = MachineManagement.GetMachineModel(models, modelid);
|
||||
AssetModel model = MachineManagement.GetMachineModel(models, modelid);
|
||||
ml.MachineModel = model == null ? string.Empty : model.Name;
|
||||
|
||||
int typeid = FIDbAccess.GetFieldInt(dr["TYPEID"], 0);
|
||||
MachineType mtype = MachineManagement.GetMachineType(types, typeid);
|
||||
AssetType mtype = MachineManagement.GetMachineType(types, typeid);
|
||||
ml.MachineType = mtype == null ? string.Empty : mtype.Name;
|
||||
|
||||
return ml;
|
||||
}
|
||||
|
||||
public static WorkOrderInfo[] GetMaintenanceWorkOrders(string sessionid, string custid, string[] assignedusers, string[] asseitgroups, string filter, string useriid)
|
||||
public static WorkOrderListItemClient[] GetMaintenanceWorkOrders(string sessionid, string custid, string[] assignedusers, string[] asseitgroups, string filter, string useriid)
|
||||
{
|
||||
const string SQL = @"select m.MAINTENANCEID,m.COMPLETEDBY,(select USERNAME from USERS where USERS.USERIID=m.COMPLETEDBY) as ASSIGNEDTONAME,m.NOTES,m.MAINTENANCEDATE
|
||||
,b.MACHINEID,b.VIN,b.MACHINENAME,b.MACHINENAME2 from MAINTENANCELOG m left join MACHINES b on b.MACHINEID=m.MACHINEID
|
||||
where m.ALERTID not in (select ALERTID from WORKORDER_ALERTS) and m.MACHINEID = b.MACHINEID and ISNULL(b.HIDE,0)<>1 ";
|
||||
const string SQL = @"select m.MAINTENANCEID,m.COMPLETEDBY,(select USERNAME from USERS with(nolock) where USERS.USERIID=m.COMPLETEDBY) as ASSIGNEDTONAME,m.NOTES,m.MAINTENANCEDATE
|
||||
,b.MACHINEID,b.VIN,b.MACHINENAME,b.MACHINENAME2 from MAINTENANCELOG m with(nolock) left join MACHINES b with(nolock) on b.MACHINEID=m.MACHINEID
|
||||
where m.ALERTID not in (select ALERTID from WORKORDER_ALERTS with(nolock)) and m.MACHINEID = b.MACHINEID and ISNULL(b.HIDE,0)<>1 ";
|
||||
const string SQL_FILTER = " and (m.NOTES like {0} or b.MACHINEID like {0} or b.VIN like {0} or b.MACHINENAME like {0} or b.MACHINENAME2 like {0}) ";
|
||||
const string SQL_ORDERBY = " order by m.MAINTENANCEID";
|
||||
|
||||
var user = FleetServiceClientHelper.CreateClient<UserQueryClient>(custid, sessionid).GetUserByIID(useriid);
|
||||
if (user == null || (!user.Active))
|
||||
{
|
||||
return new WorkOrderInfo[0];
|
||||
return new WorkOrderListItemClient[0];
|
||||
}
|
||||
if (user == null || (!user.Active))
|
||||
{
|
||||
return new WorkOrderInfo[0];
|
||||
return new WorkOrderListItemClient[0];
|
||||
}
|
||||
if (string.Compare(user.CompanyID, SystemParams.CompanyID, true) != 0 && (!user.IsForesightUser))
|
||||
{
|
||||
return new WorkOrderInfo[0];
|
||||
return new WorkOrderListItemClient[0];
|
||||
}
|
||||
|
||||
string sql = SQL;
|
||||
@ -666,12 +528,12 @@ namespace IronIntel.Contractor.Maintenance
|
||||
dt = db.GetDataTableBySQL(sql + SQL_FILTER + SQL_ORDERBY, "%" + filter + "%");
|
||||
|
||||
if (dt.Rows.Count == 0)
|
||||
return new WorkOrderInfo[0];
|
||||
return new WorkOrderListItemClient[0];
|
||||
|
||||
List<WorkOrderInfo> list = new List<WorkOrderInfo>();
|
||||
List<WorkOrderListItemClient> list = new List<WorkOrderListItemClient>();
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
WorkOrderInfo wo = new WorkOrderInfo();
|
||||
WorkOrderListItemClient wo = new WorkOrderListItemClient();
|
||||
|
||||
long assetid = FIDbAccess.GetFieldInt64(dr["MACHINEID"], 0);
|
||||
if (assets != null && assets.Length > 0)
|
||||
@ -681,14 +543,15 @@ namespace IronIntel.Contractor.Maintenance
|
||||
continue;
|
||||
}
|
||||
}
|
||||
wo.AssetID = assetid;
|
||||
wo.AssignedTo = FIDbAccess.GetFieldString(dr["COMPLETEDBY"], string.Empty);
|
||||
wo.AssetId = assetid;
|
||||
wo.MaintenanceID = FIDbAccess.GetFieldString(dr["MAINTENANCEID"], string.Empty);
|
||||
wo.Description = FIDbAccess.GetFieldString(dr["NOTES"], string.Empty);
|
||||
wo.CompleteDate = FIDbAccess.GetFieldDateTime(dr["MAINTENANCEDATE"], DateTime.MinValue);
|
||||
wo.VIN = FIDbAccess.GetFieldString(dr["VIN"], string.Empty);
|
||||
wo.AssetName = FIDbAccess.GetFieldString(dr["MACHINENAME"], string.Empty);
|
||||
wo.AssignedToName = FIDbAccess.GetFieldString(dr["ASSIGNEDTONAME"], wo.AssignedTo);
|
||||
//var assignedTo = FIDbAccess.GetFieldString(dr["COMPLETEDBY"], string.Empty);
|
||||
//wo.AssignedToName = FIDbAccess.GetFieldString(dr["ASSIGNEDTONAME"], assignedTo);
|
||||
|
||||
wo.WorkOrderNumber = "";
|
||||
|
||||
list.Add(wo);
|
||||
}
|
||||
@ -717,7 +580,7 @@ namespace IronIntel.Contractor.Maintenance
|
||||
#region Machines
|
||||
|
||||
|
||||
public static MaintenanceMachineInfo[] GetMaintenanceMachines1(string sessionid, int machinetype, string searchtxt, string useriid, string companyid = null)
|
||||
public static MaintenanceMachineInfo[] GetMaintenanceMachines(string sessionid, int machinetype, string searchtxt, string useriid, string companyid = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
@ -727,7 +590,7 @@ namespace IronIntel.Contractor.Maintenance
|
||||
var client = FleetServiceClientHelper.CreateClient<AssetQueryClient>(companyid, sessionid);
|
||||
if (user.UserType < Users.UserTypes.Admin)
|
||||
availableAssetsids = client.GetAvailableAssetsForUsers(companyid, useriid);
|
||||
AssetBasicInfo[] assets = client.GetAssetBasicInfo(companyid, searchtxt, availableAssetsids);
|
||||
AssetBasicInfo[] assets = client.GetAssetBasicInfo(companyid, searchtxt, availableAssetsids, 0);
|
||||
if (assets != null && machinetype != -1)
|
||||
assets = assets.Where(m => m.TypeID == machinetype).ToArray();
|
||||
long[] mids = null;
|
||||
@ -749,7 +612,7 @@ namespace IronIntel.Contractor.Maintenance
|
||||
mi.TypeID = a.TypeID;
|
||||
mi.MachineType = a.TypeName;
|
||||
mi.Hide = a.Hide;
|
||||
mi.EngineHours = a.EngineHours;
|
||||
mi.EngineHours = a.EngineHours == null ? 0 : a.EngineHours.Value;
|
||||
if (odos != null && odos.Length > 0)
|
||||
{
|
||||
var odo = odos.FirstOrDefault((o) => o.AssetID == mi.MachineID);
|
||||
@ -763,104 +626,7 @@ namespace IronIntel.Contractor.Maintenance
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public static MaintenanceMachineInfo[] GetMaintenanceMachines(string sessionid, int machinetype, string searchtxt, string useriid, string companyid = null)
|
||||
{
|
||||
const string SQL = @"select m.MACHINEID,m.MACHINENAME2,m.MACHINENAME,m.MAKEID,m.MODELID,m.TYPEID,m.VIN,ISNULL(m.ENGINEHOURS,0) as ENGINEHOURS,
|
||||
ISNULL(m.ODOMETER,0) as ODOMETER,ISNULL(m.ODOMETERUOM,'Mile') AS ODOMETERUOM,m.HIDE from MACHINES m
|
||||
where 1=1";
|
||||
const string ORDER_BY = " order by MACHINEID";
|
||||
|
||||
string sql = string.Empty;
|
||||
if (machinetype >= 0)
|
||||
{
|
||||
sql = SQL + " and TYPEID=" + machinetype.ToString() + ORDER_BY;
|
||||
}
|
||||
else
|
||||
{
|
||||
sql = SQL + ORDER_BY;
|
||||
}
|
||||
|
||||
FIDbAccess db = null;
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
{
|
||||
companyid = SystemParams.CompanyID;
|
||||
db = SystemParams.GetDbInstance();
|
||||
}
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(companyid);
|
||||
db = new FISqlConnection(connetionstring);
|
||||
}
|
||||
|
||||
DataTable tb = db.GetDataTableBySQL(sql);
|
||||
if (tb.Rows.Count == 0)
|
||||
{
|
||||
return new MaintenanceMachineInfo[0];
|
||||
}
|
||||
|
||||
long[] availableAssetsids = null;
|
||||
var user = Users.UserManagement.GetUserByIID(useriid);
|
||||
if (user.UserType < Users.UserTypes.Admin)
|
||||
availableAssetsids = FleetServiceClientHelper.CreateClient<AssetQueryClient>(companyid, sessionid).GetAvailableAssetsForUsers(companyid, useriid);
|
||||
|
||||
MachineManagement.RefreshBaseData();
|
||||
MachineMake[] makes = MachineManagement.GetMachineMakes();
|
||||
MachineModel[] models = MachineManagement.GetMachineModels();
|
||||
MachineType[] types = MachineManagement.GetMachineTypes();
|
||||
List<MaintenanceMachineInfo> ls = new List<MaintenanceMachineInfo>();
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
long mid = Convert.ToInt64(dr["MACHINEID"]);
|
||||
if (user.UserType < Users.UserTypes.Admin && !availableAssetsids.Contains(mid))
|
||||
continue;
|
||||
MaintenanceMachineInfo mi = ConvertToMaintenanceMachineInfo(dr, makes, models, types);
|
||||
mi.Hide = FIDbAccess.GetFieldInt(dr["HIDE"], 0) == 1;
|
||||
if (mi.Hide) continue;
|
||||
if (!string.IsNullOrWhiteSpace(searchtxt))
|
||||
{
|
||||
if (Helper.Contains(mi.VIN, searchtxt)
|
||||
|| Helper.Contains(mi.MachineID.ToString(), searchtxt)
|
||||
|| Helper.Contains(mi.MachineName, searchtxt)
|
||||
|| Helper.Contains(mi.MachineName2, searchtxt)
|
||||
|| Helper.Contains(mi.Make, searchtxt)
|
||||
|| Helper.Contains(mi.MachineType, searchtxt)
|
||||
|| Helper.Contains(mi.Model, searchtxt))
|
||||
{
|
||||
ls.Add(mi);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ls.Add(mi);
|
||||
}
|
||||
}
|
||||
return ls.ToArray();
|
||||
}
|
||||
|
||||
public static MaintenanceMachineInfo GetmachineByMachineID(long machineid)
|
||||
{
|
||||
string SQL = @"select MACHINEID,MACHINENAME,MACHINENAME2,MAKEID,MODELID,TYPEID,VIN,ISNULL(ENGINEHOURS,0) as ENGINEHOURS,
|
||||
ISNULL(ODOMETER,0) as ODOMETER,ISNULL(ODOMETERUOM,'Mile') AS ODOMETERUOM from MACHINES where MACHINEID={0}";
|
||||
FISqlConnection db = SystemParams.GetDbInstance();
|
||||
DataTable tb = db.GetDataTableBySQL(SQL, machineid);
|
||||
MaintenanceMachineInfo mi = new MaintenanceMachineInfo();
|
||||
if (tb.Rows.Count == 0)
|
||||
{
|
||||
mi.MachineID = -1;
|
||||
return mi;
|
||||
}
|
||||
MachineManagement.RefreshBaseData();
|
||||
MachineMake[] makes = MachineManagement.GetMachineMakes();
|
||||
MachineModel[] models = MachineManagement.GetMachineModels();
|
||||
MachineType[] types = MachineManagement.GetMachineTypes();
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
mi = ConvertToMaintenanceMachineInfo(dr, makes, models, types);
|
||||
}
|
||||
return mi;
|
||||
}
|
||||
|
||||
public static MaintenanceMachineInfo ConvertToMaintenanceMachineInfo(DataRow dr, MachineMake[] makes, MachineModel[] models, MachineType[] types)
|
||||
public static MaintenanceMachineInfo ConvertToMaintenanceMachineInfo(DataRow dr, AssetMake[] makes, AssetModel[] models, AssetType[] types)
|
||||
{
|
||||
MaintenanceMachineInfo mi = new MaintenanceMachineInfo();
|
||||
mi.MachineID = Convert.ToInt64(dr["MACHINEID"]);
|
||||
@ -871,15 +637,15 @@ namespace IronIntel.Contractor.Maintenance
|
||||
mi.Odometer = FIDbAccess.GetFieldDouble(dr["ODOMETER"], 0);
|
||||
|
||||
int makeid = FIDbAccess.GetFieldInt(dr["MAKEID"], 0);
|
||||
MachineMake make = MachineManagement.GetMachineMake(makes, makeid);
|
||||
AssetMake make = MachineManagement.GetMachineMake(makes, makeid);
|
||||
mi.Make = make == null ? string.Empty : make.Name;
|
||||
|
||||
int modelid = FIDbAccess.GetFieldInt(dr["MODELID"], 0);
|
||||
MachineModel model = MachineManagement.GetMachineModel(models, modelid);
|
||||
AssetModel model = MachineManagement.GetMachineModel(models, modelid);
|
||||
mi.Model = model == null ? string.Empty : model.Name;
|
||||
|
||||
int typeid = FIDbAccess.GetFieldInt(dr["TYPEID"], 0);
|
||||
MachineType mtype = MachineManagement.GetMachineType(types, typeid);
|
||||
AssetType mtype = MachineManagement.GetMachineType(types, typeid);
|
||||
mi.TypeID = mtype == null ? 0 : mtype.ID;
|
||||
mi.MachineType = mtype == null ? string.Empty : mtype.Name;
|
||||
|
||||
@ -902,38 +668,5 @@ namespace IronIntel.Contractor.Maintenance
|
||||
|
||||
#endregion
|
||||
|
||||
public static string[] GetPMDescriptionByAssetID(string companyid, long assetid)
|
||||
{
|
||||
const string SQL_1 = @"select * from usvMaintenanceAlertsMapLayer ml with (nolock) right join
|
||||
(select cast(MachineID as nvarchar) + cast(max(MaintenanceDate) as nvarchar) as MaintenanceID from usvMaintenanceAlertsMapLayer with (nolock) where PMStatus = 'Complete'
|
||||
group by MachineID) a on ml.MaintenanceID = a.MaintenanceID where PMStatus = 'Complete' and MachineID={0}";
|
||||
const string SQL_2 = "select * from usvMaintenanceAlertsMapLayer with (nolock) where PMStatus = 'Overdue' and MachineID={0}";
|
||||
const string SQL_3 = "select * from usvMaintenanceAlertsMapLayer with (nolock) where PMStatus = 'Upcoming' and MachineID={0}";
|
||||
|
||||
|
||||
string connetionstring = SystemParams.DataDbConnectionString;
|
||||
if (SystemParams.IsDealer)
|
||||
connetionstring = SystemParams.GetDbStringByCompany(companyid);
|
||||
|
||||
FISqlConnection db = new FISqlConnection(connetionstring);
|
||||
DataTable dt = db.GetDataTableBySQL(SQL_1, assetid);
|
||||
if (dt == null || dt.Rows.Count == 0)
|
||||
dt = db.GetDataTableBySQL(SQL_2, assetid);
|
||||
if (dt == null || dt.Rows.Count == 0)
|
||||
dt = db.GetDataTableBySQL(SQL_3, assetid);
|
||||
|
||||
if (dt == null || dt.Rows.Count == 0)
|
||||
return new string[0];
|
||||
|
||||
List<string> list = new List<string>();
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
string desc = FIDbAccess.GetFieldString(dr["DESCRIPTION"], string.Empty);
|
||||
list.Add(desc);
|
||||
}
|
||||
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -22,5 +22,7 @@ namespace IronIntel.Contractor.Maintenance
|
||||
public DateTime? CompletedDate { get; set; }
|
||||
public string CompletedDateStr { get { return CompletedDate == null ? "" : CompletedDate.Value.ToShortDateString(); } }
|
||||
public string Component { get; set; }
|
||||
public bool Billable { get; set; }
|
||||
public string SegmentType { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,8 @@
|
||||
using System;
|
||||
using Foresight.Fleet.Services.AssetHealth.WorkOrder;
|
||||
using Foresight.Fleet.Services.Customer;
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Contractor.Users;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -6,52 +10,133 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.Maintenance
|
||||
{
|
||||
public class WorkOrderInfo
|
||||
public class WorkOrderInfoClient : WorkOrderInfo
|
||||
{
|
||||
public long ID { get; set; }
|
||||
public string MaintenanceID { get; set; }
|
||||
public string WorkOrderType { get; set; }
|
||||
public string AssignedTo { get; set; }
|
||||
public string AssignedToName { get; set; }
|
||||
public string Status { get; set; }
|
||||
public long AssetID { get; set; }
|
||||
public string AssetName { get; set; }
|
||||
public string VIN { get; set; }
|
||||
public string Description { get; set; }
|
||||
public DateTime? DueDate { get; set; }
|
||||
public string MakeName { get; set; }
|
||||
public string ModelName { get; set; }
|
||||
public string TypeName { get; set; }
|
||||
public string DueDateStr { get { return DueDate == null ? "" : DueDate.Value.ToShortDateString(); } }
|
||||
public DateTime? CompleteDate { get; set; }
|
||||
public string CompleteDateStr { get { return CompleteDate == null ? "" : CompleteDate.Value.ToShortDateString(); } }
|
||||
public string InvoiceNumber { get; set; }
|
||||
public string NextFollowUpDateStr { get { return NextFollowUpDate == null ? "" : NextFollowUpDate.Value.ToShortDateString(); } }
|
||||
public string PartsExpectedDateStr { get { return PartsExpectedDate == null ? "" : PartsExpectedDate.Value.ToShortDateString(); } }
|
||||
public string LastLaborDateStr { get { return LastLaborDate == null ? "" : LastLaborDate.Value.ToShortDateString(); } }
|
||||
public ContactInfoClient[] ContactsClient { get; set; }
|
||||
public WorkOrderFollowerInfo[] Followers { get; set; }
|
||||
}
|
||||
|
||||
public class WorkOrderDetailInfo : WorkOrderInfo
|
||||
public class ContactInfoClient : ContactInfo
|
||||
{
|
||||
public string MeterType { get; set; }
|
||||
public double HourMeter { get; set; }
|
||||
public string ContactPreferenceStr { get; set; }
|
||||
public int SaveToCustomer { get; set; }
|
||||
}
|
||||
|
||||
private double _Odometer;
|
||||
public double Odometer
|
||||
public class WorkOrderListItemClient : WorkOrderListItem
|
||||
{
|
||||
public string DueDateStr { get { return DueDate == null ? "" : DueDate.Value.ToShortDateString(); } }
|
||||
public string CompleteDateStr { get { return CompleteDate == null ? "" : CompleteDate.Value.ToShortDateString(); } }
|
||||
public string NextFollowUpDateStr { get { return NextFollowUpDate == null ? "" : NextFollowUpDate.Value.ToShortDateString(); } }
|
||||
public string CreateDateStr { get { return CreateDate == null ? "" : CreateDate.Value.ToShortDateString(); } }
|
||||
public string CreationDateStr { get { return CreationDate == null ? "" : CreationDate.Value.ToShortDateString(); } }
|
||||
public string LastCommunicationDateStr { get { return (LastCommunicationDate == null || LastCommunicationDate == DateTime.MinValue) ? "" : LastCommunicationDate.Value.ToShortDateString(); } }
|
||||
public string LastInternalCommunicationDateStr { get { return (LastInternalCommunicationDate == null || LastInternalCommunicationDate == DateTime.MinValue) ? "" : LastInternalCommunicationDate.Value.ToShortDateString(); } }
|
||||
public string PartsExpectedDateStr { get { return PartsExpectedDate == null ? "" : PartsExpectedDate.Value.ToShortDateString(); } }
|
||||
public string LastLaborDateStr { get { return LastLaborDate == null ? "" : LastLaborDate.Value.ToShortDateString(); } }
|
||||
|
||||
public string MaintenanceID { get; set; }
|
||||
public WorkOrderStatus[] WorkOrderStatus { get; set; }
|
||||
public UserInfo[] AssignedToUsers { get; set; }
|
||||
public DepartmentInfo[] Departments { get; set; }
|
||||
public CustomerLocation[] Locations { get; set; }
|
||||
public StringKeyValue[] Salespersons { get; set; }
|
||||
public string ContactsStr
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Odometer;
|
||||
}
|
||||
set
|
||||
{
|
||||
value = value > 0 ? value : 0;
|
||||
_Odometer = Math.Round(value, 2);
|
||||
var rst = "";
|
||||
if (Contacts != null && Contacts.Count > 0)
|
||||
{
|
||||
for (var i = 0; i < Contacts.Count; i++)
|
||||
{
|
||||
var contact = Contacts[i];
|
||||
var ptext = contact.Name;
|
||||
if ((int)contact.ContactPreference == 0)
|
||||
{
|
||||
ptext += " – T";
|
||||
if (contact.MobilePhoneDisplayText != "")
|
||||
ptext += " – " + contact.MobilePhoneDisplayText;
|
||||
}
|
||||
else if ((int)contact.ContactPreference == 1)
|
||||
{
|
||||
if (contact.Email != "")
|
||||
ptext += " - " + contact.Email;
|
||||
}
|
||||
else if ((int)contact.ContactPreference == 2)
|
||||
{
|
||||
ptext += " – P";
|
||||
if (contact.MobilePhoneDisplayText != "")
|
||||
ptext += " – " + contact.MobilePhoneDisplayText;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(rst))
|
||||
rst += ptext;
|
||||
else
|
||||
rst += ("\n" + ptext);
|
||||
}
|
||||
}
|
||||
return rst;
|
||||
}
|
||||
}
|
||||
public string OdometerUnits { get; set; }
|
||||
public decimal WorkOrderTotalCost { get; set; }
|
||||
public decimal HoursToComplete { get; set; }
|
||||
public string InternalID { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public decimal PartsCost { get; set; }
|
||||
public decimal TravelTimeCost { get; set; }
|
||||
public decimal LaborCost { get; set; }
|
||||
public decimal HourlyRate { get; set; }
|
||||
public decimal OtherCost { get; set; }
|
||||
}
|
||||
|
||||
public class TextMessageClient : TextMessage
|
||||
{
|
||||
public bool StatusIncorrect
|
||||
{//6219, 2022-09-20 17:50:00 以前的状态可能存在问题,界面上不显示状态
|
||||
get
|
||||
{
|
||||
return SystemParams.CustomerDetail.CustomerTimeToUtc(Time) < DateTime.Parse("2022-09-20 17:50:00");
|
||||
}
|
||||
}
|
||||
|
||||
public string FormatSender
|
||||
{
|
||||
get
|
||||
{
|
||||
var rst = "";
|
||||
if (IsReply)
|
||||
{
|
||||
if (Helper.IsEmail(Sender) || !Helper.IsNumber(Sender))
|
||||
rst = Sender;
|
||||
else
|
||||
rst = Foresight.Standard.PhoneNumber.FormatPhoneNumber(Sender);
|
||||
}
|
||||
return rst;
|
||||
}
|
||||
}
|
||||
|
||||
public string[] OriPhoneNumbers
|
||||
{
|
||||
get
|
||||
{
|
||||
List<string> ls = new List<string>();
|
||||
if (Participator != null && Participator.Count > 0)
|
||||
{
|
||||
foreach (var p in Participator)
|
||||
{
|
||||
if (Helper.IsEmail(p.CustomerNumber))
|
||||
ls.Add(p.CustomerNumber);
|
||||
else
|
||||
{
|
||||
p.CustomerNumber = Foresight.Standard.PhoneNumber.PreparePhonenumber(p.CustomerNumber);
|
||||
ls.Add(p.CustomerNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ls.ToArray();
|
||||
}
|
||||
}
|
||||
public string TimeStr { get { return Time == DateTime.MinValue ? "" : Time.ToString("M/d/yyyy h:m tt"); } }
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,13 @@ using Foresight.Data;
|
||||
using System.Web;
|
||||
using Foresight.Fleet.Services.AssetHealth;
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using Foresight.Fleet.Services.AssetHealth.WorkOrder;
|
||||
using Foresight.Fleet.Services.Inspection;
|
||||
using Foresight.Chart.Drawer;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using Foresight.Chart.Drawer.Contracts;
|
||||
using System.Net.Mail;
|
||||
|
||||
namespace IronIntel.Contractor.Maintenance
|
||||
{
|
||||
@ -47,8 +54,8 @@ namespace IronIntel.Contractor.Maintenance
|
||||
Int64.TryParse(mid, out assetid);
|
||||
else
|
||||
{
|
||||
var client = FleetServiceClientHelper.CreateClient<WorkOrderClient>(sessionid);
|
||||
var workorder = client.GetWorkOrderDetail(SystemParams.CompanyID, Convert.ToInt64(woid));
|
||||
var client = FleetServiceClientHelper.CreateClient<WorkOrderProvider>(sessionid);
|
||||
var workorder = client.GetWorkOrderInfo(SystemParams.CompanyID, Convert.ToInt64(woid));
|
||||
assetid = workorder.AssetID;
|
||||
}
|
||||
long[] availableAssetsids = FleetServiceClientHelper.CreateClient<AssetQueryClient>(sessionid).GetAvailableAssetsForUsers(SystemParams.CompanyID, useriid);
|
||||
@ -77,113 +84,756 @@ namespace IronIntel.Contractor.Maintenance
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public static string GenerateWorkOrderPrintHtml(string sessionid, string companyid, long woid)
|
||||
public string[] GetLocations()
|
||||
{
|
||||
const string SQL = @"select distinct LOCATION from WORKORDER where ISNULL(LOCATION,'')<>''";
|
||||
|
||||
DataTable dt = GetDataTableBySQL(SQL);
|
||||
if (dt.Rows.Count == 0)
|
||||
return new string[0];
|
||||
|
||||
List<string> list = new List<string>();
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
string num = FIDbAccess.GetFieldString(dr["LOCATION"], string.Empty);
|
||||
if (!string.IsNullOrEmpty(num))
|
||||
list.Add(num);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public string[] GetDepartments()
|
||||
{
|
||||
const string SQL = @"select distinct DEPARTMENT from WORKORDER where ISNULL(DEPARTMENT,'')<>''";
|
||||
|
||||
DataTable dt = GetDataTableBySQL(SQL);
|
||||
if (dt.Rows.Count == 0)
|
||||
return new string[0];
|
||||
|
||||
List<string> list = new List<string>();
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
string num = FIDbAccess.GetFieldString(dr["DEPARTMENT"], string.Empty);
|
||||
if (!string.IsNullOrEmpty(num))
|
||||
list.Add(num);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
|
||||
public string[] GetAdvisors()
|
||||
{
|
||||
const string SQL = @"select distinct ADVISOR from WORKORDER where ISNULL(ADVISOR,'')<>''";
|
||||
|
||||
DataTable dt = GetDataTableBySQL(SQL);
|
||||
if (dt.Rows.Count == 0)
|
||||
return new string[0];
|
||||
|
||||
List<string> list = new List<string>();
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
string num = FIDbAccess.GetFieldString(dr["ADVISOR"], string.Empty);
|
||||
if (!string.IsNullOrEmpty(num))
|
||||
list.Add(num);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
public static string GenerateWorkOrderPrintHtml(string sessionid, string companyid, long woid, string lang)
|
||||
{
|
||||
var client = FleetServiceClientHelper.CreateClient<WorkOrderProvider>(companyid, sessionid);
|
||||
WorkOrderInfo wo = client.GetWorkOrderInfo(companyid, woid);
|
||||
|
||||
StringBuilder str = new StringBuilder();
|
||||
str.AppendLine("<H1 style='text-align:center;'>Work Order</H1>");
|
||||
str.AppendFormat("<div style='font-weight:bold;'>Details for work order <{0}> are listed below:</div>", woid);
|
||||
str.AppendLine("<H1 style='text-align:center;'>" + SystemParams.GetTextByKey(lang, "P_WORKORDER", "Work Order") + "</H1>");
|
||||
string detailstr = SystemParams.GetTextByKey(lang, "P_WO_DETAILFORWORKORDERARELISTEDBELOW", "Details for work order <{0}> are listed below:").Replace("<", "<").Replace(">", ">");
|
||||
str.AppendFormat("<div style='font-weight:bold;padding-bottom:5px;'>" + detailstr + "</div>", wo.WorkOrderNumber);
|
||||
str.AppendLine("");
|
||||
//str.AppendLine("<div class='label' style='text-align:left;'>Work Order Information:</div>");
|
||||
str.AppendLine("<div style='padding-left:30px;margin-bottom:36px;'>");
|
||||
|
||||
var client = FleetServiceClientHelper.CreateClient<WorkOrderClient>(companyid, sessionid);
|
||||
WorkOrderDetail wo = client.GetWorkOrderDetail(companyid, woid);
|
||||
str.Append(GenerateWorkOrderInfoHtml(wo));
|
||||
var aclient = FleetServiceClientHelper.CreateClient<AssetQueryClient>(companyid, sessionid);
|
||||
var asset = aclient.GetAssetDetailInfo(companyid, wo.AssetID);
|
||||
str.Append(GenerateWorkOrderInfoHtml(asset, wo, lang));
|
||||
str.AppendLine("</div>");
|
||||
//str.AppendLine("<div class='label' style='text-align:left;'>Segments:</div>");
|
||||
|
||||
WorkOrderSegmentItem[] segments = client.GetSegments(companyid, woid);
|
||||
WorkOrderSegmentInfo[] segments = client.GetSegments(companyid, woid);
|
||||
|
||||
if (segments != null && segments.Length > 0)
|
||||
{
|
||||
for (int i = 0; i < segments.Length; i++)
|
||||
{
|
||||
var se = segments[i];
|
||||
str.Append(GenerateSegmentHtml(se, i + 1));
|
||||
str.Append(GenerateSegmentHtml(se, i + 1, lang));
|
||||
}
|
||||
}
|
||||
|
||||
str.Append("<div style='margin-bottom:36px;margin-left:30px;'>");
|
||||
str.Append(WorkorderAlertsFormart(woid, lang, sessionid));
|
||||
|
||||
AssetInspectItem[] insplectitems = client.GetWOInspectItems(SystemParams.CompanyID, woid);
|
||||
if (insplectitems != null && insplectitems.Length > 0)
|
||||
{
|
||||
foreach (AssetInspectItem isp in insplectitems)
|
||||
{
|
||||
var report = FleetServiceClientHelper.CreateClient<AssetInspectClient>(sessionid).GetInspection(SystemParams.CompanyID, isp.Id);
|
||||
str.Append(GenerateInspectionHtml(report, lang));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
str.Append("</div>");
|
||||
|
||||
return str.ToString();
|
||||
}
|
||||
|
||||
private static string GenerateWorkOrderInfoHtml(WorkOrderDetail wo)
|
||||
private static string GenerateWorkOrderInfoHtml(AssetDetailInfo asset, WorkOrderInfo wo, string lang)
|
||||
{
|
||||
StringBuilder str = new StringBuilder();
|
||||
str.Append("<table>");
|
||||
str.AppendFormat("<tr><td class='label' style='width:170px;'>Work Order Type</td><td>{0}</td></tr>", wo.WorkOrderType);
|
||||
str.AppendFormat("<tr><td class='label' style='width:170px;'>" + SystemParams.GetTextByKey(lang, "P_WO_ASSETNAME", "Asset Name") + "</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(asset.Name));
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>Assigned To</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(wo.AssignedToName));
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_ASSETNAMECUSTOM", "Asset Name (Custom)") + "</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(asset.Name2));
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>Status</td><td>{0}</td></tr>", wo.Status);
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_VIN", "VIN/SN") + "</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(asset.VIN));
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>Due Date</td><td>{0}</td></tr>", wo.DueDate == null ? "" : wo.DueDate.Value.ToShortDateString());
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_MAKE", "Make") + "</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(asset.MakeName));
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>Description</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(wo.Description).Replace("\n", "<br>"));
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_MODEL", "Model") + "</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(asset.ModelName));
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>Meter Type</td><td>{0}</td></tr>", wo.MeterType);
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_ASSETTYPE", "Asset Type") + "</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(asset.TypeName));
|
||||
str.AppendLine("");
|
||||
if (string.Compare(wo.MeterType, "HourMeter", true) == 0
|
||||
|| string.Compare(wo.MeterType, "Both", true) == 0)
|
||||
str.AppendFormat("<tr><td class='label'>Hour Meter</td><td>{0}</td></tr>", wo.HourMeter);
|
||||
if (string.Compare(wo.MeterType, "Odometer", true) == 0
|
||||
|| string.Compare(wo.MeterType, "Both", true) == 0)
|
||||
str.AppendFormat("<tr><td class='label'>Odometer</td><td>{0} {1}</td></tr>", wo.Odometer, wo.OdometerUnits);
|
||||
str.AppendFormat("<tr><td class='label'>Work Order Total Costs ($)</td><td>{0}</td></tr>", wo.WorkOrderTotalCost);
|
||||
if (asset.OnRoad)
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_CURRENTODOMETER", "Current Odometer") + "</td><td>{0}</td></tr>", asset.CurrentOdometer == null ? "" : asset.CurrentOdometer.Corrected.ToString("#,##0"));
|
||||
else
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_CURRENTHOURS", "Current Hours") + "</td><td>{0}</td></tr>", asset.CurrentHours == null ? "" : asset.CurrentHours.Corrected.ToString("#,##0"));
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>Other Cost ($)</td><td>{0}</td></tr>", wo.OtherCost);
|
||||
str.AppendFormat("<tr><td class='label' style='width:170px;'>" + SystemParams.GetTextByKey(lang, "P_WO_CURRJOBSITE", "Current Jobsite") + " </td><td>{0}</td></tr>", HttpUtility.HtmlEncode(asset.CurrentJobSiteNames));
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>Parts Cost ($)</td><td>{0}</td></tr>", wo.PartsCost);
|
||||
str.AppendFormat("<tr><td class='label' style='width:170px;'>" + SystemParams.GetTextByKey(lang, "P_WO_CURRLOCATION", "Current Location") + " </td><td>{0}</td></tr>", asset.CurrentLocation == null ? "" : HttpUtility.HtmlEncode(asset.CurrentLocation.Address));
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>Travel Time Cost ($)</td><td>{0}</td></tr>", wo.TravelTimeCost);
|
||||
str.AppendFormat("<tr><td class='label' style='width:170px;'>" + SystemParams.GetTextByKey(lang, "P_WO_WORKORDERTYPE", "Work Order Type") + "</td><td>{0}</td></tr>", wo.WorkOrderType);
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>Labor Cost ($)</td><td>{0}</td></tr>", wo.LaborCost);
|
||||
str.AppendFormat("<tr><td class='label' style='width:170px;'>" + SystemParams.GetTextByKey(lang, "P_WO_COMPONENT", "Work Order Type") + "</td><td>{0}</td></tr>", wo.Completed);
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>Hourly Rate</td><td>{0}</td></tr>", wo.HourlyRate);
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_ASSIGNEDTO", "Assigned To") + "</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(wo.AssignedToName));
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>Time To Complete(Hrs)</td><td>{0}</td></tr>", wo.HoursToComplete);
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_STATUS", "Status") + "</td><td>{0}</td></tr>", wo.StatusName);
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>Completed Date</td><td>{0}</td></tr>", wo.CompleteDate == null ? "" : wo.CompleteDate.Value.ToShortDateString());
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_DUEDATE", "Due Date") + "</td><td>{0}</td></tr>", wo.DueDate == null ? "" : wo.DueDate.Value.ToShortDateString());
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>Internal ID</td><td>{0}</td></tr>", wo.InternalID);
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_NEXTFOLLOWUPDATE", "Next Follow Up Date") + "</td><td>{0}</td></tr>", wo.NextFollowUpDate == null ? "" : wo.NextFollowUpDate.Value.ToShortDateString());
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>Invoice Number</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(wo.InvoiceNumber));
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_DESCRIPTION", "Description") + "</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(wo.Description).Replace("\n", "<br>"));
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>Notes</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(wo.Notes).Replace("\n", "<br>"));
|
||||
if (wo.Completed)
|
||||
{
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_METERTYPE", "Meter Type") + "</td><td>{0}</td></tr>", wo.MeterType);
|
||||
str.AppendLine("");
|
||||
if (string.Compare(wo.MeterType, "HourMeter", true) == 0
|
||||
|| string.Compare(wo.MeterType, "Both", true) == 0)
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_HOURMETER", "Hour Meter") + "</td><td>{0}</td></tr>", wo.HourMeter);
|
||||
if (string.Compare(wo.MeterType, "Odometer", true) == 0
|
||||
|| string.Compare(wo.MeterType, "Both", true) == 0)
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_ODOMETER", "Odometer") + "</td><td>{0} {1}</td></tr>", wo.Odometer, wo.OdometerUnits);
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_WORKORDERTOTALCOST", "Work Order Total Costs ($)") + "</td><td>{0}</td></tr>", wo.WorkOrderTotalCost);
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_OTHERCOST", "Other Cost ($)") + "</td><td>{0}</td></tr>", wo.OtherCost);
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_PARTSCOST", "Parts Cost ($)") + "</td><td>{0}</td></tr>", wo.PartsCost);
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_TRAVELTIMECOST", "Travel Time Cost ($)") + "</td><td>{0}</td></tr>", wo.TravelTimeCost);
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_LABORCOST", "Labor Cost ($)") + "</td><td>{0}</td></tr>", wo.LaborCost);
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_HOURLYRATE", "Hourly Rate") + "</td><td>{0}</td></tr>", wo.HourlyRate);
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_TIMETOCOMPLATEHOURS", "Time To Complete(Hrs)") + "</td><td>{0}</td></tr>", wo.HoursToComplete);
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_COMPLETEDDATE", "Completed Date") + "</td><td>{0}</td></tr>", wo.CompleteDate == null ? "" : wo.CompleteDate.Value.ToShortDateString());
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_INTERNALID", "Internal ID") + "</td><td>{0}</td></tr>", wo.InternalID);
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_INVOICENUMBER", "Invoice Number") + "</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(wo.InvoiceNumber));
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>" + "Billable" + "</td><td>{0}</td></tr>", wo.Billable ? "Yes" : "No");
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>" + "Bill To Job" + "</td><td>{0}</td></tr>", wo.BillToJobName);
|
||||
str.AppendLine("");
|
||||
}
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_NOTES", "Notes") + "</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(wo.Notes).Replace("\n", "<br>"));
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("</table>");
|
||||
|
||||
return str.ToString();
|
||||
}
|
||||
|
||||
private static string GenerateSegmentHtml(WorkOrderSegmentItem se, int index)
|
||||
private static string GenerateSegmentHtml(WorkOrderSegmentInfo se, int index, string lang)
|
||||
{
|
||||
StringBuilder str = new StringBuilder();
|
||||
//str.AppendFormat("<div style='margin-bottom:36px;margin-left:30px;{0}'>", (index - 2) % 4 == 0 ? "page-break-after: always;" : "");
|
||||
//str.AppendLine("");
|
||||
str.AppendLine("<div style='margin-bottom:36px;margin-left:30px;'>");
|
||||
str.AppendLine("<table>");
|
||||
str.AppendFormat("<tr><td class='label' colspan='2' style='text-align:left;'>Segment {0}</td></tr>", index);
|
||||
str.AppendFormat("<tr><td class='label' colspan='2' style='text-align:left;'>" + SystemParams.GetTextByKey(lang, "P_WO_SEGMENT", "Segment") + " {0}</td></tr>", index);
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label' style='width:170px;'>User</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(se.UserName));
|
||||
str.AppendFormat("<tr><td class='label' style='width:170px;'>" + SystemParams.GetTextByKey(lang, "P_WO_USER", "User") + "</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(se.UserName));
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>Hours</td><td>{0}</td></tr>", se.Hours);
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_HOURS", "Hours") + "</td><td>{0}</td></tr>", se.Hours);
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>Job Site</td><td>{0}</td></tr>", se.JobsiteName);
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_JOBSITE", "Jobsite") + "</td><td>{0}</td></tr>", se.JobsiteName);
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>Cost</td><td>{0}</td></tr>", se.Cost);
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_COST", "Cost") + "</td><td>{0}</td></tr>", se.Cost);
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>Component</td><td>{0}</td></tr>", se.Component);
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_COMPONENT", "Component") + "</td><td>{0}</td></tr>", se.Component);
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>Completed</td><td>{0}</td></tr>", se.Completed ? "Yes" : "No");
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_COMPLETED", "Completed") + "</td><td>{0}</td></tr>", se.Completed ? "Yes" : "No");
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>Completed Date</td><td>{0}</td></tr>", se.CompletedDate == null ? "" : se.CompletedDate.Value.ToShortDateString());
|
||||
str.AppendFormat("<tr><td class='label'>Description</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(se.Description));
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_COMPLETEDDATE", "Completed Date") + "</td><td>{0}</td></tr>", se.CompletedDate == null ? "" : se.CompletedDate.Value.ToShortDateString());
|
||||
str.AppendFormat("<tr><td class='label'>" + "Segment Type" + "</td><td>{0}</td></tr>", se.SegmentType);
|
||||
str.AppendFormat("<tr><td class='label'>" + "Billable" + "</td><td>{0}</td></tr>", se.Billable ? "Yes" : "No");
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_DESCRIPTION", "Description") + "</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(se.Description));
|
||||
str.AppendLine("");
|
||||
str.AppendFormat("<tr><td class='label'>Notes</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(se.Notes).Replace("\n", "<br>"));
|
||||
str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_NOTES", "Notes") + "</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(se.Notes).Replace("\n", "<br>"));
|
||||
str.AppendLine("");
|
||||
str.AppendLine("</table>");
|
||||
str.AppendLine("</div>");
|
||||
return str.ToString();
|
||||
}
|
||||
|
||||
private static string GenerateInspectionHtml(InspectReportInfo report, string lang)
|
||||
{
|
||||
StringBuilder str = new StringBuilder();
|
||||
str.AppendLine("<div style='margin-bottom:36px;'>");
|
||||
str.AppendLine("<table>");
|
||||
str.AppendFormat("<tr><td class='label' colspan='2' style='text-align:left;'>" + report.Template.Name + " <span style='margin-left:30px;'>" + (report.CommitTimeLocal == DateTime.MinValue ? "" : report.CommitTimeLocal.ToString("M/d/yyyy h:mm tt")) + "</span></td></tr>");
|
||||
str.AppendLine("");
|
||||
foreach (var page in report.Template.Pages)
|
||||
{
|
||||
foreach (var section in page.Sections)
|
||||
{
|
||||
foreach (var q in section.Questions)
|
||||
{
|
||||
//if (q.VisibleToCustomer)
|
||||
//{
|
||||
str.AppendLine("<tr><td class='label' style='width:170px;'>" + q.DisplayText + "</td>");
|
||||
var span_level = "<span style='float:right;padding-right:3px;'>" + ShowSeverityLevel(lang, (int)q.SeverityLevel) + "</span>";
|
||||
InspectResultItem[] anwers = report.Answers.Where(m => m.QuestionId.ToLower() == q.Id.ToLower()).ToArray();
|
||||
if (anwers != null && anwers.Length > 0)
|
||||
{
|
||||
foreach (var a in anwers)
|
||||
{
|
||||
int[] ids = new int[] { 5, 8, 9, 10, 14, 15 };
|
||||
if (!ids.Contains((int)q.QuestionType) || ((int)q.QuestionType == 15 && q.SubType != 15))
|
||||
{
|
||||
var result = a.Result;
|
||||
if (result == null)
|
||||
result = "";
|
||||
|
||||
if ((int)q.QuestionType == 6 && result.IndexOf(' ') >= 0)//Date do not show time
|
||||
result = result.Split(' ')[0];
|
||||
if ((int)q.QuestionType == 11//Odometer
|
||||
|| (int)q.QuestionType == 18 //FuelUsed
|
||||
|| ((int)q.QuestionType == 15 && q.SubType == 8)//FuelRecords Odometer
|
||||
|| ((int)q.QuestionType == 15 && q.SubType == 10))//FuelRecords Quantity
|
||||
result += " " + ConvertUnits(a.Units);
|
||||
|
||||
if ((int)q.QuestionType == 17 && q.TextToCompare != null && result.ToLower() != q.TextToCompare.ToLower()) // BarCodeValidate
|
||||
str.AppendLine("<td><span style='color:red'>" + result + "<span><span style='margin-left:6px'>(" + q.TextToCompare + ")<span>");
|
||||
else
|
||||
str.AppendLine("<td>" + result);
|
||||
|
||||
str.AppendLine(span_level + "</td>");
|
||||
break;
|
||||
}
|
||||
else if ((int)q.QuestionType == 5)//YesOrNo
|
||||
{
|
||||
if (a.SelectedItems != null && a.SelectedItems.Count > 0)
|
||||
{
|
||||
span_level = "<span style='float:right;padding-right:3px;'>" + ShowSeverityLevel(lang, (int)a.SelectedItems[0].SeverityLevel) + "</span>";
|
||||
var label = "<label style='margin-left:5px; '>" + a.SelectedItems[0].Text + "</lable>";
|
||||
var div_circle = "<div style=' width: 12px; height: 12px; border-radius: 6px; display: inline-block;'></div>";
|
||||
if (!string.IsNullOrEmpty(a.SelectedItems[0].BackgroundColor))
|
||||
{
|
||||
div_circle = "<div style=' width: 12px; height: 12px; border-radius: 6px; display: inline-block;background-color:" + a.SelectedItems[0].BackgroundColor + "'></div>";
|
||||
}
|
||||
|
||||
str.AppendLine("<td>" + div_circle + label + span_level + "</td>");
|
||||
}
|
||||
}
|
||||
else if ((int)q.QuestionType == 8 || (int)q.QuestionType == 9 || ((int)q.QuestionType == 15 && q.SubType == 6) || ((int)q.QuestionType == 15 && q.SubType == 9))//DropDown、List
|
||||
{
|
||||
if (q.MultipleSelect)
|
||||
{
|
||||
if (a.SelectedItems != null && a.SelectedItems.Count > 0)
|
||||
{
|
||||
StringBuilder str1 = new StringBuilder();
|
||||
str1.AppendLine("<table class='inptable'>");
|
||||
for (var j = 0; j < a.SelectedItems.Count; j++)
|
||||
{
|
||||
str1.AppendLine("<tr>");
|
||||
span_level = "<span style='float:right;padding-right:3px;'>" + ShowSeverityLevel(lang, (int)a.SelectedItems[j].SeverityLevel) + "</span>";
|
||||
var label = "<label style='margin-left:5px; '>" + (j + 1) + ". " + a.SelectedItems[j].Text + "</lable>";
|
||||
|
||||
var div_circle = "<div style=' width: 12px; height: 12px; border-radius: 6px; display: inline-block;'></div>";
|
||||
if (!string.IsNullOrEmpty(a.SelectedItems[j].BackgroundColor))
|
||||
{
|
||||
div_circle = "<div style=' width: 12px; height: 12px; border-radius: 6px; display: inline-block;background-color:" + a.SelectedItems[j].BackgroundColor + "'></div>";
|
||||
}
|
||||
str1.AppendLine("<td>" + div_circle + label + span_level + "</td>");
|
||||
str1.AppendLine("</tr>");
|
||||
}
|
||||
|
||||
str1.AppendLine("</table>");
|
||||
str.AppendLine("<td>" + str1.ToString() + "</td>");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (a.SelectedItems != null && a.SelectedItems.Count > 0)
|
||||
{
|
||||
span_level = "<span style='float:right;padding-right:3px;'>" + ShowSeverityLevel(lang, (int)a.SelectedItems[0].SeverityLevel) + "</span>";
|
||||
var label = "<label style='margin-left:5px; '>" + a.SelectedItems[0].Text + "</lable>";
|
||||
|
||||
var div_circle = "<div style=' width: 12px; height: 12px; border-radius: 6px; display: inline-block;'></div>";
|
||||
if (!string.IsNullOrEmpty(a.SelectedItems[0].BackgroundColor))
|
||||
{
|
||||
div_circle = "<div style=' width: 12px; height: 12px; border-radius: 6px; display: inline-block;background-color:" + a.SelectedItems[0].BackgroundColor + "'></div>";
|
||||
}
|
||||
|
||||
str.AppendLine("<td>" + div_circle + label + span_level + "</td>");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((int)q.QuestionType == 14)//Email (Drop Down)
|
||||
{
|
||||
if (a.SelectedItems != null && a.SelectedItems.Count > 0)
|
||||
{
|
||||
StringBuilder str1 = new StringBuilder();
|
||||
str1.AppendLine("<table class='inptable'>");
|
||||
for (var j = 0; j < a.SelectedItems.Count; j++)
|
||||
{
|
||||
str1.AppendLine("<tr>");
|
||||
var label = "<label>" + (j + 1) + ". " + a.SelectedItems[j].Text + "<" + a.SelectedItems[j].Value + "</lable>"; ;
|
||||
str1.AppendLine("<td>" + label + "</td>");
|
||||
str1.AppendLine("</tr>");
|
||||
}
|
||||
str1.AppendLine("</table>");
|
||||
str.AppendLine("<td>" + str1.ToString() + "</td>");
|
||||
}
|
||||
}
|
||||
else if ((int)q.QuestionType == 10 || ((int)q.QuestionType == 15 && q.SubType == 15))//Picture
|
||||
{
|
||||
StringBuilder str1 = new StringBuilder();
|
||||
str1.AppendLine("<div style='min-height:80px;overflow:auto;'>");
|
||||
if (report.Medias != null && report.Medias.Count > 0)
|
||||
{
|
||||
for (var j = 0; j < report.Medias.Count; j++)
|
||||
{
|
||||
var m = report.Medias[j];
|
||||
if (m.AnswerId.ToLower() == a.Id.ToLower())
|
||||
{
|
||||
string[] pictypes = new string[] { ".mp4", ".mov" };
|
||||
if (pictypes.Contains(m.FileType.ToLower()))
|
||||
{
|
||||
str1.AppendLine("<div class='media'><span class='video'></span></div>");
|
||||
}
|
||||
else
|
||||
{
|
||||
str1.AppendLine("<img class='media' src='" + m.ThumbnailUrl + "'></img>");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
str1.AppendLine("</div>");
|
||||
|
||||
str.AppendLine("<td>" + str1.ToString() + "</td>");
|
||||
}
|
||||
else
|
||||
str.AppendLine("<td></td>");
|
||||
}
|
||||
str.AppendLine("</tr>");
|
||||
str.AppendLine("");
|
||||
}
|
||||
else
|
||||
{
|
||||
str.AppendLine("<td></td>");
|
||||
str.AppendLine("</tr>");
|
||||
str.AppendLine("");
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
str.AppendLine("</table>");
|
||||
str.AppendLine("</div>");
|
||||
return str.ToString();
|
||||
}
|
||||
|
||||
private static string ConvertUnits(string u)
|
||||
{
|
||||
switch (u.ToLower())
|
||||
{
|
||||
case "mile":
|
||||
return "Mile(s)";
|
||||
case "kilometre":
|
||||
case "kilometer":
|
||||
return "Kilometer";
|
||||
case "percent":
|
||||
return "Percent";
|
||||
case "gallon":
|
||||
case "gal":
|
||||
return "Gallon";
|
||||
case "litre":
|
||||
return "Litre";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return u;
|
||||
}
|
||||
|
||||
private static string ShowSeverityLevel(string lang, int level)
|
||||
{
|
||||
var levertext = SystemParams.GetTextByKey(lang, "P_IPT_SEVERITYLEVEL_COLON", "Severity Level: ");
|
||||
if (level == 0)
|
||||
levertext = "";
|
||||
if (level == 1)
|
||||
levertext += SystemParams.GetTextByKey(lang, "P_IPT_SL_LOW", "Low");
|
||||
else if (level == 2)
|
||||
levertext += SystemParams.GetTextByKey(lang, "P_IPT_SL_MEDIUM", "Medium");
|
||||
else if (level == 3)
|
||||
levertext += SystemParams.GetTextByKey(lang, "P_IPT_SL_HIGH", "High");
|
||||
return levertext;
|
||||
}
|
||||
|
||||
public static string WorkorderAlertsFormart(long woid, string lang, string sessionid)
|
||||
{
|
||||
AlertItems items = GetWorkOrderAlerts(woid, sessionid);
|
||||
string EmailFormat = string.Empty;
|
||||
if (items != null)
|
||||
{
|
||||
if (items.DTCAlerts != null && items.DTCAlerts.Length > 0)
|
||||
EmailFormat += AlertsFormat(items.DTCAlerts, SystemParams.GetTextByKey(lang, "P_WO_DTCALERTS", "DTC Alerts"), lang);
|
||||
if (items.PMAlerts != null && items.PMAlerts.Length > 0)
|
||||
EmailFormat += AlertsFormat(items.PMAlerts, SystemParams.GetTextByKey(lang, "P_WO_PMALERTS", "PM Alerts"), lang);
|
||||
if (items.InspectAlerts != null && items.InspectAlerts.Length > 0)
|
||||
EmailFormat += AlertsFormat(items.InspectAlerts, SystemParams.GetTextByKey(lang, "P_WO_INSPECTALERTS", "Inspect Alerts"), lang);
|
||||
if (items.OilAlerts != null && items.OilAlerts.Length > 0)
|
||||
EmailFormat += AlertsFormat(items.OilAlerts, SystemParams.GetTextByKey(lang, "P_WO_OILALERTS", "Oil Alerts"), lang);
|
||||
}
|
||||
return EmailFormat;
|
||||
}
|
||||
|
||||
public static string AlertsFormat(AlertInfo[] alerts, string type, string lang)
|
||||
{
|
||||
string AlertsFormat = "<table style=\"border:solid 1px #e1dbdb;border-collapse: collapse;margin-bottom:36px;\"><tr>";
|
||||
AlertsFormat += "<td colspan=\"6\"><span style=\"font-weight:700;\">{0}</span></td></tr>";
|
||||
|
||||
AlertsFormat += "<tr style=\"height:30px; background-color:#f1f1f1;\">";
|
||||
AlertsFormat += "<td style=\"border:1px solid #e1dbdb;\">" + SystemParams.GetTextByKey(lang, "P_WO_HOURS", "Hours") + "</td>";
|
||||
AlertsFormat += "<td style=\"border:1px solid #e1dbdb;\">" + SystemParams.GetTextByKey(lang, "P_WO_ALERTTYPE", "Alert Type") + "</td>";
|
||||
AlertsFormat += "<td style=\"border:1px solid #e1dbdb;\">" + SystemParams.GetTextByKey(lang, "P_WO_DESCRIPTION", "Description") + "</td>";
|
||||
if (string.Compare(type, "PM Alerts", true) == 0)
|
||||
AlertsFormat += "<td style=\"border:1px solid #e1dbdb;\">" + SystemParams.GetTextByKey(lang, "P_WO_SERVICEDESCRIPTION", "Service Description") + "</td>";
|
||||
AlertsFormat += "<td style=\"border:1px solid #e1dbdb;\">" + SystemParams.GetTextByKey(lang, "P_WO_COUNT", "Count") + "</td>";
|
||||
AlertsFormat += "<td style=\"border:1px solid #e1dbdb;\">" + SystemParams.GetTextByKey(lang, "P_WO_LATESTDATETIME", "Latest DateTime") + "</td>";
|
||||
AlertsFormat += "</tr>";
|
||||
AlertsFormat += "{1}";//Alert Information
|
||||
AlertsFormat += "</table>";
|
||||
|
||||
if (alerts != null)
|
||||
{
|
||||
string tr_data = string.Empty;
|
||||
foreach (AlertInfo item in alerts)
|
||||
{
|
||||
tr_data += "<tr>";
|
||||
tr_data += "<td style=\"border:1px solid #e1dbdb;\">" + item.EngineHours + "</td>";
|
||||
tr_data += "<td style=\"border:1px solid #e1dbdb;\">" + item.AlertType + "</td>";
|
||||
tr_data += "<td style=\"border:1px solid #e1dbdb;\">" + item.Description + "</td>";
|
||||
if (string.Compare(type, "PM Alerts", true) == 0)
|
||||
tr_data += "<td style=\"border:1px solid #e1dbdb;\">" + item.ServiceDescription + "</td>";
|
||||
tr_data += "<td style=\"border:1px solid #e1dbdb;\">" + item.AlertCount + "</td>";
|
||||
tr_data += "<td style=\"border:1px solid #e1dbdb;\">" + item.AlertLocalTimeStr + "</td>";
|
||||
tr_data += "</tr>";
|
||||
}
|
||||
|
||||
return string.Format(AlertsFormat, type, tr_data);
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static AlertItems GetWorkOrderAlerts(long workorderid, string sessionid)
|
||||
{
|
||||
AssetAlertItem[] alerts = FleetServiceClientHelper.CreateClient<WorkOrderProvider>(sessionid).GetWorkOrderAlerts(SystemParams.CompanyID, workorderid);
|
||||
|
||||
if (alerts != null)
|
||||
{
|
||||
AlertItems items = new AlertItems();
|
||||
var dtcalerts = new List<AlertInfo>();
|
||||
var pmaalerts = new List<AlertInfo>();
|
||||
var inspectalerts = new List<AlertInfo>();
|
||||
var oilalerts = new List<AlertInfo>();
|
||||
Dictionary<string, List<AlertInfo>> pmalertdic = new Dictionary<string, List<AlertInfo>>();
|
||||
foreach (AssetAlertItem alertitem in alerts.OrderByDescending(ai => ai.AlertTime))
|
||||
{
|
||||
List<AlertInfo> tempList = null;
|
||||
if (alertitem.Category == AssetAlertCategory.PMAlert)
|
||||
tempList = pmaalerts;
|
||||
else if (alertitem.Category == AssetAlertCategory.InspectAlert)
|
||||
tempList = inspectalerts;
|
||||
else if (alertitem.Category == AssetAlertCategory.OilSampleAlert)
|
||||
tempList = oilalerts;
|
||||
else
|
||||
tempList = dtcalerts;
|
||||
|
||||
var existalert = tempList.FirstOrDefault((ai) => ai.Description == alertitem.Description);
|
||||
if (existalert != null)
|
||||
{
|
||||
existalert.AlertCount++;
|
||||
if (existalert.RepeatedAlerts == null)
|
||||
existalert.RepeatedAlerts = new List<long>();
|
||||
existalert.RepeatedAlerts.Add(alertitem.ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
var a = ConvertAlert(alertitem);
|
||||
a.AlertCount = 1;
|
||||
tempList.Add(a);
|
||||
|
||||
if (alertitem.Category == AssetAlertCategory.PMAlert)
|
||||
{
|
||||
if (!pmalertdic.ContainsKey(a.ScheduleID))
|
||||
pmalertdic[a.ScheduleID] = new List<AlertInfo>();
|
||||
pmalertdic[a.ScheduleID].Add(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
items.DTCAlerts = dtcalerts.ToArray();
|
||||
items.PMAlerts = pmaalerts.ToArray();
|
||||
items.InspectAlerts = inspectalerts.ToArray();
|
||||
items.OilAlerts = oilalerts.ToArray();
|
||||
items.AllExpectedCost = 0;
|
||||
|
||||
foreach (var dic in pmalertdic)
|
||||
{
|
||||
items.AllExpectedCost += dic.Value.Where(m => !m.Recurring).Sum(m => m.ExpectedCost);
|
||||
|
||||
int minPriority = dic.Value.Select(m => m.Priority).Min();
|
||||
var recalerts = dic.Value.Where(m => m.Priority == minPriority && m.Recurring && m.ExpectedCost > 0);
|
||||
if (recalerts != null && recalerts.Count() > 0)
|
||||
items.AllExpectedCost += recalerts.Sum(m => m.ExpectedCost);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private static AlertInfo ConvertAlert(AssetAlertItem alertitem)
|
||||
{
|
||||
AlertInfo ai = new AlertInfo();
|
||||
ai.AlertID = alertitem.ID;
|
||||
ai.MachineID = alertitem.AssetID;
|
||||
ai.AlertType = alertitem.AlertType;
|
||||
ai.Description = alertitem.Description;
|
||||
ai.Description = ai.FormatDescription(ai.Description);
|
||||
ai.AlertTime_UTC = alertitem.AlertTime;
|
||||
ai.AlertLocalTime = alertitem.AlertLocalTime;
|
||||
ai.EngineHours = alertitem.EngineHours;
|
||||
ai.ServiceDescription = alertitem.ServiceDescription;
|
||||
ai.ScheduleID = alertitem.ScheduleID;
|
||||
ai.IntervalID = alertitem.IntervalID;
|
||||
ai.Recurring = alertitem.Recurring;
|
||||
ai.Priority = alertitem.Priority;
|
||||
ai.ExpectedCost = alertitem.ExpectedCost;
|
||||
|
||||
return ai;
|
||||
}
|
||||
|
||||
public static (string body, KeyValuePair<string, byte[]>[]) GetSurveyReportEmail(SurveyReportInfo report)
|
||||
{
|
||||
var list = new List<KeyValuePair<string, byte[]>>();
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("<div>");
|
||||
sb.AppendLine($"<div style=\"font-size: 24px; font-weight: bold; text-align: center\">{HttpUtility.HtmlEncode(report.TemplateName)}</div>");
|
||||
sb.AppendLine($"<div style=\"font-size: 16px; font-weight: bold; text-align: center\">There are {report.SurveyCount} survey(s) in total.</div>");
|
||||
sb.AppendLine("<br/><br/>");
|
||||
int count = 0;
|
||||
foreach (var q in report.Questions)
|
||||
{
|
||||
string imgid;
|
||||
if (q.QuestionType == SurveyQuestionTypes.Choose)
|
||||
{
|
||||
sb.AppendLine($"<div style=\"font-size: 24px; font-weight: bold; padding-left: 10px\">{HttpUtility.HtmlEncode(q.Title)}</div>");
|
||||
imgid = "img" + (++count).ToString("000");
|
||||
sb.AppendLine($"<img src=\"cid:{imgid}\"/>");
|
||||
var chooseBarDrawer = new ColumnChartDrawer
|
||||
{
|
||||
Data = new ChartData
|
||||
{
|
||||
XAxis = q.Values.Select(v => new XValue { Label = v.DisplayText }).ToArray(),
|
||||
XInclinedValue = -45,
|
||||
Series = new[]
|
||||
{
|
||||
new DataSeries
|
||||
{
|
||||
SeriesType = SeriesType.Column,
|
||||
Color = Color.FromArgb(0x43, 0x86, 0xd8),
|
||||
DataPoints = q.Values.Select(v => new DataPoint { Y = v.Count }).ToArray()
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var bitmap = new Bitmap(800, 300);
|
||||
var result = chooseBarDrawer.DrawChart(bitmap);
|
||||
var ms = new MemoryStream();
|
||||
bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
|
||||
ms.Flush();
|
||||
list.Add(new KeyValuePair<string, byte[]>(imgid, ms.ToArray()));
|
||||
|
||||
imgid = "img" + (++count).ToString("000");
|
||||
sb.AppendLine($"<img src=\"cid:{imgid}\"/>");
|
||||
var pieDrawer = new PieChartDrawer
|
||||
{
|
||||
Data = new ChartData
|
||||
{
|
||||
Series = new[]
|
||||
{
|
||||
new DataSeries
|
||||
{
|
||||
SeriesType = SeriesType.Pie,
|
||||
DataPoints = q.Values.Select(v => new DataPoint { Name = v.DisplayText, Y = v.Count, DisplayValue = v.Count.ToString() }).ToArray()
|
||||
}
|
||||
},
|
||||
ShowLegend = true
|
||||
}
|
||||
};
|
||||
bitmap = new Bitmap(800, 300);
|
||||
result = pieDrawer.DrawChart(bitmap);
|
||||
ms = new MemoryStream();
|
||||
bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
|
||||
ms.Flush();
|
||||
list.Add(new KeyValuePair<string, byte[]>(imgid, ms.ToArray()));
|
||||
}
|
||||
else if (q.QuestionType == SurveyQuestionTypes.YesOrNo)
|
||||
{
|
||||
sb.AppendLine($"<div style=\"font-size: 24px; font-weight: bold; padding-left: 10px\">{HttpUtility.HtmlEncode(q.Title)}</div>");
|
||||
imgid = "img" + (++count).ToString("000");
|
||||
sb.AppendLine($"<img src=\"cid:{imgid}\"/>");
|
||||
var barDrawer = new BarChartDrawer
|
||||
{
|
||||
Data = new ChartData
|
||||
{
|
||||
XAxis = new[]
|
||||
{
|
||||
new XValue
|
||||
{
|
||||
Label = string.Empty
|
||||
}
|
||||
},
|
||||
Series = new[]
|
||||
{
|
||||
new DataSeries
|
||||
{
|
||||
Name = q.Values[0].DisplayText,
|
||||
SeriesType = SeriesType.Bar,
|
||||
DataPoints = new[]
|
||||
{
|
||||
new DataPoint { Y = q.Values[0].Count }
|
||||
}
|
||||
},
|
||||
new DataSeries
|
||||
{
|
||||
Name = q.Values[1].DisplayText,
|
||||
SeriesType = SeriesType.Bar,
|
||||
DataPoints = new[]
|
||||
{
|
||||
new DataPoint { Y = q.Values[1].Count }
|
||||
}
|
||||
}
|
||||
},
|
||||
ShowLegend = true
|
||||
}
|
||||
};
|
||||
var bitmap = new Bitmap(700, 220);
|
||||
var result = barDrawer.DrawChart(bitmap);
|
||||
var ms = new MemoryStream();
|
||||
bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
|
||||
ms.Flush();
|
||||
list.Add(new KeyValuePair<string, byte[]>(imgid, ms.ToArray()));
|
||||
}
|
||||
else if (q.QuestionType == SurveyQuestionTypes.Score)
|
||||
{
|
||||
sb.AppendLine($"<div style=\"font-size: 24px; font-weight: bold; padding-left: 10px\">{HttpUtility.HtmlEncode(q.Title)}</div>");
|
||||
imgid = "img" + (++count).ToString("000");
|
||||
sb.AppendLine($"<img src=\"cid:{imgid}\"/>");
|
||||
var chooseBarDrawer = new ColumnChartDrawer
|
||||
{
|
||||
Data = new ChartData
|
||||
{
|
||||
XAxis = q.Values.Select(v => new XValue { Label = v.DisplayText }).ToArray(),
|
||||
XInclinedValue = -45,
|
||||
Series = new[]
|
||||
{
|
||||
new DataSeries
|
||||
{
|
||||
SeriesType = SeriesType.Column,
|
||||
Color = Color.FromArgb(0x43, 0x86, 0xd8),
|
||||
DataPoints = q.Values.Select(v => new DataPoint { Y = v.Count }).ToArray()
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var bitmap = new Bitmap(800, 300);
|
||||
var result = chooseBarDrawer.DrawChart(bitmap);
|
||||
var ms = new MemoryStream();
|
||||
bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
|
||||
ms.Flush();
|
||||
list.Add(new KeyValuePair<string, byte[]>(imgid, ms.ToArray()));
|
||||
|
||||
imgid = "img" + (++count).ToString("000");
|
||||
sb.AppendLine($"<img src=\"cid:{imgid}\"/>");
|
||||
var pieDrawer = new PieChartDrawer
|
||||
{
|
||||
Data = new ChartData
|
||||
{
|
||||
Series = new[]
|
||||
{
|
||||
new DataSeries
|
||||
{
|
||||
SeriesType = SeriesType.Pie,
|
||||
DataPoints = q.Values.Select(v => new DataPoint { Name = v.DisplayText, Y = v.Count, DisplayValue = v.Count.ToString() }).ToArray()
|
||||
}
|
||||
},
|
||||
ShowLegend = true
|
||||
}
|
||||
};
|
||||
bitmap = new Bitmap(800, 300);
|
||||
result = pieDrawer.DrawChart(bitmap);
|
||||
ms = new MemoryStream();
|
||||
bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
|
||||
ms.Flush();
|
||||
list.Add(new KeyValuePair<string, byte[]>(imgid, ms.ToArray()));
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
sb.AppendLine("<br/><br/>");
|
||||
}
|
||||
sb.AppendLine("</div>");
|
||||
|
||||
return (sb.ToString(), list.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
public class AlertItems
|
||||
{
|
||||
public AlertInfo[] DTCAlerts { get; set; }
|
||||
public AlertInfo[] PMAlerts { get; set; }
|
||||
public AlertInfo[] InspectAlerts { get; set; }
|
||||
public AlertInfo[] OilAlerts { get; set; }
|
||||
public double AllExpectedCost { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,14 @@ using System.Text;
|
||||
using System.Web;
|
||||
using Foresight.Data;
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using IronIntel.Contractor.Machines;
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using Foresight.Fleet.Services.MapView;
|
||||
using Foresight.Fleet.Services.JobSite;
|
||||
using Foresight.Fleet.Services.Device;
|
||||
using Foresight.Fleet.Services.User;
|
||||
using System.Threading;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
|
||||
namespace IronIntel.Contractor.MapView
|
||||
{
|
||||
@ -20,7 +23,7 @@ namespace IronIntel.Contractor.MapView
|
||||
/// 根据Contractorid获取机器列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static AssetMapViewPinItem[] GetAssets(string sessionid, string companyid, string useriid, string filtertext, int onroad, MachineAlertViewQueryParameter param, bool IncludeNoLocation)
|
||||
public static AssetMapViewPinItem[] GetAssets(string sessionid, string companyid, string useriid, string filtertext, int onroad, MachineAlertViewQueryParameter param, bool IncludeNoLocation, int attachment)
|
||||
{
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
@ -38,23 +41,99 @@ namespace IronIntel.Contractor.MapView
|
||||
}
|
||||
|
||||
var client = FleetServiceClientHelper.CreateClient<MapViewQueryClient>(companyid, sessionid);
|
||||
AssetMapViewPinItem[] assets = client.GetAssets(companyid, useriid, qp);
|
||||
return assets;
|
||||
//List<AssetViewItem> result = new List<AssetViewItem>();
|
||||
//foreach (var a in assets)
|
||||
//{
|
||||
// AssetViewItem avi = new AssetViewItem();
|
||||
// Helper.CloneProperty(avi, a);
|
||||
// result.Add(avi);
|
||||
//}
|
||||
//return result.ToArray();
|
||||
AssetMapViewPinItem[] assets = client.GetAssets(companyid, useriid, qp, attachment);
|
||||
List<AssetMapViewPinItemClient> result = new List<AssetMapViewPinItemClient>();
|
||||
foreach (var a in assets)
|
||||
{
|
||||
AssetMapViewPinItemClient avi = new AssetMapViewPinItemClient();
|
||||
Helper.CloneProperty(avi, a);
|
||||
result.Add(avi);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取Dealer站点下多个Contractor机器列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static AssetMapViewPinItem[] GetDealerAssets(string sessionid, string companyids, string useriid, string filtertext, int onroad, MachineAlertViewQueryParameter param, bool IncludeNoLocation, int attachment)
|
||||
{
|
||||
string[] cids = null;
|
||||
if (!string.IsNullOrEmpty(companyids))
|
||||
cids = companyids.Split(',');
|
||||
|
||||
var contractors = SystemParams.GetContractors();
|
||||
if (cids == null || cids.Length == 0)
|
||||
cids = contractors.Select(c => c.ID).ToArray();
|
||||
|
||||
if (cids == null || cids.Length == 0)
|
||||
return new AssetMapViewPinItem[0];
|
||||
|
||||
int requestCount = 0;
|
||||
Exception lasterror = null;
|
||||
List<AssetMapViewPinItem> results = new List<AssetMapViewPinItem>();
|
||||
foreach (var cid in cids)
|
||||
{
|
||||
requestCount++;
|
||||
Thread th = new Thread((object state) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var assets = GetAssets(sessionid, cid, useriid, filtertext, onroad, param, IncludeNoLocation, attachment);
|
||||
lock (results)
|
||||
{
|
||||
foreach (var a in assets)
|
||||
{
|
||||
AssetMapViewPinItemClient asset = new AssetMapViewPinItemClient();
|
||||
Helper.CloneProperty(asset, a);
|
||||
var c = contractors.FirstOrDefault(t => t.ID.Equals(cid, StringComparison.OrdinalIgnoreCase));
|
||||
if (c != null)
|
||||
{
|
||||
asset.CompanyID = c.ID;
|
||||
asset.CompanyName = c.Name;
|
||||
}
|
||||
results.Add(asset);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
lasterror = ex;
|
||||
}
|
||||
requestCount--;
|
||||
});
|
||||
|
||||
th.Start();
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
if (requestCount == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (lasterror != null)
|
||||
{
|
||||
throw lasterror;
|
||||
}
|
||||
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
public static AssetDetailViewItem GetAssetDetailItem(string sessionid, string companyid, long machineid, string datasource = null)
|
||||
{
|
||||
var client = FleetServiceClientHelper.CreateClient<AssetQueryClient>(companyid, sessionid);
|
||||
var locclient = FleetServiceClientHelper.CreateClient<AssetLocationQueryClient>(companyid, sessionid);
|
||||
var asset = client.GetAssetDetailInfo(companyid, machineid);
|
||||
var companyinfo = SystemParams.GetCustomerInfo(companyid);
|
||||
AssetDetailViewItem mi = new AssetDetailViewItem();
|
||||
if (companyinfo != null)
|
||||
{
|
||||
mi.CompanyID = companyinfo.ID;
|
||||
mi.CompanyName = companyinfo.Name;
|
||||
}
|
||||
mi.ID = asset.ID;
|
||||
mi.Name = asset.Name;
|
||||
mi.Name2 = asset.Name2;
|
||||
@ -67,6 +146,7 @@ namespace IronIntel.Contractor.MapView
|
||||
mi.IconUrl = asset.MapViewIconUrl;
|
||||
mi.AssetIconUrl = asset.AssetIconUrl;
|
||||
mi.Description = asset.Description;
|
||||
mi.DisplayName = asset.DisplayName;
|
||||
|
||||
if (asset.CurrentHours != null)
|
||||
{
|
||||
@ -79,7 +159,7 @@ namespace IronIntel.Contractor.MapView
|
||||
if (!string.IsNullOrWhiteSpace(datasource)
|
||||
&& (loc == null || string.Compare(datasource, loc.DataSource, true) != 0))
|
||||
{
|
||||
AssetLocationInfo[] locs = client.GetAssetCurrentLocation(companyid, machineid);
|
||||
AssetLocationInfo[] locs = locclient.GetAssetCurrentLocation(companyid, machineid);
|
||||
var tempLoc = locs.FirstOrDefault(l => string.Compare(datasource, l.DataSource, true) != 0);
|
||||
if (tempLoc != null)
|
||||
{
|
||||
@ -91,6 +171,8 @@ namespace IronIntel.Contractor.MapView
|
||||
mi.Location.PostedSpeed = tempLoc.PostedSpeedLimit;
|
||||
mi.Location.PostedSpeedUnit = tempLoc.SpeedLimitUnits;
|
||||
mi.Location.Street = tempLoc.Street;
|
||||
|
||||
//MapView页面 不会走此分支,所以暂时不用对DataSource/SubSource/EventType/MsgUID赋值
|
||||
}
|
||||
}
|
||||
else if (loc != null)
|
||||
@ -103,8 +185,19 @@ namespace IronIntel.Contractor.MapView
|
||||
mi.Location.PostedSpeed = loc.PostedSpeedLimit;
|
||||
mi.Location.PostedSpeedUnit = loc.SpeedLimitUnits;
|
||||
mi.Location.Street = loc.Street;
|
||||
|
||||
//当前位置没有LogID,通过DataSource/SubSource/EventType/MsgUID 来进行RequestVideo
|
||||
mi.Location.DataSource = loc.DataSource;
|
||||
mi.Location.SubSource = loc.SubSource;
|
||||
mi.Location.EventType = loc.EventType;
|
||||
mi.Location.MsgUID = loc.MsgUID;
|
||||
}
|
||||
|
||||
var assetDevices = client.GetPairedDevices(companyid, machineid);
|
||||
var device = assetDevices.FirstOrDefault(d => d.Source.Equals(Foresight.Fleet.Services.Device.DeviceInfo.DEVICESOURCE_SMARTWITNESS, StringComparison.OrdinalIgnoreCase)
|
||||
&& d.Status == 1);
|
||||
mi.Location.FromSmartWitness = device == null ? false : true;//11342 通过机器当前是否绑定SmartWitness来判断
|
||||
|
||||
if (asset.CurrentOdometer != null)
|
||||
{
|
||||
mi.Odometer = asset.CurrentOdometer.Corrected;
|
||||
@ -131,8 +224,75 @@ namespace IronIntel.Contractor.MapView
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public static AssetGroupViewItem[] GetDealerAssetGroups(string sessionid, string companyids, string useriid, string searchtext)
|
||||
{
|
||||
string[] cids = null;
|
||||
if (!string.IsNullOrEmpty(companyids))
|
||||
cids = companyids.Split(',');
|
||||
|
||||
var contractors = SystemParams.GetContractors();
|
||||
if (cids == null || cids.Length == 0)
|
||||
cids = contractors.Select(c => c.ID).ToArray();
|
||||
|
||||
if (cids == null || cids.Length == 0)
|
||||
return new AssetGroupViewItem[0];
|
||||
|
||||
int requestCount = 0;
|
||||
Exception lasterror = null;
|
||||
List<AssetGroupViewItem> results = new List<AssetGroupViewItem>();
|
||||
foreach (var cid in cids)
|
||||
{
|
||||
requestCount++;
|
||||
Thread th = new Thread((object state) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var ags = GetAssetGroups(sessionid, cid, useriid, searchtext);
|
||||
lock (results)
|
||||
{
|
||||
foreach (var ag in ags)
|
||||
{
|
||||
var c = contractors.FirstOrDefault(t => t.ID.Equals(cid, StringComparison.OrdinalIgnoreCase));
|
||||
if (c != null)
|
||||
{
|
||||
ag.CompanyID = c.ID;
|
||||
ag.CompanyName = c.Name;
|
||||
}
|
||||
}
|
||||
results.AddRange(ags);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
lasterror = ex;
|
||||
}
|
||||
requestCount--;
|
||||
});
|
||||
|
||||
th.Start();
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
if (requestCount == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (lasterror != null)
|
||||
{
|
||||
throw lasterror;
|
||||
}
|
||||
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
public static JobSiteViewItem[] GetJobsites(string sessionid, string companyid, string useriid, string searchtext)
|
||||
{
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
|
||||
var client = FleetServiceClientHelper.CreateClient<MapViewQueryClient>(companyid, sessionid);
|
||||
MapViewJobSiteInfo[] jss = client.GetAvailableJobSites(companyid, useriid, searchtext, false);
|
||||
|
||||
@ -146,8 +306,16 @@ namespace IronIntel.Contractor.MapView
|
||||
ajs.Longitude = js.Longitude;
|
||||
ajs.Radius = js.Radius;
|
||||
ajs.Radius_UOM = js.RadiusUOM;
|
||||
if (js.StartDate != null)
|
||||
ajs.StartDate = js.StartDate.Value;
|
||||
if (js.EndDate != null)
|
||||
ajs.EndDate = js.EndDate.Value;
|
||||
if (js.ProjectedEndDate != null)
|
||||
ajs.ProjectedEndDate = js.ProjectedEndDate.Value;
|
||||
|
||||
//ajs.Assets = js.Assets;
|
||||
|
||||
ajs.ColorString = js.Color;
|
||||
System.Drawing.Color color = System.Drawing.Color.Orange;
|
||||
try
|
||||
{
|
||||
@ -167,58 +335,90 @@ namespace IronIntel.Contractor.MapView
|
||||
ajs.Polygon = temp.ToArray();
|
||||
}
|
||||
ajs.Notes = js.Notes;
|
||||
ajs.Code = js.Code;
|
||||
ajs.RegionId = js.ReginId;
|
||||
ajs.Region = js.Region;
|
||||
ajs.Number = js.Number;
|
||||
ajs.Foreman = js.Foreman;
|
||||
ajs.Manager = js.Manager;
|
||||
ajs.Phone = js.Phone;
|
||||
ajs.Email = js.Email;
|
||||
ajs.Group = js.Group;
|
||||
ajs.Address1 = js.Address1;
|
||||
ajs.Address2 = js.Address2;
|
||||
ajs.City = js.City;
|
||||
ajs.State = js.State;
|
||||
ajs.Zip = js.Zip;
|
||||
ajs.County = js.County;
|
||||
ajs.BaseOnMachineID = js.BaseonMachineID;
|
||||
ajs.Types = new string[] { js.JobSiteTypes };
|
||||
list.Add(ajs);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
private static Dictionary<string, List<MachineViewItem>> GetGroupAssets(string useriid, FISqlConnection db = null)
|
||||
public static JobSiteViewItem[] GetDealerJobsites(string sessionid, string companyids, string useriid, string searchtext)
|
||||
{
|
||||
const string SQL = @"if(select count(1) from USERMACHINEGROUPMAP where USERIID={0})=0
|
||||
select a.MACHINEID,a.GROUPID,b.VIN,b.MACHINENAME,b.MACHINENAME2 from MACHINEGROUPMAP a,MACHINES b where a.MACHINEID=b.MACHINEID and ISNULL(b.HIDE,0)=0
|
||||
else
|
||||
select a.MACHINEID,a.GROUPID,b.VIN,b.MACHINENAME,b.MACHINENAME2 from MACHINEGROUPMAP a,MACHINES b where a.MACHINEID=b.MACHINEID and ISNULL(b.HIDE,0)=0
|
||||
and b.MACHINEID in (select distinct MACHINEID from MACHINEGROUPMAP
|
||||
where GROUPID in (select GROUPID from USERMACHINEGROUPMAP where USERIID={0}))";
|
||||
string[] cids = null;
|
||||
if (!string.IsNullOrEmpty(companyids))
|
||||
cids = companyids.Split(',');
|
||||
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
DataTable dt = null;
|
||||
dt = db.GetDataTableBySQL(SQL, useriid);
|
||||
var contractors = SystemParams.GetContractors();
|
||||
if (cids == null || cids.Length == 0)
|
||||
cids = contractors.Select(c => c.ID).ToArray();
|
||||
|
||||
Dictionary<string, List<MachineViewItem>> result = new Dictionary<string, List<MachineViewItem>>(StringComparer.OrdinalIgnoreCase);
|
||||
if (dt.Rows.Count == 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
MachineViewItem mi = new MachineViewItem();
|
||||
mi.ID = FIDbAccess.GetFieldInt64(dr["MACHINEID"], 0);
|
||||
mi.Name = FIDbAccess.GetFieldString(dr["MACHINENAME"], string.Empty);
|
||||
mi.Name2 = FIDbAccess.GetFieldString(dr["MACHINENAME2"], string.Empty);
|
||||
mi.VIN = FIDbAccess.GetFieldString(dr["VIN"], string.Empty);
|
||||
string groupID = FIDbAccess.GetFieldString(dr["GROUPID"], string.Empty);
|
||||
if (!result.ContainsKey(groupID))
|
||||
result[groupID] = new List<MachineViewItem>();
|
||||
result[groupID].Add(mi);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
if (cids == null || cids.Length == 0)
|
||||
return new JobSiteViewItem[0];
|
||||
|
||||
private static void ConvertSpeedUnitToMile(LocationViewItem loc)
|
||||
{
|
||||
if (loc == null) return;
|
||||
if (loc.Speed >= 0 && loc.SpeedUnit.StartsWith("K", StringComparison.OrdinalIgnoreCase))
|
||||
int requestCount = 0;
|
||||
Exception lasterror = null;
|
||||
List<JobSiteViewItem> results = new List<JobSiteViewItem>();
|
||||
foreach (var cid in cids)
|
||||
{
|
||||
loc.Speed = loc.Speed * 0.6213712;
|
||||
loc.SpeedUnit = "mi/h";
|
||||
requestCount++;
|
||||
Thread th = new Thread((object state) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var jss = GetJobsites(sessionid, cid, useriid, searchtext);
|
||||
lock (results)
|
||||
{
|
||||
foreach (var js in jss)
|
||||
{
|
||||
var c = contractors.FirstOrDefault(t => t.ID.Equals(cid, StringComparison.OrdinalIgnoreCase));
|
||||
if (c != null)
|
||||
{
|
||||
js.CompanyID = c.ID;
|
||||
js.CompanyName = c.Name;
|
||||
}
|
||||
}
|
||||
results.AddRange(jss);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
lasterror = ex;
|
||||
}
|
||||
requestCount--;
|
||||
});
|
||||
|
||||
th.Start();
|
||||
}
|
||||
if (loc.PostedSpeed > 0 && loc.PostedSpeedUnit.StartsWith("K", StringComparison.OrdinalIgnoreCase))
|
||||
|
||||
while (true)
|
||||
{
|
||||
loc.PostedSpeed = loc.PostedSpeed * 0.6213712;
|
||||
loc.PostedSpeedUnit = "mi/h";
|
||||
Thread.Sleep(10);
|
||||
if (requestCount == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (lasterror != null)
|
||||
{
|
||||
throw lasterror;
|
||||
}
|
||||
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
public static AssetLocationHistoryViewItem GetMachineLocationHistory(string sessionid, string machineid, DateTime startTime, DateTime endTime, string companyid, bool notShow00loc, string datasource)
|
||||
@ -231,19 +431,24 @@ namespace IronIntel.Contractor.MapView
|
||||
//AssetViewItem ai = new AssetViewItem();
|
||||
//Helper.CloneProperty(ai, asset);
|
||||
|
||||
double timeOffset = SystemParams.GetHoursOffset();
|
||||
startTime = startTime.AddHours(-timeOffset);
|
||||
endTime = endTime.AddHours(-timeOffset);
|
||||
var assetDevices = client.GetPairedDevices(companyid, long.Parse(machineid));
|
||||
var device = assetDevices.FirstOrDefault(d => d.Source.Equals(Foresight.Fleet.Services.Device.DeviceInfo.DEVICESOURCE_SMARTWITNESS, StringComparison.OrdinalIgnoreCase)
|
||||
&& d.Status == 1);
|
||||
|
||||
AssetLocationInfo[] assetLocs = client.GetAssetBasicLocationHistory(companyid, long.Parse(machineid), startTime, endTime, datasource, "", !notShow00loc);
|
||||
var locclient = FleetServiceClientHelper.CreateClient<AssetLocationQueryClient>(companyid, sessionid);
|
||||
AssetLocationInfo[] assetLocs = locclient.GetAssetBasicLocationHistory(companyid, long.Parse(machineid), startTime, endTime, datasource, "", !notShow00loc);
|
||||
|
||||
List<LocationViewItem> ls = new List<LocationViewItem>();
|
||||
foreach (AssetLocationInfo assetLoc in assetLocs)
|
||||
{
|
||||
LocationViewItem li = new LocationViewItem();
|
||||
li.LogId = assetLoc.LogId;
|
||||
li.Latitude = assetLoc.Latitude;
|
||||
li.Longitude = assetLoc.Longitude;
|
||||
li.LocationTime = assetLoc.AsofTime.AddHours(timeOffset);
|
||||
li.LocationTime = assetLoc.AsofTimeLocal;
|
||||
|
||||
//历史位置通过Logid进行RequestVideo,无需对DataSource/SubSource/EventType/MsgUID 赋值
|
||||
li.LogId = assetLoc.LogId;
|
||||
|
||||
li.Speed = assetLoc.Speed;
|
||||
li.SpeedUnit = assetLoc.SpeedUnits;
|
||||
@ -252,10 +457,12 @@ namespace IronIntel.Contractor.MapView
|
||||
li.Street = assetLoc.Street;
|
||||
li.HarshDringEvent = assetLoc.HarshDringEvent;
|
||||
li.SpeedingBehavior = assetLoc.SpeedingBehavior;
|
||||
li.IconURL = GenerateLocationIconUrl(assetLoc);
|
||||
li.IconURL = GenerateLocationIconUrl(assetLoc, asset.OnRoad);
|
||||
li.SmartWitnessVideoUrl = assetLoc.SmartWitnessVideoUrl;
|
||||
|
||||
ConvertSpeedUnitToMile(li);
|
||||
li.FromSmartWitness = device == null ? false : true;//11342 通过机器当前是否绑定SmartWitness来判断
|
||||
|
||||
//ConvertSpeedUnitToMile(li);
|
||||
ls.Add(li);
|
||||
}
|
||||
AssetLocationHistoryViewItem al = new AssetLocationHistoryViewItem();
|
||||
@ -264,7 +471,7 @@ namespace IronIntel.Contractor.MapView
|
||||
return al;
|
||||
}
|
||||
|
||||
private static string GenerateLocationIconUrl(AssetLocationInfo loc)
|
||||
private static string GenerateLocationIconUrl(AssetLocationInfo loc, bool onRoad)
|
||||
{
|
||||
//http://iron.soft.rz/admin/machinetypeicon.ashx
|
||||
//http://iron.soft.rz/admin/machinemovingicon.ashx
|
||||
@ -272,26 +479,29 @@ namespace IronIntel.Contractor.MapView
|
||||
const string PARAM = "?tp={0}&bkcolor={1}&heading={2}";
|
||||
int tp = (int)HarshDrivingEvents.HardAccelerationEvent;
|
||||
string color = "";
|
||||
switch (loc.HarshDringEvent)
|
||||
if (onRoad)
|
||||
{
|
||||
case HarshDrivingEvents.None:
|
||||
break;
|
||||
case HarshDrivingEvents.HardAccelerationEvent:
|
||||
color = "#ff3f48cc";
|
||||
break;
|
||||
case HarshDrivingEvents.HardBrakeEvent:
|
||||
color = "#ff00a8f3";
|
||||
break;
|
||||
case HarshDrivingEvents.HardTurnEvent:
|
||||
color = "#fffff200";
|
||||
break;
|
||||
}
|
||||
if (string.IsNullOrEmpty(color))
|
||||
{
|
||||
if (loc.SpeedingBehavior == SpeedingBehaviors.MinorSpeeding)
|
||||
color = "#ffff7f27";
|
||||
else if (loc.SpeedingBehavior == SpeedingBehaviors.SevereSpeeding)
|
||||
color = "#ffec1c24";
|
||||
switch (loc.HarshDringEvent)
|
||||
{
|
||||
case HarshDrivingEvents.None:
|
||||
break;
|
||||
case HarshDrivingEvents.HardAccelerationEvent:
|
||||
color = "#ff3f48cc";
|
||||
break;
|
||||
case HarshDrivingEvents.HardBrakeEvent:
|
||||
color = "#ff00a8f3";
|
||||
break;
|
||||
case HarshDrivingEvents.HardTurnEvent:
|
||||
color = "#fffff200";
|
||||
break;
|
||||
}
|
||||
if (string.IsNullOrEmpty(color))
|
||||
{
|
||||
if (loc.SpeedingBehavior == SpeedingBehaviors.MinorSpeeding)
|
||||
color = "#ffff7f27";
|
||||
else if (loc.SpeedingBehavior == SpeedingBehaviors.SevereSpeeding)
|
||||
color = "#ffec1c24";
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(color))
|
||||
{
|
||||
@ -308,6 +518,10 @@ namespace IronIntel.Contractor.MapView
|
||||
return path + "?legend=StoppedOn";
|
||||
else if (loc.MoveStatus == AssetMoveStatus.StoppedOff)
|
||||
return path + "?legend=StoppedOff";
|
||||
else if (loc.MoveStatus == AssetMoveStatus.ConnectivityRecovery)
|
||||
return path + "?legend=CGAIN";
|
||||
else if (loc.MoveStatus == AssetMoveStatus.ConnectivityLose)
|
||||
return path + "?legend=CLOSS";
|
||||
}
|
||||
color = HttpUtility.UrlEncode(color);
|
||||
path = path + string.Format(PARAM, tp, color, loc.Heading);
|
||||
@ -359,7 +573,101 @@ namespace IronIntel.Contractor.MapView
|
||||
ls.Add(mi);
|
||||
}
|
||||
return ls.OrderBy((mal) => mal.Name).ToArray();
|
||||
}
|
||||
|
||||
public static MapAlertViewDefinitionItem[] GetDealerMapAlertViews(string sessionid, string companyids, string selectedViewID)
|
||||
{
|
||||
string[] cids = null;
|
||||
if (!string.IsNullOrEmpty(companyids))
|
||||
cids = companyids.Split(',');
|
||||
|
||||
var contractors = SystemParams.GetContractors();
|
||||
if (cids == null || cids.Length == 0)
|
||||
cids = contractors.Select(c => c.ID).ToArray();
|
||||
|
||||
if (cids == null || cids.Length == 0)
|
||||
return new MapAlertViewDefinitionItem[0];
|
||||
|
||||
int requestCount = 0;
|
||||
Exception lasterror = null;
|
||||
List<MapAlertViewDefinitionItem> results = new List<MapAlertViewDefinitionItem>();
|
||||
foreach (var cid in cids)
|
||||
{
|
||||
requestCount++;
|
||||
Thread th = new Thread((object state) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = FleetServiceClientHelper.CreateClient<MapViewQueryClient>(cid, sessionid);
|
||||
AlertViewMapItem[] views = client.GetAlertViewMapItems(cid);
|
||||
|
||||
AlertViewMapItem viewInfo = null;
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(selectedViewID))//获取View下使用的数据源信息
|
||||
viewInfo = client.GetAlertViewMapItem(cid, selectedViewID);
|
||||
}
|
||||
catch { }
|
||||
|
||||
string path = SystemParams.MachineTypeMapViewIconUrl;
|
||||
lock (results)
|
||||
{
|
||||
foreach (AlertViewMapItem ai in views)
|
||||
{
|
||||
MapAlertViewDefinitionItem mi = results.FirstOrDefault(r => r.ID.Equals(ai.ID, StringComparison.OrdinalIgnoreCase));
|
||||
if (mi == null)
|
||||
{
|
||||
mi = new MapAlertViewDefinitionItem();
|
||||
mi.ID = ai.ID;
|
||||
mi.Name = ai.Name;
|
||||
results.Add(mi);
|
||||
}
|
||||
|
||||
if (viewInfo != null && viewInfo.ID.Equals(mi.ID, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
mi.Layers = new MapAlertLayerDefinitionItem[viewInfo.Layers.Count];
|
||||
for (int i = 0; i < viewInfo.Layers.Count; i++)
|
||||
{
|
||||
var layer = viewInfo.Layers[i];
|
||||
mi.Layers[i] = new MapAlertLayerDefinitionItem();
|
||||
mi.Layers[i].ID = layer.LayerId;
|
||||
mi.Layers[i].Title = layer.Title;
|
||||
mi.Layers[i].LegendUrl = layer.LegendUrl;
|
||||
|
||||
if (layer.Pivots != null && layer.Pivots.Count > 0)
|
||||
mi.Layers[i].Pivots = ConvertPivotsDefine(layer.Pivots);
|
||||
}
|
||||
//mi.Layers = mi.Layers.OrderBy((l) => l.AlertLayerType).ToArray();
|
||||
var lookupData = ConvertLookupData(viewInfo.LookupDataSources);
|
||||
mi.LookupDataSources.AddRange(lookupData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
lasterror = ex;
|
||||
}
|
||||
requestCount--;
|
||||
});
|
||||
|
||||
th.Start();
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
if (requestCount == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (lasterror != null)
|
||||
{
|
||||
throw lasterror;
|
||||
}
|
||||
|
||||
return results.OrderBy(r => r.Name).ToArray();
|
||||
}
|
||||
|
||||
private static List<LookupDataSourceDataItem> ConvertLookupData(List<LookupDataSourceData> data)
|
||||
@ -402,26 +710,194 @@ namespace IronIntel.Contractor.MapView
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public static long[] GetNoGroupAssets(string companyid)
|
||||
/// <summary>
|
||||
/// 根据Contractorid获取Shape列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static ShapeFileItem[] GetShapes(string sessionid, string companyid, string filtertext)
|
||||
{
|
||||
const string SQL = @"select b.MACHINEID from MACHINES b where not exists(select 1 from MACHINEGROUPMAP a where a.MACHINEID=b.MACHINEID) and isnull(b.HIDE,0)=0";
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
|
||||
string dbs = SystemParams.GetCompanyDbString(companyid);
|
||||
FISqlConnection db = new FISqlConnection(dbs);
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
DataTable dt = db.GetDataTableBySQL(SQL);
|
||||
ShapeFileInfo[] files = FleetServiceClientHelper.CreateClient<ShapeFileProvider>(companyid, sessionid).GetShapeFileInfos(companyid, filtertext);
|
||||
if (files == null || files.Length == 0)
|
||||
return new ShapeFileItem[0];
|
||||
|
||||
List<long> result = new List<long>();
|
||||
if (dt.Rows.Count == 0)
|
||||
List<ShapeFileItem> list = new List<ShapeFileItem>();
|
||||
foreach (ShapeFileInfo fi in files)
|
||||
{
|
||||
return new long[0];
|
||||
ShapeFileItem item = new ShapeFileItem();
|
||||
Helper.CloneProperty(item, fi);
|
||||
list.Add(item);
|
||||
}
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
return list.OrderBy(m => m.Name).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取Dealer站点下多个Contractor机器列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static ShapeFileItem[] GetDealerShapes(string sessionid, string companyids, string filtertext)
|
||||
{
|
||||
string[] cids = null;
|
||||
if (!string.IsNullOrEmpty(companyids))
|
||||
cids = companyids.Split(',');
|
||||
|
||||
var contractors = SystemParams.GetContractors();
|
||||
if (cids == null || cids.Length == 0)
|
||||
cids = contractors.Select(c => c.ID).ToArray();
|
||||
|
||||
if (cids == null || cids.Length == 0)
|
||||
return new ShapeFileItem[0];
|
||||
|
||||
int requestCount = 0;
|
||||
Exception lasterror = null;
|
||||
List<ShapeFileItem> results = new List<ShapeFileItem>();
|
||||
foreach (var cid in cids)
|
||||
{
|
||||
result.Add(FIDbAccess.GetFieldInt64(dr["MACHINEID"], 0));
|
||||
requestCount++;
|
||||
Thread th = new Thread((object state) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
ShapeFileInfo[] files = FleetServiceClientHelper.CreateClient<ShapeFileProvider>(cid, sessionid).GetShapeFileInfos(cid, filtertext);
|
||||
lock (results)
|
||||
{
|
||||
foreach (ShapeFileInfo fi in files)
|
||||
{
|
||||
ShapeFileItem item = new ShapeFileItem();
|
||||
Helper.CloneProperty(item, fi);
|
||||
var c = contractors.FirstOrDefault(t => t.ID.Equals(cid, StringComparison.OrdinalIgnoreCase));
|
||||
if (c != null)
|
||||
{
|
||||
item.CompanyID = c.ID;
|
||||
item.CompanyName = c.Name;
|
||||
}
|
||||
results.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
lasterror = ex;
|
||||
}
|
||||
requestCount--;
|
||||
});
|
||||
|
||||
th.Start();
|
||||
}
|
||||
return result.ToArray();
|
||||
|
||||
while (true)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
if (requestCount == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (lasterror != null)
|
||||
{
|
||||
throw lasterror;
|
||||
}
|
||||
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据Contractorid获取Location列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static CompanyLocationViewItem[] GetLocations(string sessionid, string companyid)
|
||||
{
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
|
||||
var client = FleetServiceClientHelper.CreateClient<MapViewQueryClient>(companyid, sessionid);
|
||||
CustomerLocation[] locs = client.GetCompanyLocations(companyid);
|
||||
List<CompanyLocationViewItem> temps = new List<CompanyLocationViewItem>();
|
||||
foreach (var loc in locs)
|
||||
{
|
||||
CompanyLocationViewItem l = new CompanyLocationViewItem();
|
||||
l.ID = loc.ID;
|
||||
l.Latitude = loc.Latitude;
|
||||
l.Longitude = loc.Longitude;
|
||||
l.LocationName = loc.Name;
|
||||
l.Notes = loc.Notes;
|
||||
l.IconUrl = loc.IconUrl;
|
||||
temps.Add(l);
|
||||
}
|
||||
return temps.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取Dealer站点下多个Contractor机器列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static CompanyLocationViewItem[] GetDealerLocations(string sessionid, string companyids)
|
||||
{
|
||||
string[] cids = null;
|
||||
if (!string.IsNullOrEmpty(companyids))
|
||||
cids = companyids.Split(',');
|
||||
|
||||
var contractors = SystemParams.GetContractors();
|
||||
if (cids == null || cids.Length == 0)
|
||||
cids = contractors.Select(c => c.ID).ToArray();
|
||||
|
||||
if (cids == null || cids.Length == 0)
|
||||
return new CompanyLocationViewItem[0];
|
||||
|
||||
int requestCount = 0;
|
||||
Exception lasterror = null;
|
||||
List<CompanyLocationViewItem> results = new List<CompanyLocationViewItem>();
|
||||
foreach (var cid in cids)
|
||||
{
|
||||
requestCount++;
|
||||
Thread th = new Thread((object state) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = FleetServiceClientHelper.CreateClient<MapViewQueryClient>(cid, sessionid);
|
||||
CustomerLocation[] locs = client.GetCompanyLocations(cid);
|
||||
lock (results)
|
||||
{
|
||||
foreach (var loc in locs)
|
||||
{
|
||||
CompanyLocationViewItem l = new CompanyLocationViewItem();
|
||||
l.ID = loc.ID;
|
||||
l.Latitude = loc.Latitude;
|
||||
l.Longitude = loc.Longitude;
|
||||
l.LocationName = loc.Name;
|
||||
l.Notes = loc.Notes;
|
||||
l.IconUrl = loc.IconUrl;
|
||||
results.Add(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
lasterror = ex;
|
||||
}
|
||||
requestCount--;
|
||||
});
|
||||
|
||||
th.Start();
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
if (requestCount == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (lasterror != null)
|
||||
{
|
||||
throw lasterror;
|
||||
}
|
||||
|
||||
return results.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,9 @@ namespace IronIntel.Contractor.MapView
|
||||
{
|
||||
public class AssetDetailViewItem
|
||||
{
|
||||
public string CompanyID { get; set; } = "";
|
||||
public string CompanyName { get; set; } = "";
|
||||
|
||||
private double _EngineHours;
|
||||
public double EngineHours
|
||||
{
|
||||
@ -64,6 +67,7 @@ namespace IronIntel.Contractor.MapView
|
||||
return "";
|
||||
}
|
||||
}
|
||||
public string DisplayName { get; set; }
|
||||
}
|
||||
|
||||
public class AssetLocationHistoryViewItem
|
||||
|
@ -1,125 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Foresight.Data;
|
||||
|
||||
namespace IronIntel.Contractor.MapView
|
||||
{
|
||||
public class JobManagement
|
||||
{
|
||||
public static JobSiteViewItem[] GetJobSite(string searchtext, int onroad, string companyid)
|
||||
{
|
||||
const string sql_1 = @"select JOBSITEID,JOBSITENAME,LATITUDE,LONGITUDE ,RADIUS,RADUIS_UOM,CONTRACTORID,COLOR,NOTES,STARTDATE,ENDDATE,POLYGON from JOBSITES where ENDDATE is null or ENDDATE>getdate() order by JOBSITENAME";
|
||||
const string sql_2 = @"select JOBSITEID,JOBSITENAME,LATITUDE,LONGITUDE ,RADIUS,RADUIS_UOM,CONTRACTORID,COLOR,NOTES,STARTDATE,ENDDATE,POLYGON from JOBSITES where (ENDDATE is null or ENDDATE>getdate()) and JOBSITENAME like {0} order by JOBSITENAME";
|
||||
|
||||
FISqlConnection db = SystemParams.GetCompanyDbConnection(companyid);
|
||||
if (db == null)
|
||||
{
|
||||
return new JobSiteViewItem[0];
|
||||
}
|
||||
DataTable dt = null;
|
||||
if (string.IsNullOrWhiteSpace(searchtext))
|
||||
{
|
||||
dt = db.GetDataTableBySQL(sql_1);
|
||||
}
|
||||
else
|
||||
{
|
||||
dt = db.GetDataTableBySQL(sql_2, "%" + searchtext + "%");
|
||||
}
|
||||
List<JobSiteViewItem> list = new List<JobSiteViewItem>();
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
JobSiteViewItem js = new JobSiteViewItem();
|
||||
long JobSiteId = FIDbAccess.GetFieldInt(dr["JOBSITEID"], 0);
|
||||
js.ID = FIDbAccess.GetFieldInt(dr["JOBSITEID"], 0);
|
||||
js.Name = FIDbAccess.GetFieldString(dr["JOBSITENAME"], string.Empty);
|
||||
js.Latitude = FIDbAccess.GetFieldDouble(dr["LATITUDE"], 0);
|
||||
js.Longitude = FIDbAccess.GetFieldDouble(dr["LONGITUDE"], 0);
|
||||
js.Radius = FIDbAccess.GetFieldDouble(dr["RADIUS"], 0);
|
||||
js.Radius_UOM = FIDbAccess.GetFieldString(dr["RADUIS_UOM"], string.Empty);
|
||||
if (string.IsNullOrWhiteSpace(js.Radius_UOM))
|
||||
js.Radius_UOM = "Mile";
|
||||
js.ContractorID = FIDbAccess.GetFieldString(dr["CONTRACTORID"], string.Empty);
|
||||
js.ColorString = FIDbAccess.GetFieldString(dr["COLOR"], string.Empty);
|
||||
System.Drawing.Color color = System.Drawing.Color.Orange;
|
||||
try
|
||||
{
|
||||
color = System.Drawing.ColorTranslator.FromHtml(js.ColorString);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
js.Color = new IIColor() { Alpha = color.A, Red = color.R, Green = color.G, Blue = color.B };
|
||||
|
||||
js.Notes = FIDbAccess.GetFieldString(dr["NOTES"], string.Empty);
|
||||
js.StartDate = FIDbAccess.GetFieldDateTime(dr["STARTDATE"], DateTime.MinValue);
|
||||
js.EndDate = FIDbAccess.GetFieldDateTime(dr["ENDDATE"], DateTime.MinValue);
|
||||
string polygon = FIDbAccess.GetFieldString(dr["POLYGON"], string.Empty);
|
||||
js.Polygon = ConvertPolygonToPointItem(polygon);
|
||||
MachineViewItem[] msiary = GetJobSiteMachines(JobSiteId, onroad, db);
|
||||
if (msiary.Count() > 0)
|
||||
{
|
||||
js.Machines = msiary.OrderBy((m) => m.VIN).ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
js.Machines = null;
|
||||
}
|
||||
list.Add(js);
|
||||
}
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
private static MachineViewItem[] GetJobSiteMachines(long jobsiteid, int onroad, FISqlConnection db = null)
|
||||
{
|
||||
const string sql_m = @"select a.MACHINEID,b.VIN,b.MACHINENAME,b.MACHINENAME2,ONROAD from JOBSITEMACHINES a,MACHINES b where a.MACHINEID=b.MACHINEID and ISNULL(b.HIDE,0)=0 and a.JOBSITEID={0}";
|
||||
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
DataTable dt = null;
|
||||
dt = db.GetDataTableBySQL(sql_m, jobsiteid);
|
||||
|
||||
if (dt.Rows.Count == 0)
|
||||
{
|
||||
return new MachineViewItem[0];
|
||||
}
|
||||
List<MachineViewItem> list = new List<MachineViewItem>();
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
MachineViewItem mi = new MachineViewItem();
|
||||
mi.ID = FIDbAccess.GetFieldInt64(dr["MACHINEID"], 0);
|
||||
mi.Name = FIDbAccess.GetFieldString(dr["MACHINENAME"], string.Empty);
|
||||
mi.Name2 = FIDbAccess.GetFieldString(dr["MACHINENAME2"], string.Empty);
|
||||
mi.VIN = FIDbAccess.GetFieldString(dr["VIN"], string.Empty);
|
||||
mi.Onroad = FIDbAccess.GetFieldInt(dr["ONROAD"], 0);
|
||||
if (onroad < 0 || onroad == mi.Onroad)
|
||||
list.Add(mi);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
private static PostionItem[] ConvertPolygonToPointItem(string polygon)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(polygon))
|
||||
return null;
|
||||
|
||||
List<PostionItem> list = new List<PostionItem>();
|
||||
var polygons = polygon.Split(';');
|
||||
foreach (var py in polygons)
|
||||
{
|
||||
PostionItem pi = new PostionItem();
|
||||
var sap = py.Split(',');
|
||||
pi.Latitude = Convert.ToDouble(sap[0]);
|
||||
pi.Longitude = Convert.ToDouble(sap[1]);
|
||||
list.Add(pi);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Foresight.Fleet.Services.Customer;
|
||||
using IronIntel.Services;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
|
||||
namespace IronIntel.Contractor.MapView
|
||||
{
|
||||
public class LocationManagement
|
||||
{
|
||||
public static CompanyLocationViewItem[] GetCompanyLocations(string companyid)
|
||||
{
|
||||
List<CompanyLocationViewItem> ls = new List<CompanyLocationViewItem>();
|
||||
if (string.IsNullOrWhiteSpace(companyid) || string.Compare(companyid, SystemParams.CompanyID, true) == 0)
|
||||
{
|
||||
GetCompanyLocations(SystemParams.CompanyID, ls);
|
||||
if (!SystemParams.IsDealer)
|
||||
{
|
||||
Services.Customers.CustomerInfo dealer = SystemParams.GetFirstDealerInfo();
|
||||
if (dealer != null)
|
||||
{
|
||||
GetCompanyLocations(dealer.ID, ls);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ls.ToArray();
|
||||
}
|
||||
|
||||
private static void GetCompanyLocations(string companyid, List<CompanyLocationViewItem> ls)
|
||||
{
|
||||
CustomerLocation[] locations = FleetServiceClientHelper.CreateClient<CustomerProvider>(companyid, string.Empty).GetCustomerLocations(companyid);
|
||||
|
||||
foreach (CustomerLocation loc in locations)
|
||||
{
|
||||
ls.Add(ConvertToViewItem(loc, companyid));
|
||||
}
|
||||
}
|
||||
|
||||
private static CompanyLocationViewItem ConvertToViewItem(CustomerLocation loc, string companyid)
|
||||
{
|
||||
CompanyLocationViewItem li = new CompanyLocationViewItem();
|
||||
li.CompanyID = companyid;
|
||||
li.ID = loc.ID;
|
||||
li.LocationName = loc.Name;
|
||||
li.Latitude = loc.Latitude;
|
||||
li.Longitude = loc.Longitude;
|
||||
li.Notes = loc.Notes;
|
||||
|
||||
return li;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
using Foresight;
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using IronIntel.Services.Common;
|
||||
using IronIntel.Services.MapView;
|
||||
using Foresight.Fleet.Services.JobSite;
|
||||
using Foresight.Fleet.Services.MapView;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -10,93 +10,11 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.MapView
|
||||
{
|
||||
public class MachineViewItem
|
||||
{
|
||||
public string VIN { get; set; }
|
||||
public long ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Name2 { get; set; }
|
||||
public string IconUrl { get; set; }
|
||||
public string EmptyIconUrl { get; set; }//不包含机器图标
|
||||
public string MachineType { get; set; }
|
||||
public string Make { get; set; }
|
||||
public string Model { get; set; }
|
||||
public int MakeYear { get; set; }
|
||||
|
||||
private double _EngineHours;
|
||||
public double EngineHours
|
||||
{
|
||||
get
|
||||
{
|
||||
return _EngineHours;
|
||||
}
|
||||
set
|
||||
{
|
||||
value = value > 0 ? value : 0;
|
||||
_EngineHours = Math.Round(value, 2);
|
||||
}
|
||||
}
|
||||
public DateTime EngineHoursDate { get; set; }
|
||||
public int TypeID { get; set; }
|
||||
public string AlertTip { get; set; }
|
||||
public bool OnSite { get; set; }
|
||||
public string JobSiteName { get; set; }//当前所在的JobSiteName
|
||||
public double DistanceFromSite { get; set; }//机器与Jobsite之间的距离
|
||||
public bool WithinSite { get; set; }//机器是否在JobSite多边形范围内
|
||||
public LocationViewItem Location { get; set; }
|
||||
|
||||
private double _Odometer;
|
||||
public double Odometer
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Odometer;
|
||||
}
|
||||
set
|
||||
{
|
||||
value = value > 0 ? value : 0;
|
||||
_Odometer = Math.Round(value, 2);
|
||||
}
|
||||
}
|
||||
public string OdometerUOM { get; set; }
|
||||
public int Onroad { get; set; }
|
||||
public string IconFileName { get; set; }
|
||||
public string MoveStatus { get; set; }
|
||||
public int Directionalheading { get; set; }
|
||||
public int MapAlertLayerPriority { get; set; }
|
||||
public Int64 GpsDeviceID { get; set; } //空 -1
|
||||
public string AssetGroupNames { get; set; }
|
||||
public string DisplayName
|
||||
{
|
||||
get
|
||||
{
|
||||
//Name取值顺序为Name2,Name,VIN,ID用于前端显示
|
||||
string name = Name2;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
name = Name;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
name = VIN;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
name = ID.ToString();
|
||||
return name;
|
||||
}
|
||||
}//由于地图显示及排序的名称
|
||||
|
||||
public string EngineHoursDateText
|
||||
{
|
||||
get
|
||||
{
|
||||
if (EngineHoursDate != DateTime.MinValue)
|
||||
{
|
||||
return EngineHoursDate.ToString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class JobSiteViewItem
|
||||
{
|
||||
public string CompanyID { get; set; } = "";
|
||||
public string CompanyName { get; set; } = "";
|
||||
|
||||
public Int64 ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string[] Types { get; set; }
|
||||
@ -109,14 +27,30 @@ namespace IronIntel.Contractor.MapView
|
||||
public IIColor Color { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public DateTime StartDate { get; set; }
|
||||
public DateTime ProjectedEndDate { get; set; }
|
||||
public DateTime EndDate { get; set; }
|
||||
public PostionItem[] Polygon { get; set; }
|
||||
public Int64 BaseOnMachineID { get; set; }
|
||||
public string BaseonMachineName { get; set; }
|
||||
public string Code { get; set; }
|
||||
public long[] Assets { get; set; }
|
||||
public bool IsDeleted { get; set; }
|
||||
public int RegionId { get; set; }
|
||||
public string Region { get; set; }
|
||||
public string Number { get; set; }
|
||||
public string Foreman { get; set; }
|
||||
public string Manager { get; set; }
|
||||
public string Phone { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Group { get; set; }
|
||||
public string Address1 { get; set; }
|
||||
public string Address2 { get; set; }
|
||||
public string City { get; set; }
|
||||
public string State { get; set; }
|
||||
public string Zip { get; set; }
|
||||
public string County { get; set; }
|
||||
|
||||
public string strStartDate
|
||||
public string StartDateStr
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -133,7 +67,7 @@ namespace IronIntel.Contractor.MapView
|
||||
|
||||
|
||||
|
||||
public string strEndDate
|
||||
public string EndDateStr
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -147,12 +81,50 @@ namespace IronIntel.Contractor.MapView
|
||||
}
|
||||
}
|
||||
}
|
||||
public string ProjectedEndDateStr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ProjectedEndDate == DateTime.MinValue)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return ProjectedEndDate.ToShortDateString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MachineViewItem[] Machines { get; set; }
|
||||
public string RadiusStr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Radius > 0)
|
||||
{
|
||||
return Radius + " " + Radius_UOM + "(s)";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public JobSiteAssetItem[] Machines { get; set; }
|
||||
}
|
||||
|
||||
public class AssetMapViewPinItemClient : AssetMapViewPinItem
|
||||
{
|
||||
public string CompanyID { get; set; } = "";
|
||||
|
||||
public string CompanyName { get; set; } = "";
|
||||
}
|
||||
|
||||
public class AssetGroupViewItem
|
||||
{
|
||||
public string CompanyID { get; set; } = "";
|
||||
public string CompanyName { get; set; } = "";
|
||||
public string ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public long[] Assets { get; set; }
|
||||
@ -161,7 +133,7 @@ namespace IronIntel.Contractor.MapView
|
||||
public class CompanyLocationViewItem
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string CompanyID { get; set; }
|
||||
public string CompanyID { get; set; } = "";
|
||||
public double Latitude { get; set; }
|
||||
public double Longitude { get; set; }
|
||||
public string LocationName { get; set; }
|
||||
@ -174,7 +146,7 @@ namespace IronIntel.Contractor.MapView
|
||||
public string ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public MapAlertLayerDefinitionItem[] Layers { get; set; }
|
||||
public List<LookupDataSourceDataItem> LookupDataSources { get; set; }
|
||||
public List<LookupDataSourceDataItem> LookupDataSources { get; set; } = new List<LookupDataSourceDataItem>();
|
||||
}
|
||||
|
||||
public class LookupDataSourceDataItem
|
||||
@ -231,6 +203,7 @@ namespace IronIntel.Contractor.MapView
|
||||
|
||||
public class LocationViewItem
|
||||
{
|
||||
public long LogId { get; set; }
|
||||
public double Latitude { get; set; }
|
||||
public double Longitude { get; set; }
|
||||
public DateTime LocationTime { get; set; }
|
||||
@ -245,6 +218,11 @@ namespace IronIntel.Contractor.MapView
|
||||
return "";
|
||||
}
|
||||
}
|
||||
public string DataSource { get; set; }
|
||||
public string SubSource { get; set; }
|
||||
public string EventType { get; set; } = string.Empty;
|
||||
public string MsgUID { get; set; } = string.Empty;
|
||||
|
||||
public double Speed { get; set; } = -1;
|
||||
public string SpeedUnit { get; set; }
|
||||
public double PostedSpeed { get; set; } = -1;
|
||||
@ -254,29 +232,15 @@ namespace IronIntel.Contractor.MapView
|
||||
public List<KeyValuePair<string, string>> SmartWitnessVideoUrl { get; set; }
|
||||
public SpeedingBehaviors SpeedingBehavior { get; set; }
|
||||
public HarshDrivingEvents HarshDringEvent { get; set; }
|
||||
public bool FromSmartWitness { get; set; }
|
||||
}
|
||||
|
||||
public class MachineLocationHistoryViewItem
|
||||
{
|
||||
public MachineViewItem Machine { get; set; }
|
||||
public LocationViewItem[] Locations { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class MachineTypeItem
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 供JobSite选中的Mahcine
|
||||
/// </summary>
|
||||
public class AvailableMachines
|
||||
{
|
||||
public MachineViewItem[] Assigned { get; set; }
|
||||
public MachineViewItem[] Unassigned { get; set; }
|
||||
}
|
||||
public struct PostionItem
|
||||
{
|
||||
public double Latitude;
|
||||
@ -291,8 +255,11 @@ namespace IronIntel.Contractor.MapView
|
||||
|
||||
public class ShapeFileItem
|
||||
{
|
||||
public string CompanyID { get; set; } = "";
|
||||
public string CompanyName { get; set; } = "";
|
||||
public long ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public string FileName { get; set; }
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -4,8 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using IronIntel.Services;
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services.MapView;
|
||||
using IronIntel.Services.Customers;
|
||||
using Foresight.Fleet.Services.Customer;
|
||||
|
||||
namespace IronIntel.Contractor.MapView
|
||||
{
|
||||
|
@ -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.609")]
|
||||
[assembly: AssemblyFileVersion("23.4.26")]
|
||||
|
@ -1,25 +0,0 @@
|
||||
using Foresight.ServiceModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.Security
|
||||
{
|
||||
public class CurfewInfo
|
||||
{
|
||||
public string CurfewID { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Day { get; set; }
|
||||
public string StartTime { get; set; }
|
||||
public string EndTime { get; set; }
|
||||
public int IsEnabled { get; set; }
|
||||
public DateTime DateAdded { get; set; }
|
||||
public string AddBy { get; set; }
|
||||
public DateTime DateUpdated { get; set; }
|
||||
public string UpdatedBy { get; set; }
|
||||
public string TimePeriod { get; set; }
|
||||
public StringKeyValue[] TimePeriods { get; set; }
|
||||
}
|
||||
}
|
@ -1,281 +0,0 @@
|
||||
using Foresight.Data;
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Contractor.Machines;
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
using IronIntel.Contractor.MapView;
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.Security
|
||||
{
|
||||
public class CurfewManagement
|
||||
{
|
||||
public static CurfewInfo[] GetCurfews(string sessionid, string searchtext, FISqlConnection db = null)
|
||||
{
|
||||
const string SQL = "select CURFEWID,TITLE,DAY,STARTTIME,ENDTIME,ISENABLED,DATEADDED_UTC,ADDBY,DATEUPDATED_UTC,UPDATEDBY,TIMEPERIOD from CURFEW where ISENABLED=1";
|
||||
|
||||
List<CurfewInfo> list = new List<CurfewInfo>();
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
DataTable dt = db.GetDataTableBySQL(SQL);
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
UserInfo[] users = UserManagement.GetUsers();
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
CurfewInfo ci = ConvertToCurfewInfo(dr);
|
||||
if (string.IsNullOrWhiteSpace(searchtext)
|
||||
|| Helper.Contains(ci.Title, searchtext))
|
||||
list.Add(ci);
|
||||
}
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public static CurfewInfo GetCurfewInfo(string curfewid, FISqlConnection db = null)
|
||||
{
|
||||
const string SQL = "select CURFEWID,TITLE,DAY,STARTTIME,ENDTIME,ISENABLED,DATEADDED_UTC,ADDBY,DATEUPDATED_UTC,UPDATEDBY,TIMEPERIOD from CURFEW where ISENABLED=1 and CURFEWID={0}";
|
||||
|
||||
List<CurfewInfo> list = new List<CurfewInfo>();
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
DataTable dt = db.GetDataTableBySQL(SQL, curfewid);
|
||||
CurfewInfo ci = new CurfewInfo();
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
ci = ConvertToCurfewInfo(dt.Rows[0]);
|
||||
}
|
||||
return ci;
|
||||
}
|
||||
|
||||
|
||||
public static void SaveCurfew(CurfewInfo ci, string useriid, FISqlConnection db = null)
|
||||
{
|
||||
const string SQL = @"if exists(select 1 from CURFEW where CURFEWID={0}) update CURFEW set TITLE={1},DAY={2},STARTTIME={3},ENDTIME={4},DATEUPDATED_UTC=GETUTCDATE(),UPDATEDBY={5},TIMEPERIOD={6} where CURFEWID={0}
|
||||
else insert CURFEW(CURFEWID,TITLE,DAY,STARTTIME,ENDTIME,ISENABLED,DATEADDED_UTC,ADDBY,DATEUPDATED_UTC,UPDATEDBY,TIMEPERIOD) values({0},{1},{2},{3},{4},1,GETUTCDATE(),{5},GETUTCDATE(),{5},{6})";
|
||||
|
||||
const string SQL_C = "select COUNT(1) from CURFEW where CURFEWID!={0} and TITLE={1} and ISENABLED=1";
|
||||
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
object obj = db.GetRC1BySQL(SQL_C, ci.CurfewID, ci.Title);
|
||||
if (Convert.ToInt32(obj) > 0)
|
||||
{
|
||||
throw new Exception("The curfew title must be unique.");
|
||||
}
|
||||
|
||||
string timeperiodStr = "";
|
||||
if (ci.TimePeriods == null || ci.TimePeriods.Length <= 0)
|
||||
throw new Exception("Period cannot be empty.");
|
||||
|
||||
foreach (StringKeyValue item in ci.TimePeriods)
|
||||
{
|
||||
int st = Convert.ToInt32(item.Tag1 + item.Tag2);
|
||||
int et = Convert.ToInt32(item.Tag3 + item.Tag4);
|
||||
if (st >= et)
|
||||
throw new Exception("End Time must be later than Start Time.");
|
||||
|
||||
string str = item.Tag1 + ":" + item.Tag2 + "-" + item.Tag3 + ":" + item.Tag4;
|
||||
if (string.IsNullOrWhiteSpace(timeperiodStr))
|
||||
timeperiodStr = str;
|
||||
else
|
||||
timeperiodStr = timeperiodStr + "," + str;
|
||||
}
|
||||
|
||||
|
||||
db.ExecSQL(SQL, ci.CurfewID, ci.Title, ci.Day, ci.StartTime, ci.EndTime, useriid, timeperiodStr);
|
||||
|
||||
}
|
||||
|
||||
public static void DeleteCurfew(string curfewid, FISqlConnection db = null)
|
||||
{
|
||||
const string SQL = @"update CURFEW set ISENABLED=0 where CURFEWID={0}";
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
db.ExecSQL(SQL, curfewid);
|
||||
}
|
||||
|
||||
public static MaintenanceMachineInfo[] GetCurfewMachinesByID(string curfewid, FISqlConnection db = null)
|
||||
{
|
||||
const string SQL = @"select a.RELATEDID as MACHINEID,b.MACHINENAME,b.MACHINENAME2,b.VIN,b.MAKEID,b.MODELID,b.TYPEID,b.HIDE,ISNULL(b.ENGINEHOURS,0) as ENGINEHOURS,
|
||||
ISNULL(b.ODOMETER,0) as ODOMETER,ISNULL(b.ODOMETERUOM,'Mile') AS ODOMETERUOM from RELATIONSHIP a,MACHINES b
|
||||
where a.RELATEDID=b.MACHINEID and a.RELATIONSHIPTYPEID='CurfewToMachine' and a.REMOVED<>1 and a.PRIMARYID={0}";
|
||||
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
DataTable tb = db.GetDataTableBySQL(SQL, curfewid);
|
||||
if (tb.Rows.Count == 0)
|
||||
{
|
||||
return new MaintenanceMachineInfo[0];
|
||||
}
|
||||
MachineManagement.RefreshBaseData();
|
||||
MachineMake[] makes = MachineManagement.GetMachineMakes();
|
||||
MachineModel[] models = MachineManagement.GetMachineModels();
|
||||
MachineType[] types = MachineManagement.GetMachineTypes();
|
||||
List<MaintenanceMachineInfo> ls = new List<MaintenanceMachineInfo>();
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
MaintenanceMachineInfo mi = MaintenanceManagement.ConvertToMaintenanceMachineInfo(dr, makes, models, types);
|
||||
ls.Add(mi);
|
||||
}
|
||||
return ls.ToArray();
|
||||
|
||||
}
|
||||
|
||||
public static void SaveCurfewMachines(string curfewid, string contractorid, string[] machineids, FISqlConnection db)
|
||||
{
|
||||
const string SQL_R = "update RELATIONSHIP set REMOVEDON=GETUTCDATE(),REMOVED=1 where RELATIONSHIPTYPEID='CurfewToMachine' and REMOVED<>1 and PRIMARYID={0}";
|
||||
const string SQL = @"if exists(select 1 from RELATIONSHIP where RELATIONSHIPTYPEID='CurfewToMachine' and PRIMARYID={0} and RELATEDID={1}) update RELATIONSHIP
|
||||
set REMOVEDON=null,REMOVED=0 where RELATIONSHIPTYPEID='CurfewToMachine' and PRIMARYID={0} and RELATEDID={1} else insert into RELATIONSHIP
|
||||
(RELATIONSHIPID,RELATIONSHIPTYPEID,CONTRACTORID,PRIMARYID,RELATEDID,ADDEDON) values({3},'CurfewToMachine',{2},{0},{1},GETUTCDATE())";
|
||||
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
db.ExecSQL(SQL_R, curfewid);
|
||||
|
||||
foreach (var mid in machineids)
|
||||
{
|
||||
db.ExecSQL(SQL, curfewid, mid, contractorid, Guid.NewGuid().ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private static CurfewInfo ConvertToCurfewInfo(DataRow dr)
|
||||
{
|
||||
CurfewInfo ci = new CurfewInfo();
|
||||
ci.CurfewID = FIDbAccess.GetFieldString(dr["CURFEWID"], string.Empty);
|
||||
ci.Title = FIDbAccess.GetFieldString(dr["TITLE"], string.Empty);
|
||||
ci.Day = FIDbAccess.GetFieldString(dr["DAY"], string.Empty);
|
||||
ci.StartTime = FIDbAccess.GetFieldString(dr["STARTTIME"], string.Empty);
|
||||
ci.EndTime = FIDbAccess.GetFieldString(dr["ENDTIME"], string.Empty);
|
||||
ci.IsEnabled = FIDbAccess.GetFieldInt(dr["ISENABLED"], 0);
|
||||
ci.DateAdded = FIDbAccess.GetFieldDateTime(dr["DATEADDED_UTC"], DateTime.MinValue);
|
||||
ci.DateAdded = ci.DateAdded.AddHours(SystemParams.GetHoursOffset());
|
||||
ci.AddBy = FIDbAccess.GetFieldString(dr["ADDBY"], string.Empty);
|
||||
ci.DateUpdated = FIDbAccess.GetFieldDateTime(dr["DATEUPDATED_UTC"], DateTime.MinValue);
|
||||
ci.DateUpdated = ci.DateUpdated.AddHours(SystemParams.GetHoursOffset());
|
||||
ci.UpdatedBy = FIDbAccess.GetFieldString(dr["UPDATEDBY"], string.Empty);
|
||||
ci.TimePeriod = FIDbAccess.GetFieldString(dr["TIMEPERIOD"], string.Empty);
|
||||
if (!string.IsNullOrWhiteSpace(ci.TimePeriod))
|
||||
{
|
||||
List<StringKeyValue> list = new List<StringKeyValue>();
|
||||
string[] periods = ci.TimePeriod.Split(',');
|
||||
foreach (string pd in periods)
|
||||
{
|
||||
StringKeyValue kv = new StringKeyValue();
|
||||
string[] time = pd.Split('-');
|
||||
string[] starttime = time[0].Split(':');
|
||||
string[] endtime = time[1].Split(':');
|
||||
kv.Tag1 = starttime[0];
|
||||
kv.Tag2 = starttime[1];
|
||||
kv.Tag3 = endtime[0];
|
||||
kv.Tag4 = endtime[1];
|
||||
list.Add(kv);
|
||||
}
|
||||
ci.TimePeriods = list.ToArray();
|
||||
}
|
||||
else
|
||||
ci.TimePeriods = new StringKeyValue[0];
|
||||
return ci;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static JobSiteViewItem[] GetCurfewJobsitesByID(string curfewid, FISqlConnection db = null)
|
||||
{
|
||||
const string SQL = @"select a.RELATEDID as JOBSITEID,JOBSITENAME,LATITUDE,LONGITUDE ,RADIUS,RADUIS_UOM,b.CONTRACTORID,COLOR,NOTES,STARTDATE,ENDDATE,POLYGON from RELATIONSHIP a,JOBSITES b
|
||||
where a.RELATIONSHIPTYPEID='CurfewToJobsite' and a.REMOVED<>1 and a.RELATEDID=b.JOBSITEID and a.PRIMARYID={0}";
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
DataTable tb = db.GetDataTableBySQL(SQL, curfewid);
|
||||
if (tb.Rows.Count == 0)
|
||||
{
|
||||
return new JobSiteViewItem[0];
|
||||
}
|
||||
List<JobSiteViewItem> ls = new List<JobSiteViewItem>();
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
JobSiteViewItem js = ConvertToJobSiteViewItem(dr);
|
||||
ls.Add(js);
|
||||
}
|
||||
return ls.ToArray();
|
||||
|
||||
}
|
||||
|
||||
public static void SaveCurfewJobsites(string curfewid, string contractorid, string[] jobsiteids, FISqlConnection db = null)
|
||||
{
|
||||
const string SQL_R = "update RELATIONSHIP set REMOVEDON=GETUTCDATE(),REMOVED=1 where RELATIONSHIPTYPEID='CurfewToJobsite' and REMOVED<>1 and PRIMARYID={0}";
|
||||
const string SQL = @"if exists(select 1 from RELATIONSHIP where RELATIONSHIPTYPEID='CurfewToJobsite' and PRIMARYID={0} and RELATEDID={1}) update RELATIONSHIP
|
||||
set REMOVEDON=null,REMOVED=0 where RELATIONSHIPTYPEID='CurfewToJobsite' and PRIMARYID={0} and RELATEDID={1} else insert into RELATIONSHIP
|
||||
(RELATIONSHIPID,RELATIONSHIPTYPEID,CONTRACTORID,PRIMARYID,RELATEDID,ADDEDON) values({3},'CurfewToJobsite',{2},{0},{1},GETUTCDATE())";
|
||||
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
db.ExecSQL(SQL_R, curfewid);
|
||||
|
||||
foreach (var mid in jobsiteids)
|
||||
{
|
||||
db.ExecSQL(SQL, curfewid, mid, contractorid, Guid.NewGuid().ToString());
|
||||
}
|
||||
}
|
||||
private static JobSiteViewItem ConvertToJobSiteViewItem(DataRow dr)
|
||||
{
|
||||
JobSiteViewItem js = new JobSiteViewItem();
|
||||
long JobSiteId = FIDbAccess.GetFieldInt(dr["JOBSITEID"], 0);
|
||||
js.ID = FIDbAccess.GetFieldInt(dr["JOBSITEID"], 0);
|
||||
js.Name = FIDbAccess.GetFieldString(dr["JOBSITENAME"], string.Empty);
|
||||
js.Latitude = FIDbAccess.GetFieldDouble(dr["LATITUDE"], 0);
|
||||
js.Longitude = FIDbAccess.GetFieldDouble(dr["LONGITUDE"], 0);
|
||||
js.Radius = FIDbAccess.GetFieldDouble(dr["RADIUS"], 0);
|
||||
js.Radius_UOM = FIDbAccess.GetFieldString(dr["RADUIS_UOM"], string.Empty);
|
||||
if (string.IsNullOrWhiteSpace(js.Radius_UOM))
|
||||
js.Radius_UOM = "Mile";
|
||||
js.ContractorID = FIDbAccess.GetFieldString(dr["CONTRACTORID"], string.Empty);
|
||||
//js.ColorString = FIDbAccess.GetFieldString(dr["COLOR"], string.Empty);
|
||||
//System.Drawing.Color color = System.Drawing.Color.Orange;
|
||||
//try
|
||||
//{
|
||||
// color = System.Drawing.ColorTranslator.FromHtml(js.ColorString);
|
||||
//}
|
||||
//catch
|
||||
//{
|
||||
//}
|
||||
//js.Color = new IIColor() { Alpha = color.A, Red = color.R, Green = color.G, Blue = color.B };
|
||||
|
||||
js.Notes = FIDbAccess.GetFieldString(dr["NOTES"], string.Empty);
|
||||
js.StartDate = FIDbAccess.GetFieldDateTime(dr["STARTDATE"], DateTime.MinValue);
|
||||
js.EndDate = FIDbAccess.GetFieldDateTime(dr["ENDDATE"], DateTime.MinValue);
|
||||
return js;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取机器Curfew和机器的对应关系
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Dictionary<int, List<string>> GetCurfewMachines(FISqlConnection db)
|
||||
{
|
||||
const string SQL_C = "select PRIMARYID,RELATEDID from RELATIONSHIP where RELATIONSHIPTYPEID='CurfewToMachine' and REMOVED<>1";
|
||||
|
||||
Dictionary<int, List<string>> result = new Dictionary<int, List<string>>();
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
DataTable tb = db.GetDataTableBySQL(SQL_C);
|
||||
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
int machineid = FIDbAccess.GetFieldInt(dr["RELATEDID"], 0);
|
||||
string curfewid = FIDbAccess.GetFieldString(dr["PRIMARYID"], "");
|
||||
if (!result.ContainsKey(machineid))
|
||||
result[machineid] = new List<string>();
|
||||
result[machineid].Add(curfewid);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
using Foresight.Data;
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
@ -3,13 +3,156 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
namespace IronIntel.Contractor.Shape
|
||||
{
|
||||
public static class ShapeFileParser
|
||||
{
|
||||
/// <summary>
|
||||
/// 解析.shp文件
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
public static void ParseFromShapeFile(string fileName, Shape shape)
|
||||
{
|
||||
using (FileStream fileStream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
ParseFromShapeFile(fileStream, shape);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析.shp文件
|
||||
/// </summary>
|
||||
/// <param name="buffer">.shp文件数据</param>
|
||||
/// <param name="shape"></param>
|
||||
public static void ParseFromShapeFile(byte[] buffer, Shape shape)
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream(buffer, false))
|
||||
{
|
||||
ParseFromShapeFile(ms, shape);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析.shp文件
|
||||
/// </summary>
|
||||
/// <param name="fs">装载.shp文件数据的流</param>
|
||||
public static void ParseFromShapeFile(Stream fs, Shape shape)
|
||||
{
|
||||
fs.Seek(0, SeekOrigin.Begin);
|
||||
using (BinaryReader binaryReader = new BinaryReader(fs))
|
||||
{
|
||||
binaryReader.ReadBytes(24);
|
||||
|
||||
int FileLength = binaryReader.ReadInt32();//<0代表数据长度未知
|
||||
int FileBanben = binaryReader.ReadInt32();
|
||||
int ShapeType = binaryReader.ReadInt32();
|
||||
|
||||
double xmin = binaryReader.ReadDouble();
|
||||
double ymax = -1 * binaryReader.ReadDouble();
|
||||
double xmax = binaryReader.ReadDouble();
|
||||
double ymin = -1 * binaryReader.ReadDouble();
|
||||
double width = xmax - xmin;
|
||||
double height = ymax - ymin;
|
||||
|
||||
binaryReader.ReadBytes(32);
|
||||
|
||||
switch (ShapeType)
|
||||
{
|
||||
case 1://Point
|
||||
case 11://PointZ
|
||||
case 21://PointM
|
||||
MapPoints points = new MapPoints();
|
||||
shape.Points.Add(points);
|
||||
ParsePoints(binaryReader, points);
|
||||
break;
|
||||
case 3://PolyLine
|
||||
case 13://PolyLineZ
|
||||
case 23://PolyLineM
|
||||
ParsePolylines(binaryReader, shape.Polylines);
|
||||
break;
|
||||
case 5://Polygon
|
||||
case 15://PolygonZ
|
||||
case 25://PolygonM
|
||||
ParsePolygons(binaryReader, shape.Polygons);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从zip文件当中解析.shp
|
||||
/// </summary>
|
||||
/// <param name="stream">装载.zip文件内容的流</param>
|
||||
/// <param name="shape"></param>
|
||||
public static void ParseFromZipFile(Stream stream, Shape shape)
|
||||
{
|
||||
const string EXT = ".shp";
|
||||
//using (ZipInputStream s = new ZipInputStream(stream))
|
||||
//{
|
||||
// ZipEntry zipentry = s.GetNextEntry();
|
||||
// while (zipentry != null)
|
||||
// {
|
||||
// if (zipentry.IsDirectory)
|
||||
// {
|
||||
// zipentry = s.GetNextEntry();
|
||||
// continue;
|
||||
// }
|
||||
// string ext = Path.GetExtension(zipentry.FileName);
|
||||
// if (string.Compare(ext, EXT, true) == 0)
|
||||
// {
|
||||
// Stream shpStream = new MemoryStream();
|
||||
// int size = 0;
|
||||
// byte[] data = new byte[2048];
|
||||
// while (true)
|
||||
// {
|
||||
// size = s.Read(data, 0, data.Length);
|
||||
// if (size > 0)
|
||||
// {
|
||||
// shpStream.Write(data, 0, size);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// ParseFromShapeFile(shpStream, shape);
|
||||
// }
|
||||
// zipentry = s.GetNextEntry();
|
||||
// }//while
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从.zip文件当中解析.shp
|
||||
/// </summary>
|
||||
/// <param name="buffer">.zip文件数据</param>
|
||||
/// <param name="shape"></param>
|
||||
public static void ParseFromZipFile(byte[] buffer, Shape shape)
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream(buffer, false))
|
||||
{
|
||||
ParseFromZipFile(ms, shape);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从.zip文件当中解析.shp
|
||||
/// </summary>
|
||||
/// <param name="filename"></param>
|
||||
/// <param name="shape"></param>
|
||||
public static void ParseFromZipFile(string filename, Shape shape)
|
||||
{
|
||||
using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
ParseFromZipFile(fs, shape);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ParsePoints(BinaryReader binaryReader, MapPoints points)
|
||||
{
|
||||
while (binaryReader.PeekChar() != -1)
|
||||
@ -177,148 +320,189 @@ namespace IronIntel.Contractor.Shape
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析.shp文件
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
public static void ParseFromShapeFile(string fileName, Shape shape)
|
||||
{
|
||||
using (FileStream fileStream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
ParseFromShapeFile(fileStream, shape);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region kmz/kml
|
||||
|
||||
/// <summary>
|
||||
/// 解析.shp文件
|
||||
/// 从kmz文件当中解析.kml,再解析kml
|
||||
/// </summary>
|
||||
/// <param name="buffer">.shp文件数据</param>
|
||||
/// <param name="stream"></param>
|
||||
/// <param name="shape"></param>
|
||||
public static void ParseFromShapeFile(byte[] buffer, Shape shape)
|
||||
public static void ParseFromKMZFile(byte[] buffer, Shape shape)
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream(buffer, false))
|
||||
{
|
||||
ParseFromShapeFile(ms, shape);
|
||||
ParseFromKMZFile(ms, shape);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析.shp文件
|
||||
/// 从kmz文件当中解析.kml,再解析kml
|
||||
/// </summary>
|
||||
/// <param name="fs">装载.shp文件数据的流</param>
|
||||
public static void ParseFromShapeFile(Stream fs, Shape shape)
|
||||
/// <param name="stream"></param>
|
||||
/// <param name="shape"></param>
|
||||
public static void ParseFromKMZFile(Stream stream, Shape shape)
|
||||
{
|
||||
fs.Seek(0, SeekOrigin.Begin);
|
||||
using (BinaryReader binaryReader = new BinaryReader(fs))
|
||||
const string EXT = ".kml";
|
||||
using (ZipArchive archive = new ZipArchive(stream))
|
||||
{
|
||||
binaryReader.ReadBytes(24);
|
||||
|
||||
int FileLength = binaryReader.ReadInt32();//<0代表数据长度未知
|
||||
int FileBanben = binaryReader.ReadInt32();
|
||||
int ShapeType = binaryReader.ReadInt32();
|
||||
|
||||
double xmin = binaryReader.ReadDouble();
|
||||
double ymax = -1 * binaryReader.ReadDouble();
|
||||
double xmax = binaryReader.ReadDouble();
|
||||
double ymin = -1 * binaryReader.ReadDouble();
|
||||
double width = xmax - xmin;
|
||||
double height = ymax - ymin;
|
||||
|
||||
binaryReader.ReadBytes(32);
|
||||
|
||||
switch (ShapeType)
|
||||
foreach (var e in archive.Entries)
|
||||
{
|
||||
case 1://Point
|
||||
case 11://PointZ
|
||||
case 21://PointM
|
||||
MapPoints points = new MapPoints();
|
||||
shape.Points.Add(points);
|
||||
ParsePoints(binaryReader, points);
|
||||
break;
|
||||
case 3://PolyLine
|
||||
case 13://PolyLineZ
|
||||
case 23://PolyLineM
|
||||
ParsePolylines(binaryReader, shape.Polylines);
|
||||
break;
|
||||
case 5://Polygon
|
||||
case 15://PolygonZ
|
||||
case 25://PolygonM
|
||||
ParsePolygons(binaryReader, shape.Polygons);
|
||||
break;
|
||||
string ext = Path.GetExtension(e.Name);
|
||||
if (string.Compare(ext, EXT, true) == 0)
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(e.Open()))
|
||||
{
|
||||
using (MemoryStream fstream = new MemoryStream())
|
||||
{
|
||||
e.Open().CopyTo(fstream);
|
||||
ParseFromKMLFile(fstream, shape);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从zip文件当中解析.shp
|
||||
/// 解析.kml文件
|
||||
/// </summary>
|
||||
/// <param name="stream">装载.zip文件内容的流</param>
|
||||
/// <param name="shape"></param>
|
||||
public static void ParseFromZipFile(Stream stream, Shape shape)
|
||||
/// <param name="fileName"></param>
|
||||
public static void ParseFromKMLFile(string fileName, Shape shape)
|
||||
{
|
||||
const string EXT = ".shp";
|
||||
//using (ZipInputStream s = new ZipInputStream(stream))
|
||||
//{
|
||||
// ZipEntry zipentry = s.GetNextEntry();
|
||||
// while (zipentry != null)
|
||||
// {
|
||||
// if (zipentry.IsDirectory)
|
||||
// {
|
||||
// zipentry = s.GetNextEntry();
|
||||
// continue;
|
||||
// }
|
||||
// string ext = Path.GetExtension(zipentry.FileName);
|
||||
// if (string.Compare(ext, EXT, true) == 0)
|
||||
// {
|
||||
// Stream shpStream = new MemoryStream();
|
||||
// int size = 0;
|
||||
// byte[] data = new byte[2048];
|
||||
// while (true)
|
||||
// {
|
||||
// size = s.Read(data, 0, data.Length);
|
||||
// if (size > 0)
|
||||
// {
|
||||
// shpStream.Write(data, 0, size);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// ParseFromShapeFile(shpStream, shape);
|
||||
// }
|
||||
// zipentry = s.GetNextEntry();
|
||||
// }//while
|
||||
//}
|
||||
using (FileStream fileStream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
ParseFromKMLFile(fileStream, shape);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从.zip文件当中解析.shp
|
||||
/// 解析.kml文件
|
||||
/// </summary>
|
||||
/// <param name="buffer">.zip文件数据</param>
|
||||
/// <param name="buffer">.kml文件数据</param>
|
||||
/// <param name="shape"></param>
|
||||
public static void ParseFromZipFile(byte[] buffer, Shape shape)
|
||||
public static void ParseFromKMLFile(byte[] buffer, Shape shape)
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream(buffer, false))
|
||||
{
|
||||
ParseFromZipFile(ms, shape);
|
||||
ParseFromKMLFile(ms, shape);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从.zip文件当中解析.shp
|
||||
/// 解析.kml文件
|
||||
/// </summary>
|
||||
/// <param name="filename"></param>
|
||||
/// <param name="shape"></param>
|
||||
public static void ParseFromZipFile(string filename, Shape shape)
|
||||
/// <param name="fs">装载.kml文件数据的流</param>
|
||||
public static void ParseFromKMLFile(Stream fs, Shape shape)
|
||||
{
|
||||
using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
//fs.Seek(0, SeekOrigin.Begin);
|
||||
//StreamReader sr = new StreamReader(fs);
|
||||
//string content = sr.ReadToEnd();
|
||||
fs.Seek(0, SeekOrigin.Begin);
|
||||
XmlDocument xmldoc = new XmlDocument();
|
||||
xmldoc.Load(fs);
|
||||
XmlElement root = xmldoc.DocumentElement;
|
||||
|
||||
XmlNodeList pointNodes = root.GetElementsByTagName("Point");
|
||||
foreach (XmlElement pe in pointNodes)
|
||||
{
|
||||
ParseFromZipFile(fs, shape);
|
||||
ParseKMLPoints(pe, shape.Points);
|
||||
}
|
||||
|
||||
XmlNodeList lineNodes = root.GetElementsByTagName("LineString");
|
||||
foreach (XmlElement le in lineNodes)
|
||||
{
|
||||
ParseKMLLines(le, shape.Polylines);
|
||||
}
|
||||
|
||||
XmlNodeList polygonNodes = root.GetElementsByTagName("Polygon");
|
||||
foreach (XmlElement pe in polygonNodes)
|
||||
{
|
||||
ParseKMLPolygons(pe, shape.Polygons);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void ParseKMLPoints(XmlElement node, List<MapPoints> ls)
|
||||
{
|
||||
if (node == null) return;
|
||||
var coordinates = node["coordinates"];
|
||||
if (coordinates == null) return;
|
||||
|
||||
MapPoints points = new MapPoints();
|
||||
ls.Add(points);
|
||||
|
||||
string coordinatesstr = coordinates.InnerText.Trim();
|
||||
string[] temps = coordinatesstr.Split(',');//Longitude,Latitude,Z
|
||||
MapPoint mp = new MapPoint();
|
||||
double d = 0;
|
||||
if (double.TryParse(temps[0], out d))
|
||||
mp.Longitude = d;
|
||||
if (double.TryParse(temps[1], out d))
|
||||
mp.Latitude = d;
|
||||
points.Points.Add(mp);
|
||||
}
|
||||
|
||||
private static void ParseKMLLines(XmlElement node, List<Polyline> ls)
|
||||
{
|
||||
if (node == null) return;
|
||||
var coordinates = node["coordinates"];
|
||||
if (coordinates == null) return;
|
||||
|
||||
Polyline l = new Polyline();
|
||||
ls.Add(l);
|
||||
|
||||
MapPoints line = new MapPoints();
|
||||
l.Parts.Add(line);
|
||||
|
||||
string coordinatesstr = coordinates.InnerText.Trim();
|
||||
string[] cs = coordinatesstr.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
double d = 0;
|
||||
foreach (string c in cs)
|
||||
{
|
||||
string[] temps = c.Split(',');//Longitude,Latitude,Z
|
||||
MapPoint mp = new MapPoint();
|
||||
if (double.TryParse(temps[0], out d))
|
||||
mp.Longitude = d;
|
||||
if (double.TryParse(temps[1], out d))
|
||||
mp.Latitude = d;
|
||||
line.Points.Add(mp);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ParseKMLPolygons(XmlElement node, List<Polygon> ls)
|
||||
{
|
||||
if (node == null) return;
|
||||
var outer = node["outerBoundaryIs"];
|
||||
if (outer == null) return;
|
||||
var linearRing = outer["LinearRing"];
|
||||
if (linearRing == null) return;
|
||||
var coordinates = linearRing["coordinates"];
|
||||
if (coordinates == null) return;
|
||||
|
||||
Polygon p = new Polygon();
|
||||
ls.Add(p);
|
||||
|
||||
MapPoints ring = new MapPoints();
|
||||
p.Rings.Add(ring);
|
||||
|
||||
string coordinatesstr = coordinates.InnerText.Trim();
|
||||
string[] cs = coordinatesstr.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
double d = 0;
|
||||
foreach (string c in cs)
|
||||
{
|
||||
string[] temps = c.Split(',');//Longitude,Latitude,Z
|
||||
MapPoint mp = new MapPoint();
|
||||
if (double.TryParse(temps[0], out d))
|
||||
mp.Longitude = d;
|
||||
if (double.TryParse(temps[1], out d))
|
||||
mp.Latitude = d;
|
||||
ring.Points.Add(mp);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,6 +5,7 @@ using System.Collections.Concurrent;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Net;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
@ -13,25 +14,17 @@ using System.Threading;
|
||||
using System.Data.SqlClient;
|
||||
using Foresight.Security;
|
||||
using Foresight.Data;
|
||||
using IronIntel.Services;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services.Contractor.Machine;
|
||||
using IronIntel.Services.Users;
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using Foresight.Fleet.Services.Attachment;
|
||||
using Foresight.ServiceModel;
|
||||
using Foresight.Fleet.Services.FITracker;
|
||||
using Foresight.Fleet.Services.AssetHealth;
|
||||
using Foresight.Fleet.Services.User;
|
||||
using Foresight.Fleet.Services.Device;
|
||||
using Foresight.Fleet.Services.JobSite;
|
||||
using Foresight.Fleet.Services;
|
||||
using Foresight.Fleet.Services.OTRConfig;
|
||||
using Foresight.Fleet.Services.Customer;
|
||||
using Foresight.Fleet.Services.MapView;
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using Foresight.Fleet.Services.Styles;
|
||||
using Foresight.Fleet.Services.Style;
|
||||
using IronIntel.Contractor.Users;
|
||||
using Foresight.Fleet.Services.User;
|
||||
using Foresight.Fleet.Services.SystemOption;
|
||||
using Foresight.Fleet.Services.Inspection;
|
||||
using Foresight;
|
||||
using DocumentFormat.OpenXml.Presentation;
|
||||
|
||||
namespace IronIntel.Contractor
|
||||
{
|
||||
@ -46,6 +39,12 @@ namespace IronIntel.Contractor
|
||||
|
||||
private static string _ContractorVersion = "";
|
||||
private static string _FICVersion = "";
|
||||
public const string ICONCOLOR = "?typeid={0}&bkcolor=FF000000&dotcolor=FF69D850&sn={1}";
|
||||
|
||||
public const string WOSMSFootnotes = "WOSMSFootnotes";
|
||||
public const string EstimateMessage = "EstimateMessage";
|
||||
public const string DefaultPORequired = "DefaultPORequired";
|
||||
public const string InvoiceMessage = "InvoiceMessage";
|
||||
|
||||
private static string EncryptString(string s)
|
||||
{
|
||||
@ -224,12 +223,28 @@ namespace IronIntel.Contractor
|
||||
}
|
||||
}
|
||||
|
||||
private static string _WebSocketURL = null;
|
||||
public static string WebSocketURL
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_WebSocketURL == null)
|
||||
{
|
||||
string url = GetStringParam("WebSocketURL");
|
||||
if (string.IsNullOrEmpty(url))
|
||||
url = FleetServiceClientHelper.CreateClient<SystemOptionProvider>().GetMasterSysParam("WebSocketURL");
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
_WebSocketURL = string.Format("{0}?custid={1}", url, SystemParams.CompanyID);
|
||||
else
|
||||
_WebSocketURL = "";
|
||||
}
|
||||
return _WebSocketURL;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetStringParam(string paramname, string value)
|
||||
{
|
||||
const string SQL = "if exists(select 1 from SYSPARAMS where PARAMNAME={0}) update SYSPARAMS set PARAMVALUE={1} where PARAMNAME={0}"
|
||||
+ " else insert into SYSPARAMS(PARAMNAME,PARAMVALUE) values({0},{1})";
|
||||
FIDbAccess db = GetDbInstance();
|
||||
db.ExecSQL(SQL, paramname, value);
|
||||
FleetServiceClientHelper.CreateClient<CustomerProvider>().SetSystemParams(CompanyID, paramname, value);
|
||||
_Params[paramname] = value;
|
||||
}
|
||||
|
||||
@ -276,7 +291,7 @@ namespace IronIntel.Contractor
|
||||
FICDBInstance.ExecSQL(SQL, paramname, value);
|
||||
}
|
||||
|
||||
private static Services.Customers.CustomerInfo _Company = null;
|
||||
private static CustomerInfo _Company = null;
|
||||
|
||||
public static string CompanyID
|
||||
{
|
||||
@ -307,35 +322,42 @@ namespace IronIntel.Contractor
|
||||
}
|
||||
}
|
||||
|
||||
private static CustomerDetail _ForesightCustomer = null;
|
||||
private static object _sycfcust = new object();
|
||||
|
||||
|
||||
public static T GetServiceClient<T>() where T : Foresight.ServiceModel.ServiceClientBase, new()
|
||||
public static CustomerDetail ForesightCustomerDetail
|
||||
{
|
||||
T rst = new T();
|
||||
rst.ServiceAddress = SystemServiceAddresses[0];
|
||||
rst.AppName = APPNAME;
|
||||
return rst;
|
||||
get
|
||||
{
|
||||
if (_ForesightCustomer == null)
|
||||
{
|
||||
lock (_sycfcust)
|
||||
{
|
||||
if (_ForesightCustomer == null)
|
||||
{
|
||||
_ForesightCustomer = FleetServiceClientHelper.CreateClient<CustomerProvider>().GetCustomerDetail("Foresight");
|
||||
}
|
||||
}
|
||||
}
|
||||
return _ForesightCustomer;
|
||||
}
|
||||
}
|
||||
|
||||
public static T GetServiceClient<T>(string sessionid) where T : Foresight.ServiceModel.ServiceClientBase, new()
|
||||
public static CustomerDetail GetCustomerDetail(string cid)
|
||||
{
|
||||
T rst = new T();
|
||||
rst.ServiceAddress = SystemServiceAddresses[0];
|
||||
rst.AppName = APPNAME;
|
||||
rst.LoginSessionID = sessionid;
|
||||
return rst;
|
||||
return FleetServiceClientHelper.CreateClient<CustomerProvider>().GetCustomerDetail(cid);
|
||||
}
|
||||
|
||||
public static Services.LicenseInfo GetLicense()
|
||||
public static LicenseInfo GetLicense()
|
||||
{
|
||||
var ic = GetServiceClient<Services.Customers.CustomerProvider>();
|
||||
CustomerProvider ic = FleetServiceClientHelper.CreateClient<CustomerProvider>();
|
||||
return ic.GetLicenseInfo(CompanyID);
|
||||
}
|
||||
|
||||
public static bool HasLicense(string itemName)
|
||||
{
|
||||
bool result = false;
|
||||
var license = SystemParams.GetLicense();
|
||||
var license = GetLicense();
|
||||
if (license != null && license.Items.Count > 0)
|
||||
{
|
||||
var item = license.Items.FirstOrDefault(m => m.Key.Equals(itemName, StringComparison.OrdinalIgnoreCase));
|
||||
@ -349,8 +371,6 @@ namespace IronIntel.Contractor
|
||||
{
|
||||
if (string.IsNullOrEmpty(_ContractorVersion))
|
||||
{
|
||||
//IronSysServiceClient ic = GetIronSystemServiceClient();
|
||||
//_ContractorVersion = ic.GetServerVersion();
|
||||
_ContractorVersion = GetAssemblyFileVersion();
|
||||
}
|
||||
return _ContractorVersion;
|
||||
@ -370,21 +390,6 @@ namespace IronIntel.Contractor
|
||||
return _FICVersion;
|
||||
}
|
||||
|
||||
private static string[] _IronIntelSystemServiceAddresses = null;
|
||||
|
||||
public static string[] SystemServiceAddresses
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_IronIntelSystemServiceAddresses == null)
|
||||
{
|
||||
string s = GetStringParam("MasterServiceAddress");
|
||||
_IronIntelSystemServiceAddresses = s.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
return _IronIntelSystemServiceAddresses;
|
||||
}
|
||||
}
|
||||
|
||||
private static string _ReportDbString = string.Empty;
|
||||
|
||||
public static string GetIronIntelReportDataDbString(string companyid = null)
|
||||
@ -395,11 +400,6 @@ namespace IronIntel.Contractor
|
||||
{
|
||||
return _ReportDbString;
|
||||
}
|
||||
string svcaddress = GetStringParam("IronIntelSystemServiceAddress");
|
||||
if (string.IsNullOrWhiteSpace(svcaddress))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
CustomerDetail cust = FleetServiceClientHelper.CreateClient<CustomerProvider>(companyid, string.Empty).GetCustomerDetail(companyid);
|
||||
string dbstring = cust.ReportDataDbString;
|
||||
if (!string.IsNullOrEmpty(dbstring))
|
||||
@ -416,6 +416,29 @@ namespace IronIntel.Contractor
|
||||
return GetCustomerDbString(companyid, "MASTER_DATA_DB");
|
||||
}
|
||||
|
||||
public static string[] GetMonitorServiceAddresses()
|
||||
{
|
||||
SystemOptionProvider sp = FleetServiceClientHelper.CreateClient<SystemOptionProvider>();
|
||||
string xml = sp.GetMasterSysParam("ForesightPublicService");
|
||||
if (string.IsNullOrWhiteSpace(xml))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.LoadXml(xml);
|
||||
foreach (XmlNode node in doc.DocumentElement.ChildNodes)
|
||||
{
|
||||
if (string.Compare(node.Name, "MonitorServiceAddress", true) == 0)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(node.InnerText))
|
||||
{
|
||||
return node.InnerText.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetCustomerDbString(string companyid, string dbtype)
|
||||
{
|
||||
string key = companyid + dbtype;
|
||||
@ -428,19 +451,19 @@ namespace IronIntel.Contractor
|
||||
return dbstring;
|
||||
}
|
||||
|
||||
public static Services.Customers.CustomerInfo GetCompanyInfo()
|
||||
public static CustomerInfo GetCompanyInfo()
|
||||
{
|
||||
if (_Company == null)
|
||||
{
|
||||
var ic = GetCustomerProvider();
|
||||
var ic = FleetServiceClientHelper.CreateClient<CustomerProvider>(CompanyID);
|
||||
_Company = ic.GetCustomerByID(CompanyID);
|
||||
}
|
||||
return _Company;
|
||||
}
|
||||
public static MainStyle GetMainStyle()
|
||||
{
|
||||
IronSysServiceClient ic = GetIronSystemServiceClient();
|
||||
return ic.GetMainStyle(CompanyID);
|
||||
var sp = FleetServiceClientHelper.CreateClient<StyleProvider>();
|
||||
return sp.GetMainStyle(CompanyID);
|
||||
}
|
||||
|
||||
public static bool IsDealer
|
||||
@ -451,16 +474,16 @@ namespace IronIntel.Contractor
|
||||
}
|
||||
}
|
||||
|
||||
public static Services.Customers.CustomerInfo[] GetContractors()
|
||||
public static CustomerInfo[] GetContractors()
|
||||
{
|
||||
if (IsDealer)
|
||||
{
|
||||
var cust = GetCustomerProvider();
|
||||
return cust.GetContractors(CompanyID);
|
||||
var ic = FleetServiceClientHelper.CreateClient<CustomerProvider>(CompanyID);
|
||||
return ic.GetContractors(CompanyID);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new Services.Customers.CustomerInfo[0];
|
||||
return new CustomerInfo[0];
|
||||
}
|
||||
}
|
||||
|
||||
@ -471,8 +494,8 @@ namespace IronIntel.Contractor
|
||||
|
||||
public static byte[] GetForesightLOGOInMainStyle()
|
||||
{
|
||||
IronSysServiceClient ic = GetIronSystemServiceClient();
|
||||
return ic.GetLogoInMainStyle(CompanyID, 1);
|
||||
var sp = FleetServiceClientHelper.CreateClient<StyleProvider>();
|
||||
return sp.GetLogoInMainStyle(CompanyID, 1);
|
||||
}
|
||||
|
||||
public static byte[] GetCompanyLocationLOGO(string companyid)
|
||||
@ -488,7 +511,7 @@ namespace IronIntel.Contractor
|
||||
}
|
||||
}
|
||||
|
||||
public static Services.Customers.CustomerInfo GetFirstDealerInfo()
|
||||
public static CustomerInfo GetFirstDealerInfo()
|
||||
{
|
||||
if (IsDealer)
|
||||
{
|
||||
@ -496,7 +519,7 @@ namespace IronIntel.Contractor
|
||||
}
|
||||
else
|
||||
{
|
||||
var cust = GetCustomerProvider();
|
||||
var cust = FleetServiceClientHelper.CreateClient<CustomerProvider>(CompanyID);
|
||||
var cmps = cust.GetDealers(CompanyID);
|
||||
if ((cmps != null) && (cmps.Length > 0))
|
||||
{
|
||||
@ -506,9 +529,22 @@ namespace IronIntel.Contractor
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Dictionary<string, CustomerInfo> _DealerConttactors = new Dictionary<string, CustomerInfo>();
|
||||
public static CustomerInfo GetCustomerInfo(string id)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(id)) return null;
|
||||
if (!_DealerConttactors.ContainsKey(id))
|
||||
{
|
||||
var ic = FleetServiceClientHelper.CreateClient<CustomerProvider>(id);
|
||||
var c = ic.GetCustomerByID(id);
|
||||
_DealerConttactors[id] = c;
|
||||
}
|
||||
return _DealerConttactors[id];
|
||||
}
|
||||
|
||||
public static bool HasLOGO(string companyid)
|
||||
{
|
||||
IronSysServiceClient ic = GetIronSystemServiceClient();
|
||||
CustomerProvider ic = FleetServiceClientHelper.CreateClient<CustomerProvider>();
|
||||
return ic.HasLOGO(companyid);
|
||||
}
|
||||
public static void ExecSQL(FIDbAccess db, int retrytimes, string sql, params object[] values)
|
||||
@ -533,30 +569,6 @@ namespace IronIntel.Contractor
|
||||
}
|
||||
}
|
||||
|
||||
public static IronSysServiceClient GetIronSystemServiceClient()
|
||||
{
|
||||
IronSysServiceClient ic = GetServiceClient<IronSysServiceClient>();
|
||||
return ic;
|
||||
}
|
||||
|
||||
public static MachineServiceClient2 GetMachineServiceClient()
|
||||
{
|
||||
MachineServiceClient2 ic = GetServiceClient<MachineServiceClient2>();
|
||||
return ic;
|
||||
}
|
||||
|
||||
public static MapAlertLayerClient GetMapAlertLayerClient()
|
||||
{
|
||||
MapAlertLayerClient ic = GetServiceClient<MapAlertLayerClient>();
|
||||
return ic;
|
||||
}
|
||||
|
||||
public static Services.Customers.CustomerProvider GetCustomerProvider()
|
||||
{
|
||||
var ic = GetServiceClient<Services.Customers.CustomerProvider>();
|
||||
return ic;
|
||||
}
|
||||
|
||||
/**Fleet Service***/
|
||||
public static string[] FleetAssetServiceAddresses
|
||||
{
|
||||
@ -591,8 +603,8 @@ namespace IronIntel.Contractor
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_MachineTypeMapViewIconUrl))
|
||||
{
|
||||
MachineServiceClient2 mc2 = SystemParams.GetMachineServiceClient();
|
||||
_MachineTypeMapViewIconUrl = mc2.GetMachineTypeIconUrl();
|
||||
var client = FleetServiceClientHelper.CreateClient<AssetClassProvider>();
|
||||
_MachineTypeMapViewIconUrl = client.GetMachineTypeIconUrl();
|
||||
}
|
||||
return _MachineTypeMapViewIconUrl;
|
||||
}
|
||||
@ -605,50 +617,14 @@ namespace IronIntel.Contractor
|
||||
int styleID = -1;
|
||||
if (string.IsNullOrEmpty(sid) || !int.TryParse(sid, out styleID))
|
||||
styleID = -1;
|
||||
var sc = GetIronSystemServiceClient();
|
||||
CustUIStyle style = sc.GetDefaultUIStyle(SystemParams.CompanyID, styleID);
|
||||
var sp = FleetServiceClientHelper.CreateClient<StyleProvider>();
|
||||
CustUIStyle style = sp.GetDefaultUIStyle(CompanyID, styleID);
|
||||
return style;
|
||||
}
|
||||
|
||||
//public static int GetTimeAdjust()
|
||||
//{
|
||||
// var sc = GetIronSystemServiceClient();
|
||||
// return sc.GetCompanyTimeAdjust(CompanyID);
|
||||
//}
|
||||
|
||||
public static double GetHoursOffset()
|
||||
public static TimeZoneInfo GetTimeZoneInfo(string custid)
|
||||
{
|
||||
//double offsetMinutes = 0;
|
||||
//string offset = GetStringParam("CustomerTimeZoneOffset");
|
||||
//if (!string.IsNullOrEmpty(offset) && double.TryParse(offset, out offsetMinutes))
|
||||
//{
|
||||
// return offsetMinutes / 60;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
string tzName = GetStringParam("CustomerTimeZone");
|
||||
if (!string.IsNullOrEmpty(tzName))
|
||||
{
|
||||
var tz = TimeZoneInfo.FindSystemTimeZoneById(tzName.Trim());
|
||||
if (tz != null)
|
||||
{
|
||||
TimeSpan offset = tz.GetUtcOffset(DateTime.UtcNow);
|
||||
return offset.Hours + (double)offset.Minutes / 60;
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
var sc = GetIronSystemServiceClient();
|
||||
double offsetHours = sc.GetCompanyTimeAdjust(CompanyID);
|
||||
return offsetHours;
|
||||
}
|
||||
|
||||
public static TimeZoneInfo GetTimeZoneInfo(string custid, FISqlConnection db = null)
|
||||
{
|
||||
|
||||
string tzName = GetStringParam("CustomerTimeZone", true, db);
|
||||
if (string.IsNullOrEmpty(tzName))
|
||||
tzName = FleetServiceClientHelper.CreateClient<CustomerProvider>(custid, string.Empty).GetCustomerTimeZoneName(custid);
|
||||
string tzName = FleetServiceClientHelper.CreateClient<CustomerProvider>(custid, string.Empty).GetCustomerTimeZoneName(custid);
|
||||
var tz = TimeZoneInfo.FindSystemTimeZoneById(tzName.Trim());
|
||||
return tz;
|
||||
}
|
||||
@ -669,30 +645,26 @@ namespace IronIntel.Contractor
|
||||
result.Add(skv);
|
||||
}
|
||||
return result.OrderBy(tz => double.Parse(tz.Tag1)).ThenBy(tz => tz.Key).ToArray();
|
||||
//const string SQL = "select name,current_utc_offset as offset from sys.time_zone_info";
|
||||
|
||||
//FISqlConnection db = GetDbInstance();
|
||||
//DataTable tb = db.GetDataTableBySQL(SQL);
|
||||
//if (tb.Rows.Count > 0)
|
||||
//{
|
||||
// foreach (DataRow dr in tb.Rows)
|
||||
// {
|
||||
// StringKeyValue skv = new StringKeyValue();
|
||||
// skv.Key = FIDbAccess.GetFieldString(dr["name"], string.Empty);
|
||||
// skv.Value = FIDbAccess.GetFieldString(dr["offset"], string.Empty);
|
||||
|
||||
// string offsetstr = skv.Value;
|
||||
// string symbol = offsetstr.Substring(0, 1);
|
||||
// string offset = offsetstr.Remove(0, 1);
|
||||
// string[] strs = offset.Split(':');
|
||||
|
||||
// skv.Tag1 = (int.Parse(symbol + strs[0]) * 60 + int.Parse(symbol + strs[1])).ToString();
|
||||
// result.Add(skv);
|
||||
// }
|
||||
//}
|
||||
//return result.ToArray();
|
||||
}
|
||||
|
||||
public static DateTime ConvertToUserTimeFromUtc(Foresight.Fleet.Services.User.UserInfo ui, DateTime utctime)
|
||||
{
|
||||
TimeZoneInfo timeZone = null;
|
||||
if (!string.IsNullOrWhiteSpace(ui.TimeZone))
|
||||
{
|
||||
timeZone = TimeZoneInfo.FindSystemTimeZoneById(ui.TimeZone);
|
||||
}
|
||||
|
||||
if (timeZone == null)
|
||||
{
|
||||
if (ui.IsForesightUser)
|
||||
timeZone = ForesightCustomerDetail.TimeZone;
|
||||
else
|
||||
timeZone = CustomerDetail.TimeZone;
|
||||
}
|
||||
|
||||
return TimeZoneInfo.ConvertTimeFromUtc(new DateTime(utctime.Ticks), timeZone);
|
||||
}
|
||||
|
||||
public const string APPNAME = "IronIntelCustomerSite";
|
||||
private const string WORKING_COMPANY_HEADER = "WorkingCompanyID";
|
||||
@ -729,6 +701,17 @@ namespace IronIntel.Contractor
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteLog_Ext(string logType, string source, string message, string detail, string extmsg)
|
||||
{
|
||||
try
|
||||
{
|
||||
FleetServiceClientHelper.CreateClient<SystemUtil>().WriteLog(CompanyID, APPNAME, logType, source, message, detail, extmsg);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteRefreshLog(string useriid, string userhost, string objname, string refreshtype)
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(new WaitCallback((e) => { _WriteRefreshLog(useriid, userhost, objname, refreshtype); }), null);
|
||||
@ -826,10 +809,17 @@ namespace IronIntel.Contractor
|
||||
|
||||
public static Dictionary<string, string> GetAdditionalParameter()
|
||||
{
|
||||
StringKeyValue connector = new StringKeyValue();
|
||||
|
||||
string connectorxml = GetStringParam("Connector");
|
||||
StringKeyValue[] connectors = ConnectorHelper.FromXML(connectorxml);
|
||||
if (connectors != null && connectors.Length > 0)
|
||||
connector = connectors[0];
|
||||
|
||||
var dict = new Dictionary<string, string>
|
||||
{
|
||||
{ "ConnectorToken", ConnectorToken },
|
||||
{ "ConnectorServer", ConnectorServer },
|
||||
{ "ConnectorServer", connector.Key },
|
||||
{ "ConnectorToken", connector.Value },
|
||||
{ "LdapAgentID", LdapAgentID },
|
||||
{ "LdapAgentToken", LdapAgentToken },
|
||||
{ "CanUseConnectorLDAP", CanUseConnectorLDAP ? "1" : "0" }
|
||||
@ -837,5 +827,196 @@ namespace IronIntel.Contractor
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
private static ConcurrentDictionary<string, Dictionary<string, object>> _Languages = new ConcurrentDictionary<string, Dictionary<string, object>>(StringComparer.OrdinalIgnoreCase);
|
||||
private static Dictionary<string, object> GetLanguage(string lang)
|
||||
{
|
||||
if (!_Languages.ContainsKey(lang))
|
||||
{
|
||||
var ldata = LoadLanguage(lang);
|
||||
if (ldata != null)
|
||||
{
|
||||
_Languages[lang] = ldata;
|
||||
return ldata;
|
||||
}
|
||||
}
|
||||
else
|
||||
return _Languages[lang];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Dictionary<string, object> LoadLanguage(string lang)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(lang))
|
||||
lang = "en-us";
|
||||
|
||||
string filename = lang + ".json";
|
||||
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Languages\\" + filename);
|
||||
TextReader tr = File.OpenText(path);
|
||||
Newtonsoft.Json.JsonTextReader jtr = new Newtonsoft.Json.JsonTextReader(tr);
|
||||
Newtonsoft.Json.Linq.JObject obj = Newtonsoft.Json.Linq.JObject.Load(jtr);
|
||||
|
||||
System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
|
||||
Dictionary<string, object> dic = (Dictionary<string, object>)js.DeserializeObject(obj["Values"].ToString());
|
||||
|
||||
return dic;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetTextByKey(string lang, string key, string defaultValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
Dictionary<string, object> dic = GetLanguage(lang);
|
||||
if (dic == null || !dic.ContainsKey(key))
|
||||
return defaultValue;
|
||||
return dic[key].ToString();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static string _TimeZoneAbbreviation = "";
|
||||
public static string TimeZoneAbbreviation
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(_TimeZoneAbbreviation))
|
||||
{
|
||||
_TimeZoneAbbreviation = GetUpperTimeZone(CustomerDetail.TimeZone.Id);
|
||||
//Dictionary<string, string> dic = GetTimeZoneAbbreviations();
|
||||
//if (dic.ContainsKey(CustomerDetail.TimeZone.Id))
|
||||
// _TimeZoneAbbreviation = dic[CustomerDetail.TimeZone.Id];
|
||||
//else
|
||||
// _TimeZoneAbbreviation = CustomerDetail.TimeZone.Id;
|
||||
}
|
||||
return _TimeZoneAbbreviation;
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetUpperTimeZone(string tzid)
|
||||
{
|
||||
tzid = System.Text.RegularExpressions.Regex.Replace(tzid, @"\(.*\)", "");
|
||||
return System.Text.RegularExpressions.Regex.Replace(tzid, @"[a-z ]*", "");
|
||||
}
|
||||
|
||||
public static bool ShowForesightLogo()
|
||||
{
|
||||
string temp = GetStringParam("ShowForesightLogo");
|
||||
if (string.IsNullOrEmpty(temp))
|
||||
return true;
|
||||
return Helper.IsTrue(temp);
|
||||
}
|
||||
|
||||
public static string GetUserLanguage(string useriid)
|
||||
{
|
||||
var uc = FleetServiceClientHelper.CreateClient<UserQueryClient>();
|
||||
string language = uc.GetUserPreferredLanguageByIID(useriid);
|
||||
if (string.IsNullOrEmpty(language))
|
||||
{
|
||||
var ic = FleetServiceClientHelper.CreateClient<CustomerProvider>(CompanyID);
|
||||
var cust = ic.GetCustomerByID(CompanyID);
|
||||
language = cust.LanguageId;
|
||||
}
|
||||
|
||||
return string.IsNullOrEmpty(language) ? "en-us" : language;
|
||||
}
|
||||
|
||||
|
||||
public static bool CheckRight(string custid, Foresight.Fleet.Services.User.UserInfo user, int featureid, Permissions per = Permissions.ReadOnly)
|
||||
{
|
||||
if (user == null)
|
||||
return false;
|
||||
|
||||
if (user.UserType == Foresight.Fleet.Services.User.UserTypes.SupperAdmin)
|
||||
return true;
|
||||
|
||||
if (user.UserType == Foresight.Fleet.Services.User.UserTypes.Common || user.UserType == Foresight.Fleet.Services.User.UserTypes.Admin)
|
||||
{
|
||||
var client = FleetServiceClientHelper.CreateClient<PermissionProvider>();
|
||||
Tuple<Feature, Permissions>[] pmss = client.GetUserPermissions(custid, user.UID);
|
||||
if (pmss.Length > 0)
|
||||
{
|
||||
Tuple<Feature, Permissions> permission = pmss.FirstOrDefault(m => m.Item1.Id == featureid);
|
||||
if (permission != null && permission.Item2 >= per)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class ConnectorHelper
|
||||
{
|
||||
public static StringKeyValue[] FromXML(string xmlstr)
|
||||
{
|
||||
List<StringKeyValue> ls = new List<StringKeyValue>();
|
||||
if (!string.IsNullOrEmpty(xmlstr))
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.LoadXml(xmlstr);
|
||||
XmlNode ch = doc.DocumentElement.FirstChild;
|
||||
if (string.Compare(ch.Name, "Connectors", true) == 0)
|
||||
{
|
||||
foreach (XmlNode node in ch.ChildNodes)
|
||||
{
|
||||
ls.Add(FromXml(node));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ls.ToArray();
|
||||
}
|
||||
|
||||
private static StringKeyValue FromXml(XmlNode node)
|
||||
{
|
||||
StringKeyValue kv = new StringKeyValue();
|
||||
foreach (XmlNode ch in node.ChildNodes)
|
||||
{
|
||||
if (string.Compare(ch.Name, "Server", true) == 0)
|
||||
kv.Key = ch.InnerText;
|
||||
else if (string.Compare(ch.Name, "Token", true) == 0)
|
||||
kv.Value = ch.InnerText;
|
||||
|
||||
}
|
||||
return kv;
|
||||
}
|
||||
|
||||
public static XmlDocument ToXml(StringKeyValue[] kvs)
|
||||
{
|
||||
XmlDocument doc = XmlHelper.CreateXmlDocument();
|
||||
XmlNode node = XmlHelper.AppendChildNode(doc.DocumentElement, "Connectors", "");
|
||||
if (kvs != null && kvs.Length > 0)
|
||||
{
|
||||
foreach (var kv in kvs)
|
||||
{
|
||||
var sn = AddSubNode(node, "Connector", "");
|
||||
|
||||
AddSubNode(sn, "Server", kv.Key);
|
||||
AddSubNode(sn, "Token", kv.Value);
|
||||
}
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
|
||||
private static XmlNode AddSubNode(XmlNode parent, string nodename, string innertext)
|
||||
{
|
||||
XmlNode node = parent.OwnerDocument.CreateNode(XmlNodeType.Element, nodename, string.Empty);
|
||||
if (!string.IsNullOrEmpty(innertext))
|
||||
{
|
||||
node.InnerText = innertext;
|
||||
}
|
||||
parent.AppendChild(node);
|
||||
return node;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -23,24 +23,74 @@ namespace IronIntel.Contractor.Users
|
||||
public AppModuleType ModuleType { get; set; }
|
||||
public List<NavigateItem> SubItems { get; set; }
|
||||
|
||||
public List<NavigateItem> GetJobsiteNavigateItems(Tuple<Feature, Permissions>[] pmss)
|
||||
{
|
||||
List<NavigateItem> list = new List<NavigateItem>();
|
||||
Foresight.Fleet.Services.Customer.LicenseInfo license = SystemParams.GetLicense();
|
||||
var jsitem = license.Items.FirstOrDefault(m => m.Key == "JobSites");
|
||||
if (jsitem == null || !Helper.IsTrue(jsitem.Value))
|
||||
{
|
||||
return list;
|
||||
}
|
||||
NavigateItem item = null;
|
||||
var jsditem = license.Items.FirstOrDefault(m => m.Key == "JobsiteDispatch");
|
||||
if (jsditem != null && Helper.IsTrue(jsditem.Value))
|
||||
{
|
||||
item = new NavigateItem();
|
||||
item.ID = "nav_jobsiterequirements";
|
||||
item.FeatureID = Feature.JOB_SITES_REQUIREMENTS;
|
||||
item.Title = "Jobsite Requirements";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "JobSiteRequirements.aspx";
|
||||
item.IconPath = "img/jobsiterequirements.png";
|
||||
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.JOB_SITES_REQUIREMENTS) != null)
|
||||
list.Add(item);
|
||||
|
||||
item = new NavigateItem();
|
||||
item.ID = "nav_dispatchrequests";
|
||||
item.FeatureID = Feature.JOB_SITES_DISPATCHREQUESTS;
|
||||
item.Title = "Dispatch Requests";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "DispatchRequests.aspx";
|
||||
item.IconPath = "img/dispatch.png";
|
||||
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.JOB_SITES_DISPATCHREQUESTS) != null)
|
||||
list.Add(item);
|
||||
}
|
||||
|
||||
item = new NavigateItem();
|
||||
item.ID = "nav_jobsitemanage";
|
||||
item.FeatureID = Feature.JOB_SITES;
|
||||
item.Title = "Jobsites";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "JobSiteManage.aspx";
|
||||
item.IconPath = "img/jobsite.png";
|
||||
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.JOB_SITES) != null)
|
||||
list.Add(item);
|
||||
|
||||
if (jsditem != null || Helper.IsTrue(jsditem.Value))
|
||||
{
|
||||
item = new NavigateItem();
|
||||
item.ID = "nav_scheduler";
|
||||
item.FeatureID = Feature.JOB_SITES_SCHEDULER;
|
||||
item.Title = "Scheduler";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "SchedulerManagement.aspx";
|
||||
item.IconPath = "img/scheduler.png";
|
||||
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.JOB_SITES_SCHEDULER) != null)
|
||||
list.Add(item);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<NavigateItem> GetMaintenanceNavigateItems(Tuple<Feature, Permissions>[] pmss)
|
||||
{
|
||||
List<NavigateItem> list = new List<NavigateItem>();
|
||||
|
||||
NavigateItem item = new NavigateItem();
|
||||
item.ID = "nav_alertsmanagement";
|
||||
item.FeatureID = Feature.ALERTS_MANAGEMENT;
|
||||
item.Title = "Alerts Management **New**";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "AlertsManagement.aspx";
|
||||
item.IconPath = "img/alert.png";
|
||||
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.ALERTS_MANAGEMENT) != null)
|
||||
list.Add(item);
|
||||
|
||||
item = new NavigateItem();
|
||||
item.ID = "nav_workorder";
|
||||
item.FeatureID = Feature.WORK_ORDER;
|
||||
item.Title = "Work Order **New**";
|
||||
item.Title = "Work Order";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "WorkOrderMaintenance.aspx";
|
||||
item.IconPath = "img/workorder.png";
|
||||
@ -48,75 +98,93 @@ namespace IronIntel.Contractor.Users
|
||||
list.Add(item);
|
||||
|
||||
item = new NavigateItem();
|
||||
item.ID = "nav_preventative";
|
||||
item.FeatureID = Feature.PREVENTATIVE_MAINTENANCE;
|
||||
item.Title = "Absolute Hours Maintenance";
|
||||
item.ID = "nav_workorderhis";
|
||||
item.FeatureID = Feature.WORKORDERHISTORY;
|
||||
item.Title = "Work Order History";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "PreventativeMaintenance.aspx";
|
||||
item.PageUrl = "WorkOrderHistory.aspx";
|
||||
item.IconPath = "img/workorderhis.png";
|
||||
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.WORKORDERHISTORY) != null)
|
||||
list.Add(item);
|
||||
|
||||
item = new NavigateItem();
|
||||
item.ID = "nav_alertsmanagement";
|
||||
item.FeatureID = Feature.ALERTS_MANAGEMENT;
|
||||
item.Title = "Alerts Management";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "AlertsManagement.aspx";
|
||||
item.IconPath = "img/alert.png";
|
||||
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.ALERTS_MANAGEMENT) != null)
|
||||
list.Add(item);
|
||||
|
||||
item = new NavigateItem();
|
||||
item.ID = "nav_maintenanceschedule";
|
||||
item.FeatureID = Feature.PREVENTATIVE_MAINTENANCE;
|
||||
item.Title = "Maintenance Schedules";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "MaintenanceSchedulesManagement.aspx";
|
||||
item.IconPath = "img/preventative.png";
|
||||
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.PREVENTATIVE_MAINTENANCE) != null)
|
||||
list.Add(item);
|
||||
|
||||
item = new NavigateItem();
|
||||
item.ID = "nav_timebased";
|
||||
item.FeatureID = Feature.PREVENTATIVE_MAINTENANCE;
|
||||
item.Title = "Relative Time Maintenance";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "TimeBasedMaintenance.aspx";
|
||||
item.IconPath = "img/timebased.png";
|
||||
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.PREVENTATIVE_MAINTENANCE) != null)
|
||||
list.Add(item);
|
||||
|
||||
item = new NavigateItem();
|
||||
item.ID = "nav_hours";
|
||||
item.FeatureID = Feature.PREVENTATIVE_MAINTENANCE;
|
||||
item.Title = "Relative Hours Maintenance";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "HoursMaintenance.aspx";
|
||||
item.IconPath = "img/hours.png";
|
||||
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.PREVENTATIVE_MAINTENANCE) != null)
|
||||
list.Add(item);
|
||||
|
||||
item = new NavigateItem();
|
||||
item.ID = "nav_absolutedistance";
|
||||
item.FeatureID = Feature.PREVENTATIVE_MAINTENANCE;
|
||||
item.Title = "Absolute Distance Maintenance";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "AbsoluteDistanceMaintenance.aspx";
|
||||
item.IconPath = "img/preventative.png";
|
||||
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.PREVENTATIVE_MAINTENANCE) != null)
|
||||
list.Add(item);
|
||||
|
||||
item = new NavigateItem();
|
||||
item.FeatureID = Feature.PREVENTATIVE_MAINTENANCE;
|
||||
item.ID = "nav_relativedistance";
|
||||
item.Title = "Relative Distance Maintenance";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "RelativeDistanceMaintenance.aspx";
|
||||
item.IconPath = "img/hours.png";
|
||||
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.PREVENTATIVE_MAINTENANCE) != null)
|
||||
list.Add(item);
|
||||
|
||||
item = new NavigateItem();
|
||||
item.ID = "nav_record";
|
||||
item.FeatureID = Feature.PREVENTATIVE_MAINTENANCE;
|
||||
item.Title = "Maintenance Record **Legacy**";
|
||||
item.Title = "Maintenance Record";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "MaintanceRecordsManagement.aspx";
|
||||
item.IconPath = "img/record.png";
|
||||
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.PREVENTATIVE_MAINTENANCE) != null)
|
||||
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.PREVENTATIVE_MAINTENANCE) != null
|
||||
&& pmss.FirstOrDefault(m => m.Item1.Id == Feature.MAINTENANCE_RECORD) != null)
|
||||
list.Add(item);
|
||||
|
||||
item = new NavigateItem();
|
||||
item.ID = "nav_fuelrecord";
|
||||
item.FeatureID = Feature.FUEL_RECORDS;
|
||||
item.Title = "Fuel Records";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "FuelRecordManagement.aspx";
|
||||
item.IconPath = "img/fuelrecord.png";
|
||||
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.FUEL_RECORDS) != null)
|
||||
{
|
||||
item = new NavigateItem();
|
||||
item.ID = "nav_fuelrecord";
|
||||
item.FeatureID = Feature.FUEL_RECORDS;
|
||||
item.Title = "Fuel Records";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "FuelRecordManagement.aspx";
|
||||
item.IconPath = "img/fuelrecord.png";
|
||||
list.Add(item);
|
||||
}
|
||||
|
||||
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.CUSTOMER_RECORD) != null)
|
||||
{
|
||||
item = new NavigateItem();
|
||||
item.ID = "nav_customerrecord";
|
||||
item.FeatureID = Feature.CUSTOMER_RECORD;
|
||||
item.Title = "Customer Record";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "CustomerRecordManagement.aspx";
|
||||
item.IconPath = "img/customerrecord.png?v=1";
|
||||
list.Add(item);
|
||||
|
||||
item = new NavigateItem();
|
||||
item.ID = "nav_surveymanagementresult";
|
||||
item.FeatureID = Feature.WORKORDERSURVEYS;
|
||||
item.Title = "Survey Management/Result";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "SurveyManagement.aspx";
|
||||
list.Add(item);
|
||||
|
||||
item = new NavigateItem();
|
||||
item.ID = "nav_wosurveytemplate";
|
||||
item.FeatureID = -1;
|
||||
item.Title = "Templates";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "SurveyTemplateManagement.aspx";
|
||||
list.Add(item);
|
||||
|
||||
item = new NavigateItem();
|
||||
item.ID = "nav_wosurveytemplatereport";
|
||||
item.FeatureID = -1;
|
||||
item.Title = "Report";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "SurveyTemplateReport.aspx";
|
||||
list.Add(item);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
@ -178,7 +246,8 @@ namespace IronIntel.Contractor.Users
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "CurfewManage.aspx";
|
||||
item.IconPath = "img/curfew.png";
|
||||
list.Add(item);
|
||||
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.CURFEW_CONFIG) != null)
|
||||
list.Add(item);
|
||||
|
||||
if (user.UserType == UserTypes.SupperAdmin)
|
||||
{
|
||||
@ -189,7 +258,8 @@ namespace IronIntel.Contractor.Users
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "CurfewMovementTolerance.aspx";
|
||||
item.IconPath = "img/curfewmovementtolerance.png";
|
||||
list.Add(item);
|
||||
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.CURFEW_CONFIG) != null)
|
||||
list.Add(item);
|
||||
}
|
||||
|
||||
return list;
|
||||
@ -250,6 +320,70 @@ namespace IronIntel.Contractor.Users
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<NavigateItem> GetCredentialNavigateItems(Tuple<Feature, Permissions>[] pmss, UserInfo user)
|
||||
{
|
||||
List<NavigateItem> list = new List<NavigateItem>();
|
||||
NavigateItem item = new NavigateItem();
|
||||
item.ID = "nav_credential";
|
||||
item.FeatureID = Feature.CREDENTIALS;
|
||||
item.Title = "Credentials";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "ManageCredential.aspx";
|
||||
item.IconPath = "img/credential.png";
|
||||
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.CREDENTIALS) != null)
|
||||
list.Add(item);
|
||||
|
||||
item = new NavigateItem();
|
||||
item.ID = "nav_jdlink";
|
||||
item.FeatureID = Feature.JDLINK;
|
||||
item.Title = "JD Link";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "ManageJDLink.aspx";
|
||||
item.IconPath = "img/jdlink.png";
|
||||
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.JDLINK) != null)
|
||||
list.Add(item);
|
||||
|
||||
//item = new NavigateItem();
|
||||
//item.ID = "nav_jdnotification";
|
||||
//item.FeatureID = Feature.JDNOTIFICATION;
|
||||
//item.Title = "JohnDeere Notifications";
|
||||
//item.Url = Url + "#" + item.ID;
|
||||
//item.PageUrl = "ManageJDNotifications.aspx";
|
||||
//item.IconPath = "img/jdnotifications.png";
|
||||
//if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.JDNOTIFICATION) != null)
|
||||
// list.Add(item);
|
||||
|
||||
item = new NavigateItem();
|
||||
item.ID = "nav_apicredential";
|
||||
item.FeatureID = Feature.APICREDENTIALS;
|
||||
item.Title = "API Credentials";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "ManageAPICredential.aspx";
|
||||
item.IconPath = "img/apicredential.png";
|
||||
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.APICREDENTIALS) != null)
|
||||
list.Add(item);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public List<NavigateItem> GetOTRConfigNavigateItems(Tuple<Feature, Permissions>[] pmss, UserInfo user)
|
||||
{
|
||||
List<NavigateItem> list = new List<NavigateItem>();
|
||||
NavigateItem item = new NavigateItem();
|
||||
item.ID = "nav_manageharshdriving";
|
||||
item.FeatureID = Feature.HARSH_DRIVING;
|
||||
item.Title = "Manage Harsh Driving";
|
||||
item.Url = Url + "#" + item.ID;
|
||||
item.PageUrl = "ManageHarshDriving.aspx";
|
||||
item.IconPath = "img/harshdriving.png";
|
||||
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.HARSH_DRIVING) != null)
|
||||
list.Add(item);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class NavigateItem
|
||||
@ -270,6 +404,14 @@ namespace IronIntel.Contractor.Users
|
||||
public string IconPath { get; set; }
|
||||
}
|
||||
|
||||
public class CredentialNavigateItem
|
||||
{
|
||||
public string ID { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Url { get; set; }
|
||||
public string IconPath { get; set; }
|
||||
}
|
||||
|
||||
public enum AppModuleType
|
||||
{
|
||||
System,
|
||||
|
@ -5,9 +5,8 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Data;
|
||||
using Foresight.Data;
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services;
|
||||
using Foresight.Fleet.Services.User;
|
||||
using Foresight.Fleet.Services.Styles;
|
||||
|
||||
namespace IronIntel.Contractor.Users
|
||||
{
|
||||
@ -37,6 +36,14 @@ namespace IronIntel.Contractor.Users
|
||||
moudles.Insert(0, FeatureModule.Modules[0]);
|
||||
foreach (var m in moudles)
|
||||
{
|
||||
if (m.Id == FeatureModule.MODULE_TEAM && user.UserType != UserTypes.SupperAdmin)
|
||||
continue;
|
||||
|
||||
if (m.Id == FeatureModule.MODULE_MANAGEASSETS && pmss.FirstOrDefault(p => p.Item1.Id == Feature.MANAGE_ASSETS) == null)
|
||||
continue;
|
||||
//if (m.Id == FeatureModule.MODULE_JOBSITES && pmss.FirstOrDefault(p => p.Item1.Id == Feature.JOB_SITES) == null)
|
||||
// continue;
|
||||
|
||||
AppModuleInfo ami = new AppModuleInfo();
|
||||
ami.ID = m.Id.ToString();
|
||||
ami.Name = m.Name;
|
||||
@ -49,14 +56,19 @@ namespace IronIntel.Contractor.Users
|
||||
ami.Visible = true;
|
||||
ami.ModuleType = AppModuleType.System;
|
||||
|
||||
if (m.Id == FeatureModule.MODULE_ASSETHEALTH)
|
||||
if (m.Id == FeatureModule.MODULE_JOBSITES)
|
||||
ami.SubItems = ami.GetJobsiteNavigateItems(pmss);
|
||||
else if (m.Id == FeatureModule.MODULE_ASSETHEALTH)
|
||||
ami.SubItems = ami.GetMaintenanceNavigateItems(pmss);
|
||||
else if (m.Id == FeatureModule.MODULE_SECURITY)
|
||||
ami.SubItems = ami.GetSecurityNavigateItems(pmss, user);
|
||||
else if (m.Id == FeatureModule.MODULE_MANAGEASSETS)
|
||||
ami.SubItems = ami.GetAssetsNavigateItems(pmss, user);
|
||||
else if (m.Id == FeatureModule.MODULE_CREDENTIAL)
|
||||
ami.SubItems = ami.GetCredentialNavigateItems(pmss, user);
|
||||
|
||||
list.Add(ami);
|
||||
if (ami.SubItems == null || ami.SubItems.Count > 0)
|
||||
list.Add(ami);
|
||||
}
|
||||
AppModuleInfo[] wsps = GetFICWorkspace(user);
|
||||
foreach (AppModuleInfo ap in wsps)
|
||||
@ -82,22 +94,6 @@ namespace IronIntel.Contractor.Users
|
||||
return false;
|
||||
}
|
||||
|
||||
private static AppModuleInfo ConvertToAppModule(DataRow dr)
|
||||
{
|
||||
AppModuleInfo ai = new AppModuleInfo();
|
||||
ai.ID = FIDbAccess.GetFieldString(dr["ID"], string.Empty);
|
||||
ai.Name = FIDbAccess.GetFieldString(dr["APPMODULENAME"], string.Empty);
|
||||
ai.Description = FIDbAccess.GetFieldString(dr["APPMODULEDESC"], string.Empty);
|
||||
ai.Url = FIDbAccess.GetFieldString(dr["URL"], string.Empty);
|
||||
ai.IconPath = FIDbAccess.GetFieldString(dr["ICONPATH"], string.Empty);
|
||||
ai.BackColor = FIDbAccess.GetFieldString(dr["BACKCOLOR"], string.Empty);
|
||||
ai.ForeColor = FIDbAccess.GetFieldString(dr["FORECOLOR"], string.Empty);
|
||||
ai.OpenInNewWindow = FIDbAccess.GetFieldInt(dr["OPENINNEWWINDOW"], 0) == 1;
|
||||
ai.Visible = true;
|
||||
ai.ModuleType = AppModuleType.System;
|
||||
return ai;
|
||||
}
|
||||
|
||||
public static AppModuleInfo[] GetFICWorkspace(UserInfo user)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(SystemParams.FICDbConnectionString))
|
||||
|
@ -1,5 +1,10 @@
|
||||
using FI.FIC;
|
||||
using FI.FIC.Contracts.DataObjects.BaseObject;
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using Foresight.Fleet.Services.JobSite;
|
||||
using Foresight.Fleet.Services.User;
|
||||
using Foresight.Standard;
|
||||
using IronIntel.Contractor.Machines;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -10,7 +15,7 @@ namespace IronIntel.Contractor.Users
|
||||
{
|
||||
public class UserInfo
|
||||
{
|
||||
private static string[] ContactTypeNames = { "Foreman", "Driver", "Inventory Manager", "Rental Manager", "Service Manager", "Fleet Manager", "Technician", "Other" };
|
||||
private static string[] ContactTypeNames = { "Foreman", "Driver", "Inventory Manager", "Rental Manager", "Service Manager", "Fleet Manager", "Technician", "Advisor", "Other" };
|
||||
public string IID { get; set; }
|
||||
public string ID { get; set; }
|
||||
public string DisplayName { get; set; }
|
||||
@ -18,6 +23,7 @@ namespace IronIntel.Contractor.Users
|
||||
public bool IsUser { get; set; }
|
||||
public ContactTypes ContactType { get; set; }
|
||||
public string Mobile { get; set; }
|
||||
public string MobilePhoneDisplayText { get; set; }
|
||||
public string BusinessPhone { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public bool Active { get; set; }
|
||||
@ -25,6 +31,7 @@ namespace IronIntel.Contractor.Users
|
||||
public string TransPass { get; set; }
|
||||
public string ManagerIID { get; set; }
|
||||
public string ManagerName { get; set; }
|
||||
public bool AssignedWorkOrders { get; set; }
|
||||
public bool EmailOptOut { get; set; }
|
||||
public bool InspectEmailList { get; set; }
|
||||
public bool TeamIntelligenceUser { get; set; }
|
||||
@ -35,16 +42,29 @@ namespace IronIntel.Contractor.Users
|
||||
public bool AllowLoginIntoPC { get; set; }
|
||||
public bool AllowLoginIntoInspectMobile { get; set; }
|
||||
public bool AllowLoginIntoFleetMobile { get; set; }
|
||||
public bool AllowMobileBarcodeScanning { get; set; }
|
||||
public string PreferredLanguage { get; set; }
|
||||
public string TimeZone { get; set; }
|
||||
public string LandingPage { get; set; }
|
||||
public string GroupNamesStr { get { return (GroupNames == null || GroupNames.Length == 0) ? "" : string.Join(",", GroupNames); } }
|
||||
|
||||
public long[] AssetIDs { get; set; }
|
||||
public string[] AssetGroupIDs { get; set; }
|
||||
public string[] JobsiteIDs { get; set; }
|
||||
public string[] AssetTypeIDs { get; set; }
|
||||
public int[] LocationIds { get; set; }
|
||||
public int[] DepartmentIds { get; set; }
|
||||
public bool WorkOrderFollower { get; set; }
|
||||
public bool ExcelExports { get; set; }
|
||||
public LoginVerifyTypes LoginVerifyType { get; set; } = LoginVerifyTypes.OrganizationSetting;
|
||||
public UserInfo[] Managers { get; set; }
|
||||
public string ContactTypeName
|
||||
{
|
||||
get
|
||||
{
|
||||
int cType = (int)ContactType;
|
||||
if (cType > 7)
|
||||
cType = 7;
|
||||
if (cType > 8)
|
||||
cType = 8;
|
||||
return ContactTypeNames[cType];
|
||||
}
|
||||
}
|
||||
@ -56,8 +76,12 @@ namespace IronIntel.Contractor.Users
|
||||
public SubscribeMessageByEmail Subscribe { get; set; }
|
||||
public KeyValuePair<int, Foresight.Fleet.Services.User.Permissions[]>[] Features { get; set; }
|
||||
|
||||
public EmailSchedule Schedule { get; set; }
|
||||
public string UserAlertFilter { get; set; }
|
||||
|
||||
public EmailSchedule Schedule { get; set; }
|
||||
public StringKeyValue[] MessageTypes { get; set; }
|
||||
public UserFilterTemplateItem[] FilterTemplates { get; set; }
|
||||
public int[] DeleteFilterTemplates { get; set; }
|
||||
}
|
||||
|
||||
public enum UserTypes
|
||||
@ -76,6 +100,7 @@ namespace IronIntel.Contractor.Users
|
||||
ServiceManager = 4,
|
||||
FleetManager = 5,
|
||||
Technician = 6,
|
||||
Advisor = 7,
|
||||
Other = 100
|
||||
}
|
||||
|
||||
@ -85,4 +110,15 @@ namespace IronIntel.Contractor.Users
|
||||
public string ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
public class UserFilterTemplateItem
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public AssetListItemInfo[] Assets { get; set; }
|
||||
public MachineGroup[] AssetGroups { get; set; }
|
||||
public AssetType[] AssetTypes { get; set; }
|
||||
public JobSiteItem[] Jobsites { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,12 +2,12 @@
|
||||
using FI.FIC.Contracts.DataObjects;
|
||||
using FI.FIC.Contracts.DataObjects.BaseObject;
|
||||
using FI.FIC.Contracts.DataObjects.Enumeration;
|
||||
using FI.FIC.Models;
|
||||
using Foresight.Data;
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using Foresight.Fleet.Services.Customer;
|
||||
using Foresight.Fleet.Services.User;
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Services.Customers;
|
||||
using IronIntel.Services.Users;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
@ -17,11 +17,11 @@ namespace IronIntel.Contractor.Users
|
||||
{
|
||||
public static class UserManagement
|
||||
{
|
||||
public static UserInfo[] GetUsers(string companyid = null)
|
||||
public static UserInfo[] GetUsers(string companyid = null, string filter = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
var users = FleetServiceClientHelper.CreateClient<UserQueryClient>(companyid, string.Empty).GetUsersByCustomerID(companyid, "");
|
||||
var users = FleetServiceClientHelper.CreateClient<UserQueryClient>(companyid, string.Empty).GetUsersByCustomerID(companyid, filter);
|
||||
if (users == null || users.Length == 0)
|
||||
return new UserInfo[0];
|
||||
|
||||
@ -35,16 +35,6 @@ namespace IronIntel.Contractor.Users
|
||||
list.Add(u);
|
||||
}
|
||||
return list.ToArray();
|
||||
|
||||
//const string SQL = @"SELECT USERIID,USERID,USERNAME,USERTYPE,EMAIL,ACTIVE,MOBILE,BUSINESSPHONE,NOTES FROM USERS";
|
||||
//FIDbAccess db = SystemParams.GetDbInstance();
|
||||
//DataTable dt = db.GetDataTableBySQL(SQL);
|
||||
//List<UserInfo> list = new List<UserInfo>();
|
||||
//foreach (DataRow dr in dt.Rows)
|
||||
//{
|
||||
// list.Add(ConvertToUserInfo(dr));
|
||||
//}
|
||||
//return list.ToArray();
|
||||
}
|
||||
|
||||
|
||||
@ -86,6 +76,30 @@ namespace IronIntel.Contractor.Users
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public static UserInfo[] GetSalespersons(string sessionid, string companyid = null, string filter = "")
|
||||
{
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
var users = FleetServiceClientHelper.CreateClient<UserQueryClient>(companyid, sessionid).GetUsersByCustomerID(companyid, "");
|
||||
List<UserInfo> list = new List<UserInfo>();
|
||||
foreach (var user in users)
|
||||
{
|
||||
if (user.Active)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filter))
|
||||
list.Add(ConvertUserItem(user));
|
||||
else
|
||||
{
|
||||
if (user.ID.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0
|
||||
|| user.Name.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0
|
||||
|| user.FOB.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0)
|
||||
list.Add(ConvertUserItem(user));
|
||||
}
|
||||
}
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
private static UserInfo ConvertUserItem(Foresight.Fleet.Services.User.UserInfo user)
|
||||
{
|
||||
if (user == null)
|
||||
@ -98,12 +112,14 @@ namespace IronIntel.Contractor.Users
|
||||
u.Active = user.Active;
|
||||
u.TextAddress = user.TextAddress;
|
||||
u.Mobile = user.Mobile;
|
||||
u.MobilePhoneDisplayText = user.MobilePhoneDisplayText;
|
||||
u.BusinessPhone = user.BusinessPhone;
|
||||
u.Notes = user.Remark;
|
||||
u.IsUser = user.IsUser;
|
||||
u.ContactType = (ContactTypes)user.ContactType;
|
||||
u.ManagerIID = user.ManagerIID;
|
||||
u.ManagerName = user.ManagerName;
|
||||
u.AssignedWorkOrders = user.AssignedWorkOrders;
|
||||
u.EmailOptOut = user.EmailOptOut;
|
||||
u.InspectEmailList = user.InspectEmailList;
|
||||
u.TeamIntelligenceUser = user.TeamIntelligenceUser;
|
||||
@ -112,6 +128,13 @@ namespace IronIntel.Contractor.Users
|
||||
u.AllowLoginIntoPC = user.AllowLoginIntoPC;
|
||||
u.AllowLoginIntoFleetMobile = user.AllowLoginIntoFleetMobile;
|
||||
u.AllowLoginIntoInspectMobile = user.AllowLoginIntoInspectMobile;
|
||||
u.AllowMobileBarcodeScanning = user.AllowMobileBarcodeScanning;
|
||||
u.PreferredLanguage = user.PreferredLanguage;
|
||||
u.LoginVerifyType = user.LoginVerifyType;
|
||||
u.TimeZone = user.TimeZone;
|
||||
if (!string.IsNullOrWhiteSpace(u.ManagerIID))
|
||||
u.Managers = new UserInfo[] { new UserInfo() { IID = u.ManagerIID, DisplayName = u.ManagerName } };
|
||||
|
||||
return u;
|
||||
}
|
||||
|
||||
@ -133,6 +156,7 @@ namespace IronIntel.Contractor.Users
|
||||
u.IsUser = user.IsUser;
|
||||
u.ContactType = (Foresight.Fleet.Services.User.ContactTypes)user.ContactType;
|
||||
u.ManagerIID = user.ManagerIID;
|
||||
u.AssignedWorkOrders = user.AssignedWorkOrders;
|
||||
u.EmailOptOut = user.EmailOptOut;
|
||||
u.InspectEmailList = user.InspectEmailList;
|
||||
u.TeamIntelligenceUser = user.TeamIntelligenceUser;
|
||||
@ -141,18 +165,23 @@ namespace IronIntel.Contractor.Users
|
||||
u.AllowLoginIntoPC = user.AllowLoginIntoPC;
|
||||
u.AllowLoginIntoFleetMobile = user.AllowLoginIntoFleetMobile;
|
||||
u.AllowLoginIntoInspectMobile = user.AllowLoginIntoInspectMobile;
|
||||
u.AllowMobileBarcodeScanning = user.AllowMobileBarcodeScanning;
|
||||
u.PreferredLanguage = user.PreferredLanguage;
|
||||
u.LoginVerifyType = user.LoginVerifyType;
|
||||
u.TimeZone = user.TimeZone;
|
||||
return u;
|
||||
}
|
||||
|
||||
public static UserInfo[] GetUnmanagementUsers()
|
||||
{
|
||||
const string SQL = @"SELECT USERIID,USERID,USERNAME,USERTYPE,EMAIL,ACTIVE,MOBILE,BUSINESSPHONE,NOTES FROM USERS where isnull(ISUSER,0)=1 and (USERTYPE=0 or USERTYPE=1)";
|
||||
FIDbAccess db = SystemParams.GetDbInstance();
|
||||
DataTable dt = db.GetDataTableBySQL(SQL);
|
||||
var users = FleetServiceClientHelper.CreateClient<UserQueryClient>(SystemParams.CompanyID).GetUsersByCustomerID(SystemParams.CompanyID, "");
|
||||
List<UserInfo> list = new List<UserInfo>();
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
foreach (var user in users)
|
||||
{
|
||||
list.Add(ConvertToUserInfo(dr));
|
||||
if (user.IsUser && user.UserType < Foresight.Fleet.Services.User.UserTypes.Admin)
|
||||
{
|
||||
list.Add(ConvertUserItem(user));
|
||||
}
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
@ -173,12 +202,6 @@ namespace IronIntel.Contractor.Users
|
||||
{
|
||||
var dealerusers = GetUsers(dealer.ID);
|
||||
ls.AddRange(dealerusers);
|
||||
//LoginProvider lp = SystemParams.GetLoginProvider();
|
||||
//UserInfoEx[] dealerusers = lp.GetAllUsersByCustomerID(dealer.ID);
|
||||
//foreach (UserInfoEx u in dealerusers)
|
||||
//{
|
||||
// ls.Add(ConvertToServiceUserInfo(u));
|
||||
//}
|
||||
}
|
||||
}
|
||||
return ls.ToArray();
|
||||
@ -193,30 +216,6 @@ namespace IronIntel.Contractor.Users
|
||||
list.Add(ConvertUserItem(user));
|
||||
}
|
||||
return list.ToArray();
|
||||
|
||||
//LoginProvider lp = SystemParams.GetLoginProvider();
|
||||
//UserInfoEx[] susers = lp.GetAllUsersByCustomerID("Foresight");
|
||||
|
||||
//List<UserInfo> list = new List<UserInfo>();
|
||||
//foreach (UserInfoEx u in susers)
|
||||
//{
|
||||
// UserInfo user = ConvertToServiceUserInfo(u);
|
||||
// list.Add(user);
|
||||
//}
|
||||
//return list.ToArray();
|
||||
}
|
||||
|
||||
private static UserInfo ConvertToServiceUserInfo(UserInfoEx suer)
|
||||
{
|
||||
UserInfo user = new UserInfo();
|
||||
user.IID = suer.UID;
|
||||
user.ID = suer.ID;
|
||||
user.DisplayName = suer.Name;
|
||||
user.Mobile = suer.Mobile;
|
||||
user.BusinessPhone = suer.BusinessPhone;
|
||||
user.Active = suer.Active;
|
||||
user.UserType = (UserTypes)3;
|
||||
return user;
|
||||
}
|
||||
|
||||
private static UserInfo ConvertToUserInfo(DataRow dr)
|
||||
@ -234,21 +233,6 @@ namespace IronIntel.Contractor.Users
|
||||
return ui;
|
||||
}
|
||||
|
||||
private static UserInfo GetLocalUserInfo(string sessionid, string iid)
|
||||
{
|
||||
var user = FleetServiceClientHelper.CreateClient<UserQueryClient>(sessionid).GetUserByIID(iid);
|
||||
return ConvertUserItem(user);
|
||||
//const string SQL = "select * from USERS where USERIID={0}";
|
||||
|
||||
//FIDbAccess db = SystemParams.GetDbInstance();
|
||||
//DataTable dt = db.GetDataTableBySQL(SQL, iid);
|
||||
//if (dt.Rows.Count == 0)
|
||||
//{
|
||||
// return null;
|
||||
//}
|
||||
//return ConvertToUserInfo(dt.Rows[0]);
|
||||
}
|
||||
|
||||
public static UserInfo GetUserBySessionID(string sessionid)
|
||||
{
|
||||
var ls = FleetServiceClientHelper.CreateClient<UserQueryClient>(sessionid).GetLoginSession(sessionid);
|
||||
@ -264,78 +248,28 @@ namespace IronIntel.Contractor.Users
|
||||
ui.DisplayName = ls.User.Name;
|
||||
ui.Active = true;
|
||||
ui.UserType = UserTypes.SupperAdmin;
|
||||
ui.TimeZone = ls.User.TimeZone;
|
||||
return ui;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ConvertUserItem(ls.User);
|
||||
}
|
||||
|
||||
//LoginProvider lp = SystemParams.GetLoginProvider();
|
||||
//LoginSession ls = lp.GetLoginSession(sessionid);
|
||||
|
||||
//if (ls == null)
|
||||
//{
|
||||
// return null;
|
||||
//}
|
||||
//if (ls.User.IsForesightUser)
|
||||
//{
|
||||
// UserInfo ui = new UserInfo();
|
||||
// ui.IID = ls.User.UID;
|
||||
// ui.ID = ls.User.ID;
|
||||
// ui.DisplayName = ls.User.Name;
|
||||
// ui.Active = true;
|
||||
// ui.UserType = UserTypes.SupperAdmin;
|
||||
// return ui;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// return GetLocalUserInfo(ls.User.UID);
|
||||
//}
|
||||
}
|
||||
|
||||
public static UserInfo GetUserByIID(string iid)
|
||||
{
|
||||
var user = FleetServiceClientHelper.CreateClient<UserQueryClient>().GetUserByIID(iid);
|
||||
return ConvertUserItem(user);
|
||||
|
||||
//LoginProvider lp = SystemParams.GetLoginProvider();
|
||||
//UserInfoEx ui1 = lp.GetUserInfoEx(iid);
|
||||
//if (ui1 == null)
|
||||
//{
|
||||
// return null;
|
||||
//}
|
||||
|
||||
//if (ui1.IsForesightUser)
|
||||
//{
|
||||
// UserInfo ui = new UserInfo();
|
||||
// ui.IID = ui1.UID;
|
||||
// ui.ID = ui1.ID;
|
||||
// ui.DisplayName = ui1.Name;
|
||||
// ui.Active = true;
|
||||
// ui.UserType = UserTypes.SupperAdmin;
|
||||
// return ui;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// return GetLocalUserInfo(iid);
|
||||
//}
|
||||
}
|
||||
|
||||
public static UserInfo GetUserByID(string userid)
|
||||
{
|
||||
var user = FleetServiceClientHelper.CreateClient<UserQueryClient>().GetUserByUserID(userid);
|
||||
return ConvertUserItem(user);
|
||||
//LoginProvider lp = SystemParams.GetLoginProvider();
|
||||
//UserInfoEx ui1 = lp.GetUserInfoExByUserID(userid);
|
||||
//if (ui1 == null)
|
||||
//{
|
||||
// return null;
|
||||
//}
|
||||
//return GetUserByIID(ui1.UID);
|
||||
}
|
||||
|
||||
public static string AddUser(UserInfo ui, string password, string addby, string sessionid, string clienthost)
|
||||
public static string AddUser(UserInfo ui, string password, string addby, string sessionid, string clienthost, byte[] avadarBytes)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -346,6 +280,12 @@ namespace IronIntel.Contractor.Users
|
||||
client.SessionID = sessionid;
|
||||
client.ClientHost = clienthost;
|
||||
user = client.AddNewUser(user, password, addby);
|
||||
if (avadarBytes != null)
|
||||
{
|
||||
avadarBytes = Helper.GetThumbImg(avadarBytes, 300, 300);
|
||||
client.SetUserAvatar(user.UID, avadarBytes);
|
||||
}
|
||||
|
||||
return user.UID;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -353,47 +293,10 @@ namespace IronIntel.Contractor.Users
|
||||
SystemParams.WriteLog("Error", typeof(UserManagement).FullName + ".AddUser", "Add new user failed: " + ui.ID, ex.ToString());
|
||||
throw;
|
||||
}
|
||||
|
||||
//const string SQL = @"insert into USERS(USERIID,USERID,USERNAME,USERTYPE,EMAIL,ACTIVE,MOBILE,BUSINESSPHONE,NOTES) values({0},{1},{2},{3},{4},{5},{6},{7},{8})";
|
||||
//try
|
||||
//{
|
||||
// LoginProvider lp = SystemParams.GetLoginProvider();
|
||||
// FIDbAccess db = SystemParams.GetDbInstance();
|
||||
// UserInfoEx user = ConvertUserInfoTOUserInfoEx(ui);
|
||||
// if (!string.IsNullOrWhiteSpace(password))
|
||||
// {
|
||||
// ui.IID = lp.RegisterUser(user, password);
|
||||
// db.ExecSQL(SQL, ui.IID, ui.ID, ui.DisplayName, (int)ui.UserType, ui.ID, ui.Active ? 1 : 0, ui.Mobile, ui.BusinessPhone, ui.Notes);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ui.IID = lp.RegisterUser(user, Guid.NewGuid().ToString());
|
||||
// db.ExecSQL(SQL, ui.IID, ui.ID, ui.DisplayName, (int)ui.UserType, ui.ID, ui.Active ? 1 : 0, ui.Mobile, ui.BusinessPhone, ui.Notes);
|
||||
// lp.ForgotPassword(ui.ID);
|
||||
// }
|
||||
// return ui.IID;
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// SystemParams.WriteLog("Error", typeof(UserManagement).FullName + ".AddUserInfo", "Add new user failed: " + ui.ID, ex.ToString());
|
||||
// throw;
|
||||
//}
|
||||
}
|
||||
|
||||
private static UserInfoEx ConvertUserInfoTOUserInfoEx(UserInfo ui)
|
||||
{
|
||||
UserInfoEx user = new UserInfoEx();
|
||||
user.UID = ui.IID;
|
||||
user.ID = ui.ID;
|
||||
user.Name = ui.DisplayName;
|
||||
user.Mobile = ui.Mobile;
|
||||
user.BusinessPhone = ui.BusinessPhone;
|
||||
user.Active = ui.Active;
|
||||
user.CompanyID = SystemParams.CompanyID;
|
||||
return user;
|
||||
}
|
||||
|
||||
public static void UpdateUserInfo(UserInfo ui, string updatedby, string sessionid, string clienthost)
|
||||
public static void UpdateUserInfo(UserInfo ui, string updatedby, string sessionid, string clienthost, byte[] avadarBytes)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -404,28 +307,30 @@ namespace IronIntel.Contractor.Users
|
||||
client.SessionID = sessionid;
|
||||
client.ClientHost = clienthost;
|
||||
client.UpdateUser(user, updatedby);
|
||||
if (avadarBytes != null)
|
||||
{
|
||||
avadarBytes = Helper.GetThumbImg(avadarBytes, 300, 300);
|
||||
client.SetUserAvatar(user.UID, avadarBytes);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("Error", typeof(UserManagement).FullName + ".UpdateUserInfo", "Update user failed: " + ui.IID, ex.ToString());
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
//const string SQL = @" update USERS set USERNAME={0},MOBILE={1},BUSINESSPHONE={2},ACTIVE={3},USERTYPE={4},NOTES={5} where USERIID={6}";
|
||||
//try
|
||||
//{
|
||||
// LoginProvider lp = SystemParams.GetLoginProvider();
|
||||
// UserInfoEx user = ConvertUserInfoTOUserInfoEx(ui);
|
||||
// lp.UpdateUser(user);
|
||||
// FIDbAccess db = SystemParams.GetDbInstance();
|
||||
// db.ExecSQL(SQL, ui.DisplayName, ui.Mobile, ui.BusinessPhone, ui.Active ? 1 : 0, ui.UserType, ui.Notes, ui.IID);
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// SystemParams.WriteLog("Error", typeof(UserManagement).FullName + ".UpdateUserInfo", "Update user failed: " + ui.IID, ex.ToString());
|
||||
// throw;
|
||||
//}
|
||||
}
|
||||
public static void SetUserAvatar(string sessionid, string uid, byte[] avadarBytes)
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = FleetServiceClientHelper.CreateClient<UserQueryClient>(sessionid);
|
||||
client.SetUserAvatar(uid, avadarBytes);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("Error", typeof(UserManagement).FullName + ".SetUserAvatar", "Set user Avatar failed: " + uid, ex.ToString());
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ResetPassword(string useriid, string password, string resetby, string sessionid, string clienthost)
|
||||
@ -434,20 +339,6 @@ namespace IronIntel.Contractor.Users
|
||||
client.SessionID = sessionid;
|
||||
client.ClientHost = clienthost;
|
||||
client.ResetPassword(useriid, password, true, resetby);
|
||||
|
||||
//const string SQL = "select USERID from USERS where USERIID={0}";
|
||||
//FIDbAccess db = SystemParams.GetDbInstance();
|
||||
//string userid = db.GetRC1BySQL(SQL, useriid).ToString();
|
||||
//try
|
||||
//{
|
||||
// LoginProvider lp = SystemParams.GetLoginProvider();
|
||||
// lp.ForgotPassword(userid);
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// SystemParams.WriteLog("Error", typeof(UserManagement).FullName + ".ResetPassword", "Reset Password failed: " + useriid, ex.ToString());
|
||||
// throw;
|
||||
//}
|
||||
}
|
||||
|
||||
public static bool CanDeleteUser(string useriid)
|
||||
@ -456,6 +347,13 @@ namespace IronIntel.Contractor.Users
|
||||
return true;
|
||||
}
|
||||
|
||||
public static byte[] GetUserAvatar(string sessionid, string useriid)
|
||||
{
|
||||
|
||||
var client = FleetServiceClientHelper.CreateClient<UserQueryClient>(sessionid);
|
||||
return client.GetUserAvatar(useriid);
|
||||
}
|
||||
|
||||
|
||||
#region user group
|
||||
|
||||
@ -515,26 +413,6 @@ namespace IronIntel.Contractor.Users
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void SaveUserGroups(string userIID, string[] groupids)
|
||||
{
|
||||
if (groupids == null) return;//groupids为null表示前端group没有加载,不修改用户的Group.
|
||||
const string SQL_map = "insert into USERGROUPMAP(GROUPID,USERIID) values({0},{1})";
|
||||
const string SQL_del = "delete from USERGROUPMAP where USERIID={0}";
|
||||
|
||||
using (FISqlTransaction tran = new FISqlTransaction(SystemParams.DataDbConnectionString))
|
||||
{
|
||||
tran.ExecSQL(SQL_del, userIID);
|
||||
if (groupids.Length > 0)
|
||||
{
|
||||
foreach (string id in groupids)
|
||||
{
|
||||
tran.ExecSQL(SQL_map, id, userIID);
|
||||
}
|
||||
}
|
||||
tran.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddGroup(UserGroupInfo gi)
|
||||
{
|
||||
const string SQL_group = "insert into USERGROUPS(GROUPID,GROUPNAME,NOTES) values({0},{1},{2})";
|
||||
@ -555,7 +433,6 @@ namespace IronIntel.Contractor.Users
|
||||
}
|
||||
tran.Commit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void UpdateGroup(UserGroupInfo gi)
|
||||
@ -643,49 +520,7 @@ namespace IronIntel.Contractor.Users
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region User Machines/Jobsite
|
||||
|
||||
public static void SaveUserMachines(string uid, string[] machineids)
|
||||
{
|
||||
const string SQL_D = "delete USERMACHINEMAP where USERIID={0}";
|
||||
const string SQL = @"insert into USERMACHINEMAP(USERIID,MACHINEID) values ({0},{1})";
|
||||
|
||||
FIDbAccess db = SystemParams.GetDbInstance();
|
||||
db.ExecSQL(SQL_D, uid);
|
||||
|
||||
foreach (var mid in machineids)
|
||||
{
|
||||
db.ExecSQL(SQL, uid, mid);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveUserJobsites(string uid, string[] jobsiteids)
|
||||
{
|
||||
const string SQL_D = "delete USERJOBSITEMAP where USERIID={0}";
|
||||
const string SQL = @"insert into USERJOBSITEMAP(USERIID,JOBSITEID) values ({0},{1})";
|
||||
|
||||
FIDbAccess db = SystemParams.GetDbInstance();
|
||||
db.ExecSQL(SQL_D, uid);
|
||||
|
||||
foreach (var jsid in jobsiteids)
|
||||
{
|
||||
db.ExecSQL(SQL, uid, jsid);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveMachineUsers(string machineid, string[] uids, FISqlConnection db = null)
|
||||
{
|
||||
const string SQL_D = "delete USERMACHINEMAP where MACHINEID={0}";
|
||||
const string SQL = @"insert into USERMACHINEMAP(USERIID,MACHINEID) values ({0},{1})";
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
db.ExecSQL(SQL_D, machineid);
|
||||
|
||||
foreach (var uid in uids)
|
||||
{
|
||||
db.ExecSQL(SQL, uid, machineid);
|
||||
}
|
||||
}
|
||||
#region User Machines/Jobsite/MachineType/Department/Location
|
||||
|
||||
public static UserInfo[] GetUsersByAssetID(string sessionid, long assetid, string companyid)
|
||||
{
|
||||
@ -700,6 +535,65 @@ namespace IronIntel.Contractor.Users
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public static UserInfo[] GetWorkOrderAssignToUsers(string sessionid, string companyid, long assetid, int locid, int depid)
|
||||
{
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
var users = FleetServiceClientHelper.CreateClient<AssetQueryClient>(companyid, sessionid).GetUsersAvailableForAsset(companyid, assetid);
|
||||
var cusers = FleetServiceClientHelper.CreateClient<AssetDataAdjustClient>(companyid, sessionid).GetAssetContacts(companyid, assetid);
|
||||
|
||||
List<Foresight.Fleet.Services.User.UserInfo> allusers = new List<Foresight.Fleet.Services.User.UserInfo>();
|
||||
if (users != null && users.Length > 0)
|
||||
allusers.AddRange(users);
|
||||
if (cusers != null && cusers.Length > 0)
|
||||
allusers.AddRange(cusers);
|
||||
|
||||
string[] depandlocusers = null;
|
||||
if (locid > 0 || depid > 0)
|
||||
depandlocusers = FleetServiceClientHelper.CreateClient<UserProfileProvider>(companyid, sessionid).GetUsersByLocAndDep(companyid, locid, depid);
|
||||
List<UserInfo> list = new List<UserInfo>();
|
||||
List<string> uids = new List<string>();
|
||||
foreach (var user in allusers)
|
||||
{
|
||||
if (uids.Contains(user.UID))
|
||||
continue;
|
||||
|
||||
if (!user.AssignedWorkOrders && user.ContactType != Foresight.Fleet.Services.User.ContactTypes.Advisor) continue;
|
||||
if (depandlocusers == null || depandlocusers.Contains(user.UID, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
list.Add(ConvertUserItem(user));
|
||||
uids.Add(user.UID);
|
||||
}
|
||||
}
|
||||
return list.OrderBy(u => u.DisplayName).ToArray();
|
||||
}
|
||||
|
||||
public static UserInfo[] GetUsersByAssets(string sessionid, long[] assetids, string companyid)
|
||||
{
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
var users = FleetServiceClientHelper.CreateClient<AssetQueryClient>(companyid, sessionid).GetUsersAvailableForAssets(companyid, assetids);
|
||||
List<UserInfo> list = new List<UserInfo>();
|
||||
foreach (var user in users)
|
||||
{
|
||||
list.Add(ConvertUserItem(user));
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public static UserInfo[] GetUsersByJobsiteID(string sessionid, long jsid, string companyid)
|
||||
{
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
var users = FleetServiceClientHelper.CreateClient<AssetQueryClient>(companyid, sessionid).GetUsersAvailableForJobsite(companyid, jsid);
|
||||
List<UserInfo> list = new List<UserInfo>();
|
||||
foreach (var user in users)
|
||||
{
|
||||
list.Add(ConvertUserItem(user));
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取机器对应的ContactID
|
||||
/// </summary>
|
||||
@ -864,11 +758,11 @@ namespace IronIntel.Contractor.Users
|
||||
|
||||
return list;
|
||||
}
|
||||
internal static UserInfoItem[] GetPermissionUsers()
|
||||
internal static UserInfoItem[] GetPermissionUsers1()
|
||||
{
|
||||
List<UserInfoItem> users = new List<UserInfoItem>();
|
||||
|
||||
DataTable authenDt = SystemParams.GetDbInstance().GetDataTableBySQL("SELECT * FROM Users");
|
||||
DataTable authenDt = SystemParams.GetDbInstance().GetDataTableBySQL("select * from Users where isnull(DELETED,0)=0");
|
||||
|
||||
string str = "";
|
||||
for (int i = authenDt.Rows.Count - 1; i >= 0; i--)
|
||||
@ -890,7 +784,30 @@ namespace IronIntel.Contractor.Users
|
||||
return users.ToArray();
|
||||
}
|
||||
|
||||
internal static UserPermissionData[] GetUserOrGroupPermission(string UserOrGroup, string objIID, string userIID)
|
||||
internal static UserInfoItem[] GetPermissionUsers()
|
||||
{
|
||||
List<UserInfoItem> ls = new List<UserInfoItem>();
|
||||
|
||||
var users = FleetServiceClientHelper.CreateClient<UserQueryClient>(SystemParams.CompanyID, string.Empty).GetUsersByCustomerID(SystemParams.CompanyID, "");
|
||||
if (users == null || users.Length == 0)
|
||||
return new UserInfoItem[0];
|
||||
|
||||
foreach (var u in users)
|
||||
{
|
||||
if (string.Compare(u.ID, "admin", true) == 0 || (int)u.UserType != 1) //EMUserType.Common
|
||||
continue;
|
||||
|
||||
UserInfoItem user = new UserInfoItem();
|
||||
user.IID = u.UID;
|
||||
user.ID = u.ID;
|
||||
user.DisplayName = u.Name;
|
||||
ls.Add(user);
|
||||
}
|
||||
|
||||
return ls.ToArray();
|
||||
}
|
||||
|
||||
internal static UserPermissionData[] GetUserOrGroupPermission(string UserOrGroup, string objIID, string userIID, string lang)
|
||||
{
|
||||
List<UserPermissionData> UserOrGroupPermissionDatas = new List<UserPermissionData>();
|
||||
|
||||
@ -910,8 +827,8 @@ namespace IronIntel.Contractor.Users
|
||||
UserPermissionData upmd = new UserPermissionData();
|
||||
upmd.FunctionIID = opr.IID;
|
||||
upmd.IsAllowed = false;
|
||||
upmd.ManagementFunction = ResManager.GetLanguage(ResManager.GetResourceString(opr.FunctionName));
|
||||
upmd.Description = ResManager.GetLanguage(ResManager.GetResourceString(opr.Description));
|
||||
upmd.ManagementFunction = ResManager.GetLanguage(lang, ResManager.GetResourceString(opr.FunctionName));
|
||||
upmd.Description = ResManager.GetLanguage(lang, ResManager.GetResourceString(opr.Description));
|
||||
upmd.IsNotPermissionInGroup = true;
|
||||
|
||||
UserOrGroupPermissionDatas.Add(upmd);
|
||||
|
@ -14,6 +14,7 @@ namespace IronIntel.Contractor.Users
|
||||
public static class UserParams
|
||||
{
|
||||
private const string _AutoRecenterMap = "AutoRecenterMap";
|
||||
private const string _ShowJSTooltip = "ShowJSTooltip";
|
||||
private const string _BaseMap = "BaseMap";
|
||||
private const string _MapViewContratorID = "MapViewContratorID";
|
||||
private const string _MapAlertLayer = "MapAlertLayer";
|
||||
@ -26,6 +27,7 @@ namespace IronIntel.Contractor.Users
|
||||
private const string _UnShownJobsites = "UnShownJobsites";
|
||||
private const string _UnShownJobsiteMachines = "UnShownJobsiteMachines";
|
||||
private const string _Onroad = "Onroad";
|
||||
private const string _Attachment = "Attachment";
|
||||
private const string _ExcludeNoLocation = "ExcludeNoLocation";
|
||||
|
||||
private const string _MapViewSearches = "MapViewSearches";
|
||||
@ -47,6 +49,9 @@ namespace IronIntel.Contractor.Users
|
||||
case _AutoRecenterMap:
|
||||
userParams.AutoRecenterMap = Helper.IsTrue(value);
|
||||
break;
|
||||
case _ShowJSTooltip:
|
||||
userParams.ShowJSTooltip = Helper.IsTrue(value);
|
||||
break;
|
||||
case _BaseMap:
|
||||
userParams.BaseMap = value;
|
||||
break;
|
||||
@ -80,6 +85,9 @@ namespace IronIntel.Contractor.Users
|
||||
case _Onroad:
|
||||
userParams.Onroad = int.Parse(value);
|
||||
break;
|
||||
case _Attachment:
|
||||
userParams.Attachment = int.Parse(value);
|
||||
break;
|
||||
case _ExcludeNoLocation:
|
||||
userParams.ExcludeNoLocation = int.Parse(value) == 1;
|
||||
break;
|
||||
@ -102,6 +110,11 @@ namespace IronIntel.Contractor.Users
|
||||
else
|
||||
userParams.MapRefreshInterval = 60;
|
||||
userParams.MachineIconURL = SystemParams.MachineTypeMapViewIconUrl;
|
||||
|
||||
var uc = FleetServiceClientHelper.CreateClient<UserQueryClient>();
|
||||
userParams.PreferredLanguage = uc.GetUserPreferredLanguageByIID(useriid);
|
||||
userParams.TimeZone = uc.GetUserTimeZoneByIID(useriid);
|
||||
|
||||
return userParams;
|
||||
}
|
||||
|
||||
@ -114,6 +127,7 @@ namespace IronIntel.Contractor.Users
|
||||
|
||||
FIDbAccess db = SystemParams.GetDbInstance();
|
||||
db.ExecSQL(SQL, useriid, _AutoRecenterMap, userParams.AutoRecenterMap ? "true" : "false");
|
||||
db.ExecSQL(SQL, useriid, _ShowJSTooltip, userParams.ShowJSTooltip ? "true" : "false");
|
||||
|
||||
if (!string.IsNullOrEmpty(userParams.BaseMap))
|
||||
db.ExecSQL(SQL, useriid, _BaseMap, userParams.BaseMap);
|
||||
@ -170,13 +184,18 @@ namespace IronIntel.Contractor.Users
|
||||
else
|
||||
db.ExecSQL(SQL_Delete, useriid, _Onroad);
|
||||
|
||||
if (userParams.ExcludeNoLocation)
|
||||
db.ExecSQL(SQL, useriid, _ExcludeNoLocation, userParams.ExcludeNoLocation ? 1 : 0);
|
||||
if (userParams.Attachment >= 0)
|
||||
db.ExecSQL(SQL, useriid, _Attachment, userParams.Attachment);
|
||||
else
|
||||
db.ExecSQL(SQL_Delete, useriid, _Attachment);
|
||||
|
||||
db.ExecSQL(SQL, useriid, _ExcludeNoLocation, userParams.ExcludeNoLocation ? 1 : 0);
|
||||
|
||||
if (!string.IsNullOrEmpty(userParams.LandingPage))
|
||||
db.ExecSQL(SQL, useriid, _LandingPage, userParams.LandingPage);
|
||||
else
|
||||
db.ExecSQL(SQL_Delete, useriid, _LandingPage);
|
||||
|
||||
}
|
||||
|
||||
public static string GetStringParameter(string useriid, string paramname)
|
||||
@ -304,6 +323,7 @@ namespace IronIntel.Contractor.Users
|
||||
public class UserParamInfo
|
||||
{
|
||||
public bool AutoRecenterMap { get; set; } = false;
|
||||
public bool ShowJSTooltip { get; set; } = false;
|
||||
public string BaseMap { get; set; }
|
||||
public string MapViewContratorID { get; set; }
|
||||
public string MapAlertLayer { get; set; }
|
||||
@ -317,10 +337,13 @@ namespace IronIntel.Contractor.Users
|
||||
public string[] UnShownJobsites { get; set; }
|
||||
public string[] UnShownJobsiteMachines { get; set; }
|
||||
public int Onroad { get; set; } = -1;
|
||||
public int Attachment { get; set; } = 0;
|
||||
public bool ExcludeNoLocation { get; set; } = true;
|
||||
|
||||
public MapViewSearchItem[] MapViewSearches { get; set; }
|
||||
public string LandingPage { get; set; }
|
||||
public string PreferredLanguage { get; set; }
|
||||
public string TimeZone { get; set; }
|
||||
}
|
||||
|
||||
public class MapViewSearcheHelper
|
||||
@ -355,6 +378,8 @@ namespace IronIntel.Contractor.Users
|
||||
item.IsDefault = Helper.IsTrue(ch.InnerText);
|
||||
else if (string.Compare(ch.Name, "Onroad", true) == 0)
|
||||
item.Onroad = Convert.ToInt32(ch.InnerText);
|
||||
else if (string.Compare(ch.Name, "Attachment", true) == 0)
|
||||
item.Attachment = Convert.ToInt32(ch.InnerText);
|
||||
else if (string.Compare(ch.Name, "AssetDefaultSearch", true) == 0)
|
||||
item.AssetDefaultSearch = ch.InnerText;
|
||||
else if (string.Compare(ch.Name, "JobSiteDefaultSearch", true) == 0)
|
||||
@ -392,6 +417,7 @@ namespace IronIntel.Contractor.Users
|
||||
if (!string.IsNullOrEmpty(search.AssetGroupDefaultSearch))
|
||||
AddSubNode(sn, "AssetGroupDefaultSearch", search.AssetGroupDefaultSearch);
|
||||
AddSubNode(sn, "Onroad", search.Onroad.ToString());
|
||||
AddSubNode(sn, "Attachment", search.Attachment.ToString());
|
||||
AddSubNode(sn, "ExcludeNoLocation", search.ExcludeNoLocation ? "1" : "0");
|
||||
if (search.UnShownMachines != null && search.UnShownMachines.Length > 0)
|
||||
AddSubNode(sn, "UnShownMachines", string.Join(",", search.UnShownMachines));
|
||||
@ -422,6 +448,7 @@ namespace IronIntel.Contractor.Users
|
||||
public bool IsDefault { get; set; }
|
||||
|
||||
public int Onroad { get; set; } = -1;
|
||||
public int Attachment { get; set; } = 0;
|
||||
public string AssetDefaultSearch { get; set; } = "";
|
||||
public string JobSiteDefaultSearch { get; set; } = "";
|
||||
public string AssetGroupDefaultSearch { get; set; } = "";
|
||||
|
405
IronIntelContractorBusiness/iisitebase/IronIntelBasePage.cs
Normal file
405
IronIntelContractorBusiness/iisitebase/IronIntelBasePage.cs
Normal file
@ -0,0 +1,405 @@
|
||||
using Foresight.Fleet.Services.Customer;
|
||||
using Foresight.Fleet.Services.User;
|
||||
using Foresight.Security;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace IronIntel.Contractor.iisitebase
|
||||
{
|
||||
|
||||
public class IronIntelBasePage : System.Web.UI.Page
|
||||
{
|
||||
public const string LOGINSESSION_COOKIENAME = "iiabc_";
|
||||
public const string LANGUAGE_COOKIENAME = "iiabc_lang";
|
||||
private static int _LOCAL_TIMEOFFSET = 10000;
|
||||
public const string APPNAME = "iron-desktop";
|
||||
public const string CLIENT_TIMEOFFSET_COOKIENAME = "clienttimeoffset";
|
||||
|
||||
private static string _HostName = null;
|
||||
|
||||
private static string _Branch = string.Empty;
|
||||
private static string _AboutUrl = string.Empty;
|
||||
private static string _Copyrights = string.Empty;
|
||||
private static string _PageTitle = string.Empty;
|
||||
private static string _ShowTermofuse = string.Empty;
|
||||
|
||||
public IronIntelBasePage()
|
||||
{
|
||||
EnableViewState = false;
|
||||
}
|
||||
|
||||
public static string LocalHostName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_HostName == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
_HostName = Dns.GetHostName();
|
||||
}
|
||||
catch
|
||||
{
|
||||
_HostName = string.Empty;
|
||||
}
|
||||
}
|
||||
return _HostName;
|
||||
}
|
||||
}
|
||||
|
||||
public static int LocalTimeOffset
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_LOCAL_TIMEOFFSET == 10000)
|
||||
{
|
||||
DateTime dt = DateTime.Now;
|
||||
DateTime dt1 = dt.ToUniversalTime();
|
||||
TimeSpan sp = dt1 - dt;
|
||||
_LOCAL_TIMEOFFSET = Convert.ToInt32(sp.TotalMinutes);
|
||||
}
|
||||
return _LOCAL_TIMEOFFSET;
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly byte[] KEY = new byte[] { 219, 239, 201, 20, 173, 133, 64, 29, 33, 71, 49, 117, 208, 115, 79, 169, 1, 126, 201, 229, 115, 35, 62, 102, 71, 16, 71, 220, 44, 95, 186, 223 };
|
||||
private static readonly byte[] IV = new byte[] { 255, 180, 99, 244, 147, 37, 175, 243, 193, 52, 167, 82, 143, 199, 242, 171 };
|
||||
|
||||
public static string EncryptString(string s)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
byte[] buf = Encoding.UTF8.GetBytes(s);
|
||||
byte[] tmp = SecurityHelper.AesEncrypt(buf, KEY, IV);
|
||||
return Convert.ToBase64String(tmp);
|
||||
}
|
||||
|
||||
public static string DecryptString(string s)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
byte[] tmp = Convert.FromBase64String(s);
|
||||
byte[] buf = SecurityHelper.AesDecrypt(tmp, KEY, IV);
|
||||
return Encoding.UTF8.GetString(buf);
|
||||
}
|
||||
|
||||
private string GetServerParam(string key)
|
||||
{
|
||||
//IronSysServiceClient ic = new IronSysServiceClient(GetIronSystemServiceAddress());
|
||||
//StringKeyValue[] kvs = ic.GetServerParams();
|
||||
//foreach (StringKeyValue kv in kvs)
|
||||
//{
|
||||
// if (string.Compare(kv.Key, key, true) == 0)
|
||||
// {
|
||||
// return kv.Value;
|
||||
// }
|
||||
//}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public string Branch
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_Branch))
|
||||
{
|
||||
_Branch = GetServerParam("Branch");
|
||||
}
|
||||
return _Branch;
|
||||
}
|
||||
}
|
||||
|
||||
public string AboutUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(_AboutUrl))
|
||||
{
|
||||
_AboutUrl = GetServerParam("AboutUrl");
|
||||
}
|
||||
return _AboutUrl;
|
||||
}
|
||||
}
|
||||
|
||||
public string Copyrights
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(_Copyrights))
|
||||
{
|
||||
_Copyrights = GetServerParam("Copyrights");
|
||||
}
|
||||
return _Copyrights;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public string PageTitle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(_PageTitle))
|
||||
{
|
||||
_PageTitle = GetServerParam("PageTitle");
|
||||
}
|
||||
return _PageTitle;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowTermofuse
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(_ShowTermofuse))
|
||||
{
|
||||
_ShowTermofuse = GetServerParam("ShowTermofuse");
|
||||
}
|
||||
return string.Compare(_ShowTermofuse, "True", true) == 0 || string.Compare(_ShowTermofuse, "Yes", true) == 0 || string.Compare(_ShowTermofuse, "1", true) == 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetLoginSessionID(HttpRequest request)
|
||||
{
|
||||
HttpCookie cookie = request.Cookies[LOGINSESSION_COOKIENAME];
|
||||
if (cookie == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(cookie.Value))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
return DecryptString(cookie.Value);
|
||||
}
|
||||
|
||||
public LoginSession GetCurrentLoginSession()
|
||||
{
|
||||
string sessionid = GetLoginSessionID(Request);
|
||||
if (string.IsNullOrWhiteSpace(sessionid))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
UserQueryClient ic = FleetServiceClientHelper.CreateClient<UserQueryClient>();
|
||||
return ic.GetLoginSession(sessionid);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void RedirectToLoginPage()
|
||||
{
|
||||
Response.Redirect(LoginPageUrl);
|
||||
}
|
||||
|
||||
protected string LoginPageUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
CustomerProvider cp = FleetServiceClientHelper.CreateClient<CustomerProvider>();
|
||||
return cp.GetPortalLoginUrl();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当用户登录成功后,跳转到用户的默认主界面, 也即是各公司的主界面
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
protected void RedirectToUsersDefaultEntryPage(UserInfo user)
|
||||
{
|
||||
Response.Redirect(GetUserDefaultEntryPageUrl(user), true);
|
||||
}
|
||||
|
||||
protected string GetUserDefaultEntryPageUrl(UserInfo user)
|
||||
{
|
||||
CustomerProvider cp = FleetServiceClientHelper.CreateClient<CustomerProvider>();
|
||||
return cp.GetCompanyPortalEntryUrl(user.CompanyID);
|
||||
}
|
||||
|
||||
protected void ClearLoginSessionCookie()
|
||||
{
|
||||
HttpCookie cookie = new HttpCookie(LOGINSESSION_COOKIENAME);
|
||||
cookie.Value = string.Empty;
|
||||
cookie.Expires = DateTime.Now.AddDays(-3);
|
||||
Response.Cookies.Add(cookie);
|
||||
}
|
||||
|
||||
protected void SetLoginSessionCookie(string sessionid)
|
||||
{
|
||||
HttpCookie cookie = new HttpCookie(LOGINSESSION_COOKIENAME);
|
||||
cookie.Value = EncryptString(sessionid);
|
||||
|
||||
string path = ConfigurationManager.AppSettings["sessioncookiepath"];
|
||||
if (!string.IsNullOrWhiteSpace(path))
|
||||
{
|
||||
cookie.Path = path;
|
||||
}
|
||||
string domain = ConfigurationManager.AppSettings["sessioncookiedomain"];
|
||||
if (!string.IsNullOrWhiteSpace(domain))
|
||||
{
|
||||
cookie.Domain = domain;
|
||||
}
|
||||
Response.Cookies.Add(cookie);
|
||||
}
|
||||
|
||||
protected void SetClientTimeOffset(int offset)
|
||||
{
|
||||
HttpCookie cookie = new HttpCookie(CLIENT_TIMEOFFSET_COOKIENAME);
|
||||
cookie.Value = offset.ToString();
|
||||
cookie.Expires = DateTime.Now.AddYears(1);
|
||||
Response.Cookies.Add(cookie);
|
||||
}
|
||||
protected void SetLanguageCookie(string useriid)
|
||||
{
|
||||
HttpCookie cookie = new HttpCookie(LANGUAGE_COOKIENAME);
|
||||
cookie.Value = SystemParams.GetUserLanguage(useriid);
|
||||
|
||||
string path = ConfigurationManager.AppSettings["sessioncookiepath"];
|
||||
if (!string.IsNullOrWhiteSpace(path))
|
||||
{
|
||||
cookie.Path = path;
|
||||
}
|
||||
string domain = ConfigurationManager.AppSettings["sessioncookiedomain"];
|
||||
if (!string.IsNullOrWhiteSpace(domain))
|
||||
{
|
||||
cookie.Domain = domain;
|
||||
}
|
||||
Response.Cookies.Add(cookie);
|
||||
}
|
||||
protected string GetLanguageCookie()
|
||||
{
|
||||
HttpCookie cookie = Request.Cookies[LANGUAGE_COOKIENAME];
|
||||
if (cookie == null)
|
||||
{
|
||||
return "en-us";
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(cookie.Value))
|
||||
{
|
||||
return "en-us";
|
||||
}
|
||||
return cookie.Value;
|
||||
}
|
||||
|
||||
protected int GetClientTimeOffset()
|
||||
{
|
||||
HttpCookie cookie = Request.Cookies[CLIENT_TIMEOFFSET_COOKIENAME];
|
||||
if (cookie == null)
|
||||
{
|
||||
return LocalTimeOffset;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(cookie.Value))
|
||||
{
|
||||
return LocalTimeOffset;
|
||||
}
|
||||
int n = 0;
|
||||
if (int.TryParse(cookie.Value, out n))
|
||||
{
|
||||
return n;
|
||||
}
|
||||
else
|
||||
{
|
||||
return LocalTimeOffset;
|
||||
}
|
||||
}
|
||||
|
||||
public static DateTime UtcTimeToClientTime(DateTime dt, int clienttimeoffset)
|
||||
{
|
||||
return dt.AddMinutes(-1 * clienttimeoffset);
|
||||
}
|
||||
|
||||
public static Int64 GetSiteFileDateTime(string url)
|
||||
{
|
||||
string fn = HttpContext.Current.Server.MapPath(url);
|
||||
if (System.IO.File.Exists(fn))
|
||||
{
|
||||
try
|
||||
{
|
||||
return System.IO.File.GetLastWriteTimeUtc(fn).Ticks;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用于构造js/css或图片文件的url,在其最后加上版本标识,解决浏览器缓存问题
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetFileUrlWithVersion(string url)
|
||||
{
|
||||
string fn = HttpContext.Current.Server.MapPath(url);
|
||||
if (System.IO.File.Exists(fn))
|
||||
{
|
||||
try
|
||||
{
|
||||
Int64 n = System.IO.File.GetLastWriteTimeUtc(fn).Ticks;
|
||||
return url + "?sn=" + n.ToString();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return url;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
public static string ReadTextFromStream(System.IO.Stream stream)
|
||||
{
|
||||
using (System.IO.StreamReader sr = new System.IO.StreamReader(stream))
|
||||
{
|
||||
return sr.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetUserHostAddress(HttpRequest request)
|
||||
{
|
||||
const string CLIENT_IP = "client-ip";
|
||||
if (request == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
string rst = request.Headers[CLIENT_IP];
|
||||
if (string.IsNullOrWhiteSpace(rst))
|
||||
{
|
||||
rst = request.UserHostAddress;
|
||||
}
|
||||
if (rst == null)
|
||||
{
|
||||
rst = string.Empty;
|
||||
}
|
||||
return rst;
|
||||
}
|
||||
|
||||
protected string UserHostAddress
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetUserHostAddress(Request);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
using Foresight.Fleet.Services.User;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace IronIntel.Contractor.iisitebase
|
||||
{
|
||||
|
||||
public class IronIntelHttpHandlerBase : IDisposable
|
||||
{
|
||||
public static string LocalHostName
|
||||
{
|
||||
get { return IronIntelBasePage.LocalHostName; }
|
||||
}
|
||||
|
||||
public HttpContext Context { get; private set; }
|
||||
protected LoginSession LoginSession { get; private set; }
|
||||
|
||||
protected int ClientTimeOffset { get; private set; }
|
||||
|
||||
public IronIntelHttpHandlerBase(HttpContext context)
|
||||
{
|
||||
Context = context;
|
||||
try
|
||||
{
|
||||
LoginSession = GetCurrentLoginSession();
|
||||
}
|
||||
catch
|
||||
{
|
||||
LoginSession = null;
|
||||
}
|
||||
ClientTimeOffset = GetClientTimeOffset();
|
||||
}
|
||||
|
||||
|
||||
public LoginSession GetCurrentLoginSession()
|
||||
{
|
||||
HttpCookie cookie = Context.Request.Cookies[IronIntelBasePage.LOGINSESSION_COOKIENAME];
|
||||
if (cookie == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(cookie.Value))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string sessionid = IronIntelBasePage.DecryptString(cookie.Value);
|
||||
try
|
||||
{
|
||||
UserQueryClient ic = FleetServiceClientHelper.CreateClient<UserQueryClient>();
|
||||
return ic.GetLoginSession(sessionid);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private int GetClientTimeOffset()
|
||||
{
|
||||
HttpCookie cookie = Context.Request.Cookies[IronIntelBasePage.CLIENT_TIMEOFFSET_COOKIENAME];
|
||||
if (cookie == null)
|
||||
{
|
||||
return IronIntelBasePage.LocalTimeOffset;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(cookie.Value))
|
||||
{
|
||||
return IronIntelBasePage.LocalTimeOffset;
|
||||
}
|
||||
int n = 0;
|
||||
if (int.TryParse(cookie.Value, out n))
|
||||
{
|
||||
return n;
|
||||
}
|
||||
else
|
||||
{
|
||||
return IronIntelBasePage.LocalTimeOffset;
|
||||
}
|
||||
}
|
||||
|
||||
public static string ReadTextFromStream(System.IO.Stream stream)
|
||||
{
|
||||
using (System.IO.StreamReader sr = new System.IO.StreamReader(stream))
|
||||
{
|
||||
return sr.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ProcessRequest()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private bool disposed = false;
|
||||
protected void Dispose(bool disposed)
|
||||
{
|
||||
Context = null;
|
||||
LoginSession = null;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (!disposed)
|
||||
{
|
||||
Dispose(true);
|
||||
disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public string UserHostAddress
|
||||
{
|
||||
get
|
||||
{
|
||||
return IronIntelBasePage.GetUserHostAddress(Context.Request);
|
||||
}
|
||||
}
|
||||
protected string GetLanguageCookie()
|
||||
{
|
||||
HttpCookie cookie = Context.Request.Cookies[IronIntelBasePage.LANGUAGE_COOKIENAME];
|
||||
if (cookie == null)
|
||||
{
|
||||
return "en-us";
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(cookie.Value))
|
||||
{
|
||||
return "en-us";
|
||||
}
|
||||
return cookie.Value;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="System.Data.SqlClient" version="4.6.0" targetFramework="net471" />
|
||||
<package id="System.Data.SqlClient" version="4.8.1" targetFramework="net472" />
|
||||
<package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="net472" />
|
||||
</packages>
|
Reference in New Issue
Block a user