public async Task <int> SaveScreenShotToSql(ScreenShot screenShot)
        {
            int result = 0;

            if (screenShot == null)
            {
                return(result);
            }

            try
            {
                if (sqliteService == null)
                {
                    sqliteService = new SQLiteService <ScreenShotSQL>(sqlitePlatform, await fileSystemService.GetPath(configuration.SqlDatabaseName));
                }
            }
            catch (Exception exp)
            {
                sqliteService = null;
            }
            if (sqliteService != null)
            {
                try
                {
                    result = await sqliteService.Insert(converter.ConvertToScreenShotSQL(screenShot));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(await TaskHelper.Complete(result));
        }
Beispiel #2
0
        public async Task <IEnumerable <Command> > GetCommandRest(DeviceModel device)
        {
            string         result      = String.Empty;
            List <Command> listCommand = null;

            try
            {
                RestService restService = new RestService(configuration.RestServerUrl, "GetCommand");
                restService.Timeout = configuration.ServerTimeOut;
                listCommand         = await restService.Get <Command>
                                          (new CodeRequest
                {
                    AndroidIDmacHash = device.AndroidIDmacHash,
                    CRC          = this.CRC,
                    TypeDeviceID = device.TypeDeviceID
                });
            }
            catch (AggregateException e)
            {
                if (e.InnerExceptions[0].Data.Count > 0)
                {
                    result = e.InnerExceptions[0].Data["message"].ToString();
                }
                else
                {
                    result = "undefinedException";
                }
            }
            catch (Exception e)
            {
                result = String.Format("Error = " + e.Message);
            }

            return(await TaskHelper.Complete(listCommand));
        }
        public async Task <IEnumerable <ScreenShot> > GetSQLScreenShot(DateTime from, DateTime to)
        {
            List <ScreenShot> listScreenShots = null;

            try
            {
                if (sqliteService == null)
                {
                    sqliteService = new SQLiteService <ScreenShotSQL>(sqlitePlatform, await fileSystemService.GetPath(configuration.SqlDatabaseName));
                }
            }
            catch (Exception exp)
            {
                sqliteService = null;
            }
            if (sqliteService != null)
            {
                try
                {
                    long f = ConverterHelper.ConvertDateWithoutTimeToMillisec(from);
                    long t = ConverterHelper.ConvertDateWithoutTimeToMillisec(to);
                    List <ScreenShotSQL> listScreenShotSql = await sqliteService.GetWhere(predicate : x => x.Date >= f && x.Date <= t && x.IsActive, orderBy : x => x.Date);

                    if (listScreenShotSql != null && listScreenShotSql.Count != 0)
                    {
                        listScreenShots = new List <ScreenShot>();
                        foreach (var powerPCSql in listScreenShotSql)
                        {
                            listScreenShots.Add(converter.ConvertToScreenShot(powerPCSql));
                        }
                    }
                }
                catch (Exception ex)
                {
                    var err = ex.Message;
                    throw ex;
                }
            }
            return(await TaskHelper.Complete(listScreenShots));
        }