/// <summary>
        /// Enregistre ou met a jour un evenement
        /// </summary>
        public void Save()
        {
            if (this.Id == Guid.Empty)
            {
                this.Metier.Id = Guid.NewGuid();
                this.Metier.ImageEvenement.Id   = Guid.NewGuid();
                this.Metier.AdresseEvenement.Id = Guid.NewGuid();

                using (ParkingContext context = new ParkingContext())
                {
                    ServiceAdresse.Insert(this.Metier.AdresseEvenement, context);
                    ServiceImage.Insert(this.Metier.ImageEvenement, context);

                    string query = "https://maps.googleapis.com/maps/api/geocode/json?address=" + this.Metier.AdresseEvenement.ToString() + "&key=AIzaSyCyoqbqJVd_MtZRT_0DmYmznxxJWRfMjQI";

                    using (WebClient wc = new WebClient())
                    {
                        var json = wc.DownloadString(query);
                        RootObjectGoogle item = JsonConvert.DeserializeObject <RootObjectGoogle>(json);
                        if (item != null)
                        {
                            this.Metier.AdresseEvenement.lat = item.results.FirstOrDefault().geometry.location.lat;
                            this.Metier.AdresseEvenement.lng = item.results.FirstOrDefault().geometry.location.lng;
                        }
                    }

                    ServiceEvenement.Insert(this.Metier, context);
                    context.SaveChanges();
                }
            }
            else
            {
                ServiceEvenement.Update(this.Metier);
            }
        }
Пример #2
0
 public ImageController()
 {
     _imageService    = new ServiceImage();
     _auditLogService = new ServiceAuditLog();
     _userId          = Convert.ToInt32(((ClaimsIdentity)User.Identity).Claims.Where(c => c.Type == "user_id")
                                        .Select(c => c.Value).SingleOrDefault());
 }
Пример #3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            //Upload Photo
            var filename = Guid.NewGuid().ToString() + Path.GetExtension(ServiceImage.FileName);
            var file     = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "images", "service-images", filename);

            using (var fileStream = new FileStream(file, FileMode.Create))
            {
                await ServiceImage.CopyToAsync(fileStream);
            }
            Service.Photo = filename;
            //Default values
            Service.DateCreated = DateTime.Now;
            Service.Status      = "Pending";
            Service.Votes       = 0;
            var currentUser = await _userManager.GetUserAsync(User);

            Service.CreatedBy = currentUser;
            _context.Service.Add(Service);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
        public JsonResult Save([FromBody] ServiceImage model)
        {
            ActionsResult result;

            result = ApiHelper <ActionsResult> .HttpPostAsync($"{Helper.ApiUrl}api/serviceimages/save", model);

            return(Json(new { result }));
        }
Пример #5
0
 public CarController()
 {
     myService          = new ServiceCar();
     serviceSubCategory = new ServiceSubCategory();
     serviceCarModel    = new ServiceCarModel();
     serviceCreation    = new ServiceCreationYear();
     serviceType        = new ServiceTypeCar();
     serviceImage       = new ServiceImage();
     serviceRating      = new ServiceRating();
 }
Пример #6
0
        public async Task <ActionResult> Edit([Bind(Include = "ServiceImageId,Title,FileName")] ServiceImage serviceImage, int SubServiceId, int CompanyServiceId)
        {
            if (ModelState.IsValid)
            {
                db.Entry(serviceImage).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index", new { id = SubServiceId, CompanyServiceId = CompanyServiceId }));
            }
            return(View(serviceImage));
        }
        private async void BtnCamara_Click(object sender, System.EventArgs e)
        {
            MediaFile file = null;

            try
            {
                file = await ServiceImage.TakePicture(true);
            }
            catch (Android.OS.OperationCanceledException) { }
            SetImageControl(file);
            btnAnalizaFoto.Visibility = Android.Views.ViewStates.Visible;
        }
Пример #8
0
        private async void Fab_Click(object sender, EventArgs e)
        {
            MediaFile file = null;

            try
            {
                file = await ServiceImage.TakePicture(true);
            }
            catch (Android.OS.OperationCanceledException)
            {
            }
            SetImageToControl(file);
        }
Пример #9
0
        public async Task <ActionResult> Create([Bind(Include = "ServiceImageId,Title,FileName")] ServiceImage serviceImage, int SubServiceId, int CompanyServiceId)
        {
            if (ModelState.IsValid)
            {
                serviceImage.SubService = db.SubServices.Find(SubServiceId);
                db.ServiceImages.Add(serviceImage);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index", new { id = SubServiceId, CompanyServiceId = CompanyServiceId }));
            }

            return(View(serviceImage));
        }
Пример #10
0
        public async Task <ActionResult> DeleteConfirmed(int id, string deleteFileName, int SubServiceId, int CompanyServiceId)
        {
            //delete image file first
            PhotoFileManager manager = new PhotoFileManager(PhotoManagerType.Service);

            manager.Delete(deleteFileName, true);

            ServiceImage serviceImage = await db.ServiceImages.FindAsync(id);

            db.ServiceImages.Remove(serviceImage);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index", new { id = SubServiceId, CompanyServiceId = CompanyServiceId }));
        }
        public IActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            ServiceImage serviceImage = _db.ServiceImages.Find(id);

            if (serviceImage == null)
            {
                return(NotFound());
            }
            return(View(serviceImage));
        }
Пример #12
0
            public void Bind(IFeedback model)
            {
                if (CellContentRootView != null)
                {
                    CellContentRootView.Tag    = new { Model = model, Text = ServiceText, Image = ServiceImage };
                    CellContentRootView.Click -= CellContentRootView_Click;
                    CellContentRootView.Click += CellContentRootView_Click;

                    CellContentRootView.SetBackgroundColor(ColorConstants.TransparentColor);
                }

                if (ServiceText != null)
                {
                    ServiceText.Text = model.Name.ToUpperInvariant();
                    ServiceText.SetFont(FontsConstant.OpenSansBold, FontsConstant.Size12);

                    if (!FeedbackManager.Instance.LastService)
                    {
                        ServiceText.SetTextColor(ColorConstants.BackgroundGray);
                    }
                    else if (!model.Selected)
                    {
                        ServiceText.SetTextColor(ColorConstants.BackgroundGray);
                    }
                    else
                    {
                        ServiceText.SetTextColor(ColorConstants.SelectorHome);
                    }
                }

                if (ServiceImage == null)
                {
                    return;
                }
                ServiceImage.SetImageFromResource(model.ImagePath);

                if (!FeedbackManager.Instance.LastService)
                {
                    ServiceImage.SetImageColorFilter(ColorConstants.BackgroundGray);
                }
                else if (!model.Selected)
                {
                    ServiceImage.SetImageColorFilter(ColorConstants.BackgroundGray);
                }
                else
                {
                    ServiceImage.SetImageColorFilter(ColorConstants.SelectorHome);
                }
            }
Пример #13
0
        private async void AddPhoto()
        {
            try
            {
                var action = await App.Current.MainPage.DisplayActionSheet("Foto de perfil", "Cancelar", null, "Usar cámara", "Seleccionar de galería");

                bool camera = action.Contains("Usar cámara");
                var  file   = await ServiceImage.TakePicture(camera);

                await App.Current.MainPage.Navigation.PushAsync(new PreImageView(file), true);
            }catch (Exception ex)
            {
                var msgError = ex.Message;
            }
        }
Пример #14
0
        public bool CheckImageExists(int imageId)
        {
            //storage type is set to smb, get this current com server's storage
            var guid          = ConfigurationManager.AppSettings["ComServerUniqueId"];
            var thisComServer = new ServiceClientComServer().GetServerByGuid(guid);

            if (thisComServer == null)
            {
                log.Error($"Com Server With Guid {guid} Not Found");
                return(false);
            }

            var image = new ServiceImage().GetImage(imageId);

            var basePath = thisComServer.LocalStoragePath;

            if (string.IsNullOrEmpty(image.Name))
            {
                return(false);
            }


            var imagePath = Path.Combine(basePath, "images", image.Name);

            if (!Directory.Exists(imagePath))
            {
                return(false);
            }
            var guidPath = Path.Combine(imagePath, "guid");

            if (!File.Exists(guidPath))
            {
                return(false);
            }
            using (StreamReader reader = new StreamReader(guidPath))
            {
                var fileGuid = reader.ReadLine() ?? "";
                if (fileGuid.Equals(image.LastUploadGuid))
                {
                    return(true);
                }
            }


            return(false);
        }
Пример #15
0
        // GET: ServiceImages/Details/5
        public async Task <ActionResult> Details(int?id, int SubServiceId, int CompanyServiceId)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ServiceImage serviceImage = await db.ServiceImages.FindAsync(id);

            if (serviceImage == null)
            {
                return(HttpNotFound());
            }
            ViewBag.SubServiceId     = SubServiceId;
            ViewBag.CompanyServiceId = CompanyServiceId;
            ViewBag.ImageType        = PhotoManagerType.Service;
            ViewBag.ImageDirectory   = PhotoFileManager.StorageDirectoryDetection(PhotoManagerType.Service);
            return(View(serviceImage));
        }
        public async Task <IActionResult> DeletePost(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            ServiceImage serviceImage = _db.ServiceImages.Find(id);

            if (serviceImage == null)
            {
                return(NotFound());
            }
            Helper.DeleteImg(_env.WebRootPath, "img/services", serviceImage.Image);
            _db.ServiceImages.Remove(serviceImage);
            await _db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Пример #17
0
        async void btnPicture_Clicked(object sender, EventArgs e)
        {
            var useCam = ((Button)sender).Text.Contains("Cámara");
            var file   = await ServiceImage.TakePicture(useCam);

            Results.Children.Clear();
            lblResult.Text = "---";

            imgPicture.Source = ImageSource.FromStream(() =>
            {
                var stream     = file.GetStream();
                var streamCopy = new MemoryStream();
                stream.CopyTo(streamCopy);
                stream.Seek(0, SeekOrigin.Begin);
                file.Dispose();
                return(stream);
            });
        }
        public async Task <IActionResult> Create(ServiceImage image)
        {
            ServiceImage serviceImage = new ServiceImage()
            {
                Name = image.Name
            };

            if (image.Photo == null)
            {
                ModelState.AddModelError("", "Shekil sechin");
                return(View());
            }
            if (!image.Photo.IsImage())
            {
                ModelState.AddModelError("", "Shekil formatinda bir fayl sechin");
                return(View());
            }
            if (image.Photo.MaxLength(1400))
            {
                ModelState.AddModelError("", "Shekilin olchusu max 1400kb ola biler");
                return(View());
            }
            serviceImage.Image = await image.Photo.SaveImage(_env.WebRootPath, "img/services");

            string  aaaa          = Request.Form["services"];
            Service serviceImage1 = _db.Services.FirstOrDefault(s => s.Name.ToLower().Trim() == aaaa.ToLower().Trim());

            serviceImage.ServiceId = serviceImage1.Id;
            string b = Request.Form["ismain"];

            if (b.ToLower().Trim() == "main")
            {
                serviceImage.IsMain = true;
            }
            else
            {
                serviceImage.IsMain = false;
            }
            _db.ServiceImages.Add(serviceImage);
            await _db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Пример #19
0
        public async Task <IActionResult> Create(Service service)
        {
            if (User.Identity.IsAuthenticated && User.IsInRole("admin"))
            {
                if (!ModelState.IsValid)
                {
                    return(NotFound());
                }
                if (string.IsNullOrEmpty(service.Heading))
                {
                    ModelState.AddModelError("Heading", "Başlıq boş olmamalıdır");
                    return(View(service));
                }
                if (string.IsNullOrEmpty(service.CategoryName))
                {
                    ModelState.AddModelError("CategoryName", "Kateqoriya boş olmamalıdır");
                    return(View(service));
                }
                if (service.CategoryIcon == null)
                {
                    ModelState.AddModelError("CategoryIcon", "İkon boş olmamalıdır");
                    return(View(service));
                }
                if (!service.CategoryIcon.ContentType.Contains("image/"))
                {
                    ModelState.AddModelError("CategoryIcon", "Ikonun formatı düzgün deyil");
                    return(View(service));
                }
                if (service.CategoryImage == null)
                {
                    ModelState.AddModelError("CategoryImage", "Kateqoriya şəkli boş olmamalıdır");
                    return(View(service));
                }
                if (!service.CategoryImage.ContentType.Contains("image/"))
                {
                    ModelState.AddModelError("CategoryImage", "Kateqoriya şəklinin formatı düzgün deyil");
                    return(View(service));
                }
                if (service.DetailPhotos == null)
                {
                    ModelState.AddModelError("DetailPhotos", "Şəkillər boş olmamalıdır");
                    return(View(service));
                }
                await _context.services.AddAsync(service);

                foreach (var image in service.DetailPhotos)
                {
                    if (!image.ContentType.Contains("image/"))
                    {
                        ModelState.AddModelError("DetailPhotos", "Şəklin formatı düzgün deyil");
                        return(View(service));
                    }
                }

                service.CategoryIconUrl = await service.CategoryIcon.SavePhotoAsync(_env.WebRootPath, "serviceIcons");

                service.CategoryImageUrl = await service.CategoryImage.SavePhotoAsync(_env.WebRootPath, "serviceCategories");

                foreach (var image in service.DetailPhotos)
                {
                    ServiceImage serviceImage = new ServiceImage
                    {
                        ServiceId = service.Id,
                        ImageUrl  = await image.SavePhotoAsync(_env.WebRootPath, "service")
                    };
                    await _context.serviceImages.AddAsync(serviceImage);
                }
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(Redirect("/egmedia_admin/login"));
            }
        }
        public async Task <IActionResult> Edit(int?id, ServiceCRUDvm serviceCRU)
        {
            if (id == null)
            {
                return(View());
            }
            ServiceImage image = _db.ServiceImages.Find(id);

            if (image == null)
            {
                return(NotFound());
            }
            if (serviceCRU.ServiceImage.Photo != null)
            {
                if (!serviceCRU.ServiceImage.Photo.IsImage())
                {
                    ModelState.AddModelError("", "Shekil formatinda bir fayl sechin");
                    return(View());
                }
                if (serviceCRU.ServiceImage.Photo.MaxLength(1400))
                {
                    ModelState.AddModelError("", "Shekilin olchusu max 1400kb ola biler");
                    return(View());
                }
                Helper.DeleteImg(_env.WebRootPath, "img/services", image.Image);
                image.Image = await serviceCRU.ServiceImage.Photo.SaveImage(_env.WebRootPath, "img/services");

                string  aaaa          = Request.Form["services"];
                Service serviceImage1 = _db.Services.FirstOrDefault(s => s.Name.ToLower().Trim() == aaaa.ToLower().Trim());
                image.ServiceId = serviceImage1.Id;
                string b = Request.Form["ismain"];
                if (b.ToLower().Trim() == "main")
                {
                    image.IsMain = true;
                }
                else
                {
                    image.IsMain = false;
                }
                await _db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            else
            {
                string  aaaa          = Request.Form["services"];
                Service serviceImage1 = _db.Services.FirstOrDefault(s => s.Name.ToLower().Trim() == aaaa.ToLower().Trim());
                image.ServiceId = serviceImage1.Id;
                string b = Request.Form["ismain"];
                if (b.ToLower().Trim() == "main")
                {
                    image.IsMain = true;
                }
                else
                {
                    image.IsMain = false;
                }
                await _db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
        }
Пример #21
0
        public async Task <IActionResult> Update(Service service)
        {
            if (User.Identity.IsAuthenticated && User.IsInRole("admin"))
            {
                if (!ModelState.IsValid)
                {
                    return(NotFound());
                }
                if (string.IsNullOrEmpty(service.Heading))
                {
                    ModelState.AddModelError("Heading", "Başlıq boş olmamalıdır");
                    return(View(service));
                }
                if (string.IsNullOrEmpty(service.CategoryName))
                {
                    ModelState.AddModelError("CategoryName", "Kateqoriya boş olmamalıdır");
                    return(View(service));
                }
                Service service_from_db = await _context.services.FindAsync(service.Id);

                if (service.CategoryIcon != null)
                {
                    if (!service.CategoryIcon.ContentType.Contains("image/"))
                    {
                        ModelState.AddModelError("CategoryIcon", "Ikonun formatı düzgün deyil");
                        return(View(service));
                    }
                    else
                    {
                        RemovePhoto(_env.WebRootPath, service_from_db.CategoryIconUrl);
                        service_from_db.CategoryIconUrl = await service.CategoryIcon.SavePhotoAsync(_env.WebRootPath, "serviceIcons");
                    }
                }
                if (service.CategoryImage != null)
                {
                    if (!service.CategoryImage.ContentType.Contains("image/"))
                    {
                        ModelState.AddModelError("CategoryImage", "Kateqoriya şəklinin formatı düzgün deyil");
                        return(View(service));
                    }
                    else
                    {
                        RemovePhoto(_env.WebRootPath, service_from_db.CategoryImageUrl);
                        service_from_db.CategoryImageUrl = await service.CategoryImage.SavePhotoAsync(_env.WebRootPath, "serviceCategories");
                    }
                }
                if (service.DetailPhotos != null)
                {
                    foreach (var image in service.DetailPhotos)
                    {
                        if (!image.ContentType.Contains("image/"))
                        {
                            ModelState.AddModelError("DetailPhotos", "Şəklin formatı düzgün deyil");
                            return(View(service));
                        }
                    }
                    foreach (var image in _context.serviceImages.Where(i => i.ServiceId == service.Id))
                    {
                        RemovePhoto(_env.WebRootPath, image.ImageUrl);
                        _context.serviceImages.Remove(image);
                    }
                    foreach (var image in service.DetailPhotos)
                    {
                        ServiceImage serviceImage = new ServiceImage
                        {
                            ServiceId = service.Id,
                            ImageUrl  = await image.SavePhotoAsync(_env.WebRootPath, "service")
                        };
                        await _context.serviceImages.AddAsync(serviceImage);
                    }
                }
                service_from_db.CategoryName = service.CategoryName;
                service_from_db.Heading      = service.Heading;
                service_from_db.Content      = service.Content;
                service_from_db.Status       = service.Status;
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(Redirect("/egmedia_admin/login"));
            }
        }
Пример #22
0
        public async Task <CommandResult <PostServiceViewModel> > ExecuteAsync(PostServiceViewModel vm)
        {
            var userId   = _httpContext.HttpContext.User.Identity.Name;
            var userName = _userManager.FindByIdAsync(userId).Result.UserName;

            try
            {
                var getPermissionForService = await IsOwnService(Guid.Parse(vm.Id));

                if (getPermissionForService.isValid || await _checkUserIsAdminQuery.ExecuteAsync(userId) ||
                    await _getPermissionActionQuery.ExecuteAsync(userId, ConstantFunctions.SERVICE, ActionSetting.CanUpdate))
                {
                    var currentService = getPermissionForService.myModel;
                    var service        = await _serviceRepository.FindByIdAsync(Guid.Parse(vm.Id));

                    if (service == null)
                    {
                        return(new CommandResult <PostServiceViewModel>
                        {
                            isValid = false,
                            errorMessage = ErrorMessageConstant.ERROR_CANNOT_FIND_ID
                        });
                    }
                    List <Tag> newTag    = new List <Tag>();
                    var        tagDelete = await RemoveTag(Guid.Parse(vm.Id), vm.tagofServices);

                    foreach (var item in vm.tagofServices)
                    {
                        if (item.isAdd == true)
                        {
                            newTag.Add(new Tag
                            {
                                TagName = item.TagName
                            });
                        }
                    }
                    //Update Image
                    List <ServiceImage> lstService = new List <ServiceImage>();
                    foreach (var item in vm.listImages)
                    {
                        if (item.ImageId == 0)
                        {
                            ServiceImage serviceImage = new ServiceImage()
                            {
                                DateCreated = DateTime.Now,
                                Path        = item.Path,
                                isAvatar    = item.IsAvatar,
                                ServiceId   = Guid.Parse(vm.Id)
                            };
                            lstService.Add(serviceImage);
                        }
                        else
                        {
                            var imageId = await _serviceImageRepository.FindByIdAsync(item.ImageId);

                            if (imageId != null)
                            {
                                imageId.isAvatar     = item.IsAvatar;
                                imageId.DateModified = DateTime.Now;
                                _serviceImageRepository.Update(imageId);
                            }
                        }
                    }
                    var deletImage = await RemoveImage(Guid.Parse(vm.Id), vm.listImages);

                    _serviceImageRepository.RemoveMultiple(deletImage);
                    await _tagServiceRepository.Add(newTag);

                    _tagServiceRepository.RemoveMultiple(tagDelete);
                    var mappingService = await MappingService(vm, service, userId);

                    mappingService.TagServices = null;
                    foreach (var tag in newTag)
                    {
                        Model.Entities.ServiceModel.TagService mappingTag = new Model.Entities.ServiceModel.TagService();
                        mappingTag.TagId     = tag.Id;
                        mappingTag.ServiceId = Guid.Parse(vm.Id);
                        await _serviceOfTagRepository.Add(mappingTag);
                    }

                    _serviceRepository.Update(mappingService);
                    await _serviceRepository.SaveAsync();

                    //Cotentemail
                    var findEmailUser = await GetEmailUserAsync(mappingService);

                    if (findEmailUser != ErrorMessageConstant.ERROR_CANNOT_FIND_ID)
                    {
                        //Set content for email
                        //Get All email
                        var getAllEmail = await _getAllEmailServiceQuery.ExecuteAsync();

                        var getFirstEmail = getAllEmail.Where(x => x.Name == EmailName.Approve_Service).FirstOrDefault();

                        var generateCode = _configuration.GetSection("Host").GetSection("LinkConfirmService").Value +
                                           mappingService.codeConfirm + '_' + mappingService.Id;

                        getFirstEmail.Message = getFirstEmail.Message.
                                                Replace(EmailKey.ServiceNameKey, mappingService.ServiceName).
                                                Replace(EmailKey.UserNameKey, findEmailUser).
                                                Replace(EmailKey.ConfirmLink, generateCode);
                        ContentEmail(_configEmail.Value.SendGridKey, getFirstEmail.Subject,
                                     getFirstEmail.Message, findEmailUser).Wait();
                    }
                    else
                    {
                        await Logging <UpdatePostServiceCommand> .
                        WarningAsync(ActionCommand.COMMAND_APPROVE, userName, "Cannot find email user");

                        return(new CommandResult <PostServiceViewModel>
                        {
                            isValid = false,
                            errorMessage = "Cannot find email user"
                        });
                    }
                    await Logging <UpdatePostServiceCommand> .
                    InformationAsync(ActionCommand.COMMAND_UPDATE, userName, JsonConvert.SerializeObject(vm));

                    return(new CommandResult <PostServiceViewModel>
                    {
                        isValid = true,
                    });
                }
                await Logging <UpdatePostServiceCommand> .
                WarningAsync(ActionCommand.COMMAND_UPDATE, userName, ErrorMessageConstant.ERROR_UPDATE_PERMISSION);

                return(new CommandResult <PostServiceViewModel>
                {
                    isValid = false,
                    errorMessage = ErrorMessageConstant.ERROR_UPDATE_PERMISSION
                });
            }
            catch (System.Exception ex)
            {
                await Logging <UpdatePostServiceCommand> .
                ErrorAsync(ex, ActionCommand.COMMAND_UPDATE, userName, "Has error");

                return(new CommandResult <PostServiceViewModel>
                {
                    isValid = false,
                    errorMessage = ex.InnerException.ToString()
                });
            }
        }
Пример #23
0
        public bool SyncToCom(List <int> imageIds)
        {
            if (!ServiceSetting.GetSettingValue(SettingStrings.StorageType).Equals("SMB"))
            {
                return(true);
            }

            var guid          = ConfigurationManager.AppSettings["ComServerUniqueId"];
            var thisComServer = new ServiceClientComServer().GetServerByGuid(guid);

            if (thisComServer == null)
            {
                Logger.Error($"Com Server With Guid {guid} Not Found");
                return(false);
            }


            using (var unc = new UncServices())
            {
                if (unc.NetUseWithCredentials() || unc.LastError == 1219)
                {
                    foreach (var imageId in imageIds)
                    {
                        var image = new ServiceImage().GetImage(imageId);
                        if (string.IsNullOrEmpty(image.Name))
                        {
                            continue;
                        }
                        var sourcePath = Path.Combine(ServiceSetting.GetSettingValue(SettingStrings.StoragePath), "images", image.Name);
                        var destPath   = Path.Combine(thisComServer.LocalStoragePath, "images", image.Name).TrimEnd('\\');

                        using (RoboCommand backup = new RoboCommand())
                        {
                            // events

                            /*backup.OnFileProcessed += backup_OnFileProcessed;
                             * backup.OnCommandCompleted += backup_OnCommandCompleted;
                             * backup.OnCopyProgressChanged += Backup_OnCopyProgressChanged;
                             */
                            backup.OnError += Backup_OnError;
                            // copy options
                            backup.CopyOptions.Source             = sourcePath;
                            backup.CopyOptions.Destination        = destPath;
                            backup.CopyOptions.CopySubdirectories = true;
                            backup.SelectionOptions.IncludeSame   = true;
                            backup.CopyOptions.UseUnbufferedIo    = true;
                            if (thisComServer.ReplicationRateIpg != 0)
                            {
                                backup.CopyOptions.InterPacketGap = thisComServer.ReplicationRateIpg;
                            }
                            else
                            {
                                backup.CopyOptions.InterPacketGap = 0;
                            }
                            // select options
                            backup.CopyOptions.Mirror           = true;
                            backup.CopyOptions.Purge            = true;
                            backup.LoggingOptions.VerboseOutput = false;

                            backup.SelectionOptions.ExcludeFiles = "guid";
                            // retry options
                            backup.RetryOptions.RetryCount    = 3;
                            backup.RetryOptions.RetryWaitTime = 60;

                            backup.Start().Wait();
                            if (backup.Results.Status.ExitCodeValue == 0 || backup.Results.Status.ExitCodeValue == 1)
                            {
                                //backup succesful, copy the guid now
                                try
                                {
                                    var guidPath = Path.Combine(sourcePath, "guid");
                                    File.Copy(guidPath, destPath + Path.DirectorySeparatorChar + "guid");
                                }
                                catch (Exception ex)
                                {
                                    Logger.Error(ex.Message);
                                    Logger.Error("Could Not Replicate Image " + image.Name);
                                }
                            }
                        }
                    }
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #24
0
            public void Bind(IFeedback model)
            {
                CellContentRootView?.SetBackgroundColor(ColorConstants.TransparentColor, 4);

                if (ServiceText != null)
                {
                    ServiceText.Text = "";
                    ServiceText.SetTextColor(ColorConstants.WhiteColor);
                    ServiceText.SetFont(FontsConstant.OpenSansRegular, FontsConstant.Size12);
                }

                if (Service2Text != null)
                {
                    Service2Text.Text = model.NameCategory;
                    Service2Text.SetTextColor(ColorConstants.WhiteColor);
                    Service2Text.SetFont(FontsConstant.OpenSansBold, FontsConstant.Size12);
                }

                if (FeedbackStatus != null)
                {
                    FeedbackStatus.SetFont(FontsConstant.OpenSansBold, FontsConstant.Size18);
                    FeedbackStatus.SetTextColor(ColorConstants.WhiteColor);
                }

                if (FeedbackVotes != null)
                {
                    FeedbackVotes.Text = "";
                    FeedbackVotes.SetTextColor(ColorConstants.BackgroundGray);
                    FeedbackVotes.SetFont(FontsConstant.OpenSansRegular, FontsConstant.Size12);
                }

                ServiceImage?.SetImageFromResource(model.ImagePathCategory);
                ProgressView?.SetBackgroundColor(ColorConstants.WhiteColor.SelectorTransparence(ColorConstants.Procent20), 5);

                if (model.Rating == 0)
                {
                    ResetView();

                    FeedbackStatus.Text = RFeedback.TerribleText.ToUpperInvariant();
                    ImageStatus?.SetImageFromResource(FeedbackManager.Instance.GetItem().ElementAtOrDefault(0).ImagePath);
                }
                else if (model.Rating <= 20)
                {
                    FeedbackStatus.Text = RFeedback.TerribleText.ToUpperInvariant();
                    ImageStatus?.SetImageFromResource(FeedbackManager.Instance.GetItem().ElementAtOrDefault(0).ImagePath);
                    ProgressView20?.SetBackgroundColor(ColorConstants.SelectorHome, 5);

                    ProgressView20.Visibility = ViewState.Visible;
                    ProgressView40.Visibility = ViewState.Invisible;
                    ProgressView60.Visibility = ViewState.Invisible;
                    ProgressView80.Visibility = ViewState.Invisible;
                }
                else if (model.Rating <= 40)
                {
                    FeedbackStatus.Text = RFeedback.BadText.ToUpperInvariant();
                    ImageStatus?.SetImageFromResource(FeedbackManager.Instance.GetItem().ElementAtOrDefault(1).ImagePath);
                    ProgressView40?.SetBackgroundColor(ColorConstants.SelectorHome, 5);

                    ProgressView40.Visibility = ViewState.Visible;
                    ProgressView20.Visibility = ViewState.Invisible;
                    ProgressView60.Visibility = ViewState.Invisible;
                    ProgressView80.Visibility = ViewState.Invisible;
                }
                else if (model.Rating <= 60)
                {
                    FeedbackStatus.Text = RFeedback.OkayText.ToUpperInvariant();
                    ImageStatus?.SetImageFromResource(FeedbackManager.Instance.GetItem().ElementAtOrDefault(2).ImagePath);
                    ProgressView60?.SetBackgroundColor(ColorConstants.SelectorHome, 5);

                    ProgressView60.Visibility = ViewState.Visible;
                    ProgressView40.Visibility = ViewState.Invisible;
                    ProgressView20.Visibility = ViewState.Invisible;
                    ProgressView80.Visibility = ViewState.Invisible;
                }
                else if (model.Rating <= 80)
                {
                    FeedbackStatus.Text = RFeedback.GoodText.ToUpperInvariant();
                    ImageStatus?.SetImageFromResource(FeedbackManager.Instance.GetItem().ElementAtOrDefault(3).ImagePath);
                    ProgressView80?.SetBackgroundColor(ColorConstants.SelectorHome, 5);

                    ProgressView80.Visibility = ViewState.Visible;
                    ProgressView60.Visibility = ViewState.Invisible;
                    ProgressView40.Visibility = ViewState.Invisible;
                    ProgressView20.Visibility = ViewState.Invisible;
                }
                else if (model.Rating == 100)
                {
                    FeedbackStatus.Text = RFeedback.GreatText.ToUpperInvariant();
                    ImageStatus?.SetImageFromResource(FeedbackManager.Instance.GetItem().ElementAtOrDefault(4).ImagePath);
                    ProgressView?.SetBackgroundColor(ColorConstants.SelectorHome, 5);

                    ResetView();
                }

                ImageStatus?.SetImageColorFilter(ColorConstants.WhiteColor.SelectorTransparence(ColorConstants.Procent84));
            }