Пример #1
0
 private static List<FileVersion> GetFileVersions(string path, string folder, VersionInfo.ErrorMessageDel onErrorMessage)
 {
     try
     {
         var files = new List<FileProperties>();
         FileReader.LoadFiles(path, folder, SystemName.Terminal.ToString(), files);
         return files.Select(f => new FileVersion
         {
             FileName = f.Path + "\\" + f.Name,
             Date = f.TimeUpdated,
             Length = f.Length,
             HashCode = f.HashCode
         }).ToList();
     }
     catch (Exception ex)
     {
         onErrorMessage("Ошибка при получении FileInfo ({0}{1}): {2}", path, folder, ex);
         return new List<FileVersion>();
     }
 }
Пример #2
0
 public static List<FileVersion> GetFileVersions(VersionInfo.ErrorMessageDel onErrorMessage)
 {
     return GetFileVersions(ownPath, ownPath, onErrorMessage);
 }
Пример #3
0
        private void CheckVersionDoWork(object sender, DoWorkEventArgs e)
        {
            // проверить врем¤ файлов
            // файлы в собственной директории
            Dictionary<string, FileVersion> ownVersion;
            var vers = new VersionInfo(Logger.ErrorFormat);
            try
            {
                ownVersion = vers.GetOwnVersionInfo(ExecutablePath.ExecPath);
            }
            catch (Exception ex)
            {
                Logger.Error("ќшибка в CheckVersionThreadSafe", ex);
                return;
            }

            // файлы на сервере
            var siteVersion = vers.GetVersionInfoFromUrl();
            if (siteVersion == null || siteVersion.Count == 0) return;

            // сравнить версии
            var missingFiles = new List<string>();
            var olderFiles = new List<string>();

            foreach (var pair in siteVersion)
            {
                var siteFileName = pair.Key;
                var siteFileAttrs = pair.Value;
                if (!ownVersion.ContainsKey(siteFileName))
                    missingFiles.Add(siteFileName);
                else if (!ownVersion[siteFileName].IsRelevant(siteFileAttrs))
                    olderFiles.Add(siteFileName);
            }

            e.Result = new Cortege2<List<string>, List<string>>(missingFiles, olderFiles);
        }