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