Beispiel #1
0
 public void InitUploadFileName(string rootLocalPath, string uploadPath)
 {
     if (string.IsNullOrEmpty(uploadPath))
     {
         UploadFileName = LocalFileName.Replace(rootLocalPath, string.Empty);
     }
     else if (!string.IsNullOrEmpty(rootLocalPath))
     {
         UploadFileName = string.Format("{0}/{1}", uploadPath, LocalFileName.Replace(rootLocalPath, string.Empty));
     }
     else
     {
         UploadFileName = uploadPath;
     }
     UploadFileName = UploadFileName.Replace("//", "/");
     Log.l(string.Format("UploadFileName {0}", UploadFileName));
 }
Beispiel #2
0
        ///// <summary>
        /////
        ///// </summary>
        //[Category("Data")]
        //public string LocalFileName
        //{
        //    get { return _localFileName; }
        //    set
        //    {
        //        _localFileName = value;
        //        // load the file if the browser is already initialized
        //        if (_firstPageLoaded)
        //            OpenLocalFile();
        //    }
        //}

        private void OpenLocalFile()
        {
            // strip anchors, etc. from any HTTP-path style local file names
            string strippedPath = LocalFileName;

            // removing anchors
            int hashIndex = LocalFileName.IndexOf('#');

            if (hashIndex > 0)
            {
                strippedPath = LocalFileName.Remove(hashIndex);
            }

            // loading for first time so set the page to the LocalFileName
            if (File.Exists(strippedPath))
            {
                Navigate(Path.GetFullPath(LocalFileName));
            }
        }
        private UploadProcessingResult HandleZipFile()
        {
            try
            {
                var RelativePath = _database + @"\" + LocalFileName.Replace(".zip", "").Split('\\').Last();
                // NOTE: BaseDirectory ends with a \ but we don't include the \ in the .Replace method.
                var DirectoryName = AppDomain.CurrentDomain.BaseDirectory.ToLower().Replace("GHuploader", @"GHweb\eps\training\customsites") + RelativePath;

                var indexFound = false;
                using (ZipArchive archive = ZipFile.OpenRead(LocalFileName))
                {
                    if (archive.Entries.Any(file => file.Name.ToLower() == "presentation_html5.html"))
                    {
                        ZipFile.ExtractToDirectory(LocalFileName, DirectoryName);
                        indexFound = true;
                    }
                }

                if (indexFound)
                {
                    File.Delete(LocalFileName);
                    var result = new UploadProcessingResult()
                    {
                        IsComplete    = true,
                        FileName      = OriginalFileName.Replace(".zip", ""),
                        LocalFilePath = RelativePath + @"\presentation_html5.html",
                        FileMetadata  = _streamProvider.FormData
                    };
                    result.FileMetadata.Add("isCustomSite", "true");
                    return(result);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                throw ex;
            }

            return(null);
        }