Example #1
0
        private void SendToSync(int status)
        {
            this.ChangesBusy = true;
            List <DestinationsServer> servers;
            var changes = LogHelper.ReadNotAddedChanges();

            Parallel.ForEach(changes, (change) => {
                if (status == 0)
                {
                    servers = Setting.CurrentSetting.Servers.Where(s => s.IsActive).ToList();
                }
                if (status == 1)
                {
                    servers = GetServer();
                }
                foreach (var server in GetServer())
                {
                    var log             = new SyncLog();
                    log.AddTime         = DateTime.Now;
                    log.SourcePath      = change.FilePath;
                    log.DestinationName = server.Name;
                    log.DestinationPath = Path.GetPathRoot(server.Path) + change.FilePath.Substring(2, change.FilePath.Length - 2);
                    log.DestinationRoot = server.Path;
                    var result          = LogHelper.AddSync(log);
                    if (result)
                    {
                        LogHelper.UpdateChangesStatus(change.Id, 1);
                    }
                }
            });
            this.ChangesBusy = false;
        }