public void SetStatus(EnumTableSyncStatus status) { string sql = $"update SyncStatus set Status='{status}' where SyncTable='{TableName}' and CompanyId={CompanyId}"; MobileCommon.ExecuteNonQuery(sql); SyncInfo.Status = status; }
public override void CommitReceive() { if (new EnumTableSyncStatus[] { EnumTableSyncStatus.Receiving, EnumTableSyncStatus.CompleteReceive }.Contains(SyncInfo.Status)) { string sql = $"delete LoginUser where InSync<>1"; MobileCommon.ExecuteNonQuery(sql); sql = $"update LoginUser set InSync=0"; MobileCommon.ExecuteNonQuery(sql); sql = $"delete UserAccess where InSync<>1"; MobileCommon.ExecuteNonQuery(sql); sql = $"update UserAccess set InSync=0"; MobileCommon.ExecuteNonQuery(sql); sql = $"delete ProjectAccess where InSync<>1"; MobileCommon.ExecuteNonQuery(sql); sql = $"update ProjectAccess set InSync=0"; MobileCommon.ExecuteNonQuery(sql); UpdateStatus(EnumTableSyncStatus.ReadyToSync); if (LoginUser.CurrUser != null) { int?id = LoginUser.ValidUser(LoginUser.CurrUser.LoginName); LoginUser.CurrUser = LoginUser.GetUser(id.Value); } } }
public static void SqlUpdate(int id, DateTime poDate, string poNum, string supplierCode, int projectId, bool billable) { string sql = $"update FieldPO set POdate='{poDate}', PONum='{StrEx.SqlEsc(poNum)}', SupplierCode='{supplierCode}', projectId={projectId}, " + $"Billable='{billable}', FieldPOStatus='{(char)EnumSubmitStatus.Open}', SyncStatus='{EnumRecordSyncStatus.NoSubmit}' where Id={id}"; MobileCommon.ExecuteNonQuery(sql); }
public static void SqlUpdate(int id, string desc, int?level1Id, int?level2Id, int?level3Id, int?level4Id, EnumComponentType component, bool billable, decimal amount) { string sql = $"update FieldPODetail set Description='{desc}', Level1Code={StrEx.ValueOrNull(level1Id)}, Level2Code={StrEx.ValueOrNull(level2Id)}, " + $"Level3Code={StrEx.ValueOrNull(level3Id)}, Level4Code={StrEx.ValueOrNull(level4Id)}, Component='{(char)component}', Billable='{billable}', Amount={amount} where id={id} "; MobileCommon.ExecuteNonQuery(sql); }
public static void SqlDelete(int id) { var curr = LemHeader.GetLogHeader(id); if (curr.MatchId != -1) { string sql = $"update LemHeader set deleted=1 where id={id}"; MobileCommon.ExecuteNonQuery(sql); DeleteHistory.SqlInsert(DeleteHistory.LemHeader, curr.MatchId); var labourList = LabourTimeEntry.GetLabourEntryList(id); labourList.ForEach(x => LabourTimeEntry.DeleteEntry(x.Id)); var equipList = EquipTimeEntry.GetEquipEntryList(id); equipList.ForEach(x => EquipTimeEntry.DeleteEntry(x.Id)); var attachList = Attachment.GetAttachList(Attachment.LemHeaderId, id); attachList.ForEach(x => Attachment.DeleteAttach(DeleteHistory.LemHeaderAttach, x.RepositoryId)); } else { SqlForceDelete(id); } }
public static void SqlInsert(string tableName, int matchId) { string sql = $"INSERT INTO DeleteHistory(TableName, MatchId, CompanyId, TimeStamp) " + $"values('{tableName}', {matchId}, {Company.CurrentId}, getdate())"; MobileCommon.ExecuteNonQuery(sql); }
public override void CommitReceive() { if (new EnumTableSyncStatus[] { EnumTableSyncStatus.Receiving, EnumTableSyncStatus.CompleteReceive }.Contains(SyncInfo.Status)) { DataTable table = MobileCommon.ExecuteDataAdapter($"select * from LemHeader where CompanyId={CompanyId} and SyncStatus='{EnumRecordSyncStatus.Updating}'"); List <LemHeader> oldList = table.Select().Select(r => new LemHeader(r)).ToList(); oldList.ForEach(r => LemHeader.SqlForceDelete(r.Id)); table = MobileCommon.ExecuteDataAdapter($"select * from LemHeader where CompanyId={CompanyId} and SyncStatus='{EnumRecordSyncStatus.Receiving}'"); List <LemHeader> newList = table.Select().Select(r => new LemHeader(r)).ToList(); foreach (var item in oldList) { int newHeaderId = newList.Single(x => x.MatchId == item.MatchId).Id; string sql = $"update LabourTimeEntry set LogHeaderId={newHeaderId} where SyncStatus<>'{EnumRecordSyncStatus.Receiving}' and CompanyId={CompanyId} and LogHeaderId={item.Id}"; MobileCommon.ExecuteNonQuery(sql); sql = $"update EquipTimeEntry set LogHeaderId={newHeaderId} where SyncStatus<>'{EnumRecordSyncStatus.Receiving}' and CompanyId={CompanyId} and LogHeaderId={item.Id}"; MobileCommon.ExecuteNonQuery(sql); sql = $"update LemAP set LogHeaderId={newHeaderId} where SyncStatus<>'{EnumRecordSyncStatus.Receiving}' and CompanyId={CompanyId} and LogHeaderId={item.Id}"; MobileCommon.ExecuteNonQuery(sql); sql = $"update CFS_FileLink set IdValue={newHeaderId} where SyncStatus<>'{EnumRecordSyncStatus.Receiving}' and CompanyId={CompanyId} and IdValue={item.Id}"; MobileCommon.ExecuteNonQuery(sql); } base.CommitReceive(); } }
public static void SqlUpdate(int id, string eqpNum, int?empNum, int?changeOrderId, int?level1Id, int?level2Id, int?level3Id, int?level4Id, bool billable, decimal quantity, EnumBillCycle billCycle, decimal?billAmount) { string sql = $"update EquipTimeEntry set EqpNum={eqpNum}, EmpNum={StrEx.ValueOrNull(empNum)}, Billable='{billable}', ChangeOrderId={StrEx.ValueOrNull(changeOrderId)}, " + $"Level1Id={StrEx.ValueOrNull(level1Id)}, Level2Id={StrEx.ValueOrNull(level2Id)}, Level3Id={StrEx.ValueOrNull(level3Id)}, Level4Id={StrEx.ValueOrNull(level4Id)}, " + $"Quantity={quantity}, BillCycle='{(char)billCycle}', BillAmount={StrEx.ValueOrNull(billAmount)}, SyncStatus='{EnumRecordSyncStatus.NoSubmit}' where Id={id} "; MobileCommon.ExecuteNonQuery(sql); }
public static void SqlUpdate(int id, int empNum, int?changeOrderId, int?level1Id, int?level2Id, int?level3Id, int?level4Id, bool billable, bool manual, string workClassCode, decimal?includedHours, decimal?totalHours, decimal?billAmount) { string sql = $"update LabourTimeEntry set EmpNum={empNum}, ChangeOrderId={StrEx.ValueOrNull(changeOrderId)}, Level1Id={StrEx.ValueOrNull(level1Id)}, Level2Id={StrEx.ValueOrNull(level2Id)}, " + $"Level3Id={StrEx.ValueOrNull(level3Id)}, Level4Id={StrEx.ValueOrNull(level4Id)}, Billable='{billable}', Manual='{manual}', WorkClassCode='{workClassCode}', " + $"IncludedHours={StrEx.ValueOrNull(includedHours)}, TotalHours={StrEx.ValueOrNull(totalHours)}, BillAmount={StrEx.ValueOrNull(billAmount)}, SyncStatus='{EnumRecordSyncStatus.NoSubmit}' where Id={id} "; MobileCommon.ExecuteNonQuery(sql); }
public static void UndeleteAll(int companyId) { MobileCommon.ExecuteNonQuery($"update LemHeader set Deleted=0 where CompanyId={companyId} and Deleted=1"); MobileCommon.ExecuteNonQuery($"update LabourTimeEntry set Deleted=0 where CompanyId={companyId} and Deleted=1"); MobileCommon.ExecuteNonQuery($"update EquipTimeEntry set Deleted=0 where CompanyId={companyId} and Deleted=1"); MobileCommon.ExecuteNonQuery($"update CFS_FileLink set TableDotField=Replace(TableDotField, '_DEL','') where CompanyId={companyId} and TableDotField='%_DEL'"); }
public static void SqlDelete(int id) { MobileCommon.ExecuteNonQuery($"delete FieldPODetail where POId={id}"); MobileCommon.ExecuteNonQuery($"delete FieldPO where id={id}"); var attachList = Attachment.GetAttachList(Attachment.FieldPOId, id); attachList.ForEach(x => Attachment.DeleteAttach(DeleteHistory.FieldPOAttach, x.RepositoryId)); }
public override void RollbackReceive() { if (new EnumTableSyncStatus[] { EnumTableSyncStatus.Receiving, EnumTableSyncStatus.CompleteReceive, EnumTableSyncStatus.ErrorInReceive }.Contains(SyncInfo.Status)) { string sql = $"update FieldPO set SyncStatus='{EnumRecordSyncStatus.NoSubmit}' where SyncStatus='{EnumRecordSyncStatus.Updating}' and CompanyId={CompanyId}"; MobileCommon.ExecuteNonQuery(sql); UpdateStatus(EnumTableSyncStatus.ReadyToSync); } }
public virtual void RollbackReceive() { if (new EnumTableSyncStatus[] { EnumTableSyncStatus.Receiving, EnumTableSyncStatus.CompleteReceive, EnumTableSyncStatus.ErrorInReceive }.Contains(SyncInfo.Status)) { string sql = $"delete {TableName} where InSync=1 and CompanyId={CompanyId}"; MobileCommon.ExecuteNonQuery(sql); UpdateStatus(EnumTableSyncStatus.ReadyToSync); } }
public virtual void RollbackSend() { if (new EnumTableSyncStatus[] { EnumTableSyncStatus.Sending, EnumTableSyncStatus.CompleteSend, EnumTableSyncStatus.ErrorInSend }.Contains(SyncInfo.Status)) { string sql = $"update {TableName} set SyncStatus='{EnumRecordSyncStatus.NoSubmit}' where SyncStatus='{EnumRecordSyncStatus.Submiting}' and CompanyId={CompanyId}"; MobileCommon.ExecuteNonQuery(sql); UpdateStatus(EnumTableSyncStatus.ReadyToSync); } }
public override async System.Threading.Tasks.Task <SyncResult> Receive() { try { LoginUser.Refresh(); using (HttpClient client = new HttpClient()) { client.Init(); HttpResponseMessage response = await client.GetAsync("api/LoginUsers"); if (response.IsSuccessStatusCode) { UpdateStatus(EnumTableSyncStatus.Receiving); List <LoginUser> list = await response.Content.ReadAsAsync <List <LoginUser> >(); list.ForEach(x => { string sql = $"insert LoginUser(MatchId, LoginName, CodeVersion, InSync) values({x.MatchId}, '{x.LoginName}', '1.0.0.0', 1); " + $"Select CAST(SCOPE_IDENTITY() AS INT);"; int id = Convert.ToInt32(MobileCommon.ExecuteScalar(sql)); x.AccessList.ForEach(r => { sql = $"insert UserAccess( UserId, CompanyId, UserName, Department, InSync) values({id}, {r.CompanyId}, '{r.UserName}', '{r.Department}', 1)"; MobileCommon.ExecuteNonQuery(sql); }); x.ProjectList.ForEach(c => { sql = $"insert ProjectAccess( UserId, CompanyId, ProjectId, InSync) values({id}, {c.CompanyId}, {c.ProjectId}, 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 = "LoginUser", Message = e.Message }); } }
public override async Task <SyncResult> Receive(Guid token) { try { using (HttpClient client = new HttpClient()) { client.Init(token); var query = HttpUtility.ParseQueryString(string.Empty); query["companyId"] = CompanyId.ToString(); query["clientMac"] = MobileCommon.MachineMac; HttpResponseMessage response = await client.GetAsync($"api/LemAP?{query.ToString()}"); if (response.IsSuccessStatusCode) { UpdateStatus(EnumTableSyncStatus.Receiving); List <LemAP> list = await response.Content.ReadAsAsync <List <LemAP> >(); list.ForEach(x => { BeforeReceiveRecord(x.MatchId); string sql = $"insert LemAp(MatchId, CompanyId, ProjectId, InvoiceDate, LogHeaderId, InvoiceNum, SupplierCode, PONum, InvoiceAmount, MarkupAmount, BillAmount, SyncStatus) " + $"values({x.MatchId}, {x.CompanyId}, {x.ProjectId}, '{x.InvoiceDate}', null, '{x.InvoiceNum}', '{x.SupplierCode}', '{x.PONum}', {x.InvoiceAmount}, {x.MarkupAmount}, {x.BillAmount}, '{EnumRecordSyncStatus.Receiving}'); " + $"Select CAST(SCOPE_IDENTITY() AS INT);"; int mid = Convert.ToInt32(MobileCommon.ExecuteScalar(sql)); foreach (var d in x.DetailList) { sql = $"insert LemAPDetail(MatchId, CompanyId, LemAPId, LineNum, Description, Reference, Amount, MarkupPercent, MarkupAmount, BillAmount, Level1Id, Level2Id, Level3Id, Level4Id) " + $"values({d.MatchId}, {d.CompanyId}, {mid}, {d.LineNum}, '{d.Description}', '{d.Reference}', {d.Amount}, {d.MarkupPercent}, {d.MarkupAmount}, {d.BillAmount}, " + $"{StrEx.ValueOrNull(d.Level1Id)}, {StrEx.ValueOrNull(d.Level2Id)}, {StrEx.ValueOrNull(d.Level3Id)}, {StrEx.ValueOrNull(d.Level4Id)});"; 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 virtual void CommitReceive() { if (new EnumTableSyncStatus[] { EnumTableSyncStatus.Receiving, EnumTableSyncStatus.CompleteReceive }.Contains(SyncInfo.Status)) { string sql = $"delete {TableName} where InSync<>1"; MobileCommon.ExecuteNonQuery(sql); sql = $"update {TableName} set InSync=0"; MobileCommon.ExecuteNonQuery(sql); UpdateStatus(EnumTableSyncStatus.ReadyToSync); } }
public static void DeleteEntry(int id) { LabourTimeEntry curr = LabourTimeEntry.GetLabourEntry(id); if (curr.MatchId != -1) { MobileCommon.ExecuteNonQuery($"update LabourTimeEntry set deleted=1 where id={id}"); DeleteHistory.SqlInsert(DeleteHistory.LabourTimeEntry, curr.MatchId); } else { SqlForceDelete(id); } }
public override void RollbackReceive() { if (new EnumTableSyncStatus[] { EnumTableSyncStatus.Receiving, EnumTableSyncStatus.CompleteReceive, EnumTableSyncStatus.ErrorInReceive }.Contains(SyncInfo.Status)) { DataTable table = MobileCommon.ExecuteDataAdapter($"select Id from LabourTimeEntry where SyncStatus='{EnumRecordSyncStatus.Receiving}' and CompanyId={CompanyId}"); List <int> idList = table.Select().ToList().Select(r => (int)r["Id"]).ToList(); idList.ForEach(id => LabourTimeEntry.SqlForceDelete(id)); string sql = $"update LabourTimeEntry set SyncStatus='{EnumRecordSyncStatus.NoSubmit}' where SyncStatus='{EnumRecordSyncStatus.Updating}' and CompanyId={CompanyId}"; MobileCommon.ExecuteNonQuery(sql); UpdateStatus(EnumTableSyncStatus.ReadyToSync); } }
public static void DeleteEntry(int id) { var curr = EquipTimeEntry.GetEquipEntry(id); if (curr.MatchId != -1) { MobileCommon.ExecuteNonQuery($"update EquipTimeEntry set Deleted=1 where id={id}"); DeleteHistory.SqlInsert(DeleteHistory.EquipTimeEntry, curr.MatchId); } else { SqlForceDelete(id); } }
public override void CommitSend() { if (new EnumTableSyncStatus[] { EnumTableSyncStatus.Sending, EnumTableSyncStatus.CompleteSend }.Contains(SyncInfo.Status)) { DataTable table = MobileCommon.ExecuteDataAdapter($"select FileRepository_ID from CFS_FileLink where SyncStatus='{EnumRecordSyncStatus.Submiting}' and CompanyID={CompanyId}"); var repoIdList = table.Select().Select(r => (int)r["FileRepository_ID"]); foreach (int repoId in repoIdList) { var match = SyncCoreMatch.GetMatch(TableName, repoId); MobileCommon.ExecuteNonQuery($"update CFS_FileLink set MatchID={match.MatchId}, SyncStatus='{EnumRecordSyncStatus.Submitted}' where FileRepository_ID={repoId}"); } UpdateStatus(EnumTableSyncStatus.ReadyToSync); } }
public override void CommitSend() { if (new EnumTableSyncStatus[] { EnumTableSyncStatus.Sending, EnumTableSyncStatus.CompleteSend }.Contains(SyncInfo.Status)) { DataTable table = MobileCommon.ExecuteDataAdapter($"select Id from LabourTimeEntry where CompanyId={CompanyId} and SyncStatus='{EnumRecordSyncStatus.Submiting}'"); var idList = table.Select().ToList().Select(r => (int)r["Id"]); foreach (int id in idList) { var match = SyncCoreMatch.GetMatch(TableName, id); MobileCommon.ExecuteNonQuery($"update LabourTimeEntry set MatchID={match.MatchId}, SyncStatus='{EnumRecordSyncStatus.Submitted}' where Id={id}"); } UpdateStatus(EnumTableSyncStatus.ReadyToSync); } }
public static void SqlUpdateLemAP(int id, int?logHeaderId) { if (logHeaderId == null) { int matchId = (int)MobileCommon.ExecuteScalar($"select isnull(matchid, 0) from LemAP where id={id} and SyncStatus='{EnumRecordSyncStatus.Submitted}'"); if (matchId != 0) { DeleteHistory.SqlInsert(DeleteHistory.LemAPUnselect, matchId); } } string sql = $"update LemAP set LogHeaderId={StrEx.ValueOrNull(logHeaderId)}, SyncStatus='{EnumRecordSyncStatus.NoSubmit}' where Id={id}"; MobileCommon.ExecuteNonQuery(sql); }
public override void CommitReceive() { if (new EnumTableSyncStatus[] { EnumTableSyncStatus.Receiving, EnumTableSyncStatus.CompleteReceive }.Contains(SyncInfo.Status)) { DataTable table = MobileCommon.ExecuteDataAdapter($"select * from DeleteHistory where CompanyId={CompanyId} and SyncStatus='{EnumRecordSyncStatus.Receiving}'"); List <DeleteHistory> list = table.Select().Select(r => new DeleteHistory(r)).ToList(); list.ForEach(x => x.SqlExecute()); DeleteHistory.UndeleteAll(CompanyId); MobileCommon.ExecuteNonQuery($"delete DeleteHistory where CompanyId={CompanyId} and SyncStatus='{EnumRecordSyncStatus.Receiving}'"); UpdateStatus(EnumTableSyncStatus.ReadyToSync); } }
public static void Purge() { try { int?days = SystemInfo.Current.KeepDays; if (days is null || days == 0) { return; } DateTime purgeDate = DateTime.Today.AddDays(-days.Value); string sql = $"select id from LemHeader where LogStatus='{(char)EnumLogStatus.Billed}' and LogDate<'{purgeDate}'"; DataTable table = MobileCommon.ExecuteDataAdapter(sql); List <int> lemHeaderList = table.Select().ToList().Select(r => (int)r["id"]).ToList(); string lemHeaderListText = "0"; lemHeaderList.ForEach(id => lemHeaderListText += $",{id}"); MobileCommon.ExecuteNonQuery($"delete EquipTimeEntry where LogHeaderId in ({lemHeaderListText})"); table = MobileCommon.ExecuteDataAdapter($"select Id from LabourTimeEntry where LogHeaderId in ({lemHeaderListText})"); List <int> subIdList = table.Select().ToList().Select(r => (int)r["Id"]).ToList(); subIdList.ForEach(id => LabourTimeEntry.SqlForceDelete(id)); table = MobileCommon.ExecuteDataAdapter($"select FileRepository_ID from CFS_FileLink where IDValue in ({lemHeaderListText}) and TableDotField='{Attachment.LemHeaderId}'"); subIdList = table.Select().ToList().Select(r => (int)r["FileRepository_ID"]).ToList(); subIdList.ForEach(id => Attachment.SqlForceDelete(id)); MobileCommon.ExecuteNonQuery($"delete LemHeader where Id in ({lemHeaderListText})"); MobileCommon.ExecuteNonQuery($"delete DeleteHistory where SyncStatus='{EnumRecordSyncStatus.Submitted}' and TimeStamp<'{purgeDate}'"); sql = $"select id from FieldPO where SyncStatus='{EnumRecordSyncStatus.Submitted}' and PODate<'{purgeDate}'"; table = MobileCommon.ExecuteDataAdapter(sql); subIdList = table.Select().ToList().Select(r => (int)r["Id"]).ToList(); subIdList.ForEach(id => FieldPO.SqlDelete(id)); sql = $"select id from LemAP where SyncStatus='{EnumRecordSyncStatus.Submitted}' and InvoiceDate<'{purgeDate}'"; table = MobileCommon.ExecuteDataAdapter(sql); subIdList = table.Select().ToList().Select(r => (int)r["Id"]).ToList(); subIdList.ForEach(id => LemAP.SqlForceDelete(id)); } catch (Exception e) { ReportMessage?.Invoke(e.Message); } }
public override void RollbackReceive() { if (new EnumTableSyncStatus[] { EnumTableSyncStatus.Receiving, EnumTableSyncStatus.CompleteReceive, EnumTableSyncStatus.ErrorInReceive }.Contains(SyncInfo.Status)) { string sql = $"delete LoginUser where InSync=1"; MobileCommon.ExecuteNonQuery(sql); sql = $"delete UserAccess where InSync=1"; MobileCommon.ExecuteNonQuery(sql); sql = $"delete ProjectAccess where InSync=1"; MobileCommon.ExecuteNonQuery(sql); UpdateStatus(EnumTableSyncStatus.ReadyToSync); } }
public static void DeleteAttach(string tableName, int repoId) { string sql = $"select matchId from CFS_FileLink where FileRepository_ID={repoId}"; int? matchId = ConvertEx.ToNullable <int>(MobileCommon.ExecuteScalar(sql)); if (matchId != null) { MobileCommon.ExecuteNonQuery($"update CFS_FileLink set TableDotField=TableDotField+'_DEL' where FileRepository_ID={repoId}"); DeleteHistory.SqlInsert(tableName, matchId.Value); } else { SqlForceDelete(repoId); } }
public override async System.Threading.Tasks.Task <SyncResult> Receive() { try { Company.Refresh(); using (HttpClient client = new HttpClient()) { client.Init(); HttpResponseMessage response = await client.GetAsync("api/Companies"); if (response.IsSuccessStatusCode) { UpdateStatus(EnumTableSyncStatus.Receiving); List <Company> list = await response.Content.ReadAsAsync <List <Company> >(); list.ForEach(x => { string sql = $"insert Company(MatchId, CompanyName, ShortName, Active, WeekStart, " + $"EquipRateGroupType, MaxLevelCode, Level1CodeDesc, Level2CodeDesc, Level3CodeDesc, Level4CodeDesc, " + $"CompanyAddress1, CompanyAddress2, CompanyAddress3, CompanyCity, CompanyState, CompanyZip, CompanyPhone, CompanyFax, " + $"CompanyEmail, CompanyWeb, InSync) " + $"values({x.MatchId}, '{StrEx.SqlEsc(x.CompanyName)}', '{x.ShortName}', '{x.Active}', {(Int16)x.WeekStart}, " + $"'{(char)x.EquipRateGroupType}', {x.MaxLevelCode}, '{x.Level1CodeDesc}', '{x.Level2CodeDesc}', '{x.Level3CodeDesc}', '{x.Level4CodeDesc}', " + $"'{StrEx.SqlEsc(x.CompanyAddress1)}', '{StrEx.SqlEsc(x.CompanyAddress2)}', '{StrEx.SqlEsc(x.CompanyAddress3)}', '{x.CompanyCity}', '{x.CompanyState}', " + $"'{x.CompanyZip}', '{x.CompanyPhone}', '{x.CompanyFax}', '{x.CompanyEmail}', '{x.CompanyWeb}', 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 { using (HttpClient client = new HttpClient()) { client.Init(token); var query = HttpUtility.ParseQueryString(string.Empty); query["companyId"] = CompanyId.ToString(); query["clientMac"] = MobileCommon.MachineMac; query["contactId"] = LoginUser.CurrUser.MatchId.ToString(); HttpResponseMessage response = await client.GetAsync($"api/LemHeader?{query.ToString()}"); if (response.IsSuccessStatusCode) { UpdateStatus(EnumTableSyncStatus.Receiving); var list = await response.Content.ReadAsAsync <List <LemHeader> >(); list.ForEach(x => { BeforeReceiveRecord(x.MatchId); string sql = $"insert LemHeader(MatchId, CompanyId, LogDate, LogStatus, SubmitStatus, ProjectId, LemNum, LEM_Desc, ApprovalComments, CreatorId, SyncStatus, Deleted) " + $"values({x.MatchId}, {x.CompanyId}, '{x.LogDate}', '{(char)x.LogStatus}', '{(char)EnumSubmitStatus.Open}', {x.ProjectId}, '{x.LemNum}', '{StrEx.SqlEsc(x.Description)}', '{StrEx.SqlEsc(x.ApprovalComments)}', {x.CreatorId}, '{EnumRecordSyncStatus.Receiving}', 0);"; 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 { using (HttpClient client = new HttpClient()) { client.Init(token); var query = HttpUtility.ParseQueryString(string.Empty); query["companyId"] = CompanyId.ToString(); query["clientMac"] = MobileCommon.MachineMac; query["contactId"] = LoginUser.CurrUser.MatchId.ToString(); HttpResponseMessage response = await client.GetAsync($"api/EquipTimeEntry?{query.ToString()}"); if (response.IsSuccessStatusCode) { UpdateStatus(EnumTableSyncStatus.Receiving); var list = await response.Content.ReadAsAsync <List <EquipTimeEntry> >(); list.ForEach(x => { BeforeReceiveRecord(x.MatchId); string sql = $"insert EquipTimeEntry(MatchID, CompanyId, LogHeaderId, EqpNum, ChangeOrderId, Level1Id, Level2Id, Level3Id, Level4Id, Billable, Quantity, BillCycle, BillAmount, SyncStatus, Deleted) " + $"values({x.MatchId}, {x.CompanyId}, {x.HeaderId}, '{x.EqpNum}', {StrEx.ValueOrNull(x.ChangeOrderId)}, {StrEx.ValueOrNull(x.Level1Id)}, {StrEx.ValueOrNull(x.Level2Id)}, " + $"{StrEx.ValueOrNull(x.Level3Id)}, {StrEx.ValueOrNull(x.Level4Id)}, '{x.Billable}', {x.Quantity}, '{(char)x.BillCycle}', {StrEx.ValueOrNull(x.BillAmount)}, '{EnumRecordSyncStatus.Receiving}', 0)"; 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 }); } }