Beispiel #1
0
 public override IDocEntity SaveChanges(bool ignoreCache, DocConstantPermission permission)
 {
     FileLabel        = FileLabel?.TrimAndPruneSpaces();
     FileName         = FileName?.TrimAndPruneSpaces();
     OriginalFileName = OriginalFileName?.TrimAndPruneSpaces();
     return(base.SaveChanges(ignoreCache, permission));
 }
Beispiel #2
0
 public override int GetHashCode()
 {
     unchecked {
         const int randomPrime = 397;
         int       hashCode    = Id.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ (FullDocumentFileName != null ? FullDocumentFileName.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (FreeSnippetFileName != null ? FreeSnippetFileName.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (OriginalFileName != null ? OriginalFileName.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (Title != null ? Title.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (Description != null ? Description.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (Degree != null ? Degree.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (CourseName != null ? CourseName.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (CourseCode != null ? CourseCode.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (Year != null ? Year.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ UniversityId.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ UploadedBy.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ UploadedAt.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ (DeletedAt != null ? DeletedAt.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ IsFree.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ (IsApproved != null ? IsApproved.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (Hash != null ? Hash.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (MinHashSignature != null ? MinHashSignature.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ CategoryId.GetHashCode();
         return(hashCode);
     }
 }
Beispiel #3
0
        public override int GetHashCode()
        {
            int result = 1;

            result = (result * 397) ^ (FileNameSaved != null ? FileNameSaved.GetHashCode() : 0);
            result = (result * 397) ^ Id.GetHashCode();
            result = (result * 397) ^ (OriginalFileName != null ? OriginalFileName.GetHashCode() : 0);
            return(result);
        }
    private void trimPreviousName()
    {
        this.OriginalFileName = (this.GridViewRowSelected.FindControl("ltlFileItem") as Literal).Text;
        this.Prefix           = OriginalFileName.Substring(0, 3);
        this.NewFileName      = OriginalFileName.Substring(0, OriginalFileName.Length - 4);
        int ingnoreMe = 0;

        if (int.TryParse(Prefix.Substring(0, 2), out ingnoreMe))
        {
            this.NewFileName = NewFileName.Substring(3);
        }
    }
 /// <summary>
 /// Serves as a hash function for a particular type.
 /// </summary>
 /// <returns>A hash code for the current <see cref="T:System.Object"/>.</returns>
 public override int GetHashCode()
 {
     return(BootCritical.GetHashCode()
            ^ InBox.GetHashCode()
            ^ (String.IsNullOrEmpty(CatalogFile) ? 0 : CatalogFile.GetHashCode())
            ^ (String.IsNullOrEmpty(ClassDescription) ? 0 : ClassDescription.GetHashCode())
            ^ (String.IsNullOrEmpty(ClassGuid) ? 0 : ClassGuid.GetHashCode())
            ^ (String.IsNullOrEmpty(ClassName) ? 0 : ClassName.GetHashCode())
            ^ Date.GetHashCode()
            ^ DriverSignature.GetHashCode()
            ^ (String.IsNullOrEmpty(OriginalFileName) ? 0 : OriginalFileName.GetHashCode())
            ^ (String.IsNullOrEmpty(ProviderName) ? 0 : ProviderName.GetHashCode())
            ^ (String.IsNullOrEmpty(PublishedName) ? 0 : PublishedName.GetHashCode()));
 }
        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);
        }
Beispiel #7
0
 private void StripExtensionAndCleanFileName()
 {
     FileNameExtension = OriginalFileName.Substring(OriginalFileName.LastIndexOf('.'));
     _fileNameWithoutExtensionAndClean = Regex.Replace(OriginalFileName.Replace(FileNameExtension, String.Empty), @"[\._-]+", " ");
 }