Ejemplo n.º 1
0
        public int AddReport(Report report, IFormFile reportimage, IFormFile reportfile, string username)
        {
            report.CreateDate      = DateTime.Now;
            report.ReportImageName = "ReportImg.jpg";
            int writerid = _userService.GetUserIDByUserName(username);

            report.WriterID = writerid;

            //Check Image
            if (reportimage != null && reportimage.IsImage())
            {
                report.ReportImageName = NameGenerator.GenerateUniqCode() + Path.GetExtension(reportimage.FileName);
                string reportimgpath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Report/ReportIMG", report.ReportImageName);
                using (var stream = new FileStream(reportimgpath, FileMode.Create))
                {
                    reportimage.CopyTo(stream);
                }

                ImageConvertor imgresizer = new ImageConvertor();
                string         thumbpath  = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Report/thumb", report.ReportImageName);
                imgresizer.Image_resize(reportimgpath, thumbpath, 250);
            }
            if (reportfile != null)
            {
                report.ReportFileName = NameGenerator.GenerateUniqCode() + Path.GetExtension(reportfile.FileName);
                string reportfilepath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Report/File", report.ReportFileName);
                using (var stream = new FileStream(reportfilepath, FileMode.Create))
                {
                    reportfile.CopyTo(stream);
                }
            }
            _context.Reports.Add(report);
            _context.SaveChanges();
            return(report.ReportID);
        }
Ejemplo n.º 2
0
        public int Addcourse(Course course, IFormFile imgCourse, IFormFile democourse)
        {
            course.Createdate     = DateTime.Now;
            course.CourseImagname = "no-image.png";
            if (imgCourse != null && imgCourse.Isimage())
            {
                course.CourseImagname = Namegenerator.GenerateUniqcode() + Path.GetExtension(imgCourse.FileName);
                string imagepath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Course/Image", course.CourseImagname);

                using (var stream = new FileStream(imagepath, FileMode.Create))
                {
                    imgCourse.CopyTo(stream);
                }
                ImageConvertor imageresizer = new ImageConvertor();
                string         thumpath     = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Course/thumb", course.CourseImagname);
                imageresizer.Image_resize(imagepath, thumpath, 150);
            }
            if (democourse != null)
            {
                course.DemofileName = Namegenerator.GenerateUniqcode() + Path.GetExtension(democourse.FileName);
                string demopath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Course/demos", course.DemofileName);
                using (var stream = new FileStream(demopath, FileMode.Create))
                {
                    democourse.CopyTo(stream);
                }
            }

            _db.Add(course);
            _db.SaveChanges();
            return(course.CourseID);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> AddUser(LoginedUserViewModel loginView)
        {
            if (ModelState.IsValid)
            {
                if (Request.Form.Files.Count == 1)
                {
                    loginView.Photo = ImageConvertor.ConvertImageToBytes(Request.Form.Files[0]);
                }

                var mappedUser = mapper.Map <UserDTO>(loginView);
                mappedUser.Role = loginView.IsAdmin ? Roles.Admin : Roles.User;
                var result = await accountService.Registration(mappedUser);

                if (result.Succeeded)
                {
                    return(RedirectToAction(nameof(Users)));
                }
                else
                {
                    foreach (var error in result.Errors)
                    {
                        ModelState.AddModelError(string.Empty, error.Description);
                    }
                }
            }
            return(View(loginView));
        }
Ejemplo n.º 4
0
 public int AddCourse(Course course, IFormFile imgCourse, IFormFile courseDemo)
 {
     course.CreateDate      = DateTime.Now;
     course.CourseImageName = "no-photo.jpg";
     if (imgCourse != null && imgCourse.IsImage())
     {
         course.CourseImageName = NameGenerator.GenerateUniqCode() + Path.GetExtension(imgCourse.FileName);
         string imagePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Course/image", course.CourseImageName);
         using (var stream = new FileStream(imagePath, FileMode.Create))
         {
             imgCourse.CopyTo(stream);
         }
         string         thumbPath  = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Course/thumb", course.CourseImageName);
         ImageConvertor imgResizer = new ImageConvertor();
         imgResizer.Image_resize(imagePath, thumbPath, 150);
     }
     if (courseDemo != null)
     {
         course.DemoFileName = NameGenerator.GenerateUniqCode() + Path.GetExtension(courseDemo.FileName);
         string demoPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Course/demoes", course.DemoFileName);
         using (var stream = new FileStream(demoPath, FileMode.Create))
         {
             courseDemo.CopyTo(stream);
         }
     }
     _context.Courses.Add(course);
     _context.SaveChanges();
     return(course.CourseId);
 }
Ejemplo n.º 5
0
        public void UpdateProduct(Product product, IFormFile proimg)
        {
            product.Updatedate = DateTime.Now;
            if (proimg != null && proimg.IsImage())
            {
                if (product.ProductImageName != "no-photo.jpg")
                {
                    string deletpath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/products/image", product.ProductImageName);
                    if (File.Exists(deletpath))
                    {
                        File.Delete(deletpath);
                    }
                    string deletthumbpath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/products/thumb", product.ProductImageName);
                    if (File.Exists(deletthumbpath))
                    {
                        File.Delete(deletthumbpath);
                    }
                }


                product.ProductImageName = NameGenerator.Generateuniqcode() + Path.GetExtension(proimg.FileName);
                string imagepath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Products/image", product.ProductImageName);


                using (var stream = new FileStream(imagepath, FileMode.Create))
                {
                    proimg.CopyTo(stream);
                }
                ImageConvertor imgresizer = new ImageConvertor();
                string         thumbpath  = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Products/thumb", product.ProductImageName);
                imgresizer.Image_resize(imagepath, thumbpath, 150);
            }
            _db.Products.Update(product);
            _db.SaveChanges();
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> ModifyUser(ProfileViewModel user)
        {
            if (ModelState.IsValid)
            {
                if (Request.Form.Files.Count == 1)
                {
                    user.Photo = ImageConvertor.ConvertImageToBytes(Request.Form.Files[0]);
                }

                user.Role = user.IsAdmin ? Roles.Admin : Roles.User;
                var userDto = mapper.Map <UserDTO>(user);

                var identityResult = await accountService.UpdateUserAsync(user.Id, userDto);

                if (identityResult.Succeeded)
                {
                    return(RedirectToAction(nameof(Users)));
                }
                else
                {
                    foreach (var error in identityResult.Errors)
                    {
                        ModelState.AddModelError(string.Empty, error.Description);
                    }
                }
            }
            return(View(user));
        }
        public override void Search(int pk)
        {
            ImageConvertor objImageConvertor = new ImageConvertor();
            string         sql = "exec [SMS].[GetStaffDetails] '" + pk + "','" + Name + "','" + EmailAddress + "'," + this.Schoolid;

            SearchResult  = DAL.Select(sql);
            IUDFlag       = "U";
            StaffID       = SearchResult.Rows[0]["StaffID"].ToString();
            Name          = SearchResult.Rows[0]["Name"].ToString();
            EmailAddress  = SearchResult.Rows[0]["EmailAddress"].ToString();
            UserID        = SearchResult.Rows[0]["UserID"].ToString();
            Password      = SearchResult.Rows[0]["Password"].ToString();
            ContactNumber = SearchResult.Rows[0]["ContactNumber"].ToString();
            Address       = SearchResult.Rows[0]["Address"].ToString();
            Designation   = SearchResult.Rows[0]["Designation"].ToString();
            Subjects      = SearchResult.Rows[0]["Subjects"].ToString();
            DateOfJoining = Convert.ToDateTime(SearchResult.Rows[0]["DateOfJoining"]);
            DateofLeaving = Convert.ToDateTime(SearchResult.Rows[0]["DateofLeaving"]);
            DateOfBirth   = Convert.ToDateTime(SearchResult.Rows[0]["DateOfBirth"]);
            Gender        = SearchResult.Rows[0]["Gender"].ToString();
            Picture       = SearchResult.Rows[0]["Picture"].ToString();
            base.SetGender();
            PhotoID = SearchResult.Rows[0]["PhotoID"].ToString();

            if (!string.IsNullOrEmpty(this.Picture))
            {
                byte[] bytearr = Convert.FromBase64String(Picture);
                objImageConvertor.ConvertByteArrayToPhot(bytearr);
            }
            this.ImageSource = objImageConvertor.ImageSource;
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> EditTopic(TopicViewModel topicView)
        {
            var topic = await topicService.FindTopic(topicView.Id);

            if (topic is null)
            {
                ModelState.AddModelError(string.Empty, "Something went wrong...Topic is not defined");
            }
            if (Request.Form.Files.Count != 1)
            {
                ModelState.AddModelError("Image", "image cannot be empty");
            }
            else
            {
                topicView.TopicPicture = ImageConvertor.ConvertImageToBytes(Request.Form.Files[0]);
            }

            if (ModelState.IsValid)
            {
                if (topicView.TopicName is null && topic != null)
                {
                    topic.TopicName = topic.TopicName;
                }

                var mappedTopic = mapper.Map <TopicDTO>(topicView);
                await topicService.UpdateTopic(mappedTopic);
            }
            return(View(topicView));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> CreateUser(RegistrationViewModel registrationModel)
        {
            var fullPath = DefaultUserImagePath();

            var image = registrationModel.Avatar;

            if (string.IsNullOrEmpty(image))
            {
                registrationModel.Avatar = ImageConvertor.GetImageFromPath(fullPath);
            }
            else
            {
                registrationModel.Avatar = await Downloader.GetImageAsBase64Url(image);
            }

            var newUser = await _userService.CreateUserAsync(registrationModel);

            if (newUser == null)
            {
                throw new ValidationException(HttpStatusCode.Forbidden, _localizer["UserAlreadyExists"].Value);
            }

            var confirmEmailDto = new ConfirmEmailDTO
            {
                UserEmail   = newUser.Email,
                CallbackUrl = registrationModel.CallbackUrlForEmailConfirm
            };
            await _emailConfirmationService.SendConfirmEmailLinkAsync(confirmEmailDto);

            return(Ok());
        }
Ejemplo n.º 10
0
        private static void seedDB(ModelBuilder builder)
        {
            // Store and Define Objects
            User u1 = new User {
                EntityId = 1L, Name = "Kevin", IsAdmin = true
            };
            User u2 = new User {
                EntityId = 2L, Name = "Robert", IsAdmin = false
            };

            // Using Test Image
            var obj = new ImageConvertor();
            var img = Image.FromFile("Images/test_img.jpg");

            byte[] imgByteArr = obj.ConvertImageToByteArray(img, ".jpg");

            ComicPage p1 = new ComicPage {
                EntityId = 1L, ComicBookId = 1L, PageNumber = 1, Image = imgByteArr, PageTitle = "Tin goes to the amuesment park"
            };
            ComicBook b1 = new ComicBook {
                EntityId = 1L, Title = "Tin Tin's Adventure", Author = "Hergé", Genre = "Adventure", EditionNumber = 32, Description = "Description goes here"
            };

            // Insert the seed data to MS SQL DB
            builder.Entity <User>().HasData(u1);
            builder.Entity <User>().HasData(u2);

            builder.Entity <ComicBook>().HasData(b1);
            builder.Entity <ComicPage>().HasData(p1);
        }
Ejemplo n.º 11
0
        public int AddGallary(IFormFile galleryImg, int productId)
        {
            ProductGallery productGallery = new ProductGallery();

            productGallery.CreatDate = DateTime.Now;
            productGallery.ImageName = "no-photo.jpg";
            productGallery.ProductId = productId;

            if (galleryImg != null && galleryImg.IsImage())
            {
                productGallery.ImageName = NameGenerator.GenerateUniqCode() + Path.GetExtension(galleryImg.FileName);
                string imagePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/images/ProductGallary", productGallery.ImageName);

                using (var stream = new FileStream(imagePath, FileMode.Create))
                {
                    galleryImg.CopyTo(stream);
                }

                ImageConvertor imgResizer = new ImageConvertor();
                string         thumbPath  = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/images/ProductGallary/thumb", productGallery.ImageName);

                imgResizer.Image_resize(imagePath, thumbPath, 200);
            }
            _context.productGalleries.Add(productGallery);
            _context.SaveChanges();

            return(productGallery.GalleryId);
        }
Ejemplo n.º 12
0
 public ComicPageModel(ComicPageViewModel model)
 {
     PageTitle   = model.PageTitle;
     PageNumber  = model.PageNumber;
     Image       = ImageConvertor.ConvertImageToByteArray(model.Image, ".jpg");
     ComicBookId = model.WebcomicId;
     ComicBook   = model.ComicBook;
 }
Ejemplo n.º 13
0
        private void GetStudentDetails()
        {
            ImageConvertor objImageConvertor = new ImageConvertor();

            if (SelectedStudentNew == null)
            {
                return;
            }
            string studentid  = SelectedStudentNew.StudentID;
            int    student_id = 0;

            int.TryParse(studentid, out student_id);
            string sql = "exec [SMS].[GetStudentPaymentDetails] '" + this.ID + "'," + student_id + "," + this.Schoolid;

            SearchResult = DAL.Select(sql);
            if (SearchResult != null && SearchResult.Rows.Count > 0)
            {
                string PhotoID = SearchResult.Rows[0]["PhotoID"].ToString();
                if (!string.IsNullOrEmpty(PhotoID))
                {
                    if (File.Exists(PhotoID))
                    {
                        StreamReader sr          = new StreamReader(PhotoID);
                        string       photostring = sr.ReadToEnd();
                        sr.Close();
                        byte[] bytearr = Convert.FromBase64String(photostring);
                        objImageConvertor.ConvertByteArrayToPhot(bytearr);
                    }
                }
                this.ImageSource  = objImageConvertor.ImageSource;
                this.FullName     = SearchResult.Rows[0]["FullName"].ToString();
                this.EnrollmentNo = SearchResult.Rows[0]["EnrollmentNo"].ToString();
                this.ClassRoom    = SearchResult.Rows[0]["Class"].ToString();
                FormFields();
                lstStudentPaymentDetails = new ObservableCollection <StudentPaymentViewModelEntity>();

                foreach (DataRow dr in SearchResult.Rows)
                {
                    StudentPaymentViewModelEntity obj = new StudentPaymentViewModelEntity();
                    obj.ID              = dr["ID"].ToString();
                    obj.EntityID        = dr["EntityID"].ToString();
                    obj.EntityType      = dr["EntityType"].ToString();
                    obj.PaymentType     = dr["PaymentType"].ToString();
                    obj.TransType       = dr["TransType"].ToString();
                    obj.Amount          = dr["Amount"].ToString();
                    obj.Comments        = dr["Comments"].ToString();
                    obj.FullName        = dr["FullName"].ToString();
                    obj.EnrollmentNo    = dr["EnrollmentNo"].ToString();
                    obj.CreatedDateTime = dr["CreatedDateTime"].ToString();
                    obj.AcademicYear    = dr["AcademicYear"].ToString();
                    obj.ModeofPayment   = dr["ModeofPayment"].ToString();
                    //obj.ChequeNo = dr["chequeno"].ToString();
                    //obj.BankBranchDetails = dr["BankBranchDetails"].ToString();
                    lstStudentPaymentDetails.Add(obj);
                }
            }
        }
        void GetImageTempate()
        {
            StreamReader sr  = new StreamReader("Template.img");
            string       str = sr.ReadToEnd();

            sr.Dispose();
            ImageConvertor objImageConvertor = new ImageConvertor();

            byte[] bytearr = Convert.FromBase64String(str);
            objImageConvertor.ConvertByteArrayToPhot(bytearr);
            this.ImageSource = objImageConvertor.ImageSource;
        }
Ejemplo n.º 15
0
        public int AddProduct(Product product, IFormFile imgUp, List <int> selectedColor, List <int> selectedSize)
        {
            product.CreatDate   = DateTime.Now;
            product.ImageName   = "no-photo.jpg";
            product.IsActive    = true;
            product.IsDelete    = false;
            product.Visit       = 0;
            product.ProductCode = product.ProductCode.Trim();

            if (imgUp != null && imgUp.IsImage())
            {
                product.ImageName = NameGenerator.GenerateUniqCode() + Path.GetExtension(imgUp.FileName);
                string imagePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/images/Product", product.ImageName);

                using (var stream = new FileStream(imagePath, FileMode.Create))
                {
                    imgUp.CopyTo(stream);
                }

                ImageConvertor imgResizer = new ImageConvertor();
                string         thumbPath  = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/images/Product/thumb", product.ImageName);

                imgResizer.Image_resize(imagePath, thumbPath, 330);
            }

            _context.Add(product);
            _context.SaveChanges();

            foreach (var itemColor in selectedColor)             //----color to product--------
            {
                ColorToProduct colorToProduct = new ColorToProduct()
                {
                    ColorId   = itemColor,
                    ProductId = product.Id,
                };
                _context.Add(colorToProduct);
            }

            foreach (var itemSize in selectedSize)             //------size to product-----
            {
                SizeToProduct sizeToProduct = new SizeToProduct()
                {
                    SizeId    = itemSize,
                    ProductId = product.Id
                };
                _context.Add(sizeToProduct);
            }

            _context.SaveChanges();

            return(product.Id);
        }
Ejemplo n.º 16
0
        private static void seedDB(ModelBuilder builder)
        {
            // Store and Define Objects
            User u1 = new User {
                EntityId = 1L, Name = "Kevin", IsAdmin = true
            };
            User u2 = new User {
                EntityId = 2L, Name = "Robert", IsAdmin = false
            };
            //
            // Using Test Image
            var obj = new ImageConvertor();
            var img = Image.FromFile("Images/test_img.jpg");

            byte[] imgByteArr = obj.ConvertImageToByteArray(img, ".jpg");

            var img2 = Image.FromFile("Images/test_img2.jpg");

            byte[] imgByteArr2 = obj.ConvertImageToByteArray(img2, ".jpg");

            var img3 = Image.FromFile("Images/test_img3.jpg");

            byte[] imgByteArr3 = obj.ConvertImageToByteArray(img3, ".jpg");

            ComicPage p1 = new ComicPage {
                EntityId = 1L, ComicBookId = 1L, PageNumber = 1, Image = imgByteArr, PageTitle = "Tin goes to the amuesment park"
            };
            ComicPage p2 = new ComicPage {
                EntityId = 2L, ComicBookId = 2L, PageNumber = 1, Image = imgByteArr2, PageTitle = "The Wedding's of the Harlequin"
            };
            ComicPage p3 = new ComicPage {
                EntityId = 3L, ComicBookId = 2L, PageNumber = 2, Image = imgByteArr3, PageTitle = "Superwoman goes for a swim"
            };

            ComicBook b1 = new ComicBook {
                EntityId = 1L, Title = "Tin Tin's Adventure", Author = "Hergé", Genre = "Adventure", EditionNumber = 32, Description = "Description goes here"
            };
            ComicBook b2 = new ComicBook {
                EntityId = 2L, Title = "All American Comic", Author = "Frank", Genre = "Action", EditionNumber = 2, Description = "Different Description"
            };

            // Insert the seed data to MS SQL DB
            builder.Entity <User>().HasData(u1);
            builder.Entity <User>().HasData(u2);

            builder.Entity <ComicBook>().HasData(b1);
            builder.Entity <ComicBook>().HasData(b2);
            builder.Entity <ComicPage>().HasData(p1);
            builder.Entity <ComicPage>().HasData(p2);
            builder.Entity <ComicPage>().HasData(p3);
        }
Ejemplo n.º 17
0
        private void PrikaziFilmove(int stranica = 1)
        {
            for (int i = (stranica * 10) - 10, row = 0; i < stranica * 10; i++, row++)
            {
                var film = model.FilmoviList[i];
                var grid = new Grid();
                grid.AutomationId      = film.Id.ToString();
                grid.ColumnDefinitions = new ColumnDefinitionCollection {
                    new ColumnDefinition()
                };
                grid.RowDefinitions = new RowDefinitionCollection {
                    new RowDefinition {
                        Height = 150
                    }, new RowDefinition {
                        Height = 20
                    }, new RowDefinition {
                        Height = 20
                    }, new RowDefinition {
                        Height = 20
                    }
                };

                var img = new Image {
                    Source = ImageConvertor.ConvertByteArrayToImageForXamarin(film.Slika), HeightRequest = 150, WidthRequest = 150, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.Center
                };
                var imeFilma = new Label {
                    TextColor = Color.Black, FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, Text = "Naziv: " + film.Naziv, FontSize = 15
                };
                var zanrFilma = new Label {
                    FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, Text = "Žanr: " + model.ZanroviList.Where(w => w.Id == film.ZanrId).Select(s => s.NazivZanra).FirstOrDefault(), FontSize = 14
                };
                var tipFilma = new Label {
                    FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, Text = "Tip: " + model.TipoviList.Where(w => w.Id == film.TipId).Select(s => s.NazivTipa).FirstOrDefault(), FontSize = 14
                };

                grid.Children.Add(img, 0, 0);
                grid.Children.Add(imeFilma, 0, 1);
                grid.Children.Add(zanrFilma, 0, 2);
                grid.Children.Add(tipFilma, 0, 3);

                var tapR = new TapGestureRecognizer();
                tapR.Tapped += (sender, e) => {
                    Navigation.PushAsync(new FilmDetaljiPage(int.Parse(((Grid)sender).AutomationId)));
                };
                grid.GestureRecognizers.Add(tapR);

                filmoviGrid.Children.Add(grid, 0, row);
            }
        }
Ejemplo n.º 18
0
        public void UpdateReport(Report report, IFormFile reportimage, IFormFile reportfile)
        {
            if (reportimage != null && reportimage.IsImage())
            {
                if (report.ReportImageName != "ReportImg.jpg")
                {
                    string deleteimagepath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Report/ReportIMG", report.ReportImageName);
                    if (File.Exists(deleteimagepath))
                    {
                        File.Delete(deleteimagepath);
                    }
                    string deletethumbpath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Report/thumb", report.ReportImageName);
                    if (File.Exists(deletethumbpath))
                    {
                        File.Delete(deletethumbpath);
                    }
                }
                report.ReportImageName = NameGenerator.GenerateUniqCode() + Path.GetExtension(reportimage.FileName);
                string reportimgpath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Report/ReportIMG", report.ReportImageName);

                using (var stream = new FileStream(reportimgpath, FileMode.Create))
                {
                    reportimage.CopyTo(stream);
                }

                ImageConvertor imgresizer = new ImageConvertor();
                string         thumbpath  = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Report/thumb", report.ReportImageName);
                imgresizer.Image_resize(reportimgpath, thumbpath, 250);
            }
            if (reportfile != null)
            {
                if (report.ReportFileName != null)
                {
                    string deletefilepath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Report/File", report.ReportFileName);
                    if (File.Exists(deletefilepath))
                    {
                        File.Delete(deletefilepath);
                    }
                }
                report.ReportFileName = NameGenerator.GenerateUniqCode() + Path.GetExtension(reportfile.FileName);
                string reportfilepath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Report/File", report.ReportFileName);
                using (var stream = new FileStream(reportfilepath, FileMode.Create))
                {
                    reportfile.CopyTo(stream);
                }
            }
            _context.Reports.Update(report);
            _context.SaveChanges();
        }
        private void IUD()
        {
            ImageConvertor objImageConvertor = new ImageConvertor();

            GetGender();
            string        sql = "exec [SMS].[IUDStudentDetails]";
            List <string> lst = new List <string>();

            this.Picture = string.Empty;
            lst.Add(IUDFlag);
            lst.Add(StudentID);
            lst.Add(EnrollmentNo);
            lst.Add(FirstName);
            lst.Add(MiddleName);
            lst.Add(LastName);
            lst.Add(Surname);
            lst.Add(DateOfBirth.ToString("yyyyMMdd"));
            lst.Add(DateOfAdmission.ToString("yyyyMMdd"));
            lst.Add(Gender);
            lst.Add(Address);
            lst.Add(MobileNumber);
            lst.Add(EmergencyContactNo1);
            lst.Add(EmergencyContactNo2);
            lst.Add(MotherName);
            lst.Add(SelectedOccupationMother.StaticID.ToString());
            lst.Add(FatherName);
            lst.Add(SelectedOccupationFather.StaticID.ToString());
            lst.Add(EmailAddress);
            lst.Add(Nationality);
            lst.Add(Caste);
            lst.Add(SelectedReligion.StaticID.ToString());
            lst.Add(LeavingDate.ToString("yyyyMMdd"));
            lst.Add(PreviousSchool);
            lst.Add(Picture);
            lst.Add(Age);
            lst.Add(PhotoID);
            lst.Add(Schoolid);
            DataTable dtResult = DAL.Select(sql, lst);

            if (dtResult != null && dtResult.Rows.Count > 0)
            {
                this.StudentID = dtResult.Rows[0][0].ToString();
                IUDStudentClassMapping();
                IUDDocumentMapping();
                MessageBox.Show("Data Saved Successfully");
                ClearFormField();
                GetStudentAsyn();
            }
        }
Ejemplo n.º 20
0
        public FileContentResult GetImage50(int?Id)
        {
            Image img = _repo.Images
                        .FirstOrDefault(g => g.Id == Id);

            if (img != null)
            {
                return(File(ImageConvertor.ScaleImage(img.ImageData, 50, 50), img.ImageMimeType));
            }
            else
            {
                Image img1 = _repo.Images.First(x => x.Id == 1);
                return(File(ImageConvertor.ScaleImage(img1.ImageData, 75, 50), img1.ImageMimeType));
            }
        }
Ejemplo n.º 21
0
        public IActionResult Edit(DetailsUserViewModel model)
        {
            if (!ModelState.IsValid)
            {
                if (model.Id != null)
                {
                    model.ImageSource = ImageConvertor.ConvertToImage(
                        this.userService
                        .UserImage(model.Id));

                    return(View("Index", model));
                }

                return(BadRequest());
            }

            byte[] image = new byte[GlobalConstants.MaximumImageSize];

            if (model.Image != null)
            {
                image = ImageConvertor.ConvertToBytes(model.Image);
            }
            else
            {
                image = this.userService.UserImage(model.Id);
            }


            this.userService.Edit(
                model.Id,
                model.FirstName,
                model.LastName,
                model.PhoneNumber,
                model.Profession,
                model.FacebookUrlAddress,
                model.Description,
                image);

            StatusMessage = MessageConstants.ProfileChanged;

            if (User.IsInRole(GlobalConstants.AdministratorRole) && this.userManager.GetUserId(User) != model.Id)
            {
                return(Redirect("/admin/home/"));
            }

            return(RedirectToAction("Index", model));
        }
Ejemplo n.º 22
0
        public IActionResult Details(string id)
        {
            var user = this.userService.Details(id);

            if (user == null)
            {
                throw new ApplicationException($"Unable to load user with ID '{id}'.");
            }

            var userView = mapper.Map <DetailsUserViewModel>(user);

            userView.ImageSource = ImageConvertor.ConvertToImage(userView.UserPhoto);

            userView.StatusMessage = StatusMessage;

            return(View(userView));
        }
        private void IUD()
        {
            ImageConvertor objImageConvertor = new ImageConvertor();

            GetGender();
            string        sql = "exec [SMS].[IUDStaffDetails]";
            List <string> lst = new List <string>();
            Dictionary <string, string> dict = new Dictionary <string, string>();

            dict.Add("StaffID", StaffID);
            dict.Add("Name", Name);
            dict.Add("EmailAddress", EmailAddress);
            dict.Add("UserID", UserID);
            SetPassWord();
            dict.Add("Password", this.Password);
            dict.Add("ContactNumber", ContactNumber);
            dict.Add("Address", Address);
            dict.Add("Designation", Designation);
            dict.Add("Subjects", Subjects);
            dict.Add("DateOfJoining", DateOfJoining.ToString("yyyyMMdd"));
            dict.Add("DateofLeaving", DateofLeaving.ToString("yyyyMMdd"));
            dict.Add("DateOfBirth", string.Empty);
            dict.Add("Gender", Gender);
            dict.Add("Picture", Picture);
            dict.Add("PhotoID", PhotoID);
            dict.Add("IUDFlag", IUDFlag);
            dict.Add("SchoolID", Schoolid);

            int result = DAL.Execute(sql, dict);

            sql  = "exec [dbo].[IUDdboUsers] ";
            lst  = new List <string>();
            dict = new Dictionary <string, string>();
            dict.Add("Name", Name);
            dict.Add("UserID", UserID);
            dict.Add("Password", this.Password);
            dict.Add("IUDFlag", IUDFlag);
            result += DAL.Execute(sql, dict);


            if (result > 1)
            {
                MessageBox.Show("Data Saved Successfully");
                ClearFormField();
            }
        }
 void GetImageTempate()
 {
     try
     {
         string       ImageTemplatePath = ConfigurationSettings.AppSettings["ImageTemplatePath"].ToString();
         StreamReader sr  = new StreamReader(ImageTemplatePath);
         string       str = sr.ReadToEnd();
         sr.Dispose();
         ImageConvertor objImageConvertor = new ImageConvertor();
         byte[]         bytearr           = Convert.FromBase64String(str);
         objImageConvertor.ConvertByteArrayToPhot(bytearr);
         this.ImageSource = objImageConvertor.ImageSource;
     }
     catch (Exception ex)
     {
         DAL.logger.Log(ex.Message + Environment.NewLine + ex.StackTrace, MessageType.Error);
     }
 }
Ejemplo n.º 25
0
        public ComicPageViewModel(ComicPageModel comic)
        {
            PageTitle  = comic.PageTitle;
            PageNumber = comic.PageNumber;
            ComicBook  = comic.ComicBook;
            ComicTitle = ComicBook.Title;
            WebcomicId = comic.ComicBookId;
            Image      = ImageConvertor.ConvertByteArrayToImage(comic.Image);
            AltText    = $"{PageNumber}. {PageTitle}";

            //In case the author is getting fancy by skipping page numbers or something, we can't
            //just get the next and previous page numbers by adding/subtracting 1 from PageNumber;
            //we have to actually look up the page number of the next/previous page.
            //First page number, too, for that matter.
            _allPages = (List <ComicPageModel>)ComicBook.ComicPages;
            int _currentIndex = _allPages.IndexOf(comic);

            FirstPageNumber = _allPages[0].PageNumber;
            //We'll check in the Controller to make sure there's at least one comic; if not, the user
            //will be directed to the About page and will never have the opportunity to click this
            //dead link.

            if (_currentIndex < (_allPages.Count - 1))
            {
                NextPageNumber = _allPages[_currentIndex + 1].PageNumber;
            }
            else
            {
                NextPageNumber = 0;
            }                             //sends to default page (Latest)

            if (_currentIndex > 0)
            {
                PreviousPageNumber = _allPages[_currentIndex - 1].PageNumber;
            }
            else
            {
                PreviousPageNumber = _allPages[0].PageNumber;
            }                                                       //sends to first page

            _randIndex       = (new Random()).Next(0, (ComicBook.ComicPages.Count - 1));
            RandomPageNumber = _allPages[_randIndex].PageNumber;
        }
Ejemplo n.º 26
0
        public async Task <IActionResult> Create([Bind("ProjectId,ProjectName,FounderId,CategoryId,ShortDescription,FullDescription,RisksAndChallenges,Background,StartBudget,StartDate")] Project project, IFormFile image)
        {
            if (ModelState.IsValid)
            {
                Project create = project;
                if (image != null && image.Length > 0)

                {
                    create.Photo = ImageConvertor.ConvertImageToBytes(image);
                }
                create.FounderId = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value.ToString();
                _unitOfWork.AddProject(create);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Categories, "CategoryId", "CategoryId", project.CategoryId);
            return(View(project));
        }
Ejemplo n.º 27
0
        public async Task <IActionResult> Create([Bind("ArticleId,Name,Briefly,Description")] Article project, IFormFile image)
        {
            if (ModelState.IsValid)
            {
                Article create = project;

                if (image != null && image.Length > 0)
                {
                    create.Photo = ImageConvertor.ConvertImageToBytes(image);
                }
                create.UserId = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value.ToString();

                _service.Add(create);

                ViewBag.Ok = "Article successfully saved";
                return(View(create));
            }
            return(View());
        }
Ejemplo n.º 28
0
        public async Task <IActionResult> CreateNewTopic(TopicViewModel topicView)
        {
            if (Request.Form.Files.Count != 1)
            {
                ModelState.AddModelError("Image", "image cannot be empty");
            }
            else
            {
                topicView.TopicPicture = ImageConvertor.ConvertImageToBytes(Request.Form.Files[0]);
            }

            if (ModelState.IsValid)
            {
                var mappedTopic = mapper.Map <TopicDTO>(topicView);
                await topicService.CreateTopic(mappedTopic);

                return(RedirectToAction(nameof(Panel)));
            }
            return(View(topicView));
        }
Ejemplo n.º 29
0
        /// <summary>
        ///
        /// </summary>
        public override void OnStart()
        {
            Camera.Main.Position = Vector2.Zero;

            //检查资源文件数量
            Resource.Init();
            Debug.Log("查找目录Resouce,资源数量:" + Resource.Name_Path.Keys.Count);
            //开启贴图转换器 GDI渲染可用,使用贴图文件代替原字符显示
            ImageConvertor.Init();

            //创建角色
            SRPGAgent wizardAgent = GameObject.CreateWith <SRPGAgent>();

            wizardAgent.LocalPosition = new Vector2(12, 12);
            //创建系统监视器
            SystemUIFactroy.GetSystemInspector(new Vector2(28, 13));
            //创建迷宫地图
            var maze = MazeGeneration.GetMaze(21, 21, new RenderPoint("■", Color.White, Config.DefaultBackColor, (int)Layer.Environment));

            maze.Position = new Vector2(5, 5);
        }
Ejemplo n.º 30
0
        private async Task AddButtonsToList(int count)
        {
            Button[] btns = new Button[count];
            ImageGV.Items.Clear();
            my_images = new MyImageBytes[count];
            my_images = await WriteReadVideoModel.ReadImageBytes();

            for (int i = 0; i < count; i++)
            {
                btns[i]      = new Button();
                btns[i].Name = "Btn " + i;
                // StackPanel stack = new StackPanel();
                //stack.Children.Add()
                btns[i].BorderBrush = new SolidColorBrush(Windows.UI.Colors.White);
                // btns[i].Background = new SolidColorBrush(Windows.UI.Color.FromArgb(50, 0, 0, 0));
                btns[i].BorderThickness = new Thickness(2);
                //добавляем грид в btn
                Grid newGrid = new Grid();
                btns[i].Content = newGrid;
                newGrid.Margin  = new Thickness(0, 0, 0, 0);



                //Добавим элемент Image в первый столбец элемента newGrid.
                Image newImage = new Image()
                {
                    Width = 100, Height = 100
                };
                newGrid.Children.Add(newImage);
                BitmapImage image = await ImageConvertor.ByteArrayToImage(my_images[i].Bytes);

                newImage.Source  = image;
                newImage.Stretch = Stretch.Fill;
                newImage.Margin  = new Thickness(0);


                //btns[i].Click += Btn_Click;
                ImageGV.Items.Add(btns[i]);
            }
        }
Ejemplo n.º 31
0
 void Awake()
 {
     _imageConvertor = new ImageConvertor(160, 120);
     _timer = 0;
     _heightWidthRatio = 120f/160f;
 }