/// <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();
     }
 }
Beispiel #2
0
        ///<summary>Загрука настроек из файла</summary>
        private void Settings_Loaded(object sender, RoutedEventArgs e)
        {
            IDiscriptionApp   discription = new DiscriptionAppInServer("127.0.0.1", 8005);
            AppVersionSetting appSetting  = discription.GetSetting(AppName, AppVers);

            Discription.Text = appSetting.AppDiscription;
            switch (appSetting.ActialFlag)
            {
            case "True":
                Check.IsChecked = true;
                break;

            case "False":
                Check.IsChecked = false;
                break;
            }
            FileInDBServerRepo repo = new FileInDBServerRepo("127.0.0.1", 8005);

            VersionNumber.TryParse(AppVers, out VersionNumber number);
            IList <FileOfVersion> testfile = repo.FindFileOfVersions(new AppVersion(AppName, number));
            List <string>         fileName = new List <string>();

            for (int i = 0; i < testfile.Count; i++)
            {
                fileName.Add(testfile[i].FilePath);
            }
            exeFile.ItemsSource = (fileName);
            exeFile.Text        = appSetting.NameExe;
            AppText.Text        = "Настройки приложения: " + AppName + " " + number.ToString();
        }
Beispiel #3
0
        ///<summary>Сохранение настроек в файл</summary>
        private void SaveSetting_Click(object sender, RoutedEventArgs e)
        {
            IDiscriptionApp   discription = new DiscriptionAppInServer("127.0.0.1", 8005);
            AppVersionSetting appSetting  = discription.GetSetting(AppName, AppVers);

            appSetting.ActialAppName    = AppName;
            appSetting.ActialAppVersion = AppVers;
            appSetting.AppDiscription   = Discription.Text;
            appSetting.ActialFlag       = Check.IsChecked.Value.ToString();
            appSetting.NameExe          = exeFile.Text;
            discription.SaveSetting(appSetting);
            Close();
        }
 /// <summary>Сохранение настроек приложения</summary><param name="versionSetting"></param><returns></returns>
 public bool SaveSetting(AppVersionSetting versionSetting)
 {
     try
     {
         mydb = new DB.SQLite.SQLite(BDPath);
         SQLiteCommand command = new SQLiteCommand();
         command.CommandText = "Update ApplicationInfo set AppDiscription = @AppDiscription, Flag=@Flag, Name_EXE = @EXE WHERE Application = @Application AND AppVersion = @AppVersion";
         command.Parameters.Add("@AppDiscription", DbType.String).Value = versionSetting.AppDiscription;
         command.Parameters.Add("@Flag", DbType.String).Value           = versionSetting.ActialFlag;
         command.Parameters.Add("@Application", DbType.String).Value    = versionSetting.ActialAppName;
         command.Parameters.Add("@AppVersion", DbType.String).Value     = versionSetting.ActialAppVersion;
         command.Parameters.Add("@EXE", DbType.String).Value            = versionSetting.NameExe;
         mydb.Insert(command);
         return(true);
     }
     catch (Exception ex)
     {
         throw new Exception();
     }
 }