private AppVersion Find_(string name)
        {
            try
            {
                string[]             Apps         = Directory.GetDirectories(RootPath);                                                                               // массив приложений(папки с названиями всех приложений)
                string               App          = (from app in Apps where (Path.GetFileNameWithoutExtension(app.ToLower()) == name.ToLower()) select app).Single(); //Строка содержащая суть к нужному приложению(к версиям)
                string[]             VersionsApps = (from vers in Directory.GetFiles(App) orderby vers descending select vers.ToString()).ToArray();
                string               js           = File.ReadAllText(VersionsApps[0]);
                JavaScriptSerializer serializer   = new JavaScriptSerializer();
                VersionMeta          meta         = serializer.Deserialize <VersionMeta>(js);
                VersionNumber        Vers         = new VersionNumber(meta.Num, meta.Bild);
                List <FileOfVersion> fileApp      = new List <FileOfVersion>();
                List <string>        ListFile     = new List <string>();
                ListFile = GetFiles_app(name, Vers);
                for (int x = 0; x < ListFile.Count; x++)
                {
                    FileOfVersion verss = new FileOfVersion(ListFile[x], fileContain(RootPath + "\\" + name + ListFile[x]), File.GetCreationTime(RootPath + "\\" + name + ListFile[x]));
                    fileApp.Add(verss);
                }
                AppVersion res = new AppVersion(Path.GetFileNameWithoutExtension(App), Vers, fileApp);
                return(res);
            }
            catch (AppVersionIsNullException ex)
            {
                return(null);

                throw new AppVersionIsNullException();
            }
        }
        ///<summary>Список всех версий приложений</summary>
        public IList <AppVersion> FindAll()
        {
            List <AppVersion> AppVersions = new List <AppVersion>();

            try
            {
                string[] folders = Directory.GetDirectories(RootPath);
                foreach (string App in folders)
                {
                    AppVersion           version      = new AppVersion(Path.GetFileNameWithoutExtension(App), new VersionNumber(1, 0));
                    AppVersion           NewVersion   = new AppVersion(Path.GetFileNameWithoutExtension(App), new VersionNumber(1, 0));
                    string[]             VersionsApps = (from vers in Directory.GetFiles(App) orderby vers descending select vers.ToString()).ToArray();
                    string               js           = File.ReadAllText(VersionsApps[0]);
                    JavaScriptSerializer serializer   = new JavaScriptSerializer();
                    VersionMeta          meta         = serializer.Deserialize <VersionMeta>(js);
                    VersionNumber        Vers         = new VersionNumber(meta.Num, meta.Bild);
                    if (version.VersionNumber < Vers)
                    {
                        NewVersion = new AppVersion(version.VersionName, Vers);
                    }
                    AppVersions.Add(NewVersion);
                }
                return(AppVersions);
            }
            catch (VersionInFileSystemRepo.AppVersionIsNullException ex)
            {
                return(null);

                throw new AppVersionIsNullException();
            }
        }
Esempio n. 3
0
 /// <summary>Список метаданных файлов приложения</summary><param name="ver"></param>
 public IList <FileOfVersion> FindFileOfVersions(AppVersion ver)
 {
     try
     {
         string[]             Apps         = Directory.GetDirectories(RootPath);                                                                                                                                 // массив приложений(папки с названиями всех приложений)
         string               App          = (from app in Apps where (Path.GetFileNameWithoutExtension(app.ToLower()) == ver.VersionName.ToLower()) select app).Single();                                        //Строка содержащая суть к нужному приложению(к версиям)
         string               VersionsApps = (from vers in Directory.GetFiles(App) where (Path.GetFileNameWithoutExtension(vers) == ver.VersionName + "-" + ver.VersionNumber.ToString()) select vers).Single(); //отсортированный по убыванию массив версий
         string               js           = File.ReadAllText(VersionsApps);
         JavaScriptSerializer serializer   = new JavaScriptSerializer();
         VersionMeta          meta         = serializer.Deserialize <VersionMeta>(js);
         VersionNumber        Vers         = new VersionNumber(meta.Num, meta.Bild);
         List <FileOfVersion> fileApp      = new List <FileOfVersion>();
         List <string>        ListFile     = new List <string>();
         ListFile = GetFiles_app(ver.VersionName, Vers);
         for (int x = 0; x < ListFile.Count; x++)
         {
             FileOfVersion verss = new FileOfVersion(ListFile[x], fileContain(RootPath + "\\" + ver.VersionName + ListFile[x]), File.GetCreationTime(RootPath + "\\" + ver.VersionName + ListFile[x]));
             fileApp.Add(verss);
         }
         return(fileApp);
     }
     catch (FilePathIsNullException ex)
     {
         throw new FilePathIsNullException();
     }
 }
Esempio n. 4
0
 public void SetStatusContent(string content, int status, byte[] rawBytes)
 {
     this.StatusCode = status;
     this.Content    = content;
     if (status < 300)
     {
         this.Data = JsonConvert.DeserializeObject <VersionMeta>(this.Content);
     }
 }
 /// <summary>Сохранение метаданных</summary><param name="version"></param>
 public bool SaveApplication(AppVersion version)
 {
     try
     {
         JavaScriptSerializer serializer  = new JavaScriptSerializer();
         VersionMeta          versionMeta = new VersionMeta();
         versionMeta.AppName = version.VersionName;
         versionMeta.Num     = version.VersionNumber.Number;
         versionMeta.Bild    = version.VersionNumber.VersionBuildNumber;
         string json = serializer.Serialize(versionMeta);
         File.WriteAllText(RootPath + "\\" + version.VersionName + "\\" + version.VersionName + "-" + version.VersionNumber.ToString() + ".xml", json);
         return(true);
     }
     catch (SaveApplicationException ex)
     {
         throw new SaveApplicationException();
     }
 }
Esempio n. 6
0
 public VersionResponseBase()
 {
     this.Data    = new VersionMeta();
     this.Headers = new Dictionary <string, object> {
     };
 }