示例#1
0
 public async Task DeleteVacationsInfoInSqlById(int id)
 {
     try
     {
         if (sqliteService == null)
         {
             sqliteService = new SQLiteService(_sqlitePlatform, await _fileSystemService.GetPath(_configuration.SqlDatabaseName));
         }
     }
     catch (Exception exp)
     {
         sqliteService = null;
     }
     if (sqliteService != null)
     {
         try
         {
             await sqliteService.Delete <VacationInfoModelDTO>(id.ToString());
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
示例#2
0
		public async void TestSQLiteService(){
			
			SQLiteService sqliteService = new SQLiteService (new SQLitePlatformWin32(), await GetPath("VTSTest"));

			VacationInfoDTO person = new VacationInfoDTO {
				Date="",
				ImageSRC="test",
				Id=12,
				Status="qwe",
				VacationType = "asd"
			};

			await sqliteService.Insert<VacationInfoDTO> (person);
			var personTest =await sqliteService.Get<VacationInfoDTO>(person.Id.ToString());
			Assert.AreNotEqual (person, personTest,"Message Insert or Get error");

			person.ImageSRC="https://ru.wikipedia.org/wiki";
			await sqliteService.Update<VacationInfoDTO> (person);
			personTest =await sqliteService.Get<VacationInfoDTO>(person.Id.ToString());
			Assert.IsTrue(person.ImageSRC == personTest.ImageSRC,"Message Update or Get error");

			await sqliteService.Delete<VacationInfoDTO>(person.Id.ToString());
			personTest =await sqliteService.Get<VacationInfoDTO>(person.Id.ToString());
			Assert.IsNull (personTest,"Message Delete error");
		}
示例#3
0
        public async Task ClearPreference()
        {
            try
            {
                if (sqliteService == null)
                {
                    sqliteService = new SQLiteService <PrefSql>(sqlitePlatform, await fileSystemService.GetPath(configuration.SqlDatabaseName));
                }
            }
            catch (Exception exp)
            {
                var err = exp.Message;
                sqliteService = null;
            }
            if (sqliteService != null)
            {
                try
                {
                    List <PrefSql> list = await sqliteService.Get();

                    if (list != null && list.Count != 0)
                    {
                        foreach (var item in list)
                        {
                            await sqliteService.Delete(item.Id.ToString());
                        }
                    }
                }
                catch (Exception ex)
                {
                    var err = ex.Message;
                    throw ex;
                }
            }
        }
示例#4
0
 public async Task DeletePair()
 {
     try
     {
         if (sqliteService == null)
         {
             sqliteService = new SQLiteService <CodeResponceSQL>(sqlitePlatform, await fileSystemService.GetPath(configuration.SqlDatabaseName));
         }
     }
     catch (Exception exp)
     {
         sqliteService = null;
     }
     if (sqliteService != null)
     {
         try
         {
             await sqliteService.Delete("1");
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
示例#5
0
        /// <summary>
        /// Clear all data in SQLite local DB
        /// </summary>
        /// <returns></returns>

        public async Task ClearMasterPair()
        {
            try
            {
                if (sqliteService == null)
                {
                    sqliteService = new SQLiteService <MasterSQL>(sqlitePlatform, await fileSystemService.GetPath(configuration.SqlDatabaseName));
                }
            }
            catch (Exception exp)
            {
                sqliteService = null;
            }
            if (sqliteService != null)
            {
                try
                {
                    List <MasterSQL> oldmasters = await sqliteService.Get();

                    if (oldmasters != null && oldmasters.Count != 0)
                    {
                        foreach (var master in oldmasters)
                        {
                            await sqliteService.Delete(master.Id.ToString());
                        }
                    }
                }
                catch (Exception ex)
                {
                    var err = ex.Message;
                    throw ex;
                }
            }
        }
示例#6
0
        /// <summary>
        /// Save Masters to local SQLite for buffer for slow rest internet connections
        /// </summary>
        /// <param name="responce"></param>
        /// <returns></returns>

        public async Task SaveMastersToSql(IEnumerable <Master> responce)
        {
            if (responce == null)
            {
                await ClearMasterPair();

                return;
            }
            try
            {
                if (sqliteService == null)
                {
                    sqliteService = new SQLiteService <MasterSQL>(sqlitePlatform, await fileSystemService.GetPath(configuration.SqlDatabaseName));
                }
            }
            catch (Exception exp)
            {
                sqliteService = null;
            }
            if (sqliteService != null)
            {
                try
                {
                    List <MasterSQL> oldmasters = await sqliteService.Get();

                    if (oldmasters != null && oldmasters.Count != 0)
                    {
                        foreach (var master in oldmasters)
                        {
                            await sqliteService.Delete(master.Id.ToString());
                        }
                    }
                    foreach (var master in responce)
                    {
                        await sqliteService.Insert(converter.ConvertToMasterSQL(master));
                    }
                }
                catch (Exception ex)
                {
                    var err = ex.Message;
                    throw ex;
                }
            }
        }
示例#7
0
        public async Task SaveLoginModelToSQLite(string name, string password)
        {
            try
            {
                if (sqliteService == null)
                {
                    sqliteService = new SQLiteService(_sqlitePlatform, await _fileSystemService.GetPath(_configuration.SqlDatabaseName));
                }
            }
            catch (Exception exp)
            {
                sqliteService = null;
            }
            if (sqliteService != null)
            {
                try
                {
                    LoginInfoDTO currentLoginInfo = new LoginInfoDTO();
                    currentLoginInfo.UserName = name;
                    currentLoginInfo.Password = SecurytyHash.CalculateSha1Hash(password);

                    List <LoginInfoDTO> listlogins = await sqliteService.Get <LoginInfoDTO>();

                    if (listlogins != null && listlogins.Count != 0)
                    {
                        foreach (LoginInfoDTO login in listlogins)
                        {
                            if (login.UserName == currentLoginInfo.UserName)
                            {
                                await sqliteService.Delete <LoginInfoDTO>(login.Id.ToString());
                            }
                        }
                    }

                    await sqliteService.Insert <LoginInfoDTO>(currentLoginInfo);
                }
                catch (Exception ex)
                {
                }
            }
        }
示例#8
0
        public async Task DeleteMasterPairSql(long masterId)
        {
            try
            {
                if (sqliteService == null)
                {
                    sqliteService = new SQLiteService <MasterSQL>(sqlitePlatform, await fileSystemService.GetPath(configuration.SqlDatabaseName));
                }
            }
            catch (Exception exp)
            {
                sqliteService = null;
            }
            if (sqliteService != null)
            {
                try
                {
                    List <MasterSQL> listMasterSql = await sqliteService.Get();

                    if (listMasterSql != null && listMasterSql.Count != 0)
                    {
                        foreach (var masterSql in listMasterSql)
                        {
                            if (masterSql.MasterId.Equals(masterId))
                            {
                                await sqliteService.Delete(masterSql.Id.ToString());

                                break;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    var err = ex.Message;
                    throw ex;
                }
            }
        }
示例#9
0
        public async Task SaveVacationsToSql(List <VTSModel> listVTSModel)
        {
            try
            {
                if (sqliteService == null)
                {
                    sqliteService = new SQLiteService(_sqlitePlatform, await _fileSystemService.GetPath(_configuration.SqlDatabaseName));
                }
            }
            catch (Exception exp)
            {
                sqliteService = null;
            }
            if (sqliteService != null)
            {
                try
                {
                    var vacationInfoList = await sqliteService.Get <VacationInfoDTO>();

                    if (vacationInfoList != null)
                    {
                        foreach (VacationInfoDTO old in vacationInfoList)
                        {
                            await sqliteService.Delete <VacationInfoDTO>(old.Id.ToString());
                        }
                    }
                    foreach (VTSModel info in listVTSModel)
                    {
                        await sqliteService.Insert(_converter.ConvertToVacationInfoDTO((info)));
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
示例#10
0
		public async Task DeleteVacationInfo (string id)
		{
			ModelConverter converter = new ModelConverter ();

			SQLiteService sqliteService;
			try {
				sqliteService = new SQLiteService (_sqlitePlatform, await _fileSystem.GetPath ("VTS"));
			} catch {
				sqliteService = null;
			}

			await sqliteService.Delete<VacationInfoDTO> (id);

			RestService restService = new RestService ("/api/Vacations", Server);
			var req = await restService.Delete(id);
		}