Exemple #1
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public ReadAllOpt()
        {
            IDbConnection db = ReadAllOpt.GetConnection();

            basicinfor = new ClientDb(db);
            ReadPosOptValue();
        }
Exemple #2
0
            public void FinishBackup_WhenDbContainsPartialHashes()
            {
                // Pst File is registered in Db but the hash table does not contains all hashes for the backup file
                // Arrange
                DeleteDb();
                CopyPartialFile();
                SUT      _backupEngine = new SUT(_appSettings, _dbFilename);
                ClientDb _clientDb     = new ClientDb(_dbFilename);

                _clientDb.RegisterNewPstFile(1, _pstFileToSave.SourcePath, Path.Combine(_destinationPath, _partialFilename));
                Assert.IsTrue(_clientDb.IsPstFileRegistered(_pstFileToSave.SourcePath));
                Assert.AreEqual(_clientDb.GetBackupFilePath(_pstFileToSave.SourcePath), Path.Combine(_destinationPath, _partialFilename), true);

                // Act
                _backupEngine.Backup((object)_pstFileToSave);
                DeleteFile(Path.Combine(_destinationPath, _pstFilename));
                CopyInterruptedFile();
                _clientDb.RenameBackupFile(_pstFileToSave.SourcePath, Path.Combine(_destinationPath, _partialFilename));
                int remainsHashes = (int)(_clientDb.GetHashes(1).Count * 75 / 100);

                _clientDb.DeleteHashes(1, remainsHashes);
                _backupEngine.Backup((object)_pstFileToSave);

                // Assert
                Assert.IsTrue(_clientDb.IsPstFileRegistered(_pstFileToSave.SourcePath));
                Assert.IsTrue(AreFilesEquals(_pstFileToSave.SourcePath, Path.Combine(_destinationPath, _pstFilename)));
                Assert.AreEqual(Path.Combine(_destinationPath, _pstFilename), _clientDb.GetBackupFilePath(_pstFileToSave.SourcePath), true);

                DeleteFile(Path.Combine(_destinationPath, _pstFilename));
            }
Exemple #3
0
            public void BackupToNewDestination_WhenDestinationChangeAfterCompletBakupOccurs()
            {
                // PST File is registred in Db and PST file exists but the destination folder have changed
                // Arrange
                DeleteDb();
                CopyPstFile();
                SUT      _backupEngine = new SUT(_appSettings, _dbFilename);
                ClientDb _clientDb     = new ClientDb(_dbFilename);

                _clientDb.RegisterNewPstFile(1, _pstFileToSave.SourcePath, Path.Combine(_destinationPath, _pstFilename));
                Assert.IsTrue(_clientDb.IsPstFileRegistered(_pstFileToSave.SourcePath));
                Assert.AreEqual(_clientDb.GetBackupFilePath(_pstFileToSave.SourcePath), Path.Combine(_destinationPath, _pstFilename), true);
                Assert.IsTrue(File.Exists(Path.Combine(_destinationPath, _pstFilename)));

                // Act
                _appSettings.FilesAndFoldersDestinationPath = @"\\192.168.0.250\share\Transit\PstFiles\courtel2";
                _backupEngine.Backup((object)_pstFileToSave);

                // Assert
                Assert.IsTrue(_clientDb.IsPstFileRegistered(_pstFileToSave.SourcePath));
                Assert.IsTrue(AreFilesEquals(_pstFileToSave.SourcePath, Path.Combine(@"\\192.168.0.250\share\Transit\PstFiles\courtel2", _pstFilename)));
                Assert.AreEqual(Path.Combine(@"\\192.168.0.250\share\Transit\PstFiles\courtel2", _pstFilename), _clientDb.GetBackupFilePath(_pstFileToSave.SourcePath), true);

                DeleteFile(Path.Combine(@"\\192.168.0.250\share\Transit\PstFiles\courtel2", _pstFilename));
                DeleteFile(Path.Combine(_destinationPath, _pstFilename));
            }
 internal static Client ToDTO(this ClientDb clientDb)
 {
     return(new Client
     {
         ClientId = clientDb.ClientId,
         FirstName = clientDb.FirstName,
         LastName = clientDb.LastName,
         Address = clientDb.Address,
         CallsToCenter = clientDb.CallsToCenter,
         ClientType = clientDb.ClientType.ToDTO(),
         Lines = clientDb.Lines.ToDTO().ToList(),
         Payments = clientDb.Payments.ToDTO().ToList(),
         ClientTypeId = clientDb.ClientTypeId
     });
 }
Exemple #5
0
 public Client LoginClient(string clientId, string contactNumber)
 {
     using (var db = new CellDbContext())
     {
         try
         {
             ClientDb client = db.Clients.Include("Lines").Include("ClientType").ToList().Where(c => c.ClientId == clientId)
                               .Where(c => c.Lines.Select(L => L.Number == contactNumber).FirstOrDefault()).FirstOrDefault();
             return(client.ToDTO());
         }
         catch (Exception ex)
         {
             System.Diagnostics.Debug.WriteLine(ex.Message);
             return(null);
         }
     }
 }
Exemple #6
0
 public bool UpdateClient(Client client)
 {
     using (var db = new CellDbContext())
     {
         try
         {
             ClientDb clientToUpdate = db.Clients.SingleOrDefault(c => c.ClientId == client.ClientId);
             db.Entry(client).State = System.Data.Entity.EntityState.Modified;
             clientToUpdate         = client.FromDTO();
             db.SaveChanges();
             return(true);
         }
         catch (Exception ex)
         {
             System.Diagnostics.Debug.WriteLine(ex.Message);
             return(false);
         }
     }
 }
Exemple #7
0
 public Client AddClient(Client client)
 {
     using (var db = new CellDbContext())
     {
         try
         {
             ClientDb newClient = client.FromDTO();
             db.Clients.Add(newClient);
             db.Entry(newClient).State = System.Data.Entity.EntityState.Added;
             db.SaveChanges();
             return(newClient.ToDTO());
         }
         catch (Exception ex)
         {
             System.Diagnostics.Debug.WriteLine(ex.Message);
             return(null);
         }
     }
 }
Exemple #8
0
 public bool RemoveClient(string clientId)
 {
     using (var db = new CellDbContext())
     {
         try
         {
             ClientDb clientToRemove = db.Clients.SingleOrDefault(c => c.ClientId == clientId);
             db.Clients.Remove(clientToRemove);
             db.Entry(clientToRemove).State = System.Data.Entity.EntityState.Deleted;
             db.SaveChanges();
             return(true);
         }
         catch (Exception ex)
         {
             System.Diagnostics.Debug.WriteLine(ex.Message);
             return(false);
         }
     }
 }
Exemple #9
0
            public void RegisterNewPstFileThenDeletePartialFileAndCreateNewOne_WhenPstFileIsNotRegisteredInDbButPartialFileExists()
            {
                // PST File is not registred in Db but partial file exists.
                // Arrange
                DeleteDb();
                CopyPartialFile();
                SUT      _backupEngine = new SUT(_appSettings, _dbFilename);
                ClientDb _clientDb     = new ClientDb(_dbFilename);

                Assert.IsFalse(_clientDb.IsPstFileRegistered(_pstFileToSave.SourcePath));

                // Act
                _backupEngine.Backup((object)_pstFileToSave);

                // Assert
                Assert.IsTrue(_clientDb.IsPstFileRegistered(_pstFileToSave.SourcePath));
                Assert.IsTrue(AreFilesEquals(Path.Combine(_sourcePath, _pstFilename), Path.Combine(_destinationPath, _pstFilename)));
                Assert.AreEqual(Path.Combine(_destinationPath, _pstFilename), _clientDb.GetBackupFilePath(_pstFileToSave.SourcePath), true);

                DeleteFile(Path.Combine(_destinationPath, _pstFilename));
            }
Exemple #10
0
        private bool CheckValidation(Client client)
        {
            ClientDb clientDb = unitOfWork.Client.FindByClientPublicId(client.ClientPublicId);

            if (clientDb == null)
            {
                return(false);
            }

            if (clientDb.Type.Equals(AppEnums.ClientType.Mobile))
            {
                if (!clientDb.ClientSecret.Equals(client.ClientSecret))
                {
                    return(false);
                }
            }

            Mapper.MapDbModelToClassModel(client, clientDb);
            client.IP = httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString();
            ClientParser(client);
            return(true);
        }
Exemple #11
0
            public void UseInformationsFromDbThenBackupFile_WhenPstFileIsRegisteredInDbAndPartialFileDoesNotExists()
            {
                // PST File is registred in Db but partial file does not exists.
                // Arrange
                DeleteDb();
                DeleteFile(Path.Combine(_destinationPath, _partialFilename));
                SUT      _backupEngine = new SUT(_appSettings, _dbFilename);
                ClientDb _clientDb     = new ClientDb(_dbFilename);

                _clientDb.RegisterNewPstFile(1, _pstFileToSave.SourcePath, Path.Combine(_destinationPath, _partialFilename));
                Assert.IsTrue(_clientDb.IsPstFileRegistered(_pstFileToSave.SourcePath));
                Assert.AreEqual(_clientDb.GetBackupFilePath(_pstFileToSave.SourcePath), Path.Combine(_destinationPath, _partialFilename), true);
                Assert.IsFalse(File.Exists(Path.Combine(_destinationPath, _partialFilename)));

                // Act
                _backupEngine.Backup((object)_pstFileToSave);

                // Assert
                Assert.IsTrue(_clientDb.IsPstFileRegistered(_pstFileToSave.SourcePath));
                Assert.IsTrue(AreFilesEquals(_pstFileToSave.SourcePath, Path.Combine(_destinationPath, _pstFilename)));
                Assert.AreEqual(Path.Combine(_destinationPath, _pstFilename), _clientDb.GetBackupFilePath(_pstFileToSave.SourcePath), true);

                DeleteFile(Path.Combine(_destinationPath, _pstFilename));
            }
Exemple #12
0
 public ClientBs()
 {
     objDb = new ClientDb();
 }
 public OrdersDb()
 {
     _client = ClientDb.AccessDb();
 }
Exemple #14
0
 /// <summary>
 /// 判断客户端是否存在
 /// </summary>
 /// <param name="ClientId"></param>
 /// <param name="ClientSecret"></param>
 /// <returns></returns>
 public async Task <bool> ExistAsync(string ClientId, string ClientSecret)
 {
     return(await ClientDb.IsAnyAsync(t => t.ClientId == ClientId& t.ClientSecret == ClientSecret));
 }
 public CustomersDb()
 {
     _client = ClientDb.AccessDb();
 }
Exemple #16
0
 public DownloadControl()
 {
     _basicInfor = CurrUserLogin.CurrReadAllOpt.basicinfor;
 }
Exemple #17
0
 /// <summary>
 /// 获取客户端
 /// </summary>
 /// <param name="ClientId"></param>
 /// <param name="ClientSecret"></param>
 /// <returns></returns>
 public async Task <ClientEntity> GetClientAsync(string ClientId, string ClientSecret)
 {
     return(await ClientDb.SingleAsync(t => t.ClientId == ClientId& t.ClientSecret == ClientSecret));
 }
 /// <summary>
 /// This Constructor is used by use cases only
 /// </summary>
 /// <param name="appSettings"></param>
 /// <param name="dbPath"></param>
 public DifferentialBackupEngine(ApplicationSettings appSettings, string dbPath) : base(appSettings)
 {
     _dbPath   = dbPath;
     _clientDb = new ClientDb(_dbPath);
     _clientDb.Initialize();
 }
Exemple #19
0
 public ConfigControll()
 {
     _basicInfor = CurrUserLogin.CurrReadAllOpt.basicinfor;
 }
Exemple #20
0
 public ClientBs()
 {
     objDb = new ClientDb();
 }