Example #1
0
        public async Task <ActionResult> GetGroupOwner(int groupId, int studentId)
        {
            var result = await _repository.GetGroupOwner(groupId, studentId);

            result.Student.ProfilePicturePath = FileManagerService.LoadImageFromFile(result.Student.ProfilePicturePath);
            return(Ok(result));
        }
Example #2
0
        public async Task <IActionResult> EditImage(IndexViewData data)
        {
            var fileUploadResponse = new DefaultServiceResponse();

            var viewModel = new IndexViewData();

            if (data.FormFileData != null)
            {
                var customerData = await UserManager.GetUserAsync(User);

                if (customerData != null)
                {
                    fileUploadResponse = await FileManagerService.LoadFileToTheServer(data.FormFileData, customerData.Id);
                }

                if (fileUploadResponse.ValidationErrors != null)
                {
                    foreach (var error in fileUploadResponse.ValidationErrors)
                    {
                        ModelState.AddModelError("", error);
                    }
                }

                viewModel.PathToTheInputImage = Path.Combine("../", "CustomersImages",
                                                             Path.GetFileName(fileUploadResponse.ResponseData.ToString()));

                Logger.LogInformation($"Path to the input image, uploaded by the customer - {viewModel.PathToTheInputImage}");
            }
            else
            {
                ModelState.AddModelError("", "In order to edit photo, you should first provide it");
            }

            return(View(viewModel));
        }
Example #3
0
        public async Task <ActionResult> CreateStudent([FromBody] StudentRegisterDTO newStudent)
        {
            newStudent.Password = AuthentificationService.EncryptPassword(newStudent.Password);
            string base64Image = newStudent.Student.ProfilePicturePath;

            if (!string.IsNullOrEmpty(base64Image))
            {
                string imageFileId = await _sharedRepository.GetNextImageId();

                newStudent.Student.ProfilePicturePath = FileManagerService.SaveImageToFile(base64Image, imageFileId);
            }

            if (await _repository.CreateNonExistingStudent(newStudent))
            {
                StudentDTO student = await _repository.StudentExists(newStudent.Student.Email);

                student.Student.ProfilePicturePath = base64Image;
                string token = JwtManager.GenerateJWToken(student.Student, student.Id.ToString());
                return(Ok(new JsonResult(token)));
            }
            else
            {
                return(Ok(new JsonResult("Email taken")));
            }
        }
Example #4
0
        private static void InitServices()
        {
            var fileManagerService = new FileManagerService();

            ServiceLocator.Register <IFileManagerService>(fileManagerService);
            ServiceLocator.Register <IMeasurerService>(new MeasureService(fileManagerService));
        }
Example #5
0
        public async Task <ActionResult> GetSpecificStudent(int studentId, int requesterId)
        {
            StudentDTO student = await _repository.GetSpecificStudent(studentId, requesterId);

            student.Student.ProfilePicturePath = FileManagerService.LoadImageFromFile(student.Student.ProfilePicturePath);
            return(Ok(student));
        }
Example #6
0
        public async Task <ActionResult> GetGroupStatistics(int groupId)
        {
            GroupStatisticsDTO result = await _repository.GetGroupStatistics(groupId);

            result.Group.GroupPicturePath = FileManagerService.LoadImageFromFile(result.Group.GroupPicturePath);
            return(Ok(result));
        }
Example #7
0
        protected override async void OnStart(string[] args)
        {
            try
            {
                OptionsManager manager = new OptionsManager(@"E:\LR5\DataManagerService\bin\Release\AppSettings.xml");
                dataManagerOptions = await manager.GetOptionsAsync <DataManagerOptions>();

                errorDb  = new Database(dataManagerOptions.ErrorConnectionString);
                personDb = new Database(dataManagerOptions.ConnectionString);
                var persons = await personDb.GetPersonsAsync(dataManagerOptions.SearchCriteria);

                XmlXsdGenerator <Person> generator = new XmlXsdGenerator <Person>(persons);
                var xmlString = generator.GenerateXml();
                var xsdString = generator.GenerateXsd();

                FileManagerService filemanager = new FileManagerService();
                await filemanager.LaunchAsync();

                FileSender sender = new FileSender(dataManagerOptions.FtpSourceFolder);
                await sender.SendAsync(xmlString, xsdString);
            }
            catch (Exception e)
            {
                await errorDb.LogErrorAsync(new Error(e.Message, e.Source, e.StackTrace, DateTime.Now));
            }
        }
Example #8
0
        public async Task <ActionResult> Index2()
        {
            int sliderTake = GetSettingValueInt("HomePageSliderImages_ItemsNumber", StoreConstants.DefaultPageSize);

            var       pageDesignTask = PageDesignService.GetPageDesignByName(StoreId, "HomePage");
            var       sliderTask     = FileManagerService.GetStoreCarouselsAsync(StoreId, sliderTake);
            Stopwatch stopwatch      = new Stopwatch();

            // Begin timing.
            stopwatch.Start();


            await Task.WhenAll(pageDesignTask, sliderTask);

            var settings = GetStoreSettings();


            var pageDesing   = pageDesignTask.Result;
            var sliderImages = sliderTask.Result;


            StoreLiquidResult liquidResult = ProductService2.GetHomePageDesign(pageDesing, sliderImages);

            liquidResult.PageTitle     = GetSettingValue("HomePage_Title", "");
            liquidResult.StoreSettings = settings;
            liquidResult.MyStore       = this.MyStore;

            // Stop timing.
            stopwatch.Stop();

            Logger.Info("Home:Index:Time elapsed: {0} elapsed milliseconds", stopwatch.ElapsedMilliseconds);
            return(View(liquidResult));
        }
Example #9
0
        public async Task <ActionResult> CreatePost(int groupId, int studentId, Post newPost)
        {
            PostDTO res = await _repository.CreatePost(groupId, studentId, newPost);

            res.Student.Student.ProfilePicturePath = FileManagerService.LoadImageFromFile(res.Student.Student.ProfilePicturePath);
            return(Ok(res));
        }
Example #10
0
        private void btSearch_Click(object sender, RoutedEventArgs e)
        {
            FileManagerService service  = new FileManagerService();
            List <MyFile>      mySearch = service.FindFile(tbName.Text.Trim());

            dtGrid.ItemsSource = mySearch;
        }
Example #11
0
        public async Task <ActionResult> DeleteGroup(int groupId)
        {
            string patha = await _repository.GetGroupImage(groupId);

            if (!string.IsNullOrEmpty(patha))
            {
                FileManagerService.DeleteFile(patha);
            }

            IEnumerable <string> paths = await _documentrepository.GetDocumentsPaths(groupId);

            if (paths != null)
            {
                foreach (string path in paths)
                {
                    if (!string.IsNullOrEmpty(path))
                    {
                        FileManagerService.DeleteFile(path);
                    }
                }
            }

            await _repository.DeleteGroup(groupId);

            return(Ok());
        }
Example #12
0
        /// <summary>
        /// Reference this in HTML as <img src="/Photo/WatermarkedImage/{ID}" />
        /// Simplistic example supporting only jpeg images.
        /// </summary>
        /// <param name="ID">Photo ID</param>
        public ActionResult WatermarkedImage(int id)
        {
            // Attempt to fetch the photo record from the database using Entity Framework 4.2.
            var file = FileManagerService.GetFilesById(id);

            if (file != null) // Found the indicated photo record.
            {
                var dic = new Dictionary <String, String>();
                // Create WebImage from photo data.
                // Should have 'using System.Web.Helpers' but just to make it clear...
                String url       = String.Format("https://docs.google.com/uc?id={0}", file.GoogleImageId);
                byte[] imageData = GeneralHelper.GetImageFromUrl(url, dic);
                var    wi        = new System.Web.Helpers.WebImage(imageData);

                // Apply the watermark.
                wi.AddTextWatermark("EMIN YUCE");

                // Extract byte array.
                var image = wi.GetBytes("image/jpeg");

                // Return byte array as jpeg.
                return(File(image, "image/jpeg"));
            }
            else // Did not find a record with passed ID.
            {
                return(null); // 'Missing image' icon will display on browser.
            }
        }
Example #13
0
        public void ImageUrl(int id, int width = 60, int height = 60)
        {
            //    var fileManagers = GetStoreImages();
            var images = FileManagerService.GetFilesById(id);  //fileManagers.FirstOrDefault(r => r.Id == id);

            if (images != null)
            {
                String url       = images.WebContentLink;
                var    dic       = new Dictionary <String, String>();
                byte[] imageData = GeneralHelper.GetImageFromUrlFromCache(url, dic);
                if (width > 0 && height > 0)
                {
                    float ratio = images.Width.ToFloat() / images.Height.ToFloat();
                    height = (int)(width * ratio);
                    new WebImage(imageData)
                    .Resize(width, height, false, true) // Resizing the image to 100x100 px on the fly...
                    .Crop(1, 1)                         // Cropping it to remove 1px border at top and left sides (bug in WebImage)
                    .Write();
                }
                else
                {
                    new WebImage(imageData)
                    .Crop(1, 1)     // Cropping it to remove 1px border at top and left sides (bug in WebImage)
                    .Write();
                }
            }
        }
Example #14
0
        public async Task <ActionResult> getGroupImage(int groupId)
        {
            string path = await _repository.GetGroupImage(groupId);

            path = FileManagerService.LoadImageFromFile(path);
            return(Ok(new { image = path }));
        }
Example #15
0
        public async Task <ActionResult> GetFilteredGroups([FromQuery] string name, [FromQuery] string field, [FromQuery] bool orderByName, [FromQuery] bool descending, [FromQuery] int from, [FromQuery] int to, [FromQuery] int user)
        {
            string userFilter = "not (s)-[:MEMBER|:OWNER]->(g) and ID(s) = " + user;
            string where1     = (string.IsNullOrEmpty(name) ? "" : ("g.Name =~\"(?i).*" + name + ".*\""));
            string where2     = (string.IsNullOrEmpty(field) ? "" : ("g.Field =~ \"(?i).*" + field + ".*\""));

            string where = "";
            if (!string.IsNullOrEmpty(where1) && !string.IsNullOrEmpty(where2))
            {
                where += where1 + " AND " + where2;
            }
            else if (!string.IsNullOrEmpty(where1))
            {
                where += where1;
            }
            else if (!string.IsNullOrEmpty(where2))
            {
                where += where2;
            }

            string order = orderByName ? "g.Name" : "ID(g)";

            IEnumerable <GroupDTO> groups;

            groups = await _repository.GetGroupsPage(where, userFilter, order, descending, from, to);

            foreach (GroupDTO g in groups)
            {
                g.Group.GroupPicturePath = FileManagerService.LoadImageFromFile(g.Group.GroupPicturePath);
            }
            return(Ok(new JsonResult(groups)));
        }
Example #16
0
        protected override void OnStart(string[] args)
        {
            try
            {
                OptionsManager manager = new OptionsManager(@"D:\Lab4\DataManagerService\bin\Release\AppSettings.xml");
                dataManagerOptions = manager.GetOptions <DataManagerOptions>();

                errorDb  = new Database(dataManagerOptions.ErrorConnectionString);
                personDb = new Database(dataManagerOptions.ConnectionString);
                var persons = personDb.GetPersons(dataManagerOptions.SearchCriteria);

                XmlXsdGenerator <Person> generator = new XmlXsdGenerator <Person>(persons);
                var xmlString = generator.GenerateXml();
                var xsdString = generator.GenerateXsd();

                FileManagerService fileManager = new FileManagerService();
                fileManager.Launch();

                FileTransfer sender = new FileTransfer(dataManagerOptions.FtpSourceFolder);
                sender.Send(xmlString, xsdString);
            }
            catch (Exception ex)
            {
                Error error = new Error(ex.Source, ex.Message, ex.StackTrace, DateTime.Now);
                errorDb.LogError(error);
            }
        }
Example #17
0
        public async Task <IActionResult> ModifyPhoto(IndexViewData data)
        {
            if (!string.IsNullOrEmpty(data.PathToTheInputImage))
            {
                var customerData = await UserManager.GetUserAsync(User);

                var fileResponse = await FileManagerService.ModifyFile(new ModifyModel {
                    UserId            = customerData.Id,
                    OutputFileType    = data.SelectedResponseFileFormat,
                    SelectedOperation = data.SelectedFileOperation,
                    Intesivity        = data.Intensity,
                    UseFrame          = data.UseFrame
                });

                Logger.LogInformation($"Path to the result image, uploaded by the customer - {fileResponse.ResponseData.ToString()}");

                return(View("EditImage", new IndexViewData()
                {
                    PathToTheInputImage = "../" + data.PathToTheInputImage,
                    PathToTheResultImage = fileResponse.ResponseData.ToString()
                }));
            }
            else
            {
                ModelState.AddModelError("", "In order to edit photo, you should first provide it");

                return(View("EditImage", new IndexViewData()));
            }
        }
Example #18
0
        public async Task <IActionResult> CreateComment(int postId, int studentId, Comment newComment)
        {
            CommentDTO res = await _repository.CreateComment(postId, studentId, newComment);

            res.Student.Student.ProfilePicturePath = FileManagerService.LoadImageFromFile(res.Student.Student.ProfilePicturePath);
            return(Ok(res));
        }
Example #19
0
 public DataAccess_Sql(ApplicationDbContext context,
                       FileManagerService fmService,
                       NotificationDbContext notificationCtx)
 {
     _notificationCtx = notificationCtx;
     _fmService       = fmService;
     _context         = context;
 }
Example #20
0
 public DbActionsController(ApplicationDbContext context,
                            FileManagerService fmService,
                            IDataAccess data)
 {
     _data      = data;
     _context   = context;
     _fmService = fmService;
 }
Example #21
0
        public async Task <ActionResult> Index()
        {
            int blogsTake    = GetSettingValueInt("HomePageMainBlogsContents_ItemsNumber", StoreConstants.DefaultPageSize);
            int newsTake     = GetSettingValueInt("HomePageMainNewsContents_ItemsNumber", StoreConstants.DefaultPageSize);
            int productsTake = GetSettingValueInt("HomePageMainProductsContents_ItemsNumber", StoreConstants.DefaultPageSize);
            int sliderTake   = GetSettingValueInt("HomePageSliderImages_ItemsNumber", StoreConstants.DefaultPageSize);


            int?   categoryId = null;
            String key        = String.Format("Home:Index-{0}-{1}-{2}-{3}-{4}", StoreId, blogsTake, newsTake,
                                              productsTake, sliderTake);

            var pageDesignTask        = PageDesignService.GetPageDesignByName(StoreId, "HomePageWithMainData");
            var blogsTask             = ContentService.GetMainPageContentsAsync(StoreId, categoryId, StoreConstants.BlogsType, blogsTake);
            var newsTask              = ContentService.GetMainPageContentsAsync(StoreId, categoryId, StoreConstants.NewsType, newsTake);
            var productsTask          = ProductService.GetMainPageProductsAsync(StoreId, productsTake);
            var sliderTask            = FileManagerService.GetStoreCarouselsAsync(StoreId, sliderTake);
            var categoriesTask        = CategoryService.GetCategoriesByStoreIdAsync(StoreId, "", true);
            var productCategoriesTask = ProductCategoryService.GetProductCategoriesByStoreIdAsync(StoreId, StoreConstants.ProductType, true);

            // Create new stopwatch.
            Stopwatch stopwatch = new Stopwatch();

            // Begin timing.
            stopwatch.Start();



            await Task.WhenAll(productsTask, blogsTask, newsTask, pageDesignTask, sliderTask, categoriesTask,
                               productCategoriesTask);

            var settings = GetStoreSettings();

            HomePageHelper.StoreId       = this.StoreId;
            HomePageHelper.StoreSettings = settings;

            var products          = productsTask.Result;
            var blogs             = blogsTask.Result;
            var news              = newsTask.Result;
            var pageDesing        = pageDesignTask.Result;
            var sliderImages      = sliderTask.Result;
            var categories        = categoriesTask.Result;
            var productCategories = productCategoriesTask.Result;

            StoreLiquidResult liquidResult = HomePageHelper.GetHomePageDesign(pageDesing, sliderImages, products, blogs,
                                                                              news, categories, productCategories);

            liquidResult.PageTitle     = GetSettingValue("HomePage_Title", "");
            liquidResult.StoreSettings = settings;
            liquidResult.MyStore       = this.MyStore;


            // Stop timing.
            stopwatch.Stop();

            Logger.Info("Home:Index:Time elapsed: {0} elapsed milliseconds", stopwatch.ElapsedMilliseconds);
            return(View(liquidResult));
        }
Example #22
0
        public async Task <ActionResult> CreateGroup(int ownerId, Group newGroup)
        {
            string imageFileId = await _sharedRepository.GetNextImageId();

            newGroup.GroupPicturePath = FileManagerService.SaveImageToFile(newGroup.GroupPicturePath, imageFileId);
            await _repository.CreateGroup(ownerId, newGroup);

            return(Ok());
        }
Example #23
0
 public FileController(FileManagerService service,
                       IDataAccess data, UserService userService,
                       DesafioService desafioService)
 {
     _data           = data;
     _fileManager    = service;
     _userService    = userService;
     _desafioService = desafioService;
 }
Example #24
0
 public HomeController(ILogger <HomeController> logger, IWebHostEnvironment webHostEnv, IHtmlsToEpub getEpub, FileManagerService fileManagerService)
 {
     _logger             = logger;
     _webHostEnvironment = webHostEnv;
     _getEpub            = getEpub;
     //_downloadRoot = $@"{_webHostEnvironment.ContentRootPath}\Downloads\";
     _downloadRoot       = Path.Combine(_webHostEnvironment.ContentRootPath, "Downloads");
     _fileManagerService = fileManagerService;
 }
Example #25
0
        public async Task<ActionResult> CreateDocument(int studentId, int groupId,  Document newDocument)
        {
            string documentFileId = await _sharedRepository.GetNextDocumentId();
            newDocument.DocumentPath = FileManagerService.SaveDocumentToFile(newDocument.DocumentPath, documentFileId);
            await _repository.CreateDocument(studentId, newDocument);
            await _repository.RelateDocumentAndGroup(groupId, newDocument.DocumentPath);

            return Ok(newDocument);
        }
Example #26
0
        public async Task <ActionResult> GetAllComments(int postId)
        {
            IEnumerable <CommentDTO> result = await _repository.GetAllComments(postId);

            foreach (CommentDTO item in result)
            {
                item.Student.Student.ProfilePicturePath = FileManagerService.LoadImageFromFile(item.Student.Student.ProfilePicturePath);
            }
            return(Ok(result));
        }
Example #27
0
        public async Task <ActionResult> GetMyOwnerships(int studentId)
        {
            var result = await _repository.GetOwnerships(studentId);

            foreach (GroupDTO g in result)
            {
                g.Group.GroupPicturePath = FileManagerService.LoadImageFromFile(g.Group.GroupPicturePath);
            }
            return(Ok(result));
        }
Example #28
0
        public async Task <ActionResult> GetStudentGroups(int studentId)
        {
            IEnumerable <GroupDTO> result = await _repository.GetStudentGroups(studentId);

            foreach (GroupDTO res in result)
            {
                res.Group.GroupPicturePath = FileManagerService.LoadImageFromFile(res.Group.GroupPicturePath);
            }
            return(Ok(result));
        }
Example #29
0
        public async Task <ActionResult> PictureListNewsEdit(string newsId, [FromBody] PictureNewsEditDTO editValue)
        {
            if (!string.IsNullOrEmpty(editValue.Picture))
            {
                editValue.Picture = FileManagerService.SaveImageToFile(editValue.Picture, "mainPicture" + newsId);
            }
            await _repository.EditNews(newsId, editValue);

            return(Ok());
        }
Example #30
0
        public ActionResult Index(int page = 1)
        {
            var photos = new PhotosViewModel();

            photos.SStore = this.MyStore;
            var m = FileManagerService.GetImagesByStoreId(MyStore.Id, page, 24);

            photos.SFileManagers = new PagedList <FileManager>(m.items, m.page - 1, m.pageSize, m.totalItemCount);
            return(View(photos));
        }