/// <summary>Получение настроек сообщения</summary><param name="appName"></param><param name="appVersion"></param><returns>result</returns>
 public AppVersionSetting GetSetting(string appName, string appVersion)
 {
     try
     {
         mydb = new DB.SQLite.SQLite(BDPath);
         SQLiteCommand command = new SQLiteCommand();
         command.CommandText = "SELECT * FROM ApplicationInfo WHERE Application = @Application AND AppVersion = @AppVersion ";
         command.Parameters.Add("@Application", DbType.String).Value = appName;
         command.Parameters.Add("@AppVersion", DbType.String).Value  = appVersion;
         DataRow[] datarows = mydb.Select(command);
         if (datarows == null)
         {
             throw new Exception();
         }
         AppVersionSetting result = new AppVersionSetting();
         foreach (var info in datarows)
         {
             result.ActialAppName    = info["Aplication"].ToString();
             result.ActialAppVersion = info["AppVersion"].ToString();
             result.ActialFlag       = info["Flag"].ToString();
             result.AppDiscription   = info["AppDiscription"].ToString();
             result.NameExe          = info["Name_EXE"].ToString();
         }
         return(result);
     }
     catch
     {
         throw new Exception();
     }
 }
        /// <summary>Получение версии приложения</summary><param name="appName"></param><returns></returns>
        public AppVersion GetAppVersion(string appName)
        {
            AppVersion AppVersions = null;

            mydb = new DB.SQLite.SQLite(BDPath);
            string        flag    = "True";
            SQLiteCommand command = new SQLiteCommand();

            command.CommandText = "SELECT * FROM ApplicationInfo WHERE Flag = @Flag AND Application = @Application";
            command.Parameters.Add("@Flag", DbType.String).Value        = flag;
            command.Parameters.Add("@Application", DbType.String).Value = appName;
            DataRow[] datarows = mydb.Select(command);
            if (datarows == null)
            {
                throw new Exception();
            }
            foreach (DataRow dr in datarows)
            {
                VersionNumber VerNum;
                VersionNumber.TryParse(dr["AppVersion"].ToString().Trim(), out VerNum);
                AppVersion AppVer = new AppVersion(dr["Application"].ToString(), VerNum);
                AppVersions = (AppVer);
            }
            return(AppVersions);
        }
示例#3
0
 /// <summary>Получение содержимого файла версии приложения</summary><param name="version"></param><param name="name"></param><returns>byte[]</returns>
 public byte[] GetFile(AppVersion version, FileOfVersion name)
 {
     try
     {
         byte[] contains = null;
         mydb = new DB.SQLite.SQLite(BDPath);
         SQLiteCommand command = new SQLiteCommand();
         command.CommandText = "SELECT * FROM FilesContains WHERE Applications = @Applications AND AppVersions = @AppVersions AND FilePath = @FilePath";
         command.Parameters.Add("@Applications", DbType.String).Value = version.VersionName;
         command.Parameters.Add("@AppVersions", DbType.String).Value  = version.VersionNumber.ToString();
         command.Parameters.Add("@FilePath", DbType.String).Value     = name.FilePath;
         DataRow[] datarows = mydb.Select(command);
         if (datarows == null)
         {
             logger.Add("Не удалось подключиться к базе данных");
             throw new FilePathIsNullException();
         }
         foreach (var dr in from DataRow dr in datarows select dr)
         {
             contains = (byte[])dr["Contains"];
         }
         return(contains);
     }
     catch
     {
         throw new FilePathIsNullException();;
     }
 }
示例#4
0
 /// <summary>Список метаданных файлов приложения</summary><param name="ver"></param>
 public IList <FileOfVersion> FindFileOfVersions(AppVersion ver)// попробовать рпеределать не по индексу а по ключу
 {
     try
     {
         mydb = new DB.SQLite.SQLite(BDPath);
         SQLiteCommand command = new SQLiteCommand();
         command.CommandText = "SELECT * FROM FilesContains WHERE Applications = @Applications";
         command.Parameters.Add("@Applications", DbType.String).Value = ver.VersionName;
         DataRow[] datarows = mydb.Select(command);
         if (datarows == null)
         {
             logger.Add("Не удалось подключиться к базе данных");
             throw new FilePathIsNullException();
         }
         string[]      versss = (from vers in datarows orderby vers.ItemArray[0] descending select vers.ItemArray[1].ToString()).ToArray();//поиск наибольшей версии
         VersionNumber Vers;
         VersionNumber.TryParse(versss[0], out Vers);
         List <FileOfVersion> fileApp = new List <FileOfVersion>();
         foreach (var dr in from DataRow dr in datarows where Vers.ToString() == dr["AppVersions"].ToString().Trim() select dr)// Заполнение списка мета данных файлов
         {
             FileOfVersion verss = new FileOfVersion(dr["FilePath"].ToString(),
                                                     (byte[])dr["Contains"], File.GetCreationTime(dr["FilePath"].ToString()));
             fileApp.Add(verss);
         }
         return(fileApp);
     }
     catch (VersionInFileSystemRepo.FilePathIsNullException ex)
     {
         logger.Add(ex);
         throw new FilePathIsNullException();
     }
 }
        /// <summary>Получение описания приложения</summary><param name="appName"></param><param name="appVersion"></param><returns>discription</returns>
        public string GetDiscription(string appName, string appVersion)
        {
            mydb = new DB.SQLite.SQLite(BDPath);
            string        flag        = "True";
            string        discription = "";
            SQLiteCommand command     = new SQLiteCommand();

            command.CommandText = "SELECT * FROM ApplicationInfo WHERE Flag = @Flag AND Application = @Application AND AppVersion = @AppVersion";
            command.Parameters.Add("@Flag", DbType.String).Value        = flag;
            command.Parameters.Add("@Application", DbType.String).Value = appName;
            command.Parameters.Add("@Application", DbType.String).Value = appVersion;
            DataRow[] datarows = mydb.Select(command);
            if (datarows == null)
            {
                throw new Exception();
            }
            foreach (DataRow dr in datarows)
            {
                discription = dr["AppDiscription"].ToString();
            }
            return(discription);
        }
        /// <summary>Получение имени исполняемого файла приложения</summary><param name="appName"></param><param name="appVersion"></param><returns></returns>
        public string GetNameExe(string appName, string appVersion)
        {
            mydb = new DB.SQLite.SQLite(BDPath);
            string        flag    = "True";
            SQLiteCommand command = new SQLiteCommand();

            command.CommandText = "SELECT * FROM ApplicationInfo WHERE Flag = @Flag AND Application = @Application AND AppVersion = @AppVersion";
            command.Parameters.Add("@Flag", DbType.String).Value        = flag;
            command.Parameters.Add("@Application", DbType.String).Value = appName;
            command.Parameters.Add("@AppVersion", DbType.String).Value  = appVersion;
            DataRow[] datarows = mydb.Select(command);
            if (datarows == null)
            {
                throw new Exception();
            }
            string name = "";

            foreach (var info in datarows)
            {
                name = info["Name_EXE"].ToString();
            }
            return(name);
        }