public void MarkAsSynced(SqlBase origin) { try { SyncHistory syncHistory = new SyncHistory { DeviceId = Daemon.Devices.Device.Current.DeviceId, Guid = this.Guid, Date = DateTime.Now }; origin.Table <SyncHistory>().Delete(x => x.Guid == syncHistory.Guid); origin.Insert(syncHistory, string.Empty); //if (connection is SqlServer SQLH) //{ // SQLH.EXEC("INSERT INTO DESCARGAS_VERSIONES(ID_DESCARGA,ID_DISPOSITIVO) VALUES(@ID_DESCARGA,@ID_DISPOSITIVO)" // , System.Data.CommandType.Text, false, // new SqlParameter("ID_DESCARGA", Id), // new SqlParameter("ID_DISPOSITIVO", Device.Current.DeviceId)); //} //else if (connection is SqLite SQLHLite) //{ // SQLHLite.EXEC($"DELETE FROM VERSION_CONTROL WHERE ID=?", Id); //} } catch (Exception ex) { Log.Logger.Error(ex, "Al marcar como finalizada la sincronización - [{0}]", this); } }
public static DeviceInformation Get(SqlBase sql) { return(sql.Table <DeviceInformation>() .FirstOrDefault(x => x.DeviceId == Device.Current.DeviceId) ?? new DeviceInformation() { DeviceId = Device.Current.DeviceId }.SetIsFirstLaunchTime(true).Save(sql)); }
public static void MarkAsSynced(SqlBase origin, Guid SyncGuid) { SyncHistory syncHistory = new SyncHistory { DeviceId = Daemon.Devices.Device.Current.DeviceId, Guid = SyncGuid }; origin.Table <SyncHistory>().Delete(x => x.Guid == syncHistory.Guid); origin.Insert(syncHistory, string.Empty); }
public static SyncStatus GetSyncStatus(SqlBase source_con, Guid guid, SyncStatus SyncStatus) { var history = source_con.Table <SyncHistory>().FirstOrDefault(x => x.Guid == guid); if (history is null) { ChangesHistory changes = source_con.Table <ChangesHistory>().FirstOrDefault(x => x.Guid == guid); if (changes is null) { //Has been downloaded by Daemon service since daemon downloads dont get inserted here SyncStatus = SyncStatus.Done; return(SyncStatus); } if (SyncStatus == SyncStatus.Failed) { return(SyncStatus.Failed); } SyncStatus = SyncStatus.Pending; return(SyncStatus.Pending); } SyncStatus = SyncStatus.Done; return(SyncStatus.Done); }
public virtual ISync GetBySyncGuid(SqlBase con, Guid syncguid) { var table = con.Table(this.GetType()).Table; string selection_list = table.SelectionList; string condition = (con is SQLiteConnection ? "SyncGuid=?" : "SyncGuid=@SyncGuid"); CommandBase command = con.CreateCommand($"SELECT {selection_list} FROM {table.TableName} WHERE {condition}", new BaseTableQuery.Condition("SyncGuid", syncguid)); MethodInfo method = command.GetType().GetMethod(nameof(CommandBase.ExecuteDeferredQuery), new[] { typeof(Kit.Sql.Base.TableMapping) }); method = method.MakeGenericMethod(table.MappedType); IEnumerable <dynamic> result = (IEnumerable <dynamic>)method.Invoke(command, new object[] { table }); dynamic i_result = result.FirstOrDefault(); ISync read = Convert.ChangeType(i_result, typeof(ISync)); return(read); }
public DeviceInformation Save(SqlBase sql) { sql.Table <DeviceInformation>().Delete(false); sql.InsertOrReplace(this); return(this); }
public static void Delete(SqlBase con, Guid syncGuid) { con.Table <SyncHistory>().Delete(x => x.Guid == syncGuid, false); }