sync
This commit is contained in:
		
							
								
								
									
										3
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							| @@ -1,3 +0,0 @@ | |||||||
| [submodule "Site"] |  | ||||||
| 	path = Site |  | ||||||
| 	url = ssh://git@file.tsanie.us:9022/tsanie/fleet-contractor-site.git |  | ||||||
| @@ -1,7 +1,7 @@ | |||||||
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||||
| <configuration> | <configuration> | ||||||
|   <startup> |   <startup> | ||||||
|     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1"/> |     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/> | ||||||
|   </startup> |   </startup> | ||||||
|   <appSettings> |   <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="DbConntionString" value="Data Source=192.168.25.215\IRONINTEL;Initial Catalog=IRONINTEL_IRONDEV;Integrated Security=false;User ID=fi;Password=database"/>     | ||||||
| @@ -11,4 +11,32 @@ | |||||||
|     <add key="AppVersion" value="1.16.12.15"/> |     <add key="AppVersion" value="1.16.12.15"/> | ||||||
|     <add key="LastUpdateTime" value="10/17/2016 10:36:26.229"/> |     <add key="LastUpdateTime" value="10/17/2016 10:36:26.229"/> | ||||||
|   </appSettings> |   </appSettings> | ||||||
|  |   <runtime> | ||||||
|  |     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||||||
|  |       <dependentAssembly> | ||||||
|  |         <assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral"/> | ||||||
|  |         <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0"/> | ||||||
|  |       </dependentAssembly> | ||||||
|  |       <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> | </configuration> | ||||||
|   | |||||||
| @@ -9,9 +9,24 @@ | |||||||
|     <AppDesignerFolder>Properties</AppDesignerFolder> |     <AppDesignerFolder>Properties</AppDesignerFolder> | ||||||
|     <RootNamespace>ConsoleApplication1</RootNamespace> |     <RootNamespace>ConsoleApplication1</RootNamespace> | ||||||
|     <AssemblyName>ConsoleApplication1</AssemblyName> |     <AssemblyName>ConsoleApplication1</AssemblyName> | ||||||
|     <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion> |     <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||||||
|     <FileAlignment>512</FileAlignment> |     <FileAlignment>512</FileAlignment> | ||||||
|     <TargetFrameworkProfile /> |     <TargetFrameworkProfile /> | ||||||
|  |     <PublishUrl>publish\</PublishUrl> | ||||||
|  |     <Install>true</Install> | ||||||
|  |     <InstallFrom>Disk</InstallFrom> | ||||||
|  |     <UpdateEnabled>false</UpdateEnabled> | ||||||
|  |     <UpdateMode>Foreground</UpdateMode> | ||||||
|  |     <UpdateInterval>7</UpdateInterval> | ||||||
|  |     <UpdateIntervalUnits>Days</UpdateIntervalUnits> | ||||||
|  |     <UpdatePeriodically>false</UpdatePeriodically> | ||||||
|  |     <UpdateRequired>false</UpdateRequired> | ||||||
|  |     <MapFileExtensions>true</MapFileExtensions> | ||||||
|  |     <ApplicationRevision>0</ApplicationRevision> | ||||||
|  |     <ApplicationVersion>1.0.0.%2a</ApplicationVersion> | ||||||
|  |     <IsWebBootstrapper>false</IsWebBootstrapper> | ||||||
|  |     <UseApplicationTrust>false</UseApplicationTrust> | ||||||
|  |     <BootstrapperEnabled>true</BootstrapperEnabled> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||||||
|     <PlatformTarget>AnyCPU</PlatformTarget> |     <PlatformTarget>AnyCPU</PlatformTarget> | ||||||
| @@ -34,6 +49,18 @@ | |||||||
|     <Prefer32Bit>false</Prefer32Bit> |     <Prefer32Bit>false</Prefer32Bit> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|  |     <Reference Include="FICBLC"> | ||||||
|  |       <HintPath>..\Reflib\FIC\FICBLC.dll</HintPath> | ||||||
|  |     </Reference> | ||||||
|  |     <Reference Include="FICIntf"> | ||||||
|  |       <HintPath>..\Reflib\FIC\FICIntf.dll</HintPath> | ||||||
|  |     </Reference> | ||||||
|  |     <Reference Include="FICIntfAdv"> | ||||||
|  |       <HintPath>..\Reflib\FIC\FICIntfAdv.dll</HintPath> | ||||||
|  |     </Reference> | ||||||
|  |     <Reference Include="FICModels"> | ||||||
|  |       <HintPath>..\Reflib\FIC\FICModels.dll</HintPath> | ||||||
|  |     </Reference> | ||||||
|     <Reference Include="FICore"> |     <Reference Include="FICore"> | ||||||
|       <HintPath>..\Reflib\FICore.dll</HintPath> |       <HintPath>..\Reflib\FICore.dll</HintPath> | ||||||
|     </Reference> |     </Reference> | ||||||
| @@ -80,6 +107,18 @@ | |||||||
|       <Name>IronIntelContractorSiteLib</Name> |       <Name>IronIntelContractorSiteLib</Name> | ||||||
|     </ProjectReference> |     </ProjectReference> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|  |   <ItemGroup> | ||||||
|  |     <BootstrapperPackage Include=".NETFramework,Version=v4.7.2"> | ||||||
|  |       <Visible>False</Visible> | ||||||
|  |       <ProductName>Microsoft .NET Framework 4.7.2 %28x86 和 x64%29</ProductName> | ||||||
|  |       <Install>true</Install> | ||||||
|  |     </BootstrapperPackage> | ||||||
|  |     <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> | ||||||
|  |       <Visible>False</Visible> | ||||||
|  |       <ProductName>.NET Framework 3.5 SP1</ProductName> | ||||||
|  |       <Install>false</Install> | ||||||
|  |     </BootstrapperPackage> | ||||||
|  |   </ItemGroup> | ||||||
|   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||||||
|   <!-- To modify your build process, add your task inside one of the targets below and uncomment it.  |   <!-- To modify your build process, add your task inside one of the targets below and uncomment it.  | ||||||
|        Other similar extension points exist, see Microsoft.Common.targets. |        Other similar extension points exist, see Microsoft.Common.targets. | ||||||
|   | |||||||
| @@ -5,57 +5,9 @@ using System.Configuration; | |||||||
| using System.Net.Mail; | using System.Net.Mail; | ||||||
| using System.Text; | using System.Text; | ||||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||||
| using IronIntel.DataModel; |  | ||||||
| using IronIntel.DataModel.Admin.Customers; |  | ||||||
| using IronIntel.DataModel.Admin.Users; |  | ||||||
| using Foresight.Services.Log; | using Foresight.Services.Log; | ||||||
|  |  | ||||||
| namespace ConsoleApplication1 | namespace ConsoleApplication1 | ||||||
| { | { | ||||||
|     class IronIntelDebugHost : IIronIntelHost |  | ||||||
|     { |  | ||||||
|         public CustomerInfo GetCustomerInfo(string custid) |  | ||||||
|         { |  | ||||||
|             throw new NotImplementedException(); |  | ||||||
|         } |  | ||||||
|      |      | ||||||
|         public CustomerManager GetCustomerManager() |  | ||||||
|         { |  | ||||||
|             return new CustomerManager(ConfigurationManager.AppSettings["MasterDb"]); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         public string GetIronIntelDbConnectionString(string custid) |  | ||||||
|         { |  | ||||||
|             throw new NotImplementedException(); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         public LoginManager GetLoginManager() |  | ||||||
|         { |  | ||||||
|             return new LoginManager(ConfigurationManager.AppSettings["MasterDb"]); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         public int SendEmail(string customerid, MailMessage msg) |  | ||||||
|         { |  | ||||||
|             var mail = new Foresight.Services.Mail.MailSender(@"net.tcp://192.168.25.210:20100/fisvcs/systemsvc"); |  | ||||||
|             mail.AppName = "fleet_dev"; |  | ||||||
|             return (int)mail.SendMail("fleet_dev", customerid, "", msg); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         public void WriteLog(string logtype, string source, string message, string detail, string extmsg) |  | ||||||
|         { |  | ||||||
|             LogWriter log = new LogWriter(@"net.tcp://192.168.25.210:20100/fisvcs/systemsvc"); |  | ||||||
|             log.WriteLog("fleet_dev", "Foresight", "hq-pc", "SystemService", logtype, source, message, detail, extmsg); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         public void WriteLog(string customerid, string logtype, string source, string message, string detail, string extmsg) |  | ||||||
|         { |  | ||||||
|             LogWriter log = new LogWriter(@"net.tcp://192.168.25.210:20100/fisvcs/systemsvc"); |  | ||||||
|             log.WriteLog("fleet_dev", customerid, "hq-pc", "SystemService", logtype, source, message, detail, extmsg); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         long IIronIntelHost.SendEmail(string customerid, MailMessage msg) |  | ||||||
|         { |  | ||||||
|             throw new NotImplementedException(); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -7,8 +7,8 @@ using IronIntel.Contractor.MapView; | |||||||
| using IronIntel.Contractor.Users; | using IronIntel.Contractor.Users; | ||||||
| using IronIntel.Contractor.Machines; | using IronIntel.Contractor.Machines; | ||||||
| using IronIntel.Contractor; | using IronIntel.Contractor; | ||||||
| using IronIntel.DataModel; | using FI.FIC.Extention; | ||||||
| using IronIntel.DataModel.Admin.Customers; |  | ||||||
|  |  | ||||||
| namespace ConsoleApplication1 | namespace ConsoleApplication1 | ||||||
| { | { | ||||||
| @@ -16,42 +16,30 @@ namespace ConsoleApplication1 | |||||||
|     { |     { | ||||||
|         static void Main(string[] args) |         static void Main(string[] args) | ||||||
|         { |         { | ||||||
|             //  IronIntelHostEnvironment.InitHost(new IronIntelDebugHost()); |             string fn = "IronIntel.Contractor.FICExtDataTable.AssetTripsDataTable,iicontractorbl"; | ||||||
|  |  | ||||||
|             //  Test1(); |             Type intftype = typeof(IExtDataTable); | ||||||
|  |             Type tp = Type.GetType(fn); | ||||||
|  |             if (!tp.IsAbstract && tp.IsClass &&tp.IsPublic&& tp.GetInterface(intftype.FullName) != null) | ||||||
|  |             { | ||||||
|  |  | ||||||
|  |             } | ||||||
|  |              | ||||||
|  |  | ||||||
|  |            | ||||||
|  |  | ||||||
|  |             IExtDataTable ext = Activator.CreateInstance(tp) as IExtDataTable; | ||||||
|  |  | ||||||
|  |             Console.WriteLine(ext.ID); | ||||||
|  |  | ||||||
|             Guid gd = new Guid("10000000-0000-0000-0000-100000000001"); |             Guid gd = new Guid("10000000-0000-0000-0000-100000000001"); | ||||||
|  |  | ||||||
|             ContractorHost.Init(); |  | ||||||
|              |              | ||||||
|             testdemo(); |  | ||||||
|             Console.ReadLine(); |             Console.ReadLine(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private static void Test1() |  | ||||||
|         { |  | ||||||
|             var cm = IronIntelHostEnvironment.GetCustomerManager(); |  | ||||||
|            var db= cm.GetCustomerDatabaseInfo("Foresight", "IRONINTEL_ADMINDB"); |  | ||||||
|             Console.WriteLine(db.ToString()); |  | ||||||
|             //var loc = cm.GetLocationManager("IRONDEV"); |  | ||||||
|  |  | ||||||
|             //var locs = loc.GetCustomerLocations(); |  | ||||||
|             //Console.WriteLine(locs.ToString()); |  | ||||||
|         } |  | ||||||
|          |          | ||||||
|         private static void testlogin() |  | ||||||
|         { |  | ||||||
|             var lm = IronIntelHostEnvironment.GetLoginManager(); |  | ||||||
|  |  | ||||||
|             lm.DeleteUser("6D3A02C7-FC25-47C0-A7A4-97D470EA4CC5", true); |  | ||||||
|  |  | ||||||
|          //  Console.WriteLine(r.ToString()); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private static void testdemo() |  | ||||||
|         { |  | ||||||
|             var usermanager = ContractorHost.Instance.GetContractorManager<IronIntel.DataModel.Contractor.Users.UserManager>();             |  | ||||||
|  |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										106
									
								
								Contractor.sln
									
									
									
									
									
								
							
							
						
						
									
										106
									
								
								Contractor.sln
									
									
									
									
									
								
							| @@ -1,11 +1,12 @@ | |||||||
|  |  | ||||||
| Microsoft Visual Studio Solution File, Format Version 12.00 | Microsoft Visual Studio Solution File, Format Version 12.00 | ||||||
| # Visual Studio 15 | # Visual Studio Version 17 | ||||||
| VisualStudioVersion = 15.0.27130.2003 | VisualStudioVersion = 17.1.32421.90 | ||||||
| MinimumVisualStudioVersion = 10.0.40219.1 | MinimumVisualStudioVersion = 10.0.40219.1 | ||||||
| Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "Site", "Site\", "{C2BC3E5B-B059-4B6C-8563-07FEAE54AF6B}" | Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "Site", "Site\", "{C2BC3E5B-B059-4B6C-8563-07FEAE54AF6B}" | ||||||
| 	ProjectSection(WebsiteProperties) = preProject | 	ProjectSection(WebsiteProperties) = preProject | ||||||
| 		TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.7.2" | 		TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.7.2" | ||||||
|  | 		ProjectReferences = "{9d398985-9424-4fc7-a637-6b5b204d8f7c}|iicontractorsitelib.dll;{515fb61f-f032-4a48-8f32-93b59b9d37f8}|iicontractorbl.dll;{39E2A8C6-F58F-4839-B7C1-82D44153FC3A}|FICBLC.dll;{DDDA41C4-099D-4614-8925-B11F70459886}|EqpQueryIntfLibForPC.dll;{E4DB03B6-8D79-4B54-BBAE-3F916FED4398}|FICExport.dll;{4963DEB2-F0E3-44A3-B5E1-E13E191A8DE8}|FICIntf.dll;{3FFA4093-4325-4FBB-A874-F288BFDCF7BA}|FICIntfAdv.dll;{F47EBF77-EED3-44E2-9983-EF556372A648}|FICModels.dll;{A2948428-15E6-4BBC-B46D-3EFDA3D5F34C}|FRPTExtIntf.dll;{B0110465-8537-4FE7-BEE6-B10FAA0BA92D}|FleetClientBase.dll;{A872B915-D7F0-4E7F-81E7-742DBB4DBBBA}|FleetServiceClient.dll;{c181bd0e-4b98-4adc-ba92-bb389550d1f6}|FIChartLib.dll;" | ||||||
| 		Debug.AspNetCompiler.VirtualPath = "/localhost_5246" | 		Debug.AspNetCompiler.VirtualPath = "/localhost_5246" | ||||||
| 		Debug.AspNetCompiler.PhysicalPath = "Site\" | 		Debug.AspNetCompiler.PhysicalPath = "Site\" | ||||||
| 		Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_5246\" | 		Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_5246\" | ||||||
| @@ -34,6 +35,38 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApplication1", "Cons | |||||||
| EndProject | EndProject | ||||||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronIntelSiteServiceHost", "IronIntelSiteServiceHost\IronIntelSiteServiceHost.csproj", "{B5E29343-DF46-47DE-A8E8-69BCF58C0697}" | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronIntelSiteServiceHost", "IronIntelSiteServiceHost\IronIntelSiteServiceHost.csproj", "{B5E29343-DF46-47DE-A8E8-69BCF58C0697}" | ||||||
| EndProject | EndProject | ||||||
|  | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LanguageExtractTool", "LanguageExtractTool\LanguageExtractTool.csproj", "{BE465497-20E8-4C29-B98F-3AF19996F1CB}" | ||||||
|  | EndProject | ||||||
|  | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConverImage", "..\..\..\MyProjects\PO_General\Src\ConverImage\ConverImage.csproj", "{64030316-4944-43C1-8F35-C7AE6BD71518}" | ||||||
|  | EndProject | ||||||
|  | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConvertXml2Sqlite", "E:\PO\tools\ConvertXml2Sqlite\ConvertXml2Sqlite.csproj", "{6DADAE33-4436-4D6D-96FD-3AB415AA826F}" | ||||||
|  | EndProject | ||||||
|  | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FIC", "FIC", "{A29EDD95-7564-4A09-AD02-4FF284082DA9}" | ||||||
|  | EndProject | ||||||
|  | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FICBLC", "..\..\..\FI_G3\FICG5Core\Service\FICBLC\FICBLC.csproj", "{39E2A8C6-F58F-4839-B7C1-82D44153FC3A}" | ||||||
|  | EndProject | ||||||
|  | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EqpQueryIntfLibForPC", "..\..\..\FI\EquipQueryApp\Interface\EqpQueryIntfLibForPC\EqpQueryIntfLibForPC.csproj", "{DDDA41C4-099D-4614-8925-B11F70459886}" | ||||||
|  | EndProject | ||||||
|  | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FRPTExtIntf", "..\..\..\FI_G3\FICG5Core\Service\ExtAppIntf\FRPTExtIntf.csproj", "{A2948428-15E6-4BBC-B46D-3EFDA3D5F34C}" | ||||||
|  | EndProject | ||||||
|  | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FICIntf", "..\..\..\FI_G3\FICG5Core\Service\FICIntf\FICIntf\FICIntf.csproj", "{4963DEB2-F0E3-44A3-B5E1-E13E191A8DE8}" | ||||||
|  | EndProject | ||||||
|  | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FICIntfAdv", "..\..\..\FI_G3\FICG5Core\Service\FICIntf\FICIntfAdv\FICIntfAdv.csproj", "{3FFA4093-4325-4FBB-A874-F288BFDCF7BA}" | ||||||
|  | EndProject | ||||||
|  | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FICModels", "..\..\..\FI_G3\FICG5Core\Service\FICModels\FICModels.csproj", "{F47EBF77-EED3-44E2-9983-EF556372A648}" | ||||||
|  | EndProject | ||||||
|  | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FICExport", "..\..\..\FI_G3\FICG5Core\Service\FICExport\FICExport.csproj", "{E4DB03B6-8D79-4B54-BBAE-3F916FED4398}" | ||||||
|  | EndProject | ||||||
|  | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FICEmailSubscribe", "..\..\..\FI_G3\FICG5Core\Service\FICEmailSubscribe\FICEmailSubscribe.csproj", "{8650F244-1D1A-4627-8B15-8FFA4B34932F}" | ||||||
|  | EndProject | ||||||
|  | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DataModel", "DataModel", "{B7B7275E-2530-4E8D-9AE3-C49B4BADCF67}" | ||||||
|  | EndProject | ||||||
|  | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FleetClientBase", "..\..\Service\DataModel\FleetClientBase\FleetClientBase.csproj", "{B0110465-8537-4FE7-BEE6-B10FAA0BA92D}" | ||||||
|  | EndProject | ||||||
|  | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FleetServiceClient", "..\..\Service\DataModel\FleetServiceClient\FleetServiceClient.csproj", "{A872B915-D7F0-4E7F-81E7-742DBB4DBBBA}" | ||||||
|  | EndProject | ||||||
|  | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FIChartLib", "..\..\..\FI_G3\FICG5Core\FICore\FIChartLib\FIChartLib.csproj", "{C181BD0E-4B98-4ADC-BA92-BB389550D1F6}" | ||||||
|  | EndProject | ||||||
| Global | Global | ||||||
| 	GlobalSection(SolutionConfigurationPlatforms) = preSolution | 	GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||||||
| 		Debug|Any CPU = Debug|Any CPU | 		Debug|Any CPU = Debug|Any CPU | ||||||
| @@ -60,10 +93,79 @@ Global | |||||||
| 		{B5E29343-DF46-47DE-A8E8-69BCF58C0697}.Debug|Any CPU.Build.0 = Debug|Any CPU | 		{B5E29343-DF46-47DE-A8E8-69BCF58C0697}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||||
| 		{B5E29343-DF46-47DE-A8E8-69BCF58C0697}.Release|Any CPU.ActiveCfg = Release|Any CPU | 		{B5E29343-DF46-47DE-A8E8-69BCF58C0697}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||||
| 		{B5E29343-DF46-47DE-A8E8-69BCF58C0697}.Release|Any CPU.Build.0 = Release|Any CPU | 		{B5E29343-DF46-47DE-A8E8-69BCF58C0697}.Release|Any CPU.Build.0 = Release|Any CPU | ||||||
|  | 		{BE465497-20E8-4C29-B98F-3AF19996F1CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||||||
|  | 		{BE465497-20E8-4C29-B98F-3AF19996F1CB}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||||
|  | 		{BE465497-20E8-4C29-B98F-3AF19996F1CB}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||||
|  | 		{BE465497-20E8-4C29-B98F-3AF19996F1CB}.Release|Any CPU.Build.0 = Release|Any CPU | ||||||
|  | 		{64030316-4944-43C1-8F35-C7AE6BD71518}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||||||
|  | 		{64030316-4944-43C1-8F35-C7AE6BD71518}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||||
|  | 		{64030316-4944-43C1-8F35-C7AE6BD71518}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||||
|  | 		{64030316-4944-43C1-8F35-C7AE6BD71518}.Release|Any CPU.Build.0 = Release|Any CPU | ||||||
|  | 		{6DADAE33-4436-4D6D-96FD-3AB415AA826F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||||||
|  | 		{6DADAE33-4436-4D6D-96FD-3AB415AA826F}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||||
|  | 		{6DADAE33-4436-4D6D-96FD-3AB415AA826F}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||||
|  | 		{6DADAE33-4436-4D6D-96FD-3AB415AA826F}.Release|Any CPU.Build.0 = Release|Any CPU | ||||||
|  | 		{39E2A8C6-F58F-4839-B7C1-82D44153FC3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||||||
|  | 		{39E2A8C6-F58F-4839-B7C1-82D44153FC3A}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||||
|  | 		{39E2A8C6-F58F-4839-B7C1-82D44153FC3A}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||||
|  | 		{39E2A8C6-F58F-4839-B7C1-82D44153FC3A}.Release|Any CPU.Build.0 = Release|Any CPU | ||||||
|  | 		{DDDA41C4-099D-4614-8925-B11F70459886}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||||||
|  | 		{DDDA41C4-099D-4614-8925-B11F70459886}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||||
|  | 		{DDDA41C4-099D-4614-8925-B11F70459886}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||||
|  | 		{DDDA41C4-099D-4614-8925-B11F70459886}.Release|Any CPU.Build.0 = Release|Any CPU | ||||||
|  | 		{A2948428-15E6-4BBC-B46D-3EFDA3D5F34C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||||||
|  | 		{A2948428-15E6-4BBC-B46D-3EFDA3D5F34C}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||||
|  | 		{A2948428-15E6-4BBC-B46D-3EFDA3D5F34C}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||||
|  | 		{A2948428-15E6-4BBC-B46D-3EFDA3D5F34C}.Release|Any CPU.Build.0 = Release|Any CPU | ||||||
|  | 		{4963DEB2-F0E3-44A3-B5E1-E13E191A8DE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||||||
|  | 		{4963DEB2-F0E3-44A3-B5E1-E13E191A8DE8}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||||
|  | 		{4963DEB2-F0E3-44A3-B5E1-E13E191A8DE8}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||||
|  | 		{4963DEB2-F0E3-44A3-B5E1-E13E191A8DE8}.Release|Any CPU.Build.0 = Release|Any CPU | ||||||
|  | 		{3FFA4093-4325-4FBB-A874-F288BFDCF7BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||||||
|  | 		{3FFA4093-4325-4FBB-A874-F288BFDCF7BA}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||||
|  | 		{3FFA4093-4325-4FBB-A874-F288BFDCF7BA}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||||
|  | 		{3FFA4093-4325-4FBB-A874-F288BFDCF7BA}.Release|Any CPU.Build.0 = Release|Any CPU | ||||||
|  | 		{F47EBF77-EED3-44E2-9983-EF556372A648}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||||||
|  | 		{F47EBF77-EED3-44E2-9983-EF556372A648}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||||
|  | 		{F47EBF77-EED3-44E2-9983-EF556372A648}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||||
|  | 		{F47EBF77-EED3-44E2-9983-EF556372A648}.Release|Any CPU.Build.0 = Release|Any CPU | ||||||
|  | 		{E4DB03B6-8D79-4B54-BBAE-3F916FED4398}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||||||
|  | 		{E4DB03B6-8D79-4B54-BBAE-3F916FED4398}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||||
|  | 		{E4DB03B6-8D79-4B54-BBAE-3F916FED4398}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||||
|  | 		{E4DB03B6-8D79-4B54-BBAE-3F916FED4398}.Release|Any CPU.Build.0 = Release|Any CPU | ||||||
|  | 		{8650F244-1D1A-4627-8B15-8FFA4B34932F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||||||
|  | 		{8650F244-1D1A-4627-8B15-8FFA4B34932F}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||||
|  | 		{8650F244-1D1A-4627-8B15-8FFA4B34932F}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||||
|  | 		{8650F244-1D1A-4627-8B15-8FFA4B34932F}.Release|Any CPU.Build.0 = Release|Any CPU | ||||||
|  | 		{B0110465-8537-4FE7-BEE6-B10FAA0BA92D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||||||
|  | 		{B0110465-8537-4FE7-BEE6-B10FAA0BA92D}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||||
|  | 		{B0110465-8537-4FE7-BEE6-B10FAA0BA92D}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||||
|  | 		{B0110465-8537-4FE7-BEE6-B10FAA0BA92D}.Release|Any CPU.Build.0 = Release|Any CPU | ||||||
|  | 		{A872B915-D7F0-4E7F-81E7-742DBB4DBBBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||||||
|  | 		{A872B915-D7F0-4E7F-81E7-742DBB4DBBBA}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||||
|  | 		{A872B915-D7F0-4E7F-81E7-742DBB4DBBBA}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||||
|  | 		{A872B915-D7F0-4E7F-81E7-742DBB4DBBBA}.Release|Any CPU.Build.0 = Release|Any CPU | ||||||
|  | 		{C181BD0E-4B98-4ADC-BA92-BB389550D1F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||||||
|  | 		{C181BD0E-4B98-4ADC-BA92-BB389550D1F6}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||||
|  | 		{C181BD0E-4B98-4ADC-BA92-BB389550D1F6}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||||
|  | 		{C181BD0E-4B98-4ADC-BA92-BB389550D1F6}.Release|Any CPU.Build.0 = Release|Any CPU | ||||||
| 	EndGlobalSection | 	EndGlobalSection | ||||||
| 	GlobalSection(SolutionProperties) = preSolution | 	GlobalSection(SolutionProperties) = preSolution | ||||||
| 		HideSolutionNode = FALSE | 		HideSolutionNode = FALSE | ||||||
| 	EndGlobalSection | 	EndGlobalSection | ||||||
|  | 	GlobalSection(NestedProjects) = preSolution | ||||||
|  | 		{39E2A8C6-F58F-4839-B7C1-82D44153FC3A} = {A29EDD95-7564-4A09-AD02-4FF284082DA9} | ||||||
|  | 		{DDDA41C4-099D-4614-8925-B11F70459886} = {A29EDD95-7564-4A09-AD02-4FF284082DA9} | ||||||
|  | 		{A2948428-15E6-4BBC-B46D-3EFDA3D5F34C} = {A29EDD95-7564-4A09-AD02-4FF284082DA9} | ||||||
|  | 		{4963DEB2-F0E3-44A3-B5E1-E13E191A8DE8} = {A29EDD95-7564-4A09-AD02-4FF284082DA9} | ||||||
|  | 		{3FFA4093-4325-4FBB-A874-F288BFDCF7BA} = {A29EDD95-7564-4A09-AD02-4FF284082DA9} | ||||||
|  | 		{F47EBF77-EED3-44E2-9983-EF556372A648} = {A29EDD95-7564-4A09-AD02-4FF284082DA9} | ||||||
|  | 		{E4DB03B6-8D79-4B54-BBAE-3F916FED4398} = {A29EDD95-7564-4A09-AD02-4FF284082DA9} | ||||||
|  | 		{8650F244-1D1A-4627-8B15-8FFA4B34932F} = {A29EDD95-7564-4A09-AD02-4FF284082DA9} | ||||||
|  | 		{B0110465-8537-4FE7-BEE6-B10FAA0BA92D} = {B7B7275E-2530-4E8D-9AE3-C49B4BADCF67} | ||||||
|  | 		{A872B915-D7F0-4E7F-81E7-742DBB4DBBBA} = {B7B7275E-2530-4E8D-9AE3-C49B4BADCF67} | ||||||
|  | 		{C181BD0E-4B98-4ADC-BA92-BB389550D1F6} = {A29EDD95-7564-4A09-AD02-4FF284082DA9} | ||||||
|  | 	EndGlobalSection | ||||||
| 	GlobalSection(ExtensibilityGlobals) = postSolution | 	GlobalSection(ExtensibilityGlobals) = postSolution | ||||||
| 		SolutionGuid = {BAE453CC-00EC-4D9C-902A-AF8F249C8653} | 		SolutionGuid = {BAE453CC-00EC-4D9C-902A-AF8F249C8653} | ||||||
| 	EndGlobalSection | 	EndGlobalSection | ||||||
|   | |||||||
| @@ -1,23 +1,47 @@ | |||||||
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||||
| <configuration> | <configuration> | ||||||
|   <appSettings> |   <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="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="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="ClientSettingsProvider.ServiceUri" value="" /> | ||||||
|   </appSettings> |   </appSettings> | ||||||
|   <startup> |   <startup> | ||||||
|     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/> |     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> | ||||||
|   </startup> |   </startup> | ||||||
|   <system.web> |   <system.web> | ||||||
|     <membership defaultProvider="ClientAuthenticationMembershipProvider"> |     <membership defaultProvider="ClientAuthenticationMembershipProvider"> | ||||||
|       <providers> |       <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> |       </providers> | ||||||
|     </membership> |     </membership> | ||||||
|     <roleManager defaultProvider="ClientRoleProvider" enabled="true"> |     <roleManager defaultProvider="ClientRoleProvider" enabled="true"> | ||||||
|       <providers> |       <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> |       </providers> | ||||||
|     </roleManager> |     </roleManager> | ||||||
|   </system.web> |   </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> | </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 Newtonsoft.Json; | ||||||
| using Foresight.Data; | using Foresight.Data; | ||||||
| using IronIntel.Contractor.Users; | using IronIntel.Contractor.Users; | ||||||
| using IronIntel.Contractor.Attachment; | using Foresight.Fleet.Services; | ||||||
| using Foresight.Fleet.Services.Attachment; |  | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor | namespace IronIntel.Contractor | ||||||
| { | { | ||||||
| @@ -152,24 +151,12 @@ namespace IronIntel.Contractor | |||||||
|             db.ExecSQL(sql); |             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)) |             if (string.IsNullOrEmpty(custid)) | ||||||
|                 custid = SystemParams.CompanyID; |                 custid = SystemParams.CompanyID; | ||||||
|             Foresight.Fleet.Services.Attachment.AttachmentInfo att = FleetServiceClientHelper.CreateClient<AttachmentClient>(custid, sessionid).GetAttachment(custid, attid); |             Tuple<string, byte[]> attr = FleetServiceClientHelper.CreateClient<AttachmentProvider>(custid, sessionid).GetAttachmentData(custid, attid); | ||||||
|             AttachmentItem item = new AttachmentItem(); |             return attr; | ||||||
|             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; |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -3,91 +3,26 @@ using System.Collections.Generic; | |||||||
| using System.Linq; | using System.Linq; | ||||||
| using System.Text; | using System.Text; | ||||||
| using Foresight.Cache; | using Foresight.Cache; | ||||||
| using Foresight.Cache.AspNet; | using Foresight.Service.Cache; | ||||||
| using Foresight.Cache.Redis; | using Foresight.Fleet.Services.SystemOption; | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor | namespace IronIntel.Contractor | ||||||
| { | { | ||||||
|     public static class CacheManager |     public static class CacheManager | ||||||
|     { |     { | ||||||
|         public static void Dispose() |  | ||||||
|         { |  | ||||||
|             if (_Client != null) |  | ||||||
|             { |  | ||||||
|                 _Client.Dispose(); |  | ||||||
|                 _Client = null; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private static CacheClient _Client = null; |         private static CacheClient _Client = null; | ||||||
|         private static object _sycobj = new object(); |         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)) |             if ((servers == null) || (servers.Length == 0)) | ||||||
|             { |             { | ||||||
|                 return null; |                 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 |             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()); |  | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|      |      | ||||||
| @@ -101,7 +36,7 @@ namespace IronIntel.Contractor | |||||||
|                     { |                     { | ||||||
|                         if (_Client == null) |                         if (_Client == null) | ||||||
|                         { |                         { | ||||||
|                             InitCacheClient(); |                             _Client = CreateRedisClient(); | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|   | |||||||
| @@ -1,11 +1,10 @@ | |||||||
| using Foresight.Data; | using Foresight.Data; | ||||||
|  | using Foresight.Fleet.Services.Asset; | ||||||
| using Foresight.ServiceModel; | using Foresight.ServiceModel; | ||||||
| using IronIntel.Contractor.Machines; | using IronIntel.Contractor.Machines; | ||||||
| using IronIntel.Contractor.Maintenance; | using IronIntel.Contractor.Maintenance; | ||||||
| using IronIntel.Contractor.MapView; | using IronIntel.Contractor.MapView; | ||||||
| using IronIntel.Contractor.Users; | using IronIntel.Contractor.Users; | ||||||
| using IronIntel.Services.Business.Admin; |  | ||||||
| using IronIntel.Services.Customers; |  | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using System.Data; | using System.Data; | ||||||
| @@ -84,9 +83,9 @@ namespace IronIntel.Contractor.Contact | |||||||
|                 return new MaintenanceMachineInfo[0]; |                 return new MaintenanceMachineInfo[0]; | ||||||
|             } |             } | ||||||
|             MachineManagement.RefreshBaseData(); |             MachineManagement.RefreshBaseData(); | ||||||
|             MachineMake[] makes = MachineManagement.GetMachineMakes(); |             AssetMake[] makes = MachineManagement.GetMachineMakes(); | ||||||
|             MachineModel[] models = MachineManagement.GetMachineModels(); |             AssetModel[] models = MachineManagement.GetMachineModels(); | ||||||
|             MachineType[] types = MachineManagement.GetMachineTypes(); |             AssetType[] types = MachineManagement.GetMachineTypes(); | ||||||
|             List<MaintenanceMachineInfo> ls = new List<MaintenanceMachineInfo>(); |             List<MaintenanceMachineInfo> ls = new List<MaintenanceMachineInfo>(); | ||||||
|             foreach (DataRow dr in tb.Rows) |             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) |         private static ContactInfo ConvertToContactInfo(DataRow dr) | ||||||
|         { |         { | ||||||
|             ContactInfo ci = new ContactInfo(); |             ContactInfo ci = new ContactInfo(); | ||||||
| @@ -143,8 +125,6 @@ namespace IronIntel.Contractor.Contact | |||||||
|             return ci; |             return ci; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         public static JobSiteViewItem[] GetContactJobsitesByID(string contactid) |         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  |             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); |             js.BaseOnMachineID = FIDbAccess.GetFieldInt(dr["BASEONMACHINEID"], 0); | ||||||
|             return js; |             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 == null) return null; | ||||||
|             if (s.GetType() != typeof(string)) return s; |             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 = |             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]"; |                 "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x7f]"; | ||||||
|  |  | ||||||
|             //取代其中無效字元, 通通換成空字串 |             //取代其中無效字元, 通通換成空字串 | ||||||
| @@ -247,7 +250,7 @@ namespace IronIntel.Contractor | |||||||
|                         cellData.FormatCode = ""; |                         cellData.FormatCode = ""; | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|                     cellData.Value = rdc.ColumnName; |                     cellData.Value = rdc.Caption; | ||||||
|  |  | ||||||
|                     rowData.Add(cellData); |                     rowData.Add(cellData); | ||||||
|                 } |                 } | ||||||
| @@ -269,31 +272,53 @@ namespace IronIntel.Contractor | |||||||
|                         rdc = data.Columns[q]; |                         rdc = data.Columns[q]; | ||||||
|  |  | ||||||
|                         string format = ""; |                         string format = ""; | ||||||
|                         //if (rdc != null) |                         if (rdc != null) | ||||||
|                         //{ |                         { | ||||||
|                         //if (rdc.Attributes != null && rdc.Attributes.ContainsKey("DataFormat")) |                             if (rdc.ExtendedProperties != null && rdc.ExtendedProperties.ContainsKey("DataFormat")) | ||||||
|                         //{ |                             { | ||||||
|                         //    format = (rdc.Attributes["DataFormat"] == null |                                 format = (rdc.ExtendedProperties["DataFormat"] == null | ||||||
|                         //        ? "" |                                     ? "" | ||||||
|                         //        : rdc.Attributes["DataFormat"].ToString()); |                                     : rdc.ExtendedProperties["DataFormat"].ToString()); | ||||||
|                         //} |                             } | ||||||
|                         //} |                         } | ||||||
|  |  | ||||||
|                         cellData = new ChartFormatedData(); |                         cellData = new ChartFormatedData(); | ||||||
|  |  | ||||||
|                         //将特殊格式值处理成字符串显示。 |                         //将特殊格式值处理成字符串显示。 | ||||||
|  |                         CExcelCellValue cExcelValue = null; | ||||||
|                         if (rdr != null) |                         if (rdr != null) | ||||||
|                         { |                         { | ||||||
|                             bool isProcessed = false; |                             bool isProcessed = false; | ||||||
|  |                             object cValue = rdr[q]; | ||||||
|  |                             if (cValue is CExcelCellValue) | ||||||
|  |                             { | ||||||
|  |                                 cExcelValue = (cValue as CExcelCellValue); | ||||||
|  |                                 cValue = cExcelValue.Value; | ||||||
|  |                             } | ||||||
|                             cellData.Value = |                             cellData.Value = | ||||||
|                                 ConvertIvalidChars( |                                 ConvertIvalidChars( | ||||||
|                                     ProcessSpecialFormat(rdr[q], format, ref isProcessed)); |                                     ProcessSpecialFormat(cValue, format, ref isProcessed)); | ||||||
|                             if (isProcessed) format = ""; |                             if (isProcessed) format = ""; | ||||||
|                         } |                         } | ||||||
|                         cellData.FormatCode = ProcessFormat(format); |                         cellData.FormatCode = ProcessFormat(format); | ||||||
|                         cellData.DataType = |                         cellData.DataType = | ||||||
|                             GetDataType((cellData.Value == null ? typeof(string) : cellData.Value.GetType())); |                             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 = ""; |                         string alignment = ""; | ||||||
|                         if (rdc != null) |                         if (rdc != null) | ||||||
|                         { |                         { | ||||||
| @@ -304,6 +329,14 @@ namespace IronIntel.Contractor | |||||||
|                             cellData.CAlignment = new CellAlignment(); |                             cellData.CAlignment = new CellAlignment(); | ||||||
|                             cellData.CAlignment.Align = GetAlignment(alignment); |                             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) |                         //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) |         private string ConvertColNumber(int colnum) | ||||||
|         { |         { | ||||||
|             string zzz = "Z+"; |             string zzz = "Z+"; | ||||||
| @@ -477,6 +541,10 @@ namespace IronIntel.Contractor | |||||||
|             { |             { | ||||||
|                 resultFormat = resultFormat.Replace("@", "\"@\""); |                 resultFormat = resultFormat.Replace("@", "\"@\""); | ||||||
|             } |             } | ||||||
|  |             if (format.IndexOf("\n") >= 0) | ||||||
|  |             { | ||||||
|  |                 resultFormat = resultFormat.Replace("@", "\"@\""); | ||||||
|  |             } | ||||||
|             return resultFormat; |             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; } |             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.Configuration; | ||||||
| using System.Data; | using System.Data; | ||||||
| using Foresight.Data; | using Foresight.Data; | ||||||
| using IronIntel.Services; |  | ||||||
| using IronIntel.Services.Customers; |  | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor.FilterQ | namespace IronIntel.Contractor.FilterQ | ||||||
| { | { | ||||||
|   | |||||||
| @@ -5,6 +5,7 @@ using System.Text; | |||||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||||
| using System.Configuration; | using System.Configuration; | ||||||
| using Foresight.Fleet.Services; | using Foresight.Fleet.Services; | ||||||
|  | using Foresight.Standard; | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor | namespace IronIntel.Contractor | ||||||
| { | { | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
|  | using System.Drawing; | ||||||
|  | using System.IO; | ||||||
| using System.Linq; | using System.Linq; | ||||||
| using System.Reflection; | using System.Reflection; | ||||||
| using System.Text; | using System.Text; | ||||||
| @@ -11,6 +13,33 @@ namespace IronIntel.Contractor | |||||||
|     { |     { | ||||||
|         public static readonly DateTime DBMinDateTime = new DateTime(1900, 01, 01); |         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) |         public static bool IsTrue(string s) | ||||||
|         { |         { | ||||||
|             const string YES = "Yes"; |             const string YES = "Yes"; | ||||||
| @@ -88,5 +117,184 @@ namespace IronIntel.Contractor | |||||||
|                 return value; |                 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.Collections.Generic; | ||||||
| using System.Configuration; | using System.Configuration; | ||||||
| using System.Linq; | using System.Linq; | ||||||
| @@ -21,7 +22,7 @@ namespace IronIntel.Contractor | |||||||
|             { |             { | ||||||
|                 if (_LoginSessionCookieName == null) |                 if (_LoginSessionCookieName == null) | ||||||
|                 { |                 { | ||||||
|                     _LoginSessionCookieName = Site.IronIntelBasePage.LOGINSESSION_COOKIENAME; |                     _LoginSessionCookieName = IronIntelBasePage.LOGINSESSION_COOKIENAME; | ||||||
|                 } |                 } | ||||||
|                 return _LoginSessionCookieName; |                 return _LoginSessionCookieName; | ||||||
|             } |             } | ||||||
| @@ -34,7 +35,7 @@ namespace IronIntel.Contractor | |||||||
|             { |             { | ||||||
|                 if (_LanguageCookieName == null) |                 if (_LanguageCookieName == null) | ||||||
|                 { |                 { | ||||||
|                     _LanguageCookieName = LoginSessionCookieName + "language"; |                     _LanguageCookieName = IronIntelBasePage.LANGUAGE_COOKIENAME; | ||||||
|                 } |                 } | ||||||
|                 return _LanguageCookieName; |                 return _LanguageCookieName; | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -72,7 +72,7 @@ namespace IronIntel.Contractor | |||||||
|             catch (Exception ex) |             catch (Exception ex) | ||||||
|             { |             { | ||||||
|                 SystemParams.WriteLog("ERROR", "DeleteUserGroup", ex.Message, ex.ToString()); |                 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; |             return null; | ||||||
|         } |         } | ||||||
| @@ -176,7 +176,7 @@ namespace IronIntel.Contractor | |||||||
|             if (flag) |             if (flag) | ||||||
|             { |             { | ||||||
|                 SystemParams.WriteLog("ERROR", "SaveUser", "user try to edit user with illegal permission.", string.Format("current user: {0}, {1}", CurrentUserIID, CurrentUserName)); |                 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; |             return null; | ||||||
|         } |         } | ||||||
| @@ -217,19 +217,19 @@ namespace IronIntel.Contractor | |||||||
|  |  | ||||||
|             if (string.IsNullOrWhiteSpace(user.ID)) |             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) |             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)) |             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) |             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(); |             user.ID = user.ID.Trim(); | ||||||
|             if (user.ID.Length > 100) |             if (user.ID.Length > 100) | ||||||
| @@ -400,7 +400,7 @@ namespace IronIntel.Contractor | |||||||
|             } |             } | ||||||
|             if (string.IsNullOrWhiteSpace(group.Name)) |             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 |             // users | ||||||
| @@ -511,7 +511,7 @@ namespace IronIntel.Contractor | |||||||
|  |  | ||||||
|         public UserPermissionData[] GetUserOrGroupPermission(string UserOrGroup, string objIID) |         public UserPermissionData[] GetUserOrGroupPermission(string UserOrGroup, string objIID) | ||||||
|         { |         { | ||||||
|             return UserManagement.GetUserOrGroupPermission(UserOrGroup, objIID, CurrentUserIID); |             return UserManagement.GetUserOrGroupPermission(UserOrGroup, objIID, CurrentUserIID, ClientLanguage); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         #region - System Options - |         #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"> |     <Reference Include="DocumentFormat.OpenXml"> | ||||||
|       <HintPath>..\Reflib\DocumentFormat.OpenXml.dll</HintPath> |       <HintPath>..\Reflib\DocumentFormat.OpenXml.dll</HintPath> | ||||||
|     </Reference> |     </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"> |     <Reference Include="FICBLC"> | ||||||
|       <HintPath>..\Reflib\FIC\FICBLC.dll</HintPath> |       <HintPath>..\Reflib\FIC\FICBLC.dll</HintPath> | ||||||
|     </Reference> |     </Reference> | ||||||
|     <Reference Include="FICIntf"> |     <Reference Include="FICIntf"> | ||||||
|       <HintPath>..\Reflib\FIC\FICIntf.dll</HintPath> |       <HintPath>..\Reflib\FIC\FICIntf.dll</HintPath> | ||||||
|     </Reference> |     </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"> |     <Reference Include="FICIntfAdv, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b006d6021b5c4397, processorArchitecture=MSIL"> | ||||||
|       <SpecificVersion>False</SpecificVersion> |       <SpecificVersion>False</SpecificVersion> | ||||||
|       <HintPath>..\Reflib\FIC\FICIntfAdv.dll</HintPath> |       <HintPath>..\Reflib\FIC\FICIntfAdv.dll</HintPath> | ||||||
| @@ -75,49 +69,34 @@ | |||||||
|     <Reference Include="FIWinLib"> |     <Reference Include="FIWinLib"> | ||||||
|       <HintPath>..\Reflib\FIWinLib.dll</HintPath> |       <HintPath>..\Reflib\FIWinLib.dll</HintPath> | ||||||
|     </Reference> |     </Reference> | ||||||
|     <Reference Include="FleetClientBase"> |     <Reference Include="Foresight.Service.Client"> | ||||||
|       <HintPath>..\Reflib\FleetClientBase.dll</HintPath> |       <HintPath>..\Reflib\Foresight.Service.Client.dll</HintPath> | ||||||
|     </Reference> |  | ||||||
|     <Reference Include="FleetServiceClient"> |  | ||||||
|       <HintPath>..\Reflib\FleetServiceClient.dll</HintPath> |  | ||||||
|     </Reference> |     </Reference> | ||||||
|     <Reference Include="Foresight.ServiceModel"> |     <Reference Include="Foresight.ServiceModel"> | ||||||
|       <HintPath>..\Reflib\Foresight.ServiceModel.dll</HintPath> |       <HintPath>..\Reflib\Foresight.ServiceModel.dll</HintPath> | ||||||
|     </Reference> |     </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"> |     <Reference Include="irondbobjlib"> | ||||||
|       <HintPath>..\Reflib\irondbobjlib.dll</HintPath> |       <HintPath>..\Reflib\irondbobjlib.dll</HintPath> | ||||||
|     </Reference> |     </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"> |     <Reference Include="Newtonsoft.Json"> | ||||||
|       <HintPath>..\Reflib\Newtonsoft.Json.dll</HintPath> |       <HintPath>..\Reflib\Newtonsoft.Json.dll</HintPath> | ||||||
|     </Reference> |     </Reference> | ||||||
|     <Reference Include="System" /> |     <Reference Include="System" /> | ||||||
|     <Reference Include="System.Configuration" /> |     <Reference Include="System.Configuration" /> | ||||||
|     <Reference Include="System.Core" /> |     <Reference Include="System.Core" /> | ||||||
|     <Reference Include="System.Data.SqlClient, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> |     <Reference Include="System.Data.SqlClient, Version=4.6.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||||||
|       <HintPath>..\packages\System.Data.SqlClient.4.6.0\lib\net461\System.Data.SqlClient.dll</HintPath> |       <HintPath>..\packages\System.Data.SqlClient.4.8.1\lib\net461\System.Data.SqlClient.dll</HintPath> | ||||||
|  |       <SpecificVersion>False</SpecificVersion> | ||||||
|     </Reference> |     </Reference> | ||||||
|     <Reference Include="System.Drawing" /> |     <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" /> | ||||||
|     <Reference Include="System.Web.Extensions" /> |     <Reference Include="System.Web.Extensions" /> | ||||||
|     <Reference Include="System.Xml.Linq" /> |     <Reference Include="System.Xml.Linq" /> | ||||||
| @@ -130,16 +109,19 @@ | |||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <Compile Include="AttachmentsManagement.cs" /> |     <Compile Include="AttachmentsManagement.cs" /> | ||||||
|     <Compile Include="Attachment\AttachmentItem.cs" /> |  | ||||||
|     <Compile Include="BusinessBase.cs" /> |     <Compile Include="BusinessBase.cs" /> | ||||||
|     <Compile Include="CacheManager.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="ExportExcelManager.cs" /> | ||||||
|     <Compile Include="ExportExcel\ConvertFormat.cs" /> |     <Compile Include="ExportExcel\ConvertFormat.cs" /> | ||||||
|     <Compile Include="ExportExcel\ExcelXlsx.cs" /> |     <Compile Include="ExportExcel\ExcelXlsx.cs" /> | ||||||
|     <Compile Include="ExportExcel\ExportToExcel.cs" /> |     <Compile Include="ExportExcel\ExportToExcel.cs" /> | ||||||
|     <Compile Include="ExportExcel\IOpenXmlExcelStyleAndData.cs" /> |     <Compile Include="ExportExcel\IOpenXmlExcelStyleAndData.cs" /> | ||||||
|     <Compile Include="ExportExcel\XlsxObj.cs" /> |     <Compile Include="ExportExcel\XlsxObj.cs" /> | ||||||
|  |     <Compile Include="FICExtDataTable\AssetTripsDataTable.cs" /> | ||||||
|  |     <Compile Include="FICExtDataTable\FleetExtDataTable.cs" /> | ||||||
|     <Compile Include="FITracker\FITrackerManagement.cs" /> |     <Compile Include="FITracker\FITrackerManagement.cs" /> | ||||||
|     <Compile Include="FleetServiceClientHelper.cs" /> |     <Compile Include="FleetServiceClientHelper.cs" /> | ||||||
|     <Compile Include="Host\ClientModels.cs" /> |     <Compile Include="Host\ClientModels.cs" /> | ||||||
| @@ -149,6 +131,10 @@ | |||||||
|     <Compile Include="Helper.cs" /> |     <Compile Include="Helper.cs" /> | ||||||
|     <Compile Include="Host\HostRequesEntry.cs" /> |     <Compile Include="Host\HostRequesEntry.cs" /> | ||||||
|     <Compile Include="Host\HostService.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="MachineDetailWorkspace.cs" /> | ||||||
|     <Compile Include="Machines\FuelusedInfo.cs" /> |     <Compile Include="Machines\FuelusedInfo.cs" /> | ||||||
|     <Compile Include="Machines\IdlehoursInfo.cs" /> |     <Compile Include="Machines\IdlehoursInfo.cs" /> | ||||||
| @@ -160,6 +146,7 @@ | |||||||
|     <Compile Include="Machines\OdometerInfo.cs" /> |     <Compile Include="Machines\OdometerInfo.cs" /> | ||||||
|     <Compile Include="Maintenance\AlertInfo.cs" /> |     <Compile Include="Maintenance\AlertInfo.cs" /> | ||||||
|     <Compile Include="Maintenance\AlertManager.cs" /> |     <Compile Include="Maintenance\AlertManager.cs" /> | ||||||
|  |     <Compile Include="Maintenance\AlertQueryParams.cs" /> | ||||||
|     <Compile Include="Maintenance\FuelRecordInfo.cs" /> |     <Compile Include="Maintenance\FuelRecordInfo.cs" /> | ||||||
|     <Compile Include="Maintenance\IATCAlertsSyncService.cs" /> |     <Compile Include="Maintenance\IATCAlertsSyncService.cs" /> | ||||||
|     <Compile Include="Maintenance\MaintenanceInfo.cs" /> |     <Compile Include="Maintenance\MaintenanceInfo.cs" /> | ||||||
| @@ -172,8 +159,6 @@ | |||||||
|     <Compile Include="OTRConfig\HarshDrivingItem.cs" /> |     <Compile Include="OTRConfig\HarshDrivingItem.cs" /> | ||||||
|     <Compile Include="OTRConfig\HarshDrivingManagement.cs" /> |     <Compile Include="OTRConfig\HarshDrivingManagement.cs" /> | ||||||
|     <Compile Include="OTRConfig\SpeedingItem.cs" /> |     <Compile Include="OTRConfig\SpeedingItem.cs" /> | ||||||
|     <Compile Include="Security\CurfewInfo.cs" /> |  | ||||||
|     <Compile Include="Security\CurfewManagement.cs" /> |  | ||||||
|     <Compile Include="Security\CurfewMovementToleranceInfo.cs" /> |     <Compile Include="Security\CurfewMovementToleranceInfo.cs" /> | ||||||
|     <Compile Include="Security\JobsiteLimitInfo.cs" /> |     <Compile Include="Security\JobsiteLimitInfo.cs" /> | ||||||
|     <Compile Include="Security\JobsiteLimitManagement.cs" /> |     <Compile Include="Security\JobsiteLimitManagement.cs" /> | ||||||
| @@ -186,10 +171,7 @@ | |||||||
|     <Compile Include="IIColor.cs" /> |     <Compile Include="IIColor.cs" /> | ||||||
|     <Compile Include="IronintelHost.cs" /> |     <Compile Include="IronintelHost.cs" /> | ||||||
|     <Compile Include="JobSites\JobSitesManagement.cs" /> |     <Compile Include="JobSites\JobSitesManagement.cs" /> | ||||||
|     <Compile Include="MapView\JobManagement.cs" /> |  | ||||||
|     <Compile Include="MapView\LocationManagement.cs" /> |  | ||||||
|     <Compile Include="MapView\MachineStateInfo.cs" /> |     <Compile Include="MapView\MachineStateInfo.cs" /> | ||||||
|     <Compile Include="MapView\MachinesMapViewerManagement.cs" /> |  | ||||||
|     <Compile Include="MapView\MapViewer.cs" /> |     <Compile Include="MapView\MapViewer.cs" /> | ||||||
|     <Compile Include="Properties\AssemblyInfo.cs" /> |     <Compile Include="Properties\AssemblyInfo.cs" /> | ||||||
|     <Compile Include="SystemParams.cs" /> |     <Compile Include="SystemParams.cs" /> | ||||||
| @@ -209,6 +191,16 @@ | |||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <WCFMetadata Include="Connected Services\" /> |     <WCFMetadata Include="Connected Services\" /> | ||||||
|   </ItemGroup> |   </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" /> |   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||||||
|   <PropertyGroup> |   <PropertyGroup> | ||||||
|     <PostBuildEvent>copy "$(TargetFileName)" "$(ProjectDir)\..\Site\Bin\$(TargetFileName)"</PostBuildEvent> |     <PostBuildEvent>copy "$(TargetFileName)" "$(ProjectDir)\..\Site\Bin\$(TargetFileName)"</PostBuildEvent> | ||||||
|   | |||||||
| @@ -1,5 +1,6 @@ | |||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
|  | using System.Collections.Concurrent; | ||||||
| using System.Linq; | using System.Linq; | ||||||
| using System.Text; | using System.Text; | ||||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||||
| @@ -15,6 +16,12 @@ using IronIntel.Contractor.Users; | |||||||
| using FI.FIC.Contracts.DataObjects.Enumeration; | using FI.FIC.Contracts.DataObjects.Enumeration; | ||||||
| using System.Web; | using System.Web; | ||||||
| using System.Runtime.Serialization.Formatters.Binary; | 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 | namespace IronIntel.Contractor | ||||||
| { | { | ||||||
| @@ -60,10 +67,12 @@ namespace IronIntel.Contractor | |||||||
|             FICHostEnvironment.SetHost(new IronIntelHost()); |             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) |         public byte[] GetCacheData(string key, bool ignoreExpired, ref DateTime createTime) | ||||||
|         { |         { | ||||||
|             byte[] buffer = CacheManager.GetValue(key); |             byte[] buffer = CacheManager.GetValue(key); | ||||||
|             if (buffer == null) |             if (buffer == null || buffer.Length == 0) | ||||||
|             { |             { | ||||||
|                 return null; |                 return null; | ||||||
|             } |             } | ||||||
| @@ -81,10 +90,18 @@ namespace IronIntel.Contractor | |||||||
|             { |             { | ||||||
|                 return null; |                 return null; | ||||||
|             } |             } | ||||||
|             //FIDataTable tb = new FIDataTable(); |             using (MemoryStream ms = new MemoryStream(buffer, false)) | ||||||
|             //tb.FillFromBuffer(buffer); |             { | ||||||
|             //return FIDbAccess.ConvertDataTable(tb); |                 try | ||||||
|             return Deserialize(buffer) as DataTable; |                 { | ||||||
|  |                     TableReader tr = new TableReader(ms); | ||||||
|  |                     return tr.Read(); | ||||||
|  |                 } | ||||||
|  |                 catch | ||||||
|  |                 { | ||||||
|  |                     return null; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public FICCompanyInfo GetCompanyInfo() |         public FICCompanyInfo GetCompanyInfo() | ||||||
| @@ -99,7 +116,7 @@ namespace IronIntel.Contractor | |||||||
|  |  | ||||||
|         public CompanyLic GetLicense() |         public CompanyLic GetLicense() | ||||||
|         { |         { | ||||||
|             IronIntel.Services.LicenseInfo lic = SystemParams.GetLicense(); |             Foresight.Fleet.Services.Customer.LicenseInfo lic = SystemParams.GetLicense(); | ||||||
|             if (lic == null) |             if (lic == null) | ||||||
|             { |             { | ||||||
|                 return null; |                 return null; | ||||||
| @@ -108,7 +125,7 @@ namespace IronIntel.Contractor | |||||||
|             ci.CompanyID = SystemParams.CompanyID; |             ci.CompanyID = SystemParams.CompanyID; | ||||||
|             ci.CompanyName = SystemParams.CustomerDetail.Name; |             ci.CompanyName = SystemParams.CustomerDetail.Name; | ||||||
|  |  | ||||||
|             Foresight.Security.License.LicenseInfo li = new LicenseInfo(); |             LicenseInfo li = new LicenseInfo(); | ||||||
|             ci.Licenses.Add(li); |             ci.Licenses.Add(li); | ||||||
|             li.CompanyID = ci.CompanyID; |             li.CompanyID = ci.CompanyID; | ||||||
|             li.CompanyName = ci.CompanyName; |             li.CompanyName = ci.CompanyName; | ||||||
| @@ -131,7 +148,7 @@ namespace IronIntel.Contractor | |||||||
|             return ci; |             return ci; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private LicenseAddtionalPropertyObj ConvertLicenseItem(Services.LicenseItem item) |         private LicenseAddtionalPropertyObj ConvertLicenseItem(Foresight.Fleet.Services.Customer.LicenseItem item) | ||||||
|         { |         { | ||||||
|             if (item == null) |             if (item == null) | ||||||
|                 return null; |                 return null; | ||||||
| @@ -184,6 +201,8 @@ namespace IronIntel.Contractor | |||||||
|                 //Mobile = ui.Mobile, |                 //Mobile = ui.Mobile, | ||||||
|                 Mobile = ui.TextAddress, |                 Mobile = ui.TextAddress, | ||||||
|                 BusinessPhone = ui.BusinessPhone, |                 BusinessPhone = ui.BusinessPhone, | ||||||
|  |                 UserLanguage = ui.PreferredLanguage, | ||||||
|  |                 UserTimeZone = ui.TimeZone | ||||||
|             }; |             }; | ||||||
|             switch (ui.UserType) |             switch (ui.UserType) | ||||||
|             { |             { | ||||||
| @@ -206,14 +225,29 @@ namespace IronIntel.Contractor | |||||||
|             return user; |             return user; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         const int EXPIRESECONDS = 600; | ||||||
|  |  | ||||||
|         public FICUserInfo GetUserByIID(string useriid) |         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); |             UserInfo ui = UserManagement.GetUserByIID(useriid); | ||||||
|             if (ui == null) |             if (ui == null) | ||||||
|             { |             { | ||||||
|                 return 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) |         public FICUserInfo GetUserByLoginSessionID(string sessionid) | ||||||
| @@ -223,41 +257,116 @@ namespace IronIntel.Contractor | |||||||
|             { |             { | ||||||
|                 return null; |                 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) |         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); |             UserInfo ui = UserManagement.GetUserByID(userId); | ||||||
|             if (ui == null) |             if (ui == null) | ||||||
|             { |             { | ||||||
|                 return 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() |         public FICUserInfo[] GetUsers() | ||||||
|  |         { | ||||||
|  |             TimeSpan sp = DateTime.Now - _LastGetAllUsersTime; | ||||||
|  |             if (sp.TotalSeconds >= EXPIRESECONDS) | ||||||
|             { |             { | ||||||
|                 UserInfo[] users = UserManagement.GetUsers(); |                 UserInfo[] users = UserManagement.GetUsers(); | ||||||
|             List<FICUserInfo> ls = new List<FICUserInfo>(users.Length); |  | ||||||
|                 foreach (UserInfo ui in users) |                 foreach (UserInfo ui in users) | ||||||
|                 { |                 { | ||||||
|                 ls.Add(ConvertToFICUserInfo(ui)); |                     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(); |             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) |         public string GetUserEmail(string useriid) | ||||||
|         { |         { | ||||||
|             UserInfo ui = UserManagement.GetUserByIID(useriid); |             FICUserInfo u = GetUserByIID(useriid); | ||||||
|             if (ui == null) |             return u == null ? null : u.ID; | ||||||
|             { |  | ||||||
|                 return null; |  | ||||||
|             } |  | ||||||
|             else |  | ||||||
|             { |  | ||||||
|                 return ui.ID; |  | ||||||
|             } |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public void PostMessage(int category, string msg) |         public void PostMessage(int category, string msg) | ||||||
| @@ -310,11 +419,20 @@ namespace IronIntel.Contractor | |||||||
|             } |             } | ||||||
|             else |             else | ||||||
|             { |             { | ||||||
|                 //FIDataTable tb = FIDbAccess.ConvertDataTable(dt, -1); |                 if (dt.Rows.Count > 1000000) | ||||||
|                 byte[] buffer = Serialize(dt, createTime); |                 { | ||||||
|  |                     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); |                     SetCacheData(key, buffer, expirationsecond, slidingExpiration, createTime); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|         public void SubscribeMessage(int category, Action<IEnumerable<MessageInformation>> action) |         public void SubscribeMessage(int category, Action<IEnumerable<MessageInformation>> action) | ||||||
|         { |         { | ||||||
| @@ -323,7 +441,7 @@ namespace IronIntel.Contractor | |||||||
|  |  | ||||||
|         public void WriteLog(string logType, string category, string source, string message, string detail) |         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) |         public List<string> GetUserGroupIDByUserIID(string userIID) | ||||||
| @@ -331,30 +449,12 @@ namespace IronIntel.Contractor | |||||||
|             return UserManagement.GetUserGroupIDByUserIID(userIID); |             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) |         public LoginContext GetCurrentLoginContext(HttpContext context) | ||||||
|         { |         { | ||||||
|             string session = Site.IronIntelBasePage.GetLoginSessionID(context.Request); |             string session = IronIntelBasePage.GetLoginSessionID(context.Request); | ||||||
|             if (string.IsNullOrWhiteSpace(session)) |             if (string.IsNullOrWhiteSpace(session)) | ||||||
|             { |             { | ||||||
|                 return null; |                 return null; | ||||||
| @@ -415,6 +515,28 @@ namespace IronIntel.Contractor | |||||||
|             get { return string.Empty; } |             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) |         public string GetStyleDefines(string useriid) | ||||||
|         { |         { | ||||||
|             //StringBuilder s = new StringBuilder(); |             //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("<Board><Title><Background>#666666</Background><Foreground>#777777</Foreground></Title></Board>"); | ||||||
|             //s.Append("</root>"); |             //s.Append("</root>"); | ||||||
|             //return s.ToString(); |             //return s.ToString(); | ||||||
|             Services.CustUIStyle uistyle = SystemParams.GetUIStyle(useriid); |             CustUIStyle uistyle = SystemParams.GetUIStyle(useriid); | ||||||
|  |  | ||||||
|             StringBuilder s = new StringBuilder(); |             StringBuilder s = new StringBuilder(); | ||||||
|             s.Append(@"<?xml version=""1.0"" encoding=""UTF-8""?>"); |             s.Append(@"<?xml version=""1.0"" encoding=""UTF-8""?>"); | ||||||
| @@ -441,20 +563,7 @@ namespace IronIntel.Contractor | |||||||
|             return SystemParams.GetAdditionalParameter(); |             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() |         public SpecialDatabaseConnectionInfo[] GetSpecialDatabaseConnections() | ||||||
|         { |         { | ||||||
| @@ -542,6 +651,112 @@ namespace IronIntel.Contractor | |||||||
|             return SystemParams.GetCompanyLOGO(SystemParams.CompanyID); |             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 |         #endregion | ||||||
|   | |||||||
| @@ -6,7 +6,6 @@ using Foresight.ServiceModel; | |||||||
| using IronIntel.Contractor.Machines; | using IronIntel.Contractor.Machines; | ||||||
| using IronIntel.Contractor.MapView; | using IronIntel.Contractor.MapView; | ||||||
| using IronIntel.Contractor.Shape; | using IronIntel.Contractor.Shape; | ||||||
| using IronIntel.Services.Business.Admin; |  | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using System.Data; | using System.Data; | ||||||
| @@ -22,31 +21,6 @@ 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"; |         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) |         public static void RefreshJobsiteAssets(string sessionid, long jobsiteid) | ||||||
|         { |         { | ||||||
|             System.Threading.ThreadPool.QueueUserWorkItem((object state) => |             System.Threading.ThreadPool.QueueUserWorkItem((object state) => | ||||||
| @@ -59,17 +33,6 @@ namespace IronIntel.Contractor.JobSites | |||||||
|             }, null); |             }, 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) |         public static void AddMachinesToJobSite(JobSiteViewItem jobsite) | ||||||
|         { |         { | ||||||
|             if (jobsite != null) |             if (jobsite != null) | ||||||
| @@ -82,7 +45,7 @@ namespace IronIntel.Contractor.JobSites | |||||||
|                 string ad = string.Empty; |                 string ad = string.Empty; | ||||||
|                 if (jobsite.Machines != null && jobsite.Machines.Length > 0) |                 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 + ")"; |                     ad = "  and MACHINEID not in(" + machineids + ")"; | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
| @@ -97,14 +60,14 @@ namespace IronIntel.Contractor.JobSites | |||||||
|  |  | ||||||
|                     if (jobsite.Machines != null && jobsite.Machines.Length > 0) |                     if (jobsite.Machines != null && jobsite.Machines.Length > 0) | ||||||
|                     { |                     { | ||||||
|                         foreach (MachineViewItem mac in jobsite.Machines) |                         foreach (var mac in jobsite.Machines) | ||||||
|                         { |                         { | ||||||
|                             if (mac.OnSite) |                             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(); |                     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) |         private static JobSiteViewItem ConvertToJobSiteViewItem(DataRow dr) | ||||||
|         { |         { | ||||||
|             JobSiteViewItem js = new JobSiteViewItem(); |             JobSiteViewItem js = new JobSiteViewItem(); | ||||||
| @@ -183,356 +130,10 @@ namespace IronIntel.Contractor.JobSites | |||||||
|             return list.ToArray(); |             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() |         public static MachineTypeItem[] GetMachineTypes() | ||||||
|         { |         { | ||||||
|             List<MachineTypeItem> mTypes = new List<MachineTypeItem>(); |             List<MachineTypeItem> mTypes = new List<MachineTypeItem>(); | ||||||
|             MachineType[] types = MachineManagement.GetMachineTypes(); |             AssetType[] types = MachineManagement.GetMachineTypes(); | ||||||
|             if (types != null) |             if (types != null) | ||||||
|             { |             { | ||||||
|                 foreach (var t in types) |                 foreach (var t in types) | ||||||
| @@ -543,64 +144,6 @@ namespace IronIntel.Contractor.JobSites | |||||||
|             return mTypes.ToArray(); |             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> |         /// <summary> | ||||||
|         /// 从Shape文件导入Jobsite范围 |         /// 从Shape文件导入Jobsite范围 | ||||||
|         /// </summary> |         /// </summary> | ||||||
| @@ -610,7 +153,12 @@ namespace IronIntel.Contractor.JobSites | |||||||
|         public static MapPoint[] ImportJobsitePolygon(string filename, byte[] buffer) |         public static MapPoint[] ImportJobsitePolygon(string filename, byte[] buffer) | ||||||
|         { |         { | ||||||
|             Shape.Shape shape = new Shape.Shape(); |             Shape.Shape shape = new Shape.Shape(); | ||||||
|  |             if (filename.EndsWith(".shp", StringComparison.OrdinalIgnoreCase)) | ||||||
|                 ShapeFileParser.ParseFromShapeFile(buffer, shape); |                 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) |             if (shape.Polygons.Count > 0 && shape.Polygons[0].Rings.Count > 0) | ||||||
|             { |             { | ||||||
|                 return shape.Polygons[0].Rings[0].Points.ToArray(); |                 return shape.Polygons[0].Rings[0].Points.ToArray(); | ||||||
|   | |||||||
| @@ -65,6 +65,7 @@ namespace IronIntel.Contractor.Machines | |||||||
|         /// 前端选择的时区的分钟偏移 |         /// 前端选择的时区的分钟偏移 | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         public int OffsetMinute { get; set; } |         public int OffsetMinute { get; set; } | ||||||
|  |         public string DataSource { get; set; } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -82,15 +83,15 @@ namespace IronIntel.Contractor.Machines | |||||||
|         { |         { | ||||||
|             get |             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 |         public string EventTimeLocalText | ||||||
|         { |         { | ||||||
|             get |             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 |             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 |         public string EventTimeLocalText | ||||||
|         { |         { | ||||||
|             get |             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 LogId { get; set; } | ||||||
|         public long AssetId { 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 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 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 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 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; |         private double _EngineHours; | ||||||
|         public double EngineHours |         public double EngineHours | ||||||
|   | |||||||
| @@ -20,6 +20,7 @@ namespace IronIntel.Contractor.Machines | |||||||
|         public double Amount { get; set; } |         public double Amount { get; set; } | ||||||
|         public double Percent { get; set; } |         public double Percent { get; set; } | ||||||
|         public string UOM { get; set; } |         public string UOM { get; set; } | ||||||
|  |         public string PercentText { get; set; } | ||||||
|         public string ReceivedDateStr |         public string ReceivedDateStr | ||||||
|         { |         { | ||||||
|             get |             get | ||||||
|   | |||||||
| @@ -1,6 +1,5 @@ | |||||||
| using Foresight.Fleet.Services.Asset; | using Foresight.Fleet.Services.Asset; | ||||||
| using Foresight.ServiceModel; | using Foresight.ServiceModel; | ||||||
| using IronIntel.Services.Business.Admin; |  | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using System.Linq; | 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 TelematicsEnabled { get; set; } | ||||||
|         public bool Hide { get; set; } |         public bool Hide { get; set; } | ||||||
|         public bool OnRoad { get; set; } |         public bool OnRoad { get; set; } | ||||||
|  |         public bool Attachment { get; set; } | ||||||
|  |  | ||||||
|  |         public bool Preloaded { get; set; } | ||||||
|         public int MakeYear { get; set; } |         public int MakeYear { get; set; } | ||||||
|         public string DealerID { get; set; } |         public string DealerID { get; set; } | ||||||
|         public string Dealer { get; set; } |         public string Dealer { get; set; } | ||||||
| @@ -46,6 +48,19 @@ namespace IronIntel.Contractor.Machines | |||||||
|         public int MakeID { get; set; } |         public int MakeID { get; set; } | ||||||
|         public string VIN { get; set; } |         public string VIN { get; set; } | ||||||
|         public DateTime? EngineHoursDate { 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 |         public string DisplayName | ||||||
|         { |         { | ||||||
|             get |             get | ||||||
| @@ -61,8 +76,10 @@ namespace IronIntel.Contractor.Machines | |||||||
|                 return name; |                 return name; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         public string EngineHoursDateStr { get { return EngineHoursDate == null ? "" : EngineHoursDate.Value.ToShortDateString(); } } |         public string AddedTimeStr { get { return (AddedLocalTime == null || AddedLocalTime.Value <= Helper.DBMinDateTime) ? "" : AddedLocalTime.Value.ToShortDateString(); } } | ||||||
|         public string EngineHoursDateTimeStr { get { return EngineHoursDate == null ? "" : EngineHoursDate.Value.ToString(); } } |         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 TelematicsEnabled { get; set; } | ||||||
|         public bool Hidden { get; set; } |         public bool Hidden { get; set; } | ||||||
|         public bool OnRoad { get; set; } |         public bool OnRoad { get; set; } | ||||||
|  |         public bool Attachment { get; set; } | ||||||
|  |  | ||||||
|  |         public bool Preloaded { get; set; } | ||||||
|         public string EQClass { get; set; } |         public string EQClass { get; set; } | ||||||
|         public string CostCenter { get; set; } |         public string CostCenter { get; set; } | ||||||
|         public string AquisitionType { get; set; } |         public string AquisitionType { get; set; } | ||||||
| @@ -133,12 +153,16 @@ namespace IronIntel.Contractor.Machines | |||||||
|  |  | ||||||
|         public string ContractorID { get; set; } |         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[] ContactIDs { get; set; } | ||||||
|         public string[] MachineGroupIDs { get; set; } |         public string[] MachineGroupIDs { get; set; } | ||||||
|         public MachineRentalInfo MachineRental { get; set; } |         public MachineRentalInfo MachineRental { get; set; } | ||||||
|         public MachineAttributeClient[] MachineAttributes { get; set; } |         public MachineAttributeClient[] MachineAttributes { get; set; } | ||||||
|         public StringKeyValue[] VisibleOnWorkOrders { 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 |         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 |     public class DeviceItem | ||||||
|     { |     { | ||||||
| @@ -296,9 +312,14 @@ namespace IronIntel.Contractor.Machines | |||||||
|         public long DeviceID { get; set; } |         public long DeviceID { get; set; } | ||||||
|         public bool FIInstalltion { get; set; } |         public bool FIInstalltion { get; set; } | ||||||
|         public string Installer { 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 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 InvoiceDateStr { get { return InvoiceDate == null ? "" : InvoiceDate.Value.ToShortDateString(); } } | ||||||
|         public string ServiceStartDateStr { get { return ServiceStartDate == null ? "" : ServiceStartDate.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 |     public class PairedAssetItem | ||||||
| @@ -313,15 +334,30 @@ namespace IronIntel.Contractor.Machines | |||||||
|         public double? EngineHours { get; set; } |         public double? EngineHours { get; set; } | ||||||
|         public DateTime? EngineHoursDate { get; set; } |         public DateTime? EngineHoursDate { get; set; } | ||||||
|         public DateTime? EngineHoursLocalDate { 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 string SubmitDateStr { get { return SubmitLocalDate == DateTime.MinValue ? "" : SubmitLocalDate.ToString("M/d/yyyy h:m tt"); } } | ||||||
|         public DateTime SubmitLocalDate { get; set; } |  | ||||||
|         public string UserName { get; set; } |         public void FormatFollowUp() | ||||||
|         public string Comment { get; set; } |         { | ||||||
|         public string SubmitDateStr { get { return SubmitLocalDate == DateTime.MinValue ? "" : SubmitLocalDate.ToString(); } } |             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 |     public class MachineGroup | ||||||
| @@ -400,15 +436,16 @@ namespace IronIntel.Contractor.Machines | |||||||
|  |  | ||||||
|     public class AssetAttachmentItem |     public class AssetAttachmentItem | ||||||
|     { |     { | ||||||
|         public long ID { get; set; } |         public long Id { get; set; } | ||||||
|         public long AssetId { get; set; } |         public string Name { get; set; } | ||||||
|         public string FileName { get; set; } |         public string FileType { get; set; } | ||||||
|         public string AddedByUserIID { get; set; } |  | ||||||
|         public string AddedByUserName { get; set; } |  | ||||||
|         public string Notes { get; set; } |  | ||||||
|         public bool VisibleOnWorkOrder { get; set; } |  | ||||||
|         public DateTime AddedOn { get; set; } |         public DateTime AddedOn { get; set; } | ||||||
|         public string AddedOnStr { get { return AddedOn.ToString(); } } |         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 System.Data; | ||||||
| using Foresight.Data; | using Foresight.Data; | ||||||
| using Foresight.ServiceModel; | using Foresight.ServiceModel; | ||||||
| using IronIntel.Services.Business.Admin; |  | ||||||
| using IronIntel.Services.MapView; |  | ||||||
| using IronIntel.Services.Customers; |  | ||||||
| using IronIntel.Contractor.Maintenance; | using IronIntel.Contractor.Maintenance; | ||||||
| using Foresight.Fleet.Services.Asset; | using Foresight.Fleet.Services.Asset; | ||||||
|  |  | ||||||
| @@ -15,13 +12,13 @@ namespace IronIntel.Contractor.Machines | |||||||
| { | { | ||||||
|     public class MachineManagement |     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 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 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 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"; |         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() |         public static void RefreshMakes() | ||||||
|         { |         { | ||||||
|             MachineMake[] mks = null; |             AssetMake[] mks = null; | ||||||
|             MachineServiceClient2 mc = SystemParams.GetMachineServiceClient(); |             var acp = FleetServiceClientHelper.CreateClient<AssetClassProvider>(); | ||||||
|             try |             try | ||||||
|             { |             { | ||||||
|                 mks = mc.GetMachineMakes(); |                 mks = acp.GetAssetMakes(string.Empty); | ||||||
|             } |             } | ||||||
|             catch |             catch | ||||||
|             { |             { | ||||||
| @@ -61,11 +58,12 @@ namespace IronIntel.Contractor.Machines | |||||||
|  |  | ||||||
|         public static void RefreshMachineTypes() |         public static void RefreshMachineTypes() | ||||||
|         { |         { | ||||||
|             MachineType[] mks = null; |             AssetType[] mks = null; | ||||||
|             MachineServiceClient2 mc = SystemParams.GetMachineServiceClient(); |  | ||||||
|  |             var acp = FleetServiceClientHelper.CreateClient<AssetClassProvider>(); | ||||||
|             try |             try | ||||||
|             { |             { | ||||||
|                 mks = mc.GetMachineTypes(); |                 mks = acp.GetAssetTypes(string.Empty); | ||||||
|             } |             } | ||||||
|             catch |             catch | ||||||
|             { |             { | ||||||
| @@ -82,11 +80,11 @@ namespace IronIntel.Contractor.Machines | |||||||
|  |  | ||||||
|         public static void RefreshModels() |         public static void RefreshModels() | ||||||
|         { |         { | ||||||
|             MachineModel[] mks = null; |             AssetModel[] mks = null; | ||||||
|             MachineServiceClient2 mc = SystemParams.GetMachineServiceClient(); |             var acp = FleetServiceClientHelper.CreateClient<AssetClassProvider>(); | ||||||
|             try |             try | ||||||
|             { |             { | ||||||
|                 mks = mc.GetMachineModels(); |                 mks = acp.GetAssetModels(-1, string.Empty); | ||||||
|             } |             } | ||||||
|             catch |             catch | ||||||
|             { |             { | ||||||
| @@ -101,7 +99,7 @@ namespace IronIntel.Contractor.Machines | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public static MachineMake[] GetMachineMakes() |         public static AssetMake[] GetMachineMakes() | ||||||
|         { |         { | ||||||
|             lock (_sycmakes) |             lock (_sycmakes) | ||||||
|             { |             { | ||||||
| @@ -109,7 +107,7 @@ namespace IronIntel.Contractor.Machines | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public static MachineType[] GetMachineTypes() |         public static AssetType[] GetMachineTypes() | ||||||
|         { |         { | ||||||
|             lock (_syctypes) |             lock (_syctypes) | ||||||
|             { |             { | ||||||
| @@ -117,7 +115,7 @@ namespace IronIntel.Contractor.Machines | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public static MachineModel[] GetMachineModels() |         public static AssetModel[] GetMachineModels() | ||||||
|         { |         { | ||||||
|             lock (_sycmodels) |             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(); |             var makes = GetMachineMakes(); | ||||||
|             foreach (var make in makes) |             foreach (var make in makes) | ||||||
| @@ -153,7 +151,7 @@ namespace IronIntel.Contractor.Machines | |||||||
|             return make == null ? string.Empty : make.Name; |             return make == null ? string.Empty : make.Name; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public static MachineModel GetMachineModel(int modelid) |         public static AssetModel GetMachineModel(int modelid) | ||||||
|         { |         { | ||||||
|             var models = GetMachineModels(); |             var models = GetMachineModels(); | ||||||
|             foreach (var model in models) |             foreach (var model in models) | ||||||
| @@ -181,7 +179,7 @@ namespace IronIntel.Contractor.Machines | |||||||
|             return model == null ? string.Empty : model.Name; |             return model == null ? string.Empty : model.Name; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public static MachineType GetMachineType(int typeid) |         public static AssetType GetMachineType(int typeid) | ||||||
|         { |         { | ||||||
|             var types = GetMachineTypes(); |             var types = GetMachineTypes(); | ||||||
|             foreach (var mtype in types) |             foreach (var mtype in types) | ||||||
| @@ -209,9 +207,9 @@ namespace IronIntel.Contractor.Machines | |||||||
|             return mtype == null ? string.Empty : mtype.Name; |             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) |                 if (id == mk.ID) | ||||||
|                 { |                 { | ||||||
| @@ -221,9 +219,9 @@ namespace IronIntel.Contractor.Machines | |||||||
|             return null; |             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) |                 if (id == mk.ID) | ||||||
|                 { |                 { | ||||||
| @@ -233,9 +231,9 @@ namespace IronIntel.Contractor.Machines | |||||||
|             return null; |             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) |                 if (id == mk.ID) | ||||||
|                 { |                 { | ||||||
| @@ -257,8 +255,8 @@ namespace IronIntel.Contractor.Machines | |||||||
|                 { |                 { | ||||||
|                     try |                     try | ||||||
|                     { |                     { | ||||||
|                         MachineServiceClient2 mc = SystemParams.GetMachineServiceClient(); |                         var acp = FleetServiceClientHelper.CreateClient<AssetClassProvider>(); | ||||||
|                         _DefaultMachineTypeIconUrl = mc.GetDefaultMachineTypeIconUrl(); |                         _DefaultMachineTypeIconUrl = acp.GetDefaultMachineTypeIconUrl(); | ||||||
|                     } |                     } | ||||||
|                     catch |                     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) |         public static bool Contains(string text, string val) | ||||||
|         { |         { | ||||||
|             if (!string.IsNullOrWhiteSpace(text)) |             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) |         public static MachineItem[] GetMachines(string sessionid, string useriid, string searchtxt, string companyid = null) | ||||||
|         { |         { | ||||||
|             string SQL = "select " + string.Format(MachineFields, "") + " from MACHINES  order by MACHINENAME"; |             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); |                     availableAssetsids = FleetServiceClientHelper.CreateClient<AssetQueryClient>(companyid, sessionid).GetAvailableAssetsForUsers(companyid, useriid); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             MachineManagement.RefreshBaseData(); |             RefreshBaseData(); | ||||||
|             MachineMake[] makes = MachineManagement.GetMachineMakes(); |             AssetMake[] makes = GetMachineMakes(); | ||||||
|             MachineModel[] models = MachineManagement.GetMachineModels(); |             AssetModel[] models = GetMachineModels(); | ||||||
|             MachineType[] types = MachineManagement.GetMachineTypes(); |             AssetType[] types = GetMachineTypes(); | ||||||
|  |  | ||||||
|             List<MachineItem> ls = new List<MachineItem>(); |             List<MachineItem> ls = new List<MachineItem>(); | ||||||
|             if (tb.Rows.Count > 0) |             if (tb.Rows.Count > 0) | ||||||
| @@ -425,10 +372,10 @@ namespace IronIntel.Contractor.Machines | |||||||
|             if (user.UserType < Users.UserTypes.Admin) |             if (user.UserType < Users.UserTypes.Admin) | ||||||
|                 availableAssetsids = FleetServiceClientHelper.CreateClient<AssetQueryClient>(companyid, sessionid).GetAvailableAssetsForUsers(companyid, useriid); |                 availableAssetsids = FleetServiceClientHelper.CreateClient<AssetQueryClient>(companyid, sessionid).GetAvailableAssetsForUsers(companyid, useriid); | ||||||
|  |  | ||||||
|             MachineManagement.RefreshBaseData(); |             RefreshBaseData(); | ||||||
|             MachineMake[] makes = MachineManagement.GetMachineMakes(); |             AssetMake[] makes = GetMachineMakes(); | ||||||
|             MachineModel[] models = MachineManagement.GetMachineModels(); |             AssetModel[] models = GetMachineModels(); | ||||||
|             MachineType[] types = MachineManagement.GetMachineTypes(); |             AssetType[] types = GetMachineTypes(); | ||||||
|  |  | ||||||
|             List<MachineItem> ls = new List<MachineItem>(); |             List<MachineItem> ls = new List<MachineItem>(); | ||||||
|             if (tb.Rows.Count > 0) |             if (tb.Rows.Count > 0) | ||||||
| @@ -461,7 +408,7 @@ namespace IronIntel.Contractor.Machines | |||||||
|             return ls.ToArray(); |             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(); |             MachineItem mi = new MachineItem(); | ||||||
|             mi.MachineID = FIDbAccess.GetFieldInt(dr["MACHINEID"], 0); |             mi.MachineID = FIDbAccess.GetFieldInt(dr["MACHINEID"], 0); | ||||||
| @@ -489,15 +436,15 @@ namespace IronIntel.Contractor.Machines | |||||||
|             mi.RetirementOdo = FIDbAccess.GetFieldDouble(dr["RETIREMENTODO"], 0); |             mi.RetirementOdo = FIDbAccess.GetFieldDouble(dr["RETIREMENTODO"], 0); | ||||||
|  |  | ||||||
|             mi.MakeID = FIDbAccess.GetFieldInt(dr["MAKEID"], 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.Make = make == null ? string.Empty : make.Name; | ||||||
|  |  | ||||||
|             mi.ModelID = FIDbAccess.GetFieldInt(dr["MODELID"], 0); |             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.Model = model == null ? string.Empty : model.Name; | ||||||
|  |  | ||||||
|             mi.TypeID = FIDbAccess.GetFieldInt(dr["TYPEID"], 0); |             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.MachineType = mtype == null ? string.Empty : mtype.Name; | ||||||
|             mi.OnRoad = FIDbAccess.GetFieldInt(dr["ONROAD"], 0) == 1; |             mi.OnRoad = FIDbAccess.GetFieldInt(dr["ONROAD"], 0) == 1; | ||||||
|             mi.LeaseStart = FIDbAccess.GetFieldDateTime(dr["LEASESTART"], DateTime.MinValue); |             mi.LeaseStart = FIDbAccess.GetFieldDateTime(dr["LEASESTART"], DateTime.MinValue); | ||||||
| @@ -554,23 +501,6 @@ namespace IronIntel.Contractor.Machines | |||||||
|             return 0; |             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) |         public static int DeleteMachineGroup(string groupID) | ||||||
|         { |         { | ||||||
|             const string SQL_Delete = "delete from MACHINEGROUPS where GROUPID={0} delete from MACHINEGROUPMAP where GROUPID={0} "; |             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) |         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(); |             FIDbAccess db = SystemParams.GetDbInstance(); | ||||||
|             if (db == null) |             if (db == null) | ||||||
| @@ -645,10 +575,10 @@ namespace IronIntel.Contractor.Machines | |||||||
|                 return new MachineItem[0]; |                 return new MachineItem[0]; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             MachineManagement.RefreshBaseData(); |             RefreshBaseData(); | ||||||
|             MachineMake[] makes = MachineManagement.GetMachineMakes(); |             AssetMake[] makes = GetMachineMakes(); | ||||||
|             MachineModel[] models = MachineManagement.GetMachineModels(); |             AssetModel[] models = GetMachineModels(); | ||||||
|             MachineType[] types = MachineManagement.GetMachineTypes(); |             AssetType[] types = GetMachineTypes(); | ||||||
|  |  | ||||||
|             List<MachineItem> ls = new List<MachineItem>(); |             List<MachineItem> ls = new List<MachineItem>(); | ||||||
|             if (tb.Rows.Count > 0) |             if (tb.Rows.Count > 0) | ||||||
| @@ -664,7 +594,7 @@ namespace IronIntel.Contractor.Machines | |||||||
|  |  | ||||||
|         public static MachineGroup[] GetMachineGroupByUser(string useriid, FISqlConnection db = null) |         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) |             if (db == null) | ||||||
|                 db = SystemParams.GetDbInstance(); |                 db = SystemParams.GetDbInstance(); | ||||||
| @@ -682,64 +612,23 @@ namespace IronIntel.Contractor.Machines | |||||||
|             return result.ToArray(); |             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 = "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"; | ||||||
|             const string SQL_InsertDetail = "insert USERMACHINEGROUPMAP(USERIID,GROUPID) values({0},{1})"; |  | ||||||
|             FISqlConnection db = SystemParams.GetDbInstance(); |  | ||||||
|  |  | ||||||
|             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) |             if (db == null) | ||||||
|                 db = SystemParams.GetDbInstance(); |                 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); |                 AssetType mg = new AssetType(); | ||||||
|                 StringKeyValue kv = new StringKeyValue(); |                 mg.ID = FIDbAccess.GetFieldInt(dr["TYPEID"], 0); | ||||||
|                 kv.Key = FIDbAccess.GetFieldString(dr["GROUPID"], ""); |                 mg.Name = FIDbAccess.GetFieldString(dr["TYPENAME"], ""); | ||||||
|                 kv.Value = FIDbAccess.GetFieldString(dr["GROUPNAME"], ""); ; |                 result.Add(mg); | ||||||
|                 if (!result.ContainsKey(machineid)) |  | ||||||
|                     result[machineid] = new List<StringKeyValue>(); |  | ||||||
|                 result[machineid].Add(kv); |  | ||||||
|             } |             } | ||||||
|             return result; |             return result.ToArray(); | ||||||
|         } |  | ||||||
|  |  | ||||||
|         /// <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; |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
| @@ -748,7 +637,7 @@ namespace IronIntel.Contractor.Machines | |||||||
|         /// <returns></returns> |         /// <returns></returns> | ||||||
|         public static long[] GetGroupMachines(string[] groupids, FISqlConnection db = null) |         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>(); |             List<long> result = new List<long>(); | ||||||
|             if (db == null) |             if (db == null) | ||||||
| @@ -763,30 +652,6 @@ namespace IronIntel.Contractor.Machines | |||||||
|             return result.ToArray(); |             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) |         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}"; |             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); |                 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) |         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(); |             FISqlConnection db = SystemParams.GetDbInstance(); | ||||||
|  |  | ||||||
|             object obj = db.GetRC1BySQL(SQL, vin); |             object obj = db.GetRC1BySQL(SQL, vin); | ||||||
| @@ -840,7 +678,7 @@ namespace IronIntel.Contractor.Machines | |||||||
|         public static MaintenanceMachineInfo[] GetContactMachinesByID(string contactid) |         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, |             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}"; |                     where a.MACHINEID=b.MACHINEID and a.USERIID={0}"; | ||||||
|  |  | ||||||
|             FISqlConnection db = SystemParams.GetDbInstance(); |             FISqlConnection db = SystemParams.GetDbInstance(); | ||||||
| @@ -849,10 +687,10 @@ namespace IronIntel.Contractor.Machines | |||||||
|             { |             { | ||||||
|                 return new MaintenanceMachineInfo[0]; |                 return new MaintenanceMachineInfo[0]; | ||||||
|             } |             } | ||||||
|             MachineManagement.RefreshBaseData(); |             RefreshBaseData(); | ||||||
|             MachineMake[] makes = MachineManagement.GetMachineMakes(); |             AssetMake[] makes = GetMachineMakes(); | ||||||
|             MachineModel[] models = MachineManagement.GetMachineModels(); |             AssetModel[] models = GetMachineModels(); | ||||||
|             MachineType[] types = MachineManagement.GetMachineTypes(); |             AssetType[] types = GetMachineTypes(); | ||||||
|             List<MaintenanceMachineInfo> ls = new List<MaintenanceMachineInfo>(); |             List<MaintenanceMachineInfo> ls = new List<MaintenanceMachineInfo>(); | ||||||
|             foreach (DataRow dr in tb.Rows) |             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 ReturnDateStr { get { return ReturnDate == null ? "" : ReturnDate.Value.ToShortDateString(); } } | ||||||
|         public string PONumber { get; set; } |         public string PONumber { get; set; } | ||||||
|         public string Comments { get; set; } |         public string Comments { get; set; } | ||||||
|  |         public double InsuredValue { get; set; } | ||||||
|  |  | ||||||
|         public DateTime? RentalTermBillingDate { get; set; } |         public DateTime? RentalTermBillingDate { get; set; } | ||||||
|         public string RentalTermBillingDateStr { get { return RentalTermBillingDate == null ? "" : RentalTermBillingDate.Value.ToShortDateString(); } } |         public string RentalTermBillingDateStr { get { return RentalTermBillingDate == null ? "" : RentalTermBillingDate.Value.ToShortDateString(); } } | ||||||
|         public int BillingCycleDays { get; set; } |         public int BillingCycleDays { get; set; } | ||||||
|  |  | ||||||
|         public bool Selected { get; set; } |         public bool Selected { get; set; } | ||||||
|  |         public bool Hide { get; set; } | ||||||
|  |  | ||||||
|         public string DisplayName |         public string DisplayName | ||||||
|         { |         { | ||||||
| @@ -83,7 +85,7 @@ namespace IronIntel.Contractor.Machines | |||||||
|         public string LastUpdateUserName { get; set; } |         public string LastUpdateUserName { get; set; } | ||||||
|         public string LastUpdatedBy { get; set; } |         public string LastUpdatedBy { get; set; } | ||||||
|         public DateTime? LastUpdateDate { 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> |         /// </summary> | ||||||
|         public int OffsetMinute { get; set; } |         public int OffsetMinute { get; set; } | ||||||
|  |         public string DataSource { get; set; } | ||||||
|     } |     } | ||||||
|     public class CalampOdometerInfo |     public class CalampOdometerInfo | ||||||
|     { |     { | ||||||
| @@ -95,15 +96,15 @@ namespace IronIntel.Contractor.Machines | |||||||
|         { |         { | ||||||
|             get |             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 |         public string EventTimeLocalText | ||||||
|         { |         { | ||||||
|             get |             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 |             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 |         public string EventTimeLocalText | ||||||
|         { |         { | ||||||
|             get |             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 LogId { get; set; } | ||||||
|         public long AssetId { 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 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 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 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 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; |         private double _Odometer; | ||||||
|         public double Odometer |         public double Odometer | ||||||
|   | |||||||
| @@ -15,6 +15,8 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|         public string AlertType { get; set; } |         public string AlertType { get; set; } | ||||||
|         public DateTime AlertTime_UTC { get; set; } |         public DateTime AlertTime_UTC { get; set; } | ||||||
|         public string AlertTime_UTCStr { get { return AlertTime_UTC == DateTime.MinValue ? "" : AlertTime_UTC.ToString(); } } |         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 bool Completed { get; set; } | ||||||
|         public long MachineID { get; set; } |         public long MachineID { get; set; } | ||||||
|         public int ModelID { get; set; } |         public int ModelID { get; set; } | ||||||
| @@ -51,7 +53,23 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         public string Description { get; set; } |         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 int AlertCount { get; set; } | ||||||
|         public List<long> RepeatedAlerts { get; set; } |         public List<long> RepeatedAlerts { get; set; } | ||||||
|         public int OpenWorkOrderCount { get; set; }//针对Alert对应的机器 |         public int OpenWorkOrderCount { get; set; }//针对Alert对应的机器 | ||||||
| @@ -60,6 +78,9 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|         public string AcknowledgedByName { get; set; } |         public string AcknowledgedByName { get; set; } | ||||||
|         public DateTime AcknowledgedTime_UTC { get; set; } |         public DateTime AcknowledgedTime_UTC { get; set; } | ||||||
|         public string AcknowledgedTime_UTCStr { get { return AcknowledgedTime_UTC == DateTime.MinValue ? "" : AcknowledgedTime_UTC.ToString(); } } |         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; } |         public string AcknowledgedComment { get; set; } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -99,9 +120,22 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|         public long ID { get; set; } |         public long ID { get; set; } | ||||||
|         public DateTime AlertTime { get; set; } |         public DateTime AlertTime { get; set; } | ||||||
|         public string AlertTimeStr { get { return AlertTime == DateTime.MinValue ? "" : AlertTime.ToString(); } } |         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 AlertType { get; set; } | ||||||
|         public string Title { get; set; } |         public string Title { get; set; } | ||||||
|         public string Description { 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 long AssetID { get; set; } | ||||||
|         public string VIN { get; set; } |         public string VIN { get; set; } | ||||||
|         public string AssetName { 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 string CompletedDateStr { get { return CompletedDate == null ? "" : CompletedDate.ToString(); } } | ||||||
|  |  | ||||||
|         public AssetAlertCategory Category { get; set; } |         public AssetAlertCategory Category { get; set; } | ||||||
|  |         public string ServiceDescription { get; set; } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -2,14 +2,12 @@ | |||||||
| using Foresight.Fleet.Services.Asset; | using Foresight.Fleet.Services.Asset; | ||||||
| using Foresight.ServiceModel; | using Foresight.ServiceModel; | ||||||
| using IronIntel.Contractor.Users; | using IronIntel.Contractor.Users; | ||||||
| using IronIntel.Services.Business.Admin; |  | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using System.Data; | using System.Data; | ||||||
| using System.Linq; | using System.Linq; | ||||||
| using System.Text; | using System.Text; | ||||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||||
| using static IronIntel.Contractor.MapView.MachinesMapViewerManagement; |  | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor.Maintenance | 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() |         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); |             DataTable tb = GetDataTableBySQL(SQL); | ||||||
|             if (tb.Rows.Count == 0) |             if (tb.Rows.Count == 0) | ||||||
|             { |             { | ||||||
| @@ -309,29 +34,10 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|                 kv.Value = type; |                 kv.Value = type; | ||||||
|                 list.Add(kv); |                 list.Add(kv); | ||||||
|             } |             } | ||||||
|             return list.ToArray(); |             return list.OrderBy(t => t.Key).ToArray(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public AlertInfo[] GetAlertByID(long[] alertid) |         public AlertInfo[] GetAlertsByWorkOrder(long workorderid, Foresight.Fleet.Services.User.UserInfo user) | ||||||
|         { |  | ||||||
|             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) |  | ||||||
|         { |         { | ||||||
|             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 |             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 | 		  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]; |                 return new AlertInfo[0]; | ||||||
|             } |             } | ||||||
|             List<AlertInfo> ls = new List<AlertInfo>(tb.Rows.Count); |             List<AlertInfo> ls = new List<AlertInfo>(tb.Rows.Count); | ||||||
|             double timeadjust = SystemParams.GetHoursOffset(); |  | ||||||
|             foreach (DataRow dr in tb.Rows) |             foreach (DataRow dr in tb.Rows) | ||||||
|             { |             { | ||||||
|                 AlertInfo ai = ConvertToAlertInfo(dr, timeadjust); |                 AlertInfo ai = ConvertToAlertInfo(dr, user); | ||||||
|                 ai.ServiceDescription = FIDbAccess.GetFieldString(dr["SERVICEDESCRIPTION"], string.Empty); |                 ai.ServiceDescription = FIDbAccess.GetFieldString(dr["SERVICEDESCRIPTION"], string.Empty); | ||||||
|                 ls.Add(ai); |                 ls.Add(ai); | ||||||
|             } |             } | ||||||
|             return ls.ToArray(); |             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) |         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}"; |             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) |         private static AlertInfo ConvertToAlertInfo(DataRow dr, Foresight.Fleet.Services.User.UserInfo user) | ||||||
|         { |  | ||||||
|             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) |  | ||||||
|         { |         { | ||||||
|             AlertInfo ai = new AlertInfo(); |             AlertInfo ai = new AlertInfo(); | ||||||
|             ai.AlertID = FIDbAccess.GetFieldInt(dr["ALERTID"], 0); |             ai.AlertID = FIDbAccess.GetFieldInt(dr["ALERTID"], 0); | ||||||
|             ai.AlertType = FIDbAccess.GetFieldString(dr["ALERTTYPE"], string.Empty); |             ai.AlertType = FIDbAccess.GetFieldString(dr["ALERTTYPE"], string.Empty); | ||||||
|             ai.AlertTime_UTC = FIDbAccess.GetFieldDateTime(dr["ALERTTIME_UTC"], DateTime.MinValue); |             ai.AlertTime_UTC = FIDbAccess.GetFieldDateTime(dr["ALERTTIME_UTC"], DateTime.MinValue); | ||||||
|             if (ai.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.Completed = FIDbAccess.GetFieldInt(dr["COMPLETED"], 0) == 1; | ||||||
|             ai.MachineID = FIDbAccess.GetFieldInt(dr["MACHINEID"], 0); |             ai.MachineID = FIDbAccess.GetFieldInt(dr["MACHINEID"], 0); | ||||||
|             ai.VIN = FIDbAccess.GetFieldString(dr["VIN"], string.Empty); |             ai.VIN = FIDbAccess.GetFieldString(dr["VIN"], string.Empty); | ||||||
|             ai.MachineName = FIDbAccess.GetFieldString(dr["MACHINENAME"], string.Empty); |             ai.MachineName = FIDbAccess.GetFieldString(dr["MACHINENAME"], string.Empty); | ||||||
|             ai.EngineHours = FIDbAccess.GetFieldDouble(dr["ENGINGHOURS"], 0); |             ai.EngineHours = FIDbAccess.GetFieldDouble(dr["ENGINGHOURS"], 0); | ||||||
|             ai.Description = FIDbAccess.GetFieldString(dr["ALERTDESC"], string.Empty); |             ai.Description = FIDbAccess.GetFieldString(dr["ALERTDESC"], string.Empty); | ||||||
|  |             ai.Description = ai.FormatDescription(ai.Description); | ||||||
|             ai.PMType = FIDbAccess.GetFieldString(dr["PMTYPE"], string.Empty); |             ai.PMType = FIDbAccess.GetFieldString(dr["PMTYPE"], string.Empty); | ||||||
|             return ai; |             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 DriverName { get; set; } | ||||||
|         public string TicketNumber { get; set; } |         public string TicketNumber { get; set; } | ||||||
|         public DateTime TransactionDate { 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 AssetModel { get; set; } | ||||||
|         public string AssetMake { get; set; } |         public string AssetMake { get; set; } | ||||||
|         public string AssetType { get; set; } |         public string AssetType { get; set; } | ||||||
| @@ -36,6 +38,9 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|         public long FuelID { get; set; } |         public long FuelID { get; set; } | ||||||
|         public string DataSource { get; set; } |         public string DataSource { get; set; } | ||||||
|         public string BrandName { 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 |     public class FuelRecordAuditItem : FuelRecordInfo | ||||||
| @@ -47,9 +52,14 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|         public string LasetUpdatedBy { get; set; } |         public string LasetUpdatedBy { get; set; } | ||||||
|         public string LasetUpdatedByName { get; set; } |         public string LasetUpdatedByName { get; set; } | ||||||
|         public DateTime AddedOn { 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 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 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; |             machinedata m = null; | ||||||
|             if (_Machines.TryGetValue(id, out m)) |             if (_Machines.TryGetValue(id, out m)) | ||||||
| @@ -91,7 +91,6 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|                 return m; |                 return m; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             FISqlConnection db = SystemParams.GetDbInstance(); |  | ||||||
|             DataTable tb = db.GetDataTableBySQL(SQL, id); |             DataTable tb = db.GetDataTableBySQL(SQL, id); | ||||||
|             if (tb.Rows.Count == 0) |             if (tb.Rows.Count == 0) | ||||||
|             { |             { | ||||||
| @@ -117,7 +116,7 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|  |  | ||||||
|         public void SyncAlerts() |         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(); |             FISqlConnection db = SystemParams.GetDbInstance(); | ||||||
|             DataTable tb = db.GetDataTableBySQL(SQL); |             DataTable tb = db.GetDataTableBySQL(SQL); | ||||||
| @@ -137,13 +136,13 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|  |  | ||||||
|         private void InsertData(FISqlConnection db, DataRow dr) |         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," |                 + "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) " |                 + "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})"; |                 + " 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"]); |             long machineid = Convert.IsDBNull(dr["MACHINEID"]) ? -1 : Convert.ToInt64(dr["MACHINEID"]); | ||||||
|             machinedata m = GetMachinedata(machineid); |             machinedata m = GetMachinedata(db, machineid); | ||||||
|             if (m == null) |             if (m == null) | ||||||
|             { |             { | ||||||
|                 m = new machinedata(); |                 m = new machinedata(); | ||||||
| @@ -166,7 +165,11 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|             alerttype = DetermineAlertType(alerttype.Trim()); |             alerttype = DetermineAlertType(alerttype.Trim()); | ||||||
|             if (alerttype == null) |             if (alerttype == null) | ||||||
|                 return; |                 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) |         private string DetermineAlertType(string alerttype) | ||||||
|   | |||||||
| @@ -14,6 +14,24 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|         public string PmScheduleUom { get; set; } |         public string PmScheduleUom { get; set; } | ||||||
|  |  | ||||||
|         public string PmScheduleType { get; set; } //PM,TBM,HM |         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 string Notes { get; set; } | ||||||
|  |  | ||||||
|         public PmIntervalItem[] Intervals { get; set; } |         public PmIntervalItem[] Intervals { get; set; } | ||||||
| @@ -29,6 +47,7 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|  |  | ||||||
|         public string ServiceName { get; set; } |         public string ServiceName { get; set; } | ||||||
|         public bool Recurring { get; set; } |         public bool Recurring { get; set; } | ||||||
|  |         public double ExpectedCost { get; set; } | ||||||
|         public int Priority { get; set; } |         public int Priority { get; set; } | ||||||
|  |  | ||||||
|         public string ServiceDescription { get; set; } |         public string ServiceDescription { get; set; } | ||||||
| @@ -91,7 +110,7 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|             { |             { | ||||||
|                 if (AlertTime != DateTime.MinValue) |                 if (AlertTime != DateTime.MinValue) | ||||||
|                 { |                 { | ||||||
|                     return AlertTime.ToString("yyyy-MM-dd HH:mm:ss"); |                     return AlertTime.ToString("M/d/yyyy h:m:s tt"); | ||||||
|                 } |                 } | ||||||
|                 return ""; |                 return ""; | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -4,7 +4,6 @@ using Foresight.Fleet.Services.AssetHealth; | |||||||
| using Foresight.Fleet.Services.User; | using Foresight.Fleet.Services.User; | ||||||
| using IronIntel.Contractor.Machines; | using IronIntel.Contractor.Machines; | ||||||
| using IronIntel.Services; | using IronIntel.Services; | ||||||
| using IronIntel.Services.Business.Admin; |  | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using System.Data; | using System.Data; | ||||||
| @@ -19,11 +18,13 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|  |  | ||||||
|         #region PM SCHEDULES |         #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) |             if (items == null || items.Length == 0) | ||||||
|                 return new PmScheduleInfo[0]; |                 return new PmScheduleInfo[0]; | ||||||
|  |             if (!string.IsNullOrEmpty(pmid)) | ||||||
|  |                 items = items.Where(m => m.Id == pmid).ToArray(); | ||||||
|             List<PmScheduleInfo> list = new List<PmScheduleInfo>(); |             List<PmScheduleInfo> list = new List<PmScheduleInfo>(); | ||||||
|             foreach (var item in items) |             foreach (var item in items) | ||||||
|             { |             { | ||||||
| @@ -85,48 +86,6 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|  |  | ||||||
|             return pm; |             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) |         private static int[] GetAllIntervals(PMScheduleItem sc) | ||||||
|         { |         { | ||||||
| @@ -140,11 +99,13 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|             for (int i = 0; i < intervals.Count; i++) |             for (int i = 0; i < intervals.Count; i++) | ||||||
|             { |             { | ||||||
|                 PMIntervalItem ia = intervals[i]; |                 PMIntervalItem ia = intervals[i]; | ||||||
|                 if (maxInterval == 0) |                 if (maxInterval <= 0) | ||||||
|                     maxInterval = ia.Interval; |                     maxInterval = ia.Interval; | ||||||
|                 else |                 else | ||||||
|                     maxInterval = GetMinCommonMultiple(maxInterval, ia.Interval); |                     maxInterval = GetMinCommonMultiple(maxInterval, ia.Interval); | ||||||
|             } |             } | ||||||
|  |             if (maxInterval < 0 || maxInterval > 10240000)//溢出或数据过大 | ||||||
|  |                 maxInterval = intervals.LastOrDefault().Interval; | ||||||
|             for (int i = 0; i < intervals.Count; i++) |             for (int i = 0; i < intervals.Count; i++) | ||||||
|             { |             { | ||||||
|                 PMIntervalItem ia = intervals[i]; |                 PMIntervalItem ia = intervals[i]; | ||||||
| @@ -198,12 +159,14 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|             return list.ToArray(); |             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>(); |             List<PMAssetAlertInfo> result = new List<PMAssetAlertInfo>(); | ||||||
|             var client = FleetServiceClientHelper.CreateClient<PMClient>(sessionid); |             var client = FleetServiceClientHelper.CreateClient<PMClient>(sessionid); | ||||||
|             var sches = client.GetPMScheduleItems(SystemParams.CompanyID, "", string.Empty, true); |             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) |             foreach (var item in sches) | ||||||
|             { |             { | ||||||
|                 PMAssetAlertInfo pm = new PMAssetAlertInfo(); |                 PMAssetAlertInfo pm = new PMAssetAlertInfo(); | ||||||
| @@ -212,7 +175,7 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|                 pm.PmScheduleUom = item.UOM; |                 pm.PmScheduleUom = item.UOM; | ||||||
|                 pm.PmScheduleType = item.ScheduleType; |                 pm.PmScheduleType = item.ScheduleType; | ||||||
|                 pm.Notes = item.Notes; |                 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>(); |                     List<PmIntervalItem> lsinterval = new List<PmIntervalItem>(); | ||||||
|                     foreach (var pi in item.Intervals) |                     foreach (var pi in item.Intervals) | ||||||
| @@ -230,7 +193,7 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|                 else |                 else | ||||||
|                     pm.Intervals = new PmIntervalItem[0]; |                     pm.Intervals = new PmIntervalItem[0]; | ||||||
|  |  | ||||||
|                 if (aas != null) |                 if (includeinterval && aas != null) | ||||||
|                 { |                 { | ||||||
|                     var aa = aas.FirstOrDefault(a => a.PMScheduleId.Equals(pm.PmScheduleID, StringComparison.OrdinalIgnoreCase)); |                     var aa = aas.FirstOrDefault(a => a.PMScheduleId.Equals(pm.PmScheduleID, StringComparison.OrdinalIgnoreCase)); | ||||||
|                     if (aa != null) |                     if (aa != null) | ||||||
| @@ -254,20 +217,6 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|             return result.ToArray(); |             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) |         public static void UpdatePmSchedule(string sessionid, PmScheduleInfo si, string useriid) | ||||||
|         { |         { | ||||||
|             PMScheduleItem pm = new PMScheduleItem(); |             PMScheduleItem pm = new PMScheduleItem(); | ||||||
| @@ -300,103 +249,23 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|             FleetServiceClientHelper.CreateClient<PMClient>(sessionid).UpdatePMInterval(SystemParams.CompanyID, interval, useriid); |             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 |         #endregion | ||||||
|  |  | ||||||
|         #region Maintenance Log |         #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, |             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, |             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 |             (select top 1 ATTACHID from ATTACHES with(nolock) 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  |             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"; |             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"; |             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; |             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) |             if (assetid > 0) | ||||||
|             { |             { | ||||||
|                 sql = sql + " and  a.MACHINEID=" + assetid; |                 sql = sql + " and  a.MACHINEID=" + assetid; | ||||||
| @@ -411,7 +280,7 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|             } |             } | ||||||
|  |  | ||||||
|             FISqlConnection db = SystemParams.GetDbInstance(); |             FISqlConnection db = SystemParams.GetDbInstance(); | ||||||
|             DataTable dt = db.GetDataTableBySQL(sql, useriid); |             DataTable dt = db.GetDataTableBySQL(sql, sttime, ettime); | ||||||
|             if (dt.Rows.Count == 0) |             if (dt.Rows.Count == 0) | ||||||
|             { |             { | ||||||
|                 return new MaintenanceLogInfo[0]; |                 return new MaintenanceLogInfo[0]; | ||||||
| @@ -423,9 +292,9 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|                 availableAssetsids = FleetServiceClientHelper.CreateClient<AssetQueryClient>(sessionid).GetAvailableAssetsForUsers(SystemParams.CompanyID, useriid); |                 availableAssetsids = FleetServiceClientHelper.CreateClient<AssetQueryClient>(sessionid).GetAvailableAssetsForUsers(SystemParams.CompanyID, useriid); | ||||||
|  |  | ||||||
|             MachineManagement.RefreshBaseData(); |             MachineManagement.RefreshBaseData(); | ||||||
|             MachineMake[] makes = MachineManagement.GetMachineMakes(); |             AssetMake[] makes = MachineManagement.GetMachineMakes(); | ||||||
|             MachineModel[] models = MachineManagement.GetMachineModels(); |             AssetModel[] models = MachineManagement.GetMachineModels(); | ||||||
|             MachineType[] types = MachineManagement.GetMachineTypes(); |             AssetType[] types = MachineManagement.GetMachineTypes(); | ||||||
|  |  | ||||||
|             List<MaintenanceLogInfo> list = new List<MaintenanceLogInfo>(); |             List<MaintenanceLogInfo> list = new List<MaintenanceLogInfo>(); | ||||||
|             foreach (DataRow dr in dt.Rows) |             foreach (DataRow dr in dt.Rows) | ||||||
| @@ -478,9 +347,9 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|             } |             } | ||||||
|  |  | ||||||
|             MachineManagement.RefreshBaseData(); |             MachineManagement.RefreshBaseData(); | ||||||
|             MachineMake[] makes = MachineManagement.GetMachineMakes(); |             AssetMake[] makes = MachineManagement.GetMachineMakes(); | ||||||
|             MachineModel[] models = MachineManagement.GetMachineModels(); |             AssetModel[] models = MachineManagement.GetMachineModels(); | ||||||
|             MachineType[] types = MachineManagement.GetMachineTypes(); |             AssetType[] types = MachineManagement.GetMachineTypes(); | ||||||
|  |  | ||||||
|             MaintenanceLogInfo ml = ConvertToMaintenanceLogInfo(dt.Rows[0], makes, models, types); |             MaintenanceLogInfo ml = ConvertToMaintenanceLogInfo(dt.Rows[0], makes, models, types); | ||||||
|             return ml; |             return ml; | ||||||
| @@ -501,9 +370,9 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|             } |             } | ||||||
|  |  | ||||||
|             MachineManagement.RefreshBaseData(); |             MachineManagement.RefreshBaseData(); | ||||||
|             MachineMake[] makes = MachineManagement.GetMachineMakes(); |             AssetMake[] makes = MachineManagement.GetMachineMakes(); | ||||||
|             MachineModel[] models = MachineManagement.GetMachineModels(); |             AssetModel[] models = MachineManagement.GetMachineModels(); | ||||||
|             MachineType[] types = MachineManagement.GetMachineTypes(); |             AssetType[] types = MachineManagement.GetMachineTypes(); | ||||||
|  |  | ||||||
|             List<MaintenanceLogInfo> list = new List<MaintenanceLogInfo>(); |             List<MaintenanceLogInfo> list = new List<MaintenanceLogInfo>(); | ||||||
|             foreach (DataRow dr in dt.Rows) |             foreach (DataRow dr in dt.Rows) | ||||||
| @@ -527,9 +396,9 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|                 return new MaintenanceLogInfo(); |                 return new MaintenanceLogInfo(); | ||||||
|             } |             } | ||||||
|             MachineManagement.RefreshBaseData(); |             MachineManagement.RefreshBaseData(); | ||||||
|             MachineMake[] makes = MachineManagement.GetMachineMakes(); |             AssetMake[] makes = MachineManagement.GetMachineMakes(); | ||||||
|             MachineModel[] models = MachineManagement.GetMachineModels(); |             AssetModel[] models = MachineManagement.GetMachineModels(); | ||||||
|             MachineType[] types = MachineManagement.GetMachineTypes(); |             AssetType[] types = MachineManagement.GetMachineTypes(); | ||||||
|  |  | ||||||
|             MaintenanceLogInfo ml = ConvertToMaintenanceLogInfo(dt.Rows[0], makes, models, types); |             MaintenanceLogInfo ml = ConvertToMaintenanceLogInfo(dt.Rows[0], makes, models, types); | ||||||
|             return ml; |             return ml; | ||||||
| @@ -538,10 +407,10 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|         public static void UpdateMaintenanceLog(MaintenanceLogInfo ml, string addedby) |         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}, |             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, |                 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 GETUTCDATE() else null end))"; |                 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(); |             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) |         public static void DeleteMaintenanceLog(string maintencelogid) | ||||||
| @@ -551,13 +420,6 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|             db.ExecSQL(SQL, maintencelogid); |             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) |         public static PMAlert[] GetUnCompletedPMAlerts(long machineid, string maintencelogid) | ||||||
|         { |         { | ||||||
|             List<PMAlert> alerts = new List<PMAlert>(); |             List<PMAlert> alerts = new List<PMAlert>(); | ||||||
| @@ -572,7 +434,7 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|                 alert.AlertTitle = FIDbAccess.GetFieldString(dr["ALERTTITLE"], string.Empty); |                 alert.AlertTitle = FIDbAccess.GetFieldString(dr["ALERTTITLE"], string.Empty); | ||||||
|                 DateTime at = FIDbAccess.GetFieldDateTime(dr["ALERTTIME_UTC"], DateTime.MinValue); |                 DateTime at = FIDbAccess.GetFieldDateTime(dr["ALERTTIME_UTC"], DateTime.MinValue); | ||||||
|                 if (at != 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); |                 alerts.Add(alert); | ||||||
|             } |             } | ||||||
|             return alerts.ToArray(); |             return alerts.ToArray(); | ||||||
| @@ -585,7 +447,7 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|             db.ExecSQL(SQL, completed ? 1 : 0, alertID, completedby); |             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(); |             MaintenanceLogInfo ml = new MaintenanceLogInfo(); | ||||||
|             ml.MaintenanceID = FIDbAccess.GetFieldString(dr["MAINTENANCEID"], string.Empty); |             ml.MaintenanceID = FIDbAccess.GetFieldString(dr["MAINTENANCEID"], string.Empty); | ||||||
| @@ -606,40 +468,40 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|             ml.CompletedByName = FIDbAccess.GetFieldString(dr["COMPLETEDBYUSERNAME"], ""); |             ml.CompletedByName = FIDbAccess.GetFieldString(dr["COMPLETEDBYUSERNAME"], ""); | ||||||
|  |  | ||||||
|             int makeid = FIDbAccess.GetFieldInt(dr["MAKEID"], 0); |             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; |             ml.MachineMake = make == null ? string.Empty : make.Name; | ||||||
|  |  | ||||||
|             int modelid = FIDbAccess.GetFieldInt(dr["MODELID"], 0); |             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; |             ml.MachineModel = model == null ? string.Empty : model.Name; | ||||||
|  |  | ||||||
|             int typeid = FIDbAccess.GetFieldInt(dr["TYPEID"], 0); |             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; |             ml.MachineType = mtype == null ? string.Empty : mtype.Name; | ||||||
|  |  | ||||||
|             return ml; |             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 |             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 left join MACHINES b on b.MACHINEID=m.MACHINEID |             ,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) and m.MACHINEID = b.MACHINEID and ISNULL(b.HIDE,0)<>1  "; | 			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_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"; |             const string SQL_ORDERBY = " order by m.MAINTENANCEID"; | ||||||
|  |  | ||||||
|             var user = FleetServiceClientHelper.CreateClient<UserQueryClient>(custid, sessionid).GetUserByIID(useriid); |             var user = FleetServiceClientHelper.CreateClient<UserQueryClient>(custid, sessionid).GetUserByIID(useriid); | ||||||
|             if (user == null || (!user.Active)) |             if (user == null || (!user.Active)) | ||||||
|             { |             { | ||||||
|                 return new WorkOrderInfo[0]; |                 return new WorkOrderListItemClient[0]; | ||||||
|             } |             } | ||||||
|             if (user == null || (!user.Active)) |             if (user == null || (!user.Active)) | ||||||
|             { |             { | ||||||
|                 return new WorkOrderInfo[0]; |                 return new WorkOrderListItemClient[0]; | ||||||
|             } |             } | ||||||
|             if (string.Compare(user.CompanyID, SystemParams.CompanyID, true) != 0 && (!user.IsForesightUser)) |             if (string.Compare(user.CompanyID, SystemParams.CompanyID, true) != 0 && (!user.IsForesightUser)) | ||||||
|             { |             { | ||||||
|                 return new WorkOrderInfo[0]; |                 return new WorkOrderListItemClient[0]; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             string sql = SQL; |             string sql = SQL; | ||||||
| @@ -666,12 +528,12 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|                 dt = db.GetDataTableBySQL(sql + SQL_FILTER + SQL_ORDERBY, "%" + filter + "%"); |                 dt = db.GetDataTableBySQL(sql + SQL_FILTER + SQL_ORDERBY, "%" + filter + "%"); | ||||||
|  |  | ||||||
|             if (dt.Rows.Count == 0) |             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) |             foreach (DataRow dr in dt.Rows) | ||||||
|             { |             { | ||||||
|                 WorkOrderInfo wo = new WorkOrderInfo(); |                 WorkOrderListItemClient wo = new WorkOrderListItemClient(); | ||||||
|  |  | ||||||
|                 long assetid = FIDbAccess.GetFieldInt64(dr["MACHINEID"], 0); |                 long assetid = FIDbAccess.GetFieldInt64(dr["MACHINEID"], 0); | ||||||
|                 if (assets != null && assets.Length > 0) |                 if (assets != null && assets.Length > 0) | ||||||
| @@ -681,14 +543,15 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|                         continue; |                         continue; | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|                 wo.AssetID = assetid; |                 wo.AssetId = assetid; | ||||||
|                 wo.AssignedTo = FIDbAccess.GetFieldString(dr["COMPLETEDBY"], string.Empty); |  | ||||||
|                 wo.MaintenanceID = FIDbAccess.GetFieldString(dr["MAINTENANCEID"], string.Empty); |                 wo.MaintenanceID = FIDbAccess.GetFieldString(dr["MAINTENANCEID"], string.Empty); | ||||||
|                 wo.Description = FIDbAccess.GetFieldString(dr["NOTES"], string.Empty); |                 wo.Description = FIDbAccess.GetFieldString(dr["NOTES"], string.Empty); | ||||||
|                 wo.CompleteDate = FIDbAccess.GetFieldDateTime(dr["MAINTENANCEDATE"], DateTime.MinValue); |                 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.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); |                 list.Add(wo); | ||||||
|             } |             } | ||||||
| @@ -717,7 +580,7 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|         #region Machines |         #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)) |             if (string.IsNullOrEmpty(companyid)) | ||||||
|                 companyid = SystemParams.CompanyID; |                 companyid = SystemParams.CompanyID; | ||||||
| @@ -727,7 +590,7 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|             var client = FleetServiceClientHelper.CreateClient<AssetQueryClient>(companyid, sessionid); |             var client = FleetServiceClientHelper.CreateClient<AssetQueryClient>(companyid, sessionid); | ||||||
|             if (user.UserType < Users.UserTypes.Admin) |             if (user.UserType < Users.UserTypes.Admin) | ||||||
|                 availableAssetsids = client.GetAvailableAssetsForUsers(companyid, useriid); |                 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) |             if (assets != null && machinetype != -1) | ||||||
|                 assets = assets.Where(m => m.TypeID == machinetype).ToArray(); |                 assets = assets.Where(m => m.TypeID == machinetype).ToArray(); | ||||||
|             long[] mids = null; |             long[] mids = null; | ||||||
| @@ -749,7 +612,7 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|                 mi.TypeID = a.TypeID; |                 mi.TypeID = a.TypeID; | ||||||
|                 mi.MachineType = a.TypeName; |                 mi.MachineType = a.TypeName; | ||||||
|                 mi.Hide = a.Hide; |                 mi.Hide = a.Hide; | ||||||
|                 mi.EngineHours = a.EngineHours; |                 mi.EngineHours = a.EngineHours == null ? 0 : a.EngineHours.Value; | ||||||
|                 if (odos != null && odos.Length > 0) |                 if (odos != null && odos.Length > 0) | ||||||
|                 { |                 { | ||||||
|                     var odo = odos.FirstOrDefault((o) => o.AssetID == mi.MachineID); |                     var odo = odos.FirstOrDefault((o) => o.AssetID == mi.MachineID); | ||||||
| @@ -763,104 +626,7 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|             return list.ToArray(); |             return list.ToArray(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public static MaintenanceMachineInfo[] GetMaintenanceMachines(string sessionid, int machinetype, string searchtxt, string useriid, string companyid = null) |         public static MaintenanceMachineInfo ConvertToMaintenanceMachineInfo(DataRow dr, AssetMake[] makes, AssetModel[] models, AssetType[] types) | ||||||
|         { |  | ||||||
|             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) |  | ||||||
|         { |         { | ||||||
|             MaintenanceMachineInfo mi = new MaintenanceMachineInfo(); |             MaintenanceMachineInfo mi = new MaintenanceMachineInfo(); | ||||||
|             mi.MachineID = Convert.ToInt64(dr["MACHINEID"]); |             mi.MachineID = Convert.ToInt64(dr["MACHINEID"]); | ||||||
| @@ -871,15 +637,15 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|             mi.Odometer = FIDbAccess.GetFieldDouble(dr["ODOMETER"], 0); |             mi.Odometer = FIDbAccess.GetFieldDouble(dr["ODOMETER"], 0); | ||||||
|  |  | ||||||
|             int makeid = FIDbAccess.GetFieldInt(dr["MAKEID"], 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; |             mi.Make = make == null ? string.Empty : make.Name; | ||||||
|  |  | ||||||
|             int modelid = FIDbAccess.GetFieldInt(dr["MODELID"], 0); |             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; |             mi.Model = model == null ? string.Empty : model.Name; | ||||||
|  |  | ||||||
|             int typeid = FIDbAccess.GetFieldInt(dr["TYPEID"], 0); |             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.TypeID = mtype == null ? 0 : mtype.ID; | ||||||
|             mi.MachineType = mtype == null ? string.Empty : mtype.Name; |             mi.MachineType = mtype == null ? string.Empty : mtype.Name; | ||||||
|  |  | ||||||
| @@ -902,38 +668,5 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|  |  | ||||||
|         #endregion |         #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 DateTime? CompletedDate { get; set; } | ||||||
|         public string CompletedDateStr { get { return CompletedDate == null ? "" : CompletedDate.Value.ToShortDateString(); } } |         public string CompletedDateStr { get { return CompletedDate == null ? "" : CompletedDate.Value.ToShortDateString(); } } | ||||||
|         public string Component { get; set; }     |         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.Collections.Generic; | ||||||
| using System.Linq; | using System.Linq; | ||||||
| using System.Text; | using System.Text; | ||||||
| @@ -6,52 +10,133 @@ using System.Threading.Tasks; | |||||||
|  |  | ||||||
| namespace IronIntel.Contractor.Maintenance | 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 AssetName { get; set; } | ||||||
|         public string VIN { get; set; } |         public string VIN { get; set; } | ||||||
|         public string Description { get; set; } |         public string MakeName { get; set; } | ||||||
|         public DateTime? DueDate { get; set; } |         public string ModelName { get; set; } | ||||||
|  |         public string TypeName { get; set; } | ||||||
|         public string DueDateStr { get { return DueDate == null ? "" : DueDate.Value.ToShortDateString(); } } |         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 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 string ContactPreferenceStr { get; set; } | ||||||
|         public double HourMeter { get; set; } |         public int SaveToCustomer { get; set; } | ||||||
|  |     } | ||||||
|  |  | ||||||
|         private double _Odometer; |     public class WorkOrderListItemClient : WorkOrderListItem | ||||||
|         public double Odometer |     { | ||||||
|  |         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 |             get | ||||||
|             { |             { | ||||||
|                 return _Odometer; |                 var rst = ""; | ||||||
|             } |                 if (Contacts != null && Contacts.Count > 0) | ||||||
|             set |  | ||||||
|                 { |                 { | ||||||
|                 value = value > 0 ? value : 0; |                     for (var i = 0; i < Contacts.Count; i++) | ||||||
|                 _Odometer = Math.Round(value, 2); |                     { | ||||||
|  |                         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); | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|         public string OdometerUnits { get; set; } |                 return rst; | ||||||
|         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 class TextMessageClient : TextMessage | ||||||
|         public decimal TravelTimeCost { get; set; } |     { | ||||||
|         public decimal LaborCost { get; set; } |         public bool StatusIncorrect | ||||||
|         public decimal HourlyRate { get; set; } |         {//6219, 2022-09-20 17:50:00 以前的状态可能存在问题,界面上不显示状态 | ||||||
|         public decimal OtherCost { get; set; } |             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 System.Web; | ||||||
| using Foresight.Fleet.Services.AssetHealth; | using Foresight.Fleet.Services.AssetHealth; | ||||||
| using Foresight.Fleet.Services.Asset; | 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 | namespace IronIntel.Contractor.Maintenance | ||||||
| { | { | ||||||
| @@ -47,8 +54,8 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|                     Int64.TryParse(mid, out assetid); |                     Int64.TryParse(mid, out assetid); | ||||||
|                 else |                 else | ||||||
|                 { |                 { | ||||||
|                     var client = FleetServiceClientHelper.CreateClient<WorkOrderClient>(sessionid); |                     var client = FleetServiceClientHelper.CreateClient<WorkOrderProvider>(sessionid); | ||||||
|                     var workorder = client.GetWorkOrderDetail(SystemParams.CompanyID, Convert.ToInt64(woid)); |                     var workorder = client.GetWorkOrderInfo(SystemParams.CompanyID, Convert.ToInt64(woid)); | ||||||
|                     assetid = workorder.AssetID; |                     assetid = workorder.AssetID; | ||||||
|                 } |                 } | ||||||
|                 long[] availableAssetsids = FleetServiceClientHelper.CreateClient<AssetQueryClient>(sessionid).GetAvailableAssetsForUsers(SystemParams.CompanyID, useriid); |                 long[] availableAssetsids = FleetServiceClientHelper.CreateClient<AssetQueryClient>(sessionid).GetAvailableAssetsForUsers(SystemParams.CompanyID, useriid); | ||||||
| @@ -77,113 +84,756 @@ namespace IronIntel.Contractor.Maintenance | |||||||
|             return list.ToArray(); |             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(); |             StringBuilder str = new StringBuilder(); | ||||||
|             str.AppendLine("<H1 style='text-align:center;'>Work Order</H1>"); |             str.AppendLine("<H1 style='text-align:center;'>" + SystemParams.GetTextByKey(lang, "P_WORKORDER", "Work Order") + "</H1>"); | ||||||
|             str.AppendFormat("<div style='font-weight:bold;'>Details for work order <{0}> are listed below:</div>", woid); |             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(""); | ||||||
|             //str.AppendLine("<div class='label' style='text-align:left;'>Work Order Information:</div>"); |             //str.AppendLine("<div class='label' style='text-align:left;'>Work Order Information:</div>"); | ||||||
|             str.AppendLine("<div style='padding-left:30px;margin-bottom:36px;'>"); |             str.AppendLine("<div style='padding-left:30px;margin-bottom:36px;'>"); | ||||||
|  |  | ||||||
|             var client = FleetServiceClientHelper.CreateClient<WorkOrderClient>(companyid, sessionid); |             var aclient = FleetServiceClientHelper.CreateClient<AssetQueryClient>(companyid, sessionid); | ||||||
|             WorkOrderDetail wo = client.GetWorkOrderDetail(companyid, woid); |             var asset = aclient.GetAssetDetailInfo(companyid, wo.AssetID); | ||||||
|             str.Append(GenerateWorkOrderInfoHtml(wo)); |             str.Append(GenerateWorkOrderInfoHtml(asset, wo, lang)); | ||||||
|             str.AppendLine("</div>"); |             str.AppendLine("</div>"); | ||||||
|             //str.AppendLine("<div class='label' style='text-align:left;'>Segments:</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) |             if (segments != null && segments.Length > 0) | ||||||
|             { |             { | ||||||
|                 for (int i = 0; i < segments.Length; i++) |                 for (int i = 0; i < segments.Length; i++) | ||||||
|                 { |                 { | ||||||
|                     var se = segments[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(); |             return str.ToString(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private static string GenerateWorkOrderInfoHtml(WorkOrderDetail wo) |         private static string GenerateWorkOrderInfoHtml(AssetDetailInfo asset, WorkOrderInfo wo, string lang) | ||||||
|         { |         { | ||||||
|             StringBuilder str = new StringBuilder(); |             StringBuilder str = new StringBuilder(); | ||||||
|             str.Append("<table>"); |             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.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.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.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.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.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 (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' 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' 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' 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' 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'>" + 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'>" + SystemParams.GetTextByKey(lang, "P_WO_STATUS", "Status") + "</td><td>{0}</td></tr>", wo.StatusName); | ||||||
|  |             str.AppendLine(""); | ||||||
|  |             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'>" + 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'>" + SystemParams.GetTextByKey(lang, "P_WO_DESCRIPTION", "Description") + "</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(wo.Description).Replace("\n", "<br>")); | ||||||
|  |             str.AppendLine(""); | ||||||
|  |             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(""); |                 str.AppendLine(""); | ||||||
|                 if (string.Compare(wo.MeterType, "HourMeter", true) == 0 |                 if (string.Compare(wo.MeterType, "HourMeter", true) == 0 | ||||||
|                     || string.Compare(wo.MeterType, "Both", true) == 0) |                     || string.Compare(wo.MeterType, "Both", true) == 0) | ||||||
|                 str.AppendFormat("<tr><td class='label'>Hour Meter</td><td>{0}</td></tr>", wo.HourMeter); |                     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 |                 if (string.Compare(wo.MeterType, "Odometer", true) == 0 | ||||||
|                     || string.Compare(wo.MeterType, "Both", 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'>" + SystemParams.GetTextByKey(lang, "P_WO_ODOMETER", "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); |                 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.AppendLine(""); | ||||||
|             str.AppendFormat("<tr><td class='label'>Other Cost ($)</td><td>{0}</td></tr>", wo.OtherCost); |                 str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_OTHERCOST", "Other Cost ($)") + "</td><td>{0}</td></tr>", wo.OtherCost); | ||||||
|                 str.AppendLine(""); |                 str.AppendLine(""); | ||||||
|             str.AppendFormat("<tr><td class='label'>Parts Cost ($)</td><td>{0}</td></tr>", wo.PartsCost); |                 str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_PARTSCOST", "Parts Cost ($)") + "</td><td>{0}</td></tr>", wo.PartsCost); | ||||||
|                 str.AppendLine(""); |                 str.AppendLine(""); | ||||||
|             str.AppendFormat("<tr><td class='label'>Travel Time Cost ($)</td><td>{0}</td></tr>", wo.TravelTimeCost); |                 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.AppendLine(""); | ||||||
|             str.AppendFormat("<tr><td class='label'>Labor Cost ($)</td><td>{0}</td></tr>", wo.LaborCost); |                 str.AppendFormat("<tr><td class='label'>" + SystemParams.GetTextByKey(lang, "P_WO_LABORCOST", "Labor Cost ($)") + "</td><td>{0}</td></tr>", wo.LaborCost); | ||||||
|                 str.AppendLine(""); |                 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_HOURLYRATE", "Hourly Rate") + "</td><td>{0}</td></tr>", wo.HourlyRate); | ||||||
|                 str.AppendLine(""); |                 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_TIMETOCOMPLATEHOURS", "Time To Complete(Hrs)") + "</td><td>{0}</td></tr>", wo.HoursToComplete); | ||||||
|                 str.AppendLine(""); |                 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_COMPLETEDDATE", "Completed Date") + "</td><td>{0}</td></tr>", wo.CompleteDate == null ? "" : wo.CompleteDate.Value.ToShortDateString()); | ||||||
|                 str.AppendLine(""); |                 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_INTERNALID", "Internal ID") + "</td><td>{0}</td></tr>", wo.InternalID); | ||||||
|                 str.AppendLine(""); |                 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_INVOICENUMBER", "Invoice Number") + "</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(wo.InvoiceNumber)); | ||||||
|                 str.AppendLine(""); |                 str.AppendLine(""); | ||||||
|             str.AppendFormat("<tr><td class='label'>Notes</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(wo.Notes).Replace("\n", "<br>")); |                 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.AppendLine(""); | ||||||
|             str.AppendFormat("</table>"); |             str.AppendFormat("</table>"); | ||||||
|  |  | ||||||
|             return str.ToString(); |             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(); |             StringBuilder str = new StringBuilder(); | ||||||
|             //str.AppendFormat("<div style='margin-bottom:36px;margin-left:30px;{0}'>", (index - 2) % 4 == 0 ? "page-break-after: always;" : ""); |             //str.AppendFormat("<div style='margin-bottom:36px;margin-left:30px;{0}'>", (index - 2) % 4 == 0 ? "page-break-after: always;" : ""); | ||||||
|             //str.AppendLine(""); |             //str.AppendLine(""); | ||||||
|             str.AppendLine("<div style='margin-bottom:36px;margin-left:30px;'>"); |             str.AppendLine("<div style='margin-bottom:36px;margin-left:30px;'>"); | ||||||
|             str.AppendLine("<table>"); |             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.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.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.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.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.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.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.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'>" + 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'>Description</td><td>{0}</td></tr>", HttpUtility.HtmlEncode(se.Description)); |             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.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(""); | ||||||
|             str.AppendLine("</table>"); |             str.AppendLine("</table>"); | ||||||
|             str.AppendLine("</div>"); |             str.AppendLine("</div>"); | ||||||
|             return str.ToString(); |             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 System.Web; | ||||||
| using Foresight.Data; | using Foresight.Data; | ||||||
| using Foresight.ServiceModel; | using Foresight.ServiceModel; | ||||||
| using IronIntel.Services.Business.Admin; |  | ||||||
| using IronIntel.Contractor.Machines; | using IronIntel.Contractor.Machines; | ||||||
| using Foresight.Fleet.Services.Asset; | using Foresight.Fleet.Services.Asset; | ||||||
| using Foresight.Fleet.Services.MapView; | using Foresight.Fleet.Services.MapView; | ||||||
| using Foresight.Fleet.Services.JobSite; | 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 | namespace IronIntel.Contractor.MapView | ||||||
| { | { | ||||||
| @@ -20,7 +23,7 @@ namespace IronIntel.Contractor.MapView | |||||||
|         /// 根据Contractorid获取机器列表 |         /// 根据Contractorid获取机器列表 | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         /// <returns></returns> |         /// <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)) |             if (string.IsNullOrEmpty(companyid)) | ||||||
|                 companyid = SystemParams.CompanyID; |                 companyid = SystemParams.CompanyID; | ||||||
| @@ -38,23 +41,99 @@ namespace IronIntel.Contractor.MapView | |||||||
|             } |             } | ||||||
|  |  | ||||||
|             var client = FleetServiceClientHelper.CreateClient<MapViewQueryClient>(companyid, sessionid); |             var client = FleetServiceClientHelper.CreateClient<MapViewQueryClient>(companyid, sessionid); | ||||||
|             AssetMapViewPinItem[] assets = client.GetAssets(companyid, useriid, qp); |             AssetMapViewPinItem[] assets = client.GetAssets(companyid, useriid, qp, attachment); | ||||||
|             return assets; |             List<AssetMapViewPinItemClient> result = new List<AssetMapViewPinItemClient>(); | ||||||
|             //List<AssetViewItem> result = new List<AssetViewItem>(); |             foreach (var a in assets) | ||||||
|             //foreach (var a in assets) |             { | ||||||
|             //{ |                 AssetMapViewPinItemClient avi = new AssetMapViewPinItemClient(); | ||||||
|             //    AssetViewItem avi = new AssetViewItem(); |                 Helper.CloneProperty(avi, a); | ||||||
|             //    Helper.CloneProperty(avi, a); |                 result.Add(avi); | ||||||
|             //    result.Add(avi); |             } | ||||||
|             //} |             return result.ToArray(); | ||||||
|             //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) |         public static AssetDetailViewItem GetAssetDetailItem(string sessionid, string companyid, long machineid, string datasource = null) | ||||||
|         { |         { | ||||||
|             var client = FleetServiceClientHelper.CreateClient<AssetQueryClient>(companyid, sessionid); |             var client = FleetServiceClientHelper.CreateClient<AssetQueryClient>(companyid, sessionid); | ||||||
|  |             var locclient = FleetServiceClientHelper.CreateClient<AssetLocationQueryClient>(companyid, sessionid); | ||||||
|             var asset = client.GetAssetDetailInfo(companyid, machineid); |             var asset = client.GetAssetDetailInfo(companyid, machineid); | ||||||
|  |             var companyinfo = SystemParams.GetCustomerInfo(companyid); | ||||||
|             AssetDetailViewItem mi = new AssetDetailViewItem(); |             AssetDetailViewItem mi = new AssetDetailViewItem(); | ||||||
|  |             if (companyinfo != null) | ||||||
|  |             { | ||||||
|  |                 mi.CompanyID = companyinfo.ID; | ||||||
|  |                 mi.CompanyName = companyinfo.Name; | ||||||
|  |             } | ||||||
|             mi.ID = asset.ID; |             mi.ID = asset.ID; | ||||||
|             mi.Name = asset.Name; |             mi.Name = asset.Name; | ||||||
|             mi.Name2 = asset.Name2; |             mi.Name2 = asset.Name2; | ||||||
| @@ -67,6 +146,7 @@ namespace IronIntel.Contractor.MapView | |||||||
|             mi.IconUrl = asset.MapViewIconUrl; |             mi.IconUrl = asset.MapViewIconUrl; | ||||||
|             mi.AssetIconUrl = asset.AssetIconUrl; |             mi.AssetIconUrl = asset.AssetIconUrl; | ||||||
|             mi.Description = asset.Description; |             mi.Description = asset.Description; | ||||||
|  |             mi.DisplayName = asset.DisplayName; | ||||||
|  |  | ||||||
|             if (asset.CurrentHours != null) |             if (asset.CurrentHours != null) | ||||||
|             { |             { | ||||||
| @@ -79,7 +159,7 @@ namespace IronIntel.Contractor.MapView | |||||||
|             if (!string.IsNullOrWhiteSpace(datasource) |             if (!string.IsNullOrWhiteSpace(datasource) | ||||||
|                 && (loc == null || string.Compare(datasource, loc.DataSource, true) != 0)) |                 && (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); |                 var tempLoc = locs.FirstOrDefault(l => string.Compare(datasource, l.DataSource, true) != 0); | ||||||
|                 if (tempLoc != null) |                 if (tempLoc != null) | ||||||
|                 { |                 { | ||||||
| @@ -91,6 +171,8 @@ namespace IronIntel.Contractor.MapView | |||||||
|                     mi.Location.PostedSpeed = tempLoc.PostedSpeedLimit; |                     mi.Location.PostedSpeed = tempLoc.PostedSpeedLimit; | ||||||
|                     mi.Location.PostedSpeedUnit = tempLoc.SpeedLimitUnits; |                     mi.Location.PostedSpeedUnit = tempLoc.SpeedLimitUnits; | ||||||
|                     mi.Location.Street = tempLoc.Street; |                     mi.Location.Street = tempLoc.Street; | ||||||
|  |  | ||||||
|  |                     //MapView页面 不会走此分支,所以暂时不用对DataSource/SubSource/EventType/MsgUID赋值 | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|             else if (loc != null) |             else if (loc != null) | ||||||
| @@ -103,8 +185,19 @@ namespace IronIntel.Contractor.MapView | |||||||
|                 mi.Location.PostedSpeed = loc.PostedSpeedLimit; |                 mi.Location.PostedSpeed = loc.PostedSpeedLimit; | ||||||
|                 mi.Location.PostedSpeedUnit = loc.SpeedLimitUnits; |                 mi.Location.PostedSpeedUnit = loc.SpeedLimitUnits; | ||||||
|                 mi.Location.Street = loc.Street; |                 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) |             if (asset.CurrentOdometer != null) | ||||||
|             { |             { | ||||||
|                 mi.Odometer = asset.CurrentOdometer.Corrected; |                 mi.Odometer = asset.CurrentOdometer.Corrected; | ||||||
| @@ -131,8 +224,75 @@ namespace IronIntel.Contractor.MapView | |||||||
|             return list.ToArray(); |             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) |         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); |             var client = FleetServiceClientHelper.CreateClient<MapViewQueryClient>(companyid, sessionid); | ||||||
|             MapViewJobSiteInfo[] jss = client.GetAvailableJobSites(companyid, useriid, searchtext, false); |             MapViewJobSiteInfo[] jss = client.GetAvailableJobSites(companyid, useriid, searchtext, false); | ||||||
|  |  | ||||||
| @@ -146,8 +306,16 @@ namespace IronIntel.Contractor.MapView | |||||||
|                 ajs.Longitude = js.Longitude; |                 ajs.Longitude = js.Longitude; | ||||||
|                 ajs.Radius = js.Radius; |                 ajs.Radius = js.Radius; | ||||||
|                 ajs.Radius_UOM = js.RadiusUOM; |                 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.Assets = js.Assets; | ||||||
|  |  | ||||||
|  |                 ajs.ColorString = js.Color; | ||||||
|                 System.Drawing.Color color = System.Drawing.Color.Orange; |                 System.Drawing.Color color = System.Drawing.Color.Orange; | ||||||
|                 try |                 try | ||||||
|                 { |                 { | ||||||
| @@ -167,58 +335,90 @@ namespace IronIntel.Contractor.MapView | |||||||
|                     ajs.Polygon = temp.ToArray(); |                     ajs.Polygon = temp.ToArray(); | ||||||
|                 } |                 } | ||||||
|                 ajs.Notes = js.Notes; |                 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); |                 list.Add(ajs); | ||||||
|             } |             } | ||||||
|             return list.ToArray(); |             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 |             string[] cids = null; | ||||||
|             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  |             if (!string.IsNullOrEmpty(companyids)) | ||||||
|             else |                 cids = companyids.Split(','); | ||||||
|             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}))"; |  | ||||||
|  |  | ||||||
|             if (db == null) |             var contractors = SystemParams.GetContractors(); | ||||||
|                 db = SystemParams.GetDbInstance(); |             if (cids == null || cids.Length == 0) | ||||||
|             DataTable dt = null; |                 cids = contractors.Select(c => c.ID).ToArray(); | ||||||
|             dt = db.GetDataTableBySQL(SQL, useriid); |  | ||||||
|  |  | ||||||
|             Dictionary<string, List<MachineViewItem>> result = new Dictionary<string, List<MachineViewItem>>(StringComparer.OrdinalIgnoreCase); |             if (cids == null || cids.Length == 0) | ||||||
|             if (dt.Rows.Count == 0) |                 return new JobSiteViewItem[0]; | ||||||
|  |  | ||||||
|  |             int requestCount = 0; | ||||||
|  |             Exception lasterror = null; | ||||||
|  |             List<JobSiteViewItem> results = new List<JobSiteViewItem>(); | ||||||
|  |             foreach (var cid in cids) | ||||||
|             { |             { | ||||||
|                 return result; |                 requestCount++; | ||||||
|             } |                 Thread th = new Thread((object state) => | ||||||
|             foreach (DataRow dr in dt.Rows) |  | ||||||
|                 { |                 { | ||||||
|                 MachineViewItem mi = new MachineViewItem(); |                     try | ||||||
|                 mi.ID = FIDbAccess.GetFieldInt64(dr["MACHINEID"], 0); |                     { | ||||||
|                 mi.Name = FIDbAccess.GetFieldString(dr["MACHINENAME"], string.Empty); |                         var jss = GetJobsites(sessionid, cid, useriid, searchtext); | ||||||
|                 mi.Name2 = FIDbAccess.GetFieldString(dr["MACHINENAME2"], string.Empty); |                         lock (results) | ||||||
|                 mi.VIN = FIDbAccess.GetFieldString(dr["VIN"], string.Empty); |                         { | ||||||
|                 string groupID = FIDbAccess.GetFieldString(dr["GROUPID"], string.Empty); |                             foreach (var js in jss) | ||||||
|                 if (!result.ContainsKey(groupID)) |                             { | ||||||
|                     result[groupID] = new List<MachineViewItem>(); |                                 var c = contractors.FirstOrDefault(t => t.ID.Equals(cid, StringComparison.OrdinalIgnoreCase)); | ||||||
|                 result[groupID].Add(mi); |                                 if (c != null) | ||||||
|  |                                 { | ||||||
|  |                                     js.CompanyID = c.ID; | ||||||
|  |                                     js.CompanyName = c.Name; | ||||||
|                                 } |                                 } | ||||||
|             return result; |                             } | ||||||
|  |                             results.AddRange(jss); | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |                     catch (Exception ex) | ||||||
|  |                     { | ||||||
|  |                         lasterror = ex; | ||||||
|  |                     } | ||||||
|  |                     requestCount--; | ||||||
|  |                 }); | ||||||
|  |  | ||||||
|  |                 th.Start(); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|         private static void ConvertSpeedUnitToMile(LocationViewItem loc) |             while (true) | ||||||
|             { |             { | ||||||
|             if (loc == null) return; |                 Thread.Sleep(10); | ||||||
|             if (loc.Speed >= 0 && loc.SpeedUnit.StartsWith("K", StringComparison.OrdinalIgnoreCase)) |                 if (requestCount == 0) | ||||||
|                 { |                 { | ||||||
|                 loc.Speed = loc.Speed * 0.6213712; |                     break; | ||||||
|                 loc.SpeedUnit = "mi/h"; |  | ||||||
|                 } |                 } | ||||||
|             if (loc.PostedSpeed > 0 && loc.PostedSpeedUnit.StartsWith("K", StringComparison.OrdinalIgnoreCase)) |  | ||||||
|             { |  | ||||||
|                 loc.PostedSpeed = loc.PostedSpeed * 0.6213712; |  | ||||||
|                 loc.PostedSpeedUnit = "mi/h"; |  | ||||||
|             } |             } | ||||||
|  |             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) |         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(); |             //AssetViewItem ai = new AssetViewItem(); | ||||||
|             //Helper.CloneProperty(ai, asset); |             //Helper.CloneProperty(ai, asset); | ||||||
|  |  | ||||||
|             double timeOffset = SystemParams.GetHoursOffset(); |             var assetDevices = client.GetPairedDevices(companyid, long.Parse(machineid)); | ||||||
|             startTime = startTime.AddHours(-timeOffset); |             var device = assetDevices.FirstOrDefault(d => d.Source.Equals(Foresight.Fleet.Services.Device.DeviceInfo.DEVICESOURCE_SMARTWITNESS, StringComparison.OrdinalIgnoreCase) | ||||||
|             endTime = endTime.AddHours(-timeOffset); |             && 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>(); |             List<LocationViewItem> ls = new List<LocationViewItem>(); | ||||||
|             foreach (AssetLocationInfo assetLoc in assetLocs) |             foreach (AssetLocationInfo assetLoc in assetLocs) | ||||||
|             { |             { | ||||||
|                 LocationViewItem li = new LocationViewItem(); |                 LocationViewItem li = new LocationViewItem(); | ||||||
|  |                 li.LogId = assetLoc.LogId; | ||||||
|                 li.Latitude = assetLoc.Latitude; |                 li.Latitude = assetLoc.Latitude; | ||||||
|                 li.Longitude = assetLoc.Longitude; |                 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.Speed = assetLoc.Speed; | ||||||
|                 li.SpeedUnit = assetLoc.SpeedUnits; |                 li.SpeedUnit = assetLoc.SpeedUnits; | ||||||
| @@ -252,10 +457,12 @@ namespace IronIntel.Contractor.MapView | |||||||
|                 li.Street = assetLoc.Street; |                 li.Street = assetLoc.Street; | ||||||
|                 li.HarshDringEvent = assetLoc.HarshDringEvent; |                 li.HarshDringEvent = assetLoc.HarshDringEvent; | ||||||
|                 li.SpeedingBehavior = assetLoc.SpeedingBehavior; |                 li.SpeedingBehavior = assetLoc.SpeedingBehavior; | ||||||
|                 li.IconURL = GenerateLocationIconUrl(assetLoc); |                 li.IconURL = GenerateLocationIconUrl(assetLoc, asset.OnRoad); | ||||||
|                 li.SmartWitnessVideoUrl = assetLoc.SmartWitnessVideoUrl; |                 li.SmartWitnessVideoUrl = assetLoc.SmartWitnessVideoUrl; | ||||||
|  |  | ||||||
|                 ConvertSpeedUnitToMile(li); |                 li.FromSmartWitness = device == null ? false : true;//11342 通过机器当前是否绑定SmartWitness来判断 | ||||||
|  |  | ||||||
|  |                 //ConvertSpeedUnitToMile(li); | ||||||
|                 ls.Add(li); |                 ls.Add(li); | ||||||
|             } |             } | ||||||
|             AssetLocationHistoryViewItem al = new AssetLocationHistoryViewItem(); |             AssetLocationHistoryViewItem al = new AssetLocationHistoryViewItem(); | ||||||
| @@ -264,7 +471,7 @@ namespace IronIntel.Contractor.MapView | |||||||
|             return al; |             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/machinetypeicon.ashx | ||||||
|             //http://iron.soft.rz/admin/machinemovingicon.ashx |             //http://iron.soft.rz/admin/machinemovingicon.ashx | ||||||
| @@ -272,6 +479,8 @@ namespace IronIntel.Contractor.MapView | |||||||
|             const string PARAM = "?tp={0}&bkcolor={1}&heading={2}"; |             const string PARAM = "?tp={0}&bkcolor={1}&heading={2}"; | ||||||
|             int tp = (int)HarshDrivingEvents.HardAccelerationEvent; |             int tp = (int)HarshDrivingEvents.HardAccelerationEvent; | ||||||
|             string color = ""; |             string color = ""; | ||||||
|  |             if (onRoad) | ||||||
|  |             { | ||||||
|                 switch (loc.HarshDringEvent) |                 switch (loc.HarshDringEvent) | ||||||
|                 { |                 { | ||||||
|                     case HarshDrivingEvents.None: |                     case HarshDrivingEvents.None: | ||||||
| @@ -293,6 +502,7 @@ namespace IronIntel.Contractor.MapView | |||||||
|                     else if (loc.SpeedingBehavior == SpeedingBehaviors.SevereSpeeding) |                     else if (loc.SpeedingBehavior == SpeedingBehaviors.SevereSpeeding) | ||||||
|                         color = "#ffec1c24"; |                         color = "#ffec1c24"; | ||||||
|                 } |                 } | ||||||
|  |             } | ||||||
|             if (string.IsNullOrEmpty(color)) |             if (string.IsNullOrEmpty(color)) | ||||||
|             { |             { | ||||||
|                 if (loc.MoveStatus == AssetMoveStatus.InMotion) |                 if (loc.MoveStatus == AssetMoveStatus.InMotion) | ||||||
| @@ -308,6 +518,10 @@ namespace IronIntel.Contractor.MapView | |||||||
|                     return path + "?legend=StoppedOn"; |                     return path + "?legend=StoppedOn"; | ||||||
|                 else if (loc.MoveStatus == AssetMoveStatus.StoppedOff) |                 else if (loc.MoveStatus == AssetMoveStatus.StoppedOff) | ||||||
|                     return path + "?legend=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); |             color = HttpUtility.UrlEncode(color); | ||||||
|             path = path + string.Format(PARAM, tp, color, loc.Heading); |             path = path + string.Format(PARAM, tp, color, loc.Heading); | ||||||
| @@ -359,7 +573,101 @@ namespace IronIntel.Contractor.MapView | |||||||
|                 ls.Add(mi); |                 ls.Add(mi); | ||||||
|             } |             } | ||||||
|             return ls.OrderBy((mal) => mal.Name).ToArray(); |             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) |         private static List<LookupDataSourceDataItem> ConvertLookupData(List<LookupDataSourceData> data) | ||||||
| @@ -402,26 +710,194 @@ namespace IronIntel.Contractor.MapView | |||||||
|             return list.ToArray(); |             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); |             ShapeFileInfo[] files = FleetServiceClientHelper.CreateClient<ShapeFileProvider>(companyid, sessionid).GetShapeFileInfos(companyid, filtertext); | ||||||
|             FISqlConnection db = new FISqlConnection(dbs); |             if (files == null || files.Length == 0) | ||||||
|             if (db == null) |                 return new ShapeFileItem[0]; | ||||||
|                 db = SystemParams.GetDbInstance(); |  | ||||||
|             DataTable dt = db.GetDataTableBySQL(SQL); |  | ||||||
|  |  | ||||||
|             List<long> result = new List<long>(); |             List<ShapeFileItem> list = new List<ShapeFileItem>(); | ||||||
|             if (dt.Rows.Count == 0) |             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) | ||||||
|         { |         { | ||||||
|                 result.Add(FIDbAccess.GetFieldInt64(dr["MACHINEID"], 0)); |             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) | ||||||
|  |             { | ||||||
|  |                 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; | ||||||
|                                 } |                                 } | ||||||
|             return result.ToArray(); |                                 results.Add(item); | ||||||
|  |                             } | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |                     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(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         /// <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 class AssetDetailViewItem | ||||||
|     { |     { | ||||||
|  |         public string CompanyID { get; set; } = ""; | ||||||
|  |         public string CompanyName { get; set; } = ""; | ||||||
|  |  | ||||||
|         private double _EngineHours; |         private double _EngineHours; | ||||||
|         public double EngineHours |         public double EngineHours | ||||||
|         { |         { | ||||||
| @@ -64,6 +67,7 @@ namespace IronIntel.Contractor.MapView | |||||||
|                 return ""; |                 return ""; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |         public string DisplayName { get; set; } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public class AssetLocationHistoryViewItem |     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; | ||||||
| using Foresight.Fleet.Services.Asset; | using Foresight.Fleet.Services.Asset; | ||||||
| using IronIntel.Services.Common; | using Foresight.Fleet.Services.JobSite; | ||||||
| using IronIntel.Services.MapView; | using Foresight.Fleet.Services.MapView; | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using System.Linq; | using System.Linq; | ||||||
| @@ -10,93 +10,11 @@ using System.Threading.Tasks; | |||||||
|  |  | ||||||
| namespace IronIntel.Contractor.MapView | 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 class JobSiteViewItem | ||||||
|     { |     { | ||||||
|  |         public string CompanyID { get; set; } = ""; | ||||||
|  |         public string CompanyName { get; set; } = ""; | ||||||
|  |  | ||||||
|         public Int64 ID { get; set; } |         public Int64 ID { get; set; } | ||||||
|         public string Name { get; set; } |         public string Name { get; set; } | ||||||
|         public string[] Types { get; set; } |         public string[] Types { get; set; } | ||||||
| @@ -109,14 +27,30 @@ namespace IronIntel.Contractor.MapView | |||||||
|         public IIColor Color { get; set; } |         public IIColor Color { get; set; } | ||||||
|         public string Notes { get; set; } |         public string Notes { get; set; } | ||||||
|         public DateTime StartDate { get; set; } |         public DateTime StartDate { get; set; } | ||||||
|  |         public DateTime ProjectedEndDate { get; set; } | ||||||
|         public DateTime EndDate { get; set; } |         public DateTime EndDate { get; set; } | ||||||
|         public PostionItem[] Polygon { get; set; } |         public PostionItem[] Polygon { get; set; } | ||||||
|         public Int64 BaseOnMachineID { get; set; } |         public Int64 BaseOnMachineID { get; set; } | ||||||
|  |         public string BaseonMachineName { get; set; } | ||||||
|         public string Code { get; set; } |         public string Code { get; set; } | ||||||
|         public long[] Assets { get; set; } |         public long[] Assets { get; set; } | ||||||
|         public bool IsDeleted { 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 |             get | ||||||
|             { |             { | ||||||
| @@ -133,7 +67,7 @@ namespace IronIntel.Contractor.MapView | |||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         public string strEndDate |         public string EndDateStr | ||||||
|         { |         { | ||||||
|             get |             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 class AssetGroupViewItem | ||||||
|     { |     { | ||||||
|  |         public string CompanyID { get; set; } = ""; | ||||||
|  |         public string CompanyName { get; set; } = ""; | ||||||
|         public string ID { get; set; } |         public string ID { get; set; } | ||||||
|         public string Name { get; set; } |         public string Name { get; set; } | ||||||
|         public long[] Assets { get; set; } |         public long[] Assets { get; set; } | ||||||
| @@ -161,7 +133,7 @@ namespace IronIntel.Contractor.MapView | |||||||
|     public class CompanyLocationViewItem |     public class CompanyLocationViewItem | ||||||
|     { |     { | ||||||
|         public int ID { get; set; } |         public int ID { get; set; } | ||||||
|         public string CompanyID { get; set; } |         public string CompanyID { get; set; } = ""; | ||||||
|         public double Latitude { get; set; } |         public double Latitude { get; set; } | ||||||
|         public double Longitude { get; set; } |         public double Longitude { get; set; } | ||||||
|         public string LocationName { get; set; } |         public string LocationName { get; set; } | ||||||
| @@ -174,7 +146,7 @@ namespace IronIntel.Contractor.MapView | |||||||
|         public string ID { get; set; } |         public string ID { get; set; } | ||||||
|         public string Name { get; set; } |         public string Name { get; set; } | ||||||
|         public MapAlertLayerDefinitionItem[] Layers { 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 |     public class LookupDataSourceDataItem | ||||||
| @@ -231,6 +203,7 @@ namespace IronIntel.Contractor.MapView | |||||||
|  |  | ||||||
|     public class LocationViewItem |     public class LocationViewItem | ||||||
|     { |     { | ||||||
|  |         public long LogId { get; set; } | ||||||
|         public double Latitude { get; set; } |         public double Latitude { get; set; } | ||||||
|         public double Longitude { get; set; } |         public double Longitude { get; set; } | ||||||
|         public DateTime LocationTime { get; set; } |         public DateTime LocationTime { get; set; } | ||||||
| @@ -245,6 +218,11 @@ namespace IronIntel.Contractor.MapView | |||||||
|                 return ""; |                 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 double Speed { get; set; } = -1; | ||||||
|         public string SpeedUnit { get; set; } |         public string SpeedUnit { get; set; } | ||||||
|         public double PostedSpeed { get; set; } = -1; |         public double PostedSpeed { get; set; } = -1; | ||||||
| @@ -254,29 +232,15 @@ namespace IronIntel.Contractor.MapView | |||||||
|         public List<KeyValuePair<string, string>> SmartWitnessVideoUrl { get; set; } |         public List<KeyValuePair<string, string>> SmartWitnessVideoUrl { get; set; } | ||||||
|         public SpeedingBehaviors SpeedingBehavior { get; set; } |         public SpeedingBehaviors SpeedingBehavior { get; set; } | ||||||
|         public HarshDrivingEvents HarshDringEvent { 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 class MachineTypeItem | ||||||
|     { |     { | ||||||
|         public int ID { get; set; } |         public int ID { get; set; } | ||||||
|         public string Name { 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 struct PostionItem | ||||||
|     { |     { | ||||||
|         public double Latitude; |         public double Latitude; | ||||||
| @@ -291,8 +255,11 @@ namespace IronIntel.Contractor.MapView | |||||||
|  |  | ||||||
|     public class ShapeFileItem |     public class ShapeFileItem | ||||||
|     { |     { | ||||||
|  |         public string CompanyID { get; set; } = ""; | ||||||
|  |         public string CompanyName { get; set; } = ""; | ||||||
|         public long ID { get; set; } |         public long ID { get; set; } | ||||||
|         public string Name { get; set; } |         public string Name { get; set; } | ||||||
|         public string Notes { 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 System.Text; | ||||||
| using IronIntel.Services; | using IronIntel.Services; | ||||||
| using IronIntel.Contractor.Users; | using IronIntel.Contractor.Users; | ||||||
| using IronIntel.Services.MapView; | using Foresight.Fleet.Services.Customer; | ||||||
| using IronIntel.Services.Customers; |  | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor.MapView | namespace IronIntel.Contractor.MapView | ||||||
| { | { | ||||||
|   | |||||||
| @@ -33,4 +33,4 @@ using System.Runtime.InteropServices; | |||||||
| // by using the '*' as shown below: | // by using the '*' as shown below: | ||||||
| // [assembly: AssemblyVersion("1.0.*")] | // [assembly: AssemblyVersion("1.0.*")] | ||||||
| [assembly: AssemblyVersion("1.0.0.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 Foresight.Data; | ||||||
| using IronIntel.Contractor.Users; | using IronIntel.Contractor.Users; | ||||||
| using IronIntel.Services.Business.Admin; |  | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using System.Data; | using System.Data; | ||||||
|   | |||||||
| @@ -3,13 +3,156 @@ using System.Collections; | |||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using System.Data; | using System.Data; | ||||||
| using System.IO; | using System.IO; | ||||||
|  | using System.IO.Compression; | ||||||
| using System.Linq; | using System.Linq; | ||||||
| using System.Text; | using System.Text; | ||||||
|  | using System.Xml; | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor.Shape | namespace IronIntel.Contractor.Shape | ||||||
| { | { | ||||||
|     public static class ShapeFileParser |     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) |         private static void ParsePoints(BinaryReader binaryReader, MapPoints points) | ||||||
|         { |         { | ||||||
|             while (binaryReader.PeekChar() != -1) |             while (binaryReader.PeekChar() != -1) | ||||||
| @@ -177,148 +320,189 @@ namespace IronIntel.Contractor.Shape | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         #region kmz/kml | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// 解析.shp文件 |         /// 从kmz文件当中解析.kml,再解析kml | ||||||
|  |         /// </summary> | ||||||
|  |         /// <param name="stream"></param> | ||||||
|  |         /// <param name="shape"></param> | ||||||
|  |         public static void ParseFromKMZFile(byte[] buffer, Shape shape) | ||||||
|  |         { | ||||||
|  |             using (MemoryStream ms = new MemoryStream(buffer, false)) | ||||||
|  |             { | ||||||
|  |                 ParseFromKMZFile(ms, shape); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// 从kmz文件当中解析.kml,再解析kml | ||||||
|  |         /// </summary> | ||||||
|  |         /// <param name="stream"></param> | ||||||
|  |         /// <param name="shape"></param> | ||||||
|  |         public static void ParseFromKMZFile(Stream stream, Shape shape) | ||||||
|  |         { | ||||||
|  |             const string EXT = ".kml"; | ||||||
|  |             using (ZipArchive archive = new ZipArchive(stream)) | ||||||
|  |             { | ||||||
|  |                 foreach (var e in archive.Entries) | ||||||
|  |                 { | ||||||
|  |                     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> | ||||||
|  |         /// 解析.kml文件 | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         /// <param name="fileName"></param> |         /// <param name="fileName"></param> | ||||||
|         public static void ParseFromShapeFile(string fileName, Shape shape) |         public static void ParseFromKMLFile(string fileName, Shape shape) | ||||||
|         { |         { | ||||||
|             using (FileStream fileStream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) |             using (FileStream fileStream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) | ||||||
|             { |             { | ||||||
|                 ParseFromShapeFile(fileStream, shape); |                 ParseFromKMLFile(fileStream, shape); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         ///  解析.shp文件 |         ///  解析.kml文件 | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         /// <param name="buffer">.shp文件数据</param> |         /// <param name="buffer">.kml文件数据</param> | ||||||
|         /// <param name="shape"></param> |         /// <param name="shape"></param> | ||||||
|         public static void ParseFromShapeFile(byte[] buffer, Shape shape) |         public static void ParseFromKMLFile(byte[] buffer, Shape shape) | ||||||
|         { |         { | ||||||
|             using (MemoryStream ms = new MemoryStream(buffer, false)) |             using (MemoryStream ms = new MemoryStream(buffer, false)) | ||||||
|             { |             { | ||||||
|                 ParseFromShapeFile(ms, shape); |                 ParseFromKMLFile(ms, shape); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// 解析.shp文件 |         /// 解析.kml文件 | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         /// <param name="fs">装载.shp文件数据的流</param> |         /// <param name="fs">装载.kml文件数据的流</param> | ||||||
|         public static void ParseFromShapeFile(Stream fs, Shape shape) |         public static void ParseFromKMLFile(Stream fs, Shape shape) | ||||||
|         { |         { | ||||||
|  |             //fs.Seek(0, SeekOrigin.Begin); | ||||||
|  |             //StreamReader sr = new StreamReader(fs); | ||||||
|  |             //string content = sr.ReadToEnd(); | ||||||
|             fs.Seek(0, SeekOrigin.Begin); |             fs.Seek(0, SeekOrigin.Begin); | ||||||
|             using (BinaryReader binaryReader = new BinaryReader(fs)) |             XmlDocument xmldoc = new XmlDocument(); | ||||||
|  |             xmldoc.Load(fs); | ||||||
|  |             XmlElement root = xmldoc.DocumentElement; | ||||||
|  |  | ||||||
|  |             XmlNodeList pointNodes = root.GetElementsByTagName("Point"); | ||||||
|  |             foreach (XmlElement pe in pointNodes) | ||||||
|             { |             { | ||||||
|                 binaryReader.ReadBytes(24); |                 ParseKMLPoints(pe, shape.Points); | ||||||
|  |             } | ||||||
|  |  | ||||||
|                 int FileLength = binaryReader.ReadInt32();//<0代表数据长度未知 |             XmlNodeList lineNodes = root.GetElementsByTagName("LineString"); | ||||||
|                 int FileBanben = binaryReader.ReadInt32(); |             foreach (XmlElement le in lineNodes) | ||||||
|                 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 |                 ParseKMLLines(le, shape.Polylines); | ||||||
|                     case 11://PointZ |             } | ||||||
|                     case 21://PointM |  | ||||||
|  |             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(); |             MapPoints points = new MapPoints(); | ||||||
|                         shape.Points.Add(points); |             ls.Add(points); | ||||||
|                         ParsePoints(binaryReader, points); |  | ||||||
|                         break; |             string coordinatesstr = coordinates.InnerText.Trim(); | ||||||
|                     case 3://PolyLine |             string[] temps = coordinatesstr.Split(',');//Longitude,Latitude,Z | ||||||
|                     case 13://PolyLineZ |             MapPoint mp = new MapPoint(); | ||||||
|                     case 23://PolyLineM |             double d = 0; | ||||||
|                         ParsePolylines(binaryReader, shape.Polylines); |             if (double.TryParse(temps[0], out d)) | ||||||
|                         break; |                 mp.Longitude = d; | ||||||
|                     case 5://Polygon |             if (double.TryParse(temps[1], out d)) | ||||||
|                     case 15://PolygonZ |                 mp.Latitude = d; | ||||||
|                     case 25://PolygonM |             points.Points.Add(mp); | ||||||
|                         ParsePolygons(binaryReader, shape.Polygons); |  | ||||||
|                         break; |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         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); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         /// <summary> |         private static void ParseKMLPolygons(XmlElement node, List<Polygon> ls) | ||||||
|         /// 从zip文件当中解析.shp |  | ||||||
|         /// </summary> |  | ||||||
|         /// <param name="stream">装载.zip文件内容的流</param> |  | ||||||
|         /// <param name="shape"></param> |  | ||||||
|         public static void ParseFromZipFile(Stream stream, Shape shape) |  | ||||||
|         { |         { | ||||||
|             const string EXT = ".shp"; |             if (node == null) return; | ||||||
|             //using (ZipInputStream s = new ZipInputStream(stream)) |             var outer = node["outerBoundaryIs"]; | ||||||
|             //{ |             if (outer == null) return; | ||||||
|             //    ZipEntry zipentry = s.GetNextEntry(); |             var linearRing = outer["LinearRing"]; | ||||||
|             //    while (zipentry != null) |             if (linearRing == null) return; | ||||||
|             //    { |             var coordinates = linearRing["coordinates"]; | ||||||
|             //        if (zipentry.IsDirectory) |             if (coordinates == null) return; | ||||||
|             //        { |  | ||||||
|             //            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> |             Polygon p = new Polygon(); | ||||||
|         /// 从.zip文件当中解析.shp |             ls.Add(p); | ||||||
|         /// </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> |             MapPoints ring = new MapPoints(); | ||||||
|         /// 从.zip文件当中解析.shp |             p.Rings.Add(ring); | ||||||
|         /// </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); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|  |             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.Reflection; | ||||||
| using System.Linq; | using System.Linq; | ||||||
| using System.Text; | using System.Text; | ||||||
|  | using System.Xml; | ||||||
| using System.Net; | using System.Net; | ||||||
| using System.Data; | using System.Data; | ||||||
| using System.IO; | using System.IO; | ||||||
| @@ -13,25 +14,17 @@ using System.Threading; | |||||||
| using System.Data.SqlClient; | using System.Data.SqlClient; | ||||||
| using Foresight.Security; | using Foresight.Security; | ||||||
| using Foresight.Data; | 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.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; | ||||||
| using Foresight.Fleet.Services.OTRConfig; |  | ||||||
| using Foresight.Fleet.Services.Customer; | 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.SystemOption; | ||||||
| using Foresight.Fleet.Services.Inspection; | using Foresight; | ||||||
|  | using DocumentFormat.OpenXml.Presentation; | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor | namespace IronIntel.Contractor | ||||||
| { | { | ||||||
| @@ -46,6 +39,12 @@ namespace IronIntel.Contractor | |||||||
|  |  | ||||||
|         private static string _ContractorVersion = ""; |         private static string _ContractorVersion = ""; | ||||||
|         private static string _FICVersion = ""; |         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) |         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) |         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}" |             FleetServiceClientHelper.CreateClient<CustomerProvider>().SetSystemParams(CompanyID, paramname, value); | ||||||
|               + " else insert into SYSPARAMS(PARAMNAME,PARAMVALUE) values({0},{1})"; |  | ||||||
|             FIDbAccess db = GetDbInstance(); |  | ||||||
|             db.ExecSQL(SQL, paramname, value); |  | ||||||
|             _Params[paramname] = value; |             _Params[paramname] = value; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -276,7 +291,7 @@ namespace IronIntel.Contractor | |||||||
|             FICDBInstance.ExecSQL(SQL, paramname, value); |             FICDBInstance.ExecSQL(SQL, paramname, value); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private static Services.Customers.CustomerInfo _Company = null; |         private static CustomerInfo _Company = null; | ||||||
|  |  | ||||||
|         public static string CompanyID |         public static string CompanyID | ||||||
|         { |         { | ||||||
| @@ -307,35 +322,42 @@ namespace IronIntel.Contractor | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         private static CustomerDetail _ForesightCustomer = null; | ||||||
|  |         private static object _sycfcust = new object(); | ||||||
|  |  | ||||||
|  |         public static CustomerDetail ForesightCustomerDetail | ||||||
|         public static T GetServiceClient<T>() where T : Foresight.ServiceModel.ServiceClientBase, new() |  | ||||||
|         { |         { | ||||||
|             T rst = new T(); |             get | ||||||
|             rst.ServiceAddress = SystemServiceAddresses[0]; |             { | ||||||
|             rst.AppName = APPNAME; |                 if (_ForesightCustomer == null) | ||||||
|             return rst; |                 { | ||||||
|  |                     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(); |             return FleetServiceClientHelper.CreateClient<CustomerProvider>().GetCustomerDetail(cid); | ||||||
|             rst.ServiceAddress = SystemServiceAddresses[0]; |  | ||||||
|             rst.AppName = APPNAME; |  | ||||||
|             rst.LoginSessionID = sessionid; |  | ||||||
|             return rst; |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public static Services.LicenseInfo GetLicense() |         public static LicenseInfo GetLicense() | ||||||
|         { |         { | ||||||
|             var ic = GetServiceClient<Services.Customers.CustomerProvider>(); |             CustomerProvider ic = FleetServiceClientHelper.CreateClient<CustomerProvider>(); | ||||||
|             return ic.GetLicenseInfo(CompanyID); |             return ic.GetLicenseInfo(CompanyID); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public static bool HasLicense(string itemName) |         public static bool HasLicense(string itemName) | ||||||
|         { |         { | ||||||
|             bool result = false; |             bool result = false; | ||||||
|             var license = SystemParams.GetLicense(); |             var license = GetLicense(); | ||||||
|             if (license != null && license.Items.Count > 0) |             if (license != null && license.Items.Count > 0) | ||||||
|             { |             { | ||||||
|                 var item = license.Items.FirstOrDefault(m => m.Key.Equals(itemName, StringComparison.OrdinalIgnoreCase)); |                 var item = license.Items.FirstOrDefault(m => m.Key.Equals(itemName, StringComparison.OrdinalIgnoreCase)); | ||||||
| @@ -349,8 +371,6 @@ namespace IronIntel.Contractor | |||||||
|         { |         { | ||||||
|             if (string.IsNullOrEmpty(_ContractorVersion)) |             if (string.IsNullOrEmpty(_ContractorVersion)) | ||||||
|             { |             { | ||||||
|                 //IronSysServiceClient ic = GetIronSystemServiceClient(); |  | ||||||
|                 //_ContractorVersion = ic.GetServerVersion(); |  | ||||||
|                 _ContractorVersion = GetAssemblyFileVersion(); |                 _ContractorVersion = GetAssemblyFileVersion(); | ||||||
|             } |             } | ||||||
|             return _ContractorVersion; |             return _ContractorVersion; | ||||||
| @@ -370,21 +390,6 @@ namespace IronIntel.Contractor | |||||||
|             return _FICVersion; |             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; |         private static string _ReportDbString = string.Empty; | ||||||
|  |  | ||||||
|         public static string GetIronIntelReportDataDbString(string companyid = null) |         public static string GetIronIntelReportDataDbString(string companyid = null) | ||||||
| @@ -395,11 +400,6 @@ namespace IronIntel.Contractor | |||||||
|             { |             { | ||||||
|                 return _ReportDbString; |                 return _ReportDbString; | ||||||
|             } |             } | ||||||
|             string svcaddress = GetStringParam("IronIntelSystemServiceAddress"); |  | ||||||
|             if (string.IsNullOrWhiteSpace(svcaddress)) |  | ||||||
|             { |  | ||||||
|                 return string.Empty; |  | ||||||
|             } |  | ||||||
|             CustomerDetail cust = FleetServiceClientHelper.CreateClient<CustomerProvider>(companyid, string.Empty).GetCustomerDetail(companyid); |             CustomerDetail cust = FleetServiceClientHelper.CreateClient<CustomerProvider>(companyid, string.Empty).GetCustomerDetail(companyid); | ||||||
|             string dbstring = cust.ReportDataDbString; |             string dbstring = cust.ReportDataDbString; | ||||||
|             if (!string.IsNullOrEmpty(dbstring)) |             if (!string.IsNullOrEmpty(dbstring)) | ||||||
| @@ -416,6 +416,29 @@ namespace IronIntel.Contractor | |||||||
|             return GetCustomerDbString(companyid, "MASTER_DATA_DB"); |             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) |         public static string GetCustomerDbString(string companyid, string dbtype) | ||||||
|         { |         { | ||||||
|             string key = companyid + dbtype; |             string key = companyid + dbtype; | ||||||
| @@ -428,19 +451,19 @@ namespace IronIntel.Contractor | |||||||
|             return dbstring; |             return dbstring; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public static Services.Customers.CustomerInfo GetCompanyInfo() |         public static CustomerInfo GetCompanyInfo() | ||||||
|         { |         { | ||||||
|             if (_Company == null) |             if (_Company == null) | ||||||
|             { |             { | ||||||
|                 var ic = GetCustomerProvider(); |                 var ic = FleetServiceClientHelper.CreateClient<CustomerProvider>(CompanyID); | ||||||
|                 _Company = ic.GetCustomerByID(CompanyID); |                 _Company = ic.GetCustomerByID(CompanyID); | ||||||
|             } |             } | ||||||
|             return _Company; |             return _Company; | ||||||
|         } |         } | ||||||
|         public static MainStyle GetMainStyle() |         public static MainStyle GetMainStyle() | ||||||
|         { |         { | ||||||
|             IronSysServiceClient ic = GetIronSystemServiceClient(); |             var sp = FleetServiceClientHelper.CreateClient<StyleProvider>(); | ||||||
|             return ic.GetMainStyle(CompanyID); |             return sp.GetMainStyle(CompanyID); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public static bool IsDealer |         public static bool IsDealer | ||||||
| @@ -451,16 +474,16 @@ namespace IronIntel.Contractor | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public static Services.Customers.CustomerInfo[] GetContractors() |         public static CustomerInfo[] GetContractors() | ||||||
|         { |         { | ||||||
|             if (IsDealer) |             if (IsDealer) | ||||||
|             { |             { | ||||||
|                 var cust = GetCustomerProvider(); |                 var ic = FleetServiceClientHelper.CreateClient<CustomerProvider>(CompanyID); | ||||||
|                 return cust.GetContractors(CompanyID); |                 return ic.GetContractors(CompanyID); | ||||||
|             } |             } | ||||||
|             else |             else | ||||||
|             { |             { | ||||||
|                 return new Services.Customers.CustomerInfo[0]; |                 return new CustomerInfo[0]; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -471,8 +494,8 @@ namespace IronIntel.Contractor | |||||||
|  |  | ||||||
|         public static byte[] GetForesightLOGOInMainStyle() |         public static byte[] GetForesightLOGOInMainStyle() | ||||||
|         { |         { | ||||||
|             IronSysServiceClient ic = GetIronSystemServiceClient(); |             var sp = FleetServiceClientHelper.CreateClient<StyleProvider>(); | ||||||
|             return ic.GetLogoInMainStyle(CompanyID, 1); |             return sp.GetLogoInMainStyle(CompanyID, 1); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public static byte[] GetCompanyLocationLOGO(string companyid) |         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) |             if (IsDealer) | ||||||
|             { |             { | ||||||
| @@ -496,7 +519,7 @@ namespace IronIntel.Contractor | |||||||
|             } |             } | ||||||
|             else |             else | ||||||
|             { |             { | ||||||
|                 var cust = GetCustomerProvider(); |                 var cust = FleetServiceClientHelper.CreateClient<CustomerProvider>(CompanyID); | ||||||
|                 var cmps = cust.GetDealers(CompanyID); |                 var cmps = cust.GetDealers(CompanyID); | ||||||
|                 if ((cmps != null) && (cmps.Length > 0)) |                 if ((cmps != null) && (cmps.Length > 0)) | ||||||
|                 { |                 { | ||||||
| @@ -506,9 +529,22 @@ namespace IronIntel.Contractor | |||||||
|             return null; |             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) |         public static bool HasLOGO(string companyid) | ||||||
|         { |         { | ||||||
|             IronSysServiceClient ic = GetIronSystemServiceClient(); |             CustomerProvider ic = FleetServiceClientHelper.CreateClient<CustomerProvider>(); | ||||||
|             return ic.HasLOGO(companyid); |             return ic.HasLOGO(companyid); | ||||||
|         } |         } | ||||||
|         public static void ExecSQL(FIDbAccess db, int retrytimes, string sql, params object[] values) |         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***/ |         /**Fleet Service***/ | ||||||
|         public static string[] FleetAssetServiceAddresses |         public static string[] FleetAssetServiceAddresses | ||||||
|         { |         { | ||||||
| @@ -591,8 +603,8 @@ namespace IronIntel.Contractor | |||||||
|             { |             { | ||||||
|                 if (string.IsNullOrWhiteSpace(_MachineTypeMapViewIconUrl)) |                 if (string.IsNullOrWhiteSpace(_MachineTypeMapViewIconUrl)) | ||||||
|                 { |                 { | ||||||
|                     MachineServiceClient2 mc2 = SystemParams.GetMachineServiceClient(); |                     var client = FleetServiceClientHelper.CreateClient<AssetClassProvider>(); | ||||||
|                     _MachineTypeMapViewIconUrl = mc2.GetMachineTypeIconUrl(); |                     _MachineTypeMapViewIconUrl = client.GetMachineTypeIconUrl(); | ||||||
|                 } |                 } | ||||||
|                 return _MachineTypeMapViewIconUrl; |                 return _MachineTypeMapViewIconUrl; | ||||||
|             } |             } | ||||||
| @@ -605,50 +617,14 @@ namespace IronIntel.Contractor | |||||||
|             int styleID = -1; |             int styleID = -1; | ||||||
|             if (string.IsNullOrEmpty(sid) || !int.TryParse(sid, out styleID)) |             if (string.IsNullOrEmpty(sid) || !int.TryParse(sid, out styleID)) | ||||||
|                 styleID = -1; |                 styleID = -1; | ||||||
|             var sc = GetIronSystemServiceClient(); |             var sp = FleetServiceClientHelper.CreateClient<StyleProvider>(); | ||||||
|             CustUIStyle style = sc.GetDefaultUIStyle(SystemParams.CompanyID, styleID); |             CustUIStyle style = sp.GetDefaultUIStyle(CompanyID, styleID); | ||||||
|             return style; |             return style; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         //public static int GetTimeAdjust() |         public static TimeZoneInfo GetTimeZoneInfo(string custid) | ||||||
|         //{ |  | ||||||
|         //    var sc = GetIronSystemServiceClient(); |  | ||||||
|         //    return sc.GetCompanyTimeAdjust(CompanyID); |  | ||||||
|         //} |  | ||||||
|  |  | ||||||
|         public static double GetHoursOffset() |  | ||||||
|         { |         { | ||||||
|             //double offsetMinutes = 0; |             string tzName = FleetServiceClientHelper.CreateClient<CustomerProvider>(custid, string.Empty).GetCustomerTimeZoneName(custid); | ||||||
|             //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); |  | ||||||
|             var tz = TimeZoneInfo.FindSystemTimeZoneById(tzName.Trim()); |             var tz = TimeZoneInfo.FindSystemTimeZoneById(tzName.Trim()); | ||||||
|             return tz; |             return tz; | ||||||
|         } |         } | ||||||
| @@ -669,30 +645,26 @@ namespace IronIntel.Contractor | |||||||
|                 result.Add(skv); |                 result.Add(skv); | ||||||
|             } |             } | ||||||
|             return result.OrderBy(tz => double.Parse(tz.Tag1)).ThenBy(tz => tz.Key).ToArray(); |             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"; |         public const string APPNAME = "IronIntelCustomerSite"; | ||||||
|         private const string WORKING_COMPANY_HEADER = "WorkingCompanyID"; |         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) |         public static void WriteRefreshLog(string useriid, string userhost, string objname, string refreshtype) | ||||||
|         { |         { | ||||||
|             ThreadPool.QueueUserWorkItem(new WaitCallback((e) => { _WriteRefreshLog(useriid, userhost, objname, refreshtype); }), null); |             ThreadPool.QueueUserWorkItem(new WaitCallback((e) => { _WriteRefreshLog(useriid, userhost, objname, refreshtype); }), null); | ||||||
| @@ -826,10 +809,17 @@ namespace IronIntel.Contractor | |||||||
|  |  | ||||||
|         public static Dictionary<string, string> GetAdditionalParameter() |         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> |             var dict = new Dictionary<string, string> | ||||||
|             { |             { | ||||||
|                 { "ConnectorToken", ConnectorToken }, |                 { "ConnectorServer", connector.Key }, | ||||||
|                 { "ConnectorServer", ConnectorServer }, |                 { "ConnectorToken", connector.Value }, | ||||||
|                 { "LdapAgentID", LdapAgentID }, |                 { "LdapAgentID", LdapAgentID }, | ||||||
|                 { "LdapAgentToken", LdapAgentToken }, |                 { "LdapAgentToken", LdapAgentToken }, | ||||||
|                 { "CanUseConnectorLDAP", CanUseConnectorLDAP ? "1" : "0" } |                 { "CanUseConnectorLDAP", CanUseConnectorLDAP ? "1" : "0" } | ||||||
| @@ -837,5 +827,196 @@ namespace IronIntel.Contractor | |||||||
|  |  | ||||||
|             return dict; |             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 AppModuleType ModuleType { get; set; } | ||||||
|         public List<NavigateItem> SubItems { 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) |         public List<NavigateItem> GetMaintenanceNavigateItems(Tuple<Feature, Permissions>[] pmss) | ||||||
|         { |         { | ||||||
|             List<NavigateItem> list = new List<NavigateItem>(); |             List<NavigateItem> list = new List<NavigateItem>(); | ||||||
|  |  | ||||||
|             NavigateItem item = new 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.ID = "nav_workorder"; | ||||||
|             item.FeatureID = Feature.WORK_ORDER; |             item.FeatureID = Feature.WORK_ORDER; | ||||||
|             item.Title = "Work Order  **New**"; |             item.Title = "Work Order"; | ||||||
|             item.Url = Url + "#" + item.ID; |             item.Url = Url + "#" + item.ID; | ||||||
|             item.PageUrl = "WorkOrderMaintenance.aspx"; |             item.PageUrl = "WorkOrderMaintenance.aspx"; | ||||||
|             item.IconPath = "img/workorder.png"; |             item.IconPath = "img/workorder.png"; | ||||||
| @@ -48,65 +98,48 @@ namespace IronIntel.Contractor.Users | |||||||
|                 list.Add(item); |                 list.Add(item); | ||||||
|  |  | ||||||
|             item = new NavigateItem(); |             item = new NavigateItem(); | ||||||
|             item.ID = "nav_preventative"; |             item.ID = "nav_workorderhis"; | ||||||
|             item.FeatureID = Feature.PREVENTATIVE_MAINTENANCE; |             item.FeatureID = Feature.WORKORDERHISTORY; | ||||||
|             item.Title = "Absolute Hours Maintenance"; |             item.Title = "Work Order History"; | ||||||
|             item.Url = Url + "#" + item.ID; |             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"; |             item.IconPath = "img/preventative.png"; | ||||||
|             if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.PREVENTATIVE_MAINTENANCE) != null) |             if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.PREVENTATIVE_MAINTENANCE) != null) | ||||||
|                 list.Add(item); |                 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 = new NavigateItem(); | ||||||
|             item.ID = "nav_record"; |             item.ID = "nav_record"; | ||||||
|             item.FeatureID = Feature.PREVENTATIVE_MAINTENANCE; |             item.FeatureID = Feature.PREVENTATIVE_MAINTENANCE; | ||||||
|             item.Title = "Maintenance Record  **Legacy**"; |             item.Title = "Maintenance Record"; | ||||||
|             item.Url = Url + "#" + item.ID; |             item.Url = Url + "#" + item.ID; | ||||||
|             item.PageUrl = "MaintanceRecordsManagement.aspx"; |             item.PageUrl = "MaintanceRecordsManagement.aspx"; | ||||||
|             item.IconPath = "img/record.png"; |             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); |                 list.Add(item); | ||||||
|  |  | ||||||
|  |             if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.FUEL_RECORDS) != null) | ||||||
|  |             { | ||||||
|                 item = new NavigateItem(); |                 item = new NavigateItem(); | ||||||
|                 item.ID = "nav_fuelrecord"; |                 item.ID = "nav_fuelrecord"; | ||||||
|                 item.FeatureID = Feature.FUEL_RECORDS; |                 item.FeatureID = Feature.FUEL_RECORDS; | ||||||
| @@ -114,9 +147,44 @@ namespace IronIntel.Contractor.Users | |||||||
|                 item.Url = Url + "#" + item.ID; |                 item.Url = Url + "#" + item.ID; | ||||||
|                 item.PageUrl = "FuelRecordManagement.aspx"; |                 item.PageUrl = "FuelRecordManagement.aspx"; | ||||||
|                 item.IconPath = "img/fuelrecord.png"; |                 item.IconPath = "img/fuelrecord.png"; | ||||||
|             if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.FUEL_RECORDS) != null) |                 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); |                 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; |             return list; | ||||||
|         } |         } | ||||||
| @@ -178,6 +246,7 @@ namespace IronIntel.Contractor.Users | |||||||
|             item.Url = Url + "#" + item.ID; |             item.Url = Url + "#" + item.ID; | ||||||
|             item.PageUrl = "CurfewManage.aspx"; |             item.PageUrl = "CurfewManage.aspx"; | ||||||
|             item.IconPath = "img/curfew.png"; |             item.IconPath = "img/curfew.png"; | ||||||
|  |             if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.CURFEW_CONFIG) != null) | ||||||
|                 list.Add(item); |                 list.Add(item); | ||||||
|  |  | ||||||
|             if (user.UserType == UserTypes.SupperAdmin) |             if (user.UserType == UserTypes.SupperAdmin) | ||||||
| @@ -189,6 +258,7 @@ namespace IronIntel.Contractor.Users | |||||||
|                 item.Url = Url + "#" + item.ID; |                 item.Url = Url + "#" + item.ID; | ||||||
|                 item.PageUrl = "CurfewMovementTolerance.aspx"; |                 item.PageUrl = "CurfewMovementTolerance.aspx"; | ||||||
|                 item.IconPath = "img/curfewmovementtolerance.png"; |                 item.IconPath = "img/curfewmovementtolerance.png"; | ||||||
|  |                 if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.CURFEW_CONFIG) != null) | ||||||
|                     list.Add(item); |                     list.Add(item); | ||||||
|             } |             } | ||||||
|  |  | ||||||
| @@ -250,6 +320,70 @@ namespace IronIntel.Contractor.Users | |||||||
|  |  | ||||||
|             return list; |             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 |     public class NavigateItem | ||||||
| @@ -270,6 +404,14 @@ namespace IronIntel.Contractor.Users | |||||||
|         public string IconPath { get; set; } |         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 |     public enum AppModuleType | ||||||
|     { |     { | ||||||
|         System, |         System, | ||||||
|   | |||||||
| @@ -5,9 +5,8 @@ using System.Text; | |||||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||||
| using System.Data; | using System.Data; | ||||||
| using Foresight.Data; | using Foresight.Data; | ||||||
| using IronIntel.Contractor.Users; |  | ||||||
| using IronIntel.Services; |  | ||||||
| using Foresight.Fleet.Services.User; | using Foresight.Fleet.Services.User; | ||||||
|  | using Foresight.Fleet.Services.Styles; | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor.Users | namespace IronIntel.Contractor.Users | ||||||
| { | { | ||||||
| @@ -37,6 +36,14 @@ namespace IronIntel.Contractor.Users | |||||||
|                 moudles.Insert(0, FeatureModule.Modules[0]); |                 moudles.Insert(0, FeatureModule.Modules[0]); | ||||||
|             foreach (var m in moudles) |             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(); |                 AppModuleInfo ami = new AppModuleInfo(); | ||||||
|                 ami.ID = m.Id.ToString(); |                 ami.ID = m.Id.ToString(); | ||||||
|                 ami.Name = m.Name; |                 ami.Name = m.Name; | ||||||
| @@ -49,13 +56,18 @@ namespace IronIntel.Contractor.Users | |||||||
|                 ami.Visible = true; |                 ami.Visible = true; | ||||||
|                 ami.ModuleType = AppModuleType.System; |                 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); |                     ami.SubItems = ami.GetMaintenanceNavigateItems(pmss); | ||||||
|                 else if (m.Id == FeatureModule.MODULE_SECURITY) |                 else if (m.Id == FeatureModule.MODULE_SECURITY) | ||||||
|                     ami.SubItems = ami.GetSecurityNavigateItems(pmss, user); |                     ami.SubItems = ami.GetSecurityNavigateItems(pmss, user); | ||||||
|                 else if (m.Id == FeatureModule.MODULE_MANAGEASSETS) |                 else if (m.Id == FeatureModule.MODULE_MANAGEASSETS) | ||||||
|                     ami.SubItems = ami.GetAssetsNavigateItems(pmss, user); |                     ami.SubItems = ami.GetAssetsNavigateItems(pmss, user); | ||||||
|  |                 else if (m.Id == FeatureModule.MODULE_CREDENTIAL) | ||||||
|  |                     ami.SubItems = ami.GetCredentialNavigateItems(pmss, user); | ||||||
|  |  | ||||||
|  |                 if (ami.SubItems == null || ami.SubItems.Count > 0) | ||||||
|                     list.Add(ami); |                     list.Add(ami); | ||||||
|             } |             } | ||||||
|             AppModuleInfo[] wsps = GetFICWorkspace(user); |             AppModuleInfo[] wsps = GetFICWorkspace(user); | ||||||
| @@ -82,22 +94,6 @@ namespace IronIntel.Contractor.Users | |||||||
|             return false; |             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) |         public static AppModuleInfo[] GetFICWorkspace(UserInfo user) | ||||||
|         { |         { | ||||||
|             if (string.IsNullOrWhiteSpace(SystemParams.FICDbConnectionString)) |             if (string.IsNullOrWhiteSpace(SystemParams.FICDbConnectionString)) | ||||||
|   | |||||||
| @@ -1,5 +1,10 @@ | |||||||
| using FI.FIC; | using FI.FIC; | ||||||
| using FI.FIC.Contracts.DataObjects.BaseObject; | 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; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using System.Linq; | using System.Linq; | ||||||
| @@ -10,7 +15,7 @@ namespace IronIntel.Contractor.Users | |||||||
| { | { | ||||||
|     public class UserInfo |     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 IID { get; set; } | ||||||
|         public string ID { get; set; } |         public string ID { get; set; } | ||||||
|         public string DisplayName { get; set; } |         public string DisplayName { get; set; } | ||||||
| @@ -18,6 +23,7 @@ namespace IronIntel.Contractor.Users | |||||||
|         public bool IsUser { get; set; } |         public bool IsUser { get; set; } | ||||||
|         public ContactTypes ContactType { get; set; } |         public ContactTypes ContactType { get; set; } | ||||||
|         public string Mobile { get; set; } |         public string Mobile { get; set; } | ||||||
|  |         public string MobilePhoneDisplayText { get; set; } | ||||||
|         public string BusinessPhone { get; set; } |         public string BusinessPhone { get; set; } | ||||||
|         public string Notes { get; set; } |         public string Notes { get; set; } | ||||||
|         public bool Active { get; set; } |         public bool Active { get; set; } | ||||||
| @@ -25,6 +31,7 @@ namespace IronIntel.Contractor.Users | |||||||
|         public string TransPass { get; set; } |         public string TransPass { get; set; } | ||||||
|         public string ManagerIID { get; set; } |         public string ManagerIID { get; set; } | ||||||
|         public string ManagerName { get; set; } |         public string ManagerName { get; set; } | ||||||
|  |         public bool AssignedWorkOrders { get; set; } | ||||||
|         public bool EmailOptOut { get; set; } |         public bool EmailOptOut { get; set; } | ||||||
|         public bool InspectEmailList { get; set; } |         public bool InspectEmailList { get; set; } | ||||||
|         public bool TeamIntelligenceUser { get; set; } |         public bool TeamIntelligenceUser { get; set; } | ||||||
| @@ -35,16 +42,29 @@ namespace IronIntel.Contractor.Users | |||||||
|         public bool AllowLoginIntoPC { get; set; } |         public bool AllowLoginIntoPC { get; set; } | ||||||
|         public bool AllowLoginIntoInspectMobile { get; set; } |         public bool AllowLoginIntoInspectMobile { get; set; } | ||||||
|         public bool AllowLoginIntoFleetMobile { 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 LandingPage { get; set; } | ||||||
|         public string GroupNamesStr { get { return (GroupNames == null || GroupNames.Length == 0) ? "" : string.Join(",", GroupNames); } } |         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 |         public string ContactTypeName | ||||||
|         { |         { | ||||||
|             get |             get | ||||||
|             { |             { | ||||||
|                 int cType = (int)ContactType; |                 int cType = (int)ContactType; | ||||||
|                 if (cType > 7) |                 if (cType > 8) | ||||||
|                     cType = 7; |                     cType = 8; | ||||||
|                 return ContactTypeNames[cType]; |                 return ContactTypeNames[cType]; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| @@ -56,8 +76,12 @@ namespace IronIntel.Contractor.Users | |||||||
|         public SubscribeMessageByEmail Subscribe { get; set; } |         public SubscribeMessageByEmail Subscribe { get; set; } | ||||||
|         public KeyValuePair<int, Foresight.Fleet.Services.User.Permissions[]>[] Features { 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 |     public enum UserTypes | ||||||
| @@ -76,6 +100,7 @@ namespace IronIntel.Contractor.Users | |||||||
|         ServiceManager = 4, |         ServiceManager = 4, | ||||||
|         FleetManager = 5, |         FleetManager = 5, | ||||||
|         Technician = 6, |         Technician = 6, | ||||||
|  |         Advisor = 7, | ||||||
|         Other = 100 |         Other = 100 | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -85,4 +110,15 @@ namespace IronIntel.Contractor.Users | |||||||
|         public string ID { get; set; } |         public string ID { get; set; } | ||||||
|         public string Name { 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; | ||||||
| using FI.FIC.Contracts.DataObjects.BaseObject; | using FI.FIC.Contracts.DataObjects.BaseObject; | ||||||
| using FI.FIC.Contracts.DataObjects.Enumeration; | using FI.FIC.Contracts.DataObjects.Enumeration; | ||||||
|  | using FI.FIC.Models; | ||||||
| using Foresight.Data; | using Foresight.Data; | ||||||
| using Foresight.Fleet.Services.Asset; | using Foresight.Fleet.Services.Asset; | ||||||
|  | using Foresight.Fleet.Services.Customer; | ||||||
| using Foresight.Fleet.Services.User; | using Foresight.Fleet.Services.User; | ||||||
| using Foresight.ServiceModel; | using Foresight.ServiceModel; | ||||||
| using IronIntel.Services.Customers; |  | ||||||
| using IronIntel.Services.Users; |  | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using System.Data; | using System.Data; | ||||||
| @@ -17,11 +17,11 @@ namespace IronIntel.Contractor.Users | |||||||
| { | { | ||||||
|     public static class UserManagement |     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)) |             if (string.IsNullOrEmpty(companyid)) | ||||||
|                 companyid = SystemParams.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) |             if (users == null || users.Length == 0) | ||||||
|                 return new UserInfo[0]; |                 return new UserInfo[0]; | ||||||
|  |  | ||||||
| @@ -35,16 +35,6 @@ namespace IronIntel.Contractor.Users | |||||||
|                 list.Add(u); |                 list.Add(u); | ||||||
|             } |             } | ||||||
|             return list.ToArray(); |             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(); |             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) |         private static UserInfo ConvertUserItem(Foresight.Fleet.Services.User.UserInfo user) | ||||||
|         { |         { | ||||||
|             if (user == null) |             if (user == null) | ||||||
| @@ -98,12 +112,14 @@ namespace IronIntel.Contractor.Users | |||||||
|             u.Active = user.Active; |             u.Active = user.Active; | ||||||
|             u.TextAddress = user.TextAddress; |             u.TextAddress = user.TextAddress; | ||||||
|             u.Mobile = user.Mobile; |             u.Mobile = user.Mobile; | ||||||
|  |             u.MobilePhoneDisplayText = user.MobilePhoneDisplayText; | ||||||
|             u.BusinessPhone = user.BusinessPhone; |             u.BusinessPhone = user.BusinessPhone; | ||||||
|             u.Notes = user.Remark; |             u.Notes = user.Remark; | ||||||
|             u.IsUser = user.IsUser; |             u.IsUser = user.IsUser; | ||||||
|             u.ContactType = (ContactTypes)user.ContactType; |             u.ContactType = (ContactTypes)user.ContactType; | ||||||
|             u.ManagerIID = user.ManagerIID; |             u.ManagerIID = user.ManagerIID; | ||||||
|             u.ManagerName = user.ManagerName; |             u.ManagerName = user.ManagerName; | ||||||
|  |             u.AssignedWorkOrders = user.AssignedWorkOrders; | ||||||
|             u.EmailOptOut = user.EmailOptOut; |             u.EmailOptOut = user.EmailOptOut; | ||||||
|             u.InspectEmailList = user.InspectEmailList; |             u.InspectEmailList = user.InspectEmailList; | ||||||
|             u.TeamIntelligenceUser = user.TeamIntelligenceUser; |             u.TeamIntelligenceUser = user.TeamIntelligenceUser; | ||||||
| @@ -112,6 +128,13 @@ namespace IronIntel.Contractor.Users | |||||||
|             u.AllowLoginIntoPC = user.AllowLoginIntoPC; |             u.AllowLoginIntoPC = user.AllowLoginIntoPC; | ||||||
|             u.AllowLoginIntoFleetMobile = user.AllowLoginIntoFleetMobile; |             u.AllowLoginIntoFleetMobile = user.AllowLoginIntoFleetMobile; | ||||||
|             u.AllowLoginIntoInspectMobile = user.AllowLoginIntoInspectMobile; |             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; |             return u; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -133,6 +156,7 @@ namespace IronIntel.Contractor.Users | |||||||
|             u.IsUser = user.IsUser; |             u.IsUser = user.IsUser; | ||||||
|             u.ContactType = (Foresight.Fleet.Services.User.ContactTypes)user.ContactType; |             u.ContactType = (Foresight.Fleet.Services.User.ContactTypes)user.ContactType; | ||||||
|             u.ManagerIID = user.ManagerIID; |             u.ManagerIID = user.ManagerIID; | ||||||
|  |             u.AssignedWorkOrders = user.AssignedWorkOrders; | ||||||
|             u.EmailOptOut = user.EmailOptOut; |             u.EmailOptOut = user.EmailOptOut; | ||||||
|             u.InspectEmailList = user.InspectEmailList; |             u.InspectEmailList = user.InspectEmailList; | ||||||
|             u.TeamIntelligenceUser = user.TeamIntelligenceUser; |             u.TeamIntelligenceUser = user.TeamIntelligenceUser; | ||||||
| @@ -141,18 +165,23 @@ namespace IronIntel.Contractor.Users | |||||||
|             u.AllowLoginIntoPC = user.AllowLoginIntoPC; |             u.AllowLoginIntoPC = user.AllowLoginIntoPC; | ||||||
|             u.AllowLoginIntoFleetMobile = user.AllowLoginIntoFleetMobile; |             u.AllowLoginIntoFleetMobile = user.AllowLoginIntoFleetMobile; | ||||||
|             u.AllowLoginIntoInspectMobile = user.AllowLoginIntoInspectMobile; |             u.AllowLoginIntoInspectMobile = user.AllowLoginIntoInspectMobile; | ||||||
|  |             u.AllowMobileBarcodeScanning = user.AllowMobileBarcodeScanning; | ||||||
|  |             u.PreferredLanguage = user.PreferredLanguage; | ||||||
|  |             u.LoginVerifyType = user.LoginVerifyType; | ||||||
|  |             u.TimeZone = user.TimeZone; | ||||||
|             return u; |             return u; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public static UserInfo[] GetUnmanagementUsers() |         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)"; |             var users = FleetServiceClientHelper.CreateClient<UserQueryClient>(SystemParams.CompanyID).GetUsersByCustomerID(SystemParams.CompanyID, ""); | ||||||
|             FIDbAccess db = SystemParams.GetDbInstance(); |  | ||||||
|             DataTable dt = db.GetDataTableBySQL(SQL); |  | ||||||
|             List<UserInfo> list = new List<UserInfo>(); |             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(); |             return list.ToArray(); | ||||||
|         } |         } | ||||||
| @@ -173,12 +202,6 @@ namespace IronIntel.Contractor.Users | |||||||
|                 { |                 { | ||||||
|                     var dealerusers = GetUsers(dealer.ID); |                     var dealerusers = GetUsers(dealer.ID); | ||||||
|                     ls.AddRange(dealerusers); |                     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(); |             return ls.ToArray(); | ||||||
| @@ -193,30 +216,6 @@ namespace IronIntel.Contractor.Users | |||||||
|                 list.Add(ConvertUserItem(user)); |                 list.Add(ConvertUserItem(user)); | ||||||
|             } |             } | ||||||
|             return list.ToArray(); |             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) |         private static UserInfo ConvertToUserInfo(DataRow dr) | ||||||
| @@ -234,21 +233,6 @@ namespace IronIntel.Contractor.Users | |||||||
|             return ui; |             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) |         public static UserInfo GetUserBySessionID(string sessionid) | ||||||
|         { |         { | ||||||
|             var ls = FleetServiceClientHelper.CreateClient<UserQueryClient>(sessionid).GetLoginSession(sessionid); |             var ls = FleetServiceClientHelper.CreateClient<UserQueryClient>(sessionid).GetLoginSession(sessionid); | ||||||
| @@ -264,78 +248,28 @@ namespace IronIntel.Contractor.Users | |||||||
|                 ui.DisplayName = ls.User.Name; |                 ui.DisplayName = ls.User.Name; | ||||||
|                 ui.Active = true; |                 ui.Active = true; | ||||||
|                 ui.UserType = UserTypes.SupperAdmin; |                 ui.UserType = UserTypes.SupperAdmin; | ||||||
|  |                 ui.TimeZone = ls.User.TimeZone; | ||||||
|                 return ui; |                 return ui; | ||||||
|             } |             } | ||||||
|             else |             else | ||||||
|             { |             { | ||||||
|                 return ConvertUserItem(ls.User); |                 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) |         public static UserInfo GetUserByIID(string iid) | ||||||
|         { |         { | ||||||
|             var user = FleetServiceClientHelper.CreateClient<UserQueryClient>().GetUserByIID(iid); |             var user = FleetServiceClientHelper.CreateClient<UserQueryClient>().GetUserByIID(iid); | ||||||
|             return ConvertUserItem(user); |             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) |         public static UserInfo GetUserByID(string userid) | ||||||
|         { |         { | ||||||
|             var user = FleetServiceClientHelper.CreateClient<UserQueryClient>().GetUserByUserID(userid); |             var user = FleetServiceClientHelper.CreateClient<UserQueryClient>().GetUserByUserID(userid); | ||||||
|             return ConvertUserItem(user); |             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 |             try | ||||||
|             { |             { | ||||||
| @@ -346,6 +280,12 @@ namespace IronIntel.Contractor.Users | |||||||
|                 client.SessionID = sessionid; |                 client.SessionID = sessionid; | ||||||
|                 client.ClientHost = clienthost; |                 client.ClientHost = clienthost; | ||||||
|                 user = client.AddNewUser(user, password, addby); |                 user = client.AddNewUser(user, password, addby); | ||||||
|  |                 if (avadarBytes != null) | ||||||
|  |                 { | ||||||
|  |                     avadarBytes = Helper.GetThumbImg(avadarBytes, 300, 300); | ||||||
|  |                     client.SetUserAvatar(user.UID, avadarBytes); | ||||||
|  |                 } | ||||||
|  |  | ||||||
|                 return user.UID; |                 return user.UID; | ||||||
|             } |             } | ||||||
|             catch (Exception ex) |             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()); |                 SystemParams.WriteLog("Error", typeof(UserManagement).FullName + ".AddUser", "Add new user failed: " + ui.ID, ex.ToString()); | ||||||
|                 throw; |                 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 |             try | ||||||
|             { |             { | ||||||
| @@ -404,28 +307,30 @@ namespace IronIntel.Contractor.Users | |||||||
|                 client.SessionID = sessionid; |                 client.SessionID = sessionid; | ||||||
|                 client.ClientHost = clienthost; |                 client.ClientHost = clienthost; | ||||||
|                 client.UpdateUser(user, updatedby); |                 client.UpdateUser(user, updatedby); | ||||||
|  |                 if (avadarBytes != null) | ||||||
|  |                 { | ||||||
|  |                     avadarBytes = Helper.GetThumbImg(avadarBytes, 300, 300); | ||||||
|  |                     client.SetUserAvatar(user.UID, avadarBytes); | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|             catch (Exception ex) |             catch (Exception ex) | ||||||
|             { |             { | ||||||
|                 SystemParams.WriteLog("Error", typeof(UserManagement).FullName + ".UpdateUserInfo", "Update user failed: " + ui.IID, ex.ToString()); |                 SystemParams.WriteLog("Error", typeof(UserManagement).FullName + ".UpdateUserInfo", "Update user failed: " + ui.IID, ex.ToString()); | ||||||
|                 throw; |                 throw; | ||||||
|             } |             } | ||||||
|  |         } | ||||||
|  |         public static void SetUserAvatar(string sessionid, string uid, byte[] avadarBytes) | ||||||
|             //const string SQL = @" update USERS set USERNAME={0},MOBILE={1},BUSINESSPHONE={2},ACTIVE={3},USERTYPE={4},NOTES={5} where USERIID={6}"; |         { | ||||||
|             //try |             try | ||||||
|             //{ |             { | ||||||
|             //    LoginProvider lp = SystemParams.GetLoginProvider(); |                 var client = FleetServiceClientHelper.CreateClient<UserQueryClient>(sessionid); | ||||||
|             //    UserInfoEx user = ConvertUserInfoTOUserInfoEx(ui); |                 client.SetUserAvatar(uid, avadarBytes); | ||||||
|             //    lp.UpdateUser(user); |             } | ||||||
|             //    FIDbAccess db = SystemParams.GetDbInstance(); |             catch (Exception ex) | ||||||
|             //    db.ExecSQL(SQL, ui.DisplayName, ui.Mobile, ui.BusinessPhone, ui.Active ? 1 : 0, ui.UserType, ui.Notes, ui.IID); |             { | ||||||
|             //} |                 SystemParams.WriteLog("Error", typeof(UserManagement).FullName + ".SetUserAvatar", "Set user Avatar failed: " + uid, ex.ToString()); | ||||||
|             //catch (Exception ex) |                 throw; | ||||||
|             //{ |             } | ||||||
|             //    SystemParams.WriteLog("Error", typeof(UserManagement).FullName + ".UpdateUserInfo", "Update user failed: " + ui.IID, ex.ToString()); |  | ||||||
|             //    throw; |  | ||||||
|             //} |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public static void ResetPassword(string useriid, string password, string resetby, string sessionid, string clienthost) |         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.SessionID = sessionid; | ||||||
|             client.ClientHost = clienthost; |             client.ClientHost = clienthost; | ||||||
|             client.ResetPassword(useriid, password, true, resetby); |             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) |         public static bool CanDeleteUser(string useriid) | ||||||
| @@ -456,6 +347,13 @@ namespace IronIntel.Contractor.Users | |||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         public static byte[] GetUserAvatar(string sessionid, string useriid) | ||||||
|  |         { | ||||||
|  |  | ||||||
|  |             var client = FleetServiceClientHelper.CreateClient<UserQueryClient>(sessionid); | ||||||
|  |             return client.GetUserAvatar(useriid); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|         #region user group |         #region user group | ||||||
|  |  | ||||||
| @@ -515,26 +413,6 @@ namespace IronIntel.Contractor.Users | |||||||
|             return result; |             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) |         public static void AddGroup(UserGroupInfo gi) | ||||||
|         { |         { | ||||||
|             const string SQL_group = "insert into USERGROUPS(GROUPID,GROUPNAME,NOTES) values({0},{1},{2})"; |             const string SQL_group = "insert into USERGROUPS(GROUPID,GROUPNAME,NOTES) values({0},{1},{2})"; | ||||||
| @@ -555,7 +433,6 @@ namespace IronIntel.Contractor.Users | |||||||
|                 } |                 } | ||||||
|                 tran.Commit(); |                 tran.Commit(); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public static void UpdateGroup(UserGroupInfo gi) |         public static void UpdateGroup(UserGroupInfo gi) | ||||||
| @@ -643,49 +520,7 @@ namespace IronIntel.Contractor.Users | |||||||
|         } |         } | ||||||
|         #endregion |         #endregion | ||||||
|  |  | ||||||
|         #region User Machines/Jobsite |         #region User Machines/Jobsite/MachineType/Department/Location | ||||||
|  |  | ||||||
|         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); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         public static UserInfo[] GetUsersByAssetID(string sessionid, long assetid, string companyid) |         public static UserInfo[] GetUsersByAssetID(string sessionid, long assetid, string companyid) | ||||||
|         { |         { | ||||||
| @@ -700,6 +535,65 @@ namespace IronIntel.Contractor.Users | |||||||
|             return list.ToArray(); |             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> |         /// <summary> | ||||||
|         /// 获取机器对应的ContactID |         /// 获取机器对应的ContactID | ||||||
|         /// </summary> |         /// </summary> | ||||||
| @@ -864,11 +758,11 @@ namespace IronIntel.Contractor.Users | |||||||
|  |  | ||||||
|             return list; |             return list; | ||||||
|         } |         } | ||||||
|         internal static UserInfoItem[] GetPermissionUsers() |         internal static UserInfoItem[] GetPermissionUsers1() | ||||||
|         { |         { | ||||||
|             List<UserInfoItem> users = new List<UserInfoItem>(); |             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 = ""; |             string str = ""; | ||||||
|             for (int i = authenDt.Rows.Count - 1; i >= 0; i--) |             for (int i = authenDt.Rows.Count - 1; i >= 0; i--) | ||||||
| @@ -890,7 +784,30 @@ namespace IronIntel.Contractor.Users | |||||||
|             return users.ToArray(); |             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>(); |             List<UserPermissionData> UserOrGroupPermissionDatas = new List<UserPermissionData>(); | ||||||
|  |  | ||||||
| @@ -910,8 +827,8 @@ namespace IronIntel.Contractor.Users | |||||||
|                 UserPermissionData upmd = new UserPermissionData(); |                 UserPermissionData upmd = new UserPermissionData(); | ||||||
|                 upmd.FunctionIID = opr.IID; |                 upmd.FunctionIID = opr.IID; | ||||||
|                 upmd.IsAllowed = false; |                 upmd.IsAllowed = false; | ||||||
|                 upmd.ManagementFunction = ResManager.GetLanguage(ResManager.GetResourceString(opr.FunctionName)); |                 upmd.ManagementFunction = ResManager.GetLanguage(lang, ResManager.GetResourceString(opr.FunctionName)); | ||||||
|                 upmd.Description = ResManager.GetLanguage(ResManager.GetResourceString(opr.Description)); |                 upmd.Description = ResManager.GetLanguage(lang, ResManager.GetResourceString(opr.Description)); | ||||||
|                 upmd.IsNotPermissionInGroup = true; |                 upmd.IsNotPermissionInGroup = true; | ||||||
|  |  | ||||||
|                 UserOrGroupPermissionDatas.Add(upmd); |                 UserOrGroupPermissionDatas.Add(upmd); | ||||||
|   | |||||||
| @@ -14,6 +14,7 @@ namespace IronIntel.Contractor.Users | |||||||
|     public static class UserParams |     public static class UserParams | ||||||
|     { |     { | ||||||
|         private const string _AutoRecenterMap = "AutoRecenterMap"; |         private const string _AutoRecenterMap = "AutoRecenterMap"; | ||||||
|  |         private const string _ShowJSTooltip = "ShowJSTooltip"; | ||||||
|         private const string _BaseMap = "BaseMap"; |         private const string _BaseMap = "BaseMap"; | ||||||
|         private const string _MapViewContratorID = "MapViewContratorID"; |         private const string _MapViewContratorID = "MapViewContratorID"; | ||||||
|         private const string _MapAlertLayer = "MapAlertLayer"; |         private const string _MapAlertLayer = "MapAlertLayer"; | ||||||
| @@ -26,6 +27,7 @@ namespace IronIntel.Contractor.Users | |||||||
|         private const string _UnShownJobsites = "UnShownJobsites"; |         private const string _UnShownJobsites = "UnShownJobsites"; | ||||||
|         private const string _UnShownJobsiteMachines = "UnShownJobsiteMachines"; |         private const string _UnShownJobsiteMachines = "UnShownJobsiteMachines"; | ||||||
|         private const string _Onroad = "Onroad"; |         private const string _Onroad = "Onroad"; | ||||||
|  |         private const string _Attachment = "Attachment"; | ||||||
|         private const string _ExcludeNoLocation = "ExcludeNoLocation"; |         private const string _ExcludeNoLocation = "ExcludeNoLocation"; | ||||||
|  |  | ||||||
|         private const string _MapViewSearches = "MapViewSearches"; |         private const string _MapViewSearches = "MapViewSearches"; | ||||||
| @@ -47,6 +49,9 @@ namespace IronIntel.Contractor.Users | |||||||
|                     case _AutoRecenterMap: |                     case _AutoRecenterMap: | ||||||
|                         userParams.AutoRecenterMap = Helper.IsTrue(value); |                         userParams.AutoRecenterMap = Helper.IsTrue(value); | ||||||
|                         break; |                         break; | ||||||
|  |                     case _ShowJSTooltip: | ||||||
|  |                         userParams.ShowJSTooltip = Helper.IsTrue(value); | ||||||
|  |                         break; | ||||||
|                     case _BaseMap: |                     case _BaseMap: | ||||||
|                         userParams.BaseMap = value; |                         userParams.BaseMap = value; | ||||||
|                         break; |                         break; | ||||||
| @@ -80,6 +85,9 @@ namespace IronIntel.Contractor.Users | |||||||
|                     case _Onroad: |                     case _Onroad: | ||||||
|                         userParams.Onroad = int.Parse(value); |                         userParams.Onroad = int.Parse(value); | ||||||
|                         break; |                         break; | ||||||
|  |                     case _Attachment: | ||||||
|  |                         userParams.Attachment = int.Parse(value); | ||||||
|  |                         break; | ||||||
|                     case _ExcludeNoLocation: |                     case _ExcludeNoLocation: | ||||||
|                         userParams.ExcludeNoLocation = int.Parse(value) == 1; |                         userParams.ExcludeNoLocation = int.Parse(value) == 1; | ||||||
|                         break; |                         break; | ||||||
| @@ -102,6 +110,11 @@ namespace IronIntel.Contractor.Users | |||||||
|             else |             else | ||||||
|                 userParams.MapRefreshInterval = 60; |                 userParams.MapRefreshInterval = 60; | ||||||
|             userParams.MachineIconURL = SystemParams.MachineTypeMapViewIconUrl; |             userParams.MachineIconURL = SystemParams.MachineTypeMapViewIconUrl; | ||||||
|  |  | ||||||
|  |             var uc = FleetServiceClientHelper.CreateClient<UserQueryClient>(); | ||||||
|  |             userParams.PreferredLanguage = uc.GetUserPreferredLanguageByIID(useriid); | ||||||
|  |             userParams.TimeZone = uc.GetUserTimeZoneByIID(useriid); | ||||||
|  |  | ||||||
|             return userParams; |             return userParams; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -114,6 +127,7 @@ namespace IronIntel.Contractor.Users | |||||||
|  |  | ||||||
|             FIDbAccess db = SystemParams.GetDbInstance(); |             FIDbAccess db = SystemParams.GetDbInstance(); | ||||||
|             db.ExecSQL(SQL, useriid, _AutoRecenterMap, userParams.AutoRecenterMap ? "true" : "false"); |             db.ExecSQL(SQL, useriid, _AutoRecenterMap, userParams.AutoRecenterMap ? "true" : "false"); | ||||||
|  |             db.ExecSQL(SQL, useriid, _ShowJSTooltip, userParams.ShowJSTooltip ? "true" : "false"); | ||||||
|  |  | ||||||
|             if (!string.IsNullOrEmpty(userParams.BaseMap)) |             if (!string.IsNullOrEmpty(userParams.BaseMap)) | ||||||
|                 db.ExecSQL(SQL, useriid, _BaseMap, userParams.BaseMap); |                 db.ExecSQL(SQL, useriid, _BaseMap, userParams.BaseMap); | ||||||
| @@ -170,13 +184,18 @@ namespace IronIntel.Contractor.Users | |||||||
|             else |             else | ||||||
|                 db.ExecSQL(SQL_Delete, useriid, _Onroad); |                 db.ExecSQL(SQL_Delete, useriid, _Onroad); | ||||||
|  |  | ||||||
|             if (userParams.ExcludeNoLocation) |             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); |             db.ExecSQL(SQL, useriid, _ExcludeNoLocation, userParams.ExcludeNoLocation ? 1 : 0); | ||||||
|  |  | ||||||
|             if (!string.IsNullOrEmpty(userParams.LandingPage)) |             if (!string.IsNullOrEmpty(userParams.LandingPage)) | ||||||
|                 db.ExecSQL(SQL, useriid, _LandingPage, userParams.LandingPage); |                 db.ExecSQL(SQL, useriid, _LandingPage, userParams.LandingPage); | ||||||
|             else |             else | ||||||
|                 db.ExecSQL(SQL_Delete, useriid, _LandingPage); |                 db.ExecSQL(SQL_Delete, useriid, _LandingPage); | ||||||
|  |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public static string GetStringParameter(string useriid, string paramname) |         public static string GetStringParameter(string useriid, string paramname) | ||||||
| @@ -304,6 +323,7 @@ namespace IronIntel.Contractor.Users | |||||||
|     public class UserParamInfo |     public class UserParamInfo | ||||||
|     { |     { | ||||||
|         public bool AutoRecenterMap { get; set; } = false; |         public bool AutoRecenterMap { get; set; } = false; | ||||||
|  |         public bool ShowJSTooltip { get; set; } = false; | ||||||
|         public string BaseMap { get; set; } |         public string BaseMap { get; set; } | ||||||
|         public string MapViewContratorID { get; set; } |         public string MapViewContratorID { get; set; } | ||||||
|         public string MapAlertLayer { get; set; } |         public string MapAlertLayer { get; set; } | ||||||
| @@ -317,10 +337,13 @@ namespace IronIntel.Contractor.Users | |||||||
|         public string[] UnShownJobsites { get; set; } |         public string[] UnShownJobsites { get; set; } | ||||||
|         public string[] UnShownJobsiteMachines { get; set; } |         public string[] UnShownJobsiteMachines { get; set; } | ||||||
|         public int Onroad { get; set; } = -1; |         public int Onroad { get; set; } = -1; | ||||||
|  |         public int Attachment { get; set; } = 0; | ||||||
|         public bool ExcludeNoLocation { get; set; } = true; |         public bool ExcludeNoLocation { get; set; } = true; | ||||||
|  |  | ||||||
|         public MapViewSearchItem[] MapViewSearches { get; set; } |         public MapViewSearchItem[] MapViewSearches { get; set; } | ||||||
|         public string LandingPage { get; set; } |         public string LandingPage { get; set; } | ||||||
|  |         public string PreferredLanguage { get; set; } | ||||||
|  |         public string TimeZone { get; set; } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public class MapViewSearcheHelper |     public class MapViewSearcheHelper | ||||||
| @@ -355,6 +378,8 @@ namespace IronIntel.Contractor.Users | |||||||
|                     item.IsDefault = Helper.IsTrue(ch.InnerText); |                     item.IsDefault = Helper.IsTrue(ch.InnerText); | ||||||
|                 else if (string.Compare(ch.Name, "Onroad", true) == 0) |                 else if (string.Compare(ch.Name, "Onroad", true) == 0) | ||||||
|                     item.Onroad = Convert.ToInt32(ch.InnerText); |                     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) |                 else if (string.Compare(ch.Name, "AssetDefaultSearch", true) == 0) | ||||||
|                     item.AssetDefaultSearch = ch.InnerText; |                     item.AssetDefaultSearch = ch.InnerText; | ||||||
|                 else if (string.Compare(ch.Name, "JobSiteDefaultSearch", true) == 0) |                 else if (string.Compare(ch.Name, "JobSiteDefaultSearch", true) == 0) | ||||||
| @@ -392,6 +417,7 @@ namespace IronIntel.Contractor.Users | |||||||
|                     if (!string.IsNullOrEmpty(search.AssetGroupDefaultSearch)) |                     if (!string.IsNullOrEmpty(search.AssetGroupDefaultSearch)) | ||||||
|                         AddSubNode(sn, "AssetGroupDefaultSearch", search.AssetGroupDefaultSearch); |                         AddSubNode(sn, "AssetGroupDefaultSearch", search.AssetGroupDefaultSearch); | ||||||
|                     AddSubNode(sn, "Onroad", search.Onroad.ToString()); |                     AddSubNode(sn, "Onroad", search.Onroad.ToString()); | ||||||
|  |                     AddSubNode(sn, "Attachment", search.Attachment.ToString()); | ||||||
|                     AddSubNode(sn, "ExcludeNoLocation", search.ExcludeNoLocation ? "1" : "0"); |                     AddSubNode(sn, "ExcludeNoLocation", search.ExcludeNoLocation ? "1" : "0"); | ||||||
|                     if (search.UnShownMachines != null && search.UnShownMachines.Length > 0) |                     if (search.UnShownMachines != null && search.UnShownMachines.Length > 0) | ||||||
|                         AddSubNode(sn, "UnShownMachines", string.Join(",", search.UnShownMachines)); |                         AddSubNode(sn, "UnShownMachines", string.Join(",", search.UnShownMachines)); | ||||||
| @@ -422,6 +448,7 @@ namespace IronIntel.Contractor.Users | |||||||
|         public bool IsDefault { get; set; } |         public bool IsDefault { get; set; } | ||||||
|  |  | ||||||
|         public int Onroad { get; set; } = -1; |         public int Onroad { get; set; } = -1; | ||||||
|  |         public int Attachment { get; set; } = 0; | ||||||
|         public string AssetDefaultSearch { get; set; } = ""; |         public string AssetDefaultSearch { get; set; } = ""; | ||||||
|         public string JobSiteDefaultSearch { get; set; } = ""; |         public string JobSiteDefaultSearch { get; set; } = ""; | ||||||
|         public string AssetGroupDefaultSearch { 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"?> | <?xml version="1.0" encoding="utf-8"?> | ||||||
| <packages> | <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> | </packages> | ||||||
| @@ -3,8 +3,8 @@ using Foresight.Fleet.Services; | |||||||
| using Foresight.Fleet.Services.Asset; | using Foresight.Fleet.Services.Asset; | ||||||
| using Foresight.Fleet.Services.AssetHealth; | using Foresight.Fleet.Services.AssetHealth; | ||||||
| using Foresight.Fleet.Services.Device; | using Foresight.Fleet.Services.Device; | ||||||
|  | using Foresight.Fleet.Services.JobSite; | ||||||
| using Foresight.Fleet.Services.User; | using Foresight.Fleet.Services.User; | ||||||
| using Foresight.ServiceModel; |  | ||||||
| using IronIntel.Contractor.Machines; | using IronIntel.Contractor.Machines; | ||||||
| using IronIntel.Contractor.Maintenance; | using IronIntel.Contractor.Maintenance; | ||||||
| using IronIntel.Contractor.Users; | using IronIntel.Contractor.Users; | ||||||
| @@ -15,6 +15,7 @@ using System.Linq; | |||||||
| using System.Text; | using System.Text; | ||||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||||
| using System.Web; | using System.Web; | ||||||
|  | using Foresight.Standard; | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor.Site.Asset | namespace IronIntel.Contractor.Site.Asset | ||||||
| { | { | ||||||
| @@ -66,6 +67,18 @@ namespace IronIntel.Contractor.Site.Asset | |||||||
|                         case "CHANGEASSETPROPERTY": |                         case "CHANGEASSETPROPERTY": | ||||||
|                             result = ChangeAssetProperty(); |                             result = ChangeAssetProperty(); | ||||||
|                             break; |                             break; | ||||||
|  |                         case "GETASSETATTACHMENTINFO": | ||||||
|  |                             result = GetAssetAttachmentInfo(); | ||||||
|  |                             break; | ||||||
|  |                         case "DELETEASSETS": | ||||||
|  |                             result = DeleteAssets(); | ||||||
|  |                             break; | ||||||
|  |                         case "MERGEASSET": | ||||||
|  |                             result = MergeAsset(); | ||||||
|  |                             break; | ||||||
|  |                         case "GETASSETDATASOURCES": | ||||||
|  |                             result = GetAssetDatasources(); | ||||||
|  |                             break; | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| @@ -89,6 +102,8 @@ namespace IronIntel.Contractor.Site.Asset | |||||||
|                     var companyid = HttpUtility.HtmlDecode(clientdata[0]); |                     var companyid = HttpUtility.HtmlDecode(clientdata[0]); | ||||||
|                     bool showHidden = HttpUtility.HtmlDecode(clientdata[1]) == "1"; |                     bool showHidden = HttpUtility.HtmlDecode(clientdata[1]) == "1"; | ||||||
|                     var searchtxt = HttpUtility.HtmlDecode(clientdata[2]); |                     var searchtxt = HttpUtility.HtmlDecode(clientdata[2]); | ||||||
|  |                     bool attachment = HttpUtility.HtmlDecode(clientdata[3]) == "1"; | ||||||
|  |                     int att = attachment ? 0 : 2; | ||||||
|  |  | ||||||
|                     if (string.IsNullOrEmpty(companyid)) |                     if (string.IsNullOrEmpty(companyid)) | ||||||
|                         companyid = SystemParams.CompanyID; |                         companyid = SystemParams.CompanyID; | ||||||
| @@ -98,13 +113,15 @@ namespace IronIntel.Contractor.Site.Asset | |||||||
|  |  | ||||||
|                     //GpsDeviceInfo[] devs = SystemParams.DeviceProvider.GetDeviceItems(contractorid, ""); |                     //GpsDeviceInfo[] devs = SystemParams.DeviceProvider.GetDeviceItems(contractorid, ""); | ||||||
|  |  | ||||||
|                     AssetBasicInfo[] assets = CreateClient<AssetQueryClient>(companyid).GetAssetBasicInfoByUser(companyid, searchtxt, session.User.UID); |                     AssetBasicInfo[] assets = CreateClient<AssetQueryClient>(companyid).GetAssetBasicInfoByUser(companyid, searchtxt, session.User.UID, att); | ||||||
|                     List<AssetBasicItem> list = new List<AssetBasicItem>(); |                     List<AssetBasicItem> list = new List<AssetBasicItem>(); | ||||||
|                     foreach (var a in assets) |                     foreach (var a in assets) | ||||||
|                     { |                     { | ||||||
|                         if (!showHidden && a.Hide) continue; |                         if (!showHidden && a.Hide) continue; | ||||||
|                         AssetBasicItem asset = new AssetBasicItem(); |                         AssetBasicItem asset = new AssetBasicItem(); | ||||||
|                         Helper.CloneProperty(asset, a); |                         Helper.CloneProperty(asset, a); | ||||||
|  |                         asset.EngineHours = a.EngineHours == null ? 0 : a.EngineHours.Value; | ||||||
|  |                         asset.Odometer = a.Odometer == null ? 0 : a.Odometer.Value; | ||||||
|                         list.Add(asset); |                         list.Add(asset); | ||||||
|                     } |                     } | ||||||
|                     return list.OrderBy((m) => m.VIN).ToArray(); |                     return list.OrderBy((m) => m.VIN).ToArray(); | ||||||
| @@ -150,7 +167,7 @@ namespace IronIntel.Contractor.Site.Asset | |||||||
|                     AssetDetailItem2 assetItem = new AssetDetailItem2(); |                     AssetDetailItem2 assetItem = new AssetDetailItem2(); | ||||||
|                     Helper.CloneProperty(assetItem, assetDetail); |                     Helper.CloneProperty(assetItem, assetDetail); | ||||||
|  |  | ||||||
|                     assetItem.OnSiteJobsiteID = mother.JobSiteID; |                     assetItem.JobSites = mother.JobSites; | ||||||
|                     assetItem.ContactIDs = string.IsNullOrEmpty(mother.ContactIDs) ? new string[0] : mother.ContactIDs.Split(','); |                     assetItem.ContactIDs = string.IsNullOrEmpty(mother.ContactIDs) ? new string[0] : mother.ContactIDs.Split(','); | ||||||
|                     assetItem.MachineGroupIDs = string.IsNullOrEmpty(mother.GroupIDs) ? new string[0] : mother.GroupIDs.Split(','); |                     assetItem.MachineGroupIDs = string.IsNullOrEmpty(mother.GroupIDs) ? new string[0] : mother.GroupIDs.Split(','); | ||||||
|  |  | ||||||
| @@ -190,7 +207,7 @@ namespace IronIntel.Contractor.Site.Asset | |||||||
|                 var session = GetCurrentLoginSession(); |                 var session = GetCurrentLoginSession(); | ||||||
|                 if (session != null) |                 if (session != null) | ||||||
|                 { |                 { | ||||||
|                     if (!CheckRight(SystemParams.CompanyID, Foresight.Fleet.Services.User.Feature.MANAGE_ASSETS)) |                     if (!CheckRight(SystemParams.CompanyID, Foresight.Fleet.Services.User.Feature.MANAGE_ASSETS, Permissions.FullControl)) | ||||||
|                         return ""; |                         return ""; | ||||||
|                     string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]); |                     string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]); | ||||||
|                     AssetDetailItem2 asset = JsonConvert.DeserializeObject<AssetDetailItem2>(clientdata); |                     AssetDetailItem2 asset = JsonConvert.DeserializeObject<AssetDetailItem2>(clientdata); | ||||||
| @@ -215,20 +232,13 @@ namespace IronIntel.Contractor.Site.Asset | |||||||
|                     AssetDataAdjustClient client = CreateClient<AssetDataAdjustClient>(customerid); |                     AssetDataAdjustClient client = CreateClient<AssetDataAdjustClient>(customerid); | ||||||
|                     if (asset.ID > 0) |                     if (asset.ID > 0) | ||||||
|                     { |                     { | ||||||
|                         //没有权限修改的,保持原来的值 |  | ||||||
|                         var oldMachine = client.GetAssetDetailInfo2(customerid, asset.ID); |                         var oldMachine = client.GetAssetDetailInfo2(customerid, asset.ID); | ||||||
|                         asset.EngineHours = oldMachine.EngineHours;//EngineHours单独保存 |                         if (oldMachine.ShareStatus == AssetShareStatus.Child) | ||||||
|                         var user = UserManagement.GetUserByIID(session.User.UID); |  | ||||||
|                         bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS); |  | ||||||
|                         if (!permission) |  | ||||||
|                         { |                         { | ||||||
|                             asset.VIN = oldMachine.VIN; |                             asset.VIN = oldMachine.VIN;//共享机器不能修改VIN/Make/Model/Type | ||||||
|                             asset.MakeID = oldMachine.MakeID; |                             asset.MakeID = oldMachine.MakeID; | ||||||
|                             asset.MakeName = oldMachine.MakeName; |  | ||||||
|                             asset.ModelID = oldMachine.ModelID; |                             asset.ModelID = oldMachine.ModelID; | ||||||
|                             asset.ModelName = oldMachine.ModelName; |                             asset.TypeID = oldMachine.TypeID; | ||||||
|                             asset.Odometer = oldMachine.Odometer; |  | ||||||
|                             asset.OdometerUnits = oldMachine.OdometerUnits; |  | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                     else if (!asset.IgnoreDuplicate) |                     else if (!asset.IgnoreDuplicate) | ||||||
| @@ -247,18 +257,14 @@ namespace IronIntel.Contractor.Site.Asset | |||||||
|  |  | ||||||
|                     AssetDetailInfo2 a = new AssetDetailInfo2(); |                     AssetDetailInfo2 a = new AssetDetailInfo2(); | ||||||
|                     Helper.CloneProperty(a, asset); |                     Helper.CloneProperty(a, asset); | ||||||
|                     a.ID = client.UpdateAssetInfo(customerid, a, asset.ContactIDs, asset.MachineGroupIDs, (int)asset.OnSiteJobsiteID, session.User.UID); |                     a.ID = client.UpdateAssetInfo(customerid, a, asset.ContactIDs, asset.MachineGroupIDs, session.User.UID); | ||||||
|  |                     CreateClient<JobSiteProvider>(customerid).AddAssetToJobSites(customerid, asset.OnSiteJobsiteIDs, a.ID, a.VIN); | ||||||
|  |  | ||||||
|                     UpdateMachineAttributes(a.ID, asset.ContractorID, asset.MachineAttributes, session.User.UID); |  | ||||||
|                     if (asset.VisibleOnWorkOrders != null) |  | ||||||
|                     { |  | ||||||
|                         foreach (StringKeyValue kv in asset.VisibleOnWorkOrders) |  | ||||||
|                         { |  | ||||||
|                             CreateClient<AssetAttachmentProvider>(customerid).ChangeVisibleOnWorkOrder(customerid, Convert.ToInt32(kv.Key), Helper.IsTrue(kv.Value)); |  | ||||||
|                         } |  | ||||||
|  |  | ||||||
|                     } |  | ||||||
|                     long rentalID = -1; |                     long rentalID = -1; | ||||||
|  |                     if (a.ShareStatus != AssetShareStatus.Child) | ||||||
|  |                     { | ||||||
|  |                         UpdateMachineAttributes(a.ID, asset.ContractorID, asset.MachineAttributes, session.User.UID); | ||||||
|  |  | ||||||
|                         if (asset.MachineRental != null) |                         if (asset.MachineRental != null) | ||||||
|                         { |                         { | ||||||
|                             asset.MachineRental.MachineID = a.ID; |                             asset.MachineRental.MachineID = a.ID; | ||||||
| @@ -267,6 +273,13 @@ namespace IronIntel.Contractor.Site.Asset | |||||||
|                             rentalinfo.RentalRate = (double)asset.MachineRental.RentalRate; |                             rentalinfo.RentalRate = (double)asset.MachineRental.RentalRate; | ||||||
|                             rentalID = CreateClient<AssetQueryClient>(customerid).SaveAssetRental(customerid, rentalinfo, session.User.UID); |                             rentalID = CreateClient<AssetQueryClient>(customerid).SaveAssetRental(customerid, rentalinfo, session.User.UID); | ||||||
|                         } |                         } | ||||||
|  |                         if (asset.AttachmentInfo != null) | ||||||
|  |                         { | ||||||
|  |                             asset.AttachmentInfo.AssetId = a.ID; | ||||||
|  |                             client.UpdateAssetAttachmentAttribute(customerid, asset.AttachmentInfo, session.User.UID); | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |  | ||||||
|                     return new |                     return new | ||||||
|                     { |                     { | ||||||
|                         Result = 1, |                         Result = 1, | ||||||
| @@ -289,6 +302,47 @@ namespace IronIntel.Contractor.Site.Asset | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         private object GetAssetAttachmentInfo() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 if (GetCurrentLoginSession() != null) | ||||||
|  |                 { | ||||||
|  |                     var clientdata = Request.Form["ClientData"].Split((char)170); | ||||||
|  |                     var companyid = HttpUtility.HtmlDecode(clientdata[0]); | ||||||
|  |                     if (string.IsNullOrEmpty(companyid)) | ||||||
|  |                         companyid = SystemParams.CompanyID; | ||||||
|  |                     var mid = HttpUtility.HtmlDecode(clientdata[1]); | ||||||
|  |                     long machineid = -1; | ||||||
|  |                     long.TryParse(mid, out machineid); | ||||||
|  |  | ||||||
|  |                     var client = CreateClient<AssetDataAdjustClient>(companyid); | ||||||
|  |                     AttachmentAttributeItem attaitem = null; | ||||||
|  |                     AttachmentAttributeInfo attainfo = client.GetAssetAttachmentAttribute(companyid, machineid); | ||||||
|  |                     if (attainfo != null) | ||||||
|  |                     { | ||||||
|  |                         attaitem = new AttachmentAttributeItem(); | ||||||
|  |                         Helper.CloneProperty(attaitem, attainfo); | ||||||
|  |                         if (attaitem.AttachedtoAssetId != null && attaitem.AttachedtoAssetId.Value > 0) | ||||||
|  |                         { | ||||||
|  |                             var asset = CreateClient<AssetQueryClient>(companyid).GetAssetBasicInfoByID(companyid, attaitem.AttachedtoAssetId.Value); | ||||||
|  |                             if (asset != null) | ||||||
|  |                                 attaitem.AttachedtoAssetName = asset.DisplayName; | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |  | ||||||
|  |                     return attaitem; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return new AttachmentAttributeItem(); | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 SystemParams.WriteLog("error", "AssetBasePage.GetAssetAttachmentInfo", ex.Message, ex.ToString()); | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|         private string ChangeAssetProperty() |         private string ChangeAssetProperty() | ||||||
|         { |         { | ||||||
|             try |             try | ||||||
| @@ -317,6 +371,12 @@ namespace IronIntel.Contractor.Site.Asset | |||||||
|                         case "TelematicsEnabled": |                         case "TelematicsEnabled": | ||||||
|                             CreateClient<AssetDataAdjustClient>(contractorid).ChangeAssetTelematicsProperty(contractorid, assetid, value, "", user.IID); |                             CreateClient<AssetDataAdjustClient>(contractorid).ChangeAssetTelematicsProperty(contractorid, assetid, value, "", user.IID); | ||||||
|                             break; |                             break; | ||||||
|  |                         case "Attachment": | ||||||
|  |                             CreateClient<AssetDataAdjustClient>(contractorid).ChangeAssetAttachmentProperty(contractorid, assetid, value, "", user.IID); | ||||||
|  |                             break; | ||||||
|  |                         case "Preloaded": | ||||||
|  |                             CreateClient<AssetDataAdjustClient>(contractorid).ChangeAssetPreloadedProperty(contractorid, assetid, value, "", user.IID); | ||||||
|  |                             break; | ||||||
|                         default: |                         default: | ||||||
|                             break; |                             break; | ||||||
|                     } |                     } | ||||||
| @@ -475,9 +535,8 @@ namespace IronIntel.Contractor.Site.Asset | |||||||
|  |  | ||||||
|                     if (!DateTime.TryParse(edate, out endtime)) |                     if (!DateTime.TryParse(edate, out endtime)) | ||||||
|                         endtime = DateTime.MaxValue; |                         endtime = DateTime.MaxValue; | ||||||
|                     else |  | ||||||
|                         endtime = endtime.Date.AddDays(1).AddSeconds(-1); |  | ||||||
|  |  | ||||||
|  |                     AssetBasicInfo asset = CreateClient<AssetQueryClient>(customerid).GetAssetBasicInfoByID(customerid, Convert.ToInt64(assetid)); | ||||||
|                     AssetOdometerAdjustInfo[] odos = CreateClient<AssetDataAdjustClient>(customerid).GetOdometerAdjustmentHistory(customerid, Convert.ToInt64(assetid), starttime, endtime); |                     AssetOdometerAdjustInfo[] odos = CreateClient<AssetDataAdjustClient>(customerid).GetOdometerAdjustmentHistory(customerid, Convert.ToInt64(assetid), starttime, endtime); | ||||||
|                     if (odos == null || odos.Length == 0) |                     if (odos == null || odos.Length == 0) | ||||||
|                         return new AssetOdometerAdjustItem[0]; |                         return new AssetOdometerAdjustItem[0]; | ||||||
| @@ -487,6 +546,8 @@ namespace IronIntel.Contractor.Site.Asset | |||||||
|                     { |                     { | ||||||
|                         AssetOdometerAdjustItem item = new AssetOdometerAdjustItem(); |                         AssetOdometerAdjustItem item = new AssetOdometerAdjustItem(); | ||||||
|                         Helper.CloneProperty(item, odo); |                         Helper.CloneProperty(item, odo); | ||||||
|  |                         item.DisplayName = asset.DisplayName; | ||||||
|  |                         item.VIN = asset.VIN; | ||||||
|                         list.Add(item); |                         list.Add(item); | ||||||
|                     } |                     } | ||||||
|                     return list.ToArray(); |                     return list.ToArray(); | ||||||
| @@ -525,9 +586,8 @@ namespace IronIntel.Contractor.Site.Asset | |||||||
|  |  | ||||||
|                     if (!DateTime.TryParse(edate, out endtime)) |                     if (!DateTime.TryParse(edate, out endtime)) | ||||||
|                         endtime = DateTime.MaxValue; |                         endtime = DateTime.MaxValue; | ||||||
|                     else |  | ||||||
|                         endtime = endtime.Date.AddDays(1).AddSeconds(-1); |  | ||||||
|  |  | ||||||
|  |                     AssetBasicInfo asset = CreateClient<AssetQueryClient>(customerid).GetAssetBasicInfoByID(customerid, Convert.ToInt64(assetid)); | ||||||
|                     AssetEngineHoursAdjustInfo[] hours = CreateClient<AssetDataAdjustClient>(customerid).GetEngineHoursAdjustmentHistory(customerid, Convert.ToInt64(assetid), starttime, endtime); |                     AssetEngineHoursAdjustInfo[] hours = CreateClient<AssetDataAdjustClient>(customerid).GetEngineHoursAdjustmentHistory(customerid, Convert.ToInt64(assetid), starttime, endtime); | ||||||
|                     if (hours == null || hours.Length == 0) |                     if (hours == null || hours.Length == 0) | ||||||
|                         return new AssetEngineHoursAdjustItem[0]; |                         return new AssetEngineHoursAdjustItem[0]; | ||||||
| @@ -537,6 +597,8 @@ namespace IronIntel.Contractor.Site.Asset | |||||||
|                     { |                     { | ||||||
|                         AssetEngineHoursAdjustItem item = new AssetEngineHoursAdjustItem(); |                         AssetEngineHoursAdjustItem item = new AssetEngineHoursAdjustItem(); | ||||||
|                         Helper.CloneProperty(item, hour); |                         Helper.CloneProperty(item, hour); | ||||||
|  |                         item.DisplayName = asset.DisplayName; | ||||||
|  |                         item.VIN = asset.VIN; | ||||||
|                         list.Add(item); |                         list.Add(item); | ||||||
|                     } |                     } | ||||||
|                     return list.ToArray(); |                     return list.ToArray(); | ||||||
| @@ -572,9 +634,9 @@ namespace IronIntel.Contractor.Site.Asset | |||||||
|  |  | ||||||
|                     StringKeyValue kv = new StringKeyValue(); |                     StringKeyValue kv = new StringKeyValue(); | ||||||
|                     kv.Key = SystemParams.GetStringParam("CustomerTimeZone", false, db); |                     kv.Key = SystemParams.GetStringParam("CustomerTimeZone", false, db); | ||||||
|                     TimeZoneInfo tz = SystemParams.GetTimeZoneInfo(custid, db); |                     TimeZoneInfo tz = SystemParams.GetTimeZoneInfo(custid); | ||||||
|                     DateTime time = TimeZoneInfo.ConvertTimeFromUtc(DateTime.Now.ToUniversalTime(), tz); |                     DateTime time = SystemParams.ConvertToUserTimeFromUtc(session.User, DateTime.Now.ToUniversalTime()); | ||||||
|                     kv.Value = time.ToString("MM/dd/yyyy HH:mm:ss"); |                     kv.Value = time.ToString("MM/dd/yyyy HH:mm:ss");//此处格式不能修改 | ||||||
|                     return kv; |                     return kv; | ||||||
|                 } |                 } | ||||||
|                 else |                 else | ||||||
| @@ -632,7 +694,7 @@ namespace IronIntel.Contractor.Site.Asset | |||||||
|                     string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]); |                     string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]); | ||||||
|                     long assetid = 0; |                     long assetid = 0; | ||||||
|                     long.TryParse(clientdata, out assetid); |                     long.TryParse(clientdata, out assetid); | ||||||
|                     return MaintenanceManagement.GetPmScheduleByAsset(session.SessionID, assetid); |                     return MaintenanceManagement.GetPmScheduleByAsset(session.SessionID, assetid, true); | ||||||
|                 } |                 } | ||||||
|                 else |                 else | ||||||
|                     return new PmScheduleInfo[0]; |                     return new PmScheduleInfo[0]; | ||||||
| @@ -701,6 +763,108 @@ namespace IronIntel.Contractor.Site.Asset | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         private object DeleteAssets() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null && session.User.UserType == Foresight.Fleet.Services.User.UserTypes.SupperAdmin) | ||||||
|  |                 { | ||||||
|  |                     string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]); | ||||||
|  |                     string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata); | ||||||
|  |                     string custid = ps[0]; | ||||||
|  |                     long[] assetids = JsonConvert.DeserializeObject<long[]>(ps[1]); | ||||||
|  |                     string notes = ps[2]; | ||||||
|  |  | ||||||
|  |                     if (string.IsNullOrEmpty(custid)) | ||||||
|  |                         custid = SystemParams.CompanyID; | ||||||
|  |  | ||||||
|  |                     var client = CreateClient<AssetDataAdjustClient>(custid); | ||||||
|  |                     foreach (long assetid in assetids) | ||||||
|  |                     { | ||||||
|  |                         client.DeleteAsset(custid, Convert.ToInt64(assetid), notes); | ||||||
|  |                     } | ||||||
|  |                     return ""; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     return "Failed"; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 SystemParams.WriteLog("error", "AssetBasePage.DeleteAsset", ex.Message, ex.ToString()); | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private object MergeAsset() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null && session.User.UserType == Foresight.Fleet.Services.User.UserTypes.SupperAdmin) | ||||||
|  |                 { | ||||||
|  |                     string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]); | ||||||
|  |                     string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata); | ||||||
|  |                     string custid = ps[0]; | ||||||
|  |                     string fromassetid = ps[1]; | ||||||
|  |                     string toassetid = ps[2]; | ||||||
|  |                     string notes = ps[3]; | ||||||
|  |  | ||||||
|  |                     if (string.IsNullOrEmpty(custid)) | ||||||
|  |                         custid = SystemParams.CompanyID; | ||||||
|  |  | ||||||
|  |                     CreateClient<AssetDataAdjustClient>(custid).MergeAsset(custid, Convert.ToInt64(fromassetid), Convert.ToInt64(toassetid), notes); | ||||||
|  |                     return ""; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     return "Failed"; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 SystemParams.WriteLog("error", "AssetBasePage.MergeAsset", ex.Message, ex.ToString()); | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private object GetAssetDatasources() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 if (GetCurrentLoginSession() != null) | ||||||
|  |                 { | ||||||
|  |                     string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]); | ||||||
|  |                     string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata); | ||||||
|  |                     var companyid = HttpUtility.HtmlDecode(ps[0]); | ||||||
|  |                     var mid = HttpUtility.HtmlDecode(ps[1]); | ||||||
|  |                     long machineid = -1; | ||||||
|  |                     long.TryParse(mid, out machineid); | ||||||
|  |  | ||||||
|  |                     if (!SystemParams.IsDealer) | ||||||
|  |                     { | ||||||
|  |                         companyid = SystemParams.CompanyID; | ||||||
|  |                     } | ||||||
|  |  | ||||||
|  |                     var client = CreateClient<AssetDataAdjustClient>(companyid); | ||||||
|  |                     string[] datasources = client.GetAssetDatasources(companyid, machineid); | ||||||
|  |                     if (datasources == null) | ||||||
|  |                         return new string[0]; | ||||||
|  |  | ||||||
|  |                     return datasources; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return new string[0]; | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 SystemParams.WriteLog("error", "AssetBasePage.GetAssetDatasources", ex.Message, ex.ToString()); | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|         class PMScheduleAssetItem |         class PMScheduleAssetItem | ||||||
|         { |         { | ||||||
|             public long AssetId { get; set; } |             public long AssetId { get; set; } | ||||||
| @@ -711,5 +875,15 @@ namespace IronIntel.Contractor.Site.Asset | |||||||
|             public int? StartIntervalValue { get; set; } |             public int? StartIntervalValue { get; set; } | ||||||
|             public string SelectedIntervalID { get; set; } |             public string SelectedIntervalID { get; set; } | ||||||
|         } |         } | ||||||
|  |         class AttachmentAttributeItem : AttachmentAttributeInfo | ||||||
|  |         { | ||||||
|  |             public string AttachedtoAssetName { get; set; } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         class AssetMergeItem : AssetMergeInfo | ||||||
|  |         { | ||||||
|  |             public string CompletedOnStr { get { return CompletedOn == DateTime.MinValue ? "" : CompletedOn.ToString(); } } | ||||||
|  |             public string MergeOnStr { get { return MergeOn == DateTime.MinValue ? "" : MergeOn.ToString(); } } | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										346
									
								
								IronIntelContractorSiteLib/Asset/ShareAssetBasePage.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										346
									
								
								IronIntelContractorSiteLib/Asset/ShareAssetBasePage.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,346 @@ | |||||||
|  | using Foresight.Data; | ||||||
|  | using Foresight.Fleet.Services; | ||||||
|  | using Foresight.Fleet.Services.Asset; | ||||||
|  | using Foresight.Fleet.Services.AssetHealth; | ||||||
|  | using Foresight.Fleet.Services.Device; | ||||||
|  | using Foresight.Fleet.Services.JobSite; | ||||||
|  | using Foresight.Fleet.Services.User; | ||||||
|  | using IronIntel.Contractor.Machines; | ||||||
|  | using IronIntel.Contractor.Maintenance; | ||||||
|  | using IronIntel.Contractor.Users; | ||||||
|  | using Newtonsoft.Json; | ||||||
|  | using System; | ||||||
|  | using System.Collections.Generic; | ||||||
|  | using System.Linq; | ||||||
|  | using System.Text; | ||||||
|  | using System.Threading.Tasks; | ||||||
|  | using System.Web; | ||||||
|  | using Foresight.Standard; | ||||||
|  |  | ||||||
|  | namespace IronIntel.Contractor.Site.Asset | ||||||
|  | { | ||||||
|  |     public class ShareAssetBasePage : ContractorBasePage | ||||||
|  |     { | ||||||
|  |         protected void ProcessRequest(string method) | ||||||
|  |         { | ||||||
|  |             object result = null; | ||||||
|  |             string methodName = Request.Params["MethodName"]; | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 if (methodName != null) | ||||||
|  |                 { | ||||||
|  |                     switch (methodName.ToUpper()) | ||||||
|  |                     { | ||||||
|  |                         case "GETSHAREWITHCUSTOMERS": | ||||||
|  |                             result = GetShareWithCustomers(); | ||||||
|  |                             break; | ||||||
|  |                         case "SETSHAREWITHCUSTOMERS": | ||||||
|  |                             result = SetShareWithCustomers(); | ||||||
|  |                             break; | ||||||
|  |                         case "GETASSETSHAREINFOS": | ||||||
|  |                             result = GetAssetShareInfos(); | ||||||
|  |                             break; | ||||||
|  |                         case "GETSHAREASSETLIST": | ||||||
|  |                             result = GetShareAssetList(); | ||||||
|  |                             break; | ||||||
|  |                         case "SAVESHAREASSET": | ||||||
|  |                             result = SaveShareAsset(); | ||||||
|  |                             break; | ||||||
|  |                         case "UNSHAREASSET": | ||||||
|  |                             result = UnShareAsset(); | ||||||
|  |                             break; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 SystemParams.WriteLog("error", "ShareAssetBasePage", ex.Message, ex.ToString()); | ||||||
|  |                 throw ex; | ||||||
|  |             } | ||||||
|  |             string json = JsonConvert.SerializeObject(result); | ||||||
|  |             Response.Write(json); | ||||||
|  |             Response.End(); | ||||||
|  |         } | ||||||
|  |         private object GetShareWithCustomers() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|  |                 { | ||||||
|  |  | ||||||
|  |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |                     clientdata = HttpUtility.HtmlDecode(clientdata); | ||||||
|  |                     string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata); | ||||||
|  |                     var companyid = ps[0]; | ||||||
|  |                     if (string.IsNullOrEmpty(companyid)) | ||||||
|  |                         companyid = SystemParams.CompanyID; | ||||||
|  |                     bool sharableonly = Helper.IsTrue(ps[1]); | ||||||
|  |                     var custs = CreateClient<ShareAssetsProvider>(companyid).GetSharableCustomers(companyid, sharableonly); | ||||||
|  |                     return custs.OrderBy((c) => c.CustomerName).ToArray(); | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return new MachineItem[0]; | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 AddLog("ERROR", "ShareAssetBasePage.GetShareWithCustomers", ex.Message, ex.ToString()); | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private object GetAssetShareInfos() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|  |                 { | ||||||
|  |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |                     clientdata = HttpUtility.HtmlDecode(clientdata); | ||||||
|  |                     string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata); | ||||||
|  |                     var companyid = ps[0]; | ||||||
|  |                     if (string.IsNullOrEmpty(companyid)) | ||||||
|  |                         companyid = SystemParams.CompanyID; | ||||||
|  |  | ||||||
|  |                     long asstid = -1; | ||||||
|  |                     long.TryParse(ps[1], out asstid); | ||||||
|  |                     AssetShareInfo[] assets = CreateClient<ShareAssetsProvider>(companyid).GetAssetShareInfos(companyid, asstid); | ||||||
|  |                     if (assets == null || assets.Length == 0) | ||||||
|  |                         return new AssetShareItem[0]; | ||||||
|  |  | ||||||
|  |                     List<AssetShareItem> ls = new List<AssetShareItem>(); | ||||||
|  |                     foreach (AssetShareInfo item in assets) | ||||||
|  |                     { | ||||||
|  |                         AssetShareItem ai = new AssetShareItem(); | ||||||
|  |                         Helper.CloneProperty(ai, item); | ||||||
|  |                         ls.Add(ai); | ||||||
|  |                     } | ||||||
|  |  | ||||||
|  |                     return ls.ToArray(); | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return new AssetShareItem[0]; | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 AddLog("ERROR", "ShareAssetBasePage.GetAssetShareInfos", ex.Message, ex.ToString()); | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private object GetShareAssetList() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|  |                 { | ||||||
|  |  | ||||||
|  |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |                     clientdata = HttpUtility.HtmlDecode(clientdata); | ||||||
|  |                     ShareAssetQueryItem q = JsonConvert.DeserializeObject<ShareAssetQueryItem>(clientdata); | ||||||
|  |                     if (string.IsNullOrEmpty(q.CustomerId)) | ||||||
|  |                         q.CustomerId = SystemParams.CompanyID; | ||||||
|  |  | ||||||
|  |                     ShareAssetItem[] assets = CreateClient<ShareAssetsProvider>(q.CustomerId).GetShareAssetList(q.CustomerId, q.Shared, q.OnRoad, q.IncludeHidden, q.Filter); | ||||||
|  |                     List<ShareAssetInfo> ls = new List<ShareAssetInfo>(); | ||||||
|  |                     foreach (ShareAssetItem item in assets) | ||||||
|  |                     { | ||||||
|  |                         ShareAssetInfo ai = new ShareAssetInfo(); | ||||||
|  |                         Helper.CloneProperty(ai, item); | ||||||
|  |                         if (ai.ShareInfo != null) | ||||||
|  |                         { | ||||||
|  |                             ai.ChildId = ai.ShareInfo.ChildId; | ||||||
|  |                             ai.ChildName = ai.ShareInfo.ChildName; | ||||||
|  |                             ai.StartDate = ai.ShareInfo.StartDate; | ||||||
|  |                             ai.ExpectedRetrievalDate = ai.ShareInfo.ExpectedRetrievalDate; | ||||||
|  |                             ai.RetrievalDate = ai.ShareInfo.RetrievalDate; | ||||||
|  |                         } | ||||||
|  |                         ls.Add(ai); | ||||||
|  |                     } | ||||||
|  |  | ||||||
|  |                     return ls.OrderBy(a => a.VIN).ToArray(); | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return new ShareAssetItem[0]; | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 AddLog("ERROR", "ShareAssetBasePage.GetShareAssetList", ex.Message, ex.ToString()); | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private object SaveShareAsset() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|  |                 { | ||||||
|  |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |                     clientdata = HttpUtility.HtmlDecode(clientdata); | ||||||
|  |                     var q = JsonConvert.DeserializeObject<SaveShareAssetParam>(clientdata); | ||||||
|  |                     if (string.IsNullOrEmpty(q.CustomerId)) | ||||||
|  |                         q.CustomerId = SystemParams.CompanyID; | ||||||
|  |  | ||||||
|  |                     DateTime? expected = DateTime.TryParse(q.EndDate, out DateTime dt) ? dt : default(DateTime?); | ||||||
|  |                     ShareAssetsProvider provider = CreateClient<ShareAssetsProvider>(q.CustomerId); | ||||||
|  |                     string[] results = new string[q.SharedIds.Length]; | ||||||
|  |                     Task[] tasks = new Task[q.SharedIds.Length]; | ||||||
|  |                     for (var i = 0; i < tasks.Length; i++) | ||||||
|  |                     { | ||||||
|  |                         var index = i; | ||||||
|  |                         var id = q.SharedIds[i]; | ||||||
|  |                         tasks[i] = Task.Run(() => | ||||||
|  |                         { | ||||||
|  |                             try | ||||||
|  |                             { | ||||||
|  |                                 provider.SetShareAsset(q.CustomerId, new AssetShareInfo | ||||||
|  |                                 { | ||||||
|  |                                     ChildId = q.SharedWith, | ||||||
|  |                                     AssetId = id, | ||||||
|  |                                     ExpectedRetrievalDate = expected, | ||||||
|  |                                     HideAssetOnThisSite = q.HideAsset | ||||||
|  |                                 }); | ||||||
|  |                             } | ||||||
|  |                             catch (Exception ex) | ||||||
|  |                             { | ||||||
|  |                                 results[index] = ex.Message; | ||||||
|  |                             } | ||||||
|  |                         }); | ||||||
|  |                     } | ||||||
|  |                     Task.WaitAll(tasks); | ||||||
|  |                     return results; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     return null; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 AddLog("ERROR", "ShareAssetBasePage.SaveShareAsset", ex.Message, ex.ToString()); | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private object UnShareAsset() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|  |                 { | ||||||
|  |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |                     clientdata = HttpUtility.HtmlDecode(clientdata); | ||||||
|  |                     var q = JsonConvert.DeserializeObject<SaveShareAssetParam>(clientdata); | ||||||
|  |                     if (string.IsNullOrEmpty(q.CustomerId)) | ||||||
|  |                         q.CustomerId = SystemParams.CompanyID; | ||||||
|  |  | ||||||
|  |                     ShareAssetsProvider provider = CreateClient<ShareAssetsProvider>(q.CustomerId); | ||||||
|  |                     string[] results = new string[q.SharedIds.Length]; | ||||||
|  |                     Task[] tasks = new Task[q.SharedIds.Length]; | ||||||
|  |                     for (var i = 0; i < tasks.Length; i++) | ||||||
|  |                     { | ||||||
|  |                         var index = i; | ||||||
|  |                         var id = q.SharedIds[i]; | ||||||
|  |                         tasks[i] = Task.Run(() => | ||||||
|  |                         { | ||||||
|  |                             try | ||||||
|  |                             { | ||||||
|  |                                 provider.UnShareAsset(q.CustomerId, id); | ||||||
|  |                             } | ||||||
|  |                             catch (Exception ex) | ||||||
|  |                             { | ||||||
|  |                                 results[index] = ex.Message; | ||||||
|  |                             } | ||||||
|  |                         }); | ||||||
|  |                     } | ||||||
|  |                     Task.WaitAll(tasks); | ||||||
|  |                     return results; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     return null; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 AddLog("ERROR", "ShareAssetBasePage.UnShareAsset", ex.Message, ex.ToString()); | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private object SetShareWithCustomers() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|  |                 { | ||||||
|  |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |                     clientdata = HttpUtility.HtmlDecode(clientdata); | ||||||
|  |                     string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata); | ||||||
|  |                     var companyid = ps[0]; | ||||||
|  |                     if (string.IsNullOrEmpty(companyid)) | ||||||
|  |                         companyid = SystemParams.CompanyID; | ||||||
|  |  | ||||||
|  |                     string[] ids = JsonConvert.DeserializeObject<string[]>(ps[1]); | ||||||
|  |                     string[] delids = JsonConvert.DeserializeObject<string[]>(ps[2]); | ||||||
|  |  | ||||||
|  |                     var client = CreateClient<ShareAssetsProvider>(companyid); | ||||||
|  |                     client.SetSharableCustomers(companyid, ids, true); | ||||||
|  |                     client.SetSharableCustomers(companyid, delids, false); | ||||||
|  |                 } | ||||||
|  |                 return ""; | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 AddLog("ERROR", "ShareAssetBasePage.SetShareWithCustomers", ex.Message, ex.ToString()); | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |     class ShareAssetInfo : ShareAssetItem | ||||||
|  |     { | ||||||
|  |         public string ChildId { get; set; } | ||||||
|  |         public string ChildName { get; set; } | ||||||
|  |         public DateTime? StartDate { get; set; } | ||||||
|  |         public DateTime? ExpectedRetrievalDate { get; set; } | ||||||
|  |         public DateTime? RetrievalDate { get; set; } | ||||||
|  |         public string StartDateStr { get { return Helper.IsNullDateTime(StartDate) ? "" : StartDate.Value.ToShortDateString(); } } | ||||||
|  |         public string ExpectedRetrievalDateStr { get { return Helper.IsNullDateTime(ExpectedRetrievalDate) ? "" : ExpectedRetrievalDate.Value.ToShortDateString(); } } | ||||||
|  |         public string RetrievalDateStr { get { return Helper.IsNullDateTime(RetrievalDate) ? "" : RetrievalDate.Value.ToShortDateString(); } } | ||||||
|  |         public double EngineHoursValue => EngineHours == null ? 0 : EngineHours.Value; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     class AssetShareItem : AssetShareInfo | ||||||
|  |     { | ||||||
|  |         public string StartDateStr { get { return Helper.IsNullDateTime(StartDate) ? "" : StartDate.Value.ToShortDateString(); } } | ||||||
|  |         public string ExpectedRetrievalDateStr { get { return Helper.IsNullDateTime(ExpectedRetrievalDate) ? "" : ExpectedRetrievalDate.Value.ToShortDateString(); } } | ||||||
|  |         public string RetrievalDateStr { get { return Helper.IsNullDateTime(RetrievalDate) ? "" : RetrievalDate.Value.ToShortDateString(); } } | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     class ShareAssetQueryItem | ||||||
|  |     { | ||||||
|  |         public string CustomerId { get; set; } | ||||||
|  |         public int Shared { get; set; } | ||||||
|  |         public int OnRoad { get; set; } | ||||||
|  |         public bool IncludeHidden { get; set; } | ||||||
|  |         public string Filter { get; set; } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     class SaveShareAssetParam | ||||||
|  |     { | ||||||
|  |         public string CustomerId { get; set; } | ||||||
|  |         public long[] SharedIds { get; set; } | ||||||
|  |         public string SharedWith { get; set; } | ||||||
|  |         public string EndDate { get; set; } | ||||||
|  |         public bool HideAsset { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -1,7 +1,4 @@ | |||||||
| using IronIntel.Contractor.Users; | using Newtonsoft.Json; | ||||||
| using IronIntel.Services; |  | ||||||
| using IronIntel.Services.Users; |  | ||||||
| using Newtonsoft.Json; |  | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using System.Linq; | using System.Linq; | ||||||
| @@ -48,7 +45,7 @@ namespace IronIntel.Contractor.Site | |||||||
|                 client.SessionID = session.SessionID; |                 client.SessionID = session.SessionID; | ||||||
|                 client.ClientHost = Request.UserHostName; |                 client.ClientHost = Request.UserHostName; | ||||||
|                 client.ChangePassword(session.User.UID, oldpass, newpass, session.SessionID); |                 client.ChangePassword(session.User.UID, oldpass, newpass, session.SessionID); | ||||||
|                 Response.Write(string.Empty); |                 Response.Write("\"\""); | ||||||
|             } |             } | ||||||
|             catch (Exception ex) |             catch (Exception ex) | ||||||
|             { |             { | ||||||
|   | |||||||
							
								
								
									
										97
									
								
								IronIntelContractorSiteLib/CommBase.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										97
									
								
								IronIntelContractorSiteLib/CommBase.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,97 @@ | |||||||
|  | using FI.FIC; | ||||||
|  | using Foresight.Fleet.Services.Styles; | ||||||
|  | using IronIntel.Contractor.iisitebase; | ||||||
|  | using IronIntel.Contractor.Users; | ||||||
|  | using System; | ||||||
|  | using System.Drawing; | ||||||
|  | using System.Web; | ||||||
|  | using System.Web.UI; | ||||||
|  |  | ||||||
|  | namespace IronIntel.Contractor.Site | ||||||
|  | { | ||||||
|  |     public class CommonBase : MasterPage | ||||||
|  |     { | ||||||
|  |         protected string CanExportFile = "false"; | ||||||
|  |         protected string StyleVariables = ""; | ||||||
|  |  | ||||||
|  |         protected virtual bool ExportModule => false; | ||||||
|  |  | ||||||
|  |         protected virtual StyleInfo GetUIStyle() | ||||||
|  |         { | ||||||
|  |             var sessionid = IronIntelBasePage.GetLoginSessionID(Request); | ||||||
|  |             var user = UserManagement.GetUserBySessionID(sessionid); | ||||||
|  |             CustUIStyle style = null; | ||||||
|  |             if (user != null) | ||||||
|  |             { | ||||||
|  |                 if (ExportModule) | ||||||
|  |                 { | ||||||
|  |                     CanExportFile = FICHostEnvironment.CanExportToFile(user.IID).ToString().ToLower(); | ||||||
|  |                 } | ||||||
|  |                 style = SystemParams.GetUIStyle(user.IID); | ||||||
|  |                 string color; | ||||||
|  |                 if (style != null) | ||||||
|  |                 { | ||||||
|  |                     color = style.TitleBarColor; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     color = "#f78e1e"; | ||||||
|  |                 } | ||||||
|  |                 string opacity; | ||||||
|  |                 string fore; | ||||||
|  |                 try | ||||||
|  |                 { | ||||||
|  |                     var c = ColorTranslator.FromHtml(color); | ||||||
|  |                     opacity = string.Format("rgb({0} {1} {2}/60%)", c.R, c.G, c.B); | ||||||
|  |                     fore = (.299 * c.R + .587 * c.G + .114 * c.B) < 127.5 ? "#f0f0f0" : "#0f0f0f"; | ||||||
|  |                 } | ||||||
|  |                 catch | ||||||
|  |                 { | ||||||
|  |                     opacity = "rgb(247 142 30/60%)"; | ||||||
|  |                     fore = "#0f0f0f"; | ||||||
|  |                 } | ||||||
|  |                 StyleVariables = $"--title-color: {fore}; --title-bg-color: {color}; --title-bg-opacity-color: {opacity}"; | ||||||
|  |             } | ||||||
|  |             return new StyleInfo | ||||||
|  |             { | ||||||
|  |                 User = user, | ||||||
|  |                 Style = style | ||||||
|  |             }; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         protected string GetUrl(string file) | ||||||
|  |         { | ||||||
|  |             string url; | ||||||
|  |             Page page = HttpContext.Current.Handler as Page; | ||||||
|  |             if (page != null) | ||||||
|  |             { | ||||||
|  |                 // Use page instance. | ||||||
|  |                 url = page.ResolveUrl("~/") + file; | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 // avoid duplicate operation | ||||||
|  |                 url = HttpContext.Current.Request.ApplicationPath + "/" + file; | ||||||
|  |             } | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var path = System.IO.Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, file); | ||||||
|  |                 if (System.IO.File.Exists(path)) | ||||||
|  |                 { | ||||||
|  |                     url += "?t=" + System.IO.File.GetLastWriteTimeUtc(path).Ticks; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch (Exception) | ||||||
|  |             { | ||||||
|  |                 // cant read file | ||||||
|  |             } | ||||||
|  |             return url; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public class StyleInfo | ||||||
|  |     { | ||||||
|  |         public UserInfo User { get; set; } | ||||||
|  |         public CustUIStyle Style { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -6,10 +6,11 @@ using System.Threading.Tasks; | |||||||
| using System.IO; | using System.IO; | ||||||
| using System.Web; | using System.Web; | ||||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||||
| using IronIntel.Services; |  | ||||||
| using IronIntel.Site; |  | ||||||
| using IronIntel.Contractor.Users; | using IronIntel.Contractor.Users; | ||||||
| using IronIntel.Services.Customers; | using Foresight.Fleet.Services.Customer; | ||||||
|  | using IronIntel.Contractor.iisitebase; | ||||||
|  | using Foresight.Fleet.Services.User; | ||||||
|  | using Foresight.Fleet.Services; | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor.Site | namespace IronIntel.Contractor.Site | ||||||
| { | { | ||||||
| @@ -19,7 +20,7 @@ namespace IronIntel.Contractor.Site | |||||||
|         { |         { | ||||||
|             if (string.IsNullOrWhiteSpace(companyid)) |             if (string.IsNullOrWhiteSpace(companyid)) | ||||||
|             { |             { | ||||||
|                 return SystemParams.GetCompanyLOGO(CompanyInfo.FORESIGHT); |                 return SystemParams.GetCompanyLOGO(CustomerInfo.FORESIGHT); | ||||||
|             } |             } | ||||||
|             else |             else | ||||||
|             { |             { | ||||||
| @@ -43,12 +44,8 @@ namespace IronIntel.Contractor.Site | |||||||
|  |  | ||||||
|         public static byte[] GetCustomerLocationLOGO(int locationid) |         public static byte[] GetCustomerLocationLOGO(int locationid) | ||||||
|         { |         { | ||||||
|             CustomerProvider ic = SystemParams.GetCustomerProvider(); |             CustomerProvider ic = FleetServiceClientHelper.CreateClient<CustomerProvider>(SystemParams.CompanyID); | ||||||
|             return ic.GetCustomerLocationLOGO(locationid); |             return ic.GetLocationLOGO(SystemParams.CompanyID, locationid, true); | ||||||
|         } |  | ||||||
|         public override string GetIronSystemServiceAddress() |  | ||||||
|         { |  | ||||||
|             return SystemParams.SystemServiceAddresses[0]; |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public CommonHttpRequestHandler(HttpContext context) |         public CommonHttpRequestHandler(HttpContext context) | ||||||
| @@ -62,6 +59,7 @@ namespace IronIntel.Contractor.Site | |||||||
|             if (string.IsNullOrWhiteSpace(s)) |             if (string.IsNullOrWhiteSpace(s)) | ||||||
|             { |             { | ||||||
|                 Context.Response.StatusCode = 204; |                 Context.Response.StatusCode = 204; | ||||||
|  |                 Context.Response.Write(JsonConvert.SerializeObject(null)); | ||||||
|                 Context.Response.End(); |                 Context.Response.End(); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
| @@ -73,12 +71,14 @@ namespace IronIntel.Contractor.Site | |||||||
|             catch |             catch | ||||||
|             { |             { | ||||||
|                 Context.Response.StatusCode = 400; |                 Context.Response.StatusCode = 400; | ||||||
|  |                 Context.Response.Write(JsonConvert.SerializeObject(null)); | ||||||
|                 Context.Response.End(); |                 Context.Response.End(); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|             if (req == null) |             if (req == null) | ||||||
|             { |             { | ||||||
|                 Context.Response.StatusCode = 204; |                 Context.Response.StatusCode = 204; | ||||||
|  |                 Context.Response.Write(JsonConvert.SerializeObject(null)); | ||||||
|                 Context.Response.End(); |                 Context.Response.End(); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
| @@ -101,8 +101,39 @@ namespace IronIntel.Contractor.Site | |||||||
|                 case CommonRequestMethods.AddLog: |                 case CommonRequestMethods.AddLog: | ||||||
|                     AddLog(req.ClientData); |                     AddLog(req.ClientData); | ||||||
|                     return; |                     return; | ||||||
|  |                 case CommonRequestMethods.GetLanguageResVersion: | ||||||
|  |                     GetLanguageResVersion(req.ClientData); | ||||||
|  |                     return; | ||||||
|  |                 case CommonRequestMethods.GetGridLayout: | ||||||
|  |                     GetGridLayout(req.ClientData); | ||||||
|  |                     return; | ||||||
|  |                 case CommonRequestMethods.SetGridLayout: | ||||||
|  |                     SetGridLayout(req.ClientData); | ||||||
|  |                     return; | ||||||
|  |                 case CommonRequestMethods.DeleteGridLayout: | ||||||
|  |                     DeleteGridLayout(req.ClientData); | ||||||
|  |                     return; | ||||||
|  |                 case CommonRequestMethods.GetUserMessages: | ||||||
|  |                     GetUserMessages(req.ClientData); | ||||||
|  |                     return; | ||||||
|  |                 case CommonRequestMethods.ReadUserMessages: | ||||||
|  |                     ReadUserMessages(req.ClientData); | ||||||
|  |                     return; | ||||||
|  |                 case CommonRequestMethods.DeleteUserMessages: | ||||||
|  |                     DeleteUserMessages(req.ClientData); | ||||||
|  |                     return; | ||||||
|  |                 case CommonRequestMethods.GetUnreadCount: | ||||||
|  |                     GetUnreadCount(req.ClientData); | ||||||
|  |                     return; | ||||||
|  |                 case CommonRequestMethods.GetCurrentDate: | ||||||
|  |                     GetCurrentDate(); | ||||||
|  |                     return; | ||||||
|  |                 case CommonRequestMethods.GetGridLayouts: | ||||||
|  |                     GetGridLayouts(req.ClientData); | ||||||
|  |                     return; | ||||||
|                 default: |                 default: | ||||||
|                     Context.Response.StatusCode = 204; |                     Context.Response.StatusCode = 204; | ||||||
|  |                     Context.Response.Write(JsonConvert.SerializeObject(null)); | ||||||
|                     Context.Response.End(); |                     Context.Response.End(); | ||||||
|                     return; |                     return; | ||||||
|             } |             } | ||||||
| @@ -112,6 +143,7 @@ namespace IronIntel.Contractor.Site | |||||||
|         { |         { | ||||||
|             if (LoginSession == null) |             if (LoginSession == null) | ||||||
|             { |             { | ||||||
|  |                 Context.Response.Write(JsonConvert.SerializeObject(null)); | ||||||
|                 Context.Response.StatusCode = 401; |                 Context.Response.StatusCode = 401; | ||||||
|             } |             } | ||||||
|             else |             else | ||||||
| @@ -122,11 +154,24 @@ namespace IronIntel.Contractor.Site | |||||||
|             Context.Response.End(); |             Context.Response.End(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         private void GetCurrentDate() | ||||||
|  |         { | ||||||
|  |             string s = string.Empty; | ||||||
|  |             if (LoginSession != null) | ||||||
|  |             { | ||||||
|  |                 DateTime dt = SystemParams.ConvertToUserTimeFromUtc(LoginSession.User, DateTime.UtcNow); | ||||||
|  |                 s = dt.ToString("M/d/yyyy h:mm tt"); | ||||||
|  |             } | ||||||
|  |             Context.Response.Write(JsonConvert.SerializeObject(s)); | ||||||
|  |             Context.Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         private void GetAppModules() |         private void GetAppModules() | ||||||
|         { |         { | ||||||
|             if (LoginSession == null) |             if (LoginSession == null) | ||||||
|             { |             { | ||||||
|                 Context.Response.StatusCode = 401; |                 Context.Response.StatusCode = 401; | ||||||
|  |                 Context.Response.Write(JsonConvert.SerializeObject(null)); | ||||||
|                 Context.Response.End(); |                 Context.Response.End(); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
| @@ -140,7 +185,7 @@ namespace IronIntel.Contractor.Site | |||||||
|         { |         { | ||||||
|             string s = LoginSession == null ? string.Empty : LoginSession.User.Name; |             string s = LoginSession == null ? string.Empty : LoginSession.User.Name; | ||||||
|  |  | ||||||
|             Context.Response.Write(s); |             Context.Response.Write(JsonConvert.SerializeObject(s)); | ||||||
|             Context.Response.End(); |             Context.Response.End(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -151,8 +196,185 @@ namespace IronIntel.Contractor.Site | |||||||
|             Context.Response.StatusCode = 200; |             Context.Response.StatusCode = 200; | ||||||
|             try |             try | ||||||
|             { |             { | ||||||
|  |                 string logininfo = ""; | ||||||
|  |                 if (LoginSession != null) | ||||||
|  |                 { | ||||||
|  |                     logininfo = LoginSession.SessionID; | ||||||
|  |                     if (LoginSession.User != null) | ||||||
|  |                         logininfo += "/" + LoginSession.User.ID; | ||||||
|  |                 } | ||||||
|                 string[] s = clientdata.Split(new char[] { SPLITCHAR }); |                 string[] s = clientdata.Split(new char[] { SPLITCHAR }); | ||||||
|                 SystemParams.WriteLog(s[0], s[1], s[2], s[3]); |                 SystemParams.WriteLog_Ext(s[0], s[1], s[2], s[3], logininfo); | ||||||
|  |                 Context.Response.Write("\"OK\""); | ||||||
|  |             } | ||||||
|  |             catch | ||||||
|  |             { } | ||||||
|  |             Context.Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void GetLanguageResVersion(string clientdata) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 if (string.IsNullOrEmpty(clientdata)) | ||||||
|  |                     clientdata = "en-us"; | ||||||
|  |                 string file = clientdata + ".json"; | ||||||
|  |                 var path = System.IO.Path.Combine(System.Web.HttpContext.Current.Request.PhysicalApplicationPath, "Languages\\" + file); | ||||||
|  |                 var ticks = System.IO.File.GetLastWriteTimeUtc(path).Ticks; | ||||||
|  |                 string json = JsonConvert.SerializeObject(ticks); | ||||||
|  |                 Context.Response.Write(json); | ||||||
|  |             } | ||||||
|  |             catch | ||||||
|  |             { } | ||||||
|  |             Context.Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void GetGridLayout(string clientdata) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 string objid = clientdata; | ||||||
|  |                 if (!string.IsNullOrEmpty(objid) && LoginSession != null) | ||||||
|  |                 { | ||||||
|  |                     var client = FleetServiceClientHelper.CreateClient<UserProfileProvider>(LoginSession.SessionID); | ||||||
|  |                     var layout = client.GetGridLayout(SystemParams.CompanyID, LoginSession.User.UID, objid); | ||||||
|  |                     Context.Response.Write(JsonConvert.SerializeObject(layout)); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch | ||||||
|  |             { } | ||||||
|  |             Context.Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void GetGridLayouts(string clientdata) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 string objid = clientdata; | ||||||
|  |                 if (!string.IsNullOrEmpty(objid) && LoginSession != null) | ||||||
|  |                 { | ||||||
|  |                     var client = FleetServiceClientHelper.CreateClient<UserProfileProvider>(LoginSession.SessionID); | ||||||
|  |                     UserGridLayoutInfo[] layouts = client.GetGridLayouts(SystemParams.CompanyID, LoginSession.User.UID, objid); | ||||||
|  |                     Context.Response.Write(JsonConvert.SerializeObject(layouts)); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch | ||||||
|  |             { } | ||||||
|  |             Context.Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void SetGridLayout(string clientdata) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 if (LoginSession != null) | ||||||
|  |                 { | ||||||
|  |                     string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata); | ||||||
|  |                     var layoutinfo = JsonConvert.DeserializeObject<UserGridLayoutInfo>(ps[0]); | ||||||
|  |                     if (layoutinfo.IsPublic && LoginSession.User.UserType < Foresight.Fleet.Services.User.UserTypes.Admin) | ||||||
|  |                         Context.Response.Write("\"-1\""); | ||||||
|  |  | ||||||
|  |                     layoutinfo.UserIID = LoginSession.User.UID; | ||||||
|  |                     bool overwrite = ps[1] == "1"; | ||||||
|  |  | ||||||
|  |                     var client = FleetServiceClientHelper.CreateClient<UserProfileProvider>(LoginSession.SessionID); | ||||||
|  |                     int r = client.SetGridLayout(SystemParams.CompanyID, layoutinfo, overwrite); | ||||||
|  |                     Context.Response.Write(JsonConvert.SerializeObject(r)); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch | ||||||
|  |             { } | ||||||
|  |             Context.Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void DeleteGridLayout(string clientdata) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 string layoutid = clientdata; | ||||||
|  |                 if (!string.IsNullOrEmpty(layoutid) && LoginSession != null) | ||||||
|  |                 { | ||||||
|  |                     var client = FleetServiceClientHelper.CreateClient<UserProfileProvider>(LoginSession.SessionID); | ||||||
|  |                     //client.DeleteGridLayout(SystemParams.CompanyID, LoginSession.User.UID, int.Parse(objid)); | ||||||
|  |                     client.DeleteGridLayout(SystemParams.CompanyID, int.Parse(layoutid)); | ||||||
|  |                     Context.Response.Write("\"OK\""); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch | ||||||
|  |             { } | ||||||
|  |             Context.Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void GetUserMessages(string clientdata) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 int startid = 0; | ||||||
|  |                 int.TryParse(clientdata, out startid); | ||||||
|  |                 if (int.TryParse(clientdata, out startid) && LoginSession != null) | ||||||
|  |                 { | ||||||
|  |                     var client = FleetServiceClientHelper.CreateClient<MessageProvider>(LoginSession.SessionID); | ||||||
|  |                     var msgs = client.GetMessages(SystemParams.CompanyID, startid); | ||||||
|  |                     List<MessageInfoClient> msgls = new List<MessageInfoClient>(); | ||||||
|  |                     foreach (var msg in msgs) | ||||||
|  |                     { | ||||||
|  |                         MessageInfoClient mc = new MessageInfoClient(); | ||||||
|  |                         Helper.CloneProperty(mc, msg); | ||||||
|  |                         msgls.Add(mc); | ||||||
|  |                     } | ||||||
|  |                     string json = JsonConvert.SerializeObject(msgls); | ||||||
|  |                     Context.Response.Write(json); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch | ||||||
|  |             { } | ||||||
|  |             Context.Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void ReadUserMessages(string clientdata) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 long[] msgids = JsonConvert.DeserializeObject<long[]>(clientdata); | ||||||
|  |                 if (msgids.Length > 0 && LoginSession != null) | ||||||
|  |                 { | ||||||
|  |                     var client = FleetServiceClientHelper.CreateClient<MessageProvider>(LoginSession.SessionID); | ||||||
|  |                     client.MarkReaded(SystemParams.CompanyID, msgids); | ||||||
|  |                     Context.Response.Write("\"OK\""); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch | ||||||
|  |             { } | ||||||
|  |             Context.Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void DeleteUserMessages(string clientdata) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 long[] msgids = JsonConvert.DeserializeObject<long[]>(clientdata); | ||||||
|  |                 if (msgids.Length > 0 && LoginSession != null) | ||||||
|  |                 { | ||||||
|  |                     var client = FleetServiceClientHelper.CreateClient<MessageProvider>(LoginSession.SessionID); | ||||||
|  |                     client.DeleteMessage(SystemParams.CompanyID, msgids); | ||||||
|  |                     Context.Response.Write("\"OK\""); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch | ||||||
|  |             { } | ||||||
|  |             Context.Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void GetUnreadCount(string clientdata) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 if (LoginSession != null) | ||||||
|  |                 { | ||||||
|  |                     var client = FleetServiceClientHelper.CreateClient<MessageProvider>(LoginSession.SessionID); | ||||||
|  |                     int count = client.GetNewMessageNumber(SystemParams.CompanyID); | ||||||
|  |                     Context.Response.Write(JsonConvert.SerializeObject(count)); | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|             catch |             catch | ||||||
|             { } |             { } | ||||||
| @@ -177,6 +399,21 @@ namespace IronIntel.Contractor.Site | |||||||
|         GetCurrentLoginName = 2, |         GetCurrentLoginName = 2, | ||||||
|         AddLog = 3, |         AddLog = 3, | ||||||
|         GetMachineMapPinItem = 4, |         GetMachineMapPinItem = 4, | ||||||
|         GetJobSiteMapItem = 5 |         GetJobSiteMapItem = 5, | ||||||
|  |         GetLanguageResVersion = 6, | ||||||
|  |         GetGridLayout = 7, | ||||||
|  |         SetGridLayout = 8, | ||||||
|  |         DeleteGridLayout = 9, | ||||||
|  |         GetUserMessages = 10, | ||||||
|  |         ReadUserMessages = 11, | ||||||
|  |         DeleteUserMessages = 12, | ||||||
|  |         GetUnreadCount = 13, | ||||||
|  |         GetCurrentDate = 14, | ||||||
|  |         GetGridLayouts = 15 | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public class MessageInfoClient : MessageInfo | ||||||
|  |     { | ||||||
|  |         public string CreatedTimeStr { get { return CreatedTime < new DateTime(2000, 1, 1) ? "" : CreatedTime.ToString(); } } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -210,7 +210,7 @@ namespace IronIntel.Contractor.Site.Contact | |||||||
|                 if (GetCurrentLoginSession() != null) |                 if (GetCurrentLoginSession() != null) | ||||||
|                 { |                 { | ||||||
|                     var s = Request.Form["ClientData"]; |                     var s = Request.Form["ClientData"]; | ||||||
|                     s = HttpUtility.UrlDecode(s); |                     s = HttpUtility.HtmlDecode(s); | ||||||
|  |  | ||||||
|                     var jss = CreateClient<JobSiteProvider>().GetJobSiteItems(SystemParams.CompanyID, "", false); |                     var jss = CreateClient<JobSiteProvider>().GetJobSiteItems(SystemParams.CompanyID, "", false); | ||||||
|                     List<JobSiteViewItem> list = new List<JobSiteViewItem>(); |                     List<JobSiteViewItem> list = new List<JobSiteViewItem>(); | ||||||
| @@ -243,7 +243,7 @@ namespace IronIntel.Contractor.Site.Contact | |||||||
|                 if (GetCurrentLoginSession() != null) |                 if (GetCurrentLoginSession() != null) | ||||||
|                 { |                 { | ||||||
|                     var contactid = Request.Form["ClientData"]; |                     var contactid = Request.Form["ClientData"]; | ||||||
|                     contactid = HttpUtility.UrlDecode(contactid); |                     contactid = HttpUtility.HtmlDecode(contactid); | ||||||
|  |  | ||||||
|                     items = ContactManagement.GetContactJobsitesByID(contactid); |                     items = ContactManagement.GetContactJobsitesByID(contactid); | ||||||
|                 } |                 } | ||||||
|   | |||||||
| @@ -2,15 +2,15 @@ | |||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using System.Linq; | using System.Linq; | ||||||
| using System.Text; | using System.Text; | ||||||
|  |  | ||||||
| using IronIntel.Services; |  | ||||||
| using IronIntel.Services.Users; |  | ||||||
| using IronIntel.Site; |  | ||||||
| using IronIntel.Contractor.Users; |  | ||||||
| using IronIntel.Services.Customers; |  | ||||||
| using System.Web; | using System.Web; | ||||||
| using Foresight.Fleet.Services; | using Foresight.Fleet.Services; | ||||||
| using Foresight.Fleet.Services.User; | using Foresight.Fleet.Services.User; | ||||||
|  | using Foresight.Fleet.Services.Style; | ||||||
|  | using Foresight.Fleet.Services.Customer; | ||||||
|  | using IronIntel.Contractor.Users; | ||||||
|  | using IronIntel.Contractor.iisitebase; | ||||||
|  | using Foresight.Standard; | ||||||
|  | using System.Security.Cryptography; | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor.Site | namespace IronIntel.Contractor.Site | ||||||
| { | { | ||||||
| @@ -47,7 +47,7 @@ namespace IronIntel.Contractor.Site | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         protected IronIntel.Contractor.Users.UserInfo GetCurrentUser() |         protected Users.UserInfo GetCurrentUser() | ||||||
|         { |         { | ||||||
|             var session = GetCurrentLoginSession(); |             var session = GetCurrentLoginSession(); | ||||||
|             if (session == null) |             if (session == null) | ||||||
| @@ -69,10 +69,23 @@ namespace IronIntel.Contractor.Site | |||||||
|                 return (user.UserType == Users.UserTypes.Admin || user.UserType == Users.UserTypes.SupperAdmin); |                 return (user.UserType == Users.UserTypes.Admin || user.UserType == Users.UserTypes.SupperAdmin); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |         protected virtual bool AllowCurrentLoginSessionEnter(LoginSession session) | ||||||
|         public override string GetIronSystemServiceAddress() |  | ||||||
|         { |         { | ||||||
|             return SystemParams.SystemServiceAddresses[0]; |             if (session == null) | ||||||
|  |                 session = GetCurrentLoginSession(); | ||||||
|  |             if (session == null) | ||||||
|  |             { | ||||||
|  |                 return false; | ||||||
|  |             } | ||||||
|  |             if (string.Compare(session.User.CompanyID, SystemParams.CompanyID, true) == 0) | ||||||
|  |             { | ||||||
|  |                 return true; | ||||||
|  |             } | ||||||
|  |             if (string.Compare(session.User.CompanyID, CustomerInfo.FORESIGHT, true) == 0) | ||||||
|  |             { | ||||||
|  |                 return true; | ||||||
|  |             } | ||||||
|  |             return CreateClient<UserQueryClient>().CanEnterSite(session.SessionID, SystemParams.CompanyID); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         protected virtual bool AllowCurrentLoginSessionEnter() |         protected virtual bool AllowCurrentLoginSessionEnter() | ||||||
| @@ -86,11 +99,11 @@ namespace IronIntel.Contractor.Site | |||||||
|             { |             { | ||||||
|                 return true; |                 return true; | ||||||
|             } |             } | ||||||
|             if (string.Compare(session.User.CompanyID, CompanyInfo.FORESIGHT, true) == 0) |             if (string.Compare(session.User.CompanyID, CustomerInfo.FORESIGHT, true) == 0) | ||||||
|             { |             { | ||||||
|                 return true; |                 return true; | ||||||
|             } |             } | ||||||
|             return CreateClient<Foresight.Fleet.Services.User.UserQueryClient>().CanEnterSite(session.SessionID, SystemParams.CompanyID); |             return CreateClient<UserQueryClient>().CanEnterSite(session.SessionID, SystemParams.CompanyID); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         protected virtual bool ThrowIfNotAllowed { get { return false; } } |         protected virtual bool ThrowIfNotAllowed { get { return false; } } | ||||||
| @@ -152,7 +165,12 @@ namespace IronIntel.Contractor.Site | |||||||
|                     RedirectToLoginPage(); |                     RedirectToLoginPage(); | ||||||
|                 return false; |                 return false; | ||||||
|             } |             } | ||||||
|             if (!AllowCurrentLoginSessionEnter() || !CheckRight(FeatureID)) |             if (!session.User.AllowLoginIntoPC) | ||||||
|  |             { | ||||||
|  |                 RedirectToErrorPage(); | ||||||
|  |                 return false; | ||||||
|  |             } | ||||||
|  |             if (!AllowCurrentLoginSessionEnter(session) || !CheckRight(FeatureID)) | ||||||
|             { |             { | ||||||
|                 if (ThrowIfNotAllowed) |                 if (ThrowIfNotAllowed) | ||||||
|                 { |                 { | ||||||
| @@ -160,7 +178,7 @@ namespace IronIntel.Contractor.Site | |||||||
|                 } |                 } | ||||||
|                 else |                 else | ||||||
|                 { |                 { | ||||||
|                     RedirectToEntryPage(); |                     RedirectToErrorPage(); | ||||||
|                 } |                 } | ||||||
|                 return false; |                 return false; | ||||||
|             } |             } | ||||||
| @@ -193,6 +211,13 @@ namespace IronIntel.Contractor.Site | |||||||
|                 Response.Redirect(LoginPageUrl, true); |                 Response.Redirect(LoginPageUrl, true); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         protected void RedirectToErrorPage() | ||||||
|  |         { | ||||||
|  |             var url = Request.Url; | ||||||
|  |             var addr = string.Format("{0}://{1}:{2}{3}/ErrorPage.aspx?code=403", url.Scheme, url.Host, url.Port, Request.ApplicationPath); | ||||||
|  |             Response.Redirect(addr, true); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         protected void DoLogout() |         protected void DoLogout() | ||||||
|         { |         { | ||||||
|             string sid = null; |             string sid = null; | ||||||
| @@ -222,7 +247,14 @@ namespace IronIntel.Contractor.Site | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             RedirectToLoginPage(); |             //RedirectToLoginPage(); | ||||||
|  |             RedirectToLoginPageAndClearCookie(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         protected void RedirectToLoginPageAndClearCookie() | ||||||
|  |         {//由于登录站点和Contractor站得Webconfig的sessioncookiedomain配置不一样导致ClearLoginSessionCookie无法清除Sessionid的cookie | ||||||
|  |             //增加tp=c,在登录页面清除Sessionid的cookie | ||||||
|  |             Response.Redirect(LoginPageUrl + "?tp=c"); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         protected void AddLog(string type, string source, string message, string detail) |         protected void AddLog(string type, string source, string message, string detail) | ||||||
| @@ -277,13 +309,15 @@ namespace IronIntel.Contractor.Site | |||||||
|  |  | ||||||
|         public virtual string JQueryVersion |         public virtual string JQueryVersion | ||||||
|         { |         { | ||||||
|             get { return "1.8.0"; } |             get { return "3.6.0"; } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         protected T CreateClient<T>(string companyid = null) where T : RemoteClientBase |         protected T CreateClient<T>(string companyid = null) where T : RemoteClientBase | ||||||
|         { |         { | ||||||
|             var session = GetCurrentLoginSession(); |             var session = GetCurrentLoginSession(); | ||||||
|             return FleetServiceClientHelper.CreateClient<T>(companyid, session == null ? "" : session.SessionID); |             var client = FleetServiceClientHelper.CreateClient<T>(string.IsNullOrEmpty(companyid) ? SystemParams.CompanyID : companyid, session == null ? "" : session.SessionID); | ||||||
|  |             client.Timeout = 300; | ||||||
|  |             return client; | ||||||
|         } |         } | ||||||
|         protected bool CheckRight(int featureid) |         protected bool CheckRight(int featureid) | ||||||
|         { |         { | ||||||
| @@ -292,7 +326,7 @@ namespace IronIntel.Contractor.Site | |||||||
|             return CheckRight(SystemParams.CompanyID, featureid); |             return CheckRight(SystemParams.CompanyID, featureid); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         protected bool CheckRight(string custid, int featureid) |         protected bool CheckRight(string custid, int featureid, Permissions per = Permissions.ReadOnly) | ||||||
|         { |         { | ||||||
|             var user = GetCurrentUser(); |             var user = GetCurrentUser(); | ||||||
|             if (user == null) |             if (user == null) | ||||||
| @@ -308,7 +342,53 @@ namespace IronIntel.Contractor.Site | |||||||
|                 if (pmss.Length > 0) |                 if (pmss.Length > 0) | ||||||
|                 { |                 { | ||||||
|                     Tuple<Feature, Permissions> permission = pmss.FirstOrDefault(m => m.Item1.Id == featureid); |                     Tuple<Feature, Permissions> permission = pmss.FirstOrDefault(m => m.Item1.Id == featureid); | ||||||
|                     if (permission != null) |                     if (permission != null && permission.Item2 >= per) | ||||||
|  |                         return true; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         protected bool CheckReadonly(string custid, int featureid) | ||||||
|  |         { | ||||||
|  |             var user = GetCurrentUser(); | ||||||
|  |             if (user == null) | ||||||
|  |                 return false; | ||||||
|  |  | ||||||
|  |             if (user.UserType == Users.UserTypes.SupperAdmin || user.UserType == Users.UserTypes.Admin) | ||||||
|  |                 return false; | ||||||
|  |  | ||||||
|  |             if (user.UserType == Users.UserTypes.Common) | ||||||
|  |             { | ||||||
|  |                 var client = FleetServiceClientHelper.CreateClient<PermissionProvider>(); | ||||||
|  |                 Tuple<Feature, Permissions>[] pmss = client.GetUserPermissions(custid, user.IID); | ||||||
|  |                 if (pmss.Length > 0) | ||||||
|  |                 { | ||||||
|  |                     Tuple<Feature, Permissions> permission = pmss.FirstOrDefault(m => m.Item1.Id == featureid); | ||||||
|  |                     if (permission != null && permission.Item2 == Permissions.ReadOnly) | ||||||
|  |                         return true; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         protected bool CanEdit(string custid, int featureid, Permissions per = Permissions.FullControl) | ||||||
|  |         { | ||||||
|  |             var user = GetCurrentUser(); | ||||||
|  |             if (user == null) | ||||||
|  |                 return false; | ||||||
|  |  | ||||||
|  |             if (user.UserType == Users.UserTypes.SupperAdmin || user.UserType == Users.UserTypes.Admin) | ||||||
|  |                 return true; | ||||||
|  |  | ||||||
|  |             if (user.UserType == Users.UserTypes.Common) | ||||||
|  |             { | ||||||
|  |                 var client = FleetServiceClientHelper.CreateClient<PermissionProvider>(); | ||||||
|  |                 Tuple<Feature, Permissions>[] pmss = client.GetUserPermissions(custid, user.IID); | ||||||
|  |                 if (pmss.Length > 0) | ||||||
|  |                 { | ||||||
|  |                     Tuple<Feature, Permissions> permission = pmss.FirstOrDefault(m => m.Item1.Id == featureid); | ||||||
|  |                     if (permission != null && permission.Item2 >= per) | ||||||
|                         return true; |                         return true; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -1,331 +0,0 @@ | |||||||
| using Foresight.ServiceModel; |  | ||||||
| using IronIntel.Contractor.Users; |  | ||||||
| using IronIntel.Services; |  | ||||||
| using IronIntel.Services.CredentialObjects; |  | ||||||
| using Newtonsoft.Json; |  | ||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
| using System.Web; |  | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor.Site |  | ||||||
| { |  | ||||||
|     public class CredentialEntryBasePage : ContractorBasePage |  | ||||||
|     { |  | ||||||
|         private const string AEMP = "AEMPFLEET"; |  | ||||||
|         private const string JDAPI = "JDAPI"; |  | ||||||
|         protected void ProcessRequest(string methodName) |  | ||||||
|         { |  | ||||||
|             if (methodName != null) |  | ||||||
|             { |  | ||||||
|                 switch (methodName) |  | ||||||
|                 { |  | ||||||
|                     case "GetCredentials": |  | ||||||
|                         GetCredentials(); |  | ||||||
|                         break; |  | ||||||
|                     case "SaveCredential": |  | ||||||
|                         SaveCredential(true); |  | ||||||
|                         break; |  | ||||||
|                     case "DeleteCredential": |  | ||||||
|                         DeleteCredential(); |  | ||||||
|                         break; |  | ||||||
|                     case "GetAEMPSources": |  | ||||||
|                         GetAEMPSources(); |  | ||||||
|                         break; |  | ||||||
|                     case "GetJDLinkCredentials": |  | ||||||
|                         GetJDLinkCredentials(); |  | ||||||
|                         break; |  | ||||||
|                     case "AuthorizeRequestToken": |  | ||||||
|                         AuthorizeRequestToken(); |  | ||||||
|                         break; |  | ||||||
|                     case "FinishJDLinkOAuthRequest": |  | ||||||
|                         FinishJDLinkOAuthRequest(); |  | ||||||
|                         break; |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             Response.End(); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         protected override bool AllowCurrentLoginSessionEnter() |  | ||||||
|         { |  | ||||||
|             var f = base.AllowCurrentLoginSessionEnter(); |  | ||||||
|             if (!f) |  | ||||||
|             { |  | ||||||
|                 return false; |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             // check whether you are admin. |  | ||||||
|             var session = GetCurrentLoginSession(); |  | ||||||
|             if (session == null || session.User == null) |  | ||||||
|             { |  | ||||||
|                 return false; |  | ||||||
|             } |  | ||||||
|             var ui = UserManagement.GetUserByIID(session.User.UID); |  | ||||||
|             return ui != null && ui.UserType >= UserTypes.Admin; |  | ||||||
|         }         |  | ||||||
|  |  | ||||||
|         private void GetCredentials() |  | ||||||
|         { |  | ||||||
|             string type = Request.Form["ClientData"]; |  | ||||||
|             string creType = ""; |  | ||||||
|             switch (type) |  | ||||||
|             { |  | ||||||
|                 case "AEMP": |  | ||||||
|                     creType = AEMP; |  | ||||||
|                     break; |  | ||||||
|             } |  | ||||||
|             CredentialManagementClient crd = SystemParams.GetServiceClient<CredentialManagementClient>(); |  | ||||||
|             CredentialInfo[] creInfos = crd.GetCredentialByCompanyID(SystemParams.CompanyID, creType); |  | ||||||
|  |  | ||||||
|             List<CredentialObj> creObjs = new List<CredentialObj>(); |  | ||||||
|             foreach (var cre in creInfos) |  | ||||||
|             { |  | ||||||
|                 creObjs.Add(ConvertFromAEMP(cre)); |  | ||||||
|             } |  | ||||||
|             var items = creObjs.OrderBy((c) => c.UserName).ToArray(); |  | ||||||
|             string json = JsonConvert.SerializeObject(items); |  | ||||||
|             Response.Write(json); |  | ||||||
|             Response.End(); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private void SaveCredential(bool adduser) |  | ||||||
|         { |  | ||||||
|             var content = Request.Form["ClientData"]; |  | ||||||
|             content = HttpUtility.HtmlDecode(content); |  | ||||||
|             var item = JsonConvert.DeserializeObject<CredentialObj>(content); |  | ||||||
|  |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 if (string.IsNullOrEmpty(item.ID)) |  | ||||||
|                     item.ID = Guid.NewGuid().ToString(); |  | ||||||
|                 CredentialInfo creInfo = null; |  | ||||||
|                 switch (item.CredentialType) |  | ||||||
|                 { |  | ||||||
|                     case "AEMP": |  | ||||||
|                         creInfo = ConvertToAEMP(item); |  | ||||||
|                         break; |  | ||||||
|                 } |  | ||||||
|                 if (creInfo != null) |  | ||||||
|                 { |  | ||||||
|                     CredentialManagementClient crd = SystemParams.GetServiceClient<CredentialManagementClient>(); |  | ||||||
|                     crd.UpdateCredential(creInfo); |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             catch (Exception ex) |  | ||||||
|             { |  | ||||||
|                 Response.Write(JsonConvert.SerializeObject(ex.Message)); |  | ||||||
|                 return; |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             Response.Write("\"OK\""); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private void DeleteCredential() |  | ||||||
|         { |  | ||||||
|             var iid = Request.Form["ClientData"]; |  | ||||||
|             Guid guid; |  | ||||||
|             if (!Guid.TryParse(iid, out guid)) |  | ||||||
|             { |  | ||||||
|                 throw new ArgumentException("Credential IID is not valid."); |  | ||||||
|             } |  | ||||||
|             CredentialManagementClient crd = SystemParams.GetServiceClient<CredentialManagementClient>(); |  | ||||||
|             crd.DeleteCredential(iid); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private void GetAEMPSources() |  | ||||||
|         { |  | ||||||
|             IronSysServiceClient ic = SystemParams.GetIronSystemServiceClient(); |  | ||||||
|             AEMPSourceInfo[] sources = ic.GetAEMPSourceInfo(); |  | ||||||
|  |  | ||||||
|             List<AEMPSourceItem> list = new List<AEMPSourceItem>(); |  | ||||||
|             foreach (var source in sources) |  | ||||||
|             { |  | ||||||
|                 AEMPSourceItem item = new AEMPSourceItem(); |  | ||||||
|                 Helper.CloneProperty(item, source); |  | ||||||
|                 list.Add(item); |  | ||||||
|             } |  | ||||||
|             var items = list.OrderBy((c) => c.ManufactureName).ToArray(); |  | ||||||
|             string json = JsonConvert.SerializeObject(items); |  | ||||||
|             Response.Write(json); |  | ||||||
|             Response.End(); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         #region AEMP |  | ||||||
|  |  | ||||||
|         private CredentialObj ConvertFromAEMP(CredentialInfo cre) |  | ||||||
|         { |  | ||||||
|             CredentialObj result = new CredentialObj(); |  | ||||||
|             result.ID = cre.ID; |  | ||||||
|             result.CredentialType = cre.CredentialType; |  | ||||||
|  |  | ||||||
|             AEMPCredential aemp = new AEMPCredential(); |  | ||||||
|             aemp.FillFromXml(cre.Credential); |  | ||||||
|             if (aemp != null) |  | ||||||
|             { |  | ||||||
|                 result.Manufacture = aemp.ManufactureID; |  | ||||||
|                 result.UserName = aemp.UserName; |  | ||||||
|                 result.Password = aemp.Password; |  | ||||||
|                 result.Enabled = aemp.Enabled; |  | ||||||
|                 result.UrlKey = aemp.UrlKey; |  | ||||||
|                 result.OrgnizationID = aemp.OrgnizationID; |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             return result; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private CredentialInfo ConvertToAEMP(CredentialObj cre) |  | ||||||
|         { |  | ||||||
|             CredentialInfo result = new CredentialInfo(); |  | ||||||
|             result.ID = cre.ID; |  | ||||||
|             result.CredentialType = AEMP; |  | ||||||
|             result.CompanyID = SystemParams.CompanyID; |  | ||||||
|  |  | ||||||
|             AEMPCredential aemp = new AEMPCredential(); |  | ||||||
|             aemp.ManufactureID = cre.Manufacture; |  | ||||||
|             aemp.UserName = cre.UserName; |  | ||||||
|             aemp.Password = cre.Password; |  | ||||||
|             aemp.Enabled = cre.Enabled; |  | ||||||
|             aemp.UrlKey = cre.UrlKey; |  | ||||||
|             aemp.OrgnizationID = cre.OrgnizationID; |  | ||||||
|  |  | ||||||
|             result.Credential = aemp.ToString(); |  | ||||||
|  |  | ||||||
|             return result; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         #endregion |  | ||||||
|  |  | ||||||
|         #region JDLink credential |  | ||||||
|         private void GetJDLinkCredentials() |  | ||||||
|         { |  | ||||||
|             CredentialManagementClient client = SystemParams.GetServiceClient<CredentialManagementClient>(); |  | ||||||
|             JDCredential[] jds = client.GetJDLinkCredentials(SystemParams.CompanyID); |  | ||||||
|             List<JDCredentialObj> list = new List<JDCredentialObj>(); |  | ||||||
|             foreach (var jd in jds) |  | ||||||
|             { |  | ||||||
|                 JDCredentialObj item = new JDCredentialObj(); |  | ||||||
|                 item.ID = jd.ID; |  | ||||||
|                 item.UserName = jd.Credential.UserName; |  | ||||||
|                 item.ExpirationDateUtc = jd.Credential.ExpirationDateUtc; |  | ||||||
|                 item.ConsumerKey = jd.Credential.ConsumerKey; |  | ||||||
|                 item.AuthorityUrl = jd.Credential.AuthorityUrl; |  | ||||||
|                 list.Add(item); |  | ||||||
|             } |  | ||||||
|             var items = list.OrderBy(m => m.UserName).ToArray(); |  | ||||||
|             string json = JsonConvert.SerializeObject(items); |  | ||||||
|             Response.Write(json); |  | ||||||
|             Response.End(); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private void AuthorizeRequestToken() |  | ||||||
|         { |  | ||||||
|             string username = Request.Form["ClientData"]; |  | ||||||
|             username = HttpUtility.HtmlDecode(username); |  | ||||||
|             CredentialManagementClient client = SystemParams.GetServiceClient<CredentialManagementClient>(); |  | ||||||
|             JDCredential[] jds = client.GetJDLinkCredentials(SystemParams.CompanyID); |  | ||||||
|             JDCredential jd = jds.FirstOrDefault(m => m.Credential.UserName == username); |  | ||||||
|             if (jd != null) |  | ||||||
|             { |  | ||||||
|                 Response.Write(JsonConvert.SerializeObject("User name already exists.")); |  | ||||||
|                 Response.End(); |  | ||||||
|             } |  | ||||||
|             StringKeyValue kv = GetJDLinkApiKey(); |  | ||||||
|             if (kv == null) |  | ||||||
|             { |  | ||||||
|                 Response.Write(JsonConvert.SerializeObject("The JDLink Key does not exist,Please contact the administrator.")); |  | ||||||
|                 Response.End(); |  | ||||||
|             } |  | ||||||
|             JDOAuthData data = client.GetJDLinkAuthorizeRequestOAuth(kv.Key, kv.Value); |  | ||||||
|             string json = JsonConvert.SerializeObject(data); |  | ||||||
|             Response.Write(json); |  | ||||||
|             Response.End(); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         public void FinishJDLinkOAuthRequest() |  | ||||||
|         { |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 var clientdata = Request.Form["ClientData"].Split((char)170); |  | ||||||
|                 var authordata = HttpUtility.HtmlDecode(clientdata[0]); |  | ||||||
|                 string virifier = HttpUtility.HtmlDecode(clientdata[1]); |  | ||||||
|  |  | ||||||
|                 JDOAuthData oriauthdata = JsonConvert.DeserializeObject<JDOAuthData>(authordata); |  | ||||||
|                 CredentialManagementClient client = SystemParams.GetServiceClient<CredentialManagementClient>(); |  | ||||||
|                 JDOAuthData data = client.FinishJDLinkOAuthRequest(oriauthdata, virifier); |  | ||||||
|                 CredentialInfo ci = new CredentialInfo(); |  | ||||||
|                 ci.ID = Guid.NewGuid().ToString().ToUpper(); |  | ||||||
|                 ci.CompanyID = SystemParams.CompanyID; |  | ||||||
|                 ci.CredentialType = "JDLINK"; |  | ||||||
|                 JDCredential jd = new JDCredential(); |  | ||||||
|                 jd.Credential = data; |  | ||||||
|                 jd.Enabled = true; |  | ||||||
|                 ci.Credential = jd.ToString(); |  | ||||||
|                 client.UpdateCredential(ci); |  | ||||||
|             } |  | ||||||
|             catch (Exception ex) |  | ||||||
|             { |  | ||||||
|                 Response.Write(JsonConvert.SerializeObject(ex.Message)); |  | ||||||
|                 return; |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             Response.Write("\"OK\""); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private StringKeyValue GetJDLinkApiKey() |  | ||||||
|         { |  | ||||||
|             string key = SystemParams.GetStringParam("JDAPIConsumerKey"); |  | ||||||
|             if (string.IsNullOrWhiteSpace(key)) |  | ||||||
|             { |  | ||||||
|                 return null; |  | ||||||
|             } |  | ||||||
|             string sec = SystemParams.GetStringParam("JDAPIConsumerSecret"); |  | ||||||
|             if (string.IsNullOrWhiteSpace(sec)) |  | ||||||
|             { |  | ||||||
|                 return null; |  | ||||||
|             } |  | ||||||
|             StringKeyValue kv = new StringKeyValue(); |  | ||||||
|             kv.Key = key; |  | ||||||
|             kv.Value = sec; |  | ||||||
|             return kv; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         #endregion |  | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// 用于传输的临时Credential类 |  | ||||||
|         /// </summary> |  | ||||||
|         public class CredentialObj |  | ||||||
|         { |  | ||||||
|             public string ID { get; set; } |  | ||||||
|             public string CredentialType { get; set; } |  | ||||||
|             public string Manufacture { get; set; } |  | ||||||
|             public string UrlKey { get; set; } |  | ||||||
|             public string UserName { get; set; } |  | ||||||
|             public string Password { get; set; } |  | ||||||
|             public bool Enabled { get; set; } |  | ||||||
|             public string OrgnizationID { get; set; } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         public class AEMPSourceItem |  | ||||||
|         { |  | ||||||
|             public string ManufactureID { get; set; } |  | ||||||
|             public string ManufactureName { get; set; } |  | ||||||
|             public string FleetUrl { get; set; } |  | ||||||
|             public string AutoServiceClass { get; set; } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         public class JDCredentialObj |  | ||||||
|         { |  | ||||||
|             public string ID { get; set; } |  | ||||||
|             public string UserName { get; set; } |  | ||||||
|             public string ConsumerKey { get; set; } |  | ||||||
|             public string AuthorityUrl { get; set; } |  | ||||||
|             public DateTime ExpirationDateUtc { get; set; } |  | ||||||
|             public string ExpirationDateUtcStr { get { return ExpirationDateUtc == DateTime.MinValue ? "" : ExpirationDateUtc.ToShortDateString(); } } |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -0,0 +1,424 @@ | |||||||
|  | using FI.FIC.Contracts.DataObjects.BaseObject; | ||||||
|  | using Foresight.Fleet.Services.Credentials; | ||||||
|  | using Foresight.Fleet.Services.Credentials.JDAPI; | ||||||
|  | using Foresight.Service.Credential.Common; | ||||||
|  | using Foresight.Service.Credential.JDAPI; | ||||||
|  | using Foresight.ServiceModel; | ||||||
|  | using IronIntel.Contractor.Users; | ||||||
|  | using Newtonsoft.Json; | ||||||
|  | using System; | ||||||
|  | using System.Collections.Generic; | ||||||
|  | using System.Linq; | ||||||
|  | using System.Text; | ||||||
|  | using System.Threading.Tasks; | ||||||
|  | using System.Web; | ||||||
|  |  | ||||||
|  | namespace IronIntel.Contractor.Site.Credentials | ||||||
|  | { | ||||||
|  |     public class CredentialEntryBasePage : ContractorBasePage | ||||||
|  |     { | ||||||
|  |         private const string AEMP = "AEMPFLEET"; | ||||||
|  |         private const string JDAPI = "JDAPI"; | ||||||
|  |         protected void ProcessRequest(string methodName) | ||||||
|  |         { | ||||||
|  |             if (methodName != null) | ||||||
|  |             { | ||||||
|  |                 switch (methodName) | ||||||
|  |                 { | ||||||
|  |                     case "GetAEMPCredentials": | ||||||
|  |                         GetAEMPCredentials(); | ||||||
|  |                         break; | ||||||
|  |                     case "UpdateAEMPCredential": | ||||||
|  |                         UpdateAEMPCredential(); | ||||||
|  |                         break; | ||||||
|  |                     case "DeleteAEMPCredential": | ||||||
|  |                         DeleteAEMPCredential(); | ||||||
|  |                         break; | ||||||
|  |                     case "DeleteToken": | ||||||
|  |                         DeleteToken(); | ||||||
|  |                         break; | ||||||
|  |                     case "GetJDLinkTokenItems": | ||||||
|  |                         GetJDLinkTokenItems(); | ||||||
|  |                         break; | ||||||
|  |                     case "CreateJDLinkAuthUrl": | ||||||
|  |                         CreateJDLinkAuthUrl(); | ||||||
|  |                         break; | ||||||
|  |                     case "GetAPIDictionaries": | ||||||
|  |                         GetAPIDictionaries(); | ||||||
|  |                         break; | ||||||
|  |                     case "GetAPICredentialDefs": | ||||||
|  |                         GetAPICredentialDefs(); | ||||||
|  |                         break; | ||||||
|  |                     case "UpdateApiCredentialDefs": | ||||||
|  |                         UpdateApiCredentialDefs(); | ||||||
|  |                         break; | ||||||
|  |                     case "DeleteApiCredential": | ||||||
|  |                         DeleteApiCredential(); | ||||||
|  |                         break; | ||||||
|  |                     case "GetNotificationSubscriptions": | ||||||
|  |                         GetNotificationSubscriptions(); | ||||||
|  |                         break; | ||||||
|  |                     case "CreateJDSubPubAuthUrl": | ||||||
|  |                         CreateJDSubPubAuthUrl(); | ||||||
|  |                         break; | ||||||
|  |                     case "DeleteNotificationSubscription": | ||||||
|  |                         DeleteNotificationSubscription(); | ||||||
|  |                         break; | ||||||
|  |                     case "GetMyJDAPITokenItems": | ||||||
|  |                         GetMyJDAPITokenItems(); | ||||||
|  |                         break; | ||||||
|  |                     case "CreateMyJDAPIAuthUrl": | ||||||
|  |                         CreateMyJDAPIAuthUrl(); | ||||||
|  |                         break; | ||||||
|  |                     case "GetOrganizations": | ||||||
|  |                         GetOrganizations(); | ||||||
|  |                         break; | ||||||
|  |                     case "GetJDOrganizationUrl": | ||||||
|  |                         GetJDOrganizationUrl(); | ||||||
|  |                         break; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         protected override bool AllowCurrentLoginSessionEnter() | ||||||
|  |         { | ||||||
|  |             var f = base.AllowCurrentLoginSessionEnter(); | ||||||
|  |             if (!f) | ||||||
|  |             { | ||||||
|  |                 return false; | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             // check whether you are admin. | ||||||
|  |             var session = GetCurrentLoginSession(); | ||||||
|  |             if (session == null || session.User == null) | ||||||
|  |             { | ||||||
|  |                 return false; | ||||||
|  |             } | ||||||
|  |             var ui = UserManagement.GetUserByIID(session.User.UID); | ||||||
|  |             return ui != null && ui.UserType >= UserTypes.Admin; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         #region  AEMP credential | ||||||
|  |         private void GetAEMPCredentials() | ||||||
|  |         { | ||||||
|  |             CredentialProvider crd = FleetServiceClientHelper.CreateClient<CredentialProvider>(); | ||||||
|  |             AEMPInfo[] items = crd.GetAEMPCredentials(SystemParams.CompanyID); | ||||||
|  |             if (items == null) | ||||||
|  |                 items = new AEMPInfo[0]; | ||||||
|  |  | ||||||
|  |             items = items.OrderBy((c) => c.UserName).ToArray(); | ||||||
|  |             string json = JsonConvert.SerializeObject(items); | ||||||
|  |             Response.Write(json); | ||||||
|  |             Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void UpdateAEMPCredential() | ||||||
|  |         { | ||||||
|  |             var content = Request.Form["ClientData"]; | ||||||
|  |             content = HttpUtility.HtmlDecode(content); | ||||||
|  |             var aempinfo = JsonConvert.DeserializeObject<AEMPInfo>(content); | ||||||
|  |  | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 if (string.IsNullOrEmpty(aempinfo.ID)) | ||||||
|  |                     aempinfo.ID = Guid.NewGuid().ToString(); | ||||||
|  |  | ||||||
|  |                 CredentialProvider crd = FleetServiceClientHelper.CreateClient<CredentialProvider>(); | ||||||
|  |                 crd.UpdateAEMPCredential(SystemParams.CompanyID, aempinfo); | ||||||
|  |  | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 Response.Write(JsonConvert.SerializeObject(ex.Message)); | ||||||
|  |                 return; | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             Response.Write("\"OK\""); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void DeleteAEMPCredential() | ||||||
|  |         { | ||||||
|  |             var iid = Request.Form["ClientData"]; | ||||||
|  |             Guid guid; | ||||||
|  |             if (!Guid.TryParse(iid, out guid)) | ||||||
|  |             { | ||||||
|  |                 throw new ArgumentException("Credential IID is not valid."); | ||||||
|  |             } | ||||||
|  |             CredentialProvider crd = FleetServiceClientHelper.CreateClient<CredentialProvider>(); | ||||||
|  |             crd.DeleteAEMPCredential(SystemParams.CompanyID, iid); | ||||||
|  |  | ||||||
|  |             Response.Write("\"OK\""); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         #endregion | ||||||
|  |  | ||||||
|  |         #region JDLink credential | ||||||
|  |         private void GetJDLinkTokenItems() | ||||||
|  |         { | ||||||
|  |             var user = GetCurrentLoginSession().User; | ||||||
|  |             JDAPICredentialProvider client = FleetServiceClientHelper.CreateClient<JDAPICredentialProvider>(); | ||||||
|  |             AuthTokenItem[] items = client.GetJDLinkTokenItems(SystemParams.CompanyID); | ||||||
|  |             List<AuthTokenInfo> ls = new List<AuthTokenInfo>(); | ||||||
|  |             if (items != null && items.Length > 0) | ||||||
|  |             { | ||||||
|  |                 foreach (AuthTokenItem item in items) | ||||||
|  |                 { | ||||||
|  |                     AuthTokenInfo ai = new AuthTokenInfo(); | ||||||
|  |                     Helper.CloneProperty(ai, item); | ||||||
|  |                     ai.RequestTime = SystemParams.ConvertToUserTimeFromUtc(user, item.RequestTimeUtc); | ||||||
|  |                     ls.Add(ai); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             string json = JsonConvert.SerializeObject(ls); | ||||||
|  |             Response.Write(json); | ||||||
|  |             Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void CreateJDLinkAuthUrl() | ||||||
|  |         { | ||||||
|  |             string absuri = Request.Url.AbsoluteUri; | ||||||
|  |             string url = absuri.Substring(0, absuri.LastIndexOf('/')); | ||||||
|  |             string redirecturl = url + "/Credentials.aspx?isjdlink=true"; | ||||||
|  |  | ||||||
|  |             JDAPICredentialProvider client = FleetServiceClientHelper.CreateClient<JDAPICredentialProvider>(); | ||||||
|  |             string result = client.CreateJDLinkAuthUrl(SystemParams.CompanyID, redirecturl); | ||||||
|  |  | ||||||
|  |             string json = JsonConvert.SerializeObject(result); | ||||||
|  |             Response.Write(json); | ||||||
|  |             Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void DeleteToken() | ||||||
|  |         { | ||||||
|  |             var iid = Request.Form["ClientData"]; | ||||||
|  |             JDAPICredentialProvider client = FleetServiceClientHelper.CreateClient<JDAPICredentialProvider>(); | ||||||
|  |             client.DeleteToken(SystemParams.CompanyID, iid, GetCurrentUser().IID, string.Empty); | ||||||
|  |  | ||||||
|  |             Response.Write("\"OK\""); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         #endregion | ||||||
|  |  | ||||||
|  |         #region MyJohnDeere | ||||||
|  |         private void GetMyJDAPITokenItems() | ||||||
|  |         { | ||||||
|  |             var user = GetCurrentLoginSession().User; | ||||||
|  |             JDAPICredentialProvider client = FleetServiceClientHelper.CreateClient<JDAPICredentialProvider>(); | ||||||
|  |             AuthTokenItem[] items = client.GetMyJDAPITokenItems(SystemParams.CompanyID); | ||||||
|  |             List<AuthTokenInfo> ls = new List<AuthTokenInfo>(); | ||||||
|  |             if (items != null && items.Length > 0) | ||||||
|  |             { | ||||||
|  |                 foreach (AuthTokenItem item in items) | ||||||
|  |                 { | ||||||
|  |                     AuthTokenInfo ai = new AuthTokenInfo(); | ||||||
|  |                     Helper.CloneProperty(ai, item); | ||||||
|  |                     ai.RequestTime = SystemParams.ConvertToUserTimeFromUtc(user, item.RequestTimeUtc); | ||||||
|  |                     ls.Add(ai); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             string json = JsonConvert.SerializeObject(ls); | ||||||
|  |             Response.Write(json); | ||||||
|  |             Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void CreateMyJDAPIAuthUrl() | ||||||
|  |         { | ||||||
|  |             string absuri = Request.Url.AbsoluteUri; | ||||||
|  |             string url = absuri.Substring(0, absuri.LastIndexOf('/')); | ||||||
|  |             string redirecturl = url + "/Credentials.aspx?ismyjd=true"; | ||||||
|  |  | ||||||
|  |             JDAPICredentialProvider client = FleetServiceClientHelper.CreateClient<JDAPICredentialProvider>(); | ||||||
|  |             string result = client.CreateMyJDAPIAuthUrl(SystemParams.CompanyID, redirecturl); | ||||||
|  |  | ||||||
|  |             string json = JsonConvert.SerializeObject(result); | ||||||
|  |             Response.Write(json); | ||||||
|  |             Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         #endregion | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         #region JDNotification credential | ||||||
|  |  | ||||||
|  |         private void GetNotificationSubscriptions() | ||||||
|  |         { | ||||||
|  |             var user = GetCurrentLoginSession().User; | ||||||
|  |             JDAPICredentialProvider client = FleetServiceClientHelper.CreateClient<JDAPICredentialProvider>(); | ||||||
|  |             SubscriptionItem[] items = client.GetNotificationSubscriptions(SystemParams.CompanyID); | ||||||
|  |             List<SubscriptionInfo> ls = new List<SubscriptionInfo>(); | ||||||
|  |             if (items != null && items.Length > 0) | ||||||
|  |             { | ||||||
|  |                 foreach (SubscriptionItem item in items) | ||||||
|  |                 { | ||||||
|  |                     SubscriptionInfo ai = new SubscriptionInfo(); | ||||||
|  |                     Helper.CloneProperty(ai, item); | ||||||
|  |                     ai.CreateTime = SystemParams.ConvertToUserTimeFromUtc(user, item.CreateTimeUtc); | ||||||
|  |                     ls.Add(ai); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             string json = JsonConvert.SerializeObject(ls); | ||||||
|  |             Response.Write(json); | ||||||
|  |             Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void CreateJDSubPubAuthUrl() | ||||||
|  |         { | ||||||
|  |             var name = Request.Form["ClientData"]; | ||||||
|  |             string absuri = Request.Url.AbsoluteUri; | ||||||
|  |             string url = absuri.Substring(0, absuri.LastIndexOf('/')); | ||||||
|  |             string redirecturl = url + "/Credentials.aspx?isjdsub=true"; | ||||||
|  |  | ||||||
|  |             JDAPICredentialProvider client = FleetServiceClientHelper.CreateClient<JDAPICredentialProvider>(); | ||||||
|  |             string result = client.CreateJDSubPubAuthUrl(SystemParams.CompanyID, redirecturl, name); | ||||||
|  |  | ||||||
|  |             string json = JsonConvert.SerializeObject(result); | ||||||
|  |             Response.Write(json); | ||||||
|  |             Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void DeleteNotificationSubscription() | ||||||
|  |         { | ||||||
|  |             var iid = Request.Form["ClientData"]; | ||||||
|  |             JDAPICredentialProvider client = FleetServiceClientHelper.CreateClient<JDAPICredentialProvider>(); | ||||||
|  |             client.DeleteNotificationSubscription(SystemParams.CompanyID, iid); | ||||||
|  |  | ||||||
|  |             Response.Write("\"OK\""); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         #endregion | ||||||
|  |  | ||||||
|  |         #region API Credential | ||||||
|  |  | ||||||
|  |         private void GetAPIDictionaries() | ||||||
|  |         { | ||||||
|  |             CredentialProvider crd = FleetServiceClientHelper.CreateClient<CredentialProvider>(); | ||||||
|  |             APIDictionary[] items = crd.GetAPIDictionaries(SystemParams.CompanyID); | ||||||
|  |             items = items.Where(m => m.IsEnabled == true).ToArray(); | ||||||
|  |             string json = JsonConvert.SerializeObject(items); | ||||||
|  |             Response.Write(json); | ||||||
|  |             Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void GetAPICredentialDefs() | ||||||
|  |         { | ||||||
|  |             CredentialProvider crd = FleetServiceClientHelper.CreateClient<CredentialProvider>(); | ||||||
|  |             APICredentialDef[] items = crd.GetAPICredentialDefs(SystemParams.CompanyID); | ||||||
|  |             string json = JsonConvert.SerializeObject(items); | ||||||
|  |             Response.Write(json); | ||||||
|  |             Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void UpdateApiCredentialDefs() | ||||||
|  |         { | ||||||
|  |             var content = Request.Form["ClientData"]; | ||||||
|  |             content = HttpUtility.HtmlDecode(content); | ||||||
|  |             var item = JsonConvert.DeserializeObject<APICredentialDef>(content); | ||||||
|  |  | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 CredentialProvider crd = FleetServiceClientHelper.CreateClient<CredentialProvider>(); | ||||||
|  |                 crd.UpdateApiCredentialDefs(SystemParams.CompanyID, item, GetCurrentUser().IID); | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 Response.Write(JsonConvert.SerializeObject(ex.Message)); | ||||||
|  |                 return; | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             Response.Write("\"OK\""); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void DeleteApiCredential() | ||||||
|  |         { | ||||||
|  |             var id = Request.Form["ClientData"]; | ||||||
|  |             CredentialProvider crd = FleetServiceClientHelper.CreateClient<CredentialProvider>(); | ||||||
|  |             crd.DeleteApiCredential(SystemParams.CompanyID, Convert.ToInt32(id), GetCurrentUser().IID); | ||||||
|  |  | ||||||
|  |             Response.Write("\"OK\""); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         #endregion | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         private void GetOrganizations() | ||||||
|  |         { | ||||||
|  |             var iid = Request.Form["ClientData"]; | ||||||
|  |             JDAPICredentialProvider client = FleetServiceClientHelper.CreateClient<JDAPICredentialProvider>(); | ||||||
|  |             JDOrganizationInfo[] items = client.GetOrganizations(SystemParams.CompanyID, iid); | ||||||
|  |             if (items == null) | ||||||
|  |                 items = new JDOrganizationInfo[0]; | ||||||
|  |  | ||||||
|  |             string json = JsonConvert.SerializeObject(items); | ||||||
|  |             Response.Write(json); | ||||||
|  |             Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void GetJDOrganizationUrl() | ||||||
|  |         { | ||||||
|  |             var iid = Request.Form["ClientData"]; | ||||||
|  |             JDAPICredentialProvider client = FleetServiceClientHelper.CreateClient<JDAPICredentialProvider>(); | ||||||
|  |             string url = client.GetJDOrganizationUrl(SystemParams.CompanyID, iid); | ||||||
|  |             string json = JsonConvert.SerializeObject(url); | ||||||
|  |             Response.Write(json); | ||||||
|  |             Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// 用于传输的临时Credential类 | ||||||
|  |         /// </summary> | ||||||
|  |         public class CredentialObj | ||||||
|  |         { | ||||||
|  |             public string ID { get; set; } | ||||||
|  |             public string CredentialType { get; set; } | ||||||
|  |             public string Manufacture { get; set; } | ||||||
|  |             public string UrlKey { get; set; } | ||||||
|  |             public string UserName { get; set; } | ||||||
|  |             public string Password { get; set; } | ||||||
|  |             public bool Enabled { get; set; } | ||||||
|  |             public string OrgnizationID { get; set; } | ||||||
|  |             public string Notes { get; set; } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         public class AEMPSourceItem | ||||||
|  |         { | ||||||
|  |             public string ManufactureID { get; set; } | ||||||
|  |             public string ManufactureName { get; set; } | ||||||
|  |             public string FleetUrl { get; set; } | ||||||
|  |             public string AutoServiceClass { get; set; } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         public class JDCredentialObj | ||||||
|  |         { | ||||||
|  |             public string ID { get; set; } | ||||||
|  |             public string UserName { get; set; } | ||||||
|  |             public string ConsumerKey { get; set; } | ||||||
|  |             public string AuthorityUrl { get; set; } | ||||||
|  |             public DateTime ExpirationDateUtc { get; set; } | ||||||
|  |             public string ExpirationDateUtcStr { get { return ExpirationDateUtc == DateTime.MinValue ? "" : ExpirationDateUtc.ToShortDateString(); } } | ||||||
|  |         } | ||||||
|  |         public class JDNotifySubItem | ||||||
|  |         { | ||||||
|  |             public string ID { get; set; } | ||||||
|  |             public string UserName { get; set; } | ||||||
|  |             public string DisplayName { get; set; } | ||||||
|  |             public DateTime ExpireDate { get; set; } | ||||||
|  |             public string ExpireDateStr { get { return ExpireDate == DateTime.MinValue ? "" : ExpireDate.ToShortDateString(); } } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         public class AuthTokenInfo : AuthTokenItem | ||||||
|  |         { | ||||||
|  |             public DateTime RequestTime { get; set; } | ||||||
|  |             public string RequestTimeStr { get { return RequestTime == DateTime.MinValue ? "" : RequestTime.ToString(); } } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         public class SubscriptionInfo : SubscriptionItem | ||||||
|  |         { | ||||||
|  |             public DateTime CreateTime { get; set; } | ||||||
|  |             public string CreateTimeStr { get { return CreateTime == DateTime.MinValue ? "" : CreateTime.ToString(); } } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -0,0 +1,84 @@ | |||||||
|  | using Foresight.Fleet.Services.Customer; | ||||||
|  | using Foresight.Fleet.Services.User; | ||||||
|  | using IronIntel.Contractor.Users; | ||||||
|  | using Newtonsoft.Json; | ||||||
|  | using System; | ||||||
|  | using System.Collections.Generic; | ||||||
|  | using System.Linq; | ||||||
|  | using System.Text; | ||||||
|  | using System.Threading.Tasks; | ||||||
|  |  | ||||||
|  | namespace IronIntel.Contractor.Site.Credentials | ||||||
|  | { | ||||||
|  |     public class CredentialsBasePage : ContractorBasePage | ||||||
|  |     { | ||||||
|  |         protected void ProcessRequest(string methodName) | ||||||
|  |         { | ||||||
|  |             object result = null; | ||||||
|  |  | ||||||
|  |             if (methodName != null) | ||||||
|  |             { | ||||||
|  |                 switch (methodName.ToUpper()) | ||||||
|  |                 { | ||||||
|  |                     case "GETNAVS": | ||||||
|  |                         result = GetNavigations(); | ||||||
|  |                         break; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             string json = JsonConvert.SerializeObject(result); | ||||||
|  |             Response.Write(json); | ||||||
|  |             Response.End(); | ||||||
|  |         } | ||||||
|  |         private CredentialNavigateItem[] GetNavigations() | ||||||
|  |         { | ||||||
|  |             List<CredentialNavigateItem> list = GetNavigateItems(); | ||||||
|  |             LicenseInfo license = SystemParams.GetLicense(); | ||||||
|  |             if (license != null && license.Items.Count > 0) | ||||||
|  |             { | ||||||
|  |                 var jdn = license.Items.FirstOrDefault(m => m.Key == "JohnDeereNotifications"); | ||||||
|  |                 if (jdn == null || !Helper.IsTrue(jdn.Value)) | ||||||
|  |                 { | ||||||
|  |                     CredentialNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_jdnotification"); | ||||||
|  |                     list.Remove(item); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             return list.ToArray(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         public static List<CredentialNavigateItem> GetNavigateItems() | ||||||
|  |         { | ||||||
|  |             List<CredentialNavigateItem> list = new List<CredentialNavigateItem>(); | ||||||
|  |  | ||||||
|  |             CredentialNavigateItem item1 = new CredentialNavigateItem(); | ||||||
|  |             item1.ID = "nav_credential"; | ||||||
|  |             item1.Title = "Credentials"; | ||||||
|  |             item1.Url = "ManageCredential.aspx"; | ||||||
|  |             item1.IconPath = "img/credential.png"; | ||||||
|  |             list.Add(item1); | ||||||
|  |  | ||||||
|  |             CredentialNavigateItem item2 = new CredentialNavigateItem(); | ||||||
|  |             item2.ID = "nav_jdlink"; | ||||||
|  |             item2.Title = "JD Link"; | ||||||
|  |             item2.Url = "ManageJDLink.aspx"; | ||||||
|  |             item2.IconPath = "img/jdlink.png"; | ||||||
|  |             list.Add(item2); | ||||||
|  |  | ||||||
|  |             //CredentialNavigateItem item3 = new CredentialNavigateItem(); | ||||||
|  |             //item3.ID = "nav_jdnotification"; | ||||||
|  |             //item3.Title = "JohnDeere Notifications"; | ||||||
|  |             //item3.Url = "ManageJDNotifications.aspx"; | ||||||
|  |             //item3.IconPath = "img/jdnotifications.png"; | ||||||
|  |             //list.Add(item3); | ||||||
|  |  | ||||||
|  |             CredentialNavigateItem item4 = new CredentialNavigateItem(); | ||||||
|  |             item4.ID = "nav_apicredential"; | ||||||
|  |             item4.Title = "API Credentials"; | ||||||
|  |             item4.Url = "ManageAPICredential.aspx"; | ||||||
|  |             item4.IconPath = "img/apicredential.png"; | ||||||
|  |             list.Add(item4); | ||||||
|  |             return list; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										594
									
								
								IronIntelContractorSiteLib/Customer/CustomerRecordBasePage.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										594
									
								
								IronIntelContractorSiteLib/Customer/CustomerRecordBasePage.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,594 @@ | |||||||
|  | using Foresight.Fleet.Services.JobSite; | ||||||
|  | using Newtonsoft.Json; | ||||||
|  | using System; | ||||||
|  | using System.Collections.Generic; | ||||||
|  | using System.Data; | ||||||
|  | using System.Linq; | ||||||
|  | using System.Text; | ||||||
|  | using System.Threading.Tasks; | ||||||
|  | using System.Web; | ||||||
|  | using Foresight.Fleet.Services.Partner; | ||||||
|  | using Foresight.Fleet.Services; | ||||||
|  | using IronIntel.Contractor.Users; | ||||||
|  | using Foresight.Fleet.Services.Asset; | ||||||
|  |  | ||||||
|  | namespace IronIntel.Contractor.Site.Customer | ||||||
|  | { | ||||||
|  |     public class CustomerRecordBasePage : ContractorBasePage | ||||||
|  |     { | ||||||
|  |         protected void ProcessRequest() | ||||||
|  |         { | ||||||
|  |             object result = null; | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 string methodName = Request.Params["MethodName"]; | ||||||
|  |                 if (methodName != null) | ||||||
|  |                 { | ||||||
|  |                     switch (methodName) | ||||||
|  |                     { | ||||||
|  |                         case "GetPartners": | ||||||
|  |                             result = GetPartners(); | ||||||
|  |                             break; | ||||||
|  |                         case "GetCustomerRecordInfo": | ||||||
|  |                             result = GetPartner(); | ||||||
|  |                             break; | ||||||
|  |                         case "SaveCustomerRecord": | ||||||
|  |                             result = SavePartner(); | ||||||
|  |                             break; | ||||||
|  |                         case "DeletePartner": | ||||||
|  |                             result = DeletePartner(); | ||||||
|  |                             break; | ||||||
|  |                         case "GetContacts": | ||||||
|  |                             result = GetContacts(); | ||||||
|  |                             break; | ||||||
|  |                         case "SaveContact": | ||||||
|  |                             result = SaveContact(); | ||||||
|  |                             break; | ||||||
|  |                         case "DeleteContact": | ||||||
|  |                             result = DeleteContact(); | ||||||
|  |                             break; | ||||||
|  |                         case "GetCustomerComments": | ||||||
|  |                             result = GetComments(); | ||||||
|  |                             break; | ||||||
|  |                         case "SubmitComment": | ||||||
|  |                             result = SubmitComment(); | ||||||
|  |                             break; | ||||||
|  |                         case "GetAssignedMachines": | ||||||
|  |                             result = GetAssignedMachines(); | ||||||
|  |                             break; | ||||||
|  |                         case "AssignMachines": | ||||||
|  |                             result = AssignMachines(); | ||||||
|  |                             break; | ||||||
|  |                         case "RemoveAssignedMachines": | ||||||
|  |                             result = RemoveAssignedMachines(); | ||||||
|  |                             break; | ||||||
|  |                         case "GetAssignedPartnersByMachine": | ||||||
|  |                             result = GetAssignedPartnersByMachine(); | ||||||
|  |                             break; | ||||||
|  |                         case "GetSalespersons": | ||||||
|  |                             result = GetSalespersons(); | ||||||
|  |                             break; | ||||||
|  |                         case "GetAllFollowers": | ||||||
|  |                             result = GetAllFollowers(); | ||||||
|  |                             break; | ||||||
|  |                         case "GetFollowers": | ||||||
|  |                             result = GetFollowers(); | ||||||
|  |                             break; | ||||||
|  |                         case "AddFollowers": | ||||||
|  |                             result = AddFollowers(); | ||||||
|  |                             break; | ||||||
|  |                         case "DeleteFollower": | ||||||
|  |                             result = DeleteFollower(); | ||||||
|  |                             break; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 SystemParams.WriteLog("error", "CustomerRecordBasePage", ex.Message, ex.ToString()); | ||||||
|  |                 throw ex; | ||||||
|  |             } | ||||||
|  |             string json = JsonConvert.SerializeObject(result); | ||||||
|  |             Response.Write(json); | ||||||
|  |             Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private object GetPartners() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|  |                 { | ||||||
|  |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |                     clientdata = HttpUtility.HtmlDecode(clientdata); | ||||||
|  |  | ||||||
|  |                     BusinessPartnerInfo[] partners = CreateClient<BusinessPartnerProvider>().GetPartners(SystemParams.CompanyID, clientdata); | ||||||
|  |                     return partners; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return new BusinessPartnerInfo[0]; | ||||||
|  |  | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private object GetPartner() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|  |                 { | ||||||
|  |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |                     var id = HttpUtility.HtmlDecode(clientdata); | ||||||
|  |  | ||||||
|  |                     BusinessPartnerInfo partner = CreateClient<BusinessPartnerProvider>().GetPartner(SystemParams.CompanyID, Convert.ToInt32(id)); | ||||||
|  |                     if (partner == null) | ||||||
|  |                         return new BusinessPartnerInfo(); | ||||||
|  |  | ||||||
|  |                     return partner; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return new BusinessPartnerInfo(); | ||||||
|  |  | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         private object GetAssignedPartnersByMachine() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|  |                 { | ||||||
|  |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |                     var assetid = HttpUtility.HtmlDecode(clientdata); | ||||||
|  |  | ||||||
|  |                     BusinessPartnerInfo[] partners = CreateClient<BusinessPartnerProvider>().GetAssignedPartnersByMachine(SystemParams.CompanyID, Convert.ToInt64(assetid)); | ||||||
|  |                     return partners; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return new BusinessPartnerInfo[0]; | ||||||
|  |  | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private object SavePartner() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var user = GetCurrentUser(); | ||||||
|  |                 if (user != null) | ||||||
|  |                 { | ||||||
|  |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |                     var data = HttpUtility.HtmlDecode(clientdata); | ||||||
|  |                     BusinessPartnerInfo partner = JsonConvert.DeserializeObject<BusinessPartnerInfo>(data); | ||||||
|  |                     if (partner.Id > 0) | ||||||
|  |                         CreateClient<BusinessPartnerProvider>().UpdatePartner(SystemParams.CompanyID, partner); | ||||||
|  |                     else | ||||||
|  |                         partner.Id = CreateClient<BusinessPartnerProvider>().AddNewPartner(SystemParams.CompanyID, partner); | ||||||
|  |                     return partner.Id; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     return "Failed"; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private string DeletePartner() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var user = GetCurrentUser(); | ||||||
|  |                 if (user != null) | ||||||
|  |                 { | ||||||
|  |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |                     var id = HttpUtility.HtmlDecode(clientdata); | ||||||
|  |  | ||||||
|  |                     CreateClient<BusinessPartnerProvider>().DeletePartner(SystemParams.CompanyID, Convert.ToInt32(id)); | ||||||
|  |                     return "OK"; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     return "Failed"; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private object GetContacts() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|  |                 { | ||||||
|  |                     string custid = Request.Form["ClientData"]; | ||||||
|  |                     custid = HttpUtility.HtmlDecode(custid); | ||||||
|  |  | ||||||
|  |                     ContactInfo[] contacts = CreateClient<BusinessPartnerProvider>().GetContacts(SystemParams.CompanyID, int.Parse(custid)); | ||||||
|  |                     if (contacts == null || contacts.Length == 0) | ||||||
|  |                         return new ContactInfo[0]; | ||||||
|  |  | ||||||
|  |                     var lang = GetLanguageCookie(); | ||||||
|  |                     List<ContactInfoClient> ls = new List<ContactInfoClient>(); | ||||||
|  |                     foreach (var pa in contacts) | ||||||
|  |                     { | ||||||
|  |                         ContactInfoClient item = new ContactInfoClient(); | ||||||
|  |                         Helper.CloneProperty(item, pa); | ||||||
|  |                         if ((int)item.ContactPreference == 0) | ||||||
|  |                             item.ContactPreferenceStr = SystemParams.GetTextByKey(lang, "P_CR_TEXT", "Text"); | ||||||
|  |                         else if ((int)item.ContactPreference == 1) | ||||||
|  |                             item.ContactPreferenceStr = SystemParams.GetTextByKey(lang, "P_CR_EMAIL", "Email"); | ||||||
|  |                         else if ((int)item.ContactPreference == 2) | ||||||
|  |                             item.ContactPreferenceStr = SystemParams.GetTextByKey(lang, "P_CR_PHONE", "Phone"); | ||||||
|  |                         ls.Add(item); | ||||||
|  |                     } | ||||||
|  |                     return ls.ToArray(); ; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return new ContactInfoClient[0]; | ||||||
|  |  | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         private object SaveContact() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var user = GetCurrentUser(); | ||||||
|  |                 if (user != null) | ||||||
|  |                 { | ||||||
|  |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |                     string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata); | ||||||
|  |                     int custid = int.Parse(ps[0]); | ||||||
|  |                     var data = HttpUtility.HtmlDecode(ps[1]); | ||||||
|  |                     ContactInfo contact = JsonConvert.DeserializeObject<ContactInfo>(data); | ||||||
|  |                     if (contact.Id > 0) | ||||||
|  |                         CreateClient<BusinessPartnerProvider>().UpdateContact(SystemParams.CompanyID, custid, contact); | ||||||
|  |                     else | ||||||
|  |                         contact.Id = CreateClient<BusinessPartnerProvider>().AddContact(SystemParams.CompanyID, custid, contact); | ||||||
|  |                     return contact.Id; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     return "Failed"; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private string DeleteContact() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var user = GetCurrentUser(); | ||||||
|  |                 if (user != null) | ||||||
|  |                 { | ||||||
|  |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |                     var id = HttpUtility.HtmlDecode(clientdata); | ||||||
|  |  | ||||||
|  |                     CreateClient<BusinessPartnerProvider>().DeleteContact(SystemParams.CompanyID, Convert.ToInt32(id)); | ||||||
|  |                     return "OK"; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     return "Failed"; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private object GetAllFollowers() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|  |                 { | ||||||
|  |                     var users = UserManagement.GetActiveUsers(session.SessionID); | ||||||
|  |                     return users.Where(u => u.IsUser).ToArray(); | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return new UserInfo[0]; | ||||||
|  |  | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 AddLog("ERROR", "CustomerRecordBasePage.GetAllFollowers", ex.Message, ex.ToString()); | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         private object GetFollowers() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|  |                 { | ||||||
|  |                     string custid = Request.Form["ClientData"]; | ||||||
|  |                     custid = HttpUtility.HtmlDecode(custid); | ||||||
|  |  | ||||||
|  |                     FollowerInfo[] followers = CreateClient<BusinessPartnerProvider>().GetFollowers(SystemParams.CompanyID, int.Parse(custid)); | ||||||
|  |                     if (followers == null || followers.Length == 0) | ||||||
|  |                         return new FollowerInfo[0]; | ||||||
|  |                     return followers; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return new FollowerInfo[0]; | ||||||
|  |  | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         private object AddFollowers() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var user = GetCurrentUser(); | ||||||
|  |                 if (user != null) | ||||||
|  |                 { | ||||||
|  |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |                     string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata); | ||||||
|  |                     int custid = int.Parse(ps[0]); | ||||||
|  |                     var data = HttpUtility.HtmlDecode(ps[1]); | ||||||
|  |                     FollowerInfo[] followers = JsonConvert.DeserializeObject<FollowerInfo[]>(data); | ||||||
|  |                     CreateClient<BusinessPartnerProvider>().AddFollowers(SystemParams.CompanyID, custid, followers); | ||||||
|  |                     return "OK"; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     return "Failed"; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private string DeleteFollower() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var user = GetCurrentUser(); | ||||||
|  |                 if (user != null) | ||||||
|  |                 { | ||||||
|  |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |                     var id = HttpUtility.HtmlDecode(clientdata); | ||||||
|  |  | ||||||
|  |                     CreateClient<BusinessPartnerProvider>().DeleteFollower(SystemParams.CompanyID, Convert.ToInt32(id)); | ||||||
|  |                     return "OK"; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     return "Failed"; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private object GetComments() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|  |                 { | ||||||
|  |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |                     var id = HttpUtility.HtmlDecode(clientdata); | ||||||
|  |  | ||||||
|  |                     CommentInfo[] comments = CreateClient<BusinessPartnerProvider>().GetComments(SystemParams.CompanyID, Convert.ToInt32(id)); | ||||||
|  |                     if (comments == null || comments.Length == 0) | ||||||
|  |                         return new CommentItem[0]; | ||||||
|  |  | ||||||
|  |                     List<CommentItem> ls = new List<CommentItem>(); | ||||||
|  |                     foreach (CommentInfo com in comments) | ||||||
|  |                     { | ||||||
|  |                         CommentItem item = new CommentItem(); | ||||||
|  |                         Helper.CloneProperty(item, com); | ||||||
|  |                         ls.Add(item); | ||||||
|  |                     } | ||||||
|  |  | ||||||
|  |                     return ls.OrderBy(r => r.SubmitLocalDate).ToArray(); | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return new CommentItem[0]; | ||||||
|  |  | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private string SubmitComment() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var user = GetCurrentUser(); | ||||||
|  |                 if (user != null) | ||||||
|  |                 { | ||||||
|  |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |                     clientdata = HttpUtility.HtmlDecode(clientdata); | ||||||
|  |                     string[] p = JsonConvert.DeserializeObject<string[]>(clientdata); | ||||||
|  |                     int id = Convert.ToInt32(p[0]); | ||||||
|  |                     bool isprivate = Helper.IsTrue(p[1]); | ||||||
|  |  | ||||||
|  |                     CreateClient<BusinessPartnerProvider>().SubmitComment(SystemParams.CompanyID, id, p[2], isprivate); | ||||||
|  |  | ||||||
|  |                     return ""; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     return "Failed"; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private object GetAssignedMachines() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|  |                 { | ||||||
|  |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |                     var id = HttpUtility.HtmlDecode(clientdata); | ||||||
|  |  | ||||||
|  |                     var machines = CreateClient<BusinessPartnerProvider>().GetAssignedMachines(SystemParams.CompanyID, Convert.ToInt32(id)); if (session.User.UserType < Foresight.Fleet.Services.User.UserTypes.Admin) | ||||||
|  |                     { | ||||||
|  |                         AssetBasicInfo[] allassets = CreateClient<AssetQueryClient>(SystemParams.CompanyID).GetAssetBasicInfoByUser(SystemParams.CompanyID, "", session.User.UID, 0); | ||||||
|  |                         var allassetids = allassets.Select(a => a.ID).ToList(); | ||||||
|  |                         machines = machines.Where(a => allassetids.Contains(a.Id)).ToArray(); | ||||||
|  |                     } | ||||||
|  |                     return machines.OrderBy(m => m.VIN).Select(m => new | ||||||
|  |                     { | ||||||
|  |                         ID = m.Id, | ||||||
|  |                         Name = m.Name, | ||||||
|  |                         m.VIN, | ||||||
|  |                         m.MakeName, | ||||||
|  |                         m.ModelName, | ||||||
|  |                         m.TypeName | ||||||
|  |                     }).ToArray(); | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return new BusinessPartnerInfo[0]; | ||||||
|  |  | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private object AssignMachines() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|  |                 { | ||||||
|  |                     var clientdata = HttpUtility.HtmlDecode(Request.Form["ClientData"]); | ||||||
|  |                     string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata); | ||||||
|  |                     int id = Convert.ToInt32(ps[0]); | ||||||
|  |                     long[] assetids = JsonConvert.DeserializeObject<long[]>(ps[1]); | ||||||
|  |  | ||||||
|  |                     CreateClient<BusinessPartnerProvider>().AssignMachines(SystemParams.CompanyID, id, assetids); | ||||||
|  |  | ||||||
|  |                     return "OK"; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return "Failed"; | ||||||
|  |  | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private object RemoveAssignedMachines() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|  |                 { | ||||||
|  |                     var clientdata = HttpUtility.HtmlDecode(Request.Form["ClientData"]); | ||||||
|  |                     string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata); | ||||||
|  |                     int id = Convert.ToInt32(ps[0]); | ||||||
|  |                     long[] assetids = JsonConvert.DeserializeObject<long[]>(ps[1]); | ||||||
|  |  | ||||||
|  |                     CreateClient<BusinessPartnerProvider>().RemoveAssignedMachines(SystemParams.CompanyID, id, assetids); | ||||||
|  |  | ||||||
|  |                     return "OK"; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return "Failed"; | ||||||
|  |  | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private object GetSalespersons() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|  |                 { | ||||||
|  |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |                     string searchtxt = HttpUtility.HtmlDecode(clientdata); | ||||||
|  |  | ||||||
|  |                     var users = UserManagement.GetSalespersons(session.SessionID, SystemParams.CompanyID, searchtxt); | ||||||
|  |                     users = users.Where(m => !string.IsNullOrWhiteSpace(m.FOB)).OrderBy(m => m.FOB).ToArray(); | ||||||
|  |                     return users; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return new UserInfo[0]; | ||||||
|  |  | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     class CommentItem : CommentInfo | ||||||
|  |     { | ||||||
|  |         public string SubmitLocalDateStr { get { return SubmitLocalDate == null ? "" : SubmitLocalDate.ToString("M/d/yyyy h:m:s tt"); } } | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public class ContactInfoClient : ContactInfo | ||||||
|  |     { | ||||||
|  |         public string ContactPreferenceStr { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -3,8 +3,6 @@ using Foresight.Fleet.Services.JobSite; | |||||||
| using IronIntel.Contractor.FITracker; | using IronIntel.Contractor.FITracker; | ||||||
| using IronIntel.Contractor.JobSites; | using IronIntel.Contractor.JobSites; | ||||||
| using IronIntel.Contractor.MapView; | using IronIntel.Contractor.MapView; | ||||||
| using IronIntel.Services; |  | ||||||
| using IronIntel.Services.Business.Admin; |  | ||||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| @@ -96,13 +94,12 @@ namespace IronIntel.Contractor.Site | |||||||
|  |  | ||||||
|                 List<TrackerChatMessage> result = new List<TrackerChatMessage>(); |                 List<TrackerChatMessage> result = new List<TrackerChatMessage>(); | ||||||
|                 var msgs = FITrackerManagement.GetMessages(session.SessionID, deviceid, lastmsgid); |                 var msgs = FITrackerManagement.GetMessages(session.SessionID, deviceid, lastmsgid); | ||||||
|                 double hourOffset = SystemParams.GetHoursOffset(); |  | ||||||
|                 foreach (ChatMessageInfo msginfo in msgs) |                 foreach (ChatMessageInfo msginfo in msgs) | ||||||
|                 { |                 { | ||||||
|                     TrackerChatMessage msg = new TrackerChatMessage(); |                     TrackerChatMessage msg = new TrackerChatMessage(); | ||||||
|                     Helper.CloneProperty(msg, msginfo); |                     Helper.CloneProperty(msg, msginfo); | ||||||
|                     if (msg.Time != DateTime.MinValue) |                     if (msg.Time != DateTime.MinValue) | ||||||
|                         msg.Time = msg.Time.AddHours(hourOffset); |                         msg.Time = SystemParams.ConvertToUserTimeFromUtc(session.User, msg.Time); | ||||||
|                     msg.IsSelf = session.User.UID.Equals(msg.SenderID, StringComparison.OrdinalIgnoreCase); |                     msg.IsSelf = session.User.UID.Equals(msg.SenderID, StringComparison.OrdinalIgnoreCase); | ||||||
|                     result.Add(msg); |                     result.Add(msg); | ||||||
|                 } |                 } | ||||||
| @@ -122,12 +119,9 @@ namespace IronIntel.Contractor.Site | |||||||
|                 int type = 0; |                 int type = 0; | ||||||
|                 int.TryParse(obj[2], out type); |                 int.TryParse(obj[2], out type); | ||||||
|                 var msginfo = FITrackerManagement.PostMessage(session.SessionID, obj[0], session.User.UID, session.User.Name, obj[1], type); |                 var msginfo = FITrackerManagement.PostMessage(session.SessionID, obj[0], session.User.UID, session.User.Name, obj[1], type); | ||||||
|                 double hourOffset = SystemParams.GetHoursOffset(); |  | ||||||
|  |  | ||||||
|                 TrackerChatMessage msg = new TrackerChatMessage(); |                 TrackerChatMessage msg = new TrackerChatMessage(); | ||||||
|                 Helper.CloneProperty(msg, msginfo); |                 Helper.CloneProperty(msg, msginfo); | ||||||
|                 if (msg.Time != DateTime.MinValue) |  | ||||||
|                     msg.Time = msg.Time.AddHours(hourOffset); |  | ||||||
|                 msg.IsSelf = session.User.UID.Equals(msg.SenderID, StringComparison.OrdinalIgnoreCase); |                 msg.IsSelf = session.User.UID.Equals(msg.SenderID, StringComparison.OrdinalIgnoreCase); | ||||||
|                 return msg; |                 return msg; | ||||||
|             } |             } | ||||||
|   | |||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -37,49 +37,18 @@ | |||||||
|     <AssemblyOriginatorKeyFile>LHBIS.snk</AssemblyOriginatorKeyFile> |     <AssemblyOriginatorKeyFile>LHBIS.snk</AssemblyOriginatorKeyFile> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <Reference Include="FICBLC"> |  | ||||||
|       <HintPath>..\Reflib\FIC\FICBLC.dll</HintPath> |  | ||||||
|     </Reference> |  | ||||||
|     <Reference Include="FICIntf, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b006d6021b5c4397, processorArchitecture=MSIL"> |  | ||||||
|       <SpecificVersion>False</SpecificVersion> |  | ||||||
|       <HintPath>..\Reflib\FIC\FICIntf.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> |  | ||||||
|     </Reference> |  | ||||||
|     <Reference Include="FICore"> |     <Reference Include="FICore"> | ||||||
|       <HintPath>..\Reflib\FICore.dll</HintPath> |       <HintPath>..\Reflib\FICore.dll</HintPath> | ||||||
|     </Reference> |     </Reference> | ||||||
|     <Reference Include="FICore.std"> |     <Reference Include="FICore.std, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1c0ebbbf33888075, processorArchitecture=MSIL"> | ||||||
|  |       <SpecificVersion>False</SpecificVersion> | ||||||
|       <HintPath>..\Reflib\FICore.std.dll</HintPath> |       <HintPath>..\Reflib\FICore.std.dll</HintPath> | ||||||
|     </Reference> |     </Reference> | ||||||
|     <Reference Include="FIWinLib"> |     <Reference Include="FIWinLib"> | ||||||
|       <HintPath>..\Reflib\FIWinLib.dll</HintPath> |       <HintPath>..\Reflib\FIWinLib.dll</HintPath> | ||||||
|     </Reference> |     </Reference> | ||||||
|     <Reference Include="FleetClientBase"> |     <Reference Include="ForesightCredentialClient"> | ||||||
|       <HintPath>..\Reflib\FleetClientBase.dll</HintPath> |       <HintPath>..\Reflib\ForesightCredentialClient.dll</HintPath> | ||||||
|     </Reference> |  | ||||||
|     <Reference Include="FleetServiceClient"> |  | ||||||
|       <HintPath>..\Reflib\FleetServiceClient.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>..\Reflib\ironcontractorwinlib.dll</HintPath> |  | ||||||
|     </Reference> |  | ||||||
|     <Reference Include="IronIntel.Services.Contractor"> |  | ||||||
|       <HintPath>..\Site\Bin\IronIntel.Services.Contractor.dll</HintPath> |  | ||||||
|     </Reference> |  | ||||||
|     <Reference Include="IronIntel.Services.CredentialObjects"> |  | ||||||
|       <HintPath>..\Reflib\IronIntel.Services.CredentialObjects.dll</HintPath> |  | ||||||
|     </Reference> |  | ||||||
|     <Reference Include="IronIntelServiceModel"> |  | ||||||
|       <HintPath>..\Reflib\IronIntelServiceModel.dll</HintPath> |  | ||||||
|     </Reference> |     </Reference> | ||||||
|     <Reference Include="Newtonsoft.Json"> |     <Reference Include="Newtonsoft.Json"> | ||||||
|       <HintPath>..\Reflib\Newtonsoft.Json.dll</HintPath> |       <HintPath>..\Reflib\Newtonsoft.Json.dll</HintPath> | ||||||
| @@ -99,9 +68,15 @@ | |||||||
|     <Compile Include="Asset\AssetBasePage.cs"> |     <Compile Include="Asset\AssetBasePage.cs"> | ||||||
|       <SubType>ASPXCodeBehind</SubType> |       <SubType>ASPXCodeBehind</SubType> | ||||||
|     </Compile> |     </Compile> | ||||||
|  |     <Compile Include="Asset\ShareAssetBasePage.cs"> | ||||||
|  |       <SubType>ASPXCodeBehind</SubType> | ||||||
|  |     </Compile> | ||||||
|     <Compile Include="ChangePasswordBasePage.cs"> |     <Compile Include="ChangePasswordBasePage.cs"> | ||||||
|       <SubType>ASPXCodeBehind</SubType> |       <SubType>ASPXCodeBehind</SubType> | ||||||
|     </Compile> |     </Compile> | ||||||
|  |     <Compile Include="CommBase.cs"> | ||||||
|  |       <SubType>ASPXCodeBehind</SubType> | ||||||
|  |     </Compile> | ||||||
|     <Compile Include="CommonHttpRequestHandler.cs" /> |     <Compile Include="CommonHttpRequestHandler.cs" /> | ||||||
|     <Compile Include="Contact\ContactBasePage.cs"> |     <Compile Include="Contact\ContactBasePage.cs"> | ||||||
|       <SubType>ASPXCodeBehind</SubType> |       <SubType>ASPXCodeBehind</SubType> | ||||||
| @@ -109,7 +84,13 @@ | |||||||
|     <Compile Include="ContractorBasePage.cs"> |     <Compile Include="ContractorBasePage.cs"> | ||||||
|       <SubType>ASPXCodeBehind</SubType> |       <SubType>ASPXCodeBehind</SubType> | ||||||
|     </Compile> |     </Compile> | ||||||
|     <Compile Include="CredentialEntryBasePage.cs"> |     <Compile Include="Credentials\CredentialEntryBasePage.cs"> | ||||||
|  |       <SubType>ASPXCodeBehind</SubType> | ||||||
|  |     </Compile> | ||||||
|  |     <Compile Include="Credentials\CredentialsBasePage.cs"> | ||||||
|  |       <SubType>ASPXCodeBehind</SubType> | ||||||
|  |     </Compile> | ||||||
|  |     <Compile Include="Customer\CustomerRecordBasePage.cs"> | ||||||
|       <SubType>ASPXCodeBehind</SubType> |       <SubType>ASPXCodeBehind</SubType> | ||||||
|     </Compile> |     </Compile> | ||||||
|     <Compile Include="FITrackerBasePage.cs"> |     <Compile Include="FITrackerBasePage.cs"> | ||||||
| @@ -118,10 +99,13 @@ | |||||||
|     <Compile Include="InspectionBasePage.cs"> |     <Compile Include="InspectionBasePage.cs"> | ||||||
|       <SubType>ASPXCodeBehind</SubType> |       <SubType>ASPXCodeBehind</SubType> | ||||||
|     </Compile> |     </Compile> | ||||||
|     <Compile Include="JobSitesBasePage.cs"> |     <Compile Include="FilterQBasePage.cs"> | ||||||
|       <SubType>ASPXCodeBehind</SubType> |       <SubType>ASPXCodeBehind</SubType> | ||||||
|     </Compile> |     </Compile> | ||||||
|     <Compile Include="FilterQBasePage.cs"> |     <Compile Include="JobSite\JobSiteRequirementsBasePage.cs"> | ||||||
|  |       <SubType>ASPXCodeBehind</SubType> | ||||||
|  |     </Compile> | ||||||
|  |     <Compile Include="JobSite\JobSitesBasePage.cs"> | ||||||
|       <SubType>ASPXCodeBehind</SubType> |       <SubType>ASPXCodeBehind</SubType> | ||||||
|     </Compile> |     </Compile> | ||||||
|     <Compile Include="MachineDeviceBasePage.cs"> |     <Compile Include="MachineDeviceBasePage.cs"> | ||||||
| @@ -165,15 +149,9 @@ | |||||||
|     <Compile Include="Security\CurfewBasePage.cs"> |     <Compile Include="Security\CurfewBasePage.cs"> | ||||||
|       <SubType>ASPXCodeBehind</SubType> |       <SubType>ASPXCodeBehind</SubType> | ||||||
|     </Compile> |     </Compile> | ||||||
|     <Compile Include="Security\FilterBasePage.cs"> |  | ||||||
|       <SubType>ASPXCodeBehind</SubType> |  | ||||||
|     </Compile> |  | ||||||
|     <Compile Include="Security\SecurityBasePage.cs"> |     <Compile Include="Security\SecurityBasePage.cs"> | ||||||
|       <SubType>ASPXCodeBehind</SubType> |       <SubType>ASPXCodeBehind</SubType> | ||||||
|     </Compile> |     </Compile> | ||||||
|     <Compile Include="Security\DataTablePermissionBasePage.cs"> |  | ||||||
|       <SubType>ASPXCodeBehind</SubType> |  | ||||||
|     </Compile> |  | ||||||
|     <Compile Include="Security\UserGroupBasePage.cs"> |     <Compile Include="Security\UserGroupBasePage.cs"> | ||||||
|       <SubType>ASPXCodeBehind</SubType> |       <SubType>ASPXCodeBehind</SubType> | ||||||
|     </Compile> |     </Compile> | ||||||
| @@ -197,14 +175,39 @@ | |||||||
|     </Compile> |     </Compile> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|  |     <None Include="app.config" /> | ||||||
|  |     <None Include="LHBIS.snk" /> | ||||||
|  |   </ItemGroup> | ||||||
|  |   <ItemGroup> | ||||||
|  |     <ProjectReference Include="..\..\..\..\FI_G3\FICG5Core\Service\FICBLC\FICBLC.csproj"> | ||||||
|  |       <Project>{39e2a8c6-f58f-4839-b7c1-82d44153fc3a}</Project> | ||||||
|  |       <Name>FICBLC</Name> | ||||||
|  |     </ProjectReference> | ||||||
|  |     <ProjectReference Include="..\..\..\..\FI_G3\FICG5Core\Service\FICIntf\FICIntfAdv\FICIntfAdv.csproj"> | ||||||
|  |       <Project>{3ffa4093-4325-4fbb-a874-f288bfdcf7ba}</Project> | ||||||
|  |       <Name>FICIntfAdv</Name> | ||||||
|  |     </ProjectReference> | ||||||
|  |     <ProjectReference Include="..\..\..\..\FI_G3\FICG5Core\Service\FICIntf\FICIntf\FICIntf.csproj"> | ||||||
|  |       <Project>{4963deb2-f0e3-44a3-b5e1-e13e191a8de8}</Project> | ||||||
|  |       <Name>FICIntf</Name> | ||||||
|  |     </ProjectReference> | ||||||
|  |     <ProjectReference Include="..\..\..\..\FI_G3\FICG5Core\Service\FICModels\FICModels.csproj"> | ||||||
|  |       <Project>{f47ebf77-eed3-44e2-9983-ef556372a648}</Project> | ||||||
|  |       <Name>FICModels</Name> | ||||||
|  |     </ProjectReference> | ||||||
|  |     <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> | ||||||
|     <ProjectReference Include="..\IronIntelContractorBusiness\IronIntelContractorBusiness.csproj"> |     <ProjectReference Include="..\IronIntelContractorBusiness\IronIntelContractorBusiness.csproj"> | ||||||
|       <Project>{515fb61f-f032-4a48-8f32-93b59b9d37f8}</Project> |       <Project>{515fb61f-f032-4a48-8f32-93b59b9d37f8}</Project> | ||||||
|       <Name>IronIntelContractorBusiness</Name> |       <Name>IronIntelContractorBusiness</Name> | ||||||
|     </ProjectReference> |     </ProjectReference> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |  | ||||||
|     <None Include="LHBIS.snk" /> |  | ||||||
|   </ItemGroup> |  | ||||||
|   <ItemGroup /> |   <ItemGroup /> | ||||||
|   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||||||
|   <PropertyGroup> |   <PropertyGroup> | ||||||
|   | |||||||
							
								
								
									
										1387
									
								
								IronIntelContractorSiteLib/JobSite/JobSiteRequirementsBasePage.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1387
									
								
								IronIntelContractorSiteLib/JobSite/JobSiteRequirementsBasePage.cs
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1136
									
								
								IronIntelContractorSiteLib/JobSite/JobSitesBasePage.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1136
									
								
								IronIntelContractorSiteLib/JobSite/JobSitesBasePage.cs
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,498 +0,0 @@ | |||||||
| using Foresight.Fleet.Services.JobSite; |  | ||||||
| using Foresight.Fleet.Services.MapView; |  | ||||||
| using Foresight.Standard; |  | ||||||
| using IronIntel.Contractor.FilterQ; |  | ||||||
| using IronIntel.Contractor.JobSites; |  | ||||||
| using IronIntel.Contractor.Machines; |  | ||||||
| using IronIntel.Contractor.MapView; |  | ||||||
| using IronIntel.Contractor.Users; |  | ||||||
| using IronIntel.Services; |  | ||||||
| using IronIntel.Services.Business.Admin; |  | ||||||
| using Newtonsoft.Json; |  | ||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
| using System.Web; |  | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor.Site |  | ||||||
| { |  | ||||||
|     public class JobSitesBasePage : ContractorBasePage |  | ||||||
|     { |  | ||||||
|         protected void ProcessRequest() |  | ||||||
|         { |  | ||||||
|             object result = null; |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 string methodName = Request.Params["MethodName"]; |  | ||||||
|                 if (methodName != null) |  | ||||||
|                 { |  | ||||||
|                     switch (methodName) |  | ||||||
|                     { |  | ||||||
|                         case "GetJobSites": |  | ||||||
|                             result = GetJobSites(); |  | ||||||
|                             break; |  | ||||||
|                         case "SaveJobSite": |  | ||||||
|                             result = SaveJobSite(); |  | ||||||
|                             break; |  | ||||||
|                         case "DeleteJobSite": |  | ||||||
|                             result = DeleteJobSite(); |  | ||||||
|                             break; |  | ||||||
|                         case "SaveJobSiteMachines": |  | ||||||
|                             result = SaveJobSiteMachines(); |  | ||||||
|                             break; |  | ||||||
|                         case "GetMachines": |  | ||||||
|                             result = GetMachines(); |  | ||||||
|                             break; |  | ||||||
|                         case "GetSelectedAssets": |  | ||||||
|                             result = GetSelectedAssets(); |  | ||||||
|                             break; |  | ||||||
|                         case "AddAssetToJobSite": |  | ||||||
|                             result = AddAssetToJobSite(); |  | ||||||
|                             break; |  | ||||||
|                         case "RemoveAssetFromJobSite": |  | ||||||
|                             result = RemoveAssetFromJobSite(); |  | ||||||
|                             break; |  | ||||||
|                         case "ChangeAssetOnSiteState": |  | ||||||
|                             result = ChangeAssetOnSiteState(); |  | ||||||
|                             break; |  | ||||||
|                         case "GetMachineTypes": |  | ||||||
|                             result = GetMachineTypes(); |  | ||||||
|                             break; |  | ||||||
|                         case "GetMachinesByType": |  | ||||||
|                             result = GetMachinesByType(); |  | ||||||
|                             break; |  | ||||||
|                         case "GetBindingMachines": |  | ||||||
|                             result = GetBindingMachines(); |  | ||||||
|                             break; |  | ||||||
|                         case "ImportJobsitePolygon": |  | ||||||
|                             result = ImportJobsitePolygon(); |  | ||||||
|                             break; |  | ||||||
|                         case "GetJobSiteUsers": |  | ||||||
|                             result = GetJobSiteUsers(); |  | ||||||
|                             break; |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             catch (Exception ex) |  | ||||||
|             { |  | ||||||
|                 SystemParams.WriteLog("error", "JobSitesBasePage", ex.Message, ex.ToString()); |  | ||||||
|                 throw ex; |  | ||||||
|             } |  | ||||||
|             string json = JsonConvert.SerializeObject(result); |  | ||||||
|             Response.Write(json); |  | ||||||
|             Response.End(); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private object GetJobSites() |  | ||||||
|         { |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 JobSiteViewItem[] items = null; |  | ||||||
|                 if (GetCurrentLoginSession() != null) |  | ||||||
|                 { |  | ||||||
|                     var s = Request.Form["ClientData"]; |  | ||||||
|                     s = HttpUtility.HtmlDecode(s); |  | ||||||
|  |  | ||||||
|                     var jss = CreateClient<JobSiteProvider>().GetJobSiteItems(SystemParams.CompanyID, s); |  | ||||||
|                     List<JobSiteViewItem> list = new List<JobSiteViewItem>(); |  | ||||||
|  |  | ||||||
|                     foreach (var js in jss) |  | ||||||
|                     { |  | ||||||
|                         JobSiteViewItem item = new JobSiteViewItem(); |  | ||||||
|                         item.ID = js.ID; |  | ||||||
|                         item.Name = js.Name; |  | ||||||
|                         item.BaseOnMachineID = js.BaseonMachineID; |  | ||||||
|                         item.Code = js.Code; |  | ||||||
|                         item.Types = new string[] { js.JobSiteTypes }; |  | ||||||
|                         item.ColorString = js.Color; |  | ||||||
|                         System.Drawing.Color color = System.Drawing.Color.Orange; |  | ||||||
|                         try |  | ||||||
|                         { |  | ||||||
|                             color = System.Drawing.ColorTranslator.FromHtml(item.ColorString); |  | ||||||
|                         } |  | ||||||
|                         catch |  | ||||||
|                         { |  | ||||||
|                         } |  | ||||||
|                         item.Color = new IIColor() { Alpha = color.A, Red = color.R, Green = color.G, Blue = color.B }; |  | ||||||
|  |  | ||||||
|                         item.Latitude = js.Latitude; |  | ||||||
|                         item.Longitude = js.Longitude; |  | ||||||
|                         item.StartDate = js.StartDate == null ? DateTime.MinValue : js.StartDate.Value; |  | ||||||
|                         item.EndDate = js.EndDate == null ? DateTime.MinValue : js.EndDate.Value; |  | ||||||
|                         item.Radius = js.Radius; |  | ||||||
|                         item.Radius_UOM = js.RadiusUOM; |  | ||||||
|                         if (js.Polygon != null && js.Polygon.Length > 0) |  | ||||||
|                         { |  | ||||||
|                             List<PostionItem> temps = new List<PostionItem>(); |  | ||||||
|                             foreach (var p in js.Polygon) |  | ||||||
|                             { |  | ||||||
|                                 temps.Add(new PostionItem(p.Latitude, p.Longtitude)); |  | ||||||
|                             } |  | ||||||
|                             item.Polygon = temps.ToArray(); |  | ||||||
|                         } |  | ||||||
|  |  | ||||||
|                         list.Add(item); |  | ||||||
|                     } |  | ||||||
|                     items = list.ToArray(); |  | ||||||
|                     //items = JobSitesManagement.GetJobSite(s); |  | ||||||
|                 } |  | ||||||
|                 else |  | ||||||
|                 { |  | ||||||
|                     items = new JobSiteViewItem[0]; |  | ||||||
|                 } |  | ||||||
|                 return items; |  | ||||||
|             } |  | ||||||
|             catch (Exception ex) |  | ||||||
|             { |  | ||||||
|                 return ex.Message; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private object SaveJobSite() |  | ||||||
|         { |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 var session = GetCurrentLoginSession(); |  | ||||||
|                 if (session != null) |  | ||||||
|                 { |  | ||||||
|                     var s = Request.Form["ClientData"]; |  | ||||||
|                     s = HttpUtility.HtmlDecode(s); |  | ||||||
|  |  | ||||||
|                     var js = JsonConvert.DeserializeObject<JobSiteViewItem>(s); |  | ||||||
|                     JobSiteItem jobsite = new JobSiteItem(); |  | ||||||
|                     Helper.CloneProperty(jobsite, js); |  | ||||||
|                     jobsite.RadiusUOM = js.Radius_UOM; |  | ||||||
|                     jobsite.BaseonMachineID = js.BaseOnMachineID; |  | ||||||
|                     jobsite.Color = js.ColorString; |  | ||||||
|                     jobsite.JobSiteTypes = string.Join(",", js.Types); |  | ||||||
|                     if (js.StartDate > Helper.DBMinDateTime) |  | ||||||
|                         jobsite.StartDate = js.StartDate; |  | ||||||
|                     if (js.EndDate > Helper.DBMinDateTime) |  | ||||||
|                         jobsite.EndDate = js.EndDate; |  | ||||||
|                     if (js.Polygon != null && js.Polygon.Length > 0) |  | ||||||
|                     { |  | ||||||
|                         List<Position> list = new List<Position>(); |  | ||||||
|                         foreach (PostionItem pi in js.Polygon) |  | ||||||
|                         { |  | ||||||
|                             Position p = new Position(pi.Latitude, pi.Longitude); |  | ||||||
|                             list.Add(p); |  | ||||||
|                         } |  | ||||||
|                         jobsite.Polygon = list.ToArray(); |  | ||||||
|                     } |  | ||||||
|  |  | ||||||
|                     long jobsiteid = CreateClient<JobSiteProvider>().SaveJobSite(SystemParams.CompanyID, jobsite, GetCurrentLoginSession().User.UID); |  | ||||||
|  |  | ||||||
|                     JobSitesManagement.RefreshJobsiteAssets(session.SessionID, jobsiteid); |  | ||||||
|  |  | ||||||
|                     return new string[] { jobsiteid.ToString(), "Saved successfully." }; |  | ||||||
|                 } |  | ||||||
|                 else |  | ||||||
|                 { |  | ||||||
|                     return "Failed"; |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             catch (Exception ex) |  | ||||||
|             { |  | ||||||
|                 return ex.Message; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private string DeleteJobSite() |  | ||||||
|         { |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 var user = GetCurrentUser(); |  | ||||||
|                 if (user != null) |  | ||||||
|                 { |  | ||||||
|                     var clientdata = Request.Form["ClientData"].Split((char)170); |  | ||||||
|                     var s = HttpUtility.HtmlDecode(clientdata[0]); |  | ||||||
|                     long jsid = Convert.ToInt64(s); |  | ||||||
|                     var notes = HttpUtility.HtmlDecode(clientdata[1]); |  | ||||||
|  |  | ||||||
|                     CreateClient<JobSiteProvider>().DeleteJobSite(SystemParams.CompanyID, jsid, notes, user.IID); |  | ||||||
|                     return "OK"; |  | ||||||
|                 } |  | ||||||
|                 else |  | ||||||
|                 { |  | ||||||
|                     return "Failed"; |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             catch (Exception ex) |  | ||||||
|             { |  | ||||||
|                 return ex.Message; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         private string SaveJobSiteMachines() |  | ||||||
|         { |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 if (GetCurrentLoginSession() != null) |  | ||||||
|                 { |  | ||||||
|                     var s = Request.Form["ClientData"]; |  | ||||||
|                     s = HttpUtility.HtmlDecode(s); |  | ||||||
|                     var jobsite = JsonConvert.DeserializeObject<JobSiteViewItem>(s); |  | ||||||
|  |  | ||||||
|                     JobSitesManagement.AddMachinesToJobSite(jobsite); |  | ||||||
|  |  | ||||||
|                     return "OK"; |  | ||||||
|                 } |  | ||||||
|                 else |  | ||||||
|                 { |  | ||||||
|                     return "Failed"; |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             catch (Exception ex) |  | ||||||
|             { |  | ||||||
|                 return ex.Message; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private AssetMapViewPinItem[] GetMachines() |  | ||||||
|         { |  | ||||||
|             var session = GetCurrentLoginSession(); |  | ||||||
|             if (session != null) |  | ||||||
|             { |  | ||||||
|                 AssetMapViewPinItem[] items = AssetMapViewManagement.GetAssets(session.SessionID, SystemParams.CompanyID, session.User.UID, "", -1, null, false); |  | ||||||
|                 return items; |  | ||||||
|             } |  | ||||||
|             return new AssetMapViewPinItem[0]; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private object[] GetSelectedAssets() |  | ||||||
|         { |  | ||||||
|             var u = GetCurrentUser(); |  | ||||||
|             if (u != null) |  | ||||||
|             { |  | ||||||
|                 var clientdata = Request.Form["ClientData"].Split((char)170); |  | ||||||
|                 var companyid = HttpUtility.HtmlDecode(clientdata[0]); |  | ||||||
|                 if (string.IsNullOrEmpty(companyid)) |  | ||||||
|                 { |  | ||||||
|                     companyid = SystemParams.CompanyID; |  | ||||||
|                 } |  | ||||||
|                 var jobsiteid = long.Parse(clientdata[1]); |  | ||||||
|                 var jobsites = CreateClient<JobSiteProvider>(companyid).GetAssetsCurrentInJobSite(companyid, jobsiteid); |  | ||||||
|                 return jobsites.Select(i => new |  | ||||||
|                 { |  | ||||||
|                     i.AssetId, |  | ||||||
|                     i.OnSite, |  | ||||||
|                     Name = string.IsNullOrEmpty(i.AssetName2) ? i.AssetName : i.AssetName2, |  | ||||||
|                     i.VIN, |  | ||||||
|                     i.MakeName, |  | ||||||
|                     i.ModelName, |  | ||||||
|                     i.TypeName |  | ||||||
|                 }).ToArray(); |  | ||||||
|             } |  | ||||||
|             return new object[0]; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private string AddAssetToJobSite() |  | ||||||
|         { |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 var u = GetCurrentUser(); |  | ||||||
|                 if (u != null) |  | ||||||
|                 { |  | ||||||
|                     var clientdata = Request.Form["ClientData"].Split((char)170); |  | ||||||
|                     var companyId = HttpUtility.HtmlDecode(clientdata[0]); |  | ||||||
|                     if (string.IsNullOrEmpty(companyId)) |  | ||||||
|                     { |  | ||||||
|                         companyId = SystemParams.CompanyID; |  | ||||||
|                     } |  | ||||||
|                     var jobsiteid = long.Parse(clientdata[1]); |  | ||||||
|                     var machineids = HttpUtility.HtmlDecode(clientdata[2]); |  | ||||||
|  |  | ||||||
|                     var ids = JsonConvert.DeserializeObject<long[]>(machineids); |  | ||||||
|  |  | ||||||
|                     var client = CreateClient<JobSiteProvider>(companyId); |  | ||||||
|                     foreach (var id in ids) |  | ||||||
|                     { |  | ||||||
|                         client.AddAssetToJobSite(companyId, jobsiteid, id, false, u.IID); |  | ||||||
|                     } |  | ||||||
|                     return "OK"; |  | ||||||
|                 } |  | ||||||
|                 else |  | ||||||
|                 { |  | ||||||
|                     return "Failed"; |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             catch (Exception ex) |  | ||||||
|             { |  | ||||||
|                 SystemParams.WriteLog("error", "JobSitesBasePage.AddAssetToJobSite", ex.Message, ex.ToString()); |  | ||||||
|                 return ex.Message; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private string RemoveAssetFromJobSite() |  | ||||||
|         { |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 var u = GetCurrentUser(); |  | ||||||
|                 if (u != null) |  | ||||||
|                 { |  | ||||||
|                     var clientdata = Request.Form["ClientData"].Split((char)170); |  | ||||||
|                     var companyId = HttpUtility.HtmlDecode(clientdata[0]); |  | ||||||
|                     if (string.IsNullOrEmpty(companyId)) |  | ||||||
|                     { |  | ||||||
|                         companyId = SystemParams.CompanyID; |  | ||||||
|                     } |  | ||||||
|                     var jobsiteid = long.Parse(clientdata[1]); |  | ||||||
|                     var machineids = HttpUtility.HtmlDecode(clientdata[2]); |  | ||||||
|  |  | ||||||
|                     var ids = JsonConvert.DeserializeObject<long[]>(machineids); |  | ||||||
|  |  | ||||||
|                     var client = CreateClient<JobSiteProvider>(companyId); |  | ||||||
|                     foreach (var id in ids) |  | ||||||
|                     { |  | ||||||
|                         client.RemoveAssetFromJobSite(companyId, jobsiteid, id, u.IID); |  | ||||||
|                     } |  | ||||||
|                     return "OK"; |  | ||||||
|                 } |  | ||||||
|                 else |  | ||||||
|                 { |  | ||||||
|                     return "Failed"; |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             catch (Exception ex) |  | ||||||
|             { |  | ||||||
|                 SystemParams.WriteLog("error", "JobSitesBasePage.RemoveAssetFromJobSite", ex.Message, ex.ToString()); |  | ||||||
|                 return ex.Message; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private string ChangeAssetOnSiteState() |  | ||||||
|         { |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 var u = GetCurrentUser(); |  | ||||||
|                 if (u != null) |  | ||||||
|                 { |  | ||||||
|                     var clientdata = Request.Form["ClientData"].Split((char)170); |  | ||||||
|                     var companyId = HttpUtility.HtmlDecode(clientdata[0]); |  | ||||||
|                     if (string.IsNullOrEmpty(companyId)) |  | ||||||
|                     { |  | ||||||
|                         companyId = SystemParams.CompanyID; |  | ||||||
|                     } |  | ||||||
|                     var jobsiteid = long.Parse(clientdata[1]); |  | ||||||
|                     var assetid = long.Parse(clientdata[2]); |  | ||||||
|                     var onsite = (clientdata[3] == "1"); |  | ||||||
|  |  | ||||||
|                     CreateClient<JobSiteProvider>(companyId).ChangeAssetOnSiteState(companyId, jobsiteid, assetid, onsite, u.IID); |  | ||||||
|                     return "OK"; |  | ||||||
|                 } |  | ||||||
|                 else |  | ||||||
|                 { |  | ||||||
|                     return "Failed"; |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             catch (Exception ex) |  | ||||||
|             { |  | ||||||
|                 SystemParams.WriteLog("error", "JobSitesBasePage.ChangeAssetOnSiteState", ex.Message, ex.ToString()); |  | ||||||
|                 return ex.Message; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private MachineViewItem[] GetBindingMachines() |  | ||||||
|         { |  | ||||||
|             var session = GetCurrentLoginSession(); |  | ||||||
|             MachineViewItem[] items = JobSitesManagement.GetBindingMachines(session.SessionID, session.User.UID); |  | ||||||
|             if (items != null) |  | ||||||
|             { |  | ||||||
|                 items = items.OrderBy((m) => m.DisplayName).ToArray(); |  | ||||||
|             } |  | ||||||
|             return items; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private MachineTypeItem[] GetMachineTypes() |  | ||||||
|         { |  | ||||||
|             MachineTypeItem[] types = JobSitesManagement.GetMachineTypes(); |  | ||||||
|             if (types != null) |  | ||||||
|             { |  | ||||||
|                 types = types.OrderBy((t) => t.Name).ToArray(); |  | ||||||
|             } |  | ||||||
|             return types; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private AvailableMachines GetMachinesByType() |  | ||||||
|         { |  | ||||||
|             var session = GetCurrentLoginSession(); |  | ||||||
|             var p = Request.Form["ClientData"]; |  | ||||||
|             p = HttpUtility.HtmlDecode(p); |  | ||||||
|             var param = JsonConvert.DeserializeObject<JobSiteMahcineQueryItem>(p); |  | ||||||
|  |  | ||||||
|             AvailableMachines machines = JobSitesManagement.GetMachineViewItemByType(session.SessionID, param.JobSiteID, param.MachineTypeID, param.SearchText, session.User.UID); |  | ||||||
|             return machines; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private object ImportJobsitePolygon() |  | ||||||
|         { |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 if (GetCurrentLoginSession() != null) |  | ||||||
|                 { |  | ||||||
|                     string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]); |  | ||||||
|                     string fileName = clientdata; |  | ||||||
|  |  | ||||||
|                     HttpPostedFile uploadFile = null; |  | ||||||
|                     byte[] buffer = null; |  | ||||||
|                     if (Request.Files.Count > 0) |  | ||||||
|                     { |  | ||||||
|                         uploadFile = Request.Files[0]; |  | ||||||
|                         buffer = ConvertFile2bytes(uploadFile); |  | ||||||
|                     } |  | ||||||
|  |  | ||||||
|                     return JobSitesManagement.ImportJobsitePolygon(fileName, buffer); |  | ||||||
|                 } |  | ||||||
|                 else |  | ||||||
|                 { |  | ||||||
|                     return null; |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             catch (Exception ex) |  | ||||||
|             { |  | ||||||
|                 return ex.Message; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private object GetJobSiteUsers() |  | ||||||
|         { |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 UserNameInfoItem[] items = null; |  | ||||||
|                 if (GetCurrentLoginSession() != null) |  | ||||||
|                 { |  | ||||||
|                     var data = HttpUtility.HtmlDecode(Request.Form["ClientData"]); |  | ||||||
|                     var jobsiteid = long.Parse(data); |  | ||||||
|                     var users = CreateClient<JobSiteProvider>().GetJobisteUserNamesList(SystemParams.CompanyID, jobsiteid); |  | ||||||
|  |  | ||||||
|                     List<UserNameInfoItem> list = new List<UserNameInfoItem>(); |  | ||||||
|                     foreach (var user in users) |  | ||||||
|                     { |  | ||||||
|                         UserNameInfoItem ui = new UserNameInfoItem(); |  | ||||||
|                         Helper.CloneProperty(ui, user); |  | ||||||
|                         list.Add(ui); |  | ||||||
|                     } |  | ||||||
|                     items = list.ToArray(); |  | ||||||
|                 } |  | ||||||
|                 else |  | ||||||
|                 { |  | ||||||
|                     items = new UserNameInfoItem[0]; |  | ||||||
|                 } |  | ||||||
|                 return items; |  | ||||||
|             } |  | ||||||
|             catch (Exception ex) |  | ||||||
|             { |  | ||||||
|                 return ex.Message; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private class JobSiteMahcineQueryItem |  | ||||||
|         { |  | ||||||
|             public string JobSiteID { get; set; } |  | ||||||
|             public string MachineTypeID { get; set; } |  | ||||||
|             public string SearchText { get; set; } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|     } |  | ||||||
| } |  | ||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -5,8 +5,10 @@ using System.Text; | |||||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||||
| using Foresight; | using Foresight; | ||||||
| using IronIntel.Services; |  | ||||||
| using IronIntel.Contractor.Users; | using IronIntel.Contractor.Users; | ||||||
|  | using System.Web; | ||||||
|  | using Foresight.Fleet.Services.User; | ||||||
|  | using Foresight.Fleet.Services.FIC; | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor.Site | namespace IronIntel.Contractor.Site | ||||||
| { | { | ||||||
| @@ -17,8 +19,8 @@ namespace IronIntel.Contractor.Site | |||||||
|             string methidName = Request.Params["MethodName"]; |             string methidName = Request.Params["MethodName"]; | ||||||
|             switch (methidName) |             switch (methidName) | ||||||
|             { |             { | ||||||
|                 case "GetUserName": |                 case "GetUserData": | ||||||
|                     GetUserName(); |                     GetUserData(); | ||||||
|                     break; |                     break; | ||||||
|                 case "GetAppModules": |                 case "GetAppModules": | ||||||
|                     GetAppModules(); |                     GetAppModules(); | ||||||
| @@ -29,23 +31,60 @@ namespace IronIntel.Contractor.Site | |||||||
|                 case "GetSiteHeaderNote": |                 case "GetSiteHeaderNote": | ||||||
|                     GetSiteHeaderNote(); |                     GetSiteHeaderNote(); | ||||||
|                     break; |                     break; | ||||||
|  |                 case "SetFavorites": | ||||||
|  |                     SetFavorites(); | ||||||
|  |                     break; | ||||||
|  |                 case "GetFavoriteItems": | ||||||
|  |                     GetFavoriteItems(); | ||||||
|  |                     break; | ||||||
|  |                 case "GetDashboardList": | ||||||
|  |                     GetDashboardList(); | ||||||
|  |                     break; | ||||||
|  |                 case "SetRecentOpenedDashboard": | ||||||
|  |                     SetRecentOpenedDashboard(); | ||||||
|  |                     break; | ||||||
|  |                 case "UploadUserAvatar": | ||||||
|  |                     UploadUserAvatar(); | ||||||
|  |                     break; | ||||||
|                 default: |                 default: | ||||||
|                     break; |                     break; | ||||||
|             } |             } | ||||||
|             //TODO |             //TODO | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private void GetUserName() |         private void GetUserData() | ||||||
|         { |         { | ||||||
|             string userName = ""; |             string userdata = ""; | ||||||
|             var session = GetCurrentLoginSession(); |             var session = GetCurrentLoginSession(); | ||||||
|             if (session != null && session.User != null) |             if (session != null && session.User != null) | ||||||
|             { |             { | ||||||
|                 userName = session.User.Name; |                 var data = new | ||||||
|  |                 { | ||||||
|  |                     UserName = session.User.Name, | ||||||
|  |                 }; | ||||||
|  |  | ||||||
|  |                 userdata = JsonConvert.SerializeObject(data); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             userName = JsonConvert.SerializeObject(userName); |             Response.Write(userdata); | ||||||
|             Response.Write(userName); |             Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void UploadUserAvatar() | ||||||
|  |         { | ||||||
|  |             var session = GetCurrentLoginSession(); | ||||||
|  |             if (session != null && session.User != null) | ||||||
|  |             { | ||||||
|  |                 byte[] avadarBytes = null; | ||||||
|  |                 if (Request.Files.Count > 0) | ||||||
|  |                 { | ||||||
|  |                     HttpPostedFile uploadFile = Request.Files[0]; | ||||||
|  |                     avadarBytes = ConvertFile2bytes(uploadFile); | ||||||
|  |                 } | ||||||
|  |                 UserManagement.SetUserAvatar(session.SessionID, session.User.UID, avadarBytes); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             Response.Write(JsonConvert.SerializeObject("OK")); | ||||||
|             Response.End(); |             Response.End(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -126,5 +165,147 @@ namespace IronIntel.Contractor.Site | |||||||
|             Response.Write(json); |             Response.Write(json); | ||||||
|             Response.End(); |             Response.End(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         private void GetFavoriteItems() | ||||||
|  |         { | ||||||
|  |             string value = string.Empty; | ||||||
|  |             var session = GetCurrentLoginSession(); | ||||||
|  |             if (session != null && session.User != null) | ||||||
|  |             { | ||||||
|  |                 value = UserParams.GetStringParameter(session.User.UID, "FavoriteSites"); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|  |             string json = string.IsNullOrEmpty(value) ? JsonConvert.SerializeObject(new FavoriteInfo[0]) : value; | ||||||
|  |             Response.Write(json); | ||||||
|  |             Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         private void SetFavorites() | ||||||
|  |         { | ||||||
|  |             var session = GetCurrentLoginSession(); | ||||||
|  |             if (session != null && session.User != null) | ||||||
|  |             { | ||||||
|  |                 var clientdata = Request.Form["ClientData"]; | ||||||
|  |                 var data = HttpUtility.HtmlDecode(clientdata); | ||||||
|  |  | ||||||
|  |                 UserParams.SetStringParameter(session.User.UID, "FavoriteSites", data); | ||||||
|  |             } | ||||||
|  |             Response.Write(JsonConvert.SerializeObject("OK")); | ||||||
|  |             Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void GetDashboardList() | ||||||
|  |         { | ||||||
|  |             List<DashboardInfo> ls = new List<DashboardInfo>(); | ||||||
|  |             var session = GetCurrentLoginSession(); | ||||||
|  |             if (session != null && session.User != null) | ||||||
|  |             { | ||||||
|  |                 var ps = JsonConvert.DeserializeObject<string[]>(Request.Form["ClientData"]); | ||||||
|  |                 var filter = HttpUtility.HtmlDecode(ps[0]); | ||||||
|  |                 int flag; | ||||||
|  |                 if (!int.TryParse(ps[1], out flag)) | ||||||
|  |                 { | ||||||
|  |                     flag = 0; | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |                 var ficprovider = FleetServiceClientHelper.CreateClient<FICObjectProvider>(); | ||||||
|  |                 WorkSpaceInfo[] wsps = ficprovider.GetWorkSpaces(SystemParams.CompanyID, filter, false, flag); | ||||||
|  |                 ChartInfo[] charts = ficprovider.GetCharts(SystemParams.CompanyID, filter, flag); | ||||||
|  |                 foreach (WorkSpaceInfo wsp in wsps) | ||||||
|  |                 { | ||||||
|  |                     DashboardInfo item = new DashboardInfo(); | ||||||
|  |                     Helper.CloneProperty(item, wsp); | ||||||
|  |                     item.IsChart = false; | ||||||
|  |                     item.Notes = wsp.Description; | ||||||
|  |                     ls.Add(item); | ||||||
|  |                 } | ||||||
|  |                 foreach (ChartInfo chart in charts) | ||||||
|  |                 { | ||||||
|  |                     DashboardInfo item = new DashboardInfo(); | ||||||
|  |                     Helper.CloneProperty(item, chart); | ||||||
|  |                     item.IsChart = true; | ||||||
|  |                     item.Notes = chart.ChartNotes; | ||||||
|  |                     ls.Add(item); | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |                 List<RecentOpenedDashboardItem> lsrencent = GetRecentOpenedDashboards(session.User.UID); | ||||||
|  |                 foreach (RecentOpenedDashboardItem item in lsrencent) | ||||||
|  |                 { | ||||||
|  |                     DashboardInfo dab = ls.FirstOrDefault(m => m.ID == item.ID); | ||||||
|  |                     if (dab != null) | ||||||
|  |                     { | ||||||
|  |                         ls.Remove(dab); | ||||||
|  |                         ls.Insert(0, dab); | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             string json = JsonConvert.SerializeObject(ls.ToArray()); | ||||||
|  |             Response.Write(json); | ||||||
|  |             Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void SetRecentOpenedDashboard() | ||||||
|  |         { | ||||||
|  |             var session = GetCurrentLoginSession(); | ||||||
|  |             if (session != null && session.User != null) | ||||||
|  |             { | ||||||
|  |                 var clientdata = Request.Form["ClientData"]; | ||||||
|  |                 var id = HttpUtility.HtmlDecode(clientdata); | ||||||
|  |  | ||||||
|  |                 List<RecentOpenedDashboardItem> lsrencent = GetRecentOpenedDashboards(session.User.UID); | ||||||
|  |                 RecentOpenedDashboardItem ritem = lsrencent.FirstOrDefault(m => m.ID == id); | ||||||
|  |                 if (ritem == null) | ||||||
|  |                 { | ||||||
|  |                     RecentOpenedDashboardItem item = new RecentOpenedDashboardItem(); | ||||||
|  |                     item.ID = id; | ||||||
|  |                     item.Time = DateTime.UtcNow; | ||||||
|  |                     lsrencent.Add(item); | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     ritem.Time = DateTime.UtcNow; | ||||||
|  |  | ||||||
|  |                 lsrencent = lsrencent.OrderBy(m => m.Time).ToList(); | ||||||
|  |                 string newdata = JsonConvert.SerializeObject(lsrencent); | ||||||
|  |                 UserParams.SetStringParameter(session.User.UID, "RecentOpenedDashboard", newdata); | ||||||
|  |             } | ||||||
|  |             Response.Write(JsonConvert.SerializeObject("OK")); | ||||||
|  |             Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private List<RecentOpenedDashboardItem> GetRecentOpenedDashboards(string uid) | ||||||
|  |         { | ||||||
|  |             string data = UserParams.GetStringParameter(uid, "RecentOpenedDashboard"); | ||||||
|  |             List<RecentOpenedDashboardItem> ls = JsonConvert.DeserializeObject<List<RecentOpenedDashboardItem>>(data); | ||||||
|  |             if (ls == null) | ||||||
|  |                 return new List<RecentOpenedDashboardItem>(); | ||||||
|  |             return ls.OrderBy(m => m.Time).ToList(); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     public class FavoriteInfo | ||||||
|  |     { | ||||||
|  |         public string ID { get; set; } | ||||||
|  |         public string Name { get; set; } | ||||||
|  |         public int FavoriteType { get; set; } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public class DashboardInfo | ||||||
|  |     { | ||||||
|  |         public string ID { get; set; } | ||||||
|  |         public string Name { get; set; } | ||||||
|  |         public string Type { get; set; } | ||||||
|  |         public string Description { get; set; } | ||||||
|  |         public string Notes { get; set; } | ||||||
|  |         public bool IsChart { get; set; } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public class RecentOpenedDashboardItem | ||||||
|  |     { | ||||||
|  |         public string ID { get; set; } | ||||||
|  |         public DateTime Time { get; set; } | ||||||
|  |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,10 +1,11 @@ | |||||||
| using Foresight.Data; | using Foresight.Data; | ||||||
| using Foresight.Fleet.Services.AssetHealth; | using Foresight.Fleet.Services.AssetHealth; | ||||||
|  | using Foresight.Fleet.Services.AssetHealth.WorkOrder; | ||||||
|  | using Foresight.Fleet.Services.JobSite; | ||||||
|  | using Foresight.Fleet.Services.User; | ||||||
| using Foresight.ServiceModel; | using Foresight.ServiceModel; | ||||||
| using IronIntel.Contractor.Machines; | using IronIntel.Contractor.Machines; | ||||||
| using IronIntel.Contractor.Maintenance; | using IronIntel.Contractor.Maintenance; | ||||||
| using IronIntel.Contractor.Users; |  | ||||||
| using IronIntel.Services; |  | ||||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| @@ -33,15 +34,15 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                         case "GETMACHINEALERTS": |                         case "GETMACHINEALERTS": | ||||||
|                             result = GetMachineAlerts(); |                             result = GetMachineAlerts(); | ||||||
|                             break; |                             break; | ||||||
|  |                         case "GETPMALERTSERVICEDESCRIPTIONS": | ||||||
|  |                             result = GetPMAlertServiceDescriptions(); | ||||||
|  |                             break; | ||||||
|                         case "SAVEACKNOWLEDGEALERT": |                         case "SAVEACKNOWLEDGEALERT": | ||||||
|                             result = SaveAcknowledgeAlert(); |                             result = SaveAcknowledgeAlert(); | ||||||
|                             break; |                             break; | ||||||
|                         case "ASSIGNEDALERTSTOWORKORDER": |                         case "ASSIGNEDALERTSTOWORKORDER": | ||||||
|                             result = AssignedAlertsToWorkOrder(); |                             result = AssignedAlertsToWorkOrder(); | ||||||
|                             break; |                             break; | ||||||
|                         case "GETALERTSBYWORKORDER": |  | ||||||
|                             result = GetAlertsByWorkOrder(); |  | ||||||
|                             break; |  | ||||||
|                         case "GETALERTSLISENCE": |                         case "GETALERTSLISENCE": | ||||||
|                             result = GetAlertsLisence(); |                             result = GetAlertsLisence(); | ||||||
|                             break; |                             break; | ||||||
| @@ -60,6 +61,30 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                         case "GETACKNOWLEDGEDALERTS": |                         case "GETACKNOWLEDGEDALERTS": | ||||||
|                             result = GetAcknowledgedAlerts(); |                             result = GetAcknowledgedAlerts(); | ||||||
|                             break; |                             break; | ||||||
|  |                         case "GETJOBSITES": | ||||||
|  |                             result = GetJobsites(); | ||||||
|  |                             break; | ||||||
|  |                         case "SAVEAUTOACKNOWLEDGEALERTTYPES": | ||||||
|  |                             result = SaveAutoAcknowledgeAlertTypes(); | ||||||
|  |                             break; | ||||||
|  |                         case "GETAUTOACKNOWLEDGEALERTTYPES": | ||||||
|  |                             result = GetAutoAcknowledgeAlertTypes(); | ||||||
|  |                             break; | ||||||
|  |                         case "GETAUTOACKNOWLEDGEALERTTYPESHISTORY": | ||||||
|  |                             result = GetAutoAcknowledgeAlertTypesHistory(); | ||||||
|  |                             break; | ||||||
|  |                         case "GETWORKORDERGENERATORS": | ||||||
|  |                             result = GetWorkOrderGenerators(); | ||||||
|  |                             break; | ||||||
|  |                         case "SAVEWORKORDERGENERATOR": | ||||||
|  |                             result = SaveWorkOrderGenerator(); | ||||||
|  |                             break; | ||||||
|  |                         case "DELETEWORKORDERGENERATOR": | ||||||
|  |                             result = DeleteWorkOrderGenerator(); | ||||||
|  |                             break; | ||||||
|  |                         case "GETASSIGNTOS": | ||||||
|  |                             result = GetAssignTos(); | ||||||
|  |                             break; | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| @@ -90,11 +115,6 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                     //    beginDate = beginDate.ToUniversalTime(); |                     //    beginDate = beginDate.ToUniversalTime(); | ||||||
|                     if (!DateTime.TryParse(alertparam.EndDate, out endDate)) |                     if (!DateTime.TryParse(alertparam.EndDate, out endDate)) | ||||||
|                         endDate = DateTime.MaxValue; |                         endDate = DateTime.MaxValue; | ||||||
|                     else |  | ||||||
|                         endDate = endDate.Date.AddDays(1).AddSeconds(-1); |  | ||||||
|  |  | ||||||
|                     beginDate = SystemParams.CustomerDetail.CustomerTimeToUtc(beginDate); |  | ||||||
|                     endDate = SystemParams.CustomerDetail.CustomerTimeToUtc(endDate); |  | ||||||
|  |  | ||||||
|                     int assigned = -1; |                     int assigned = -1; | ||||||
|                     int completed = -1; |                     int completed = -1; | ||||||
| @@ -106,18 +126,23 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                             assigned = 1; |                             assigned = 1; | ||||||
|  |  | ||||||
|                         if (alertparam.AlertStatus.Contains("Completed") && !alertparam.AlertStatus.Contains("Uncompleted")) |                         if (alertparam.AlertStatus.Contains("Completed") && !alertparam.AlertStatus.Contains("Uncompleted")) | ||||||
|                             assigned = 1; |                             completed = 1; | ||||||
|                         if (!alertparam.AlertStatus.Contains("Completed") && alertparam.AlertStatus.Contains("Uncompleted")) |                         if (!alertparam.AlertStatus.Contains("Completed") && alertparam.AlertStatus.Contains("Uncompleted")) | ||||||
|                             assigned = 0; |                             completed = 0; | ||||||
|                     } |                     } | ||||||
|                     AssetAlertGridViewItem[] assetalerts = CreateClient<WorkOrderClient>().GetAssetAlertGridViewItems(SystemParams.CompanyID, beginDate, endDate, alertparam.AlertTypes, alertparam.AssetGroups, assigned, completed, alertparam.SearchText, session.User.UID); |  | ||||||
|  |                     AssetAlertGridViewItem[] assetalerts = null; | ||||||
|  |                     if (alertparam.AssetID > 0) | ||||||
|  |                         assetalerts = CreateClient<WorkOrderProvider>().GetAssetAlertGridViewItemsByAsset(SystemParams.CompanyID, alertparam.AssetID, beginDate, endDate, alertparam.AlertTypes, alertparam.JobSites, assigned, completed, alertparam.SearchText, alertparam.IncludeunCompleted); | ||||||
|  |                     else | ||||||
|  |                         assetalerts = CreateClient<AlertProvider>().GetAssetAlertGridViewItems(SystemParams.CompanyID, beginDate, endDate, alertparam.AlertTypes, alertparam.AssetGroups, alertparam.JobSites, assigned, completed, alertparam.SearchText, session.User.UID, alertparam.IncludeunCompleted); | ||||||
|  |  | ||||||
|                     if (assetalerts == null || assetalerts.Length == 0) |                     if (assetalerts == null || assetalerts.Length == 0) | ||||||
|                         return new AlertInfo[0]; |                         return new AlertInfo[0]; | ||||||
|                     List<AlertInfo> list = new List<AlertInfo>(); |                     List<AlertInfo> list = new List<AlertInfo>(); | ||||||
|                     foreach (AssetAlertGridViewItem item in assetalerts) |                     foreach (AssetAlertGridViewItem item in assetalerts) | ||||||
|                     { |                     { | ||||||
|                         AlertInfo ai = ConvertAlertObj(item); |                         AlertInfo ai = ConvertAlertObj(item); | ||||||
|                         ai.AlertTime_UTC = item.LastAlertLocalTime; |  | ||||||
|                         list.Add(ai); |                         list.Add(ai); | ||||||
|                     } |                     } | ||||||
|                     return list.ToArray(); |                     return list.ToArray(); | ||||||
| @@ -149,11 +174,7 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                     //    beginDate = beginDate.ToUniversalTime(); |                     //    beginDate = beginDate.ToUniversalTime(); | ||||||
|                     if (!DateTime.TryParse(alertparam.EndDate, out endDate)) |                     if (!DateTime.TryParse(alertparam.EndDate, out endDate)) | ||||||
|                         endDate = DateTime.MaxValue; |                         endDate = DateTime.MaxValue; | ||||||
|                     else |  | ||||||
|                         endDate = endDate.Date.AddDays(1).AddSeconds(-1); |  | ||||||
|  |  | ||||||
|                     beginDate = SystemParams.CustomerDetail.CustomerTimeToUtc(beginDate); |  | ||||||
|                     endDate = SystemParams.CustomerDetail.CustomerTimeToUtc(endDate); |  | ||||||
|  |  | ||||||
|                     int assigned = -1; |                     int assigned = -1; | ||||||
|                     int completed = -1; |                     int completed = -1; | ||||||
| @@ -165,12 +186,16 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                             assigned = 1; |                             assigned = 1; | ||||||
|  |  | ||||||
|                         if (alertparam.AlertStatus.Contains("Completed") && !alertparam.AlertStatus.Contains("Uncompleted")) |                         if (alertparam.AlertStatus.Contains("Completed") && !alertparam.AlertStatus.Contains("Uncompleted")) | ||||||
|                             assigned = 1; |                             completed = 1; | ||||||
|                         if (!alertparam.AlertStatus.Contains("Completed") && alertparam.AlertStatus.Contains("Uncompleted")) |                         if (!alertparam.AlertStatus.Contains("Completed") && alertparam.AlertStatus.Contains("Uncompleted")) | ||||||
|                             assigned = 0; |                             completed = 0; | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|                     AssetAlertGridViewItem[] assetalerts = CreateClient<WorkOrderClient>().GetAssetAlertGridViewItems(SystemParams.CompanyID, beginDate, endDate, alertparam.AlertTypes, alertparam.AssetGroups, assigned, completed, alertparam.SearchText, session.User.UID); |                     AssetAlertGridViewItem[] assetalerts = null; | ||||||
|  |                     if (alertparam.AssetID > 0) | ||||||
|  |                         assetalerts = CreateClient<WorkOrderProvider>().GetAssetAlertGridViewItemsByAsset(SystemParams.CompanyID, alertparam.AssetID, beginDate, endDate, alertparam.AlertTypes, alertparam.JobSites, assigned, completed, alertparam.SearchText, alertparam.IncludeunCompleted); | ||||||
|  |                     else | ||||||
|  |                         assetalerts = CreateClient<AlertProvider>().GetAssetAlertGridViewItems(SystemParams.CompanyID, beginDate, endDate, alertparam.AlertTypes, alertparam.AssetGroups, alertparam.JobSites, assigned, completed, alertparam.SearchText, session.User.UID, alertparam.IncludeunCompleted); | ||||||
|  |  | ||||||
|                     if (assetalerts == null || assetalerts.Length == 0) |                     if (assetalerts == null || assetalerts.Length == 0) | ||||||
|                         return new MachineInfoForAlert[0]; |                         return new MachineInfoForAlert[0]; | ||||||
| @@ -205,8 +230,8 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                             mi.InspectAlertCount += count; |                             mi.InspectAlertCount += count; | ||||||
|                         else |                         else | ||||||
|                             mi.DTCAlertCount += count; |                             mi.DTCAlertCount += count; | ||||||
|                         if (ai.AlertTime_UTC > mi.LatestAlertDateTime) |                         if (ai.AlertLocalTime > mi.LatestAlertDateTime) | ||||||
|                             mi.LatestAlertDateTime = ai.AlertTime_UTC; |                             mi.LatestAlertDateTime = ai.AlertLocalTime; | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|                     return machinealerts.ToArray(); |                     return machinealerts.ToArray(); | ||||||
| @@ -221,6 +246,53 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         private object GetPMAlertServiceDescriptions() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (GetCurrentLoginSession() != null) | ||||||
|  |                 { | ||||||
|  |                     var clientdata = Context.Request.Params["ClientData"]; | ||||||
|  |                     long[] alertids = JsonConvert.DeserializeObject<long[]>(clientdata); | ||||||
|  |  | ||||||
|  |                     return CreateClient<AlertProvider>().GetAlertServiceDescriptions(SystemParams.CompanyID, alertids); | ||||||
|  |                 } | ||||||
|  |                 return null; | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 AddLog("ERROR", "AlertsBasePage.GetPMAlertServiceDescriptions", ex.Message, ex.ToString()); | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         private AlertInfo ConvertAlertObj1(AssetAlertItem item) | ||||||
|  |         { | ||||||
|  |             AlertInfo ai = new AlertInfo(); | ||||||
|  |             ai.AlertID = item.ID; | ||||||
|  |             ai.AlertType = item.AlertType; | ||||||
|  |             ai.AlertLocalTime = item.AlertLocalTime; | ||||||
|  |             ai.Completed = item.Completed; | ||||||
|  |             ai.MachineID = item.AssetID; | ||||||
|  |             ai.Model = item.ModelName; | ||||||
|  |             ai.Make = item.MakeName; | ||||||
|  |             ai.VIN = item.VIN; | ||||||
|  |             ai.MachineName = item.AssetName; | ||||||
|  |             ai.EngineHours = item.EngineHours; | ||||||
|  |             ai.Description = item.Description; | ||||||
|  |             ai.Description = ai.FormatDescription(ai.Description); | ||||||
|  |             ai.ServiceDescription = item.ServiceDescription; | ||||||
|  |             ai.RepeatedAlerts = item.RepeatedAlerts; | ||||||
|  |             ai.AlertCount = item.RepeatedAlerts.Count + 1; | ||||||
|  |             ai.ScheduleID = item.ScheduleID; | ||||||
|  |             ai.IntervalID = item.IntervalID; | ||||||
|  |             ai.Recurring = item.Recurring; | ||||||
|  |             ai.Priority = item.Priority; | ||||||
|  |             ai.ExpectedCost = item.ExpectedCost; | ||||||
|  |  | ||||||
|  |             return ai; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         private AlertInfo ConvertAlertObj(AssetAlertGridViewItem item) |         private AlertInfo ConvertAlertObj(AssetAlertGridViewItem item) | ||||||
|         { |         { | ||||||
|             AlertInfo ai = new AlertInfo(); |             AlertInfo ai = new AlertInfo(); | ||||||
| @@ -229,6 +301,7 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|             ai.WorkOrderStatus = item.WorkOrderStatus; |             ai.WorkOrderStatus = item.WorkOrderStatus; | ||||||
|             ai.AlertType = item.AlertType; |             ai.AlertType = item.AlertType; | ||||||
|             ai.AlertTime_UTC = item.LastAlertTime; |             ai.AlertTime_UTC = item.LastAlertTime; | ||||||
|  |             ai.AlertLocalTime = item.AlertLocalTime; | ||||||
|             ai.Completed = item.Completed; |             ai.Completed = item.Completed; | ||||||
|             ai.MachineID = item.AssetID; |             ai.MachineID = item.AssetID; | ||||||
|             //ai.ModelID = item.ModelName; |             //ai.ModelID = item.ModelName; | ||||||
| @@ -240,10 +313,42 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|             ai.EngineHours = item.EngineHours; |             ai.EngineHours = item.EngineHours; | ||||||
|             ai.CurrentHours = item.CurrentEngineHours; |             ai.CurrentHours = item.CurrentEngineHours; | ||||||
|             ai.Description = item.Description; |             ai.Description = item.Description; | ||||||
|             ai.ServiceDescription = item.ServiceDescription; |             ai.Description = ai.FormatDescription(ai.Description); | ||||||
|  |             //ai.ServiceDescription = item.ServiceDescription; | ||||||
|             ai.RepeatedAlerts = item.RepeatedAlerts; |             ai.RepeatedAlerts = item.RepeatedAlerts; | ||||||
|             ai.AlertCount = item.RepeatedAlerts.Count + 1; |             ai.AlertCount = item.RepeatedAlerts.Count + 1; | ||||||
|             ai.OpenWorkOrderCount = item.OpenWorkOrderCount; |             ai.OpenWorkOrderCount = item.OpenWorkOrderCount; | ||||||
|  |             //ai.ScheduleID = item.ScheduleID; | ||||||
|  |             //ai.IntervalID = item.IntervalID; | ||||||
|  |             //ai.Recurring = item.Recurring; | ||||||
|  |             //ai.Priority = item.Priority; | ||||||
|  |             //ai.ExpectedCost = item.ExpectedCost; | ||||||
|  |  | ||||||
|  |             return ai; | ||||||
|  |         } | ||||||
|  |         private AlertInfo ConvertAlertObj2(AcknowledgedAlertItem item) | ||||||
|  |         { | ||||||
|  |             AlertInfo ai = new AlertInfo(); | ||||||
|  |             ai.AlertID = item.ID; | ||||||
|  |             ai.WorkOrderID = item.WorkOrderId; | ||||||
|  |             ai.AlertType = item.AlertType; | ||||||
|  |             ai.AlertTime_UTC = item.LastAlertTime; | ||||||
|  |             ai.AlertLocalTime = item.AlertLocalTime; | ||||||
|  |             ai.MachineID = item.AssetID; | ||||||
|  |             ai.Model = item.ModelName; | ||||||
|  |             ai.Make = item.MakeName; | ||||||
|  |             ai.VIN = item.VIN; | ||||||
|  |             ai.MachineName = item.AssetName; | ||||||
|  |             ai.EngineHours = item.EngineHours; | ||||||
|  |             ai.Description = item.Description; | ||||||
|  |             ai.Description = ai.FormatDescription(ai.Description); | ||||||
|  |             ai.RepeatedAlerts = item.RepeatedAlerts; | ||||||
|  |             ai.AlertCount = item.RepeatedAlerts.Count + 1; | ||||||
|  |             ai.OpenWorkOrderCount = item.OpenWorkOrderCount; | ||||||
|  |             ai.AcknowledgedByName = item.AcknowledgedBy; | ||||||
|  |             ai.AcknowledgedTime_UTC = item.AcknowledgedTime; | ||||||
|  |             ai.AcknowledgedTime_Local = item.AcknowledgedLocalTime; | ||||||
|  |             ai.AcknowledgedComment = item.AcknowledgedComment; | ||||||
|  |  | ||||||
|             return ai; |             return ai; | ||||||
|         } |         } | ||||||
| @@ -265,15 +370,23 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                     //    beginDate = beginDate.ToUniversalTime(); |                     //    beginDate = beginDate.ToUniversalTime(); | ||||||
|                     if (!DateTime.TryParse(alertparam.EndDate, out endDate)) |                     if (!DateTime.TryParse(alertparam.EndDate, out endDate)) | ||||||
|                         endDate = DateTime.MaxValue; |                         endDate = DateTime.MaxValue; | ||||||
|                     else |  | ||||||
|                         endDate = endDate.Date.AddDays(1).AddSeconds(-1); |  | ||||||
|  |  | ||||||
|                     alertparam.AlertStatus = new string[0]; |                     alertparam.AlertStatus = new string[0]; | ||||||
|                     AlertManager am = new AlertManager(SystemParams.DataDbConnectionString); |                     AcknowledgedAlertItem[] ackalerts = CreateClient<AlertProvider>().GetAcknowledgedAlerts(SystemParams.CompanyID, beginDate, endDate, alertparam.AlertTypes, alertparam.AssetGroups, alertparam.SearchText); | ||||||
|                     AlertInfo[] alerts = am.SearchAcknowledgedAlerts(session.SessionID, alertparam.SearchText, alertparam.AlertStatus, alertparam.AlertTypes, alertparam.AssetGroups, beginDate, endDate, session.User.UID); |                     if (ackalerts == null || ackalerts.Length == 0) | ||||||
|                     if (alerts == null) |  | ||||||
|                         return new AlertInfo[0]; |                         return new AlertInfo[0]; | ||||||
|                     return alerts.ToArray(); |                     List<AlertInfo> list = new List<AlertInfo>(); | ||||||
|  |                     foreach (AcknowledgedAlertItem item in ackalerts) | ||||||
|  |                     { | ||||||
|  |                         AlertInfo ai = ConvertAlertObj2(item); | ||||||
|  |                         list.Add(ai); | ||||||
|  |                     } | ||||||
|  |                     if (list == null) | ||||||
|  |                         return new AlertInfo[0]; | ||||||
|  |                     if (alertparam.AssetID > 0) | ||||||
|  |                         list = list.Where(m => m.MachineID == alertparam.AssetID).ToList(); | ||||||
|  |  | ||||||
|  |                     return list.ToArray(); | ||||||
|                 } |                 } | ||||||
|                 else |                 else | ||||||
|                     return new AlertInfo[0]; |                     return new AlertInfo[0]; | ||||||
| @@ -292,7 +405,7 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                 AlertsLisenceItem result = new AlertsLisenceItem(); |                 AlertsLisenceItem result = new AlertsLisenceItem(); | ||||||
|                 if (GetCurrentLoginSession() != null) |                 if (GetCurrentLoginSession() != null) | ||||||
|                 { |                 { | ||||||
|                     LicenseInfo license = SystemParams.GetLicense(); |                     Foresight.Fleet.Services.Customer.LicenseInfo license = SystemParams.GetLicense(); | ||||||
|                     if (license != null && license.Items.Count > 0) |                     if (license != null && license.Items.Count > 0) | ||||||
|                     { |                     { | ||||||
|                         var woitem = license.Items.FirstOrDefault(m => m.Key == "WorkOrder"); |                         var woitem = license.Items.FirstOrDefault(m => m.Key == "WorkOrder"); | ||||||
| @@ -314,7 +427,7 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|         { |         { | ||||||
|             try |             try | ||||||
|             { |             { | ||||||
|                 Services.Users.LoginSession se = GetCurrentLoginSession(); |                 LoginSession se = GetCurrentLoginSession(); | ||||||
|                 if (se != null) |                 if (se != null) | ||||||
|                 { |                 { | ||||||
|                     var clientdata = Request.Form["ClientData"].Split((char)170); |                     var clientdata = Request.Form["ClientData"].Split((char)170); | ||||||
| @@ -344,10 +457,17 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                     var ids = HttpUtility.HtmlDecode(clientdata[1]); |                     var ids = HttpUtility.HtmlDecode(clientdata[1]); | ||||||
|                     long workorderid = Convert.ToInt64(id); |                     long workorderid = Convert.ToInt64(id); | ||||||
|                     long[] alertids = JsonConvert.DeserializeObject<long[]>(ids); |                     long[] alertids = JsonConvert.DeserializeObject<long[]>(ids); | ||||||
|                     if (alertids != null && alertids.Length == 0) |                     if (alertids == null) | ||||||
|                         alertids = null; |                         alertids = new long[0]; | ||||||
|                     AlertManager am = new AlertManager(SystemParams.DataDbConnectionString); |  | ||||||
|                     am.AssignedAlertsToWorkOrder(workorderid, alertids); |                     var wp = CreateClient<WorkOrderProvider>(); | ||||||
|  |                     var existsalerts = wp.GetWorkOrderAlerts(SystemParams.CompanyID, workorderid).Select(a => a.ID); | ||||||
|  |                     var added = alertids.Except(existsalerts).ToArray(); | ||||||
|  |                     var deleted = existsalerts.Except(alertids).ToArray(); | ||||||
|  |                     if (added.Length > 0) | ||||||
|  |                         wp.AddOrRemoveAlertsFromWorkOrder(SystemParams.CompanyID, workorderid, added, true); | ||||||
|  |                     if (deleted.Length > 0) | ||||||
|  |                         wp.AddOrRemoveAlertsFromWorkOrder(SystemParams.CompanyID, workorderid, deleted, false); | ||||||
|                     return "OK"; |                     return "OK"; | ||||||
|                 } |                 } | ||||||
|                 else |                 else | ||||||
| @@ -359,85 +479,26 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private object GetAlertsByWorkOrder() |  | ||||||
|         { |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 if (GetCurrentLoginSession() != null) |  | ||||||
|                 { |  | ||||||
|                     var woid = Request.Form["ClientData"]; |  | ||||||
|                     long workorderid = Convert.ToInt64(woid); |  | ||||||
|                     AlertManager am = new AlertManager(SystemParams.DataDbConnectionString); |  | ||||||
|                     AlertInfo[] alerts = am.GetAlertsByWorkOrder(workorderid); |  | ||||||
|                     if (alerts == null) |  | ||||||
|                         return new AlertInfo[0]; |  | ||||||
|                     return alerts; |  | ||||||
|                 } |  | ||||||
|                 else |  | ||||||
|                     return new AlertInfo[0]; |  | ||||||
|             } |  | ||||||
|             catch (Exception ex) |  | ||||||
|             { |  | ||||||
|                 AddLog("ERROR", "AlertsBasePage.GetAlertsByWorkOrder", ex.Message, ex.ToString()); |  | ||||||
|                 return ex.Message; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         private object GetWorkOrderAlerts() |         private object GetWorkOrderAlerts() | ||||||
|         { |         { | ||||||
|             try |             try | ||||||
|             { |             { | ||||||
|                 if (GetCurrentLoginSession() != null) |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|                 { |                 { | ||||||
|                     var clientdata = Request.Form["ClientData"]; |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |  | ||||||
|                     long workorderid = 0; |                     long workorderid = 0; | ||||||
|                     long.TryParse(clientdata, out workorderid); |                     long.TryParse(clientdata, out workorderid); | ||||||
|  |  | ||||||
|                     AssetAlertItem[] alerts = CreateClient<WorkOrderClient>().GetAssignedAlerts(SystemParams.CompanyID, workorderid); |                     AlertItems items = WorkOrderManager.GetWorkOrderAlerts(workorderid, session.SessionID); | ||||||
|  |                     if (items == null) | ||||||
|  |                         return new AlertItems(); | ||||||
|  |  | ||||||
|                     AlertItems items = new AlertItems(); |  | ||||||
|                     if (alerts != null) |  | ||||||
|                     { |  | ||||||
|                         var dtcalerts = new List<AlertInfo>(); |  | ||||||
|                         var pmaalerts = new List<AlertInfo>(); |  | ||||||
|                         var inspectalerts = new List<AlertInfo>(); |  | ||||||
|                         var oilalerts = new 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); |  | ||||||
|                             } |  | ||||||
|                         } |  | ||||||
|                         items.DTCAlerts = dtcalerts.ToArray(); |  | ||||||
|                         items.PMAlerts = pmaalerts.ToArray(); |  | ||||||
|                         items.InspectAlerts = inspectalerts.ToArray(); |  | ||||||
|                         items.OilAlerts = oilalerts.ToArray(); |  | ||||||
|                     } |  | ||||||
|                     return items; |                     return items; | ||||||
|                 } |                 } | ||||||
|                 else |                 else | ||||||
|                     return new AlertInfo[0]; |                     return new AlertItems(); | ||||||
|             } |             } | ||||||
|             catch (Exception ex) |             catch (Exception ex) | ||||||
|             { |             { | ||||||
| @@ -461,7 +522,8 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|  |  | ||||||
|                     long[] alertids = JsonConvert.DeserializeObject<long[]>(ids); |                     long[] alertids = JsonConvert.DeserializeObject<long[]>(ids); | ||||||
|  |  | ||||||
|                     AssetAlertGridViewItem[] alerts = CreateClient<WorkOrderClient>().GetAssetAlertGridViewItemsByAsset(SystemParams.CompanyID, machineid, Helper.DBMinDateTime, DateTime.MaxValue, null, -1, -1, ""); |                     AssetAlertItem[] alerts = CreateClient<WorkOrderProvider>().GetNoneAssignedAlerts(SystemParams.CompanyID, machineid); | ||||||
|  |                     //AssetAlertGridViewItem[] alerts = CreateClient<WorkOrderProvider>().GetAssetAlertGridViewItemsByAsset(SystemParams.CompanyID, machineid, Helper.DBMinDateTime, DateTime.MaxValue, null, null, -1, -1, "", false); | ||||||
|                     AlertItems items = new AlertItems(); |                     AlertItems items = new AlertItems(); | ||||||
|                     if (alerts != null) |                     if (alerts != null) | ||||||
|                     { |                     { | ||||||
| @@ -469,12 +531,11 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                         var pmaalerts = new List<AlertInfo>(); |                         var pmaalerts = new List<AlertInfo>(); | ||||||
|                         var inspectalerts = new List<AlertInfo>(); |                         var inspectalerts = new List<AlertInfo>(); | ||||||
|                         var oilalerts = new List<AlertInfo>(); |                         var oilalerts = new List<AlertInfo>(); | ||||||
|                         foreach (AssetAlertGridViewItem alertitem in alerts.OrderByDescending(ai => ai.AlertTime)) |                         Dictionary<string, List<AlertInfo>> pmalertdic = new Dictionary<string, List<AlertInfo>>(); | ||||||
|  |                         foreach (var alertitem in alerts.OrderByDescending(ai => ai.AlertTime)) | ||||||
|                         { |                         { | ||||||
|                             if (alertids != null && alertids.Length > 0 && !alertids.Contains(alertitem.ID)) |                             if (alertids != null && alertids.Length > 0 && !alertids.Contains(alertitem.ID)) | ||||||
|                                 continue; |                                 continue; | ||||||
|                             if (alertitem.Completed || alertitem.Acknowledged || alertitem.WorkOrderId > 0) |  | ||||||
|                                 continue; |  | ||||||
|  |  | ||||||
|                             List<AlertInfo> tempList = null; |                             List<AlertInfo> tempList = null; | ||||||
|                             var category = DetermineAlertCategory(alertitem.AlertType); |                             var category = DetermineAlertCategory(alertitem.AlertType); | ||||||
| @@ -487,15 +548,33 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                             else |                             else | ||||||
|                                 tempList = dtcalerts; |                                 tempList = dtcalerts; | ||||||
|  |  | ||||||
|                             var a = ConvertAlertObj(alertitem); |                             var a = ConvertAlertObj1(alertitem); | ||||||
|                             a.RepeatedAlerts = alertitem.RepeatedAlerts; |                             a.RepeatedAlerts = alertitem.RepeatedAlerts; | ||||||
|                             a.AlertCount = alertitem.RepeatedAlerts.Count + 1; |                             a.AlertCount = alertitem.RepeatedAlerts.Count + 1; | ||||||
|                             tempList.Add(a); |                             tempList.Add(a); | ||||||
|  |  | ||||||
|  |                             if (category == AssetAlertCategory.PMAlert) | ||||||
|  |                             { | ||||||
|  |                                 if (!pmalertdic.ContainsKey(a.ScheduleID)) | ||||||
|  |                                     pmalertdic[a.ScheduleID] = new List<AlertInfo>(); | ||||||
|  |                                 pmalertdic[a.ScheduleID].Add(a); | ||||||
|  |                             } | ||||||
|                         } |                         } | ||||||
|                         items.DTCAlerts = dtcalerts.ToArray(); |                         items.DTCAlerts = dtcalerts.ToArray(); | ||||||
|                         items.PMAlerts = pmaalerts.ToArray(); |                         items.PMAlerts = pmaalerts.ToArray(); | ||||||
|                         items.InspectAlerts = inspectalerts.ToArray(); |                         items.InspectAlerts = inspectalerts.ToArray(); | ||||||
|                         items.OilAlerts = oilalerts.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 items; | ||||||
|                 } |                 } | ||||||
| @@ -509,6 +588,77 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         private string SaveAutoAcknowledgeAlertTypes() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 LoginSession session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|  |                 { | ||||||
|  |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |                     string[] alerttypes = JsonConvert.DeserializeObject<string[]>(clientdata); | ||||||
|  |                     CreateClient<WorkOrderProvider>().SaveAutoAcknowledgeAlertTypes(SystemParams.CompanyID, alerttypes, session.User.UID); | ||||||
|  |  | ||||||
|  |                     return "OK"; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return "Failed"; | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private object GetAutoAcknowledgeAlertTypes() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 if (GetCurrentLoginSession() != null) | ||||||
|  |                 { | ||||||
|  |                     string[] alerttypes = CreateClient<WorkOrderProvider>().GetAutoAcknowledgeAlertTypes(SystemParams.CompanyID, GetCurrentLoginSession().User.UID); | ||||||
|  |                     return alerttypes; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return new string[0]; | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 AddLog("ERROR", "AlertsBasePage.GetAutoAcknowledgeAlertTypes", ex.Message, ex.ToString()); | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private object GetAutoAcknowledgeAlertTypesHistory() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 if (GetCurrentLoginSession() != null) | ||||||
|  |                 { | ||||||
|  |                     AutoAcknowledgeItem[] items = CreateClient<WorkOrderProvider>().GetAutoAcknowledgeAlertTypesHistory(SystemParams.CompanyID, GetCurrentLoginSession().User.UID); | ||||||
|  |                     if (items == null || items.Length == 0) | ||||||
|  |                         return new AutoAcknowledgeInfo[0]; | ||||||
|  |  | ||||||
|  |                     List<AutoAcknowledgeInfo> ls = new List<AutoAcknowledgeInfo>(); | ||||||
|  |                     foreach (AutoAcknowledgeItem item in items) | ||||||
|  |                     { | ||||||
|  |                         AutoAcknowledgeInfo ai = new AutoAcknowledgeInfo(); | ||||||
|  |                         Helper.CloneProperty(ai, item); | ||||||
|  |                         ai.LocalUpdatedOn = ai.UpdatedOnLocal; | ||||||
|  |                         ls.Add(ai); | ||||||
|  |                     } | ||||||
|  |                     return ls.OrderBy(m => m.LocalUpdatedOn).ToArray(); | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return new AutoAcknowledgeInfo[0]; | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 AddLog("ERROR", "AlertsBasePage.GetAutoAcknowledgeAlertTypesHistory", ex.Message, ex.ToString()); | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|         private static readonly string[] PMALERTS = new string[] { "Preventative Maintenance" }; |         private static readonly string[] PMALERTS = new string[] { "Preventative Maintenance" }; | ||||||
|         private static readonly string[] INSPECT = new string[] { "Red-Inspect", "Yellow-Inspect", "Green-Inspect", "Info-Inspect" }; |         private static readonly string[] INSPECT = new string[] { "Red-Inspect", "Yellow-Inspect", "Green-Inspect", "Info-Inspect" }; | ||||||
|         private static readonly string[] OILSAMPLE = new string[] { "Oil Sample Result" }; |         private static readonly string[] OILSAMPLE = new string[] { "Oil Sample Result" }; | ||||||
| @@ -559,6 +709,67 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         private object GetAssignTos() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|  |                 { | ||||||
|  |                     var users = Users.UserManagement.GetActiveUsers(session.SessionID, SystemParams.CompanyID); | ||||||
|  |                     List<StringKeyValue> list = new List<StringKeyValue>(); | ||||||
|  |                     foreach (var u in users) | ||||||
|  |                     { | ||||||
|  |                         StringKeyValue kv = new StringKeyValue(); | ||||||
|  |                         kv.Key = u.IID; | ||||||
|  |                         kv.Value = u.DisplayName; | ||||||
|  |                         list.Add(kv); | ||||||
|  |                     } | ||||||
|  |  | ||||||
|  |                     list = list.OrderBy((m) => m.Value).ToList(); | ||||||
|  |                     list.Insert(0, new StringKeyValue() { Key = "1", Value = "Alert Creator" }); | ||||||
|  |                     list.Insert(1, new StringKeyValue() { Key = "2", Value = "First Assigned Contact in Managed Assets" }); | ||||||
|  |  | ||||||
|  |                     return list.ToArray(); | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return new StringKeyValue[0]; | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 AddLog("ERROR", "AlertsBasePage.GetAssignTos", ex.Message, ex.ToString()); | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         private object GetJobsites() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|  |                 { | ||||||
|  |                     JobSiteItem[] jss = CreateClient<JobSiteProvider>().GetJobSiteItems(SystemParams.CompanyID, string.Empty, false); | ||||||
|  |                     List<StringKeyValue> list = new List<StringKeyValue>(); | ||||||
|  |                     foreach (JobSiteItem js in jss) | ||||||
|  |                     { | ||||||
|  |                         StringKeyValue kv = new StringKeyValue(); | ||||||
|  |                         kv.Key = js.ID.ToString(); | ||||||
|  |                         kv.Value = js.Name; | ||||||
|  |                         list.Add(kv); | ||||||
|  |                     } | ||||||
|  |  | ||||||
|  |                     return list.OrderBy((m) => m.Value).ToArray(); | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return new StringKeyValue[0]; | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 AddLog("ERROR", "AlertsBasePage.GetAssetGroups", ex.Message, ex.ToString()); | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|         private object GetAlertTypes() |         private object GetAlertTypes() | ||||||
|         { |         { | ||||||
|             try |             try | ||||||
| @@ -578,35 +789,83 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         #region Work Order Generators | ||||||
|  |  | ||||||
|         private AlertInfo ConvertAlert(AssetAlertItem alertitem) |         private object GetWorkOrderGenerators() | ||||||
|         { |         { | ||||||
|             AlertInfo ai = new AlertInfo(); |             try | ||||||
|             ai.AlertID = alertitem.ID; |             { | ||||||
|             ai.MachineID = alertitem.AssetID; |                 if (GetCurrentLoginSession() != null) | ||||||
|             ai.AlertType = alertitem.AlertType; |                 { | ||||||
|             ai.Description = alertitem.Description; |                     WorkOrderGeneratorInfo[] generators = CreateClient<WorkOrderProvider>().GetWorkOrderGenerators(SystemParams.CompanyID); | ||||||
|             ai.AlertTime_UTC = alertitem.AlertTime; |                     if (generators == null) | ||||||
|             ai.EngineHours = alertitem.EngineHours; |                         return new WorkOrderGeneratorInfo[0]; | ||||||
|  |  | ||||||
|             return ai; |                     return generators; | ||||||
|                 } |                 } | ||||||
|  |                 else | ||||||
|  |                     return new WorkOrderGeneratorInfo[0]; | ||||||
|             } |             } | ||||||
|     public class AlertItems |             catch (Exception ex) | ||||||
|             { |             { | ||||||
|         public AlertInfo[] DTCAlerts { get; set; } |                 AddLog("ERROR", "AlertsBasePage.GetWorkOrderGenerators", ex.Message, ex.ToString()); | ||||||
|         public AlertInfo[] PMAlerts { get; set; } |                 return ex.Message; | ||||||
|         public AlertInfo[] InspectAlerts { get; set; } |  | ||||||
|         public AlertInfo[] OilAlerts { get; set; } |  | ||||||
|             } |             } | ||||||
|     public class AlertQueryParams |         } | ||||||
|  |  | ||||||
|  |         private object SaveWorkOrderGenerator() | ||||||
|         { |         { | ||||||
|         public string SearchText { get; set; } |             try | ||||||
|         public string[] AlertStatus { get; set; } |             { | ||||||
|         public string[] AssetGroups { get; set; } |                 var session = GetCurrentLoginSession(); | ||||||
|         public string[] AlertTypes { get; set; } |                 if (session != null) | ||||||
|         public string BeginDate { get; set; } |                 { | ||||||
|         public string EndDate { get; set; } |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |                     WorkOrderGeneratorInfo generator = JsonConvert.DeserializeObject<WorkOrderGeneratorInfo>(clientdata); | ||||||
|  |  | ||||||
|  |                     if (generator.Id > 0) | ||||||
|  |                     { | ||||||
|  |                         CreateClient<WorkOrderProvider>().UpdateWorkOrderGenerator(SystemParams.CompanyID, generator); | ||||||
|  |                     } | ||||||
|  |                     else | ||||||
|  |                     { | ||||||
|  |                         generator.Id = CreateClient<WorkOrderProvider>().AddNewWorkOrderGenerator(SystemParams.CompanyID, generator); | ||||||
|  |                     } | ||||||
|  |  | ||||||
|  |                     return new string[] { generator.Id.ToString(), "" }; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return "Failed"; | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private object DeleteWorkOrderGenerator() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|  |                 { | ||||||
|  |                     string id = HttpUtility.HtmlDecode(Request.Form["ClientData"]); | ||||||
|  |  | ||||||
|  |                     CreateClient<WorkOrderProvider>().DeleteWorkOrderGenerator(SystemParams.CompanyID, Convert.ToInt32(id)); | ||||||
|  |  | ||||||
|  |                     return new string[0]; | ||||||
|  |                 } | ||||||
|  |                 return "Failed"; | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |         } | ||||||
|  |         #endregion | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public class AlertsLisenceItem |     public class AlertsLisenceItem | ||||||
|   | |||||||
| @@ -6,15 +6,10 @@ using System.Threading.Tasks; | |||||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||||
| using IronIntel.Contractor.Machines; | using IronIntel.Contractor.Machines; | ||||||
| using IronIntel.Contractor.Maintenance; | using IronIntel.Contractor.Maintenance; | ||||||
| using IronIntel.Services.Business.Admin; |  | ||||||
| using System.Web; | using System.Web; | ||||||
| using IronIntel.Contractor.Users; |  | ||||||
| using Foresight.ServiceModel; | using Foresight.ServiceModel; | ||||||
| using Foresight.Fleet.Services.AssetHealth; | using Foresight.Fleet.Services.AssetHealth; | ||||||
| using Foresight.Fleet.Services.Device; |  | ||||||
| using Foresight.Fleet.Services; | using Foresight.Fleet.Services; | ||||||
| using Foresight.Fleet.Services.Attachment; |  | ||||||
| using IronIntel.Contractor.Attachment; |  | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor.Site.Maintenance | namespace IronIntel.Contractor.Site.Maintenance | ||||||
| { | { | ||||||
| @@ -89,23 +84,26 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                     var sdatestr = HttpUtility.HtmlDecode(clientdata[1]); |                     var sdatestr = HttpUtility.HtmlDecode(clientdata[1]); | ||||||
|                     var edatestr = HttpUtility.HtmlDecode(clientdata[2]); |                     var edatestr = HttpUtility.HtmlDecode(clientdata[2]); | ||||||
|                     var searchtxt = HttpUtility.HtmlDecode(clientdata[3]); |                     var searchtxt = HttpUtility.HtmlDecode(clientdata[3]); | ||||||
|  |                     long assetid = 0; | ||||||
|  |                     long.TryParse(HttpUtility.HtmlDecode(clientdata[4]), out assetid); | ||||||
|  |  | ||||||
|                     DateTime beginDate = DateTime.MinValue; |                     DateTime beginDate = Helper.DBMinDateTime; | ||||||
|                     DateTime endDate = DateTime.MaxValue; |                     DateTime endDate = DateTime.MaxValue; | ||||||
|                     if (!DateTime.TryParse(sdatestr, out beginDate)) |                     if (!DateTime.TryParse(sdatestr, out beginDate)) | ||||||
|                         beginDate = DateTime.MinValue; |                         beginDate = Helper.DBMinDateTime; | ||||||
|                     if (!DateTime.TryParse(edatestr, out endDate)) |                     if (!DateTime.TryParse(edatestr, out endDate)) | ||||||
|                         endDate = DateTime.MaxValue; |                         endDate = DateTime.MaxValue; | ||||||
|  |  | ||||||
|                     FuelRecord[] fuels = CreateClient<FuelManagementClient>().GetFuelRecords(SystemParams.CompanyID, Convert.ToInt64(type), beginDate, endDate, searchtxt); |                     FuelRecord[] fuels = CreateClient<FuelManagementClient>().GetFuelRecords(SystemParams.CompanyID, Convert.ToInt64(type), beginDate, endDate, searchtxt); | ||||||
|  |                     if (assetid > 0) | ||||||
|  |                         fuels = fuels.Where(m => m.AssetID == assetid).ToArray(); | ||||||
|  |  | ||||||
|                     List<FuelRecordInfo> list = new List<FuelRecordInfo>(); |                     List<FuelRecordInfo> list = new List<FuelRecordInfo>(); | ||||||
|                     foreach (FuelRecord fuel in fuels) |                     foreach (FuelRecord fuel in fuels) | ||||||
|                     { |                     { | ||||||
|                         FuelRecordInfo fi = new FuelRecordInfo(); |                         FuelRecordInfo fi = new FuelRecordInfo(); | ||||||
|                         Helper.CloneProperty(fi, fuel); |                         Helper.CloneProperty(fi, fuel); | ||||||
|                         //fi.TransactionDate = fi.TransactionDate.ToLocalTime(); |                         fi.TransactionLocalDate = fuel.TransactionLocalDate; | ||||||
|                         fi.TransactionDate = SystemParams.CustomerDetail.UtcToCustomerTime(fi.TransactionDate); |  | ||||||
|                         list.Add(fi); |                         list.Add(fi); | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
| @@ -140,9 +138,7 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                         FuelRecordAuditItem fi = new FuelRecordAuditItem(); |                         FuelRecordAuditItem fi = new FuelRecordAuditItem(); | ||||||
|                         Helper.CloneProperty(fi, fuel); |                         Helper.CloneProperty(fi, fuel); | ||||||
|                         //fi.TransactionDate = fi.TransactionDate.ToLocalTime();  |                         //fi.TransactionDate = fi.TransactionDate.ToLocalTime();  | ||||||
|                         fi.TransactionDate=SystemParams.CustomerDetail.UtcToCustomerTime(fi.TransactionDate); |                         fi.TransactionLocalDate = fuel.TransactionLocalDate; | ||||||
|                         fi.AddedOn = fi.AddedOn.ToLocalTime(); |  | ||||||
|                         fi.LastUpdatedOn = fi.LastUpdatedOn.ToLocalTime(); |  | ||||||
|                         list.Add(fi); |                         list.Add(fi); | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
| @@ -171,8 +167,6 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|  |  | ||||||
|                     FuelRecord record = new FuelRecord(); |                     FuelRecord record = new FuelRecord(); | ||||||
|                     Helper.CloneProperty(record, fuelrecord); |                     Helper.CloneProperty(record, fuelrecord); | ||||||
|                     //record.TransactionDate = record.TransactionDate.ToUniversalTime(); |  | ||||||
|                     record.TransactionDate = SystemParams.CustomerDetail.CustomerTimeToUtc(record.TransactionDate); |  | ||||||
|                     long fuleid = record.FuelID; |                     long fuleid = record.FuelID; | ||||||
|                     if (record.FuelID == -1) |                     if (record.FuelID == -1) | ||||||
|                     { |                     { | ||||||
| @@ -308,22 +302,21 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                 { |                 { | ||||||
|                     string fuleid = HttpUtility.HtmlDecode(Request.Form["ClientData"]); |                     string fuleid = HttpUtility.HtmlDecode(Request.Form["ClientData"]); | ||||||
|  |  | ||||||
|                     AttachmentInfo[] atts = CreateClient<AttachmentClient>().GetAttachments(SystemParams.CompanyID, "FuelRecord", fuleid); |                     AttachmentItem[] atts = CreateClient<AttachmentProvider>().GetAttachmentItems(SystemParams.CompanyID, "FuelRecord", fuleid); | ||||||
|                     if (atts == null || atts.Length <= 0) |                     if (atts == null || atts.Length <= 0) | ||||||
|                         return new AttachmentItem[0]; |                         return new AttachmentItemClient[0]; | ||||||
|  |  | ||||||
|                     List<AttachmentItem> list = new List<AttachmentItem>(); |                     List<AttachmentItemClient> list = new List<AttachmentItemClient>(); | ||||||
|                     foreach (AttachmentInfo att in atts) |                     foreach (Foresight.Fleet.Services.AttachmentItem att in atts) | ||||||
|                     { |                     { | ||||||
|                         AttachmentItem item = new AttachmentItem(); |                         AttachmentItemClient item = new AttachmentItemClient(); | ||||||
|                         Helper.CloneProperty(item, att); |                         Helper.CloneProperty(item, att); | ||||||
|                         item.AddedOn = item.AddedOn.AddHours(SystemParams.GetHoursOffset()); |  | ||||||
|                         list.Add(item); |                         list.Add(item); | ||||||
|                     } |                     } | ||||||
|                     return list.OrderBy(m => m.AddedOn).ToArray(); |                     return list.OrderBy(m => m.AddedOn).ToArray(); | ||||||
|                 } |                 } | ||||||
|                 else |                 else | ||||||
|                     return new AttachmentItem[0]; |                     return new AttachmentItemClient[0]; | ||||||
|             } |             } | ||||||
|             catch (Exception ex) |             catch (Exception ex) | ||||||
|             { |             { | ||||||
| @@ -348,15 +341,8 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                         iconfilebyte = ConvertFile2bytes(uploadFile); |                         iconfilebyte = ConvertFile2bytes(uploadFile); | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|                     AttachmentInfo attachment = new AttachmentInfo(); |                     string FileName = uploadFile == null ? "" : uploadFile.FileName; | ||||||
|                     attachment.StringID = Guid.NewGuid().ToString().ToUpper(); |                     long attid = CreateClient<AttachmentProvider>().AddAttachment(SystemParams.CompanyID, "FuelRecord", fuleid, FileName, "", iconfilebyte); | ||||||
|                     attachment.FileName = uploadFile == null ? "" : uploadFile.FileName; |  | ||||||
|                     attachment.Source = "FuelRecord"; |  | ||||||
|                     attachment.SourceID = fuleid; |  | ||||||
|                     attachment.FileData = iconfilebyte; |  | ||||||
|                     attachment.AddedByUserIID = session.User.UID; |  | ||||||
|  |  | ||||||
|                     string attid = CreateClient<AttachmentClient>().AddAttachmentLegacy(SystemParams.CompanyID, attachment); |  | ||||||
|  |  | ||||||
|                     return "OK"; |                     return "OK"; | ||||||
|                 } |                 } | ||||||
| @@ -377,7 +363,7 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                 { |                 { | ||||||
|                     string attachid = HttpUtility.HtmlDecode(Request.Form["ClientData"]); |                     string attachid = HttpUtility.HtmlDecode(Request.Form["ClientData"]); | ||||||
|  |  | ||||||
|                     CreateClient<AttachmentClient>().DeleteAttachmentLegacy(SystemParams.CompanyID, attachid, session.User.UID); |                     CreateClient<AttachmentProvider>().DeleteAttachment(SystemParams.CompanyID, long.Parse(attachid)); | ||||||
|                     return "OK"; |                     return "OK"; | ||||||
|                 } |                 } | ||||||
|                 return "Failed"; |                 return "Failed"; | ||||||
| @@ -391,4 +377,9 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|         #endregion |         #endregion | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |     public class AttachmentItemClient : AttachmentItem | ||||||
|  |     { | ||||||
|  |         public string AddedOnStr { get { return AddedOn.ToString(); } } | ||||||
|  |         public byte[] FileData { get; set; } | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,17 +1,13 @@ | |||||||
| using System; | using Foresight.Fleet.Services; | ||||||
|  | using Foresight.Fleet.Services.Asset; | ||||||
|  | using Foresight.ServiceModel; | ||||||
|  | using IronIntel.Contractor.Maintenance; | ||||||
|  | using IronIntel.Contractor.Users; | ||||||
|  | using Newtonsoft.Json; | ||||||
|  | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using System.Linq; | using System.Linq; | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
| using Newtonsoft.Json; |  | ||||||
| using IronIntel.Contractor.Machines; |  | ||||||
| using IronIntel.Contractor.Maintenance; |  | ||||||
| using IronIntel.Services.Business.Admin; |  | ||||||
| using System.Web; | using System.Web; | ||||||
| using IronIntel.Contractor.Users; |  | ||||||
| using Foresight.ServiceModel; |  | ||||||
| using Foresight.Fleet.Services.Attachment; |  | ||||||
| using IronIntel.Contractor.Attachment; |  | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor.Site.Maintenance | namespace IronIntel.Contractor.Site.Maintenance | ||||||
| { | { | ||||||
| @@ -33,9 +29,6 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                         case "GETRECORDS": |                         case "GETRECORDS": | ||||||
|                             GetRecords(); |                             GetRecords(); | ||||||
|                             break; |                             break; | ||||||
|                         case "GETMACHINES": |  | ||||||
|                             Getmachines(); |  | ||||||
|                             break; |  | ||||||
|                         case "GETMACHINEINFO": |                         case "GETMACHINEINFO": | ||||||
|                             GetmachineInfo(); |                             GetmachineInfo(); | ||||||
|                             break; |                             break; | ||||||
| @@ -91,9 +84,8 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|         { |         { | ||||||
|             string json = ""; |             string json = ""; | ||||||
|             List<KeyValuePair<int, string>> typeskeypair = new List<KeyValuePair<int, string>>(); |             List<KeyValuePair<int, string>> typeskeypair = new List<KeyValuePair<int, string>>(); | ||||||
|             MachineServiceClient2 mc = new MachineServiceClient2(SystemParams.SystemServiceAddresses[0]); |             AssetType[] types = CreateClient<AssetClassProvider>().GetAssetTypes(SystemParams.CompanyID); | ||||||
|             MachineType[] types = mc.GetMachineTypes(); |             foreach (AssetType item in types) | ||||||
|             foreach (MachineType item in types) |  | ||||||
|             { |             { | ||||||
|                 typeskeypair.Add(new KeyValuePair<int, string>(item.ID, item.Name)); |                 typeskeypair.Add(new KeyValuePair<int, string>(item.ID, item.Name)); | ||||||
|             } |             } | ||||||
| @@ -117,7 +109,17 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|             string searchtxt = HttpUtility.UrlDecode(Request.Params["searchtxt"]); |             string searchtxt = HttpUtility.UrlDecode(Request.Params["searchtxt"]); | ||||||
|             string sortype = HttpUtility.UrlDecode(Request.Params["sortype"]); |             string sortype = HttpUtility.UrlDecode(Request.Params["sortype"]); | ||||||
|             string sortdata = HttpUtility.UrlDecode(Request.Params["sortdata"]); |             string sortdata = HttpUtility.UrlDecode(Request.Params["sortdata"]); | ||||||
|             MaintenanceLogInfo[] logs = MaintenanceManagement.GetMaintenanceLog(session.SessionID, assetid, maintenanceType, string.IsNullOrWhiteSpace(mtype) ? -1 : Convert.ToInt32(mtype), searchtxt, session.User.UID); |             string sdatestr = HttpUtility.UrlDecode(Request.Params["startdate"]); | ||||||
|  |             string edatestr = HttpUtility.UrlDecode(Request.Params["enddate"]); | ||||||
|  |  | ||||||
|  |             DateTime beginDate = Helper.DBMinDateTime; | ||||||
|  |             DateTime endDate = DateTime.MaxValue; | ||||||
|  |             if (!DateTime.TryParse(sdatestr, out beginDate)) | ||||||
|  |                 beginDate = Helper.DBMinDateTime; | ||||||
|  |             if (!DateTime.TryParse(edatestr, out endDate)) | ||||||
|  |                 endDate = DateTime.MaxValue; | ||||||
|  |  | ||||||
|  |             MaintenanceLogInfo[] logs = MaintenanceManagement.GetMaintenanceLog(session.SessionID, assetid, maintenanceType, string.IsNullOrWhiteSpace(mtype) ? -1 : Convert.ToInt32(mtype), searchtxt, beginDate, endDate, session.User.UID); | ||||||
|  |  | ||||||
|             if (!string.IsNullOrWhiteSpace(sortype)) |             if (!string.IsNullOrWhiteSpace(sortype)) | ||||||
|             { |             { | ||||||
| @@ -190,19 +192,19 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|             string json = ""; |             string json = ""; | ||||||
|             long mid = -1; |             long mid = -1; | ||||||
|             long.TryParse(Request.Params["machineID"].ToString(), out mid); |             long.TryParse(Request.Params["machineID"].ToString(), out mid); | ||||||
|             MaintenanceMachineInfo machine = MaintenanceManagement.GetmachineByMachineID(mid); |             AssetBasicInfo asset = CreateClient<AssetQueryClient>().GetAssetBasicInfoByID(SystemParams.CompanyID, mid); | ||||||
|             json += JsonConvert.SerializeObject(machine); |  | ||||||
|             Response.Write(json); |             MaintenanceMachineInfo mi = new MaintenanceMachineInfo(); | ||||||
|             Response.End(); |             mi.MachineID = asset.ID; | ||||||
|         } |             mi.MachineName = asset.Name; | ||||||
|         private void Getmachines() |             mi.MachineName2 = asset.Name2; | ||||||
|         { |             mi.VIN = asset.VIN; | ||||||
|             var session = GetCurrentLoginSession(); |             mi.EngineHours = asset.EngineHours == null ? 0 : asset.EngineHours.Value; | ||||||
|             string json = ""; |             mi.Make = asset.MakeName; | ||||||
|             string mtype = Request.Params["type"]; |             mi.Model = asset.ModelName; | ||||||
|             string searchtxt = HttpUtility.UrlDecode(Request.Params["searchtxt"]); |             mi.TypeID = asset.TypeID; | ||||||
|             MaintenanceMachineInfo[] machines = MaintenanceManagement.GetMaintenanceMachines(session.SessionID, string.IsNullOrWhiteSpace(mtype) ? -1 : Convert.ToInt32(mtype), searchtxt, session.User.UID).OrderBy(t => t.VIN).ToArray(); |             mi.MachineType = asset.TypeName; | ||||||
|             json += JsonConvert.SerializeObject(machines); |             json += JsonConvert.SerializeObject(mi); | ||||||
|             Response.Write(json); |             Response.Write(json); | ||||||
|             Response.End(); |             Response.End(); | ||||||
|         } |         } | ||||||
| @@ -211,7 +213,7 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|             var session = GetCurrentLoginSession(); |             var session = GetCurrentLoginSession(); | ||||||
|             string json = ""; |             string json = ""; | ||||||
|             string mtype = Request.Params["type"]; |             string mtype = Request.Params["type"]; | ||||||
|             string searchtxt = HttpUtility.UrlDecode(Request.Params["searchtxt"]); |             string searchtxt = HttpUtility.HtmlDecode(Request.Params["searchtxt"]); | ||||||
|  |  | ||||||
|             MaintenanceMachineInfo[] machines = MaintenanceManagement.GetMaintenanceMachines(session.SessionID, string.IsNullOrWhiteSpace(mtype) ? -1 : Convert.ToInt32(mtype), searchtxt, session.User.UID); |             MaintenanceMachineInfo[] machines = MaintenanceManagement.GetMaintenanceMachines(session.SessionID, string.IsNullOrWhiteSpace(mtype) ? -1 : Convert.ToInt32(mtype), searchtxt, session.User.UID); | ||||||
|             if (machines.Length > 0) |             if (machines.Length > 0) | ||||||
| @@ -230,6 +232,7 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                 if (u != null) |                 if (u != null) | ||||||
|                 { |                 { | ||||||
|                     var clientdata = Request.Form["ClientData"]; |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |                     clientdata = HttpUtility.HtmlDecode(clientdata); | ||||||
|                     MaintenanceLogInfo m = JsonConvert.DeserializeObject<MaintenanceLogInfo>(clientdata); |                     MaintenanceLogInfo m = JsonConvert.DeserializeObject<MaintenanceLogInfo>(clientdata); | ||||||
|  |  | ||||||
|                     MaintenanceLogInfo oldinfo = null; |                     MaintenanceLogInfo oldinfo = null; | ||||||
| @@ -247,7 +250,7 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                     oldinfo.MaintenanceHours = m.MaintenanceHours; |                     oldinfo.MaintenanceHours = m.MaintenanceHours; | ||||||
|                     oldinfo.ODOMeter = m.ODOMeter; |                     oldinfo.ODOMeter = m.ODOMeter; | ||||||
|                     oldinfo.ODOMemterUOM = m.ODOMemterUOM; |                     oldinfo.ODOMemterUOM = m.ODOMemterUOM; | ||||||
|                     oldinfo.Notes = HttpUtility.UrlDecode(m.Notes); |                     oldinfo.Notes = HttpUtility.HtmlDecode(m.Notes); | ||||||
|                     oldinfo.LogType = m.LogType; |                     oldinfo.LogType = m.LogType; | ||||||
|                     oldinfo.Cost = m.Cost; |                     oldinfo.Cost = m.Cost; | ||||||
|                     oldinfo.InvoiceNumber = m.InvoiceNumber; |                     oldinfo.InvoiceNumber = m.InvoiceNumber; | ||||||
| @@ -371,16 +374,15 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                     var clientdata = Request.Form["ClientData"].Split((char)170); |                     var clientdata = Request.Form["ClientData"].Split((char)170); | ||||||
|                     var woid = HttpUtility.HtmlDecode(clientdata[0]); |                     var woid = HttpUtility.HtmlDecode(clientdata[0]); | ||||||
|  |  | ||||||
|                     AttachmentInfo[] atts = CreateClient<AttachmentClient>().GetAttachments(SystemParams.CompanyID, "MaintenanceLog", woid); |                     AttachmentItem[] atts = CreateClient<AttachmentProvider>().GetAttachmentItems(SystemParams.CompanyID, "MaintenanceLog", woid); | ||||||
|                     if (atts == null || atts.Length <= 0) |                     if (atts == null || atts.Length <= 0) | ||||||
|                         return new AttachmentItem[0]; |                         return new AttachmentItem[0]; | ||||||
|  |  | ||||||
|                     List<AttachmentItem> list = new List<AttachmentItem>(); |                     List<AttachmentItem> list = new List<AttachmentItem>(); | ||||||
|                     foreach (AttachmentInfo att in atts) |                     foreach (AttachmentItem att in atts) | ||||||
|                     { |                     { | ||||||
|                         AttachmentItem item = new AttachmentItem(); |                         AttachmentItem item = new AttachmentItem(); | ||||||
|                         Helper.CloneProperty(item, att); |                         Helper.CloneProperty(item, att); | ||||||
|                         item.AddedOn = item.AddedOn.ToLocalTime(); |  | ||||||
|                         list.Add(item); |                         list.Add(item); | ||||||
|                     } |                     } | ||||||
|                     return list.OrderBy(m => m.AddedOn).ToArray(); |                     return list.OrderBy(m => m.AddedOn).ToArray(); | ||||||
| @@ -411,15 +413,8 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                         iconfilebyte = ConvertFile2bytes(uploadFile); |                         iconfilebyte = ConvertFile2bytes(uploadFile); | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|                     AttachmentInfo attachment = new AttachmentInfo(); |                     string FileName = uploadFile == null ? "" : uploadFile.FileName; | ||||||
|                     attachment.StringID = Guid.NewGuid().ToString().ToUpper(); |                     long attid = CreateClient<AttachmentProvider>().AddAttachment(SystemParams.CompanyID, "MaintenanceLog", woid, FileName, "", iconfilebyte); | ||||||
|                     attachment.FileName = uploadFile == null ? "" : uploadFile.FileName; |  | ||||||
|                     attachment.Source = "MaintenanceLog"; |  | ||||||
|                     attachment.SourceID = woid; |  | ||||||
|                     attachment.FileData = iconfilebyte; |  | ||||||
|                     attachment.AddedByUserIID = session.User.UID; |  | ||||||
|  |  | ||||||
|                     string attid = CreateClient<AttachmentClient>().AddAttachmentLegacy(SystemParams.CompanyID, attachment); |  | ||||||
|  |  | ||||||
|                     return "OK"; |                     return "OK"; | ||||||
|                 } |                 } | ||||||
| @@ -440,7 +435,7 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                 { |                 { | ||||||
|                     string attachid = HttpUtility.HtmlDecode(Request.Form["ClientData"]); |                     string attachid = HttpUtility.HtmlDecode(Request.Form["ClientData"]); | ||||||
|  |  | ||||||
|                     CreateClient<AttachmentClient>().DeleteAttachmentLegacy(SystemParams.CompanyID, attachid, session.User.UID); |                     CreateClient<AttachmentProvider>().DeleteAttachment(SystemParams.CompanyID, long.Parse(attachid)); | ||||||
|                     return "OK"; |                     return "OK"; | ||||||
|                 } |                 } | ||||||
|                 return "Failed"; |                 return "Failed"; | ||||||
|   | |||||||
| @@ -1,6 +1,5 @@ | |||||||
| using Foresight.Fleet.Services.User; | using Foresight.Fleet.Services.User; | ||||||
| using Foresight.ServiceModel; | using Foresight.ServiceModel; | ||||||
| using IronIntel.Services; |  | ||||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| @@ -8,6 +7,7 @@ using System.Linq; | |||||||
| using System.Text; | using System.Text; | ||||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||||
|  |  | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor.Site.Maintenance | namespace IronIntel.Contractor.Site.Maintenance | ||||||
| { | { | ||||||
|     public class MaintenanceBasePage : ContractorBasePage |     public class MaintenanceBasePage : ContractorBasePage | ||||||
| @@ -33,20 +33,22 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|         private MaintenanceNavigateItem[] GetNavigations() |         private MaintenanceNavigateItem[] GetNavigations() | ||||||
|         { |         { | ||||||
|             List<MaintenanceNavigateItem> list = GetNavigateItems(); |             List<MaintenanceNavigateItem> list = GetNavigateItems(); | ||||||
|             LicenseInfo license = SystemParams.GetLicense(); |             Foresight.Fleet.Services.Customer.LicenseInfo license = SystemParams.GetLicense(); | ||||||
|             if (license != null && license.Items.Count > 0) |             if (license != null && license.Items.Count > 0) | ||||||
|             { |             { | ||||||
|                 var alitem = license.Items.FirstOrDefault(m => m.Key == "AlertsManagement"); |  | ||||||
|                 if (alitem == null || !Helper.IsTrue(alitem.Value)) |  | ||||||
|                 { |  | ||||||
|                     MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_alertsmanagement"); |  | ||||||
|                     list.Remove(item); |  | ||||||
|                 } |  | ||||||
|                 var woitem = license.Items.FirstOrDefault(m => m.Key == "WorkOrder"); |                 var woitem = license.Items.FirstOrDefault(m => m.Key == "WorkOrder"); | ||||||
|                 if (woitem == null || !Helper.IsTrue(woitem.Value)) |                 if (woitem == null || !Helper.IsTrue(woitem.Value)) | ||||||
|                 { |                 { | ||||||
|                     MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_workorder"); |                     MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_workorder"); | ||||||
|                     list.Remove(item); |                     list.Remove(item); | ||||||
|  |                     item = list.FirstOrDefault(m => m.ID == "nav_workorderhis"); | ||||||
|  |                     list.Remove(item); | ||||||
|  |                 } | ||||||
|  |                 var alitem = license.Items.FirstOrDefault(m => m.Key == "AlertsManagement"); | ||||||
|  |                 if (alitem == null || !Helper.IsTrue(alitem.Value)) | ||||||
|  |                 { | ||||||
|  |                     MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_alertsmanagement"); | ||||||
|  |                     list.Remove(item); | ||||||
|                 } |                 } | ||||||
|                 var fuelitem = license.Items.FirstOrDefault(m => m.Key == "FuelRecords"); |                 var fuelitem = license.Items.FirstOrDefault(m => m.Key == "FuelRecords"); | ||||||
|                 if (fuelitem == null || !Helper.IsTrue(fuelitem.Value)) |                 if (fuelitem == null || !Helper.IsTrue(fuelitem.Value)) | ||||||
| @@ -54,42 +56,66 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                     MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_fuelrecord"); |                     MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_fuelrecord"); | ||||||
|                     list.Remove(item); |                     list.Remove(item); | ||||||
|                 } |                 } | ||||||
|  |                 var critem = license.Items.FirstOrDefault(m => m.Key == "CustomerRecord"); | ||||||
|  |                 if (critem == null || !Helper.IsTrue(critem.Value)) | ||||||
|  |                 { | ||||||
|  |                     MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_customerrecord"); | ||||||
|  |                     list.Remove(item); | ||||||
|  |                     item = list.FirstOrDefault(m => m.ID == "nav_customersatisfactionsurveys"); | ||||||
|  |                     list.Remove(item); | ||||||
|  |                     item = list.FirstOrDefault(m => m.ID == "nav_surveymanagementresult"); | ||||||
|  |                     list.Remove(item); | ||||||
|  |                     item = list.FirstOrDefault(m => m.ID == "nav_wosurveytemplate"); | ||||||
|  |                     list.Remove(item); | ||||||
|  |                     item = list.FirstOrDefault(m => m.ID == "nav_wosurveytemplatereport"); | ||||||
|  |                     list.Remove(item); | ||||||
|  |                 } | ||||||
|  |                 var pmitem = license.Items.FirstOrDefault(m => m.Key == "PreventativeMaintenance"); | ||||||
|  |                 if (pmitem == null || !Helper.IsTrue(pmitem.Value)) | ||||||
|  |                 { | ||||||
|  |                     MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_maintenanceschedule"); | ||||||
|  |                     list.Remove(item); | ||||||
|  |                 } | ||||||
|  |                 var mritem = license.Items.FirstOrDefault(m => m.Key == "MaintenanceRecord"); | ||||||
|  |                 if (mritem == null || !Helper.IsTrue(mritem.Value)) | ||||||
|  |                 { | ||||||
|  |                     MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_record"); | ||||||
|  |                     list.Remove(item); | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             var user = GetCurrentUser(); |             var user = GetCurrentUser(); | ||||||
|             if (user.UserType == Users.UserTypes.Common) |             if (user.UserType == Users.UserTypes.Common) | ||||||
|             { |             { | ||||||
|                 var client = FleetServiceClientHelper.CreateClient<PermissionProvider>(); |                 var client = CreateClient<PermissionProvider>(); | ||||||
|                 Tuple<Feature, Permissions>[] pmss = client.GetUserPermissions(SystemParams.CompanyID, user.IID); |                 Tuple<Feature, Permissions>[] pmss = client.GetUserPermissions(SystemParams.CompanyID, user.IID); | ||||||
|                 if (pmss.Length > 0) |                 if (pmss.Length > 0) | ||||||
|                 { |                 { | ||||||
|                     Tuple<Feature, Permissions> alertpm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.ALERTS_MANAGEMENT); |  | ||||||
|                     if (alertpm == null) |  | ||||||
|                     { |  | ||||||
|                         MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_alertsmanagement"); |  | ||||||
|                         list.Remove(item); |  | ||||||
|                     } |  | ||||||
|                     Tuple<Feature, Permissions> wopm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.WORK_ORDER); |                     Tuple<Feature, Permissions> wopm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.WORK_ORDER); | ||||||
|                     if (wopm == null) |                     if (wopm == null) | ||||||
|                     { |                     { | ||||||
|                         MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_workorder"); |                         MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_workorder"); | ||||||
|                         list.Remove(item); |                         list.Remove(item); | ||||||
|                     } |                     } | ||||||
|  |                     Tuple<Feature, Permissions> wohispm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.WORKORDERHISTORY); | ||||||
|  |                     if (wohispm == null) | ||||||
|  |                     { | ||||||
|  |                         MaintenanceNavigateItem itemhis = list.FirstOrDefault(m => m.ID == "nav_workorderhis"); | ||||||
|  |                         list.Remove(itemhis); | ||||||
|  |                     } | ||||||
|  |                     Tuple<Feature, Permissions> alertpm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.ALERTS_MANAGEMENT); | ||||||
|  |                     if (alertpm == null) | ||||||
|  |                     { | ||||||
|  |                         MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_alertsmanagement"); | ||||||
|  |                         list.Remove(item); | ||||||
|  |                     } | ||||||
|                     Tuple<Feature, Permissions> pmpm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.PREVENTATIVE_MAINTENANCE); |                     Tuple<Feature, Permissions> pmpm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.PREVENTATIVE_MAINTENANCE); | ||||||
|                     if (pmpm == null) |                     if (pmpm == null) | ||||||
|                     { |                     { | ||||||
|                         MaintenanceNavigateItem item1 = list.FirstOrDefault(m => m.ID == "nav_preventative"); |                         MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_maintenanceschedule"); | ||||||
|                         list.Remove(item1); |                         list.Remove(item); | ||||||
|                         MaintenanceNavigateItem item2 = list.FirstOrDefault(m => m.ID == "nav_timebased"); |                         item = list.FirstOrDefault(m => m.ID == "nav_record"); | ||||||
|                         list.Remove(item2); |                         list.Remove(item); | ||||||
|                         MaintenanceNavigateItem item3 = list.FirstOrDefault(m => m.ID == "nav_hours"); |  | ||||||
|                         list.Remove(item3); |  | ||||||
|                         MaintenanceNavigateItem item4 = list.FirstOrDefault(m => m.ID == "nav_absolutedistance"); |  | ||||||
|                         list.Remove(item4); |  | ||||||
|                         MaintenanceNavigateItem item5 = list.FirstOrDefault(m => m.ID == "nav_relativedistance"); |  | ||||||
|                         list.Remove(item5); |  | ||||||
|                         MaintenanceNavigateItem item6 = list.FirstOrDefault(m => m.ID == "nav_record"); |  | ||||||
|                         list.Remove(item6); |  | ||||||
|                     } |                     } | ||||||
|                     Tuple<Feature, Permissions> fuelpm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.FUEL_RECORDS); |                     Tuple<Feature, Permissions> fuelpm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.FUEL_RECORDS); | ||||||
|                     if (fuelpm == null) |                     if (fuelpm == null) | ||||||
| @@ -97,9 +123,29 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                         MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_fuelrecord"); |                         MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_fuelrecord"); | ||||||
|                         list.Remove(item); |                         list.Remove(item); | ||||||
|                     } |                     } | ||||||
|  |                     Tuple<Feature, Permissions> crpm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.CUSTOMER_RECORD); | ||||||
|  |                     if (crpm == null) | ||||||
|  |                     { | ||||||
|  |                         MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_customerrecord"); | ||||||
|  |                         list.Remove(item); | ||||||
|                     } |                     } | ||||||
|  |                     Tuple<Feature, Permissions> wosurpm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.WORKORDERSURVEYS); | ||||||
|  |                     if (crpm == null || wosurpm == null) | ||||||
|  |                     { | ||||||
|  |                         MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_customersatisfactionsurveys"); | ||||||
|  |                         list.Remove(item); | ||||||
|  |                         item = list.FirstOrDefault(m => m.ID == "nav_surveymanagementresult"); | ||||||
|  |                         list.Remove(item); | ||||||
|  |                         item = list.FirstOrDefault(m => m.ID == "nav_wosurveytemplate"); | ||||||
|  |                         list.Remove(item); | ||||||
|  |                         item = list.FirstOrDefault(m => m.ID == "nav_wosurveytemplatereport"); | ||||||
|  |                         list.Remove(item); | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             else if (user.UserType == Users.UserTypes.Readonly) | ||||||
|  |                 list.Clear(); | ||||||
|  |  | ||||||
|             } |  | ||||||
|             return list.ToArray(); |             return list.ToArray(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -108,68 +154,80 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|         { |         { | ||||||
|             List<MaintenanceNavigateItem> list = new List<MaintenanceNavigateItem>(); |             List<MaintenanceNavigateItem> list = new List<MaintenanceNavigateItem>(); | ||||||
|  |  | ||||||
|  |             MaintenanceNavigateItem item2 = new MaintenanceNavigateItem(); | ||||||
|  |             item2.ID = "nav_workorder"; | ||||||
|  |             item2.Title = "Work Order"; | ||||||
|  |             item2.Url = "WorkOrderMaintenance.aspx"; | ||||||
|  |             item2.IconPath = "img/workorder.png"; | ||||||
|  |             list.Add(item2); | ||||||
|  |  | ||||||
|  |             MaintenanceNavigateItem itemhis = new MaintenanceNavigateItem(); | ||||||
|  |             itemhis.ID = "nav_workorderhis"; | ||||||
|  |             itemhis.Title = "Work Order History"; | ||||||
|  |             itemhis.Url = "WorkOrderHistory.aspx"; | ||||||
|  |             itemhis.IconPath = "img/workorder.png"; | ||||||
|  |             list.Add(itemhis); | ||||||
|  |  | ||||||
|             MaintenanceNavigateItem item1 = new MaintenanceNavigateItem(); |             MaintenanceNavigateItem item1 = new MaintenanceNavigateItem(); | ||||||
|             item1.ID = "nav_alertsmanagement"; |             item1.ID = "nav_alertsmanagement"; | ||||||
|             item1.Title = "Alerts Management  **New**"; |             item1.Title = "Alerts Management"; | ||||||
|             item1.Url = "AlertsManagement.aspx"; |             item1.Url = "AlertsManagement.aspx"; | ||||||
|             item1.IconPath = "img/alert.png"; |             item1.IconPath = "img/alert.png"; | ||||||
|             list.Add(item1); |             list.Add(item1); | ||||||
|  |  | ||||||
|             MaintenanceNavigateItem item6 = new MaintenanceNavigateItem(); |  | ||||||
|             item6.ID = "nav_workorder"; |  | ||||||
|             item6.Title = "Work Order  **New**"; |  | ||||||
|             item6.Url = "WorkOrderMaintenance.aspx"; |  | ||||||
|             item6.IconPath = "img/workorder.png"; |  | ||||||
|             list.Add(item6); |  | ||||||
|  |  | ||||||
|             MaintenanceNavigateItem item3 = new MaintenanceNavigateItem(); |             MaintenanceNavigateItem item3 = new MaintenanceNavigateItem(); | ||||||
|             item3.ID = "nav_preventative"; |             item3.ID = "nav_maintenanceschedule"; | ||||||
|             item3.Title = "Absolute Hours Maintenance"; |             item3.Title = "Maintenance Schedules"; | ||||||
|             item3.Url = "PreventativeMaintenance.aspx"; |             item3.Url = "MaintenanceSchedulesManagement.aspx"; | ||||||
|             item3.IconPath = "img/preventative.png"; |             item3.IconPath = "img/preventative.png"; | ||||||
|             list.Add(item3); |             list.Add(item3); | ||||||
|  |  | ||||||
|             MaintenanceNavigateItem item4 = new MaintenanceNavigateItem(); |             MaintenanceNavigateItem item4 = new MaintenanceNavigateItem(); | ||||||
|             item4.ID = "nav_timebased"; |             item4.ID = "nav_record"; | ||||||
|             item4.Title = "Relative Time Maintenance"; |             item4.Title = "Maintenance Record"; | ||||||
|             item4.Url = "TimeBasedMaintenance.aspx"; |             item4.Url = "MaintanceRecordsManagement.aspx"; | ||||||
|             item4.IconPath = "img/timebased.png"; |             item4.IconPath = "img/record.png"; | ||||||
|             list.Add(item4); |             list.Add(item4); | ||||||
|  |  | ||||||
|             MaintenanceNavigateItem item7 = new MaintenanceNavigateItem(); |  | ||||||
|             item7.ID = "nav_hours"; |  | ||||||
|             item7.Title = "Relative Hours Maintenance"; |  | ||||||
|             item7.Url = "HoursMaintenance.aspx"; |  | ||||||
|             item7.IconPath = "img/hours.png"; |  | ||||||
|             list.Add(item7); |  | ||||||
|  |  | ||||||
|             MaintenanceNavigateItem item5 = new MaintenanceNavigateItem(); |             MaintenanceNavigateItem item5 = new MaintenanceNavigateItem(); | ||||||
|             item5.ID = "nav_absolutedistance"; |             item5.ID = "nav_fuelrecord"; | ||||||
|             item5.Title = "Absolute Distance Maintenance"; |             item5.Title = "Fuel Records"; | ||||||
|             item5.Url = "AbsoluteDistanceMaintenance.aspx"; |             item5.Url = "FuelRecordManagement.aspx"; | ||||||
|             item5.IconPath = "img/preventative.png"; |             item5.IconPath = "img/fuelrecord.png"; | ||||||
|             list.Add(item5); |             list.Add(item5); | ||||||
|  |  | ||||||
|  |             MaintenanceNavigateItem item6 = new MaintenanceNavigateItem(); | ||||||
|  |             item6.ID = "nav_customerrecord"; | ||||||
|  |             item6.Title = "Customer Record"; | ||||||
|  |             item6.Url = "CustomerRecordManagement.aspx"; | ||||||
|  |             item6.IconPath = "img/customerrecord.png"; | ||||||
|  |             list.Add(item6); | ||||||
|  |  | ||||||
|  |             MaintenanceNavigateItem item7 = new MaintenanceNavigateItem(); | ||||||
|  |             item7.ID = "nav_customersatisfactionsurveys"; | ||||||
|  |             item7.Title = "Customer Satisfaction Surveys"; | ||||||
|  |             //item7.Url = "SurveyTemplateManagement.aspx"; | ||||||
|  |             item7.IconPath = "img/customerrecord.png"; | ||||||
|  |             list.Add(item7); | ||||||
|  |  | ||||||
|             MaintenanceNavigateItem item8 = new MaintenanceNavigateItem(); |             MaintenanceNavigateItem item8 = new MaintenanceNavigateItem(); | ||||||
|             item8.ID = "nav_relativedistance"; |             item8.ID = "nav_surveymanagementresult"; | ||||||
|             item8.Title = "Relative Distance Maintenance"; |             item8.Title = "Survey Management/Result"; | ||||||
|             item8.Url = "RelativeDistanceMaintenance.aspx"; |             item8.Url = "SurveyManagement.aspx"; | ||||||
|             item8.IconPath = "img/hours.png"; |  | ||||||
|             list.Add(item8); |             list.Add(item8); | ||||||
|  |  | ||||||
|             MaintenanceNavigateItem item2 = new MaintenanceNavigateItem(); |  | ||||||
|             item2.ID = "nav_record"; |  | ||||||
|             item2.Title = "Maintenance Record  **Legacy**"; |  | ||||||
|             item2.Url = "MaintanceRecordsManagement.aspx"; |  | ||||||
|             item2.IconPath = "img/record.png"; |  | ||||||
|             list.Add(item2); |  | ||||||
|  |  | ||||||
|             MaintenanceNavigateItem item9 = new MaintenanceNavigateItem(); |             MaintenanceNavigateItem item9 = new MaintenanceNavigateItem(); | ||||||
|             item9.ID = "nav_fuelrecord"; |             item9.ID = "nav_wosurveytemplate"; | ||||||
|             item9.Title = "Fuel Records"; |             item9.Title = "Templates"; | ||||||
|             item9.Url = "FuelRecordManagement.aspx"; |             item9.Url = "SurveyTemplateManagement.aspx"; | ||||||
|             item9.IconPath = "img/fuelrecord.png"; |  | ||||||
|             list.Add(item9); |             list.Add(item9); | ||||||
|  |  | ||||||
|  |             MaintenanceNavigateItem item10 = new MaintenanceNavigateItem(); | ||||||
|  |             item10.ID = "nav_wosurveytemplatereport"; | ||||||
|  |             item10.Title = "Reports"; | ||||||
|  |             item10.Url = "SurveyTemplateReport.aspx"; | ||||||
|  |             list.Add(item10); | ||||||
|  |  | ||||||
|             return list; |             return list; | ||||||
|         } |         } | ||||||
|         public class MaintenanceNavigateItem |         public class MaintenanceNavigateItem | ||||||
|   | |||||||
| @@ -1,26 +0,0 @@ | |||||||
| using IronIntel.Contractor.Maintenance; |  | ||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor.Site.Maintenance |  | ||||||
| { |  | ||||||
|     public class ScheduleSaveArgs |  | ||||||
|     { |  | ||||||
|         public string IID { get; set; } |  | ||||||
|         public string Name { get; set; } |  | ||||||
|         public string ScheduleUom { get; set; } |  | ||||||
|         public string Type { get; set; } |  | ||||||
|         public string Notes { get; set; } |  | ||||||
|  |  | ||||||
|         public PmIntervalItem[] Intervals { get; set; } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public class ScheduleMachineArgs |  | ||||||
|     { |  | ||||||
|         public string IID { get; set; } |  | ||||||
|         public MaintenanceMachineInfo[] Machines { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -1,7 +1,7 @@ | |||||||
| using Foresight.Fleet.Services.AssetHealth; | using Foresight.Fleet.Services.Asset; | ||||||
|  | using Foresight.Fleet.Services.AssetHealth; | ||||||
| using IronIntel.Contractor.Machines; | using IronIntel.Contractor.Machines; | ||||||
| using IronIntel.Contractor.Maintenance; | using IronIntel.Contractor.Maintenance; | ||||||
| using IronIntel.Services.Business.Admin; |  | ||||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| @@ -69,6 +69,9 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                         case "GETPMSCHEDULEBYID": |                         case "GETPMSCHEDULEBYID": | ||||||
|                             result = GetPMScheduleByID(); |                             result = GetPMScheduleByID(); | ||||||
|                             break; |                             break; | ||||||
|  |                         case "GETMAINTENANCESCHEDULES": | ||||||
|  |                             result = GetMaintenanceSchedules(); | ||||||
|  |                             break; | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| @@ -116,7 +119,7 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                     if (string.IsNullOrWhiteSpace(pmtype)) |                     if (string.IsNullOrWhiteSpace(pmtype)) | ||||||
|                         pmtype = "PM"; |                         pmtype = "PM"; | ||||||
|  |  | ||||||
|                     return MaintenanceManagement.GetPmSchedule(session.SessionID, pmtype); |                     return MaintenanceManagement.GetPmSchedule(session.SessionID, pmtype, string.Empty, string.Empty); | ||||||
|                 } |                 } | ||||||
|                 else |                 else | ||||||
|                     return new PmScheduleInfo[0]; |                     return new PmScheduleInfo[0]; | ||||||
| @@ -127,6 +130,32 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                 return ex.Message; |                 return ex.Message; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         private object GetMaintenanceSchedules() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|  |                 { | ||||||
|  |                     var clientdata = Request.Form["ClientData"]; | ||||||
|  |                     string[] param = JsonConvert.DeserializeObject<string[]>(clientdata); | ||||||
|  |                     var pmtype = param[0]; | ||||||
|  |                     var pmid = param[1]; | ||||||
|  |                     var filter = HttpUtility.HtmlDecode(param[2]); | ||||||
|  |  | ||||||
|  |                     return MaintenanceManagement.GetPmSchedule(session.SessionID, pmtype, pmid, filter); | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return new PmScheduleInfo[0]; | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 AddLog("ERROR", "PreventativeMaintenanceBasePage.GetPmSchedule", ex.Message, ex.ToString()); | ||||||
|  |                 return ex.Message; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|         private object GetPMScheduleByID() |         private object GetPMScheduleByID() | ||||||
|         { |         { | ||||||
|             try |             try | ||||||
| @@ -316,17 +345,7 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|             var s = Request.Form["ClientData"]; |             var s = Request.Form["ClientData"]; | ||||||
|             var type = JsonConvert.DeserializeObject<MachineItem>(s); |             var type = JsonConvert.DeserializeObject<MachineItem>(s); | ||||||
|  |  | ||||||
|             //MaintenanceMachineInfo[] selected; |             var machines = MaintenanceManagement.GetMaintenanceMachines(session.SessionID, (int)type.MachineID, type.Name, session.User.UID) | ||||||
|             //if (!string.IsNullOrWhiteSpace(type.VIN)) |  | ||||||
|             //{ |  | ||||||
|             //    selected = MaintenanceManagement.GetPmMachinesByScheduleId(type.VIN); |  | ||||||
|             //} |  | ||||||
|             //else |  | ||||||
|             //{ |  | ||||||
|             //    selected = new MaintenanceMachineInfo[0]; |  | ||||||
|             //} |  | ||||||
|  |  | ||||||
|             var machines = MaintenanceManagement.GetMaintenanceMachines1(session.SessionID, (int)type.MachineID, type.Name, session.User.UID) |  | ||||||
|                 //.Where(m => !selected.Any(t => t.MachineID == m.MachineID)) |                 //.Where(m => !selected.Any(t => t.MachineID == m.MachineID)) | ||||||
|                 .OrderBy(m => m.VIN) |                 .OrderBy(m => m.VIN) | ||||||
|                 .ToArray(); |                 .ToArray(); | ||||||
| @@ -335,10 +354,21 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         private PMAssetItem[] GetSelectedMachines() |         private PMAssetItem[] GetSelectedMachines() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|                 { |                 { | ||||||
|                     var iid = Request.Form["ClientData"]; |                     var iid = Request.Form["ClientData"]; | ||||||
|                     List<PMAssetItem> result = new List<PMAssetItem>(); |                     List<PMAssetItem> result = new List<PMAssetItem>(); | ||||||
|                     var assets = CreateClient<PMClient>().GetPMAssets(SystemParams.CompanyID, iid); |                     var assets = CreateClient<PMClient>().GetPMAssets(SystemParams.CompanyID, iid); | ||||||
|  |                     if (session.User.UserType < Foresight.Fleet.Services.User.UserTypes.Admin) | ||||||
|  |                     { | ||||||
|  |                         AssetBasicInfo[] allassets = CreateClient<AssetQueryClient>(SystemParams.CompanyID).GetAssetBasicInfoByUser(SystemParams.CompanyID, "", session.User.UID, 0); | ||||||
|  |                         var allassetids = allassets.Select(a => a.ID).ToList(); | ||||||
|  |                         assets = assets.Where(a => allassetids.Contains(a.AssetId)).ToArray(); | ||||||
|  |                     } | ||||||
|                     foreach (var asset in assets) |                     foreach (var asset in assets) | ||||||
|                     { |                     { | ||||||
|                         PMAssetItem a = new PMAssetItem(); |                         PMAssetItem a = new PMAssetItem(); | ||||||
| @@ -349,6 +379,15 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|                     } |                     } | ||||||
|                     return result.ToArray(); |                     return result.ToArray(); | ||||||
|                 } |                 } | ||||||
|  |                 else | ||||||
|  |                     return null; | ||||||
|  |  | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 return null; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|         private string SaveMachines() |         private string SaveMachines() | ||||||
|         { |         { | ||||||
| @@ -409,7 +448,21 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|         { |         { | ||||||
|             public string ModelName { get; set; } |             public string ModelName { get; set; } | ||||||
|             public string Notes { get; set; } |             public string Notes { get; set; } | ||||||
|             public double? StartOdometer { get; set; } |             private double? _StartOdometer; | ||||||
|  |             public double? StartOdometer | ||||||
|  |             { | ||||||
|  |                 get | ||||||
|  |                 { | ||||||
|  |                     return _StartOdometer; | ||||||
|  |                 } | ||||||
|  |                 set | ||||||
|  |                 { | ||||||
|  |                     if (value != null) | ||||||
|  |                         _StartOdometer = Math.Round(value.Value, 2); | ||||||
|  |                     else | ||||||
|  |                         _StartOdometer = value; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|             public double? StartHours { get; set; } |             public double? StartHours { get; set; } | ||||||
|             public DateTime? StartDate { get; set; } |             public DateTime? StartDate { get; set; } | ||||||
|             public string TypeName { get; set; } |             public string TypeName { get; set; } | ||||||
| @@ -420,7 +473,22 @@ namespace IronIntel.Contractor.Site.Maintenance | |||||||
|             public string VIN { get; set; } |             public string VIN { get; set; } | ||||||
|             public long AssetId { get; set; } |             public long AssetId { get; set; } | ||||||
|             public double? EngineHours { get; set; } |             public double? EngineHours { get; set; } | ||||||
|             public double? Odometer { get; set; } |  | ||||||
|  |             private double? _Odometer; | ||||||
|  |             public double? Odometer | ||||||
|  |             { | ||||||
|  |                 get | ||||||
|  |                 { | ||||||
|  |                     return _Odometer; | ||||||
|  |                 } | ||||||
|  |                 set | ||||||
|  |                 { | ||||||
|  |                     if (value != null) | ||||||
|  |                         _Odometer = Math.Round(value.Value, 2); | ||||||
|  |                     else | ||||||
|  |                         _Odometer = value; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|             public string PMScheduleId { get; set; } |             public string PMScheduleId { get; set; } | ||||||
|             public int? StartIntervalValue { get; set; } |             public int? StartIntervalValue { get; set; } | ||||||
|             public string StartDateString |             public string StartDateString | ||||||
|   | |||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -6,24 +6,21 @@ using System.Threading.Tasks; | |||||||
| using System.IO; | using System.IO; | ||||||
| using System.Web; | using System.Web; | ||||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||||
| using IronIntel.Site; |  | ||||||
| using IronIntel.Contractor.MapView; | using IronIntel.Contractor.MapView; | ||||||
| using IronIntel.Contractor.Users; | using IronIntel.Contractor.Users; | ||||||
| using Foresight.ServiceModel; | using Foresight.ServiceModel; | ||||||
| using IronIntel.Contractor.Contact; |  | ||||||
| using Foresight.Fleet.Services.Attachment; | using Foresight.Fleet.Services.Attachment; | ||||||
| using Foresight.Fleet.Services.JobSite; | using Foresight.Fleet.Services.JobSite; | ||||||
| using Foresight.Fleet.Services.MapView; | using Foresight.Fleet.Services.MapView; | ||||||
|  | using System.Net; | ||||||
|  | using IronIntel.Contractor.iisitebase; | ||||||
|  | using Foresight.Fleet.Services.Asset; | ||||||
|  | using System.Text.RegularExpressions; | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor.Site.MapView | namespace IronIntel.Contractor.Site.MapView | ||||||
| { | { | ||||||
|     public class MapViewHandler : IronIntelHttpHandlerBase |     public class MapViewHandler : IronIntelHttpHandlerBase | ||||||
|     { |     { | ||||||
|         public override string GetIronSystemServiceAddress() |  | ||||||
|         { |  | ||||||
|             return SystemParams.SystemServiceAddresses[0]; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         public MapViewHandler(HttpContext context) |         public MapViewHandler(HttpContext context) | ||||||
|             : base(context) |             : base(context) | ||||||
|         { |         { | ||||||
| @@ -67,11 +64,17 @@ namespace IronIntel.Contractor.Site.MapView | |||||||
|                     case "GetServerVersion": |                     case "GetServerVersion": | ||||||
|                         result = GetServerVersion(); |                         result = GetServerVersion(); | ||||||
|                         break; |                         break; | ||||||
|  |                     case "GetContacts": | ||||||
|  |                         result = GetContacts(); | ||||||
|  |                         break; | ||||||
|                     case "GetMachineContacts": |                     case "GetMachineContacts": | ||||||
|                         result = GetMachineContacts(); |                         result = GetMachineContacts(); | ||||||
|                         break; |                         break; | ||||||
|                     case "SendLocation": |                     case "GetJobsiteContacts": | ||||||
|                         result = SendLocation(); |                         result = GetJobsiteContacts(); | ||||||
|  |                         break; | ||||||
|  |                     case "SendEmails": | ||||||
|  |                         result = SendEmails(); | ||||||
|                         break; |                         break; | ||||||
|                     case "SaveMapViewSearch": |                     case "SaveMapViewSearch": | ||||||
|                         result = SaveMapViewSearch(); |                         result = SaveMapViewSearch(); | ||||||
| @@ -97,6 +100,21 @@ namespace IronIntel.Contractor.Site.MapView | |||||||
|                     case "GetAssetByID": |                     case "GetAssetByID": | ||||||
|                         result = GetAssetByID(); |                         result = GetAssetByID(); | ||||||
|                         break; |                         break; | ||||||
|  |                     case "RequestVideo": | ||||||
|  |                         result = RequestVideo(); | ||||||
|  |                         break; | ||||||
|  |                     case "GetAssetTripLins": | ||||||
|  |                         result = GetAssetTripLins(); | ||||||
|  |                         break; | ||||||
|  |                     case "GetLocationPrimaryDataSource": | ||||||
|  |                         result = GetLocationPrimaryDataSource(); | ||||||
|  |                         break; | ||||||
|  |                     case "GetAssetMapAttachments": | ||||||
|  |                         result = GetAssetMapAttachments(); | ||||||
|  |                         break; | ||||||
|  |                     case "GetNowFormatDate": | ||||||
|  |                         result = GetNowFormatDate(); | ||||||
|  |                         break; | ||||||
|                     default: |                     default: | ||||||
|                         break; |                         break; | ||||||
|                 } |                 } | ||||||
| @@ -116,6 +134,9 @@ namespace IronIntel.Contractor.Site.MapView | |||||||
|             string serverVersion = SystemParams.GetVersion(); |             string serverVersion = SystemParams.GetVersion(); | ||||||
|             return serverVersion; |             return serverVersion; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         const char SPLITCHAR170 = (char)170; | ||||||
|  |         const char SPLITCHAR171 = (char)171; | ||||||
|         private object GetAssets() |         private object GetAssets() | ||||||
|         { |         { | ||||||
|             AssetMapViewPinItem[] assets = null; |             AssetMapViewPinItem[] assets = null; | ||||||
| @@ -132,7 +153,11 @@ namespace IronIntel.Contractor.Site.MapView | |||||||
|                     viewqueryparam = ConvertToMachineAlertViewQueryParameter(p); |                     viewqueryparam = ConvertToMachineAlertViewQueryParameter(p); | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 assets = AssetMapViewManagement.GetAssets(LoginSession.SessionID, p.ContractorID, LoginSession.User.UID, p.SearchText, p.Onroad, viewqueryparam, !p.ExcludeNoLocation); |                 if (!SystemParams.IsDealer) | ||||||
|  |                     assets = AssetMapViewManagement.GetAssets(LoginSession.SessionID, p.ContractorID, LoginSession.User.UID, p.SearchText, p.Onroad, viewqueryparam, !p.ExcludeNoLocation, p.Attachment); | ||||||
|  |                 else | ||||||
|  |                     assets = AssetMapViewManagement.GetDealerAssets(LoginSession.SessionID, p.ContractorID, LoginSession.User.UID, p.SearchText, p.Onroad, viewqueryparam, !p.ExcludeNoLocation, p.Attachment); | ||||||
|  |  | ||||||
|                 SystemParams.WriteRefreshLog(LoginSession.User.UID, UserHostAddress, "Assets", p.IsAutoRefresh ? "Auto" : "Manual"); |                 SystemParams.WriteRefreshLog(LoginSession.User.UID, UserHostAddress, "Assets", p.IsAutoRefresh ? "Auto" : "Manual"); | ||||||
|             } |             } | ||||||
|             else |             else | ||||||
| @@ -141,13 +166,14 @@ namespace IronIntel.Contractor.Site.MapView | |||||||
|             List<string> results = new List<string>(); |             List<string> results = new List<string>(); | ||||||
|             foreach (var r in assets) |             foreach (var r in assets) | ||||||
|             { |             { | ||||||
|                 //if (sb.Length > 0) |                 if (r is AssetMapViewPinItemClient) | ||||||
|                 //{ |                 { | ||||||
|                 //    sb.Append((char)171); |                     AssetMapViewPinItemClient rc = r as AssetMapViewPinItemClient; | ||||||
|                 //} |                     var companyinfo = rc.CompanyID + SPLITCHAR170 + rc.CompanyName; | ||||||
|                 StringBuilder sb = new StringBuilder(); |                     results.Add(companyinfo + SPLITCHAR171 + r.ToString()); | ||||||
|                 r.ToFormatedString(sb, (char)170); |                 } | ||||||
|                 results.Add(sb.ToString()); |                 else | ||||||
|  |                     results.Add(r.ToString()); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             return results.ToArray(); |             return results.ToArray(); | ||||||
| @@ -170,11 +196,13 @@ namespace IronIntel.Contractor.Site.MapView | |||||||
|                     companyid = SystemParams.CompanyID; |                     companyid = SystemParams.CompanyID; | ||||||
|  |  | ||||||
|                 List<AssetGroupViewItem> temp = new List<AssetGroupViewItem>(); |                 List<AssetGroupViewItem> temp = new List<AssetGroupViewItem>(); | ||||||
|  |                 if (!SystemParams.IsDealer) | ||||||
|                     groups = AssetMapViewManagement.GetAssetGroups(LoginSession.SessionID, companyid, LoginSession.User.UID, p.SearchText); |                     groups = AssetMapViewManagement.GetAssetGroups(LoginSession.SessionID, companyid, LoginSession.User.UID, p.SearchText); | ||||||
|  |                 else | ||||||
|  |                     groups = AssetMapViewManagement.GetDealerAssetGroups(LoginSession.SessionID, companyid, LoginSession.User.UID, p.SearchText); | ||||||
|                 temp.AddRange(groups); |                 temp.AddRange(groups); | ||||||
|  |  | ||||||
|                 AssetGroupViewItem eg = new AssetGroupViewItem() { ID = "-1", Name = "No Asset Group Assigned" }; |                 AssetGroupViewItem eg = new AssetGroupViewItem() { ID = "-1", Name = SystemParams.GetTextByKey(GetLanguageCookie(), "P_MV_NOASSETGROUPASSIGNED", "No Asset Group Assigned") }; | ||||||
|                 //eg.Assets = AssetMapViewManagement.GetNoGroupAssets(companyid); |  | ||||||
|                 temp.Add(eg); |                 temp.Add(eg); | ||||||
|                 groups = temp.ToArray(); |                 groups = temp.ToArray(); | ||||||
|             } |             } | ||||||
| @@ -274,6 +302,67 @@ namespace IronIntel.Contractor.Site.MapView | |||||||
|             return item; |             return item; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         private AssetTripItem[] GetAssetTripLins() | ||||||
|  |         { | ||||||
|  |             if (LoginSession != null) | ||||||
|  |             { | ||||||
|  |                 string p = Context.Request.Params["ClientData"]; | ||||||
|  |                 string[] ps = p.Split(';'); | ||||||
|  |                 //if (ps.Length != 6) return item; | ||||||
|  |                 DateTime dtFrom = DateTime.Now; | ||||||
|  |                 DateTime dtTo = DateTime.Now; | ||||||
|  |                 if (!DateTime.TryParse(ps[1], out dtFrom) || !DateTime.TryParse(ps[2], out dtTo)) | ||||||
|  |                     return new AssetTripItem[0]; | ||||||
|  |                 string companyid = ps[3].Trim();//companyid | ||||||
|  |                 if (string.IsNullOrEmpty(companyid)) | ||||||
|  |                     companyid = SystemParams.CompanyID; | ||||||
|  |  | ||||||
|  |                 var client = FleetServiceClientHelper.CreateClient<AssetLocationQueryClient>(companyid, LoginSession.SessionID); | ||||||
|  |                 AssetTripInfo[] trips = client.GetAssetTripLins(companyid, long.Parse(ps[0]), dtFrom, dtTo); | ||||||
|  |                 trips = trips.Where(m => m.TripOn != null || m.TripOff != null).ToArray(); | ||||||
|  |  | ||||||
|  |                 List<AssetTripItem> ls = new List<AssetTripItem>(); | ||||||
|  |                 TripColor[] colors = Enum.GetValues(typeof(TripColor)) as TripColor[]; | ||||||
|  |                 Random random = new Random(); | ||||||
|  |                 foreach (AssetTripInfo trip in trips) | ||||||
|  |                 { | ||||||
|  |                     AssetTripItem item = new AssetTripItem(); | ||||||
|  |                     Helper.CloneProperty(item, trip); | ||||||
|  |  | ||||||
|  |                     TripColor color = colors[random.Next(0, colors.Length)]; | ||||||
|  |                     item.Color = color; | ||||||
|  |  | ||||||
|  |                     ls.Add(item); | ||||||
|  |                 } | ||||||
|  |                 return ls.ToArray(); | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 return new AssetTripItem[0]; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private Tuple<string, string> GetLocationPrimaryDataSource() | ||||||
|  |         { | ||||||
|  |             if (LoginSession != null) | ||||||
|  |             { | ||||||
|  |                 string p = Context.Request.Params["ClientData"]; | ||||||
|  |                 string[] ps = p.Split(';'); | ||||||
|  |                 string companyid = ps[1].Trim();//companyid | ||||||
|  |                 if (string.IsNullOrEmpty(companyid)) | ||||||
|  |                     companyid = SystemParams.CompanyID; | ||||||
|  |  | ||||||
|  |                 var client = FleetServiceClientHelper.CreateClient<AssetLocationQueryClient>(companyid, LoginSession.SessionID); | ||||||
|  |                 Tuple<string, string> datasource = client.GetLocationPrimaryDataSource(companyid, long.Parse(ps[0])); | ||||||
|  |  | ||||||
|  |                 return datasource; | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 return new Tuple<string, string>(string.Empty, string.Empty); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|         private JobSiteViewItem[] GetJobSites() |         private JobSiteViewItem[] GetJobSites() | ||||||
|         { |         { | ||||||
|             JobSiteViewItem[] items = null; |             JobSiteViewItem[] items = null; | ||||||
| @@ -284,18 +373,14 @@ namespace IronIntel.Contractor.Site.MapView | |||||||
|                 GetJobsiteParameterItem p = JsonConvert.DeserializeObject<GetJobsiteParameterItem>(clientdata); |                 GetJobsiteParameterItem p = JsonConvert.DeserializeObject<GetJobsiteParameterItem>(clientdata); | ||||||
|                 p.SearchText = HttpUtility.HtmlDecode(p.SearchText); |                 p.SearchText = HttpUtility.HtmlDecode(p.SearchText); | ||||||
|  |  | ||||||
|                 string companyid = p.ContractorID; |  | ||||||
|                 if (string.IsNullOrEmpty(companyid)) |  | ||||||
|                     companyid = SystemParams.CompanyID; |  | ||||||
|  |  | ||||||
|                 items = AssetMapViewManagement.GetJobsites(LoginSession.SessionID, companyid, LoginSession.User.UID, p.SearchText); |  | ||||||
|  |  | ||||||
|  |  | ||||||
|                 List<JobSiteViewItem> temp = new List<JobSiteViewItem>(); |                 List<JobSiteViewItem> temp = new List<JobSiteViewItem>(); | ||||||
|                 items = AssetMapViewManagement.GetJobsites(LoginSession.SessionID, companyid, LoginSession.User.UID, p.SearchText); |                 if (!SystemParams.IsDealer) | ||||||
|  |                     items = AssetMapViewManagement.GetJobsites(LoginSession.SessionID, p.ContractorID, LoginSession.User.UID, p.SearchText); | ||||||
|  |                 else | ||||||
|  |                     items = AssetMapViewManagement.GetDealerJobsites(LoginSession.SessionID, p.ContractorID, LoginSession.User.UID, p.SearchText); | ||||||
|                 temp.AddRange(items); |                 temp.AddRange(items); | ||||||
|  |  | ||||||
|                 JobSiteViewItem js = new JobSiteViewItem() { ID = -1, Name = "No Jobsite Assigned" }; |                 JobSiteViewItem js = new JobSiteViewItem() { ID = -1, Name = SystemParams.GetTextByKey(GetLanguageCookie(), "P_MV_NOJOBSITEASSIGNED", "No Jobsite Assigned") }; | ||||||
|                 temp.Add(js); |                 temp.Add(js); | ||||||
|                 items = temp.ToArray(); |                 items = temp.ToArray(); | ||||||
|             } |             } | ||||||
| @@ -316,23 +401,11 @@ namespace IronIntel.Contractor.Site.MapView | |||||||
|                 if (string.IsNullOrEmpty(companyid)) |                 if (string.IsNullOrEmpty(companyid)) | ||||||
|                     companyid = SystemParams.CompanyID; |                     companyid = SystemParams.CompanyID; | ||||||
|  |  | ||||||
|                 var client = FleetServiceClientHelper.CreateClient<MapViewQueryClient>(companyid, LoginSession.SessionID); |  | ||||||
|                 CustomerLocation[] locs = client.GetContractorAndDealerLocations(companyid); |  | ||||||
|                 List<CompanyLocationViewItem> temps = new List<CompanyLocationViewItem>(); |                 List<CompanyLocationViewItem> temps = new List<CompanyLocationViewItem>(); | ||||||
|                 foreach (var loc in locs) |                 if (!SystemParams.IsDealer) | ||||||
|                 { |                     items = AssetMapViewManagement.GetLocations(LoginSession.SessionID, companyid); | ||||||
|                     CompanyLocationViewItem l = new CompanyLocationViewItem(); |                 else | ||||||
|                     l.ID = loc.ID; |                     items = AssetMapViewManagement.GetDealerLocations(LoginSession.SessionID, companyid); | ||||||
|                     l.Latitude = loc.Latitude; |  | ||||||
|                     l.Longitude = loc.Longitude; |  | ||||||
|                     l.LocationName = loc.Name; |  | ||||||
|                     l.Notes = loc.Notes; |  | ||||||
|                     l.IconUrl = loc.IconUrl; |  | ||||||
|                     temps.Add(l); |  | ||||||
|                 } |  | ||||||
|                 items = temps.ToArray(); |  | ||||||
|  |  | ||||||
|                 //items = LocationManagement.GetCompanyLocations(""); |  | ||||||
|             } |             } | ||||||
|             else |             else | ||||||
|             { |             { | ||||||
| @@ -352,7 +425,10 @@ namespace IronIntel.Contractor.Site.MapView | |||||||
|                 string companyid = p.Substring(0, index); |                 string companyid = p.Substring(0, index); | ||||||
|                 string selectedViewID = p.Substring(index + 1); |                 string selectedViewID = p.Substring(index + 1); | ||||||
|  |  | ||||||
|  |                 if (!SystemParams.IsDealer) | ||||||
|                     items = AssetMapViewManagement.GetMapAlertViews(LoginSession.SessionID, companyid, selectedViewID); |                     items = AssetMapViewManagement.GetMapAlertViews(LoginSession.SessionID, companyid, selectedViewID); | ||||||
|  |                 else | ||||||
|  |                     items = AssetMapViewManagement.GetDealerMapAlertViews(LoginSession.SessionID, companyid, selectedViewID); | ||||||
|             } |             } | ||||||
|             else |             else | ||||||
|             { |             { | ||||||
| @@ -409,7 +485,77 @@ namespace IronIntel.Contractor.Site.MapView | |||||||
|             return new MapViewSearchItem[0]; |             return new MapViewSearchItem[0]; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         private object GetAssetMapAttachments() | ||||||
|  |         { | ||||||
|  |             if (LoginSession != null) | ||||||
|  |             { | ||||||
|  |                 var clientdata = Context.Request.Params["ClientData"]; | ||||||
|  |                 string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata); | ||||||
|  |                 string companyid = ps[0]; | ||||||
|  |                 if (string.IsNullOrEmpty(companyid)) | ||||||
|  |                     companyid = SystemParams.CompanyID; | ||||||
|  |                 long assetid = 0; | ||||||
|  |                 if (!long.TryParse(ps[1], out assetid)) | ||||||
|  |                     return null; | ||||||
|  |  | ||||||
|  |                 var client = FleetServiceClientHelper.CreateClient<MapViewQueryClient>(companyid, LoginSession.SessionID); | ||||||
|  |                 return client.GetAssetDocumentsOnMap(companyid, assetid); | ||||||
|  |             } | ||||||
|  |             return null; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private object RequestVideo() | ||||||
|  |         { | ||||||
|  |             if (LoginSession != null && SystemParams.HasLicense("SmartWitness")) | ||||||
|  |             { | ||||||
|  |                 string p = Context.Request.Params["ClientData"]; | ||||||
|  |                 string[] ps = JsonConvert.DeserializeObject<string[]>(p); | ||||||
|  |                 string companyid = ps[0]; | ||||||
|  |                 if (string.IsNullOrEmpty(companyid)) | ||||||
|  |                     companyid = SystemParams.CompanyID; | ||||||
|  |                 long aid = 0; | ||||||
|  |                 DateTime dt = DateTime.MinValue; | ||||||
|  |                 if (long.TryParse(ps[1], out aid)) | ||||||
|  |                 { | ||||||
|  |                     bool isCustomerTime = ps[2] == "1"; | ||||||
|  |                     if (DateTime.TryParse(ps[3], out dt)) | ||||||
|  |                     { | ||||||
|  |                         var cust = SystemParams.GetCustomerDetail(companyid); | ||||||
|  |                         dt = cust.CustomerTimeToUtc(dt); | ||||||
|  |                     } | ||||||
|  |                     int seconds = ps[4] == "1" ? 30 : 120; | ||||||
|  |  | ||||||
|  |                     long logid = 0; | ||||||
|  |                     if (!long.TryParse(ps[5], out logid)) | ||||||
|  |                         logid = -1; | ||||||
|  |                     string src = ps[6]; | ||||||
|  |                     string subsrc = ps[7]; | ||||||
|  |                     string et = ps[8]; | ||||||
|  |                     string msguid = ps[9]; | ||||||
|  |  | ||||||
|  |                     var client = FleetServiceClientHelper.CreateClient<MapViewQueryClient>(companyid, LoginSession.SessionID); | ||||||
|  |                     var result = client.SendSmartWitnessVideoRequestWithTime(companyid, LoginSession.User.UID, aid, isCustomerTime, dt, seconds, logid, src, subsrc, et, msguid); | ||||||
|  |                     //var result = client.SendSmartWitnessVideoRequest(companyid, logid, LoginSession.User.UID); | ||||||
|  |                     return string.IsNullOrEmpty(result) ? "OK" : result; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             return "OK"; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         #region Send Location |         #region Send Location | ||||||
|  |         private UserInfo[] GetContacts() | ||||||
|  |         { | ||||||
|  |             UserInfo[] users; | ||||||
|  |             if (LoginSession != null) | ||||||
|  |             { | ||||||
|  |                 users = UserManagement.GetUsers().Where(u => u.Active).ToArray(); | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 users = new UserInfo[0]; | ||||||
|  |             } | ||||||
|  |             return users; | ||||||
|  |         } | ||||||
|         private UserInfo[] GetMachineContacts() |         private UserInfo[] GetMachineContacts() | ||||||
|         { |         { | ||||||
|             UserInfo[] items = null; |             UserInfo[] items = null; | ||||||
| @@ -429,51 +575,104 @@ namespace IronIntel.Contractor.Site.MapView | |||||||
|             } |             } | ||||||
|             return items; |             return items; | ||||||
|         } |         } | ||||||
|         private string SendLocation() |         private UserInfo[] GetJobsiteContacts() | ||||||
|  |         { | ||||||
|  |             UserInfo[] items = null; | ||||||
|  |             if (LoginSession != null) | ||||||
|  |             { | ||||||
|  |                 string p = Context.Request.Params["ClientData"]; | ||||||
|  |                 p = HttpUtility.HtmlDecode(p); | ||||||
|  |                 int index = p.IndexOf(";"); | ||||||
|  |                 string contractorid = p.Substring(0, index); | ||||||
|  |                 string jsid = p.Substring(index + 1); | ||||||
|  |  | ||||||
|  |                 items = UserManagement.GetUsersByJobsiteID(LoginSession.SessionID, Convert.ToInt64(jsid), contractorid); | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 items = new UserInfo[0]; | ||||||
|  |             } | ||||||
|  |             return items; | ||||||
|  |         } | ||||||
|  |         private string SendEmails() | ||||||
|         { |         { | ||||||
|             if (LoginSession != null) |             if (LoginSession != null) | ||||||
|             { |             { | ||||||
|                 string p = Context.Request.Params["ClientData"]; |                 string p = Context.Request.Params["ClientData"]; | ||||||
|                 p = HttpUtility.HtmlDecode(p); |                 p = HttpUtility.HtmlDecode(p); | ||||||
|  |  | ||||||
|                 SendLocationInfo si = JsonConvert.DeserializeObject<SendLocationInfo>(p); |                 SendEmailsInfo si = JsonConvert.DeserializeObject<SendEmailsInfo>(p); | ||||||
|                 if (string.IsNullOrEmpty(si.CompanyID)) |                 if (string.IsNullOrEmpty(si.CompanyID)) | ||||||
|                     si.CompanyID = SystemParams.CompanyID; |                     si.CompanyID = SystemParams.CompanyID; | ||||||
|  |  | ||||||
|                 AssetDetailViewItem asset = AssetMapViewManagement.GetAssetDetailItem(LoginSession.SessionID, si.CompanyID, si.AssetID); |                 if (si.Type == 0) | ||||||
|                 SendMail(asset, si); |                 {//SendLocation | ||||||
|  |                     AssetDetailViewItem asset = AssetMapViewManagement.GetAssetDetailItem(LoginSession.SessionID, si.CompanyID, si.ObjectID); | ||||||
|  |                     SendAssetLocation(asset, si); | ||||||
|  |                 } | ||||||
|  |                 else if (si.Type == 1) | ||||||
|  |                 {//Send Jobsite | ||||||
|  |                     JobSiteItem jobsite = FleetServiceClientHelper.CreateClient<JobSiteProvider>().GetJobSiteItem(si.CompanyID, si.ObjectID); | ||||||
|  |                     SendJobsite(jobsite, si); | ||||||
|  |                 } | ||||||
|  |                 else if (si.Type == 3) | ||||||
|  |                 { | ||||||
|  |                     // Send Route | ||||||
|  |                     SendRoute(si); | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|             return "OK"; |             return "OK"; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private void SendMail(AssetDetailViewItem asset, SendLocationInfo si) |  | ||||||
|  |         private void SendAssetLocation(AssetDetailViewItem asset, SendEmailsInfo si) | ||||||
|         { |         { | ||||||
|             string[] emailaddress = si.EmailAddress; |             StringKeyValue[] emailaddress = si.EmailAddress; | ||||||
|             string[] textaddress = si.TextAddress; |             StringKeyValue[] textaddress = si.TextAddress; | ||||||
|             string Subject = "Location of Asset: " + asset.Name2 + " " + asset.Name + " " + asset.Make + " " + asset.Model + " " + asset.VIN + " " + (asset.MakeYear > 0 ? asset.MakeYear.ToString() : ""); |             var alllangs = GetUserLanguages(emailaddress, textaddress); | ||||||
|             var useriid = LoginSession.User.UID; |             var useriid = LoginSession.User.UID; | ||||||
|  |             var client = FleetServiceClientHelper.CreateClient<AttachmentClient>(); | ||||||
|             if (emailaddress != null && emailaddress.Length > 0) |             if (emailaddress != null && emailaddress.Length > 0) | ||||||
|             { |             { | ||||||
|                 string Body = OrdinaryEmailFormat(asset, si.Description); |                 foreach (var item in emailaddress) | ||||||
|                 FleetServiceClientHelper.CreateClient<AttachmentClient>().SendAssetLoationEmail(si.CompanyID, si.AssetID, Subject, Body, emailaddress.ToArray(), useriid); |                 { | ||||||
|  |                     string lang = GetUserLanguage(alllangs, item.Key); | ||||||
|  |                     string Subject = SystemParams.GetTextByKey(lang, "P_MV_LOCATIONOFASSET_COLON", "Location of Asset:") + " " + asset.Name2 + " " + asset.Name + " " + asset.Make + " " + asset.Model + " " + asset.VIN + " " + (asset.MakeYear > 0 ? asset.MakeYear.ToString() : ""); | ||||||
|  |  | ||||||
|  |                     string Body = OrdinaryEmailFormat(lang, asset, si.Description, LoginSession.User.Name); | ||||||
|  |                     client.SendAssetLoationEmail(si.CompanyID, si.ObjectID, Subject, Body, new string[] { item.Value }, useriid); | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|             if (textaddress != null && textaddress.Length > 0) |             if (textaddress != null && textaddress.Length > 0) | ||||||
|             { |             { | ||||||
|                 string Body = OrdinaryTextFormat(asset, si.Description); |                 foreach (var item in textaddress) | ||||||
|                 Subject = "";//短信暂时不发Subject 8897反馈 |                 { | ||||||
|                 FleetServiceClientHelper.CreateClient<AttachmentClient>().SendAssetLoationEmail(si.CompanyID, si.AssetID, Subject, Body, textaddress.ToArray(), useriid); |                     string lang = GetUserLanguage(alllangs, item.Key); | ||||||
|  |                     string Body = OrdinaryTextFormat(lang, asset, si.Description, LoginSession.User.Name); | ||||||
|  |                     string Subject = "";//短信暂时不发Subject 8897反馈 | ||||||
|  |                     client.SendAssetLoationText(si.CompanyID, si.ObjectID, Subject, Body, new string[] { item.Value }, useriid); | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private string OrdinaryEmailFormat(AssetDetailViewItem asset, string desc) |         private string OrdinaryEmailFormat(string lang, AssetDetailViewItem asset, string desc, string username) | ||||||
|         { |         { | ||||||
|             string EmailFormat = "Location of Asset: {0} {1} {2} {3} {4} {5}</br></br>"; |             string EmailFormat = SystemParams.GetTextByKey(lang, "P_MV_LOCATIONOFASSET_COLON", "Location of Asset:") + " {0} {1} {2} {3} {4} {5}<br/><br/>"; | ||||||
|             EmailFormat += "Description:</br>"; |             EmailFormat += SystemParams.GetTextByKey(lang, "P_MV_DESCRIPTION_COLON", "Description:") + "<br/>"; | ||||||
|             EmailFormat += "{6}</br><br/>"; |             EmailFormat += "{6}<br/><br/>"; | ||||||
|             EmailFormat += "Click the link below to view directions to this asset:</br>"; |             EmailFormat += SystemParams.GetTextByKey(lang, "P_MV_CLICKTHELINKBELOWTOVIEWDIRECTIONSTOTHISASSET", "Click the link below to view directions to this asset:") + "<br/>"; | ||||||
|             EmailFormat += "<a href=\"{7}\">{7}</a>"; |             EmailFormat += "<a href=\"{7}\">" + SystemParams.GetTextByKey(lang, "P_MV_VIEWDIRECTIONS", "View Directions") + "</a>"; | ||||||
|  |  | ||||||
|             if (asset.Location == null) |             if (asset.Location == null) | ||||||
|                 asset.Location = new LocationViewItem(); |                 asset.Location = new LocationViewItem(); | ||||||
|  |  | ||||||
|  |             if (!string.IsNullOrEmpty(desc)) | ||||||
|  |             { | ||||||
|  |                 desc = Regex.Replace(desc, "\\[site name\\]", SystemParams.CustomerDetail.Name, RegexOptions.IgnoreCase); | ||||||
|  |                 desc = Regex.Replace(desc, "\\[User Name\\]", username, RegexOptions.IgnoreCase); | ||||||
|  |                 desc = Regex.Replace(desc, "\\[asset name\\]", asset.DisplayName, RegexOptions.IgnoreCase); | ||||||
|  |             } | ||||||
|  |  | ||||||
|             return string.Format(EmailFormat, |             return string.Format(EmailFormat, | ||||||
|                HttpUtility.HtmlEncode(asset.Name2), |                HttpUtility.HtmlEncode(asset.Name2), | ||||||
|                HttpUtility.HtmlEncode(asset.Name), |                HttpUtility.HtmlEncode(asset.Name), | ||||||
| @@ -485,24 +684,309 @@ namespace IronIntel.Contractor.Site.MapView | |||||||
|                 "https://www.google.com/maps/dir/?api=1&destination=" + asset.Location.Latitude + "," + asset.Location.Longitude + "&travelmode=driving"); |                 "https://www.google.com/maps/dir/?api=1&destination=" + asset.Location.Latitude + "," + asset.Location.Longitude + "&travelmode=driving"); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private string OrdinaryTextFormat(AssetDetailViewItem asset, string desc) |         private string OrdinaryTextFormat(string lang, AssetDetailViewItem asset, string desc, string username) | ||||||
|         { |         { | ||||||
|             string EmailFormat = "Location of Asset: {0} {1} {2} {3} {4} {5}</br></br>"; |             //string EmailFormat = SystemParams.GetTextByKey(lang, "P_MV_LOCATIONOFASSET_COLON", "Location of Asset:") + " {0}. "; | ||||||
|             EmailFormat += "Description:</br>"; |             ////string EmailFormat = "Location of Asset: {0} {1} {2} {3} {4} {5}. "; | ||||||
|             EmailFormat += "{6}</br><br/>"; |             ////EmailFormat += "Description: "; | ||||||
|             EmailFormat += "Click the link below to view directions to this asset:</br>"; |             ////EmailFormat += "{6}. "; | ||||||
|             EmailFormat += "<a href=\"{7}\">View Directions</a>"; |             //EmailFormat += "<a href=\"{1}\">" + SystemParams.GetTextByKey(lang, "P_MV_VIEWDIRECTIONS", "View Directions") + "</a>"; | ||||||
|             if (asset.Location == null) |             //if (asset.Location == null) | ||||||
|                 asset.Location = new LocationViewItem(); |             //    asset.Location = new LocationViewItem(); | ||||||
|  |             //return string.Format(EmailFormat, | ||||||
|  |             //   HttpUtility.HtmlEncode(asset.DisplayName), | ||||||
|  |             //    //HttpUtility.HtmlEncode(asset.Name), | ||||||
|  |             //    //HttpUtility.HtmlEncode(asset.Make), | ||||||
|  |             //    //HttpUtility.HtmlEncode(asset.Model), | ||||||
|  |             //    //HttpUtility.HtmlEncode(asset.VIN), | ||||||
|  |             //    //HttpUtility.HtmlEncode(asset.MakeYear > 0 ? asset.MakeYear.ToString() : ""), | ||||||
|  |             //    //HttpUtility.HtmlEncode(desc ?? ""), | ||||||
|  |             //    "https://www.google.com/maps/dir/?api=1&destination=" + asset.Location.Latitude + "," + asset.Location.Longitude /*+ "&travelmode=driving"*/); | ||||||
|  |  | ||||||
|  |             if (!string.IsNullOrEmpty(desc)) | ||||||
|  |             { | ||||||
|  |                 desc = Regex.Replace(desc, "\\[site name\\]", SystemParams.CustomerDetail.Name, RegexOptions.IgnoreCase); | ||||||
|  |                 desc = Regex.Replace(desc, "\\[User Name\\]", username, RegexOptions.IgnoreCase); | ||||||
|  |                 desc = Regex.Replace(desc, "\\[asset name\\]", asset.DisplayName, RegexOptions.IgnoreCase); | ||||||
|  |             } | ||||||
|  |             return desc + Environment.NewLine + Environment.NewLine + "https://www.google.com/maps/dir/?api=1&destination=" + asset.Location.Latitude + "," + asset.Location.Longitude; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void SendJobsite(JobSiteItem jobsite, SendEmailsInfo si) | ||||||
|  |         { | ||||||
|  |             StringKeyValue[] emailaddress = si.EmailAddress; | ||||||
|  |             StringKeyValue[] textaddress = si.TextAddress; | ||||||
|  |             var alllangs = GetUserLanguages(emailaddress, textaddress); | ||||||
|  |             string Subject = jobsite.Name; | ||||||
|  |             if (!string.IsNullOrEmpty(jobsite.Code)) | ||||||
|  |                 Subject += "/" + jobsite.Code; | ||||||
|  |             if (!string.IsNullOrEmpty(jobsite.Number)) | ||||||
|  |                 Subject += "/" + jobsite.Number; | ||||||
|  |  | ||||||
|  |             var useriid = LoginSession.User.UID; | ||||||
|  |  | ||||||
|  |             if (emailaddress != null && emailaddress.Length > 0) | ||||||
|  |             { | ||||||
|  |                 foreach (var item in emailaddress) | ||||||
|  |                 { | ||||||
|  |                     string lang = GetUserLanguage(alllangs, item.Key); | ||||||
|  |                     string Body = OrdinaryJobsiteEmailFormat(lang, jobsite, si.Description, LoginSession.User.Name); | ||||||
|  |                     FleetServiceClientHelper.CreateClient<AttachmentClient>().SendAssetLoationEmail(si.CompanyID, si.ObjectID, Subject, Body, new string[] { item.Value }, useriid); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             if (textaddress != null && textaddress.Length > 0) | ||||||
|  |             { | ||||||
|  |                 foreach (var item in textaddress) | ||||||
|  |                 { | ||||||
|  |                     string lang = GetUserLanguage(alllangs, item.Key); | ||||||
|  |                     string Body = OrdinaryJobsiteTextFormat(lang, jobsite, si.Description, LoginSession.User.Name); | ||||||
|  |                     FleetServiceClientHelper.CreateClient<AttachmentClient>().SendAssetLoationText(si.CompanyID, si.ObjectID, Subject, Body, new string[] { item.Value }, useriid); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void SendRoute(SendEmailsInfo si) | ||||||
|  |         { | ||||||
|  |             var emailaddress = si.EmailAddress; | ||||||
|  |             var subject = si.Title; | ||||||
|  |  | ||||||
|  |             var useriid = LoginSession.User.UID; | ||||||
|  |             if (emailaddress != null && emailaddress.Length > 0) | ||||||
|  |             { | ||||||
|  |                 var body = @"<!doctype html> | ||||||
|  | <html lang=""en""><head><style type=""text/css""> | ||||||
|  | .fa { | ||||||
|  |     display: none; | ||||||
|  |     font: normal normal normal 14px/1 FontAwesome; | ||||||
|  |     font-size: inherit; | ||||||
|  |     text-rendering: auto; | ||||||
|  |     -webkit-font-smoothing: antialiased; | ||||||
|  |     -moz-osx-font-smoothing: grayscale; | ||||||
|  | } | ||||||
|  | .routeSummary { | ||||||
|  |     line-height: 30px; | ||||||
|  |     padding: 0 20px 10px 20px; | ||||||
|  |     border-bottom: 1px solid #ccc; | ||||||
|  |     margin-bottom: 20px; | ||||||
|  | } | ||||||
|  | .routeSummary > .routeSummaryTitle { | ||||||
|  |     font-size: 1.6em; | ||||||
|  |     font-weight: 500; | ||||||
|  | } | ||||||
|  | .routeSummary > .routeSummaryDetail { | ||||||
|  |     font-size: 1.2em; | ||||||
|  |     color: gray; | ||||||
|  | } | ||||||
|  | .routeSummary .fa-car { | ||||||
|  |     font-size: 1.2em; | ||||||
|  |     padding-right: 6px; | ||||||
|  |     font-weight: bold; | ||||||
|  | } | ||||||
|  | .routeSummary .fa-car::before { content: '\f1b9'; } | ||||||
|  | .routeSummary .routeSummaryDistance { margin-left: 10px; } | ||||||
|  | .routeFeature { | ||||||
|  |     line-height: 30px; | ||||||
|  |     padding: 0 20px 0 40px; | ||||||
|  |     position: relative; | ||||||
|  | } | ||||||
|  | .routeFeature > .fa { | ||||||
|  |     position: absolute; | ||||||
|  |     width: 24px; | ||||||
|  |     height: 24px; | ||||||
|  |     left: 10px; | ||||||
|  |     top: 3px; | ||||||
|  |     line-height: 24px; | ||||||
|  |     text-align: center; | ||||||
|  |     font-size: 1.3em; | ||||||
|  | } | ||||||
|  | .routeFeature > .fa::before { content: '\f054'; } | ||||||
|  | .routeFeature > .fa-ship::before { content: '\f21a'; } | ||||||
|  | .routeFeature > .fa-merge-right { transform: scaleX(-1); } | ||||||
|  | .routeFeature > .fa-merge-right::before, | ||||||
|  | .routeFeature > .fa-merge::before { content: '\f387'; } | ||||||
|  | .routeFeature > .fa-up::before { content: '\f176'; } | ||||||
|  | .routeFeature > .fa-left::before, | ||||||
|  | .routeFeature > .fa-right::before { content: '\f148'; } | ||||||
|  | .routeFeature > .fa-back::before { content: '\f175'; } | ||||||
|  | .routeFeature > .fa-left { transform: rotate(-90deg); } | ||||||
|  | .routeFeature > .fa-right { transform: scaleX(-1) rotate(-90deg); } | ||||||
|  | .routeFeature > .fa-back { transform: rotate(180deg); } | ||||||
|  | .routeFeature > .routeFeatureMessage { font-size: 1.2em; } | ||||||
|  | .routeFeature > .routeFeatureDetail { | ||||||
|  |     color: #aaa; | ||||||
|  |     position: relative; | ||||||
|  |     height: 30px; | ||||||
|  |     font-size: 0.9em; | ||||||
|  | } | ||||||
|  | .routeFeature > .routeFeatureDetail > .routeFeatureDetailBorder { | ||||||
|  |     border-bottom: 1px solid #ccc; | ||||||
|  |     position: absolute; | ||||||
|  |     width: 100%; | ||||||
|  |     top: 50%; | ||||||
|  | } | ||||||
|  | .routeFeature > .routeFeatureDetail > span { | ||||||
|  |     background-color: white; | ||||||
|  |     position: absolute; | ||||||
|  |     padding-right: 10px; | ||||||
|  | } | ||||||
|  | </style></head><body>"; | ||||||
|  |                 body += "<p>" + (si.Description ?? "").Replace("\n", "<br>") + "</p>"; | ||||||
|  |                 body += si.HtmlBody + "</body></html>"; | ||||||
|  |                 string[] address = emailaddress.Select(m => m.Value).ToArray(); | ||||||
|  |                 FleetServiceClientHelper.CreateClient<AttachmentClient>().SendRoutesEmail(si.CompanyID, subject, body, address, useriid); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private string OrdinaryJobsiteEmailFormat(string lang, JobSiteItem jobsite, string desc, string username) | ||||||
|  |         { | ||||||
|  |             string EmailFormat = "{7}"; | ||||||
|  |             EmailFormat += SystemParams.GetTextByKey(lang, "P_MV_LATLONG_COLON", "Lat/Long:") + " {0},{1}<br/>"; | ||||||
|  |             EmailFormat += SystemParams.GetTextByKey(lang, "P_MV_DELIVERYADDRESS_COLON", "Delivery Address:") + " {2}<br/<br/>"; | ||||||
|  |             EmailFormat += SystemParams.GetTextByKey(lang, "P_JS_FOREMAN_COLON", "Foreman:") + " {3}<br/><br/>"; | ||||||
|  |             EmailFormat += SystemParams.GetTextByKey(lang, "P_JS_STATDATE_COLON", "Start Date:") + " {4}<br/>"; | ||||||
|  |             EmailFormat += SystemParams.GetTextByKey(lang, "P_JS_ENDDATE_COLON", "End Date:") + " {5}<br/><br/>"; | ||||||
|  |             EmailFormat += SystemParams.GetTextByKey(lang, "P_MA_NOTES_COLON", "Notes:") + " {6}<br/>"; | ||||||
|  |  | ||||||
|  |             if (!string.IsNullOrEmpty(desc)) | ||||||
|  |             { | ||||||
|  |                 desc = Regex.Replace(desc, "\\[site name\\]", SystemParams.CustomerDetail.Name, RegexOptions.IgnoreCase); | ||||||
|  |                 desc = Regex.Replace(desc, "\\[User Name\\]", username, RegexOptions.IgnoreCase); | ||||||
|  |                 desc = Regex.Replace(desc, "\\[jobsite\\]", jobsite.Name, RegexOptions.IgnoreCase); | ||||||
|  |                 desc = HttpUtility.HtmlEncode(desc); | ||||||
|  |             } | ||||||
|  |  | ||||||
|             return string.Format(EmailFormat, |             return string.Format(EmailFormat, | ||||||
|                HttpUtility.HtmlEncode(asset.Name2), |                HttpUtility.HtmlEncode(jobsite.Latitude), | ||||||
|                HttpUtility.HtmlEncode(asset.Name), |                HttpUtility.HtmlEncode(jobsite.Longitude), | ||||||
|                HttpUtility.HtmlEncode(asset.Make), |                HttpUtility.HtmlEncode(jobsite.Address1), | ||||||
|                HttpUtility.HtmlEncode(asset.Model), |                HttpUtility.HtmlEncode(jobsite.Foreman), | ||||||
|                HttpUtility.HtmlEncode(asset.VIN), |                HttpUtility.HtmlEncode(jobsite.StartDate == null ? "" : jobsite.StartDate.Value.ToShortDateString()), | ||||||
|                HttpUtility.HtmlEncode(asset.MakeYear > 0 ? asset.MakeYear.ToString() : ""), |                HttpUtility.HtmlEncode(jobsite.EndDate == null ? "" : jobsite.EndDate.Value.ToShortDateString()), | ||||||
|                HttpUtility.HtmlEncode(desc ?? "").Replace("\n", "<br>"), |                HttpUtility.HtmlEncode(jobsite.Notes ?? "").Replace("\n", "<br/>"), | ||||||
|                 "https://www.google.com/maps/dir/?api=1&destination=" + asset.Location.Latitude + "," + asset.Location.Longitude + "&travelmode=driving"); |                string.IsNullOrWhiteSpace(desc) ? "" : desc.Replace("\n", "<br/>") + "<br/><br/>"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private string OrdinaryJobsiteTextFormat(string lang, JobSiteItem jobsite, string desc, string username) | ||||||
|  |         { | ||||||
|  |             string EmailFormat = "{7}"; | ||||||
|  |             EmailFormat += SystemParams.GetTextByKey(lang, "P_MV_LATLONG_COLON", "Lat/Long:") + " {0},{1}  "; | ||||||
|  |             EmailFormat += SystemParams.GetTextByKey(lang, "P_MV_DELIVERYADDRESS_COLON", "Delivery Address:") + " {2}  "; | ||||||
|  |             EmailFormat += SystemParams.GetTextByKey(lang, "P_JS_FOREMAN_COLON", "Foreman:") + " {3}  "; | ||||||
|  |             EmailFormat += SystemParams.GetTextByKey(lang, "P_JS_STATDATE_COLON", "Start Date:") + " {4}  "; | ||||||
|  |             EmailFormat += SystemParams.GetTextByKey(lang, "P_JS_ENDDATE_COLON", "End Date:") + " {5}  "; | ||||||
|  |             EmailFormat += SystemParams.GetTextByKey(lang, "P_MA_NOTES_COLON", "Notes:") + " {6}"; | ||||||
|  |  | ||||||
|  |             if (!string.IsNullOrEmpty(desc)) | ||||||
|  |             { | ||||||
|  |                 desc = Regex.Replace(desc, "\\[site name\\]", SystemParams.CustomerDetail.Name, RegexOptions.IgnoreCase); | ||||||
|  |                 desc = Regex.Replace(desc, "\\[User Name\\]", username, RegexOptions.IgnoreCase); | ||||||
|  |                 desc = Regex.Replace(desc, "\\[jobsite\\]", jobsite.Name, RegexOptions.IgnoreCase); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             return string.Format(EmailFormat, jobsite.Latitude, | ||||||
|  |                jobsite.Longitude, | ||||||
|  |                jobsite.Address1, | ||||||
|  |                jobsite.Foreman, | ||||||
|  |                jobsite.StartDate == null ? "" : jobsite.StartDate.Value.ToShortDateString(), | ||||||
|  |                jobsite.EndDate == null ? "" : jobsite.EndDate.Value.ToShortDateString(), | ||||||
|  |                jobsite.Notes ?? "", | ||||||
|  |                string.IsNullOrWhiteSpace(desc) ? "" : desc + "\r\n\r\n"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         public static Foresight.Standard.StringKeyValue[] GetUserLanguages(StringKeyValue[] emailaddress, StringKeyValue[] textaddress) | ||||||
|  |         { | ||||||
|  |             List<string> uids = new List<string>(); | ||||||
|  |             if (emailaddress != null && emailaddress.Length > 0) | ||||||
|  |             { | ||||||
|  |                 List<string> ids = emailaddress.Where(m => !string.IsNullOrEmpty(m.Key)).Select(m => m.Key).ToList(); | ||||||
|  |                 if (ids != null && ids.Count > 0) | ||||||
|  |                     uids.AddRange(ids); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             if (textaddress != null && textaddress.Length > 0) | ||||||
|  |             { | ||||||
|  |                 List<string> ids = textaddress.Where(m => !string.IsNullOrEmpty(m.Key)).Select(m => m.Key).ToList(); | ||||||
|  |                 if (ids != null && ids.Count > 0) | ||||||
|  |                     uids.AddRange(ids); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             Foresight.Standard.StringKeyValue[] alllangs = null; | ||||||
|  |             if (uids.Count > 0) | ||||||
|  |             { | ||||||
|  |                 alllangs = FleetServiceClientHelper.CreateClient<Foresight.Fleet.Services.User.UserQueryClient>().GetUserLanguages(); | ||||||
|  |             } | ||||||
|  |             return alllangs; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         public static string GetUserLanguage(Foresight.Standard.StringKeyValue[] alllangs, string uid) | ||||||
|  |         { | ||||||
|  |             var lang = "en-us"; | ||||||
|  |             if (alllangs != null) | ||||||
|  |             { | ||||||
|  |                 var item = alllangs.FirstOrDefault(m => m.Key == uid); | ||||||
|  |                 if (item != null) | ||||||
|  |                     lang = item.Value; | ||||||
|  |             } | ||||||
|  |             return lang; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private string GetShotLink(string longurl) | ||||||
|  |         { | ||||||
|  |             string serverurl = "https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=AIzaSyBzQFCgFK-ytQGGfMKePtvMyb1kSqvJ7_E"; | ||||||
|  |  | ||||||
|  |             string result = longurl; | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 //string dl = string.Format("https://foresight.page.link/?link={0}", longurl); | ||||||
|  |                 var obj = new | ||||||
|  |                 { | ||||||
|  |                     dynamicLinkInfo = new | ||||||
|  |                     { | ||||||
|  |                         domainUriPrefix = "https://foresight.page.link", | ||||||
|  |                         link = longurl | ||||||
|  |                     }, | ||||||
|  |                     suffix = new | ||||||
|  |                     { | ||||||
|  |                         option = "SHORT" | ||||||
|  |                     } | ||||||
|  |                 }; | ||||||
|  |                 string json = JsonConvert.SerializeObject(obj); | ||||||
|  |                 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serverurl); | ||||||
|  |                 request.Method = "POST"; | ||||||
|  |                 request.Accept = "application/json"; | ||||||
|  |                 //request.Accept = "*/*"; | ||||||
|  |                 request.ContentType = "application/json"; | ||||||
|  |  | ||||||
|  |                 byte[] byteRequest = Encoding.Default.GetBytes(json); | ||||||
|  |                 using (Stream rs = request.GetRequestStream()) | ||||||
|  |                 { | ||||||
|  |                     rs.Write(byteRequest, 0, byteRequest.Length); | ||||||
|  |                     //rs.Close(); | ||||||
|  |                 } | ||||||
|  |                 using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) | ||||||
|  |                 { | ||||||
|  |                     Stream resultStream = response.GetResponseStream(); | ||||||
|  |                     StreamReader sr = new StreamReader(resultStream, Encoding.UTF8); | ||||||
|  |                     string rjson = sr.ReadToEnd(); | ||||||
|  |                     Newtonsoft.Json.Linq.JObject robj = JsonConvert.DeserializeObject(rjson) as Newtonsoft.Json.Linq.JObject; | ||||||
|  |  | ||||||
|  |                     if (robj != null) | ||||||
|  |                     { | ||||||
|  |                         result = robj["shortLink"].ToString(); | ||||||
|  |                     } | ||||||
|  |  | ||||||
|  |                     sr.Close(); | ||||||
|  |                     resultStream.Close(); | ||||||
|  |                     response.Close(); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 SystemParams.WriteLog("error", "GetShotLink", ex.Message, ex.ToString()); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             return result; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         #endregion |         #endregion | ||||||
| @@ -517,21 +1001,14 @@ namespace IronIntel.Contractor.Site.MapView | |||||||
|                     string clientdata = HttpUtility.HtmlDecode(Context.Request.Params["ClientData"]); |                     string clientdata = HttpUtility.HtmlDecode(Context.Request.Params["ClientData"]); | ||||||
|                     StringKeyValue kv = JsonConvert.DeserializeObject<StringKeyValue>(clientdata); |                     StringKeyValue kv = JsonConvert.DeserializeObject<StringKeyValue>(clientdata); | ||||||
|                     string customerid = kv.Key; |                     string customerid = kv.Key; | ||||||
|                     if (string.IsNullOrEmpty(customerid)) |  | ||||||
|                         customerid = SystemParams.CompanyID; |  | ||||||
|  |  | ||||||
|                     ShapeFileInfo[] files = FleetServiceClientHelper.CreateClient<ShapeFileProvider>(customerid, LoginSession.SessionID).GetShapeFileInfos(customerid, kv.Value); |                     ShapeFileItem[] files = null; | ||||||
|                     if (files == null || files.Length == 0) |                     if (!SystemParams.IsDealer) | ||||||
|                         return new ShapeFileItem[0]; |                         files = AssetMapViewManagement.GetShapes(LoginSession.SessionID, customerid, kv.Value); | ||||||
|  |                     else | ||||||
|  |                         files = AssetMapViewManagement.GetDealerShapes(LoginSession.SessionID, customerid, kv.Value); | ||||||
|  |  | ||||||
|                     List<ShapeFileItem> list = new List<ShapeFileItem>(); |                     return files.OrderBy(m => m.Name).ToArray(); | ||||||
|                     foreach (ShapeFileInfo fi in files) |  | ||||||
|                     { |  | ||||||
|                         ShapeFileItem item = new ShapeFileItem(); |  | ||||||
|                         Helper.CloneProperty(item, fi); |  | ||||||
|                         list.Add(item); |  | ||||||
|                     } |  | ||||||
|                     return list.OrderBy(m => m.Name).ToArray(); |  | ||||||
|                 } |                 } | ||||||
|                 else |                 else | ||||||
|                 { |                 { | ||||||
| @@ -558,13 +1035,15 @@ namespace IronIntel.Contractor.Site.MapView | |||||||
|  |  | ||||||
|                     HttpPostedFile uploadFile = null; |                     HttpPostedFile uploadFile = null; | ||||||
|                     byte[] iconfilebyte = null; |                     byte[] iconfilebyte = null; | ||||||
|  |                     string filename = ""; | ||||||
|                     if (Context.Request.Files.Count > 0) |                     if (Context.Request.Files.Count > 0) | ||||||
|                     { |                     { | ||||||
|                         uploadFile = Context.Request.Files[0]; |                         uploadFile = Context.Request.Files[0]; | ||||||
|                         iconfilebyte = ConvertFile2bytes(uploadFile); |                         iconfilebyte = ConvertFile2bytes(uploadFile); | ||||||
|  |                         filename = uploadFile.FileName; | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|                     FleetServiceClientHelper.CreateClient<ShapeFileProvider>(customerid, LoginSession.SessionID).ImportShape(customerid, kv.Value, kv.Tag1, LoginSession.User.UID, iconfilebyte); |                     FleetServiceClientHelper.CreateClient<ShapeFileProvider>(customerid, LoginSession.SessionID).ImportShape(customerid, kv.Value, kv.Tag1, LoginSession.User.UID, filename, iconfilebyte); | ||||||
|  |  | ||||||
|                     return "OK"; |                     return "OK"; | ||||||
|                 } |                 } | ||||||
| @@ -587,13 +1066,24 @@ namespace IronIntel.Contractor.Site.MapView | |||||||
|                     string customerid = kv.Key; |                     string customerid = kv.Key; | ||||||
|                     if (string.IsNullOrEmpty(customerid)) |                     if (string.IsNullOrEmpty(customerid)) | ||||||
|                         customerid = SystemParams.CompanyID; |                         customerid = SystemParams.CompanyID; | ||||||
|  |                     string fileName = kv.Tag1 ?? ""; | ||||||
|  |  | ||||||
|                     byte[] buffer = FleetServiceClientHelper.CreateClient<ShapeFileProvider>(customerid, LoginSession.SessionID).GetShapeData(customerid, Convert.ToInt64(kv.Value)); |                     byte[] buffer = FleetServiceClientHelper.CreateClient<ShapeFileProvider>(customerid, LoginSession.SessionID).GetShapeData(customerid, Convert.ToInt64(kv.Value)); | ||||||
|                     Shape.Shape shape = new Shape.Shape(); |                     Shape.Shape shape = new Shape.Shape(); | ||||||
|  |  | ||||||
|  |                     if (fileName == "" || fileName.EndsWith(".shp", StringComparison.OrdinalIgnoreCase)) | ||||||
|                         Shape.ShapeFileParser.ParseFromShapeFile(buffer, shape); |                         Shape.ShapeFileParser.ParseFromShapeFile(buffer, shape); | ||||||
|  |                     else if (fileName.EndsWith(".kml", StringComparison.OrdinalIgnoreCase)) | ||||||
|  |                         Shape.ShapeFileParser.ParseFromKMLFile(buffer, shape); | ||||||
|  |                     else if (fileName.EndsWith(".kmz", StringComparison.OrdinalIgnoreCase)) | ||||||
|  |                         Shape.ShapeFileParser.ParseFromKMZFile(buffer, shape); | ||||||
|  |  | ||||||
|                     Shape.SimpleShape ss = new Shape.SimpleShape(); |                     Shape.SimpleShape ss = new Shape.SimpleShape(); | ||||||
|                     ss.FromShapeObj(shape); |                     ss.FromShapeObj(shape); | ||||||
|  |                     //#if DEBUG | ||||||
|  |                     //                    if (Convert.ToInt64(kv.Value) == 12d) | ||||||
|  |                     //                        ss = AutoJobsitesCreator.DoTest(GetCurrentLoginSession().SessionID); | ||||||
|  |                     //#endif | ||||||
|                     return ss; |                     return ss; | ||||||
|                 } |                 } | ||||||
|                 else |                 else | ||||||
| @@ -668,13 +1158,28 @@ namespace IronIntel.Contractor.Site.MapView | |||||||
|  |  | ||||||
|         #endregion |         #endregion | ||||||
|  |  | ||||||
|         public class SendLocationInfo |  | ||||||
|  |         private string GetNowFormatDate() | ||||||
|         { |         { | ||||||
|  |             if (LoginSession != null) | ||||||
|  |             { | ||||||
|  |                 return SystemParams.ConvertToUserTimeFromUtc(LoginSession.User, DateTime.UtcNow).ToString("M/d/yyyy h:m:s tt"); | ||||||
|  |             } | ||||||
|  |             return ""; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         public class SendEmailsInfo | ||||||
|  |         { | ||||||
|  |             public int Type { get; set; } | ||||||
|             public string CompanyID { get; set; } |             public string CompanyID { get; set; } | ||||||
|             public long AssetID { get; set; } |             public long ObjectID { get; set; } | ||||||
|  |             public long[] ObjectIDs { get; set; } | ||||||
|             public string Description { get; set; } |             public string Description { get; set; } | ||||||
|             public string[] EmailAddress { get; set; } |             public StringKeyValue[] EmailAddress { get; set; } | ||||||
|             public string[] TextAddress { get; set; } |             public StringKeyValue[] TextAddress { get; set; } | ||||||
|  |             public string HtmlBody { get; set; } | ||||||
|  |             public string Title { get; set; } | ||||||
|  |             public string AssignTo { get; set; } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public class GetMachineParameterItem |         public class GetMachineParameterItem | ||||||
| @@ -687,6 +1192,7 @@ namespace IronIntel.Contractor.Site.MapView | |||||||
|             public MapAlertLayerDefinitionItem[] Layers { get; set; } |             public MapAlertLayerDefinitionItem[] Layers { get; set; } | ||||||
|             public string MachineIDs { get; set; } |             public string MachineIDs { get; set; } | ||||||
|             public bool ExcludeNoLocation { get; set; } |             public bool ExcludeNoLocation { get; set; } | ||||||
|  |             public int Attachment { get; set; } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public class GetJobsiteParameterItem |         public class GetJobsiteParameterItem | ||||||
| @@ -697,16 +1203,56 @@ namespace IronIntel.Contractor.Site.MapView | |||||||
|             public string SearchText { get; set; } |             public string SearchText { get; set; } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public class MachineQueryResult |         public class AssetTripItem : AssetTripInfo | ||||||
|         { |         { | ||||||
|             public MachineViewItem[] Machines { get; set; } |             public TripColor Color { get; set; } | ||||||
|             public AssetGroupViewItem[] Groups { get; set; } |             public string TripTimeStr { get { return TripTime == null ? "" : TripTime.Value.ToString(); } } | ||||||
|  |             public string TripOnLocalAsofTimeStr { get { return TripOn == null ? "" : TripOn.LocalAsofTime.ToString("MM/dd/yyyy hh:mm:ss tt"); } } | ||||||
|  |             public string TripOffLocalAsofTimeStr { get { return TripOff == null ? "" : TripOff.LocalAsofTime.ToString("MM/dd/yyyy hh:mm:ss tt"); } } | ||||||
|  |             public string TripOnAddress | ||||||
|  |             { | ||||||
|  |                 get | ||||||
|  |                 { | ||||||
|  |                     var address = ""; | ||||||
|  |                     if (TripOn != null) | ||||||
|  |                     { | ||||||
|  |                         if (!string.IsNullOrEmpty(TripOn.Street)) | ||||||
|  |                             address = TripOn.Street; | ||||||
|  |                         if (!string.IsNullOrEmpty(TripOn.City)) | ||||||
|  |                             address += ", " + TripOn.City; | ||||||
|  |                         if (!string.IsNullOrEmpty(TripOn.State)) | ||||||
|  |                             address += ", " + TripOn.State; | ||||||
|                     } |                     } | ||||||
|         public class MapViewSearchClient |                     return address; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             public string TripOffAddress | ||||||
|             { |             { | ||||||
|             public string SearchName { get; set; } |                 get | ||||||
|             public bool IsDefault { get; set; } |                 { | ||||||
|             public int Type { get; set; } |                     var address = ""; | ||||||
|  |                     if (TripOff != null) | ||||||
|  |                     { | ||||||
|  |                         if (!string.IsNullOrEmpty(TripOff.Street)) | ||||||
|  |                             address = TripOff.Street; | ||||||
|  |                         if (!string.IsNullOrEmpty(TripOff.City)) | ||||||
|  |                             address += ", " + TripOff.City; | ||||||
|  |                         if (!string.IsNullOrEmpty(TripOff.State)) | ||||||
|  |                             address += ", " + TripOff.State; | ||||||
|  |                     } | ||||||
|  |                     return address; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         public enum TripColor | ||||||
|  |         { | ||||||
|  |             Blue, | ||||||
|  |             Green, | ||||||
|  |             Purple, | ||||||
|  |             Yellow, | ||||||
|  |             Pink, | ||||||
|  |             Red, | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -4,7 +4,6 @@ using System.Linq; | |||||||
| using System.Text; | using System.Text; | ||||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||||
| using System.Web; | using System.Web; | ||||||
| using IronIntel.Services; |  | ||||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor.Site | namespace IronIntel.Contractor.Site | ||||||
|   | |||||||
| @@ -110,18 +110,12 @@ namespace IronIntel.Contractor.Site.OTRConfig | |||||||
|                     var edatestr = HttpUtility.HtmlDecode(clientdata[1]); |                     var edatestr = HttpUtility.HtmlDecode(clientdata[1]); | ||||||
|                     var searchtxt = HttpUtility.HtmlDecode(clientdata[2]); |                     var searchtxt = HttpUtility.HtmlDecode(clientdata[2]); | ||||||
|  |  | ||||||
|                     DateTime startdate = DateTime.MinValue; |                     DateTime startdate = Helper.DBMinDateTime; | ||||||
|                     DateTime enddate = DateTime.MaxValue; |                     DateTime enddate = DateTime.MaxValue; | ||||||
|                     if (!DateTime.TryParse(sdatestr, out startdate)) |                     if (!DateTime.TryParse(sdatestr, out startdate)) | ||||||
|                         startdate = DateTime.MinValue; |                         startdate = Helper.DBMinDateTime; | ||||||
|                     if (!DateTime.TryParse(edatestr, out enddate)) |                     if (!DateTime.TryParse(edatestr, out enddate)) | ||||||
|                         enddate = DateTime.MaxValue; |                         enddate = DateTime.MaxValue; | ||||||
|                     else |  | ||||||
|                         enddate = enddate.Date.AddDays(1).AddSeconds(-1); |  | ||||||
|  |  | ||||||
|                     double timeOffset = SystemParams.GetHoursOffset(); |  | ||||||
|                     startdate = startdate.AddHours(-timeOffset); |  | ||||||
|                     enddate = enddate.AddHours(-timeOffset); |  | ||||||
|  |  | ||||||
|                     return HarshDrivingManagement.GetHarshDrivingEvents(session.SessionID, startdate, enddate, searchtxt, session.User.UID); |                     return HarshDrivingManagement.GetHarshDrivingEvents(session.SessionID, startdate, enddate, searchtxt, session.User.UID); | ||||||
|                 } |                 } | ||||||
|   | |||||||
| @@ -1,12 +1,20 @@ | |||||||
| using Foresight.Fleet.Services.AssetHealth; | using FI.FIC; | ||||||
|  | using Foresight.Fleet.Services.AssetHealth; | ||||||
|  | using Foresight.Fleet.Services.AssetHealth.WorkOrder; | ||||||
|  | using Foresight.Fleet.Services.Inspection; | ||||||
|  | using Foresight.Fleet.Services.JobSite; | ||||||
| using IronIntel.Contractor.FilterQ; | using IronIntel.Contractor.FilterQ; | ||||||
| using IronIntel.Contractor.Maintenance; | using IronIntel.Contractor.Maintenance; | ||||||
|  | using IronIntel.Contractor.Site.JobSite; | ||||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
|  | using System.IO; | ||||||
| using System.Linq; | using System.Linq; | ||||||
|  | using System.Net; | ||||||
| using System.Text; | using System.Text; | ||||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||||
|  | using static IronIntel.Contractor.Site.JobSite.JobSiteRequirementsBasePage; | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor.Site | namespace IronIntel.Contractor.Site | ||||||
| { | { | ||||||
| @@ -25,11 +33,98 @@ namespace IronIntel.Contractor.Site | |||||||
|                 case (int)PrintType.WorkOrder: |                 case (int)PrintType.WorkOrder: | ||||||
|                     result = PrintWorkOrder(); |                     result = PrintWorkOrder(); | ||||||
|                     break; |                     break; | ||||||
|  |                 case (int)PrintType.DispatchRequest: | ||||||
|  |                     result = PrintDispatchRequest(); | ||||||
|  |                     break; | ||||||
|  |                 case (int)PrintType.Attachment: | ||||||
|  |                     PrintAttachment(); | ||||||
|  |                     break; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             return result; |             return result; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         protected void PrintAttachment() | ||||||
|  |         { | ||||||
|  |             string at = Request.Params["at"]; | ||||||
|  |             string attaid = Request.Params["id"]; | ||||||
|  |  | ||||||
|  |             byte[] content = null; | ||||||
|  |             string ext = ""; | ||||||
|  |             string contentType = "application/octet-stream"; | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (at == "1" || at == "2") | ||||||
|  |                 { | ||||||
|  |                     long aid = 0; | ||||||
|  |                     if (!long.TryParse(attaid, out aid)) | ||||||
|  |                         return; | ||||||
|  |                     var client = FleetServiceClientHelper.CreateClient<WorkOrderProvider>(SystemParams.CompanyID, GetCurrentLoginSession().SessionID); | ||||||
|  |                     Tuple<string, byte[]> atta = null; | ||||||
|  |                     if (at == "1") | ||||||
|  |                     { | ||||||
|  |                         atta = client.GetAssetAttachmentData(SystemParams.CompanyID, aid); | ||||||
|  |                         FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "AssetAttachment", "", "Print", atta.Item1, "", atta.Item2); | ||||||
|  |                     } | ||||||
|  |  | ||||||
|  |                     else | ||||||
|  |                     { | ||||||
|  |                         atta = client.GetWorkOrderAttachmentData(SystemParams.CompanyID, aid); | ||||||
|  |                         FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "WorkOrderAttachment", "", "Print", atta.Item1, "", atta.Item2); | ||||||
|  |                     } | ||||||
|  |  | ||||||
|  |                     if (atta != null) | ||||||
|  |                     { | ||||||
|  |                         content = atta.Item2; | ||||||
|  |                         ext = atta.Item1; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |                 else if (at == "3") | ||||||
|  |                 { | ||||||
|  |                     var client = FleetServiceClientHelper.CreateClient<AssetInspectClient>(SystemParams.CompanyID, GetCurrentLoginSession().SessionID); | ||||||
|  |                     var atta = client.DownloadMediaContent(SystemParams.CompanyID, attaid); | ||||||
|  |                     FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "MediaContent", "", "DownLoad", "", atta.FileType, atta.Content); | ||||||
|  |                     if (atta != null) | ||||||
|  |                     { | ||||||
|  |                         content = atta.Content; | ||||||
|  |                         ext = atta.FileType; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |                 if (!Helper.FileTypes.TryGetValue(ext, out contentType)) | ||||||
|  |                     ext = Helper.GetFileExtention(ext); | ||||||
|  |                 if (!Helper.FileTypes.TryGetValue(ext, out contentType)) | ||||||
|  |                     contentType = "application/octet-stream"; | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 SystemParams.WriteLog("Error", "PrintAttachment", ex.Message, ex.ToString()); | ||||||
|  |             } | ||||||
|  |             Response.ContentType = contentType; | ||||||
|  |             Response.BinaryWrite(content); | ||||||
|  |             Response.End(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private string DownloadString(string url) | ||||||
|  |         { | ||||||
|  |             HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); | ||||||
|  |             return DownloadString(request); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private string DownloadString(HttpWebRequest request) | ||||||
|  |         { | ||||||
|  |             HttpWebResponse response = (HttpWebResponse)request.GetResponse(); | ||||||
|  |             using (Stream str = response.GetResponseStream()) | ||||||
|  |             { | ||||||
|  |                 using (StreamReader r = new StreamReader(str)) | ||||||
|  |                 { | ||||||
|  |                     string s = r.ReadToEnd(); | ||||||
|  |                     response.Close(); | ||||||
|  |                     return s; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|         private string PrintWorkOrder() |         private string PrintWorkOrder() | ||||||
|         { |         { | ||||||
|             string woidstr = Request.Params["wo"]; |             string woidstr = Request.Params["wo"]; | ||||||
| @@ -37,12 +132,64 @@ namespace IronIntel.Contractor.Site | |||||||
|             if (!long.TryParse(woidstr, out woid) || woid <= 0) |             if (!long.TryParse(woidstr, out woid) || woid <= 0) | ||||||
|                 return ""; |                 return ""; | ||||||
|  |  | ||||||
|             return WorkOrderManager.GenerateWorkOrderPrintHtml(GetCurrentLoginSession().SessionID, SystemParams.CompanyID, woid); |             var session = GetCurrentLoginSession(); | ||||||
|  |             string html = WorkOrderManager.GenerateWorkOrderPrintHtml(GetCurrentLoginSession().SessionID, SystemParams.CompanyID, woid, GetLanguageCookie()); | ||||||
|  |             FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "WorkOrder", "", "Print", "", "", null); | ||||||
|  |             return html; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private string PrintDispatchRequest() | ||||||
|  |         { | ||||||
|  |             int type = -1; | ||||||
|  |             string pt = Request.Params["t"]; | ||||||
|  |             if (!int.TryParse(pt, out type)) | ||||||
|  |                 return ""; | ||||||
|  |  | ||||||
|  |             string data = Request.Params["ids"]; | ||||||
|  |             long[] ids = JsonConvert.DeserializeObject<long[]>(data); | ||||||
|  |             if (ids == null || ids.Length == 0) | ||||||
|  |                 return ""; | ||||||
|  |  | ||||||
|  |             string assignto = System.Web.HttpUtility.HtmlDecode(Request.Params["assignto"]); | ||||||
|  |  | ||||||
|  |             var client = FleetServiceClientHelper.CreateClient<JobSiteDispatchProvider>(SystemParams.CompanyID, GetCurrentLoginSession().SessionID); | ||||||
|  |  | ||||||
|  |             JobSiteAssetDispatchInfo[] items = null; | ||||||
|  |             if (type == 0)//create requiremetn | ||||||
|  |             { | ||||||
|  |                 items = client.GetAssetDispatchsByRequirementIds(SystemParams.CompanyID, ids); | ||||||
|  |             } | ||||||
|  |             else//dispatch | ||||||
|  |             { | ||||||
|  |                 items = client.GetAssetDispatchsByIds(SystemParams.CompanyID, ids); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             if (items == null || items.Length == 0) | ||||||
|  |                 return ""; | ||||||
|  |  | ||||||
|  |             string html = GenerateDispatchPrintHtml(GetLanguageCookie(), items, assignto); | ||||||
|  |             var session = GetCurrentLoginSession(); | ||||||
|  |             FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "Dispatch", "", "Print", "", "", null); | ||||||
|  |             return html; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         public static string GenerateDispatchPrintHtml(string lang, JobSiteAssetDispatchInfo[] dispatchs, string assignto) | ||||||
|  |         { | ||||||
|  |             StringBuilder str = new StringBuilder(); | ||||||
|  |             str.AppendLine("<H1 style='text-align:center;'>" + SystemParams.GetTextByKey(lang, "P_JS_DISPATCHREQUESTS", "Dispatch Requests") + "</H1>"); | ||||||
|  |             if (!string.IsNullOrEmpty(assignto)) | ||||||
|  |                 str.AppendLine("<H2 style='text-align:center;'>" + SystemParams.GetTextByKey(lang, "P_JS_FORASSET_COLON", "For Asset:") + " " + assignto + "</H2>"); | ||||||
|  |  | ||||||
|  |             str.Append(GenerateDispatchHtml(lang, dispatchs, string.Empty, string.Empty)); | ||||||
|  |  | ||||||
|  |             return str.ToString(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         protected enum PrintType |         protected enum PrintType | ||||||
|         { |         { | ||||||
|             WorkOrder = 1 |             WorkOrder = 1, | ||||||
|  |             DispatchRequest = 2, | ||||||
|  |             Attachment = 3 | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -33,4 +33,4 @@ using System.Runtime.InteropServices; | |||||||
| // by using the '*' as shown below: | // by using the '*' as shown below: | ||||||
| // [assembly: AssemblyVersion("1.0.*")] | // [assembly: AssemblyVersion("1.0.*")] | ||||||
| [assembly: AssemblyVersion("1.0.0.0")] | [assembly: AssemblyVersion("1.0.0.0")] | ||||||
| [assembly: AssemblyFileVersion("2.20.609")] | [assembly: AssemblyFileVersion("23.4.26")] | ||||||
|   | |||||||
| @@ -2,12 +2,10 @@ | |||||||
| using Foresight.Fleet.Services.AssetHealth; | using Foresight.Fleet.Services.AssetHealth; | ||||||
| using Foresight.Fleet.Services.JobSite; | using Foresight.Fleet.Services.JobSite; | ||||||
| using Foresight.Fleet.Services.SystemOption; | using Foresight.Fleet.Services.SystemOption; | ||||||
| using IronIntel.Contractor.JobSites; |  | ||||||
| using IronIntel.Contractor.Maintenance; | using IronIntel.Contractor.Maintenance; | ||||||
| using IronIntel.Contractor.MapView; | using IronIntel.Contractor.MapView; | ||||||
| using IronIntel.Contractor.Security; | using IronIntel.Contractor.Security; | ||||||
| using IronIntel.Contractor.Users; | using IronIntel.Contractor.Users; | ||||||
| using IronIntel.Services.Customers; |  | ||||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| @@ -42,12 +40,6 @@ namespace IronIntel.Contractor.Site.Security | |||||||
|                         case "DeleteCurfew": |                         case "DeleteCurfew": | ||||||
|                             result = DeleteCurfew(); |                             result = DeleteCurfew(); | ||||||
|                             break; |                             break; | ||||||
|                         case "GetSelectedMachines": |  | ||||||
|                             result = GetSelectedMachines(); |  | ||||||
|                             break; |  | ||||||
|                         case "SaveCurfewMachines": |  | ||||||
|                             result = SaveCurfewMachines(); |  | ||||||
|                             break; |  | ||||||
|                         case "GetSelectedAssets": |                         case "GetSelectedAssets": | ||||||
|                             result = GetSelectedAssets(); |                             result = GetSelectedAssets(); | ||||||
|                             break; |                             break; | ||||||
| @@ -66,9 +58,6 @@ namespace IronIntel.Contractor.Site.Security | |||||||
|                         case "SaveCurfewJobsites": |                         case "SaveCurfewJobsites": | ||||||
|                             result = SaveCurfewJobsites(); |                             result = SaveCurfewJobsites(); | ||||||
|                             break; |                             break; | ||||||
|                         case "GetMachineList": |  | ||||||
|                             result = GetMachineList(); |  | ||||||
|                             break; |  | ||||||
|                         case "GetCurfewMovementTolerance": |                         case "GetCurfewMovementTolerance": | ||||||
|                             result = GetCurfewMovementTolerance(); |                             result = GetCurfewMovementTolerance(); | ||||||
|                             break; |                             break; | ||||||
| @@ -101,16 +90,10 @@ namespace IronIntel.Contractor.Site.Security | |||||||
|                     var contractorid = HttpUtility.HtmlDecode(clientdata[0]); |                     var contractorid = HttpUtility.HtmlDecode(clientdata[0]); | ||||||
|                     var searchtext = HttpUtility.HtmlDecode(clientdata[1]); |                     var searchtext = HttpUtility.HtmlDecode(clientdata[1]); | ||||||
|  |  | ||||||
|                     FISqlConnection contractordb = null; |  | ||||||
|                     if (!SystemParams.IsDealer) |                     if (!SystemParams.IsDealer) | ||||||
|                         contractorid = SystemParams.CompanyID; |                         contractorid = SystemParams.CompanyID; | ||||||
|                     else |  | ||||||
|                     { |  | ||||||
|                         string connetionstring = SystemParams.GetDbStringByCompany(contractorid); |  | ||||||
|                         contractordb = new FISqlConnection(connetionstring); |  | ||||||
|                     } |  | ||||||
|  |  | ||||||
|                     items = CurfewManagement.GetCurfews(session.SessionID, searchtext, contractordb); |                     items = CreateClient<CurfewClient>(contractorid).GetCurfews(contractorid, searchtext); | ||||||
|                 } |                 } | ||||||
|                 else |                 else | ||||||
|                 { |                 { | ||||||
| @@ -133,16 +116,10 @@ namespace IronIntel.Contractor.Site.Security | |||||||
|                     var contractorid = HttpUtility.HtmlDecode(clientdata[0]); |                     var contractorid = HttpUtility.HtmlDecode(clientdata[0]); | ||||||
|                     var curfewid = HttpUtility.HtmlDecode(clientdata[1]); |                     var curfewid = HttpUtility.HtmlDecode(clientdata[1]); | ||||||
|  |  | ||||||
|                     FISqlConnection contractordb = null; |  | ||||||
|                     if (!SystemParams.IsDealer) |                     if (!SystemParams.IsDealer) | ||||||
|                         contractorid = SystemParams.CompanyID; |                         contractorid = SystemParams.CompanyID; | ||||||
|                     else |  | ||||||
|                     { |  | ||||||
|                         string connetionstring = SystemParams.GetDbStringByCompany(contractorid); |  | ||||||
|                         contractordb = new FISqlConnection(connetionstring); |  | ||||||
|                     } |  | ||||||
|  |  | ||||||
|                     return CurfewManagement.GetCurfewInfo(curfewid, contractordb); |                     return CreateClient<CurfewClient>(contractorid).GetCurfewInfo(contractorid, curfewid); | ||||||
|                 } |                 } | ||||||
|                 else |                 else | ||||||
|                     return new CurfewInfo(); |                     return new CurfewInfo(); | ||||||
| @@ -164,23 +141,14 @@ namespace IronIntel.Contractor.Site.Security | |||||||
|                     var data = HttpUtility.HtmlDecode(clientdata[1]); |                     var data = HttpUtility.HtmlDecode(clientdata[1]); | ||||||
|  |  | ||||||
|                     var ci = JsonConvert.DeserializeObject<CurfewInfo>(data); |                     var ci = JsonConvert.DeserializeObject<CurfewInfo>(data); | ||||||
|                     if (string.IsNullOrWhiteSpace(ci.CurfewID)) |  | ||||||
|                     { |  | ||||||
|                         ci.CurfewID = Guid.NewGuid().ToString(); |  | ||||||
|                     } |  | ||||||
|  |  | ||||||
|                     FISqlConnection contractordb = null; |  | ||||||
|                     if (!SystemParams.IsDealer) |                     if (!SystemParams.IsDealer) | ||||||
|                         contractorid = SystemParams.CompanyID; |                         contractorid = SystemParams.CompanyID; | ||||||
|                     else |  | ||||||
|                     { |  | ||||||
|                         string connetionstring = SystemParams.GetDbStringByCompany(contractorid); |  | ||||||
|                         contractordb = new FISqlConnection(connetionstring); |  | ||||||
|                     } |  | ||||||
|  |  | ||||||
|                     CurfewManagement.SaveCurfew(ci, GetCurrentLoginSession().User.UID, contractordb); |  | ||||||
|  |  | ||||||
|                     return new string[] { ci.CurfewID, "OK" }; |                     ci.Id = CreateClient<CurfewClient>(contractorid).SaveCurfew(contractorid, ci); | ||||||
|  |  | ||||||
|  |                     return new string[] { ci.Id, "OK" }; | ||||||
|                 } |                 } | ||||||
|                 else |                 else | ||||||
|                 { |                 { | ||||||
| @@ -224,74 +192,10 @@ namespace IronIntel.Contractor.Site.Security | |||||||
|                     var contractorid = HttpUtility.HtmlDecode(clientdata[0]); |                     var contractorid = HttpUtility.HtmlDecode(clientdata[0]); | ||||||
|                     var curfewid = HttpUtility.HtmlDecode(clientdata[1]); |                     var curfewid = HttpUtility.HtmlDecode(clientdata[1]); | ||||||
|  |  | ||||||
|                     FISqlConnection contractordb = null; |  | ||||||
|                     if (!SystemParams.IsDealer) |                     if (!SystemParams.IsDealer) | ||||||
|                         contractorid = SystemParams.CompanyID; |                         contractorid = SystemParams.CompanyID; | ||||||
|                     else |  | ||||||
|                     { |  | ||||||
|                         string connetionstring = SystemParams.GetDbStringByCompany(contractorid); |  | ||||||
|                         contractordb = new FISqlConnection(connetionstring); |  | ||||||
|                     } |  | ||||||
|  |  | ||||||
|                     CurfewManagement.DeleteCurfew(curfewid, contractordb); |                     CreateClient<CurfewClient>(contractorid).DeleteCurfew(contractorid, curfewid); | ||||||
|  |  | ||||||
|                     return "OK"; |  | ||||||
|                 } |  | ||||||
|                 else |  | ||||||
|                 { |  | ||||||
|                     return "Failed"; |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             catch (Exception ex) |  | ||||||
|             { |  | ||||||
|                 return ex.Message; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private MaintenanceMachineInfo[] GetSelectedMachines() |  | ||||||
|         { |  | ||||||
|             var clientdata = Request.Form["ClientData"].Split((char)170); |  | ||||||
|             var contractorid = HttpUtility.HtmlDecode(clientdata[0]); |  | ||||||
|             var curfewid = HttpUtility.HtmlDecode(clientdata[1]); |  | ||||||
|  |  | ||||||
|             FISqlConnection contractordb = null; |  | ||||||
|             if (!SystemParams.IsDealer) |  | ||||||
|                 contractorid = SystemParams.CompanyID; |  | ||||||
|             else |  | ||||||
|             { |  | ||||||
|                 string connetionstring = SystemParams.GetDbStringByCompany(contractorid); |  | ||||||
|                 contractordb = new FISqlConnection(connetionstring); |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             var machines = CurfewManagement.GetCurfewMachinesByID(curfewid, contractordb); |  | ||||||
|  |  | ||||||
|             return machines.OrderBy(m => m.VIN).ToArray(); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private string SaveCurfewMachines() |  | ||||||
|         { |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 if (GetCurrentLoginSession() != null) |  | ||||||
|                 { |  | ||||||
|                     var clientdata = Request.Form["ClientData"].Split((char)170); |  | ||||||
|                     var contractorid = HttpUtility.HtmlDecode(clientdata[0]); |  | ||||||
|                     var curfewid = HttpUtility.HtmlDecode(clientdata[1]); |  | ||||||
|                     var machineids = HttpUtility.HtmlDecode(clientdata[2]); |  | ||||||
|                     if (string.IsNullOrWhiteSpace(contractorid)) |  | ||||||
|                         contractorid = SystemParams.CompanyID; |  | ||||||
|  |  | ||||||
|                     string[] ids = JsonConvert.DeserializeObject<string[]>(machineids); |  | ||||||
|  |  | ||||||
|                     FISqlConnection contractordb = null; |  | ||||||
|                     if (!SystemParams.IsDealer) |  | ||||||
|                         contractorid = SystemParams.CompanyID; |  | ||||||
|                     else |  | ||||||
|                     { |  | ||||||
|                         string connetionstring = SystemParams.GetDbStringByCompany(contractorid); |  | ||||||
|                         contractordb = new FISqlConnection(connetionstring); |  | ||||||
|                     } |  | ||||||
|                     CurfewManagement.SaveCurfewMachines(curfewid, contractorid, ids, contractordb); |  | ||||||
|  |  | ||||||
|                     return "OK"; |                     return "OK"; | ||||||
|                 } |                 } | ||||||
| @@ -393,32 +297,6 @@ namespace IronIntel.Contractor.Site.Security | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private MaintenanceMachineInfo[] GetMachineList() |  | ||||||
|         { |  | ||||||
|             var session = GetCurrentLoginSession(); |  | ||||||
|             var clientdata = Request.Form["ClientData"].Split((char)170); |  | ||||||
|             string contractorid = HttpUtility.HtmlDecode(clientdata[0]); |  | ||||||
|             string type = HttpUtility.HtmlDecode(clientdata[1]); |  | ||||||
|             string searchtxt = HttpUtility.HtmlDecode(clientdata[2]); |  | ||||||
|  |  | ||||||
|             int typeid = 0; |  | ||||||
|             int.TryParse(type, out typeid); |  | ||||||
|  |  | ||||||
|             FISqlConnection contractordb = null; |  | ||||||
|             if (!SystemParams.IsDealer) |  | ||||||
|                 contractorid = SystemParams.CompanyID; |  | ||||||
|             else |  | ||||||
|             { |  | ||||||
|                 string connetionstring = SystemParams.GetDbStringByCompany(contractorid); |  | ||||||
|                 contractordb = new FISqlConnection(connetionstring); |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             var machines = MaintenanceManagement.GetMaintenanceMachines(session.SessionID, typeid, searchtxt, session.User.UID, contractorid) |  | ||||||
|                 .OrderBy(m => m.VIN) |  | ||||||
|                 .ToArray(); |  | ||||||
|  |  | ||||||
|             return machines; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private object GetJobsiteList() |         private object GetJobsiteList() | ||||||
|         { |         { | ||||||
| @@ -431,14 +309,8 @@ namespace IronIntel.Contractor.Site.Security | |||||||
|                     string contractorid = HttpUtility.HtmlDecode(clientdata[0]); |                     string contractorid = HttpUtility.HtmlDecode(clientdata[0]); | ||||||
|                     string searchtxt = HttpUtility.HtmlDecode(clientdata[1]); |                     string searchtxt = HttpUtility.HtmlDecode(clientdata[1]); | ||||||
|  |  | ||||||
|                     FISqlConnection contractordb = null; |  | ||||||
|                     if (!SystemParams.IsDealer) |                     if (!SystemParams.IsDealer) | ||||||
|                         contractorid = SystemParams.CompanyID; |                         contractorid = SystemParams.CompanyID; | ||||||
|                     else |  | ||||||
|                     { |  | ||||||
|                         string connetionstring = SystemParams.GetDbStringByCompany(contractorid); |  | ||||||
|                         contractordb = new FISqlConnection(connetionstring); |  | ||||||
|                     } |  | ||||||
|  |  | ||||||
|                     var jss = CreateClient<JobSiteProvider>(contractorid).GetJobSiteItems(contractorid, "", false); |                     var jss = CreateClient<JobSiteProvider>(contractorid).GetJobSiteItems(contractorid, "", false); | ||||||
|                     List<JobSiteViewItem> list = new List<JobSiteViewItem>(); |                     List<JobSiteViewItem> list = new List<JobSiteViewItem>(); | ||||||
| @@ -474,16 +346,19 @@ namespace IronIntel.Contractor.Site.Security | |||||||
|                     var contractorid = HttpUtility.HtmlDecode(clientdata[0]); |                     var contractorid = HttpUtility.HtmlDecode(clientdata[0]); | ||||||
|                     var curfewid = HttpUtility.HtmlDecode(clientdata[1]); |                     var curfewid = HttpUtility.HtmlDecode(clientdata[1]); | ||||||
|  |  | ||||||
|                     FISqlConnection contractordb = null; |  | ||||||
|                     if (!SystemParams.IsDealer) |                     if (!SystemParams.IsDealer) | ||||||
|                         contractorid = SystemParams.CompanyID; |                         contractorid = SystemParams.CompanyID; | ||||||
|                     else |                     JobSiteItem[] jss = CreateClient<CurfewClient>(contractorid).GetJobSitesAssignedToCurfew(contractorid, curfewid); | ||||||
|  |                     List<JobSiteViewItem> list = new List<JobSiteViewItem>(); | ||||||
|  |                     foreach (var js in jss) | ||||||
|                     { |                     { | ||||||
|                         string connetionstring = SystemParams.GetDbStringByCompany(contractorid); |                         JobSiteViewItem item = new JobSiteViewItem(); | ||||||
|                         contractordb = new FISqlConnection(connetionstring); |                         item.ID = js.ID; | ||||||
|                     } |                         item.Name = js.Name; | ||||||
|  |  | ||||||
|                     items = CurfewManagement.GetCurfewJobsitesByID(curfewid, contractordb); |                         list.Add(item); | ||||||
|  |                     } | ||||||
|  |                     items = list.ToArray(); | ||||||
|                 } |                 } | ||||||
|                 else |                 else | ||||||
|                 { |                 { | ||||||
| @@ -507,21 +382,16 @@ namespace IronIntel.Contractor.Site.Security | |||||||
|                     var contractorid = HttpUtility.HtmlDecode(clientdata[0]); |                     var contractorid = HttpUtility.HtmlDecode(clientdata[0]); | ||||||
|                     var curfewid = HttpUtility.HtmlDecode(clientdata[1]); |                     var curfewid = HttpUtility.HtmlDecode(clientdata[1]); | ||||||
|                     var jobsiteids = HttpUtility.HtmlDecode(clientdata[2]); |                     var jobsiteids = HttpUtility.HtmlDecode(clientdata[2]); | ||||||
|  |  | ||||||
|                     if (string.IsNullOrWhiteSpace(contractorid)) |                     if (string.IsNullOrWhiteSpace(contractorid)) | ||||||
|                         contractorid = SystemParams.CompanyID; |                         contractorid = SystemParams.CompanyID; | ||||||
|  |  | ||||||
|                     string[] ids = JsonConvert.DeserializeObject<string[]>(jobsiteids); |                     long[] ids = JsonConvert.DeserializeObject<long[]>(jobsiteids); | ||||||
|  |  | ||||||
|                     FISqlConnection contractordb = null; |  | ||||||
|                     if (!SystemParams.IsDealer) |                     if (!SystemParams.IsDealer) | ||||||
|                         contractorid = SystemParams.CompanyID; |                         contractorid = SystemParams.CompanyID; | ||||||
|                     else |  | ||||||
|                     { |  | ||||||
|                         string connetionstring = SystemParams.GetDbStringByCompany(contractorid); |  | ||||||
|                         contractordb = new FISqlConnection(connetionstring); |  | ||||||
|                     } |  | ||||||
|  |  | ||||||
|                     CurfewManagement.SaveCurfewJobsites(curfewid, contractorid, ids, contractordb); |                     CreateClient<CurfewClient>(contractorid).AssignJobSitesToCurfew(contractorid, curfewid, ids); | ||||||
|  |  | ||||||
|                     return "OK"; |                     return "OK"; | ||||||
|                 } |                 } | ||||||
|   | |||||||
| @@ -1,76 +0,0 @@ | |||||||
| using IronIntel.Contractor.Users; |  | ||||||
| using Newtonsoft.Json; |  | ||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
| using System.Web; |  | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor.Site.Security |  | ||||||
| { |  | ||||||
|     public class DataTablePermissionBasePage : ContractorBasePage |  | ||||||
|     { |  | ||||||
|         protected void ProcessRequest(string methodName) |  | ||||||
|         { |  | ||||||
|             object result = null; |  | ||||||
|  |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 if (methodName != null) |  | ||||||
|                 { |  | ||||||
|                     switch (methodName.ToUpper()) |  | ||||||
|                     { |  | ||||||
|                         case "GETUSERS": |  | ||||||
|                             result = GetUsers(); |  | ||||||
|                             break; |  | ||||||
|                         case "GETUSERGROUPS": |  | ||||||
|                             result = GetUserGroups(); |  | ||||||
|                             break; |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             catch (Exception ex) |  | ||||||
|             { |  | ||||||
|                 result = ex.Message; |  | ||||||
|                 SystemParams.WriteLog("Error", "UserGroupBasePage.ProcessRequest", ex.Message, ex.ToString()); |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             string json = JsonConvert.SerializeObject(result); |  | ||||||
|             Response.Write(json); |  | ||||||
|             Response.End(); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         protected override bool AllowCurrentLoginSessionEnter() |  | ||||||
|         { |  | ||||||
|             var f = base.AllowCurrentLoginSessionEnter(); |  | ||||||
|             if (!f) |  | ||||||
|             { |  | ||||||
|                 return false; |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             // check whether you are admin. |  | ||||||
|             var session = GetCurrentLoginSession(); |  | ||||||
|             if (session == null || session.User == null) |  | ||||||
|             { |  | ||||||
|                 return false; |  | ||||||
|             } |  | ||||||
|             var ui = UserManagement.GetUserByIID(session.User.UID); |  | ||||||
|             return ui != null && ui.UserType >= UserTypes.Admin; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         protected override bool ThrowIfNotAllowed { get { return true; } } |  | ||||||
|  |  | ||||||
|         private UserInfo[] GetUsers() |  | ||||||
|         { |  | ||||||
|             var users = UserManagement.GetUnmanagementUsers().OrderBy(u => u.DisplayName).ToArray(); |  | ||||||
|             return users; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private UserGroupInfo[] GetUserGroups() |  | ||||||
|         { |  | ||||||
|             var groups = UserManagement.GetGroups(); |  | ||||||
|             return groups; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -1,651 +0,0 @@ | |||||||
| using FI.FIC.Contracts.DataObjects.BLObject; |  | ||||||
| using FI.FIC.Models; |  | ||||||
| using IronIntel.Contractor.Users; |  | ||||||
| using Newtonsoft.Json; |  | ||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Data; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
| using System.Web; |  | ||||||
|  |  | ||||||
| namespace IronIntel.Contractor.Site.Security |  | ||||||
| { |  | ||||||
|     public class FilterBasePage : ContractorBasePage |  | ||||||
|     { |  | ||||||
|         private const string sqlIn = "In"; |  | ||||||
|         private const string isnull = "Is Null"; |  | ||||||
|         private const string isnotnull = "Is Not Null"; |  | ||||||
|         private const string defaultLanageCode = "en-us"; |  | ||||||
|         protected void ProcessRequest(string methodName) |  | ||||||
|         { |  | ||||||
|             object result = null; |  | ||||||
|  |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 if (methodName != null) |  | ||||||
|                 { |  | ||||||
|                     switch (methodName.ToUpper()) |  | ||||||
|                     { |  | ||||||
|                         case "GETFILTEROBJECT": |  | ||||||
|                             result = GetFilterObject(); |  | ||||||
|                             break; |  | ||||||
|                         case "SAVEFILTER": |  | ||||||
|                             result = SaveFilter(); |  | ||||||
|                             break; |  | ||||||
|                         case "GETDATASOURCE": |  | ||||||
|                             result = GetDataSource(); |  | ||||||
|                             break; |  | ||||||
|                         case "GETTABLEFILTERS": |  | ||||||
|                             result = GetTableFilters(); |  | ||||||
|                             break; |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             catch (Exception ex) |  | ||||||
|             { |  | ||||||
|                 result = ex.Message; |  | ||||||
|                 SystemParams.WriteLog("Error", "FilterBasePage.ProcessRequest", ex.Message, ex.ToString()); |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             string json = JsonConvert.SerializeObject(result); |  | ||||||
|             Response.Write(json); |  | ||||||
|             Response.End(); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         protected override bool AllowCurrentLoginSessionEnter() |  | ||||||
|         { |  | ||||||
|             var f = base.AllowCurrentLoginSessionEnter(); |  | ||||||
|             if (!f) |  | ||||||
|             { |  | ||||||
|                 return false; |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             // check whether you are admin. |  | ||||||
|             var session = GetCurrentLoginSession(); |  | ||||||
|             if (session == null || session.User == null) |  | ||||||
|             { |  | ||||||
|                 return false; |  | ||||||
|             } |  | ||||||
|             var ui = UserManagement.GetUserByIID(session.User.UID); |  | ||||||
|             return ui != null && ui.UserType >= UserTypes.Admin; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         protected override bool ThrowIfNotAllowed { get { return true; } } |  | ||||||
|  |  | ||||||
|         private FilterObject GetFilterObject() |  | ||||||
|         { |  | ||||||
|             var p = Request.Form["ClientData"]; |  | ||||||
|             p = HttpUtility.HtmlDecode(p); |  | ||||||
|             int index = p.IndexOf(";"); |  | ||||||
|             string iid = p.Substring(0, index); |  | ||||||
|             string type = p.Substring(index + 1);//1为Group 2为User |  | ||||||
|  |  | ||||||
|             GlobalFilterAuthorize[] globalFilters = null; |  | ||||||
|             List<DataTableInfo> tableList = null; |  | ||||||
|             TableFilterAuthorize[] tableFilters = null; |  | ||||||
|             List<FI.FIC.Contracts.DataObjects.BaseObject.Plugin> pluginList = PluginManager.GetPlugin(); |  | ||||||
|             if (type == "1") |  | ||||||
|             { |  | ||||||
|                 globalFilters = GlobalFilterManager.GetGlobalFilterAuthorizeForGroup(iid); |  | ||||||
|                 tableList = DataTableManager.GetHaveTableFilterDataTableListForUserGroup(iid, defaultLanageCode); |  | ||||||
|                 if (tableList != null && tableList.Count > 0) |  | ||||||
|                 { |  | ||||||
|                     tableFilters = GlobalFilterManager.GetTableFilterAuthorizeForGroup(iid, tableList[0].IID); |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             else if (type == "2") |  | ||||||
|             { |  | ||||||
|                 globalFilters = GlobalFilterManager.GetGlobalFilterAuthorizeForUser(iid); |  | ||||||
|                 tableList = DataTableManager.GetHaveTableFilterDataTableList(iid, defaultLanageCode); |  | ||||||
|                 if (tableList != null && tableList.Count > 0) |  | ||||||
|                 { |  | ||||||
|                     tableFilters = GlobalFilterManager.GetTableFilterAuthorizeForUser(iid, tableList[0].IID); |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             FilterObject filterObj = new FilterObject(); |  | ||||||
|  |  | ||||||
|             if (globalFilters != null) |  | ||||||
|             { |  | ||||||
|                 List<Filter> gfs = new List<Filter>(); |  | ||||||
|                 foreach (var item in globalFilters) |  | ||||||
|                 { |  | ||||||
|                     Filter gf = new Filter(); |  | ||||||
|                     gf.FilterName = item.FilterName; |  | ||||||
|                     gf.FilterCondition = item.FilterCondition ?? " "; |  | ||||||
|                     gf.FilterDataType = (int)item.FilterDataType; |  | ||||||
|                     gf.FilterType = (int)item.FilterType; |  | ||||||
|                     if (gf.FilterType == 0) |  | ||||||
|                         gf.FilterTypeString = "Single Value"; |  | ||||||
|                     else |  | ||||||
|                         gf.FilterTypeString = getPluginName(item.PluginID, pluginList); |  | ||||||
|                     gf.FilterValue = item.FilterValue; |  | ||||||
|                     gf.IID = item.IID; |  | ||||||
|                     gf.PluginID = item.PluginID; |  | ||||||
|  |  | ||||||
|                     gfs.Add(gf); |  | ||||||
|                 } |  | ||||||
|                 filterObj.GlobalFilters = gfs.ToArray(); |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             if (tableList != null) |  | ||||||
|             { |  | ||||||
|                 List<KeyValuePair<string, string>> dts = new List<KeyValuePair<string, string>>(); |  | ||||||
|                 foreach (var item in tableList) |  | ||||||
|                 { |  | ||||||
|                     KeyValuePair<string, string> kv = new KeyValuePair<string, string>(item.IID, item.DataTableName); |  | ||||||
|                     dts.Add(kv); |  | ||||||
|                 } |  | ||||||
|                 filterObj.DataTableList = dts.ToArray(); |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             if (tableFilters != null) |  | ||||||
|             { |  | ||||||
|                 List<Filter> tfs = new List<Filter>(); |  | ||||||
|                 foreach (var item in tableFilters) |  | ||||||
|                 { |  | ||||||
|                     Filter tf = new Filter(); |  | ||||||
|                     tf.FieldName = item.FieldName; |  | ||||||
|                     tf.FilterName = item.FilterName; |  | ||||||
|                     tf.FilterCondition = item.FilterCondition ?? " "; |  | ||||||
|                     tf.FilterDataType = (int)item.FilterDataType; |  | ||||||
|                     tf.FilterType = (int)item.FilterType; |  | ||||||
|                     if (tf.FilterType == 0) |  | ||||||
|                         tf.FilterTypeString = "Single Value"; |  | ||||||
|                     else |  | ||||||
|                         tf.FilterTypeString = getPluginName(item.PluginID, pluginList); |  | ||||||
|                     tf.FilterValue = item.FilterValue; |  | ||||||
|                     tf.IID = item.IID; |  | ||||||
|                     tf.PluginID = item.PluginID; |  | ||||||
|  |  | ||||||
|                     tfs.Add(tf); |  | ||||||
|                 } |  | ||||||
|                 filterObj.FirstTableFilters = tfs.ToArray(); |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             return filterObj; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private string getPluginName(string iid, List<FI.FIC.Contracts.DataObjects.BaseObject.Plugin> pluginList) |  | ||||||
|         { |  | ||||||
|             string result = ""; |  | ||||||
|             if (pluginList != null) |  | ||||||
|             { |  | ||||||
|                 var plugin = pluginList.FirstOrDefault((p) => p.IID.Equals(iid, StringComparison.OrdinalIgnoreCase)); |  | ||||||
|                 if (plugin != null) |  | ||||||
|                     result = plugin.PluginName; |  | ||||||
|             } |  | ||||||
|             return result; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private object SaveFilter() |  | ||||||
|         { |  | ||||||
|             if (GetCurrentLoginSession() != null) |  | ||||||
|             { |  | ||||||
|                 var s = Request.Form["ClientData"]; |  | ||||||
|                 s = HttpUtility.HtmlDecode(s); |  | ||||||
|                 SaveFilterObject item = JsonConvert.DeserializeObject<SaveFilterObject>(s); |  | ||||||
|  |  | ||||||
|                 if (item.Type == 2) |  | ||||||
|                 { |  | ||||||
|                     var user = UserManagement.GetUserByIID(item.UserIID); |  | ||||||
|                     if (user.UserType == UserTypes.Admin)//Admin用户不需要修改 |  | ||||||
|                         return "\"OK\""; |  | ||||||
|                 } |  | ||||||
|                 string error = ""; |  | ||||||
|                 if (!Validate(ref error, item)) |  | ||||||
|                 { |  | ||||||
|                     return new ErrorObject() { ErrorCode = 1, ErrorMessage = error }; |  | ||||||
|                 } |  | ||||||
|                 DoSaveFilter(item); |  | ||||||
|                 return "\"OK\""; |  | ||||||
|             } |  | ||||||
|             else |  | ||||||
|             { |  | ||||||
|                 return "\"Failed\""; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private void DoSaveFilter(SaveFilterObject filterObject) |  | ||||||
|         { |  | ||||||
|             List<GlobalFilterAuthorize> globalFilter = new List<GlobalFilterAuthorize>(); |  | ||||||
|             if (filterObject.GlobalFilter != null) |  | ||||||
|             { |  | ||||||
|                 foreach (var item in filterObject.GlobalFilter) |  | ||||||
|                 { |  | ||||||
|                     GlobalFilterAuthorize gf = new GlobalFilterAuthorize(); |  | ||||||
|                     gf.FilterName = item.FilterName; |  | ||||||
|                     gf.FilterCondition = item.FilterCondition; |  | ||||||
|                     gf.FilterDataType = (FI.FIC.Contracts.DataObjects.Enumeration.DBDataType)item.FilterDataType; |  | ||||||
|                     gf.FilterType = (FI.FIC.Contracts.DataObjects.Enumeration.FilterType)item.FilterType; |  | ||||||
|                     gf.FilterValue = item.FilterValue; |  | ||||||
|                     gf.IID = item.IID; |  | ||||||
|                     gf.PluginID = item.PluginID; |  | ||||||
|  |  | ||||||
|                     globalFilter.Add(gf); |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             List<TableFilterAuthorize> tableFilter = new List<TableFilterAuthorize>(); |  | ||||||
|             if (filterObject.TableFilters != null) |  | ||||||
|             { |  | ||||||
|                 foreach (var tfobj in filterObject.TableFilters) |  | ||||||
|                 { |  | ||||||
|                     foreach (var item in tfobj.Filters) |  | ||||||
|                     { |  | ||||||
|                         TableFilterAuthorize tf = new TableFilterAuthorize(); |  | ||||||
|                         tf.FilterName = item.FilterName; |  | ||||||
|                         tf.FilterCondition = item.FilterCondition; |  | ||||||
|                         tf.FilterDataType = (FI.FIC.Contracts.DataObjects.Enumeration.DBDataType)item.FilterDataType; |  | ||||||
|                         tf.FilterType = (FI.FIC.Contracts.DataObjects.Enumeration.FilterType)item.FilterType; |  | ||||||
|                         tf.FilterValue = item.FilterValue; |  | ||||||
|                         tf.IID = item.IID; |  | ||||||
|                         tf.PluginID = item.PluginID; |  | ||||||
|  |  | ||||||
|                         tableFilter.Add(tf); |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             if (filterObject.Type == 1)//1为Group,2为User |  | ||||||
|             { |  | ||||||
|                 GlobalFilterManager.SaveGlobalFilterAuthorizeForGroup(filterObject.UserIID, globalFilter.ToArray(), tableFilter.ToArray()); |  | ||||||
|             } |  | ||||||
|             else if (filterObject.Type == 2) |  | ||||||
|             { |  | ||||||
|                 GlobalFilterManager.SaveGlobalFilterAuthorizeForUser(filterObject.UserIID, globalFilter.ToArray(), tableFilter.ToArray()); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private DataSourceObject GetDataSource() |  | ||||||
|         { |  | ||||||
|             DataSourceObject result = new DataSourceObject(); |  | ||||||
|             var s = Request.Form["ClientData"]; |  | ||||||
|             string dsiid = HttpUtility.HtmlDecode(s); |  | ||||||
|             PluginStructure dsStructure = PluginManager.GetPluginStructure(dsiid); |  | ||||||
|             PluginManager pm = new PluginManager(); |  | ||||||
|             DataTable dt = pm.GetSourceData(dsiid, null); |  | ||||||
|  |  | ||||||
|             int indexOfName = dt.Columns.IndexOf(dsStructure.DataImport.DisplayField); |  | ||||||
|             int indexOfID = dt.Columns.IndexOf(dsStructure.DataImport.ValueField); |  | ||||||
|             int indexOfPID = dt.Columns.IndexOf(dsStructure.DataImport.ParentField); |  | ||||||
|             if (indexOfName < 0) |  | ||||||
|                 indexOfName = dt.Columns.IndexOf("Name"); |  | ||||||
|             if (indexOfID < 0) |  | ||||||
|                 indexOfID = dt.Columns.IndexOf("ID"); |  | ||||||
|             if (indexOfPID < 0) |  | ||||||
|                 indexOfPID = dt.Columns.IndexOf("PID"); |  | ||||||
|  |  | ||||||
|             result.IID = dsStructure.IID; |  | ||||||
|             result.IsFlat = dsStructure.IsFlat == 1; |  | ||||||
|             if (!result.IsFlat) |  | ||||||
|                 result.IsFlat = IsFlat(dt, indexOfPID); |  | ||||||
|             result.Name = dsStructure.PluginName; |  | ||||||
|             result.DisplayField = dsStructure.DataImport.DisplayField; |  | ||||||
|             result.ValueField = dsStructure.DataImport.ValueField; |  | ||||||
|  |  | ||||||
|             List<DataSourceData> datas = new List<DataSourceData>(); |  | ||||||
|             if (result.IsFlat) |  | ||||||
|             { |  | ||||||
|                 foreach (DataRow dr in dt.Select("", dt.Columns[indexOfID].ColumnName + " asc")) |  | ||||||
|                 { |  | ||||||
|                     DataSourceData ds = new DataSourceData(); |  | ||||||
|                     ds.ID = dr[indexOfID].ToString(); |  | ||||||
|                     ds.Description = dr[indexOfName].ToString(); |  | ||||||
|                     if (indexOfPID >= 0) |  | ||||||
|                         ds.PID = dr[indexOfPID].ToString(); |  | ||||||
|                     datas.Add(ds); |  | ||||||
|                 } |  | ||||||
|                 //datas = datas.OrderBy((d) => d.ID).ToList(); |  | ||||||
|             } |  | ||||||
|             else |  | ||||||
|             { |  | ||||||
|                 Dictionary<string, DataSourceData> nodes = new Dictionary<string, DataSourceData>(); |  | ||||||
|                 foreach (DataRow dr in dt.Select("", dt.Columns[indexOfID].ColumnName + " asc")) |  | ||||||
|                 { |  | ||||||
|                     DataSourceData ds = new DataSourceData(); |  | ||||||
|                     ds.ID = dr[indexOfID].ToString(); |  | ||||||
|                     ds.Description = dr[indexOfName].ToString(); |  | ||||||
|                     if (indexOfPID >= 0) |  | ||||||
|                         ds.PID = dr[indexOfPID].ToString(); |  | ||||||
|                     //if (nodes.ContainsKey(ds.PID)) |  | ||||||
|                     //{ |  | ||||||
|                     //    DataSourceData pnode = nodes[ds.PID]; |  | ||||||
|                     //    List<DataSourceData> subNodes = new List<DataSourceData>(); |  | ||||||
|                     //    if (pnode.SubData != null) |  | ||||||
|                     //        subNodes.AddRange(pnode.SubData); |  | ||||||
|                     //    subNodes.Add(ds); |  | ||||||
|                     //    pnode.SubData = subNodes.ToArray(); |  | ||||||
|                     //} |  | ||||||
|                     nodes[ds.ID] = ds; |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 foreach (var kv in nodes) |  | ||||||
|                 { |  | ||||||
|                     if (nodes.ContainsKey(kv.Value.PID)) |  | ||||||
|                     { |  | ||||||
|                         DataSourceData pnode = nodes[kv.Value.PID]; |  | ||||||
|                         List<DataSourceData> subNodes = new List<DataSourceData>(); |  | ||||||
|                         if (pnode.SubData != null) |  | ||||||
|                             subNodes.AddRange(pnode.SubData); |  | ||||||
|                         subNodes.Add(kv.Value); |  | ||||||
|                         pnode.SubData = subNodes.ToArray(); |  | ||||||
|                     } |  | ||||||
|                     else |  | ||||||
|                         datas.Add(kv.Value); |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             result.Data = datas.ToArray(); |  | ||||||
|  |  | ||||||
|             return result; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private Filter[] GetTableFilters() |  | ||||||
|         { |  | ||||||
|             var p = Request.Form["ClientData"]; |  | ||||||
|             p = HttpUtility.HtmlDecode(p); |  | ||||||
|             int index = p.IndexOf(";"); |  | ||||||
|             string iid = p.Substring(0, index); |  | ||||||
|             int index1 = p.IndexOf(";", index + 1); |  | ||||||
|             string type = p.Substring(index + 1, index1 - index - 1);//1为Group 2为User |  | ||||||
|             string dtiid = p.Substring(index1 + 1); |  | ||||||
|  |  | ||||||
|             TableFilterAuthorize[] tableFilters = null; |  | ||||||
|             List<FI.FIC.Contracts.DataObjects.BaseObject.Plugin> pluginList = PluginManager.GetPlugin(); |  | ||||||
|             if (type == "1") |  | ||||||
|             { |  | ||||||
|                 tableFilters = GlobalFilterManager.GetTableFilterAuthorizeForGroup(iid, dtiid); |  | ||||||
|             } |  | ||||||
|             else if (type == "2") |  | ||||||
|             { |  | ||||||
|                 tableFilters = GlobalFilterManager.GetTableFilterAuthorizeForUser(iid, dtiid); |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             List<Filter> filters = new List<Filter>(); |  | ||||||
|  |  | ||||||
|             if (tableFilters != null) |  | ||||||
|             { |  | ||||||
|                 foreach (var item in tableFilters) |  | ||||||
|                 { |  | ||||||
|                     Filter tf = new Filter(); |  | ||||||
|                     tf.FieldName = item.FieldName; |  | ||||||
|                     tf.FilterName = item.FilterName; |  | ||||||
|                     tf.FilterCondition = item.FilterCondition ?? " "; |  | ||||||
|                     tf.FilterDataType = (int)item.FilterDataType; |  | ||||||
|                     tf.FilterType = (int)item.FilterType; |  | ||||||
|                     if (tf.FilterType == 0) |  | ||||||
|                         tf.FilterTypeString = "Single Value"; |  | ||||||
|                     else |  | ||||||
|                         tf.FilterTypeString = getPluginName(item.PluginID, pluginList); |  | ||||||
|                     tf.FilterValue = item.FilterValue; |  | ||||||
|                     tf.IID = item.IID; |  | ||||||
|                     tf.PluginID = item.PluginID; |  | ||||||
|  |  | ||||||
|                     filters.Add(tf); |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             return filters.ToArray(); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// 判断数据源的数据是否是树形结构 |  | ||||||
|         /// </summary> |  | ||||||
|         /// <returns></returns> |  | ||||||
|         private bool IsFlat(DataTable dt, int pidIndex) |  | ||||||
|         { |  | ||||||
|             if (pidIndex < 0) return true; |  | ||||||
|  |  | ||||||
|             List<string> ids = new List<string>(); |  | ||||||
|             List<string> pids = new List<string>(); |  | ||||||
|  |  | ||||||
|             foreach (DataRow dr in dt.Rows) |  | ||||||
|             { |  | ||||||
|                 string id = dr[pidIndex].ToString(); |  | ||||||
|                 if (pids.IndexOf(id) >= 0) |  | ||||||
|                     return false; |  | ||||||
|  |  | ||||||
|                 string pid = dr[pidIndex].ToString(); |  | ||||||
|                 if (ids.IndexOf(pid) >= 0) |  | ||||||
|                     return false; |  | ||||||
|  |  | ||||||
|                 ids.Add(id); |  | ||||||
|                 pids.Add(pid); |  | ||||||
|             } |  | ||||||
|             return true; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private bool Validate(ref string error, SaveFilterObject FilterObj) |  | ||||||
|         { |  | ||||||
|             string msg = ""; |  | ||||||
|             if (FilterObj.GlobalFilter != null && FilterObj.GlobalFilter.Length > 0) |  | ||||||
|             { |  | ||||||
|                 Filter errorObj = null; |  | ||||||
|                 if (!ValidateFilter(ref msg, FilterObj.GlobalFilter, out errorObj)) |  | ||||||
|                 { |  | ||||||
|                     //string TableFilterError = CommonHelper.GetLangauge("LHBIS.FIC.Client.Modules.FilterManagement.A016") + "\n"; |  | ||||||
|                     error = "Filter '{0}' in global filter:" + "\n"; |  | ||||||
|                     error = string.Format(error, errorObj.FilterName); |  | ||||||
|                     error = error + msg; |  | ||||||
|                     return false; |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             if (FilterObj.TableFilters != null && FilterObj.TableFilters.Length > 0) |  | ||||||
|             { |  | ||||||
|                 foreach (var tf in FilterObj.TableFilters) |  | ||||||
|                 { |  | ||||||
|                     Filter errorObj = null; |  | ||||||
|                     if (!ValidateFilter(ref msg, tf.Filters, out errorObj)) |  | ||||||
|                     { |  | ||||||
|                         //string TableFilterError = CommonHelper.GetLangauge("LHBIS.FIC.Client.Modules.FilterManagement.A017") + "\n"; |  | ||||||
|                         error = "Filter '{0}' in  the data Table '{1}':" + "\n"; |  | ||||||
|                         error = string.Format(error, errorObj.FilterName, tf.TableName); |  | ||||||
|                         error = error + msg; |  | ||||||
|                         return false; |  | ||||||
|                     } |  | ||||||
|  |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             return true; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private bool ValidateFilter(ref string error, Filter[] Filters, out Filter errorObj) |  | ||||||
|         { |  | ||||||
|             errorObj = null; |  | ||||||
|             for (int i = 0; i < Filters.Length; i++) |  | ||||||
|             { |  | ||||||
|                 Filter item = Filters[i]; |  | ||||||
|                 if (!string.IsNullOrWhiteSpace(item.FilterCondition)) |  | ||||||
|                 { |  | ||||||
|                     if ((item.FilterCondition == isnull) || (item.FilterCondition == isnotnull)) |  | ||||||
|                     { |  | ||||||
|                         item.FilterValue = ""; |  | ||||||
|                     } |  | ||||||
|                     else if (item.FilterCondition != sqlIn) |  | ||||||
|                     { |  | ||||||
|                         bool returnValue = true; |  | ||||||
|                         switch (item.FilterDataType) |  | ||||||
|                         { |  | ||||||
|                             case (int)FI.FIC.Contracts.DataObjects.Enumeration.DBDataType.dtBoolean: |  | ||||||
|                                 try |  | ||||||
|                                 { |  | ||||||
|                                     bool.Parse(item.FilterValue); |  | ||||||
|                                 } |  | ||||||
|                                 catch |  | ||||||
|                                 { |  | ||||||
|                                     error = "The Filter value must be True/False.";// CommonHelper.GetLangauge("LHBIS.FIC.Client.Modules.FilterManagement.A012"); |  | ||||||
|                                     returnValue = false; |  | ||||||
|                                 } |  | ||||||
|                                 break; |  | ||||||
|                             case (int)FI.FIC.Contracts.DataObjects.Enumeration.DBDataType.dtDate: |  | ||||||
|                                 try |  | ||||||
|                                 { |  | ||||||
|                                     //必须要满足(月日年)或(年月日)的格式 |  | ||||||
|                                     DateTime t = DateTime.Now; |  | ||||||
|                                     try |  | ||||||
|                                     { |  | ||||||
|                                         t = DateTime.Parse(item.FilterValue, new System.Globalization.DateTimeFormatInfo()); |  | ||||||
|                                     } |  | ||||||
|                                     catch |  | ||||||
|                                     { |  | ||||||
|                                     } |  | ||||||
|                                     string tFilterValue = item.FilterValue.Replace(".", "-").Replace("/", "-"); |  | ||||||
|                                     if (!tFilterValue.StartsWith(t.ToString("MM-dd-yyyy")) |  | ||||||
|                                         && !tFilterValue.StartsWith(t.ToString("MM-d-yyyy")) |  | ||||||
|                                         && !tFilterValue.StartsWith(t.ToString("M-dd-yyyy")) |  | ||||||
|                                         && !tFilterValue.StartsWith(t.ToString("M-d-yyyy")) |  | ||||||
|                                         && !tFilterValue.StartsWith(t.ToString("yyyy-MM-dd")) |  | ||||||
|                                         && !tFilterValue.StartsWith(t.ToString("yyyy-MM-d")) |  | ||||||
|                                         && !tFilterValue.StartsWith(t.ToString("yyyy-M-dd")) |  | ||||||
|                                         && !tFilterValue.StartsWith(t.ToString("yyyy-M-d"))) |  | ||||||
|                                     { |  | ||||||
|                                         throw new Exception(); |  | ||||||
|                                     } |  | ||||||
|                                 } |  | ||||||
|                                 catch |  | ||||||
|                                 { |  | ||||||
|                                     error = "The Filter value must be a date.";// CommonHelper.GetLangauge("LHBIS.FIC.Client.Modules.FilterManagement.A013"); |  | ||||||
|                                     error += " " + "Date format must be 'MM/dd/yyyy' or 'yyyy-MM-dd'";// CommonHelper.GetLangauge("LHBIS.FIC.Client.Wizard.ChartWizardHelper.A286"); |  | ||||||
|                                     returnValue = false; |  | ||||||
|                                 } |  | ||||||
|                                 break; |  | ||||||
|                             case (int)FI.FIC.Contracts.DataObjects.Enumeration.DBDataType.dtFloat: |  | ||||||
|                                 try |  | ||||||
|                                 { |  | ||||||
|                                     float.Parse(item.FilterValue); |  | ||||||
|                                 } |  | ||||||
|                                 catch |  | ||||||
|                                 { |  | ||||||
|                                     error = "The Filter value must be a floating point.";//CommonHelper.GetLangauge("LHBIS.FIC.Client.Modules.FilterManagement.A014"); |  | ||||||
|                                     returnValue = false; |  | ||||||
|                                 } |  | ||||||
|                                 break; |  | ||||||
|                             case (int)FI.FIC.Contracts.DataObjects.Enumeration.DBDataType.dtInteger: |  | ||||||
|                                 try |  | ||||||
|                                 { |  | ||||||
|                                     int.Parse(item.FilterValue); |  | ||||||
|                                 } |  | ||||||
|                                 catch |  | ||||||
|                                 { |  | ||||||
|                                     error = "The Filter Value must be an integer.";// CommonHelper.GetLangauge("LHBIS.FIC.Client.Modules.FilterManagement.A015"); |  | ||||||
|                                     returnValue = false; |  | ||||||
|                                 } |  | ||||||
|                                 break; |  | ||||||
|                             case (int)FI.FIC.Contracts.DataObjects.Enumeration.DBDataType.dtGuid: |  | ||||||
|                                 try |  | ||||||
|                                 { |  | ||||||
|                                     if (string.IsNullOrEmpty(item.FilterValue)) |  | ||||||
|                                         item.FilterValue = Guid.Empty.ToString(); |  | ||||||
|                                     else |  | ||||||
|                                         new Guid(item.FilterValue); |  | ||||||
|                                 } |  | ||||||
|                                 catch |  | ||||||
|                                 { |  | ||||||
|                                     error = "The Filter Value must be a GUID.";// CommonHelper.GetLangauge("LHBIS.FIC.Client.Modules.FilterManagement.A018"); |  | ||||||
|                                     returnValue = false; |  | ||||||
|                                 } |  | ||||||
|                                 break; |  | ||||||
|                         } |  | ||||||
|  |  | ||||||
|                         if (returnValue == false) |  | ||||||
|                         { |  | ||||||
|                             errorObj = item; |  | ||||||
|                             return returnValue; |  | ||||||
|                         } |  | ||||||
|                     } |  | ||||||
|  |  | ||||||
|                     if (item.FilterValue.Length > 2000) |  | ||||||
|                     { |  | ||||||
|                         errorObj = item; |  | ||||||
|                         error = "The length of the Filter Value must be less than 2000.";// 没有资源号 |  | ||||||
|                         return false; |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             return true; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         #region Model |  | ||||||
|         public class Filter |  | ||||||
|         { |  | ||||||
|             public string IID { get; set; } |  | ||||||
|             public string FilterName { get; set; } |  | ||||||
|             public int FilterType { get; set; } |  | ||||||
|             public string FilterTypeString { get; set; } |  | ||||||
|             public string FieldName { get; set; } |  | ||||||
|             public int FilterDataType { get; set; } |  | ||||||
|             public string FilterDataTypeString |  | ||||||
|             { |  | ||||||
|                 get |  | ||||||
|                 { |  | ||||||
|                     string dataType = Enum.GetName(typeof(FI.FIC.Contracts.DataObjects.Enumeration.DBDataType), FilterDataType); |  | ||||||
|                     if (dataType == null) return null; |  | ||||||
|                     if (dataType.StartsWith("dt")) |  | ||||||
|                     { |  | ||||||
|                         return dataType.Substring(2, dataType.Length - 2); |  | ||||||
|                     } |  | ||||||
|                     return dataType; |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             public string FilterCondition { get; set; } |  | ||||||
|             public string FilterValue { get; set; } |  | ||||||
|             public string PluginID { get; set; } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// 包含Global Filter, DataTable List和第一个DataTable的Filter |  | ||||||
|         /// </summary> |  | ||||||
|         public class FilterObject |  | ||||||
|         { |  | ||||||
|             public Filter[] GlobalFilters { get; set; } |  | ||||||
|  |  | ||||||
|             public KeyValuePair<string, string>[] DataTableList { get; set; }//IID/Name |  | ||||||
|  |  | ||||||
|             public Filter[] FirstTableFilters { get; set; }//第一个DataTable的Filter |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         public class TableFilterObject |  | ||||||
|         { |  | ||||||
|             public string TableIID { get; set; } |  | ||||||
|             public string TableName { get; set; } |  | ||||||
|             public Filter[] Filters { get; set; } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         public class SaveFilterObject |  | ||||||
|         { |  | ||||||
|             public string UserIID { get; set; }//用户或用户组的IID |  | ||||||
|             public int Type { get; set; }//1 |  | ||||||
|             public Filter[] GlobalFilter { get; set; } |  | ||||||
|             public TableFilterObject[] TableFilters { get; set; } |  | ||||||
|         } |  | ||||||
|         public class DataSourceObject |  | ||||||
|         { |  | ||||||
|             public string IID { get; set; } |  | ||||||
|             public string Name { get; set; } |  | ||||||
|             public bool IsFlat { get; set; } |  | ||||||
|  |  | ||||||
|             public string DisplayField { get; set; } |  | ||||||
|             public string ValueField { get; set; } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|             public DataSourceData[] Data { get; set; } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         public class DataSourceData |  | ||||||
|         { |  | ||||||
|             public string ID { get; set; } |  | ||||||
|             public string PID { get; set; } |  | ||||||
|             public string Description { get; set; } |  | ||||||
|             public DataSourceData[] SubData { get; set; } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         public class ErrorObject |  | ||||||
|         { |  | ||||||
|             public int ErrorCode { get; set; } |  | ||||||
|             public string ErrorMessage { get; set; } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         #endregion |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -1,9 +1,10 @@ | |||||||
| using Foresight.Data; | using Foresight.Data; | ||||||
|  | using Foresight.Fleet.Services.Asset; | ||||||
| using Foresight.Fleet.Services.JobSite; | using Foresight.Fleet.Services.JobSite; | ||||||
|  | using Foresight.Fleet.Services.MapView; | ||||||
|  | using IronIntel.Contractor.MapView; | ||||||
| using IronIntel.Contractor.Security; | using IronIntel.Contractor.Security; | ||||||
| using IronIntel.Contractor.Users; | using IronIntel.Contractor.Users; | ||||||
| using IronIntel.Services.Business.Admin; |  | ||||||
| using IronIntel.Services.Customers; |  | ||||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| @@ -59,20 +60,21 @@ namespace IronIntel.Contractor.Site.Security | |||||||
|         { |         { | ||||||
|             try |             try | ||||||
|             { |             { | ||||||
|                 if (GetCurrentLoginSession() != null) |                 var session = GetCurrentLoginSession(); | ||||||
|  |                 if (session != null) | ||||||
|                 { |                 { | ||||||
|                     var clientdata = Request.Form["ClientData"].Split((char)170); |                     var clientdata = Request.Form["ClientData"].Split((char)170); | ||||||
|                     var contractorid = HttpUtility.HtmlDecode(clientdata[0]); |                     var companyid = HttpUtility.HtmlDecode(clientdata[0]); | ||||||
|                     var searchtext = HttpUtility.HtmlDecode(clientdata[1]); |                     var searchtext = HttpUtility.HtmlDecode(clientdata[1]); | ||||||
|  |  | ||||||
|                     if (!SystemParams.IsDealer) |                     if (!SystemParams.IsDealer) | ||||||
|                         contractorid = SystemParams.CompanyID; |                         companyid = SystemParams.CompanyID; | ||||||
|  |  | ||||||
|                     JobSiteLimitItem[] items = CreateClient<JobSiteProvider>(contractorid).GetJobSiteLimitItems(contractorid, searchtext); |                     JobSiteLimitItem[] items = CreateClient<JobSiteProvider>(companyid).GetJobSiteLimitItems(companyid, searchtext); | ||||||
|                     if (items == null || items.Length == 0) |                     if (items == null || items.Length == 0) | ||||||
|                         return new JobsiteLimitInfo[0]; |                         return new JobsiteLimitInfo[0]; | ||||||
|  |  | ||||||
|                     MachineType[] alltypes = Machines.MachineManagement.GetMachineTypes(); |                     AssetType[] alltypes = Machines.MachineManagement.GetMachineTypes(); | ||||||
|                     List<JobsiteLimitInfo> list = new List<JobsiteLimitInfo>(); |                     List<JobsiteLimitInfo> list = new List<JobsiteLimitInfo>(); | ||||||
|                     foreach (JobSiteLimitItem item in items) |                     foreach (JobSiteLimitItem item in items) | ||||||
|                     { |                     { | ||||||
| @@ -83,7 +85,7 @@ namespace IronIntel.Contractor.Site.Security | |||||||
|                         { |                         { | ||||||
|                             foreach (string tyid in typeids) |                             foreach (string tyid in typeids) | ||||||
|                             { |                             { | ||||||
|                                 MachineType type = alltypes.FirstOrDefault(m => m.ID == Convert.ToInt32(tyid)); |                                 AssetType type = alltypes.FirstOrDefault(m => m.ID == Convert.ToInt32(tyid)); | ||||||
|                                 if (type != null) |                                 if (type != null) | ||||||
|                                 { |                                 { | ||||||
|                                     if (string.IsNullOrWhiteSpace(jl.AssetTypeNames)) |                                     if (string.IsNullOrWhiteSpace(jl.AssetTypeNames)) | ||||||
|   | |||||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user