private void SynchronizeMapsFromSpringFiles() { if (GlobalConst.Mode == ModeType.Live) { var db = new ZkDataContext(); var processedFiles = db.ResourceContentFiles.Where(x => x.Resource.TypeID == ResourceType.Map).Select(x => x.FileName.ToLower()).Distinct().ToLookup(x => x); var triedFiles = db.SpringFilesUnitsyncAttempts.Select(x => x.FileName.ToLower()).Distinct().ToLookup(x => x); var webSyncer = new WebFolderSyncer(); foreach (var file in webSyncer.GetFileList()) { if (processedFiles.Contains(file.ToLower()) || triedFiles.Contains(file.ToLower())) { continue; } webSyncer.DownloadFile(Path.Combine(Paths.WritableDirectory, "maps"), file); UnitSyncer.Scan(); db.SpringFilesUnitsyncAttempts.Add(new SpringFilesUnitsyncAttempt() { FileName = file }); db.SaveChanges(); try { File.Delete(Path.Combine(Paths.WritableDirectory, "maps", file)); } catch (Exception ex) { } } } }
private void SynchronizeMapsFromSpringFiles() { if (GlobalConst.Mode == ModeType.Live) { var fs = new WebFolderSyncer(); fs.SynchronizeFolders("http://api.springfiles.com/files/maps/", Path.Combine(Paths.WritableDirectory, "maps")); UnitSyncer.Scan(); } }
private void SynchronizeMapsFromSpringFiles() { if (GlobalConst.Mode == ModeType.Live) { var fs = new WebFolderSyncer(); fs.SynchronizeFolders("http://api.springfiles.com/files/maps/", Path.Combine(Paths.WritableDirectory, "maps")); Scanner.Rescan(); } }