change list getting, sync
This commit is contained in:
		| @@ -1,7 +1,6 @@ | |||||||
| using Foresight.Fleet.Services.Asset; | using Foresight.Fleet.Services.Asset; | ||||||
| using Foresight.Fleet.Services.AssetHealth; | using Foresight.Fleet.Services.AssetHealth; | ||||||
| using Foresight.Fleet.Services.Inspection; | using Foresight.Fleet.Services.Inspection; | ||||||
| using Foresight.Fleet.Services.JobSite; |  | ||||||
| using Foresight.ServiceModel; | using Foresight.ServiceModel; | ||||||
| using IronIntel.Contractor.FilterQ; | using IronIntel.Contractor.FilterQ; | ||||||
| using IronIntel.Contractor.Machines; | using IronIntel.Contractor.Machines; | ||||||
| @@ -289,9 +288,10 @@ namespace IronIntel.Contractor.Site | |||||||
|                             } |                             } | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|  |                     var ic = CreateClient<InspectMobileClient>(); | ||||||
|                     if (hasEmail) |                     if (hasEmail) | ||||||
|                     { |                     { | ||||||
|                         ir.EmailList = aic.GetInspectEmailList(companyId, string.Empty); |                         ir.EmailList = Download(() => ic.DownloadTeamIntelligenceUsers(companyId)).OrderBy(e => e.UserName).ToArray(); | ||||||
|                     } |                     } | ||||||
|                     //if (hasAsset) |                     //if (hasAsset) | ||||||
|                     //{ |                     //{ | ||||||
| @@ -300,8 +300,7 @@ namespace IronIntel.Contractor.Site | |||||||
|                     //} |                     //} | ||||||
|                     if (hasJobsite) |                     if (hasJobsite) | ||||||
|                     { |                     { | ||||||
|                         var jc = CreateClient<JobSiteProvider>(); |                         ir.JobSiteList = Download(() => ic.DownloadJobSites(companyId, session.User.UID)).OrderBy(j => j.Name).ToArray(); | ||||||
|                         ir.JobSiteList = jc.GetJobSiteLimitItems(companyId, string.Empty); |  | ||||||
|                     } |                     } | ||||||
|                     return ir; |                     return ir; | ||||||
|                 } |                 } | ||||||
| @@ -325,8 +324,11 @@ namespace IronIntel.Contractor.Site | |||||||
|                     //string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata); |                     //string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata); | ||||||
|                     string companyId = SystemParams.CompanyID; |                     string companyId = SystemParams.CompanyID; | ||||||
|  |  | ||||||
|                     var ac = CreateClient<AssetQueryClient>(); |                     var ac = CreateClient<InspectMobileClient>(); | ||||||
|                     var assets = ac.GetAssetBasicInfoByUser(companyId, string.Empty, session.User.UID); |                     var list = new List<AssetItem>(); | ||||||
|  |                     var assets = Download(startid => ac.DownloadAssets(companyId, session.User.UID, startid, 20000)) | ||||||
|  |                         .OrderBy(a => a.Name) | ||||||
|  |                         .ToArray(); | ||||||
|  |  | ||||||
|                     return assets; |                     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() |         private object UpdateInspectionReport() | ||||||
|         { |         { | ||||||
|             try |             try | ||||||
| @@ -347,6 +393,7 @@ namespace IronIntel.Contractor.Site | |||||||
|                 if (session != null) |                 if (session != null) | ||||||
|                 { |                 { | ||||||
|                     string clientdata = Request.Params["ClientData"]; |                     string clientdata = Request.Params["ClientData"]; | ||||||
|  |                     clientdata = HttpUtility.HtmlDecode(clientdata); | ||||||
|                     var report = JsonConvert.DeserializeObject<InspectReportInfo>(clientdata); |                     var report = JsonConvert.DeserializeObject<InspectReportInfo>(clientdata); | ||||||
|                     bool isTeam = report.Target == TemplateTargets.Person; |                     bool isTeam = report.Target == TemplateTargets.Person; | ||||||
|  |  | ||||||
| @@ -573,6 +620,16 @@ namespace IronIntel.Contractor.Site | |||||||
|                         state = -1; |                         state = -1; | ||||||
|                     string filter = HttpUtility.HtmlDecode(ps[2]); |                     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; |                     FormTemplateItem[] templates = null; | ||||||
|                     if (teamintelligence) |                     if (teamintelligence) | ||||||
|                     { |                     { | ||||||
| @@ -582,7 +639,7 @@ namespace IronIntel.Contractor.Site | |||||||
|                     else |                     else | ||||||
|                     { |                     { | ||||||
|                         var client = CreateClient<AssetInspectClient>(); |                         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; |                     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 string CommitTimeLocalStr { get { return CommitTimeLocal == DateTime.MinValue ? "" : CommitTimeLocal.ToString(("M/d/yyyy h:mm tt")); } } | ||||||
|         public UserEmailInfo[] EmailList { get; set; } |         public UserEmailInfo[] EmailList { get; set; } | ||||||
|         public AssetBasicInfo[] AssetList { get; set; } |         public AssetBasicInfo[] AssetList { get; set; } | ||||||
|         public JobSiteLimitItem[] JobSiteList { get; set; } |         public JobSiteItem[] JobSiteList { get; set; } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										2
									
								
								Site
									
									
									
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								Site
									
									
									
									
									
								
							 Submodule Site updated: f18f90035b...0d41da80b5
									
								
							
		Reference in New Issue
	
	Block a user