Пример #1
0
        private bool InitLocalFiles()
        {
            long dealtSize = 0;

            foreach (FH2File fh2File in this.fileIndex)
            {
                FH2File localfile = clone(fh2File);
                string  fileName  = fh2File.name;
                string  filePath  = Path.Combine("..", "..", fh2File.target, fh2File.name);
                localfile.Client(filePath, rootFolder, this.webRoot);
                dealtSize += fh2File.size;
                double Progress = dealtSize / this.totalSize;
                localFiles.Add(localfile);
                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += new DoWorkEventHandler(
                    delegate(object o, DoWorkEventArgs args)
                {
                    report(Progress);
                });
                worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(
                    delegate(object o, RunWorkerCompletedEventArgs args)
                {
                    worker.Dispose();
                });
                worker.RunWorkerAsync();
            }
            return(true);
        }
Пример #2
0
        private bool InitFileIndex()
        {
            this.totalSize = 0;
            XmlTextReader reader = new XmlTextReader(this.fileIndexURL);

            while (reader.Read())
            {
                if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "file"))
                {
                    if (reader.HasAttributes)
                    {
                        FH2File fh2fileWeb = new FH2File();
                        fh2fileWeb.name     = reader.GetAttribute("name");
                        fh2fileWeb.target   = reader.GetAttribute("target");
                        fh2fileWeb.source   = reader.GetAttribute("source");
                        fh2fileWeb.size     = long.Parse(reader.GetAttribute("size"));
                        this.totalSize     += fh2fileWeb.size;
                        fh2fileWeb.checksum = reader.GetAttribute("checksum").ToUpper();
                        fh2fileWeb.fullPath = Path.Combine(fh2fileWeb.target, fh2fileWeb.name);
                        this.fileIndex.Add(fh2fileWeb);
                    }
                }
            }
            reader.Close();
            return(true);
        }
        private bool InitLocalFiles(object sender)
        {
            this.localFiles.Clear();
            long          dealtSize = 0;
            DirectoryInfo folder    = new DirectoryInfo(Application.StartupPath);

            folder = folder.Parent.Parent;
            foreach (FH2File fh2File in this.fileIndex)
            {
                if (sender != this.parent.CurrentOwner)
                {
                    Console.WriteLine("Cancel this MD5Check.");
                    return(false);
                }
                FH2File localfile = fh2File.Clone();
                string  fileName  = fh2File.name;
                string  filePath  = Path.Combine(Path.Combine(folder.FullName, fh2File.target), fh2File.name);
                localfile.Client(filePath, rootFolder);
                dealtSize += fh2File.size;
                double Progress = (double)dealtSize / (double)this.totalSize;
                localFiles.Add(localfile);
                Report(Progress);
            }
            return(true);
        }
Пример #4
0
        public FH2File Clone()
        {
            FH2File clonedFile = new FH2File();

            clonedFile.name     = this.name;
            clonedFile.target   = this.target;
            clonedFile.checksum = this.checksum;
            clonedFile.fullPath = this.fullPath;
            return(clonedFile);
        }
Пример #5
0
        private FH2File clone(FH2File fh2file)
        {
            FH2File clonedFile = new FH2File();

            clonedFile.name     = fh2file.name;
            clonedFile.target   = fh2file.target;
            clonedFile.checksum = fh2file.checksum;
            clonedFile.source   = fh2file.source;
            clonedFile.fullPath = fh2file.fullPath;
            return(clonedFile);
        }
Пример #6
0
 public bool Compare(FH2File other)
 {
     if (this.name != other.name)
     {
         return(false);
     }
     else if (this.target != other.target)
     {
         return(false);
     }
     else if (this.size != other.size)
     {
         return(false);
     }
     else if (this.checksum.ToLower() != other.checksum.ToLower())
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
        private bool InitFileIndex()
        {
            if (this.fileIndexURL.Equals(null))
            {
                throw new ContentManagerException(this, "Addon does not have a file index specified!");
            }
            this.fileIndex.Clear();
            this.totalSize = 0;
            XmlTextReader reader = new XmlTextReader(this.fileIndexURL);
            var           test   = 0;

            while (reader.Read())
            {
                if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "file"))
                {
                    if (reader.HasAttributes)
                    {
                        FH2File fh2fileWeb = new FH2File();
                        fh2fileWeb.name     = reader.GetAttribute("name");
                        fh2fileWeb.target   = reader.GetAttribute("target");
                        fh2fileWeb.size     = long.Parse(reader.GetAttribute("size"));
                        this.totalSize     += fh2fileWeb.size;
                        fh2fileWeb.checksum = reader.GetAttribute("checksum").ToUpper();
                        fh2fileWeb.fullPath = Path.Combine(fh2fileWeb.target, fh2fileWeb.name);
                        this.fileIndex.Add(fh2fileWeb);
                        test++;
                    }
                }
            }
            if (test == 0)
            {
                throw new XmlException("File Index has no elements!");
            }
            this.parent.informWorkerSize(this);
            reader.Close();
            return(true);
        }