Esempio n. 1
0
        /// <summary>
        /// start
        /// </summary>
        /// <param name="model"></param>
        public void Start(SychComplete callback, SyncFileDataModel model)
        {
            var models = new ObservableCollection <SyncFileDataModel>();

            models.Add(model);
            this.Start(callback, models);
        }
Esempio n. 2
0
        /// <summary>
        ///  sync file
        /// </summary>
        /// <param name="model"></param>
        private void Sync(SyncFileDataModel model)
        {
            model.CheckDateTime = DateTime.Now.ToString("HH:mm:ss");
            var src  = new FileOperator(model.LocalFile);
            var dest = new FileOperator(model.ServerFile);

            if ((null == src || !src.Exists()) && (null == dest || !dest.Exists()))
            {
                model.UpdateDateTime = "x";
                return;
            }

            if (null == src || !src.Exists())
            {
                dest.Copy(src);
                model.UpdateDateTime = dest.LastWriteTimeString + "↓";
                return;
            }
            if (null == dest || !dest.Exists())
            {
                src.Copy(dest);
                model.UpdateDateTime = src.LastWriteTimeString + "↑";
                return;
            }

            switch (src.LastWriteTimeString.CompareTo(dest.LastWriteTimeString))
            {
            case -1:
                dest.Copy(src);
                model.UpdateDateTime = dest.LastWriteTimeString + "↓";
                break;

            case 0:
                // NOP
                break;

            case 1:
                src.Copy(dest);
                model.UpdateDateTime = src.LastWriteTimeString + "↑";
                break;
            }
        }