private static void SaveDeviceConfig() { Console.Write("Saving device config ... "); string companyName = "Monagham Farm"; string deviceId = "RV2WJB270311-RV1WJB270515"; DateTime licenseExpiryDate = DateTime.Now.Add(new TimeSpan(30, 0, 0, 0)); ServiceFunctionResultOfListOfCustomer resultCustomer = GlobalDataCache.Instance.Service.GetCustomerByField( EntityReader <Customer> .GetPropertyName(p => p.CompanyName, false), companyName, false, GlobalDataCache.Instance.CurrentUser); if (resultCustomer.Code != ServiceResultCode.Success) { throw new Exception(resultCustomer.Message); } Customer customer = resultCustomer.Contents[0]; ServiceFunctionResultOfListOfDeviceConfig resultDeviceConfigQuery = GlobalDataCache.Instance.Service.GetDeviceConfigByField( EntityReader <DeviceConfig> .GetPropertyName(p => p.DeviceId, false), deviceId, false, GlobalDataCache.Instance.CurrentUser); if (resultDeviceConfigQuery.Code != ServiceResultCode.Success) { throw new Exception(resultDeviceConfigQuery.Message); } DeviceConfig deviceConfig = null; if (resultDeviceConfigQuery.Contents == null || resultDeviceConfigQuery.Contents.Length < 1) { deviceConfig = new DeviceConfig() { DeviceConfigId = Guid.NewGuid(), DeviceId = deviceId, DateCreated = DateTime.Now }; } else { deviceConfig = resultDeviceConfigQuery.Contents[0]; } deviceConfig.ApplicationName = "CarTracker.Mobile.exe"; deviceConfig.ApplicationWebServiceURL = "http://169.254.2.2/CarTracker.Web.Service/Service.asmx"; deviceConfig.ApplicationReplicationWebServiceURL = "http://169.254.2.2/CarTrackerMobileSync/sqlcesa35.dll"; deviceConfig.ClientConfigWebServiceURL = "http://169.254.2.2/Figlut.Web.Service/Service.asmx"; deviceConfig.LicenseExpiryDate = licenseExpiryDate; deviceConfig.CustomerId = customer.CustomerId; ServiceProcedureResult resultDeviceConfig = GlobalDataCache.Instance.Service.SaveDeviceConfig( new DeviceConfig[] { deviceConfig }, GlobalDataCache.Instance.CurrentUser, false); if (resultDeviceConfig.Code != ServiceResultCode.Success) { throw new Exception(resultDeviceConfig.Message); } Console.WriteLine("done."); }
public bool RefreshFromServerWithCustomerInfo() { ServiceFunctionResultOfListOfDeviceConfig result = GlobalDataCache.Instance.Service.GetAllDeviceConfigWithCustomerInfo( GlobalDataCache.Instance.CurrentUser); if (ServiceResultHandler.HandleServiceResult(result)) { return(true); } Clear(); result.Contents.OrderBy(p => p.CustomerCompanyName).ToList().ForEach(p => _entities.Add(p.DeviceConfigId, p)); return(false); }
public override bool RefreshFromServer() { ServiceFunctionResultOfListOfDeviceConfig result = GlobalDataCache.Instance.Service.GetAllDeviceConfig( false, GlobalDataCache.Instance.CurrentUser); if (ServiceResultHandler.HandleServiceResult(result)) { return(true); } Clear(); result.Contents.OrderBy(p => p.DeviceId).ToList().ForEach(p => _entities.Add(p.DeviceConfigId, p)); return(false); }