Exemplo n.º 1
0
        public async Task GetAllUser()
        {
            var surveys = new List <User>
            {
                new User()
                {
                    login = "******", password = "******"
                },
                new User()
                {
                    login = "******", password = "******"
                }
            };

            var fake = new Mock <IAllRepo>();

            fake.Setup(x => x.GetUsers()).ReturnsAsync(surveys);


            var service = new UserDataService(fake.Object);
            var users   = await service.GetUsers();


            Assert.Collection(users, user
                              =>
            {
                Assert.Equal("login", user.login);
                Assert.Equal("pasword", user.password);
            },
                              user =>
            {
                Assert.Equal("login11", user.login);
                Assert.Equal("pasword11", user.password);
            });
        }
Exemplo n.º 2
0
 public async Task InitializeAsync()
 {
     VersionDescription               = GetVersionDescription();
     IdentityService.LoggedOut       += OnLoggedOut;
     UserDataService.UserDataUpdated += OnUserDataUpdated;
     User = await UserDataService.GetUserAsync();
 }
        public void DeleteRating()
        {
            var service   = new UserDataService();
            var delRating = service.DeleteRatingFromUser(3, "tt11972952");

            Assert.True(delRating);
        }
        public void RateMovie()
        {
            var service   = new UserDataService();
            var rateMovie = service.RateMovie(3, 1, "tt11972952");

            Assert.True(rateMovie);
        }
        public void GetRating()
        {
            var service   = new UserDataService();
            var getRating = service.GetMovieRatingFromUser(3, "tt11972952");

            Assert.Equal(1, getRating.Rating_);
        }
Exemplo n.º 6
0
        public BeaconService()
        {
            _connection = DependencyService.Resolve <SQLiteConnectionProvider>().GetConnection();
            _connection.CreateTable <BeaconDataModel>();
            _userDataService = DependencyService.Resolve <UserDataService>();
            _userData        = _userDataService.Get();
            _httpDataService = DependencyService.Resolve <HttpDataService>();
            _uploadTimer     = new MinutesTimer(_userData.GetJumpHashTimeDifference());
            _uploadTimer.Start();
            _uploadTimer.TimeOutEvent += TimerUpload;

            _beaconTransmitter = new CBPeripheralManager();
            _beaconTransmitter.AdvertisingStarted += DidAdvertisingStarted;
            _beaconTransmitter.StateUpdated       += DidStateUpdated;

            _listOfCLBeaconRegion = new List <CLBeaconRegion>();
            _fieldRegion          = new CLBeaconRegion(new NSUuid(AppConstants.iBeaconAppUuid), "");
            _fieldRegion.NotifyEntryStateOnDisplay = true;
            _fieldRegion.NotifyOnEntry             = true;
            _fieldRegion.NotifyOnExit = true;

            // Monitoring
            _beaconManager = new CLLocationManager();
            _beaconManager.DidDetermineState += DetermineStateForRegionComplete;
            _beaconManager.RegionEntered     += EnterRegionComplete;
            _beaconManager.RegionLeft        += ExitRegionComplete;
            _beaconManager.PausesLocationUpdatesAutomatically = false;
            _beaconManager.AllowsBackgroundLocationUpdates    = true;
            _beaconManager.ShowsBackgroundLocationIndicator   = true;


            _beaconManager.DidRangeBeacons      += DidRangeBeconsInRegionComplete;
            _beaconManager.AuthorizationChanged += HandleAuthorizationChanged;
        }
Exemplo n.º 7
0
        public PositionUsersVM(PositionVM position, AccessType access)
            : base(access)
        {
            UnitOfWork = new SoheilEdmContext();
            CurrentPosition = position;
            PositionDataService = new PositionDataService(UnitOfWork);
            PositionDataService.UserAdded += OnUserAdded;
            PositionDataService.UserRemoved += OnUserRemoved;
            UserDataService = new UserDataService(UnitOfWork);

            var selectedVms = new ObservableCollection<UserPositionVM>();
            foreach (var positionUser in PositionDataService.GetUsers(position.Id))
            {
                selectedVms.Add(new UserPositionVM(positionUser, Access, RelationDirection.Reverse));
            }
            SelectedItems = new ListCollectionView(selectedVms);

            var allVms = new ObservableCollection<UserVM>();
            foreach (var user in UserDataService.GetActives(SoheilEntityType.Positions, CurrentPosition.Id))
            {
                allVms.Add(new UserVM(user, Access, UserDataService));
            }
            AllItems = new ListCollectionView(allVms);

            IncludeCommand = new Command(Include, CanInclude);
            ExcludeCommand = new Command(Exclude, CanExclude);
            
        }
        public void UpdateUserFalse()
        {
            var service     = new UserDataService();
            var updateFalse = service.UpdateUser(10, "userTestUpdate", "falsepw", "Testname", "lastname", 10, "tt@com");

            Assert.False(updateFalse);
        }
Exemplo n.º 9
0
 public ViewModelBase(INavigationService navigationService, UserDataService userDataService)
 {
     NavigationService    = navigationService;
     this.userDataService = userDataService;
     userData             = this.userDataService.Get();
     this.userDataService.UserDataChanged += _userDataChanged;
 }
Exemplo n.º 10
0
 public InstructionService(InstructionDataService instructionDataService,
                           InstructionPdfService instructionPdfService, UserDataService userDataService)
 {
     _instructionDataService = instructionDataService;
     _instructionPdfService  = instructionPdfService;
     _userDataService        = userDataService;
 }
Exemplo n.º 11
0
 private void LoginB_Click(object sender, EventArgs e)
 {
     if (userNameBox.Text == "")
     {
         MessageBox.Show("Put a valid Username..");
     }
     else if (passwordBox.Text == "")
     {
         MessageBox.Show("Put a valid Password..");
     }
     else
     {
         UserDataService userDataService = new UserDataService();
         int             result          = userDataService.UserAuthentication(userNameBox.Text, passwordBox.Text);
         if (result > 0)
         {
             int userid = userDataService.GetUserId(userNameBox.Text, passwordBox.Text);
             this.Hide();
             EventActions eventActions = new EventActions(userid);
             eventActions.Show();
         }
         else
         {
             MessageBox.Show("User Doesn't Exist!");
         }
     }
 }
        public void CreateUser(View view)
        {
            HideKeyboard();
            bool          didError = false;
            List <string> errors   = new List <string>();
            string        username = etUsername.Text;

            errors.Add(Validate(MyValidationType.Username, username, ref didError));
            string password = etPassword.Text;

            errors.Add(Validate(MyValidationType.Password, password, ref didError));
            string passwordConfirm = etConfirm.Text;

            errors.Add(ComparePasswords(password, passwordConfirm, ref didError));
            tvErrors.Text = ErrorListToString(errors);

            if (!(didError))
            {
                if (UserDataService.GetInstance().AddUser(username, password))
                {
                    this.Finish();
                }
                else
                {
                    tvErrors.Text = UserTakenError;
                }
            }
        }
Exemplo n.º 13
0
        public AccessRuleUsersVM(AccessRuleVM accessRule, AccessType access)
            : base(access)
        {
            UnitOfWork = new SoheilEdmContext();
            CurrentAccessRule = accessRule;
            AccessRuleDataService = new AccessRuleDataService(UnitOfWork);
            AccessRuleDataService.UserAdded += OnUserAdded;
            AccessRuleDataService.UserRemoved += OnUserRemoved;
            UserDataService = new UserDataService(UnitOfWork);

            var selectedVms = new ObservableCollection<UserAccessRuleVM>();
            foreach (var accessRuleUser in AccessRuleDataService.GetUsers(accessRule.Id))
            {
                selectedVms.Add(new UserAccessRuleVM(accessRuleUser, Access, RelationDirection.Reverse));
            }
            SelectedItems = new ListCollectionView(selectedVms);

            var allVms = new ObservableCollection<UserVM>();
            foreach (var user in UserDataService.GetActives())
            {
                allVms.Add(new UserVM(user, Access, UserDataService));
            }
            AllItems = new ListCollectionView(allVms);

            IncludeCommand = new Command(Include,CanInclude);
            ExcludeCommand = new Command(Exclude, CanExclude);
        }
Exemplo n.º 14
0
        private void SaveReserveren()
        {
            //Be
            Reservation test = Reservation;

            Reservation.Status = "reserved";

            //user already exist
            UserDataService dbUser = new UserDataService();

            User us = dbUser.UserExist(Reservation.User);

            if (us == null)
            {
                //creat New User
                dbUser.InsertUser(Reservation.User);
                us = dbUser.UserExist(Reservation.User);
            }
            Reservation.User = us;

            //reservation
            ReservationDataService dbReservation = new ReservationDataService();

            dbReservation.InsertReservation(Reservation);

            MessageBox.Show("Reservatie is voltooid");
            NewForm();
        }
Exemplo n.º 15
0
 public InitSettingPageViewModel(INavigationService navigationService, UserDataService userDataService) : base(navigationService, userDataService)
 {
     Title = Resources.AppResources.TitleDeviceAccess;
     this.userDataService = userDataService;
     userData             = this.userDataService.Get();
     this.userDataService.UserDataChanged += _userDataChanged;
 }
Exemplo n.º 16
0
        public void AuthorizeUserWrongPasswordTest()
        {
            IUserDataService service = new UserDataService();

            service.AuthorizeUser("login", "Bad password", out LoginFailType code);
            Assert.That(code, Is.EqualTo(LoginFailType.WrongPassword));
        }
Exemplo n.º 17
0
 public NotifyOtherPageViewModel(INavigationService navigationService, UserDataService userDataService) : base(navigationService, userDataService)
 {
     Title = Resources.AppResources.TitileUserStatusSettings;
     this.userDataService = userDataService;
     userData             = this.userDataService.Get();
     errorCount           = 0;
 }
Exemplo n.º 18
0
        protected async Task HandleValidSubmit()
        {
            Saved = false;
            var savedUser = new User();

            savedUser = await UserDataService.AddUser(User);

            if (savedUser != null && UserId == 0)
            {
                StatusClass = "alert-success";
                Message     = "New User Added Successfuly";
                Saved       = true;
            }
            else if (savedUser != null && UserId != 0)
            {
                StatusClass = "alert-success";
                Message     = "User Updated Successfuly";
                Saved       = true;
            }
            else
            {
                StatusClass = "alert-danger";
                Message     = "somthing went wrong adding the new user .please try again";
                Saved       = false;
            }
            ShowDialog = false;
            await CloseEventCallback.InvokeAsync(true);

            StateHasChanged();
            ToastService.ShowSuccess(Message, "Confirm");
        }
        public void UpdateUserCorrect()
        {
            var service = new UserDataService();
            var update  = service.UpdateUser(10, "userTest", "pwnew", "Testname", "lastname", 10, "*****@*****.**");

            Assert.True(update);
        }
Exemplo n.º 20
0
 private void submitB_Click(object sender, EventArgs e)
 {
     if (usernameBox.Text == "")
     {
         MessageBox.Show("Put a valid Username..");
     }
     else if (passwordBox.Text == "")
     {
         MessageBox.Show("Put a valid Password..");
     }
     else
     {
         if (cpBox.Text != passwordBox.Text)
         {
             MessageBox.Show("Password and Confirm Password Doesnt Match!");
         }
         else
         {
             UserDataService userDataService = new UserDataService();
             int             result          = userDataService.AddUser(usernameBox.Text, passwordBox.Text);
             if (result > 0)
             {
                 MessageBox.Show("User Added Succesfully!");
                 this.Hide();
                 Login login = new Login();
                 login.Show();
             }
             else
             {
                 MessageBox.Show("Sorry There Was An Error!");
             }
         }
     }
 }
Exemplo n.º 21
0
 public LoginViewModel(UserDataService userDataService)
 {
     _userDataService = userDataService;
     _userMail        = new ValidatableObject <string>();
     _userPassword    = new ValidatableObject <string>();
     AddValidations();
 }
 public FindTreasureVM(UserDataService userdata, PopUpWindowController popUp, FoundTreasureArgs args)
 {
     UserData     = userdata;
     TreasureArgs = args;
     PopUp        = popUp;
     MessengerInstance.Register <object>(this, "Refresh", obj => { RefreshTreasureComments(); }); //when mod deletes comments
 }
Exemplo n.º 23
0
 private async void BackgroundService()
 {
     await Task.Run(() =>
     {
         try
         {
             while (true)
             {
                 InvokeOnMainThread(delegate
                 {
                     _beaconService   = DependencyService.Resolve <IBeaconService>();
                     _userDataService = DependencyService.Resolve <UserDataService>();
                     if (_userDataService.IsExistUserData)
                     {
                         _beaconService.StartAdvertisingBeacons(_userDataService.Get());
                     }
                 });
                 System.Threading.Thread.Sleep(60000);
             }
         }
         catch (Exception ex)
         {
             System.Diagnostics.Debug.WriteLine(ex.Message + System.Environment.NewLine + ex.StackTrace);
         }
     }).ConfigureAwait(false);
 }
        public void ChangePassword()
        {
            var service = new UserDataService();
            var chpw    = service.ChangePassword("userTest", "pw", "pwnew");

            Assert.True(chpw);
        }
Exemplo n.º 25
0
        protected async Task HandleValidSubmit()
        {
            if (string.IsNullOrEmpty(User.Id)) //new
            {
                var addedUser = await UserDataService.AddUser(User);

                if (addedUser != null)
                {
                    StatusClass = "alert-success";
                    Message     = "New User added successfully.";
                    Saved       = true;
                }
                else
                {
                    StatusClass = "alert-danger";
                    Message     = "Something went wrong adding the new User. Please try again.";
                    Saved       = false;
                }
            }
            else
            {
                await UserDataService.UpdateUser(User);

                StatusClass = "alert-success";
                Message     = "User updated successfully.";
                Saved       = true;
            }
        }
 public DebugPageViewModel(INavigationService navigationService, UserDataService userDataService) : base(navigationService, userDataService)
 {
     Title = "Debug";
     this.userDataService = userDataService;
     userData             = this.userDataService.Get();
     this.userDataService.UserDataChanged += _userDataChanged;
 }
Exemplo n.º 27
0
        public ActionResult Device(Device device)
        {
            UserDataService userDataService = new UserDataService();

            var user = userDataService.GetByUserId(User.Identity.GetUserId());

            DeviceDataService deviceDataService = new DeviceDataService();

            Device newDevice = new Device
            {
                DeviceId = device.DeviceId,
                Geofence = new Geofence
                {
                    North = 180,
                    South = -180,
                    East  = 90,
                    West  = -90,
                },
                Title  = device.Title,
                UserId = user.Id
            };

            deviceDataService.Add(newDevice);


            return(RedirectToAction("Index"));
        }
Exemplo n.º 28
0
        protected async Task DeleteUserRole(string userId, string roleId)
        {
            var item = User.AspNetUserRoles.Where(v => v.UserId == userId && v.RoleId == roleId).FirstOrDefault();

            User.AspNetUserRoles.Remove(item);
            await UserDataService.DeleteUserRole(userId, roleId);
        }
 public InitSettingPageViewModel(INavigationService navigationService, UserDataService userDataService, ExposureNotificationService exposureNotificationService) : base(navigationService, userDataService, exposureNotificationService)
 {
     Title = Resources.AppResources.TitleDeviceAccess;
     this.userDataService             = userDataService;
     this.exposureNotificationService = exposureNotificationService;
     userData = this.userDataService.Get();
 }
Exemplo n.º 30
0
        public async Task GetProjectsTest()
        {
            //ARRANGE
            _httpMessageHandlerMock.SetupHttpMessageHandlerMock(HttpMethod.Get, "api/projects", HttpStatusCode.OK, new ApiResult(HttpStatusCode.OK, new List <Project>()
            {
                new Project
                {
                    ProjectName = "TestProject"
                }
            }
                                                                                                                                 ));

            var userDataService = new UserDataService(_httpClient, null);

            //ACT
            //call GetProjects() twice so we not only get the projects from the "server" but also from the cache.
            var projects = await userDataService.GetProjects();

            var projectsAgain = await userDataService.GetProjects();

            //ASSERT
            //even though GetProjects() was called twice, we only expect it to actually retrieve data from the server the first time (so only once).
            _httpMessageHandlerMock.Protected().Verify("SendAsync", Times.Exactly(1),
                                                       ItExpr.Is <HttpRequestMessage>(req =>
                                                                                      req.Method == HttpMethod.Get &&
                                                                                      req.RequestUri == new Uri("https://localhost:5001/api/projects")
                                                                                      ),
                                                       ItExpr.IsAny <CancellationToken>()
                                                       );

            Assert.Equal("TestProject", projects[0].ProjectName);

            //we expect both projects to be the same object since the second GetProjects() call simply returned the cached projects list.
            Assert.Equal(projectsAgain[0], projects[0]);
        }
Exemplo n.º 31
0
 public ChatbotPageViewModel(INavigationService navigationService, UserDataService userDataService, ExposureNotificationService exposureNotificationService) : base(navigationService, userDataService, exposureNotificationService)
 {
     Title = AppResources.SettingsPageTitle;
     this.userDataService             = userDataService;
     _UserData                        = this.userDataService.Get();
     this.exposureNotificationService = exposureNotificationService;
 }
Exemplo n.º 32
0
        public UserPositionsVM(UserVM user, AccessType access)
            : base(access)
        {
            UnitOfWork = new SoheilEdmContext();
            CurrentUser = user;
            UserDataService = new UserDataService(UnitOfWork);
            PositionDataService = new PositionDataService(UnitOfWork);
            AccessRuleDataService = new AccessRuleDataService(UnitOfWork);
            UserDataService.PositionAdded += OnPositionAdded;
            UserDataService.PositionRemoved += OnPositionRemoved;


            var selectedVms = new ObservableCollection<UserPositionVM>();
            foreach (var userPosition in UserDataService.GetPositions(user.Id))
            {
                selectedVms.Add(new UserPositionVM(userPosition, Access, RelationDirection.Straight));
            }
            SelectedItems = new ListCollectionView(selectedVms);

            var allVms = new ObservableCollection<PositionVM>();
            foreach (var position in PositionDataService.GetActives(SoheilEntityType.Users, CurrentUser.Id))
            {
                allVms.Add(new PositionVM(position, Access, PositionDataService));
            }
            AllItems = new ListCollectionView(allVms);

            //AllItems = new ListCollectionView(PositionDataService.GetActives());
            IncludeCommand = new Command(Include, CanInclude);
            ExcludeCommand = new Command(Exclude, CanExclude);
        }
Exemplo n.º 33
0
		public MainWindow()
		{
			_accessRuleDataService = new AccessRuleDataService();
			_userDataService = new UserDataService();

			var culture = CultureInfo.GetCultureInfo("fa-IR");

			Dispatcher.Thread.CurrentCulture = culture;
			Dispatcher.Thread.CurrentUICulture = culture;

			LocalizationManager.UpdateValues();

			InitializeComponent();
			AccessList = new List<Tuple<string, AccessType>>();
			LoginCommand = new Command(Login);
			_newTabNumber = 1;

			// temp
			//Login(null);
			//SetValue(LoginProperty, true);
			//.

			Closing += (s, e) => Soheil.Core.PP.PPItemManager.Abort();

			if (Environment.UserName == "Bizhan" || Environment.UserName == "Bizz")
			{
				//SingularList = new Core.ViewModels.PP.PPTableVm(AccessType.Full);
				//chrometabs.AddTab(CreateSingularTab(SoheilEntityType.ProductPlanTable), true);
			}
		}
Exemplo n.º 34
0
 public UserListViewModel()
 {
     // Dependency traz uma implementação de SQLite trazendo a conexão.
     _dataService = new UserDataService(DependencyService.Get <ISQLite>().GetConnection());
     //Entities é do tipo Observable Collection, que recebe uma lista. Aqui passamos a coleção de dados.
     Entities = new ObservableCollection <User>(_dataService.Select());
 }
Exemplo n.º 35
0
        public void Init()
        {
            Now = DateTime.Now;
            IgLogic = new InstantGagnantLogic();
            CleanUp();
            UserDataService uDal = new UserDataService();
            MainUser = uDal.GetUserByEmail("*****@*****.**");

            List<InstantGagnant> list = new List<InstantGagnant>
            {
                new InstantGagnant { FrontHtmlId = "blason-carnetcanal", Label= "second_winable", StartDateTime = new DateTime(Now.Year, Now.Month, Now.Day), Won = false},
                new InstantGagnant { FrontHtmlId = "blason-carnetcine", Label= "non_winable", StartDateTime = new DateTime(Now.Year, Now.Month, Now.Day).AddDays(1), Won = false},
                new InstantGagnant { FrontHtmlId = "blason-iphone", Label= "first_winable", StartDateTime = new DateTime(Now.Year, Now.Month, Now.Day).AddDays(-1), Won = false},
            };
            foreach (InstantGagnant ig in list)
            {
                IgLogic.AddInstantGagnant(ig);
            }
        }
Exemplo n.º 36
0
        public UserAccessRulesVM(UserVM user, AccessType access):base(access)
        {
            UnitOfWork = new SoheilEdmContext();
            CurrentUser = user;
            UserDataService = new UserDataService(UnitOfWork);
            UserDataService.AccessRuleChanged += OnAccessRuleChanged;
            AccessRuleDataService = new AccessRuleDataService(UnitOfWork);
            UserAccessRuleDataService = new UserAccessRuleDataService(UnitOfWork);
            PositionAccessRuleDataService = new PositionAccessRuleDataService(UnitOfWork);

            RootNode = new UserAccessNodeVM(Access) { Title = string.Empty, Id = -1, ParentId = -2 };

            var selectedVms = new ObservableCollection<UserAccessNodeVM>();

            var ruleAccessList = AccessRuleDataService.GetPositionsAccessOfUser(user.Id);

            foreach (var accessRule in AccessRuleDataService.GetActives())
            {
                selectedVms.Add(new UserAccessNodeVM(accessRule.Id, user.Id, AccessRuleDataService, UserAccessRuleDataService, ruleAccessList, Access));
            }

            var allVms = new ObservableCollection<AccessRuleVM>();
            foreach (var accessRule in AccessRuleDataService.GetActives())
            {
                allVms.Add(new AccessRuleVM(AccessRuleDataService, accessRule, Access));
            }
            AllItems = new ListCollectionView(allVms);

            IncludeCommand = new Command(Include, CanInclude);
            ExcludeTreeCommand = new Command(ExcludeTree, CanExcludeTree);

            foreach (UserAccessNodeVM item in selectedVms)
            {
                if (item.ParentId == RootNode.Id)
                {
                    RootNode.ChildNodes.Add(item);
                    break;
                }
            }

            CurrentNode = RootNode;
        }
Exemplo n.º 37
0
        private void InitializeData()
        {
            UnitOfWork = new SoheilEdmContext();
            UserDataService = new UserDataService(UnitOfWork);
            UserDataService.UserAdded += OnUserAdded;

            ColumnHeaders = new List<ColumnInfo> 
            { 
                new ColumnInfo("Code",0), 
                new ColumnInfo("Name",1), 
                new ColumnInfo("Username",2), 
                new ColumnInfo("Status",3) ,
                new ColumnInfo("Mode",4,true) 
            };

            AddCommand = new Command(Add, CanAdd);RefreshCommand = new Command(CreateItems);
            AddGroupCommand = new Command(Add ,CanAddGroup);
            ViewCommand = new Command(View, CanView);
            CreateItems(null);
        }
Exemplo n.º 38
0
        private void OnElapsedTime(object source, ElapsedEventArgs e)
        {
            if (DateTime.Now.DayOfWeek.Equals(DayOfWeek.Saturday) || DateTime.Now.DayOfWeek.Equals(DayOfWeek.Sunday))
                return;
            timer.Stop();
            bool hasTriggeredTodayYet = LastBundleModifiedDate == BundleLogic.GetToday();
            if (hasTriggeredTodayYet)
            {
                timer.Start();
                return;
            }

            bool rightTime = (DateTime.Now.Hour == DailyExecutionHour && DateTime.Now.Minute == DailyExecutionMinute) || WebConfig.Get.forceRightTime == "true";
            if (!rightTime)
            {
                timer.Start();
                return;
            }
            Program.log("It's business time !");
            BundleLogic bundleLogic = new BundleLogic();
            DateTime Today0h = BundleLogic.GetToday();
            var bundleGet = bundleLogic.GetBundleByDate(Today0h);
            if (!bundleGet.Result && bundleGet.Message == "Probleme de connexion à la base.")
            {
                Program.log(bundleGet.Message);
                Stop();
            }

            Program.log("Bundle déjà créé ? " + bundleGet.Result +"("+ bundleGet.Message+")");

            // predicates
            bool csvNotYetCreated = !bundleGet.Result || (bundleGet.Result && bundleGet.ReturnObject.Status == BundleStatus.NoFileCreated);
            bool featureCsvCreationActivated = WebConfig.Get.createCsv == "true";
            Program.log("yesterdayCsvNotYetCreated : " + csvNotYetCreated);
            Program.log("rightTime : " + rightTime);
            Program.log("featureCsvCreationActivated : " + featureCsvCreationActivated);

            if (csvNotYetCreated && featureCsvCreationActivated)
            {

                Program.log(string.Format("It's time ! ({0}h{1}) {2}", DateTime.Now.Hour, DateTime.Now.Minute, WebConfig.Get.forceRightTime == "true" ? "(Forced)" : ""));

                var bResult = bundleLogic.CreateBundle(Today0h); Program.log("Bundle créé : " + Today0h);

                ServiceProcess service = new ServiceProcess(); Program.log("Retrieving users since " + BundleLogic.GetPreviousDayOrSo0h().ToString("dd/MM/yyyy"));
                List<User> listNewUserDay = service.RetrieveNewUsersSince(BundleLogic.GetPreviousDayOrSo0h()); Program.log("User List : " + listNewUserDay.Count);
                bundleLogic.SetBundleTotalSubs(Today0h, listNewUserDay.Count);
                UserDataService uDal = new UserDataService();
                string csvInPath = ConfigurationManager.AppSettings["localCsvFilesDirectory"];
                string localfilePath = uDal.CreateCsvContentForCanal(csvInPath, listNewUserDay, 1);
                if (File.Exists(localfilePath))
                {
                    Program.log("File CSVIN créé : " + localfilePath);

                    var bfResult = bundleLogic.AttachFileToBundle(Today0h, localfilePath, BundleFileType.CsvIn);
                    if (bfResult.Result)
                        bundleLogic.SetBundleStatus(Today0h, BundleStatus.CsvInCreated);

                    if (ConfigurationManager.AppSettings["sendCsvToCanal"] == "true")
                    {
                        var ftpResult = service.CanalPushFileFTP(localfilePath);
                        if (ftpResult.Result)
                            bundleLogic.SetBundleStatus(Today0h, BundleStatus.CsvInSentToCanal);
                    }
                }

                if (!_canTriggerSeveralTimesADay)
                {
                    LastBundleModifiedDate = Today0h;
                }
            }
            else if (!_canTriggerSeveralTimesADay)
            {
                LastBundleModifiedDate = Today0h;
            }
            timer.Start();
        }
Exemplo n.º 39
0
		public SiteController()
		{
			UserDal = new UserDataService();
		}
        public string this[string columnName]
        {
            get
            {
                string result = "";
                switch (columnName)
                {
                    case "Username":
                        if (!_firstRun)
                        {
                            if (!Validation.ValidUsername(Username))
                            {
                                result = Messages.UserLeastFourSymbols;
                            }
                            else
                            {
                                UserDataService uService = new UserDataService();
                                UserDataModel user = uService.GetUser(Username);

                                if (user != null)
                                {
                                    result = Messages.UserAlreadyToken;
                                }
                            }
                        }
                        break;
                    case "Email": if (!_firstRun && (!Validation.ValidEmail(Email))) result = Messages.EmailIncorrect; break;
                    case "Password":
                        if (!_firstRun && (!Validation.ValidPassword(Password)))
                            result = Messages.PasswordNotLeastSixSymbols;
                        break;
                    /*case "PasswordConfirm":
                        if (!_firstRun && (!Validation.ValidPassword(PasswordConfirm)))
                            result = "PasswordConfirm is incorrect";
                        break; */
                    case "Name": if (!_firstRun && (!Validation.ValidText(Name))) result = Messages.NameOnlyLettersToThirty; break;
                    case "Surname": if (!_firstRun && (!Validation.ValidText(Surname))) result = Messages.SurnameOnlyLettersToThirty; break;
                    case "MiddleName": if (!_firstRun && (!Validation.ValidText(MiddleName))) result = Messages.MiddleNameOnlyLettersToThirty; break;
                    case "SelectedGroup":
                        if (!_firstRun && !IsTeacher)
                        {
                            if (_selectedGroup == String.Empty)
                            {
                                return Messages.StudentNotGroup;
                            }
                            else if (!Validation.ValidTextWithNumbers(_selectedGroup, 3))
                            {
                                return Messages.GroupNotLeastThreeSymbols;
                            }

                        }
                        break;
                    default: break;
                };

                return result;
            }
        }
Exemplo n.º 41
0
 public UserDboTest()
 {
     repository = new UserRepository(DbContextFactory);
     dataService = new UserDataService(repository, UnitOfWork);
 }
Exemplo n.º 42
0
 public static User CreateNew(UserDataService dataService)
 {
     int code = dataService.GenerateCode();
     int id = dataService.AddModel(new User { Code = code, Title = "جدید" ,CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, Username = string.Empty, Password = string.Empty, Status = (byte)Status.Active});
     return dataService.GetSingle(id);
 }
Exemplo n.º 43
0
        private void OnElapsedTime(object source, ElapsedEventArgs e)
        {
            timer.Stop();
            int h = Convert.ToInt32(ConfigurationManager.AppSettings["heureDuJour"].Split('h')[0]);
            int m = Convert.ToInt32(ConfigurationManager.AppSettings["heureDuJour"].Split('h')[1]);
            //Program.log(string.Format("It's {0}h{1}, not {2}h{3}.", DateTime.Now.Hour, DateTime.Now.Minute, h, m));
            if ((DateTime.Now.Hour == h && DateTime.Now.Minute == m && DateTime.Now.Date > _lastDayDone.Date)
                || ConfigurationManager.AppSettings["debugMode"] == "true"
                )
            {
                Program.Log(string.Format("It's time ! {0} as in config",ConfigurationManager.AppSettings["heureDuJour"] ));
                if(ConfigurationManager.AppSettings["debugMode"] == "true")
                    Program.Log("(Service is in Debug mode)");
                ServiceProcess mp = new ServiceProcess();

                    List<User> listNewUserDay = mp.RetrieveNewUsers();

                Program.Log("User List : " + listNewUserDay.Count);
                UserDataService uDal = new UserDataService();

                string path = ConfigurationManager.AppSettings["localCsvFilesDirectory"];
                string csvfilePath = uDal.CreateCsvFileFtpFromList(path, listNewUserDay, "CSat");
                //string csvCPlusfilePath = uDal.CreateCsvFileFtpFromList(path, listCanalPlus, "CPlus");
                //string csvCSatfilePath = uDal.CreateCsvFileFtpFromList(path, listCanalSat, "CSat");
                //Program.log(csvCPlusfilePath);
                //mp.PushFileFTP(csvCPlusfilePath, "cplus");
                Program.Log(csvfilePath);
                mp.MailPerformancePushFileFTP(csvfilePath, "plus");
                if(!_canTriggerSeveralTimesADay)
                    _lastDayDone = DateTime.Now;
            }

            if (DateTime.Now.ToString("yyyyMMdd") == ConfigurationManager.AppSettings["finOperation"])
            {
                // l'opé est terminée, on ne restart par le timer et il faudra désinstaller le service.
                //OnStop();
                Program.Log("Stopping service, end Of Operation has been reached : " + ConfigurationManager.AppSettings["finOperation"]);
                return;
            }
            //Program.log("Timer restart.");
            timer.Start();
        }
Exemplo n.º 44
0
        public ActionResult Index(HomeModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                #region checkParams
                var dd = DateTime.Parse(model.DateDebut);
                var df = DateTime.Parse(model.DateFin);
                if (dd > df)
                {
                    ModelState.AddModelError("", "La date de fin doit être supérieur à la date de début");
                    return View(model);
                }
                #endregion

                //---
                var uDal = new UserDataService();
                var extractResult = uDal.ExtractUsersWithDateLapsTime(dd, df);
                if (!extractResult.Result)
                    throw new Exception("Erreur d'extraction : " + extractResult.Message);

                var users = extractResult.ReturnObject;

                //---
                var po = users.Where(u => u.IsOffreGroupCanal).ToList();
                var nbpo = po.Count;
                var nbpoa = po.Where(u => u.IsCanal).Count();
                var total = new StatsTotal
                                {
                                    NbParticipations = users.Count,
                                    NbParticipationsOptin = nbpo,
                                    NbParticipationsOptinAbonnés = nbpoa,
                                    NbParticipationsOptinNonAbonnés = nbpo - nbpoa
                                };

                //---
                var usersa = users.Where(u => u.Provenance == "tradedoubler").ToList();
                var pa = usersa.Where(u => u.IsOffreGroupCanal).ToList();
                var nbpa = pa.Count;
                var nbpaa = pa.Where(u => u.IsCanal).Count();
                var tradedoubler = new StatsTradedoubler
                {
                    NbParticipants = usersa.Count,
                    NbParticipantsOptin = nbpa,
                    NbParticipantsOptinAbonnés = nbpaa,
                    NbParticipantsOptinNonAbonnés = nbpa - nbpaa
                };

                //---
                var oa = (int) (((Double) nbpoa/(Double) nbpo)*100);
                var oapa = (int) (((Double) nbpaa/(Double) usersa.Count)*100);
                var ona = (int) (((Double) (nbpo - nbpoa)/(Double) nbpo)*100);
                var onapa = (int) (((Double) (nbpa - nbpaa)/(Double) usersa.Count)*100);
                var op = (int) (((Double) nbpo/(Double) users.Count)*100);
                var ppa = (int) (((Double) usersa.Count/(Double) users.Count)*100);
                var analyse = new StatsAnalyse
                {
                    TauxOptinAbonnes = oa > 0 ? oa : 0,
                    TauxOptinAbonnesParticipantsTradedoubler = oapa > 0 ? oapa : 0,
                    TauxOptinNonAbonnes = ona > 0 ? ona : 0,
                    TauxOptinNonAbonnesParticipantsTradedoubler = onapa > 0 ? onapa : 0,
                    TauxOptinParticipants = op > 0 ? op : 0,
                    TauxParticipationsParticipantsTradedoubler = ppa > 0 ? ppa : 0
                };

                //---
                var episodes = new StatsEpisodes
                                   {
                                       NbJoueursEpisode1 = users.Where(u=>u.FriendEmail1!=null || u.FriendEmail2!=null || u.FriendEmail3!=null).Count(),
                                       //NbJoueursEpisode2 = users.Where(u => u.ShowType != null).Count(),
                                       //NbJoueursEpisode3 = users.Where(u => u.ConnexionType != null).Count(),
                                       NbJoueursEpisode4 = users.Where(u => u.Address != null).Count(),
                                       NbJoueursEpisode5 = users.Where(u => u.Phone != null).Count()
                                   };

                //---
                Session[ConfigurationManager.AppSettings["sessionId"] + "_users"] = users;
                model.Stats = new Stats
                                  {
                                      Total = total,
                                      Analyse = analyse,
                                      Tradedoubler = tradedoubler,
                                      Episodes = episodes
                                  };

            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
Exemplo n.º 45
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductVM"/> class from the model.
 /// </summary>
 /// <param name="entity">The model.</param>
 /// <param name="access"></param>
 public UserVM(User entity, AccessType access, UserDataService dataService)
     : base(access)
 {
     InitializeData(dataService);
     _model = entity;
 }
Exemplo n.º 46
0
 private void InitializeData(UserDataService dataService)
 {
     UserDataService = dataService;
     SaveCommand = new Command(Save, CanSave);
 }
        private void RegisterUser()
        {
            List<RoleDataModel> userRoles = new List<RoleDataModel>();
            RoleDataService rService = new RoleDataService();
            GroupDataModel group = null;
            RoleDataModel role;
            UserRole selectedRole;

            if (_ViewModel.IsTeacher)
                selectedRole = UserRole.Teacher;
            else
                selectedRole = UserRole.Student;

            role = rService.GetRole(selectedRole);

            if (role != null)
            {
                userRoles.Add(role);
            }
            // such role not exist in db? - create it!
            else
            {
                role = new RoleDataModel();
                role.Role = selectedRole;

                if (selectedRole == UserRole.Student)
                {
                    role.Name = "Student";

                    GroupDataService gService = new GroupDataService();
                    group = gService.GetGroup(_ViewModel.SelectedGroup);
                    if (group == null)
                    {
                        group = gService.CreateGroup(_ViewModel.SelectedGroup);
                    }
                }
                else
                {
                    role.Name = "Teacher";
                }

                rService.Add(role);
                userRoles.Add(rService.GetRole(selectedRole));
            }

            // adding group to UserDM if registering student
            if (selectedRole == UserRole.Student)
            {
                GroupDataService gService = new GroupDataService();
                group = gService.GetGroup(_ViewModel.SelectedGroup);
                if (group == null)
                {
                    group = gService.CreateGroup(_ViewModel.SelectedGroup);
                }
            }

            // create new user object for write to db
            UserDataModel newUser = new UserDataModel
            {
                Username = _ViewModel.Username,
                Email = _ViewModel.Email,
                Password = Authentication.HashPassword(_ViewModel.Password),
                FirstName = _ViewModel.Name,
                LastName = _ViewModel.Surname,
                MiddleName = _ViewModel.MiddleName,
                Group = group,
                Roles = userRoles
            };

            UserDataService uService = new UserDataService();
            uService.Add(newUser);
            MessageBox.Show(Messages.RegisterSuccessfull, Messages.CaptionRegistered);
            this.Close();
        }
Exemplo n.º 48
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductGroupVM"/> class initialized with default values.
 /// </summary>
 public UserVM(AccessType access, UserDataService dataService):base(access)
 {
     InitializeData(dataService);
 }