public void TestGetFilePathsNull()
        {
            var resultFiles = Filehelper.GetFilePaths(null, out var resultMessage);

            Assert.True(resultMessage == null, $"Result is not null");
            Assert.True(resultFiles.Any(), "Expected at least on file");
        }
        public void TestGetFilePathsInvalidFolder()
        {
            var resultFiles = Filehelper.GetFilePaths("c:\testtesttest", out var resultMessage);

            Assert.True(resultMessage.Code == Types.EExitCode.INVALID_FOLDER, $"Unexpected Result. Expected {Types.EExitCode.INVALID_FOLDER}");
            Assert.True(resultFiles == null, "Expected empty Array");
        }
Esempio n. 3
0
 //[ValidationAspect(typeof(CarImageValidator))]
 public IResult Update(IFormFile file, CarImage carImage)
 {
     carImage.ImagePath = Filehelper.UpdateAsync(_carImageDal.Get(p => p.Id == carImage.Id).ImagePath, file);
     carImage.Date      = DateTime.Now;
     _carImageDal.Update(carImage);
     return(new SuccessResult());
 }
        public IResult Update2(IFormFile file, CarImage carImage)
        {
            var oldpath = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..\\..\\..\\wwwroot")) + _carImageDal.Get(p => p.Id == carImage.Id).ImagePath;

            carImage.ImagePath = Filehelper.UpdateAsync(oldpath, file);
            carImage.Date      = DateTime.Now;
            _carImageDal.Update(carImage);
            return(new SuccessResult());
        }
Esempio n. 5
0
        public void TestUploadAsyncUrlNotFound()
        {
            sourceOptions.RepositoryUrl = "http://www.bing.de";
            systemUnderTest             = new HttpUploader(sourceOptions);
            var sourceFiles = Filehelper.GetFilePaths(sourceOptions.SourceFolder, out var resultMessage);

            var result = systemUnderTest.UploadAsync(sourceFiles).GetAwaiter().GetResult();

            Assert.Equal(Types.EExitCode.INVALID_PARAMS, result.Code);
        }
Esempio n. 6
0
        public void TestUploadAsyncSomeFiles()
        {
            // init Test
            systemUnderTest = new HttpUploader(sourceOptions);
            var sourceFiles = Filehelper.GetFilePaths(sourceOptions.SourceFolder, out var resultMessage);

            // perform action
            var result = systemUnderTest.UploadAsync(sourceFiles).GetAwaiter().GetResult();

            // check result
            Assert.True(result.Code == Types.EExitCode.UPLOAD_ERROR, "Unexpected Upload Success");
        }
Esempio n. 7
0
        //[ValidationAspect(typeof(CarImageValidator))]
        public IResult Add(IFormFile file, CarImage carImage)
        {
            IResult result = BusinessRules.Run(CheckIfImageLimit(carImage.CarId));

            if (result != null)
            {
                return(result);
            }
            carImage.ImagePath = Filehelper.AddAsync(file);
            carImage.Date      = DateTime.Now;
            _carImageDal.Add(carImage);
            return(new SuccessResult());
        }
Esempio n. 8
0
        public void TestRemoveAsyncSomeFiles()
        {
            // init Test
            systemUnderTest = new HttpUploader(sourceOptions);

            var sourceFiles = Filehelper.GetFilePaths(sourceOptions.SourceFolder, out var resultMessage);

            // perform action
            var result = systemUnderTest.RemoveAsync(sourceFiles).GetAwaiter().GetResult();

            // check result
            Assert.True(result == null, "Unexpected Result");
        }
        public IResult Delete2(IFormFile file, CarImage carImage)
        {
            var oldpath = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..\\..\\..\\wwwroot")) + _carImageDal.Get(p => p.Id == carImage.Id).ImagePath;

            IResult result = BusinessRules.Run();

            if (result != null)
            {
                return(result);
            }
            Filehelper.DeleteAsync(oldpath);
            _carImageDal.Delete(carImage);
            return(new SuccessResult());
        }
Esempio n. 10
0
        // [SecuredOperation("admin")]
        public IResult Add2(IFormFile file, CarImage carImage)
        {
            IResult result = BusinessRules.Run(CheckIfCarHaveMoreThan5Images(carImage.CarId)
                                               , CheckIfCarImagePathTypeCorrect(carImage.ImagePath));

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

            carImage.ImagePath = Filehelper.AddAsync(file);
            carImage.Date      = DateTime.Now;
            _carImageDal.Add(carImage);
            return(new SuccessResult());
        }
Esempio n. 11
0
        private void button_Click(object sender, EventArgs e)
        {
            var filehelper = new Filehelper();

            if (Directory.Exists(_path) && filehelper.IsAccessible(_path))
            {
                UiAccess(false);
                var responce = filehelper.SearchDirectory(_path, 0);
                Output.Text = responce;
                UiAccess(true);
            }
            else
            {
                MessageBox.Show("no directory found");
            }
        }
        public IResult Add(IFormFile file, UnivercityImage univercityImage)

        {
            IResult result = BusinessRules.Run(CheckIfUnivercityHaveMoreThan1Images(univercityImage.UnivercityId),
                                               DeleteIfUnivercityHaveImage(univercityImage.UnivercityId));


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

            univercityImage.ImagePath = Filehelper.AddAsync(file);
            _univercityImageDal.Add(univercityImage);
            return(new SuccessResult());
        }
Esempio n. 13
0
 public virtual void SaveModel(string path = null, double accuracy = -1)
 {
     if (path == null)
     {
         path = System.IO.Path.Combine(Application.StartupPath, "Models");
     }
     if (Directory.Exists(path) == false)
     {
         Directory.CreateDirectory(path);
     }
     //if (accuracy == -1)
     //{
     //    path = System.IO.Path.Combine(Application.StartupPath, this.name);
     //}
     path = System.IO.Path.Combine(path, this.name + "-" + accuracy.ToString("f3") + ".model");
     //path = System.IO.Path.Combine(path, "CNN_v1" + "-" + accuracy.ToString("f3") + ".model");
     Filehelper.SaveObject(path, this);
     Console.WriteLine("The Model has been save to" + path);
 }
Esempio n. 14
0
        //handles user Registration
        private async void SignUpClickEvent(object sender, EventArgs e)
        {
            ScaleButton2();
            if (CrossConnectivity.Current.IsConnected)
            {
                using (UserDialogs.Instance.Loading("Please Wait..", null, null, true, MaskType.Gradient))
                {
                    try
                    {
                        var imagearray = Filehelper.Readfully(file.GetStream());

                        var data = new RegisterModel
                        {
                            Id              = Guid.NewGuid(),
                            Email           = emailEntry.Text,
                            Alias           = usernameEntry.Text,
                            Password        = passwordEntry.Text,
                            ConfirmPassword = passwordEntry2.Text,
                            PhoneNumber     = phonenumberEntry.Text,
                            ImageArray      = imagearray,
                            DateJoined      = DateTime.Now
                        };
                        //checks for empty entry fields
                        if (string.IsNullOrEmpty(emailEntry.Text) || string.IsNullOrWhiteSpace(usernameEntry.Text) || string.IsNullOrWhiteSpace(passwordEntry.Text) ||
                            string.IsNullOrWhiteSpace(passwordEntry2.Text) || string.IsNullOrWhiteSpace(phonenumberEntry.Text))
                        {
                            await DisplayAlert("Error..!!", "Fields marked * cannot be empty", "ok");
                        }

                        //checks for password fields comparison
                        if (passwordEntry.Text != passwordEntry2.Text)
                        {
                            await DisplayAlert("Error..!!", "Passwords does not match", "ok");
                        }

                        if (usernameEntry.Text.Length < 2)
                        {
                            errorlbl4.IsVisible = true;
                            errorlbl4.Text      = "Username cannot be less 2 charaters";
                            UsernameSignupShake();
                            return;
                        }

                        if (phonenumberEntry.Text.Length != 11)
                        {
                            errorlbl7.IsVisible = true;
                            errorlbl7.Text      = "Phone number cannot be less than 11 characters";
                            PhoneSignUpShake();
                            return;
                        }


                        var response = await services.RegisterUser(data);

                        if (!response)
                        {
                            await DisplayAlert("Something went wrong", "Check fields for error details and modify", "ok");

                            errorlbl3.IsVisible = true;
                            errorlbl3.Text      = "Enter a valid email; [email protected] is an example of a valid email";
                            EmailSignupShake();
                            errorlbl4.IsVisible = true;
                            errorlbl4.Text      = "username must be at least 2 characters long";
                            UsernameSignupShake();
                            errorlbl5.IsVisible = true;
                            errorlbl5.Text      = "Password must be at least 6 characters and must contain special characters @!?+*$%^ and an Uppercase(A-Z)";
                            PasswordSignUpShake();
                            //errorlbl6.IsVisible = true;
                            errorlbl7.IsVisible = true;
                            errorlbl7.Text      = "Enter a valid phone number e.g 12345678890";
                            PhoneSignUpShake();
                        }
                        else
                        {
                            await DisplayAlert("Successful...", "Record saved successfully", "ok");

                            await Navigation.PushAsync(new Both());
                        }
                    }
                    catch (Exception)
                    {
                        await DisplayAlert("Error..", "Make sure Image Field or Text fields are not empty", "ok");
                    }
                }
            }
            else
            {
                await DisplayAlert("Connection Timeout", "Check your Internet Connection and Try again", "ok");
            }
        }
Esempio n. 15
0
 public virtual T LoadModel <T>(string path)
 {
     return(Filehelper.GetObjectFromFile <T>(path));
 }