Exemple #1
0
        /// <summary>
        /// Push data from source to destination
        /// </summary>
        /// <param name="factory">Storage Factory</param>
        private static void Push(StorageFactory factory)
        {
            Parallel.ForEach<IStorageItem>(factory.Source(), (from, state) =>
            {
                Trace.WriteLine(string.Format("Processing file: '{0}'.", from));

                var to = factory.To(from);
                var exists = to.Exists();
                if (!exists)
                {
                    Trace.WriteLine(string.Format("Synchronizing new file: '{0}'.", from));
                }

                if (!exists || to.MD5 != from.MD5 || to.MD5 == null)
                {
                    to.Save(from, exists);

                    Trace.WriteLine(string.Format("Synchronizing file: '{0}'.", from));
                }
                else
                {
                    Trace.WriteLine(string.Format("File '{0}' already exists at '{1}', synchronization avoided.", from.Path, to.Path));
                }

                to = null;
                from = null;
            });
        }
Exemple #2
0
        /// <summary>
        /// Push data from source to destination
        /// </summary>
        /// <param name="factory">Storage Factory</param>
        private static void Push(StorageFactory factory)
        {
            Parallel.ForEach <IStorageItem>(factory.Source(), (from, state) =>
            {
                Trace.WriteLine(string.Format("Processing file: '{0}'.", from));

                var to     = factory.To(from);
                var exists = to.Exists();
                if (!exists)
                {
                    Trace.WriteLine(string.Format("Synchronizing new file: '{0}'.", from));
                }

                if (!exists || to.MD5 != from.MD5 || to.MD5 == null)
                {
                    to.Save(from, exists);

                    Trace.WriteLine(string.Format("Synchronizing file: '{0}'.", from));
                }
                else
                {
                    Trace.WriteLine(string.Format("File '{0}' already exists at '{1}', synchronization avoided.", from.Path, to.Path));
                }

                to   = null;
                from = null;
            });
        }