当前位置: 首页>>代码示例>>C#>>正文


C# Web.HttpServerUtilityBase类代码示例

本文整理汇总了C#中System.Web.HttpServerUtilityBase的典型用法代码示例。如果您正苦于以下问题:C# HttpServerUtilityBase类的具体用法?C# HttpServerUtilityBase怎么用?C# HttpServerUtilityBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HttpServerUtilityBase类属于System.Web命名空间,在下文中一共展示了HttpServerUtilityBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getCacheFilename

        /// <summary>
        /// Calculate a unique filename representing this request.
        /// </summary>
        public string getCacheFilename(string query, bool withGzip, 
            HttpServerUtilityBase server)
        {
            Debug.Assert(!string.IsNullOrEmpty(cacheDir));

            //
            // lowercase the query, and hash it
            //
            byte[] MessageBytes = Encoding.ASCII.GetBytes(query.ToLower());

            SHA1Managed sha1 = new SHA1Managed();
            byte[] sha1Bytes = sha1.ComputeHash(MessageBytes);

            StringBuilder sb = new StringBuilder();
            sb.Append( Convert.ToBase64String(sha1Bytes) );

            //
            // replace any invalid path characters
            //
            foreach(char c in Path.GetInvalidFileNameChars()) {
                sb.Replace(c, '_');
            }

            //
            // use a distinct key for gzipped content
            //
            if (withGzip)
            {
                sb.Append(".gz");
            }

            string relPath = Path.Combine(cacheDir, sb.ToString());
            return server.MapPath(relPath);
        }
开发者ID:gmoothart,项目名称:NCombo,代码行数:37,代码来源:ncombo.cs

示例2: PRCImageCollection

        public PRCImageCollection(HttpServerUtilityBase Server, string PRCRef)
        {
            this.PRCRef = PRCRef;
            this.ServerPath = new DirectoryInfo(Server.MapPath(@"~\"));

            this.CarouselImagesDirectoryPath = new DirectoryInfo(this.ServerPath + "CarouselImages\\" + PRCRef);
            this.PropertyImagesDirectoryPath = new DirectoryInfo(this.ServerPath + "PropertyImages\\" + PRCRef);

            //get all directories and files and create PRCImages
            GetAllImagesFromADirectoryAndPlaceInACollection(CarouselImagesDirectoryPath, CarouselImageList, this.CarouselImagesExists);
            GetAllImagesFromADirectoryAndPlaceInACollection(PropertyImagesDirectoryPath, PropertyImageList, this.PropertyImagesExists);

            if (CarouselImageList.Count > 0)
            {
                CarouselImagesExists = true;
                foreach (var image in CarouselImageList)
                {
                    image.CapitalizeCamelCasedString();

                }
            }
            if (PropertyImageList.Count > 0)
            {
                PropertyImagesExists = true;
                foreach (var image in PropertyImageList)
                {
                    image.CapitalizeCamelCasedString();

                }

            }
        }
开发者ID:nadavdrewe,项目名称:portugalvillas,代码行数:32,代码来源:ImageUtility.cs

示例3: ResolveRelativePath

 private static string ResolveRelativePath(HttpServerUtilityBase server, string physicalPath)
 {
     //C:\@Projects\Tarts\Tarts.Web\assets\images\large\1040c396-c558-473e-a3ca-f20de6ab13d2.jpg
     string relative = "~/assets/images";
     string physical = server.MapPath(relative);
     return physicalPath.Replace(physical, relative).Replace("\\", "/").Replace("~","");
 }
开发者ID:s-leonard,项目名称:Tarts,代码行数:7,代码来源:ImageHelper.cs

示例4: deleteFolder

        public void deleteFolder(HttpRequestBase Request, HttpServerUtilityBase Server)
        {
            //dbContext = new PAWA.DAL.PAWAContext();

            IEnumerable<Folder> folders = GetFolders();

            int foldersIndex = 0;
            string selectedValue;
            while (foldersIndex < folders.Count())
            {
                selectedValue = Request.Form[folders.ElementAt(foldersIndex).FolderID.ToString() + "_folder"];
                int folderID = folders.ElementAt(foldersIndex).FolderID;
                if (selectedValue != null && selectedValue.Equals("on"))
                {

                    Folder delFolder = folders.ElementAt(foldersIndex);
                    deleteFolderChain(delFolder);

                }
                else
                {
                    foldersIndex++;
                }
            }
        }
开发者ID:jarradm,项目名称:PAWA,代码行数:25,代码来源:DeleteFolder.cs

示例5: SaveImage

        public Image SaveImage(HttpServerUtilityBase server, HttpPostedFileBase file)
        {
            string largeUploadFolder = server.MapPath("~/assets/images/large");
            string mediumUploadFolder = server.MapPath("~/assets/images/medium");
            string thumbUploadFolder = server.MapPath("~/assets/images/thumb");
            if (!Directory.Exists(largeUploadFolder)) Directory.CreateDirectory(largeUploadFolder);
            if (!Directory.Exists(mediumUploadFolder)) Directory.CreateDirectory(mediumUploadFolder);
            if (!Directory.Exists(thumbUploadFolder)) Directory.CreateDirectory(thumbUploadFolder);

            //The resizing settings can specify any of 30 commands.. See http://imageresizing.net for details.
            ResizeSettings largeSettings = new ResizeSettings("maxwidth=800&maxheight=800");
            ResizeSettings mediumSettings = new ResizeSettings("maxwidth=300&maxheight=300&scale=both");
            ResizeSettings thumbSettings = new ResizeSettings("width=100&height=100&crop=auto");

            //var uniqueName = System.Guid.NewGuid().ToString();
            string uniqueName = PathUtils.RemoveExtension(file.FileName) + "_" + DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss");
            string largeFilePath = Path.Combine(largeUploadFolder, uniqueName);
            string mediumFilePath = Path.Combine(mediumUploadFolder, uniqueName);
            string thumbFilePath = Path.Combine(thumbUploadFolder, uniqueName);

            //Let the image builder add the correct extension based on the output file type (which may differ).
            var large = ImageBuilder.Current.Build(file, largeFilePath, largeSettings, false, true);
            var med = ImageBuilder.Current.Build(file, mediumFilePath, mediumSettings, false, true);
            var thumb = ImageBuilder.Current.Build(file, thumbFilePath, thumbSettings, false, true);

            Image img = new Image(PathUtils.RemoveExtension(file.FileName), ResolveRelativePath(server, large), ResolveRelativePath(server, med), ResolveRelativePath(server, thumb));
            Repo.Save(img);
            return img;
        }
开发者ID:s-leonard,项目名称:Tarts,代码行数:29,代码来源:ImageHelper.cs

示例6: Delete

 public void Delete(HttpServerUtilityBase server, Image img)
 {
     try { System.IO.File.Delete(server.MapPath(img.Large)); } catch {}
     try { System.IO.File.Delete(server.MapPath(img.Medium)); } catch {}
     try { System.IO.File.Delete(server.MapPath(img.Thumb)); } catch {}
     Repo.Delete(img);
 }
开发者ID:s-leonard,项目名称:Tarts,代码行数:7,代码来源:ImageHelper.cs

示例7: CreateAlbumWithMockFile

        private Album CreateAlbumWithMockFile( AlbumRepository repo, HttpServerUtilityBase server, Mock<HttpPostedFileBase> mock )
        {
            Album album = repo.CreateAlbum( new BackOffice.Model.Album
            {
                Duration = TimeSpan.FromHours( 2 ),
                Title = RandomName(),
                Artist = new BackOffice.Model.Artist { Name = RandomName() },
                ReleaseDate = DateTime.UtcNow,
                Type = "Hip-Hop US",
                Tracks = new List<Track>
                            {
                                new Track
                                {
                                    Number = 1,
                                    Duration = TimeSpan.FromMinutes(4),
                                    File = mock.Object,
                                    Song = new Song
                                    {
                                        Name = RandomName(),
                                        Composed = new DateTime(2010,1,12)
                                    }
                                }
                            }
            }, server );

            return album;
        }
开发者ID:clegendre,项目名称:NwdStudents,代码行数:27,代码来源:AlbumRepositoryTests.cs

示例8: EditCountry

 public ProcessResult EditCountry(int id, string nameRus, string nameEng, HttpPostedFileBase imageUpload, bool deleteImage, HttpServerUtilityBase server)
 {
     Country country = GetCountry(id);
     if (String.IsNullOrEmpty(nameRus) || String.IsNullOrEmpty(nameEng))
         return ProcessResults.TitleCannotBeEmpty;
     if (country == null)
         return ProcessResults.NoSuchCountry;
     country.Translation.En = nameEng;
     country.Translation.Ru = nameRus;
     if (deleteImage && imageUpload == null)
     {
         DeleteImage(country.Image, server);
         country.Image = null;
     }
     else if(imageUpload!=null)
     {
         if (imageUpload.ContentLength <= 0 || !SecurityManager.IsImage(imageUpload))
             return ProcessResults.InvalidImageFormat;
         country.Image = SaveImage(country.Id, StaticSettings.CountriesUploadFolderPath, imageUpload, server);
     }
     Data.SaveChanges();
     ProcessResult result = ProcessResults.CountryEdited;
     result.AffectedObjectId = country.Id;
     return result;
 }
开发者ID:Reidan94,项目名称:ITouristDashboard,代码行数:25,代码来源:CountryManager.cs

示例9: PrepareExcel

        /// <summary>
        /// Prepares the excel.
        /// </summary>
        /// <param name="dataSet">The data set.</param>
        /// <param name="reportName">Name of the report.</param>
        /// <param name="reportTitle">The report title.</param>
        /// <param name="responseBase">The response base.</param>
        /// <param name="serverBase">The server base.</param>
        /// <param name="voyageIds">The voyage ids.</param>
        public void PrepareExcel(DataSet dataSet, string reportName, string reportTitle, HttpResponseBase responseBase, HttpServerUtilityBase serverBase, string voyageIds)
        {
            this.response = responseBase;
            this.server = serverBase;

            this.GenerateGuestReconciliationTable(dataSet, reportName, reportTitle, voyageIds);
        }
开发者ID:JaipurAnkita,项目名称:mastercode,代码行数:16,代码来源:ExcelProvider.cs

示例10: delete_mvc_use_only

        public Boolean delete_mvc_use_only(int id, HttpServerUtilityBase server_context)
        {
            try
             {
                HinhAnh kq = this.get_by_id(id);
                if (kq == null) return false;
                //first delete file
                try
                {
                    String directory = "~/_Upload/HinhAnh/";
                    System.IO.File.Delete(server_context.MapPath(Path.Combine(directory, kq.duongdan)));
                    System.IO.File.Delete(server_context.MapPath(Path.Combine(directory, kq.duongdan_thumb)));

                }
                catch (Exception ex)
                {
                    Debug.WriteLine("qqqqqqqqqqqq"+ex.ToString());
                }
                //delete in database
                _db.ds_hinhanh.Remove(kq);
                _db.SaveChanges();
                return true;
             }
             catch (Exception ex)
             {
                 Debug.WriteLine(ex.ToString());
                 return false;
             }
        }
开发者ID:quocdunginfo,项目名称:CuaHangDTDD,代码行数:29,代码来源:HinhAnhController.cs

示例11: GetEntryPoint

        private static string GetEntryPoint(HttpServerUtilityBase server, string filePath, string root)
        {

            var fileName = PathHelpers.GetExactFilePath(filePath);
            var folder = server.MapPath(root);
            return PathHelpers.GetRequireRelativePath(folder, fileName);
        }
开发者ID:philipooo,项目名称:RequireJSDotNet,代码行数:7,代码来源:DefaultEntryPointResolver.cs

示例12: SwtorzFirme

        internal Firma SwtorzFirme(HttpServerUtilityBase server, HttpPostedFileBase uploadFile)
        {
            string url = string.Empty;
            if (uploadFile != null && uploadFile.FileName != string.Empty)
            {
                url = Path.Combine(server.MapPath("~/Images/firmy"), uploadFile.FileName);
                uploadFile.SaveAs(url);
                url = Path.Combine("../Images/firmy", uploadFile.FileName);
            }

            Firma firma = new Firma
            {
                nazwa = nazwa,
                zdjecie = url,
                adres = new Adres
                {
                    ulica = ulica,
                    numer_budynku = numer_budynku,
                    numer_lokalu = numer_lokalu,
                },
                kontakt = new Kontakt
                {
                    mail = mail,
                    numer_komurkowy = numer_komurkowy
                },
            };

            return firma;
        }
开发者ID:przemko07,项目名称:ZaliczenieTenglera,代码行数:29,代码来源:NowaFirmaVM.cs

示例13: SetCleanExtractFolder

 private static string SetCleanExtractFolder(HttpServerUtilityBase server, string mapPath,
     string cleanFileNameNoExtension)
 {
     var extractFolder = server.MapPath(mapPath + cleanFileNameNoExtension);
     MakeOrResetDirectory(extractFolder);
     return extractFolder;
 }
开发者ID:rswetnam,项目名称:GoodBoating,代码行数:7,代码来源:FileServices.cs

示例14: FileCertificateService

 public FileCertificateService(HttpServerUtilityBase serverBase, IFileSystem fileSystem, string path, string password)
 {
     _serverBase = serverBase;
     _fileSystem = fileSystem;
     _path = path;
     _password = password;
 }
开发者ID:njmube,项目名称:SigningService,代码行数:7,代码来源:FileCertificateService.cs

示例15: EventCategorySingleViewModel

        public EventCategorySingleViewModel(string category, HttpServerUtilityBase server)
        {
            _server = server;

            category = formatCategoryString(category);

            //ImageList = getImageList();

            using (var context = new DataContext())
            {
                var tomorrow = DateTime.Now.Date;
                TheCategory = context.EventCategories.FirstOrDefault(x => x.CategoryName == category);

                EventRoll = context.Events.Where(x => x.MainCategory == category && x.IsActive == true && DateTime.Compare(x.EndDate.Value, tomorrow) >= 0).ToList();

                // Set a random picture on the eventRoll if none is currently set
                //foreach (var event in EventRoll)
                //{
                //	if (String.IsNullOrEmpty(event.ImageUrl))
                //	{
                //		event.ImageUrl = getRandomImage();
                //	}

                //}
            }
        }
开发者ID:marciocamello,项目名称:dirigo-edge,代码行数:26,代码来源:EventCategorySingleViewModel.cs


注:本文中的System.Web.HttpServerUtilityBase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。