change list getting, sync

This commit is contained in:
Tsanie Lily 2020-04-30 18:37:32 +08:00
parent 0756b7d523
commit d69325d2da
3 changed files with 66 additions and 9 deletions

View File

@ -1,7 +1,6 @@
using Foresight.Fleet.Services.Asset;
using Foresight.Fleet.Services.AssetHealth;
using Foresight.Fleet.Services.Inspection;
using Foresight.Fleet.Services.JobSite;
using Foresight.ServiceModel;
using IronIntel.Contractor.FilterQ;
using IronIntel.Contractor.Machines;
@ -289,9 +288,10 @@ namespace IronIntel.Contractor.Site
}
}
}
var ic = CreateClient<InspectMobileClient>();
if (hasEmail)
{
ir.EmailList = aic.GetInspectEmailList(companyId, string.Empty);
ir.EmailList = Download(() => ic.DownloadTeamIntelligenceUsers(companyId)).OrderBy(e => e.UserName).ToArray();
}
//if (hasAsset)
//{
@ -300,8 +300,7 @@ namespace IronIntel.Contractor.Site
//}
if (hasJobsite)
{
var jc = CreateClient<JobSiteProvider>();
ir.JobSiteList = jc.GetJobSiteLimitItems(companyId, string.Empty);
ir.JobSiteList = Download(() => ic.DownloadJobSites(companyId, session.User.UID)).OrderBy(j => j.Name).ToArray();
}
return ir;
}
@ -325,8 +324,11 @@ namespace IronIntel.Contractor.Site
//string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata);
string companyId = SystemParams.CompanyID;
var ac = CreateClient<AssetQueryClient>();
var assets = ac.GetAssetBasicInfoByUser(companyId, string.Empty, session.User.UID);
var ac = CreateClient<InspectMobileClient>();
var list = new List<AssetItem>();
var assets = Download(startid => ac.DownloadAssets(companyId, session.User.UID, startid, 20000))
.OrderBy(a => a.Name)
.ToArray();
return assets;
}
@ -339,6 +341,50 @@ namespace IronIntel.Contractor.Site
}
}
private List<AssetItem> Download(Func<long, AssetItem[]> download, long startid = -1, int size = 100)
{
var list = new List<AssetItem>();
int count = 0;
while (count < 5)
{
try
{
var items = download(startid);
list.AddRange(items);
if (items.Length < size)
{
return list;
}
else
{
startid = items[items.Length - 1].Id;
}
}
catch
{
count++;
}
}
return null;
}
IEnumerable<T> Download<T>(Func<IEnumerable<T>> download)
{
int count = 0;
while (count < 5)
{
try
{
return download();
}
catch
{
count++;
}
}
return null;
}
private object UpdateInspectionReport()
{
try
@ -347,6 +393,7 @@ namespace IronIntel.Contractor.Site
if (session != null)
{
string clientdata = Request.Params["ClientData"];
clientdata = HttpUtility.HtmlDecode(clientdata);
var report = JsonConvert.DeserializeObject<InspectReportInfo>(clientdata);
bool isTeam = report.Target == TemplateTargets.Person;
@ -573,6 +620,16 @@ namespace IronIntel.Contractor.Site
state = -1;
string filter = HttpUtility.HtmlDecode(ps[2]);
int makeid = -1;
if (!int.TryParse(ps[3], out makeid))
makeid = -1;
int modelid = -1;
if (!int.TryParse(ps[4], out modelid))
modelid = -1;
int typeid = -1;
if (!int.TryParse(ps[5], out typeid))
typeid = -1;
FormTemplateItem[] templates = null;
if (teamintelligence)
{
@ -582,7 +639,7 @@ namespace IronIntel.Contractor.Site
else
{
var client = CreateClient<AssetInspectClient>();
templates = client.GetFormTemplateItems(SystemParams.CompanyID, filter, user.IID, state);
templates = client.GetAssetTemplateItems(SystemParams.CompanyID, filter, makeid, modelid, typeid, user.IID, state);
}
return templates;
}
@ -1223,7 +1280,7 @@ namespace IronIntel.Contractor.Site
public string CommitTimeLocalStr { get { return CommitTimeLocal == DateTime.MinValue ? "" : CommitTimeLocal.ToString(("M/d/yyyy h:mm tt")); } }
public UserEmailInfo[] EmailList { get; set; }
public AssetBasicInfo[] AssetList { get; set; }
public JobSiteLimitItem[] JobSiteList { get; set; }
public JobSiteItem[] JobSiteList { get; set; }
}
}

Binary file not shown.

2
Site

@ -1 +1 @@
Subproject commit f18f90035b8af122e5489264d05ea3b4fd04e7bc
Subproject commit 0d41da80b581050ac0a71bb242117d3b6f11a908