public SyncStatus(DataRow row) { Id = (int)row["Id"]; CompanyId = ConvertEx.ToNullable <int>(row["CompanyId"]); SyncTable = (string)row["SyncTable"]; SyncName = (string)row["SyncName"]; DisplayName = (string)row["DisplayName"]; DoSync = (bool)row["DoSync"]; SyncType = ConvertEx.StringToEnum <EnumSyncType>(row["SyncType"]); Status = ConvertEx.StringToEnum <EnumTableSyncStatus>(row["Status"]); }
public static SyncStatus GetCompanySyncStatus(string syncTable, EnumSyncType syncType, string syncName, int companyId, string displayName) { DataTable table = MobileCommon.ExecuteDataAdapter($"select * from SyncStatus where SyncName='{syncName}' and CompanyId={companyId}"); if (table.Rows.Count > 0) { return(table.Select().Select(r => new SyncStatus(r)).Single()); } else { string sql = $"insert into SyncStatus(CompanyId, SyncTable, SyncType, Status, DoSync, SyncName, DisplayName) " + $"values({companyId}, '{syncTable}', '{syncType}', '{EnumTableSyncStatus.ReadyToSync}', 1, '{syncName}', '{displayName}')"; MobileCommon.ExecuteNonQuery(sql); table = MobileCommon.ExecuteDataAdapter($"select * from SyncStatus where SyncName='{syncName}' and CompanyId={companyId}"); return(table.Select().Select(r => new SyncStatus(r)).Single()); } }
public static void SetSyncProcess(int companyId, EnumSyncType syncType, EnumSyncProcess process, int syncId) { CompanySyncProcess item = GetSyncProcess(companyId, syncType); if (item != null) { item.SyncProcess = process; item.SyncId = syncId; string sql = $"Update CompanySyncProcess set SyncProcess='{process}', SyncId={syncId} where CompanyId={companyId} and SyncType='{syncType}'"; MobileCommon.ExecuteNonQuery(sql); } else { _list.Add(new CompanySyncProcess() { CompanyId = companyId, SyncType = syncType, SyncProcess = process, SyncId = syncId }); string sql = $"insert CompanySyncProcess(CompanyId, SyncType, SyncProcess, SyncId) values({companyId}, '{syncType}', '{process}', {syncId})"; MobileCommon.ExecuteNonQuery(sql); } }
public static EnumSyncProcess GetSyncProcessEnum(int companyId, EnumSyncType syncType) { return(GetSyncProcess(companyId, syncType)?.SyncProcess ?? (companyId == NoCompany ? EnumSyncProcess.SystemSyncing : EnumSyncProcess.NotSyncing)); }
public static CompanySyncProcess GetSyncProcess(int companyId, EnumSyncType syncType) { return(List.SingleOrDefault(x => x.CompanyId == companyId && x.SyncType == syncType)); }