Exemplo n.º 1
0
        public async Task <IActionResult> ImageDetail(ImageDetail model, long?Id)
        {
            var user = await GetCurrentUserAsync();

            if (user != null)
            {
                var role = await _userManager.GetRolesAsync(user);

                TempData["userRole"] = role[0];
                string filepath = HttpContext.Request.Form["filePath"];
                string restId   = string.Empty;

                restId = HttpContext.Request.Form["restId"];


                if (!string.IsNullOrEmpty(filepath))
                {
                    CloudinaryDotNet.Account account = new CloudinaryDotNet.Account("hkm2gz727", "654416183426452", "AZJIv_WvBo1Z7gkzN-uXFVg2_BE");
                    Cloudinary cloudinary            = new Cloudinary(account);

                    CloudinaryDotNet.Actions.ImageUploadParams uploadParams = new CloudinaryDotNet.Actions.ImageUploadParams();
                    uploadParams.File = new CloudinaryDotNet.Actions.FileDescription(filepath);

                    CloudinaryDotNet.Actions.ImageUploadResult uploadResult = await cloudinary.UploadAsync(uploadParams);

                    string url = cloudinary.Api.UrlImgUp.BuildUrl(String.Format("{0}.{1}", uploadResult.PublicId, uploadResult.Format));
                    model.imageUrl = url;
                }
                else
                {
                    string imageurl = HttpContext.Request.Form["imageurl"];
                    model.imageUrl = imageurl;
                }
                if (ModelState.IsValid)
                {
                    model.createdDate  = DateTime.Now;
                    model.modifiedDate = DateTime.Now;
                    model.userId       = user.Id;
                    model.restaurantId = Convert.ToInt32(restId);
                    if (model.id != 0)
                    {
                        _context.ImageDetail.Update(model);
                        _context.SaveChanges();
                    }
                    else
                    {
                        model.sortOrder = _context.ImageDetail.Max(a => a.sortOrder) + 1;
                        _context.ImageDetail.Add(model);
                        _context.SaveChanges();
                    }
                }

                return(Redirect("~/Admin/Images?resturant=" + restId));
            }
            else
            {
                return(RedirectToAction("QuickRegister", "Account"));
            }
        }
Exemplo n.º 2
0
        private void ShowDetailPic(ImageDetail img)
        {
            FormDetailedPic detail = new FormDetailedPic();

            detail.Img = img;
            detail.ShowDialog(this);
            detail.Dispose();
        }
Exemplo n.º 3
0
 public Category Update(Category category, HttpPostedFileBase Image)
 {
     if (Image != null)
     {
         ImageDetail imagePath = _fileUploadService.ThumbImageSave(Image, "Category", 130, 150);
         category.Image      = imagePath.Image;
         category.ThumbImage = imagePath.ThumbImage;
     }
     return(_categoryDal.Update(category));
 }
Exemplo n.º 4
0
        private string PrepareDestFolder(ImageDetail imgToProcess)
        {
            string parentOfBigPicFolder = Directory.GetParent(imgToProcess.ContainedBy).FullName;
            string destFolder           = Path.Combine(parentOfBigPicFolder, Properties.Settings.Default.IconDirectoryName);

            if (!Directory.Exists(destFolder))
            {
                Directory.CreateDirectory(destFolder);
            }
            return(destFolder);
        }
Exemplo n.º 5
0
        public void SelectedImageChanged()
        {
            ImageDetail img = this.screen.SelectedImage;

            if (img != null && !string.IsNullOrEmpty(img.Path))
            {
                string      bigPicPathName = FileSystemStorage.BigImgPathFor(img);
                ImageDetail bigImageDetail = ImageDetail.FromPath(bigPicPathName);
                this.screen.BigImage = bigImageDetail;
            }
        }
Exemplo n.º 6
0
        public void SelectedImageChanged()
        {
            ImageDetail img = this.screen.SelectedImage;

            if (img != null && !string.IsNullOrEmpty(img.Path))
            {
                string      bigPicPathName = BuildFolderPath(img);
                ImageDetail bigImageDetail = ImageDetail.FromPath(bigPicPathName);
                this.screen.BigImage = bigImageDetail;
            }
        }
Exemplo n.º 7
0
        private void pictureEdit1_DoubleClick(object sender, EventArgs e)
        {
            if (this.pictureEdit1.Tag == null)
            {
                return;
            }

            ImageDetail img = this.pictureEdit1.Tag as ImageDetail;

            ShowDetailPic(img);
        }
Exemplo n.º 8
0
        public void ClassifyImagesTest()
        {
            string[]      files  = System.IO.Directory.GetFiles(@"d:\20090505");
            ImageDetail[] images = new ImageDetail[10];
            for (int i = 0; i < images.Length; i++)
            {
                ImageDetail d = ImageDetail.FromPath(files[i]);
                images[i] = d;
            }

            ImageClassifier.ClassifyImages(images);
        }
        internal static string ToSerializedValue(this ImageDetail value)
        {
            switch (value)
            {
            case ImageDetail.Celebrities:
                return("celebrities");

            case ImageDetail.Landmarks:
                return("landmarks");
            }
            return(null);
        }
Exemplo n.º 10
0
 public bool GetWhoStamp(IElement element, ImageDetail image)
 {
     try
     {
         image.Who = element.GetAttribute("data-author");
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="ImageSelectionViewModel"/> class.
        /// </summary>
        /// <param name="log">The log to write debug etc to.</param>
        /// <param name="searchTerm">The search term to use for the image search.</param>
        /// <param name="webAddress">The web address to use for the image search if not null.</param>
        public ImageSelectionViewModel(log4net.ILog log, string searchTerm, string webAddress = null)
        {
            _log        = log;
            _searchTerm = searchTerm;
            UpdateSearchTermCommandAction(webAddress);

            _theHtml        = "Dummy TextBox";
            _imagesOnPage   = new ObservableCollection <ImageDetail>();
            _selectedDetail = new ImageDetail
            {
                Image = new Uri(DefaultImageAddress)
            };
        }
Exemplo n.º 12
0
        public bool GetImageUrl(IElement element, ImageDetail image)
        {
            try
            {
                image.ImageUrl = element.GetAttribute("data-url");

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 13
0
        void File_Created(object sender, FileSystemEventArgs e)
        {
            if (e.ChangeType == WatcherChangeTypes.Created)
            {
                ImageDetail img = ImageDetail.FromPath(e.FullPath);

                System.Diagnostics.Debug.WriteLine("file created");
                System.Diagnostics.Debug.WriteLine(e.FullPath);

                InitCameraQueue(img.FromCamera);
                FireUploadEvent(img);
            }
        }
        public static string[] VideoFilesOfImage(ImageDetail img)
        {
            string videoFilePath = VideoFilePathNameIfExists(img.CaptureTime, img.FromCamera);

            if (File.Exists(videoFilePath))
            {
                string[] videos = new string[] { videoFilePath };
                return(videos);
            }
            else
            {
                return(new string[0]);
            }
        }
Exemplo n.º 15
0
        public bool GetWhoStamp(IElement element, ImageDetail image)
        {
            try
            {
                var nameElement = element.GetElementsByClassName("name");

                image.Who = nameElement.First().InnerHtml ?? "Anonymous";
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainViewModel" /> class.
        /// </summary>
        public MainViewModel()
        {
            _emailAddress     = string.Empty;
            _password         = string.Empty;
            _isValidToConnect = false;
            WebAddress        = "https://www.google.com/search?q=J.G. Ballard&amp;tbm=isch";

            _theHtml        = "Dummy TextBox";
            _imagesOnPage   = new ObservableCollection <ImageDetail>();
            _selectedDetail = new ImageDetail
            {
                Image = new Uri("http://img.timeoutshanghai.com/201304/20130401044423690_Medium.jpg")
            };
        }
Exemplo n.º 17
0
 //Объект типа IActionResult, которые непосредственно предназначены для генерации результата действия.
 public IActionResult Create(IList <IFormFile> files, ImageDetail image)
 {
     foreach (var item in files)
     {
         image.PathImage = "~/uploads/" + item.FileName.Trim();
         image.Size      = item.Length / 1000;
     }
     _upload.UploadFileMultiple(files);
     _context.ImageDetail.Add(image);
     _context.SaveChanges();
     TempData["Sucess"]     = "Save Your File";
     ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Name", image.CategoryId);
     return(RedirectToAction("Create", "Panel"));
 }
Exemplo n.º 18
0
        private static string BuildFolderPath(ImageDetail img)
        {
            string nameWithoutExtension = Path.GetFileNameWithoutExtension(img.Name);
            int    idx = nameWithoutExtension.LastIndexOf('-');

            nameWithoutExtension = nameWithoutExtension.Remove(idx);

            string bigPicName   = nameWithoutExtension + Path.GetExtension(img.Name);
            string bigPicFolder = Directory.GetParent(img.ContainedBy).ToString();

            bigPicFolder = Path.Combine(bigPicFolder, Properties.Settings.Default.BigImageDirectoryName);
            string bigPicPathName = Path.Combine(bigPicFolder, bigPicName);

            return(bigPicPathName);
        }
Exemplo n.º 19
0
        private void ShowPic()
        {
            if (this.squareListView1.SelectedCell == null)
            {
                return;
            }
            string p = this.squareListView1.SelectedCell.Path;

            if (p == null)
            {
                return;
            }

            this.ShowDetailPic(ImageDetail.FromPath(p));
        }
Exemplo n.º 20
0
        public static string[] FindVideos(string rootFolder, ImageDetail img)
        {
            DateTime utcTime = img.CaptureTime.ToUniversalTime();
            string relPath = BuildRelativePathForVideoFile(utcTime);

            string videoFilePath = Path.Combine(rootFolder, relPath);
            if (File.Exists(videoFilePath))
            {
                string[] videos = new string[] { videoFilePath };
                return videos;
            }
            else
            {
                return new string[0];
            }
        }
Exemplo n.º 21
0
 public int CreateImageDetail(ImageDetailEntity imageDetailEntity)
 {
     using (var scope = new TransactionScope())
     {
         var imageDetail = new ImageDetail()
         {
             id          = imageDetailEntity.id,
             path        = imageDetailEntity.path,
             description = imageDetailEntity.description
         };
         _unitOfWork.ImageDetailRepository.Insert(imageDetail);
         _unitOfWork.Save();
         scope.Complete();
         return(imageDetail.id);
     }
 }
Exemplo n.º 22
0
        public static string[] FindVideos(string rootFolder, ImageDetail img)
        {
            DateTime utcTime = img.CaptureTime.ToUniversalTime();
            string   relPath = BuildRelativePathForVideoFile(utcTime);

            string videoFilePath = Path.Combine(rootFolder, relPath);

            if (File.Exists(videoFilePath))
            {
                string[] videos = new string[] { videoFilePath };
                return(videos);
            }
            else
            {
                return(new string[0]);
            }
        }
Exemplo n.º 23
0
        public void ImageDetailConstructorTest()
        {
            string      pathName = @"c:\abc\02_090426154606-0011.jpg"; // TODO: Initialize to an appropriate value
            ImageDetail target   = ImageDetail.FromPath(pathName);

            Assert.AreEqual(2, target.FromCamera);
            Assert.AreEqual(2009, target.CaptureTime.Year);
            Assert.AreEqual(4, target.CaptureTime.Month);
            Assert.AreEqual(26, target.CaptureTime.Day);
            Assert.AreEqual(15, target.CaptureTime.Hour);
            Assert.AreEqual(46, target.CaptureTime.Minute);
            Assert.AreEqual(6, target.CaptureTime.Second);

            Assert.AreEqual(@"c:\abc", target.ContainedBy);
            Assert.AreEqual(@"02_090426154606-0011.jpg", target.Name);
            Assert.AreEqual(@"c:\abc\02_090426154606-0011.jpg", target.Path);
        }
Exemplo n.º 24
0
        public ImageDetail ThumbImageSave(HttpPostedFileBase file, string isim, int height = 100, int witdh = 100)
        {
            string extension = file.ContentType.Split('/')[1];
            string filename  = $"{isim}_{Guid.NewGuid()}";
            string path      = $"/Medya/";

            file.SaveAs(HostingEnvironment.MapPath($"{path}{filename}.{extension}") ?? throw new InvalidOperationException());

            string thumpImage  = Thumbnail(file, $"{filename}.{extension}", height, witdh);
            var    imageDetail = new ImageDetail
            {
                ThumbImage = thumpImage,
                Image      = $"{path}{filename}.{extension}"
            };

            return(imageDetail);
        }
        public async Task UpdateImage(ImageDetail imageDetail)
        {
            var imageDb = _mapper.Map <ImageDb>(imageDetail);
            var db      = new MySqlConnection(_connectionString);

            await db.ExecuteAsync(@"
UPDATE Images SET
Location = @Location, 
Description = @Description,
DateRangeStart = @DateRangeStart, 
DateRangeEnd = @DateRangeEnd
WHERE Id = @Id", imageDb);

            var people = imageDetail.People.Select((i) => i.Id);

            await SavePeopleInImageDb(people, imageDb.Id);
        }
Exemplo n.º 26
0
        public BikeInformation PostBikeInfoDetails(CoreBikeInformation BikeInformationsmodel)
        {
            using (var db = new ObickeEntities())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        BikeInformation data = new BikeInformation()
                        {
                            BikeBrand            = BikeInformationsmodel.BikeBrand,
                            BikeModel            = Convert.ToDecimal(BikeInformationsmodel.BikeModel),
                            BikeRegistrationYear = BikeInformationsmodel.BikeRegistrationYear,
                            BikeKmDriven         = BikeInformationsmodel.BikeKmDriven,
                            BikeDescription      = BikeInformationsmodel.BikeDescription,
                            BikeOwnerName        = BikeInformationsmodel.BikeOwnerName,
                            BikePrice            = BikeInformationsmodel.BikePrice,
                            IsActive             = true,
                            IsDelete             = false
                        };
                        db.BikeInformations.Add(data);
                        db.SaveChanges();
                        foreach (var obj in BikeInformationsmodel.Imagepath)
                        {
                            ImageDetail imgdeatails = new ImageDetail()
                            {
                                BikeId  = data.BikeId,
                                ImgPath = obj.Imagepath
                            };
                            db.ImageDetails.Add(imgdeatails);
                        }
                        db.SaveChanges();
                        transaction.Commit();

                        return(data);
                    }
                    catch (Exception Ex)
                    {
                        string msg = Ex.ToString();
                        transaction.Rollback();

                        return(null);
                    }
                }
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// 加载缩略图列表
        /// </summary>
        void LoadImages()
        {
            if (ArticleID != null)
            {
                Article            a          = ArticleHelper.GetArticle(ArticleID);
                List <ImageDetail> imageList  = new List <ImageDetail>();
                string             folderPath = ExistFilePath();
                if (!Directory.Exists(folderPath))
                {
                    return;
                }
                else
                {
                    List <ThumbnailConfig>  configList = GetAllThumbnailConfigs();
                    System.IO.DirectoryInfo dir        = new System.IO.DirectoryInfo(folderPath);
                    //string[] fields = new string[] { "ChannelFolder" };
                    //Channel ch = ChannelHelper.GetChannel(OwnerID, fields);
                    //string aid = Helper.GUIDToFormatString(ArticleID);
                    StringBuilder sb = new StringBuilder();
                    foreach (System.IO.FileInfo fi in dir.GetFiles())
                    {
                        if (Server.MapPath(a.Thumbnail) == fi.FullName)
                        {
                            continue;
                        }
                        ImageDetail image = new ImageDetail();
                        image.ImagePath = string.Format("/{0}/thumbnail/{1}", !String.IsNullOrEmpty(a.AttachmentUrlPath)?a.AttachmentUrlPath.Trim('/'):"", fi.Name);

                        image.ImagePath = image.ImagePath.Replace("\\", "/");
                        string          idChar = fi.Name.Substring(fi.Name.LastIndexOf("_") + 1, fi.Name.LastIndexOf(".") - fi.Name.LastIndexOf("_") - 1);
                        ThumbnailConfig config = SearchThumbnailConfig(configList, idChar);
                        image.FileName = fi.Name;
                        if (config != null)
                        {
                            image.Name = config.Name;
                            image.Tag  = config.Tag;
                            imageList.Add(image);
                        }
                    }
                }

                ImagesRepeater.DataSource = imageList;
                ImagesRepeater.DataBind();
            }
        }
Exemplo n.º 28
0
        private void toolStripButtonPlayVideo_Click(object sender, EventArgs e)
        {
            if (SearchProxy == null)
            {
                return;
            }
            if (this.bestPicListView.SelectedItems.Count != 1)
            {
                return;
            }

            ImagePair ip = this.bestPicListView.SelectedItems[0].Tag as ImagePair;

            ImageDetail imgInfo = ImageDetail.FromPath(ip.FacePath);

            string video = null;

            try
            {
                video = SearchProxy.VideoFilePathRecordedAt(imgInfo.CaptureTime, imgInfo.FromCamera);
            }
            catch (System.ServiceModel.CommunicationException)
            {
                MessageBox.Show("通讯错误, 请重试");
                IChannel ch = SearchProxy as IChannel;
                if (ch.State == CommunicationState.Faulted)
                {
                    this.CreateProxy();
                }
                return;
            }



            if (string.IsNullOrEmpty(video))
            {
                MessageBox.Show("未找到相关视频");
                return;
            }

            this.ReceiveVideoStream();

            StreamProxy.StreamVideo(video);
            isPlaying = true;
        }
        public async Task <bool> MigrateDataRDSAsync()
        {
            var allImagesDetails = _amazonRDS.Images;

            foreach (var imageDetails in allImagesDetails)
            {
                var imageModel = new ImageDetail
                {
                    Description = imageDetails.Description,
                    FileSizeKb  = String.Format(CultureInfo.GetCultureInfo("en-US"), "{0:0.##}", imageDetails.FileSizeKb),
                    FileType    = imageDetails.FileType.Replace("image/", "")
                };
                await _elasticsearchClient.InsertDataOnElasticsearch(imageDetails.Id, imageModel);
            }
            ;

            return(true);
        }
Exemplo n.º 30
0
        public static string BigImgPathFor(ImageDetail img)
        {
            string nameWithoutExtension = Path.GetFileNameWithoutExtension(img.Name);
            int    idx = nameWithoutExtension.LastIndexOf('-');

            nameWithoutExtension = nameWithoutExtension.Remove(idx);

            string bigPicName   = nameWithoutExtension + Path.GetExtension(img.Name);
            string bigPicFolder = Directory.GetParent(img.ContainedBy).ToString();

            bigPicFolder = bigPicFolder.Replace(Properties.Settings.Default.IconDirectoryName, "");

            bigPicFolder = Path.Combine(bigPicFolder, Properties.Settings.Default.BigImageDirectoryName);
            bigPicFolder = Path.Combine(bigPicFolder, MinutesFolderFor(img.CaptureTime));
            string bigPicPathName = Path.Combine(bigPicFolder, bigPicName);

            return(bigPicPathName);
        }
Exemplo n.º 31
0
    public bool Registration(string name, string email, string gender, string s_ques, string s_ans, string dbbirth, string mobile, string country, string city, string address)
    {
        Registration rg = new Registration();

        rg.name  = name;
        rg.email = email;
        //   rg.password = password;
        rg.gender  = gender;
        rg.a_ques  = s_ques;
        rg.s_ans   = s_ans;
        rg.dob     = dbbirth;
        rg.mobile  = mobile;
        rg.country = country;
        rg.city    = city;
        rg.address = address;
        da.Registrations.InsertOnSubmit(rg);

        logindetail lg = new logindetail();

        lg.name = name;
        //lg.password = password;
        lg.email  = email;
        lg.s_ques = s_ques;
        lg.s_ans  = s_ans;
        lg.u_type = "user";
        da.logindetails.InsertOnSubmit(lg);

        ImageDetail img1 = new ImageDetail();

        img1.UserID    = email;
        img1.Imagename = "";
        img1.ImagePath = "";
        da.ImageDetails.InsertOnSubmit(img1);
        try
        {
            da.SubmitChanges();
            return(true);
        }
        catch
        {
            return(false);
        }
    }
Exemplo n.º 32
0
        public static string[] FindVideos(ImageDetail img)
        {
            string rootFolder = Path.Combine(Properties.Settings.Default.OutputPath,
                img.FromCamera.ToString("D2"));

            DateTime utcTime = img.CaptureTime.ToUniversalTime();
            string relPath = BuildRelativePathForVideoFile(utcTime);

            string videoFilePath = Path.Combine(rootFolder, relPath);
            if (File.Exists(videoFilePath))
            {
                string[] videos = new string[] { videoFilePath };
                return videos;
            }
            else
            {
                return new string[0];
            }
        }