public override async System.Threading.Tasks.Task <SyncResult> Receive(Guid token) { try { EquipmentTemplate.Refresh(); using (HttpClient client = new HttpClient()) { client.Init(token); HttpResponseMessage response = await client.GetAsync($"api/EquipmentTemplates?companyId={CompanyId}"); if (response.IsSuccessStatusCode) { UpdateStatus(EnumTableSyncStatus.Receiving); List <EquipmentTemplate> list = await response.Content.ReadAsAsync <List <EquipmentTemplate> >(); list.ForEach(x => { string sql = $"insert EquipmentTemplate(MatchId, CompanyId, ProjectId, EqpNum, EquipClassCode, StartDate, EndDate, InSync) " + $"values({x.MatchId}, {x.CompanyId}, {x.ProjectId}, {x.EqpNum}, '{x.EquipClassCode}', {StrEx.StrOrNull(x.StartDate)}, {StrEx.StrOrNull(x.EndDate)}, 1)"; MobileCommon.ExecuteNonQuery(sql); }); UpdateStatus(EnumTableSyncStatus.CompleteReceive); return(new SyncResult { Successful = true }); } throw new Exception($"Response StatusCode={response.StatusCode}"); } } catch (Exception e) { UpdateStatus(EnumTableSyncStatus.ErrorInReceive); return(new SyncResult { Successful = false, Task = TableName, Message = e.Message }); } }
public override async System.Threading.Tasks.Task <SyncResult> Receive(Guid token) { try { TimeCode.Refresh(); using (HttpClient client = new HttpClient()) { client.Init(token); HttpResponseMessage response = await client.GetAsync($"api/TimeCodes?companyId={CompanyId}"); if (response.IsSuccessStatusCode) { UpdateStatus(EnumTableSyncStatus.Receiving); List <TimeCode> list = await response.Content.ReadAsAsync <List <TimeCode> >(); list.ForEach(x => { string sql = $"insert TimeCode(MatchId, companyId, [Desc], ValueType, BillingRateType, OvertimeId, DoubleTimeId, IncludedInWeekCalc, Component, ReportTypeColumn, InSync) " + $"values({x.MatchId}, {x.CompanyId}, '{x.Desc}', '{x.ValueType}', '{x.BillingType}', {StrEx.ValueOrNull(x.OvertimeId)}, {StrEx.ValueOrNull(x.DoubleTimeId)}, '{x.IncludedInWeekCalc}', '{(char)x.Component}', {StrEx.StrOrNull(x.ReportTypeColumn)}, 1)"; MobileCommon.ExecuteNonQuery(sql); }); UpdateStatus(EnumTableSyncStatus.CompleteReceive); return(new SyncResult { Successful = true }); } throw new Exception($"Response StatusCode={response.StatusCode}"); } } catch (Exception e) { UpdateStatus(EnumTableSyncStatus.ErrorInReceive); return(new SyncResult { Successful = false, Task = TableName, Message = e.Message }); } }
public override async System.Threading.Tasks.Task <SyncResult> Receive(Guid token) { try { Project.Refresh(); using (HttpClient client = new HttpClient()) { client.Init(token); HttpResponseMessage response = await client.GetAsync($"api/Projects?companyId={CompanyId}"); if (response.IsSuccessStatusCode) { UpdateStatus(EnumTableSyncStatus.Receiving); List <Project> list = await response.Content.ReadAsAsync <List <Project> >(); list.ForEach(x => { string sql = $"insert Project(MatchId, CompanyId, Name, Code, CustomerId, CustomerCode, CustomerName, CustomerAddress, POReference, SiteLocation, StartDate, EstCompletionDate, " + $"SiteAddress, SiteCity, SiteState, SiteZip, CustomerAddress2, CustomerAddress3, CustomerCity, CustomerState, CustomerZip, ProjectExtendedDescription, Billable, InSync) " + $"values({x.MatchId}, {x.CompanyId}, '{x.Name}', {x.Code}, {x.CustomerId}, '{x.CustomerCode}', '{x.CustomerName}', '{x.CustomerAddress}', {StrEx.StrOrNull(x.POReference)}, '{x.SiteLocation}', {StrEx.StrOrNull(x.StartDate)}, {StrEx.StrOrNull(x.EstCompletionDate)}, " + $"'{x.SiteAddress}', '{x.SiteCity}', '{x.SiteState}', '{x.SiteZip}', '{x.CustomerAddress2}', '{x.CustomerAddress3}', '{x.CustomerCity}', '{x.CustomerState}', '{x.CustomerZip}', '{StrEx.SqlEsc(x.ProjectExtendedDescription)}', '{x.Billable}', 1)"; MobileCommon.ExecuteNonQuery(sql); }); UpdateStatus(EnumTableSyncStatus.CompleteReceive); return(new SyncResult { Successful = true }); } throw new Exception($"Response StatusCode={response.StatusCode}"); } } catch (Exception e) { UpdateStatus(EnumTableSyncStatus.ErrorInReceive); return(new SyncResult { Successful = false, Task = TableName, Message = e.Message }); } }
public override async Task <SyncResult> Receive(Guid token) { try { EquipmentAssignment.Refresh(); using (HttpClient client = new HttpClient()) { client.Init(token); HttpResponseMessage response = await client.GetAsync($"api/EquipmentAssignments?companyId={Company.CurrentId}"); if (response.IsSuccessStatusCode) { UpdateStatus(EnumTableSyncStatus.Receiving); List <EquipmentAssignment> list = await response.Content.ReadAsAsync <List <EquipmentAssignment> >(); list.ForEach(x => { string sql = $"insert EquipmentAssignment(CompanyId, EqpNum, EmpNum, AssignedDate, ReleasedDate, EarnGroup, EarnCode, inSync) " + $"values({x.CompanyId}, '{x.EqpNum}', {x.EmpNum}, {StrEx.StrOrNull(x.AssignedDate)}, {StrEx.StrOrNull(x.ReleasedDate)}, {StrEx.StrOrNull(x.EarnGroup)}, {StrEx.StrOrNull(x.EarnCode)}, 1)"; MobileCommon.ExecuteNonQuery(sql); }); UpdateStatus(EnumTableSyncStatus.CompleteReceive); return(new SyncResult { Successful = true }); } throw new Exception($"Response StatusCode={response.StatusCode}"); } } catch (Exception e) { UpdateStatus(EnumTableSyncStatus.ErrorInReceive); return(new SyncResult { Successful = false, Task = TableName, Message = e.Message }); } }
public override async System.Threading.Tasks.Task <SyncResult> Receive() { try { using (HttpClient client = new HttpClient()) { client.Init(); HttpResponseMessage response = await client.GetAsync("api/ContextItems"); if (response.IsSuccessStatusCode) { UpdateStatus(EnumTableSyncStatus.Receiving); List <ContextItem> list = await response.Content.ReadAsAsync <List <ContextItem> >(); list.ForEach(x => { string sql = $"insert ContextItem(ID, ContextGroupID, Name, WordMergeDSN, IsSystem, InSync) " + $"values({x.ID}, {x.ContextGroupID}, '{x.Name}', {StrEx.StrOrNull(x.WordMergeDSN)}, '{x.IsSystem}', 1)"; MobileCommon.ExecuteNonQuery(sql); }); UpdateStatus(EnumTableSyncStatus.CompleteReceive); return(new SyncResult { Successful = true }); } throw new Exception($"Response StatusCode={response.StatusCode}"); } } catch (Exception e) { UpdateStatus(EnumTableSyncStatus.ErrorInReceive); return(new SyncResult { Successful = false, Task = TableName, Message = e.Message }); } }
public static void SqlInsert(string syncTable, int srcId, int matchId, string syncMatch = null) { MobileCommon.ExecuteNonQuery($"Insert SyncCoreMatch(SyncTable, SourceId, MatchId, SyncMatch) values('{syncTable}',{srcId},{matchId},{StrEx.StrOrNull(syncMatch)})"); }