Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
 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));
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
 public DeviceInformation Save(SqlBase sql)
 {
     sql.Table <DeviceInformation>().Delete(false);
     sql.InsertOrReplace(this);
     return(this);
 }
Esempio n. 7
0
 public static void Delete(SqlBase con, Guid syncGuid)
 {
     con.Table <SyncHistory>().Delete(x => x.Guid == syncGuid, false);
 }