示例#1
0
 public void Initialize()
 {
     if (_filesHelper == null)
     {
         _filesHelper = new FilesHelper();
     }
 }
示例#2
0
 public void CleanUp()
 {
     if (_filesHelper != null)
     {
         _filesHelper.CleanUp();
         _filesHelper = null;
     }
 }
示例#3
0
        //public ActionResult Create([Bind(Include = "FlowerId,Description,Price,LastPurchase,Image,IsActive,Observation")] Flower flower)
        public ActionResult Create(FlowerView view)
        {
            if (ModelState.IsValid)
            {
                var pic    = string.Empty;
                var folder = "~/Content/Images";

                if (view.ImageFile != null)
                {
                    pic = FilesHelper.UploadPhoto(view.ImageFile, folder);
                    pic = string.Format("{0}/{1}", folder, pic);
                }
                var flower = ToFlower(view);
                flower.Image = pic;
                //db.Flowers.Add(flower);
                db.Flowers.Add(flower);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(view));
            // return View(flower);
        }
示例#4
0
        public ActionResult Edit(Driver driver)
        {
            if (ModelState.IsValid)
            {
                var pic    = string.Empty;
                var folder = "~/Content/Logos";

                if (driver.FixedPhoneFile != null)
                {
                    pic = FilesHelper.UploadPhoto(driver.FixedPhoneFile, folder);
                    pic = string.Format("{0}/{1}", folder, pic);
                    driver.FixedPhone = pic;
                }
                db.Entry(driver).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CarId        = new SelectList(CombosHelper.GetCars(), "CarId", "Plate", driver.CarId);
            ViewBag.CityId       = new SelectList(CombosHelper.GetCities(), "CityId", "Name", driver.CityId);
            ViewBag.DepartmentId = new SelectList(CombosHelper.GetDepartments(), "DepartmentId", "Name", driver.DepartmentId);
            return(View(driver));
        }
示例#5
0
        public async Task <ActionResult> Create(TeamView view)
        {
            if (ModelState.IsValid)
            {
                var pic    = string.Empty;
                var folder = "~/Content/Logos";

                if (view.LogoFile != null)
                {
                    pic = FilesHelper.UploadPhoto(view.LogoFile, folder);
                    pic = string.Format("{0}/{1}", folder, pic);
                }

                var team = ToTeam(view);
                team.Logo = pic;
                db.Teams.Add(team);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.LeagueId = new SelectList(db.Leagues, "LeagueId", "Name", view.LeagueId);
            return(View(view));
        }
示例#6
0
        public async Task <ActionResult> Edit(LeagueView view)
        {
            if (ModelState.IsValid)
            {
                var pic    = view.Logo;
                var folder = "~/Content/Leagues";

                if (view.LogoFile != null)
                {
                    pic = FilesHelper.UploadPhoto(view.LogoFile, folder);
                    pic = string.Format("{0}/{1}", folder, pic);
                }

                var league = ToLeague(view);
                league.Logo            = pic;
                db.Entry(league).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(view));
        }
示例#7
0
        private void btnSummary_Click(object sender, EventArgs e)
        {
            string strSov = FilesHelper.ReadJsonFile("Sovereignty\\Map");
            List <JOSovereignty> joSov = JsonConvert.DeserializeObject <List <JOSovereignty> >(strSov);


            List <JOSovereignty> lstNoHome = new List <JOSovereignty>();

            foreach (JOSovereignty sov in joSov)
            {
                if (sov.faction_id == 0 && sov.corporation_id == 0 && sov.alliance_id == 0)
                {
                    lstNoHome.Add(sov);
                }
            }
            string strResult = string.Empty;

            foreach (JOSovereignty sov in lstNoHome)
            {
                strResult += sov.system_name + " > " + sov.constellation_name + " > " + sov.region_name + "\n";
            }
            MessageBox.Show(strResult);
        }
示例#8
0
        /// <summary>
        /// Get files to compare.
        /// </summary>
        /// <param name="type">Files type</param>
        /// <returns>
        /// Pairs of files to compare <see cref="IEnumerable"/>.
        /// </returns>
        private static IEnumerable <TestCaseData> FindFiles(FileType type)
        {
            Logger.Info("Get Files {0}:", type);
            var liveFiles = FilesHelper.GetFilesOfGivenType(ProjectBaseConfiguration.DownloadFolderPath, type, "live");

            if (liveFiles != null)
            {
                foreach (FileInfo liveFile in liveFiles)
                {
                    Logger.Trace("liveFile: {0}", liveFile);

                    var fileNameBranch = liveFile.Name.Replace("live", "branch");
                    var testCaseName   = liveFile.Name.Replace("_" + "live", string.Empty);

                    TestCaseData data = new TestCaseData(liveFile.Name, fileNameBranch);
                    data.SetName(Regex.Replace(testCaseName, @"[.]+|\s+", "_"));

                    Logger.Trace("file Name Short: {0}", testCaseName);

                    yield return(data);
                }
            }
        }
        public async Task <ActionResult> Create(TournamentView view)
        {
            if (ModelState.IsValid)
            {
                var pic    = string.Empty;
                var folder = "~/Content/Logos";

                if (view.LogoFile != null)
                {
                    pic = FilesHelper.UploadPhoto(view.LogoFile, folder);
                    pic = $"{folder}/{pic}";
                }
                view.Logo = pic;
                var tournament = GetTournoment(view);

                db.Tournaments.Add(tournament);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(view));
        }
        public async Task <ActionResult> Edit(TournamentView view)
        {
            if (ModelState.IsValid)
            {
                var pic    = view.Logo;
                var folder = "~/Content/Logos";

                if (view.LogoFile != null)
                {
                    pic = FilesHelper.UploadPhoto(view.LogoFile, folder);
                    pic = $"{folder}/{pic}";
                }
                view.Logo = pic;

                var tournament = GetTournoment(view);

                db.Entry(tournament).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(view));
        }
        public async Task <ActionResult> Edit(ProductoVista producto)
        {
            if (ModelState.IsValid)
            {
                var pic    = producto.Foto;
                var folder = "~/Content/ImagenesProductos";

                if (producto.fotoFile != null)
                {
                    pic = FilesHelper.UploadPhoto(producto.fotoFile, folder);
                    pic = $"{folder}/{pic}";
                }

                var productos = this.ToProducto(producto, pic);

                db.Entry(productos).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.Categoria_idCategoria = new SelectList(db.Categoria, "idCategoria", "tipoCategoria", producto.Categoria_idCategoria);
            return(View(producto));
        }
        public ActionResult Create(
            //[Bind(Include = "FlowerId,Description,Price,LastPurchase,Image,IsActive,Observation")]
            FlowerView view)
        {
            if (ModelState.IsValid)
            {
                var pic    = string.Empty;
                var folder = "~/Content/Images";

                if (view.ImageFile != null)
                {
                    pic = FilesHelper.UploadPhoto(view.ImageFile, folder);
                    pic = string.Format("{0}/{1}", folder, pic);
                }
                var flower = ToFlower(view);
                flower.Image = pic;
                db.Flowers.Add(flower);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(view));
        }
        public ActionResult Edit(TemaConhecimento temaConhecimento)
        {
            if (ModelState.IsValid)
            {
                if (temaConhecimento.LogoFile != null)
                {
                    var pic    = string.Empty;
                    var folder = "~/Content/Imagens/ImagensTemaConhecimento";
                    var file   = string.Format("{0}.jpg", temaConhecimento.IDTema);

                    var response = FilesHelper.UploadPhoto(temaConhecimento.LogoFile, folder, string.Format("{0}.jpg", temaConhecimento.IDTema));
                    if (response)
                    {
                        pic = string.Format("{0}/{1}", folder, file);
                        temaConhecimento.Logo = pic;
                    }
                }

                temaConhecimentoBusiness.Alterar(temaConhecimento);
                return(RedirectToAction("Index"));
            }
            return(View(temaConhecimento));
        }
示例#14
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            var user = await db.Users.FindAsync(id);

            //  CHEJ - Captura la ruta de la imagen
            var imagePath = Server.MapPath(Url.Content(user.ImagePath));

            db.Users.Remove(user);
            response = await DbHelper.SaveChangeDB(db);

            if (response.IsSuccess)
            {
                //  CHEJ - Elimina el archivo fisico
                if (FilesHelper.ExistFile(imagePath))
                {
                    response = FilesHelper.DeleteFile(imagePath);
                }
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError(string.Empty, response.Message);
            return(View(user));
        }
示例#15
0
        public async Task <ActionResult> Create(TeamView view)
        {
            if (ModelState.IsValid)
            {
                var pic    = string.Empty;
                var folder = "~/Content/Teams";

                if (view.ImageFile != null)
                {
                    pic = FilesHelper.UploadPhoto(view.ImageFile, folder);
                    pic = string.Format("{0}/{1}", folder, pic);
                }

                var team = this.ToTeam(view);
                team.ImagePath = pic;
                db.Teams.Add(team);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(view));
        }
        public async override void OnAppearing()
        {
            base.OnAppearing();

            try
            {
                using var stream = await File.OpenReadAsync();

                var name = (string.IsNullOrWhiteSpace(File.NameWithoutExtension)
                    ? Guid.NewGuid().ToString()
                    : File.NameWithoutExtension)
                           + $".{File.Extension}";

                Path = await FilesHelper.SaveToCacheAsync(stream, name);

                stream.Position = 0;
                await ReadMeta(stream);
            }
            catch (Exception ex)
            {
                await DisplayAlertAsync(ex.Message);
            }
        }
        public async Task <ActionResult> Edit(EmployeeView view)
        {
            if (ModelState.IsValid)
            {
                var pic    = view.PicturePath;
                var folder = "~/Content/Photos";

                if (view.PictureFile != null)
                {
                    pic = FilesHelper.UploadFile(view.PictureFile, folder);
                    pic = $"{folder}/{pic}";
                }

                var employee = this.ToEmployee(view, pic);
                db.Entry(employee).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.CityId = new SelectList(db.Cities.OrderBy(c => c.Name), "CityId", "Name", view.CityId);
            return(View(view));
        }
        public async Task <ActionResult> Create(LeagueView view)
        {
            if (ModelState.IsValid)
            {
                var pic    = string.Empty;
                var folder = "~/Content/Leagues";

                if (view.LogoLFile != null)
                {
                    pic = FilesHelper.UploadPhoto(view.LogoLFile, folder, "");
                    pic = string.Format("{0}/{1}", folder, pic);
                }

                var league = ToLeague(view);
                league.Logo = pic;
                _db.Leagues.Add(league);
                await _db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(view));
        }
示例#19
0
        public async Task <string> UploadFiles(IFormFile layoutfile, IFormFile cameraDatafile, string projectName)
        {
            string directorypath = AppContext.BaseDirectory + "ProjectFiles" + "\\" + projectName;

            try
            {
                var directory = FilesHelper.IsExistDirectory(directorypath);

                if (false == directory)
                {
                    FilesHelper.CreateDir(directorypath);
                }
                FilesHelper.CreateFile(directorypath + "\\" + layoutfile.FileName, layoutfile.GetAllBytes());
                FilesHelper.CreateFile(directorypath + "\\" + cameraDatafile.FileName, cameraDatafile.GetAllBytes());
            }
            catch (Exception)
            {
                return("上传失败");
            }


            return("ok");
        }
示例#20
0
        public async Task <ActionResult> Edit(ProductView view)
        {
            if (ModelState.IsValid)
            {
                var pic    = view.Image;
                var folder = "~/Content/Images";

                if (view.ImageFile != null)
                {
                    pic = FilesHelper.UploadPhoto(view.ImageFile, folder);
                    pic = string.Format("{0}/{1}", folder, pic);
                }

                var product = ToProduct(view);
                product.Image           = pic;
                db.Entry(product).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "Description", view.CategoryId);
            return(View(view));
        }
示例#21
0
        // PUT: api/Usuarios/5
        public Usuario Put(int id, [FromBody] Usuario value)
        {
            //var path = Path.Combine(HttpContext.Current.Server.MapPath("foede"), "name");
            UsuarioService servicio = new UsuarioService(cadenaConexion);

            //subir iagen
            if (value.ImageArray != null && value.ImageArray.Length > 0)
            {
                var stream   = new MemoryStream(value.ImageArray);
                var guid     = Guid.NewGuid().ToString();
                var file     = $"{guid}.jpg";
                var folder   = "~/Content/Usuarios";
                var fullPath = $"{folder}/{file}";
                var response = FilesHelper.UploadPhoto(stream, folder, file);

                if (response)
                {
                    value.ImagePath = file;
                }
            }

            return(servicio.PutUsuario(id, value));
        }
示例#22
0
        public ActionResult Edit(Category category)
        {
            if (ModelState.IsValid)
            {
                if (category.ImageFile != null)
                {
                    var folder   = "~/Content/Categories";
                    var file     = string.Format("{0}.jpg", category.CategoryId);
                    var response = FilesHelper.UploadPhoto(category.ImageFile, folder, file);
                    if (response)
                    {
                        var pic = string.Format("{0}/{1}", folder, file);
                        category.Image           = pic;
                        db.Entry(category).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                }

                return(RedirectToAction("Index"));
            }
            ViewBag.CompanyId = new SelectList(db.Companies, "CompanyId", "Name", category.CompanyId);
            return(View(category));
        }
示例#23
0
        public async Task <ActionResult> CreateTeam(TeamView view)
        {
            if (ModelState.IsValid)
            {
                var pic    = string.Empty;
                var folder = "~/Content/Teams";

                if (view.LogoFile != null)
                {
                    pic = FilesHelper.UploadPhoto(view.LogoFile, folder);
                    pic = string.Format("{0}/{1}", folder, pic);
                }

                var team = ToTeam(view);
                team.Logo = pic;
                db.Teams.Add(team);
                await db.SaveChangesAsync();

                return(RedirectToAction(string.Format("Details/{0}", view.LeagueId)));
            }

            return(View(view));
        }
示例#24
0
        public async Task <ActionResult> CreateGroup(GroupView view)
        {
            if (ModelState.IsValid)
            {
                var pic    = string.Empty;
                var folder = "~/Content/Groups";

                if (view.LogoFile != null)
                {
                    pic = FilesHelper.UploadPhoto(view.LogoFile, folder);
                    pic = string.Format("{0}/{1}", folder, pic);
                }

                var group = ToGroup(view);
                group.Logo = pic;
                db.Groups.Add(group);
                await db.SaveChangesAsync();

                return(RedirectToAction(string.Format("Details/{0}", view.OwnerId)));
            }

            return(View(view));
        }
示例#25
0
        public async Task <ActionResult> Create(ProductView view)
        {
            if (ModelState.IsValid)
            {
                var pic    = string.Empty;
                var folder = "~/Content/Products";

                if (view.ImageFile != null)
                {
                    pic = FilesHelper.UploadPhoto(view.ImageFile, folder);
                    pic = $"{folder}/{pic}";
                }

                var product = this.ToProduct(view, pic);

                db.Products.Add(product);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(view));
        }
示例#26
0
        public async Task <ActionResult> Create(PlanView planView)
        {
            if (ModelState.IsValid)
            {
                var pic    = string.Empty;
                var folder = "~/Content/Plans";

                if (planView.ImageFile != null)
                {
                    pic = FilesHelper.UploadPhoto(planView.ImageFile, folder);
                    pic = $"{folder}/{pic}";
                }

                var plan = planView.ToPlan(pic);

                db.Plans.Add(plan);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(planView));
        }
示例#27
0
        private void UpdateSampleFile(Drive drive, DriveItem newFile, String filePath)
        {
            FilesHelper.RenameFile(drive.Id, newFile.Id, "SP2016-MinRoles.jpg");

            Stream memPhoto = getFileContent(filePath);

            try
            {
                if (memPhoto.Length > 0)
                {
                    String contentType = "image/jpeg";
                    FilesHelper.UpdateFileContent(
                        drive.Id,
                        newFile.Id,
                        memPhoto,
                        contentType);
                }
            }
            catch (Exception ex)
            {
                // Handle the exception
            }
        }
示例#28
0
        public async Task <ActionResult> Edit(ProductView view)
        {
            if (ModelState.IsValid)
            {
                var pic    = view.ImagePath;
                var folder = "~/Content/Products";

                if (view.ImageFile != null)
                {
                    pic = FilesHelper.UploadPhoto(view.ImageFile, folder);
                    //SE puede formatear de las 2 siguientes maneras
                    //pic = string.Format("{0}/{1}", folder, pic);
                    pic = $"{folder}/{pic}";
                }

                var product = this.ToProduct(view, pic);
                this.db.Entry(product).State = EntityState.Modified;
                await this.db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(view));
        }
示例#29
0
        public ActionResult Edit(Instructor instructor)
        {
            if (ModelState.IsValid)
            {
                var pic    = string.Empty;
                var folder = "~/Content/Photos";
                if (instructor.PhotoFile != null)
                {
                    pic = FilesHelper.UploadPhoto(instructor.PhotoFile, folder);
                    pic = string.Format("{0}/{1}", folder, pic);
                    instructor.image = pic;
                }


                db.Entry(instructor).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.id_Bonding    = new SelectList(db.Bondings, "id_Bonding", "Type_Linkage", instructor.id_Bonding);
            ViewBag.id_Document   = new SelectList(db.Documents, "id_Document", "typeDocument", instructor.id_Document);
            ViewBag.id_Speciality = new SelectList(db.Specialities, "id_Speciality", "speciality_Name", instructor.id_Speciality);
            return(View(instructor));
        }
示例#30
0
        public void OnProtoSerialize(ProtobufSerializer serializer)
        {
            PrefabIdentifier id = GetComponentInParent <PrefabIdentifier>();

            if (id == null)
            {
                if ((id = GetComponent <PrefabIdentifier>()) == null)
                {
                    return;
                }
            }

            if (this.gameObject != null)
            {
                string saveFolder = FilesHelper.GetSaveFolderPath();
                if (!Directory.Exists(saveFolder))
                {
                    Directory.CreateDirectory(saveFolder);
                }

                GameObject  model    = this.gameObject.FindChild("Model");
                BoxCollider collider = this.gameObject.GetComponent <BoxCollider>();
                if (model != null && collider != null)
                {
                    string size = Convert.ToString(model.transform.localScale.x, CultureInfo.InvariantCulture) + "/" +
                                  Convert.ToString(model.transform.localScale.y, CultureInfo.InvariantCulture) + "/" +
                                  Convert.ToString(model.transform.localScale.z, CultureInfo.InvariantCulture);

                    size += Environment.NewLine +
                            Convert.ToString(collider.size.x, CultureInfo.InvariantCulture) + "/" +
                            Convert.ToString(collider.size.y, CultureInfo.InvariantCulture) + "/" +
                            Convert.ToString(collider.size.z, CultureInfo.InvariantCulture);

                    File.WriteAllText(FilesHelper.Combine(saveFolder, "warperspecimen_" + id.Id + ".txt"), size, Encoding.UTF8);
                }
            }
        }
示例#31
0
        public async Task <IHttpActionResult> PutUser(int id, User user)
        {
            if (user.ImageArray != null && user.ImageArray.Length > 0)
            {
                var stream   = new MemoryStream(user.ImageArray);
                var guid     = Guid.NewGuid().ToString();
                var file     = string.Format("{0}.jpg", guid);
                var folder   = "~/Content/Images";
                var fullPath = string.Format("{0}/{1}", folder, file);
                var response = FilesHelper.UploadPhoto(stream, folder, file);

                if (response)
                {
                    user.ImagePath = fullPath;
                }
            }

            db.Entry(user).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(user));
        }
示例#32
0
 public ActionResult Create(News news)
 {
     if (ModelState.IsValid)
     {
         db.News.Add(news);
         db.SaveChanges();
         if (news.LogoFile != null)
         {
             var pic      = string.Empty;
             var folder   = "~/Photos";
             var file     = string.Format("{0}.png", news.NewsId);
             var response = FilesHelper.UploadPhoto(news.LogoFile, folder, file);
             if (response)
             {
                 pic        = string.Format("{0}/{1}", folder, file);
                 news.Photo = pic;
             }
         }
         if (news.CapaFile != null)
         {
             var pic      = string.Empty;
             var folder   = "~/Cover";
             var file     = string.Format("{0}.jpg", news.NewsId);
             var response = FilesHelper.UploadPhoto(news.CapaFile, folder, file);
             if (response)
             {
                 pic       = string.Format("{0}/{1}", folder, file);
                 news.Capa = pic;
             }
         }
         db.Entry(news).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "Name", news.CategoryId);
     return(View(news));
 }