Example #1
0
 /// <summary>Сохранение метаданных</summary><param name="version"></param>
 public bool SaveApplication(AppVersion version)
 {
     try
     {
         clientControl = new ClientControlService(Address, Port);
         IVersionRepo       repo = new VersionInDBServerRepo("127.0.0.1", 8005);
         IList <AppVersion> apps = repo.FindAll(version.VersionName);
         if (apps.Count == 0)
         {
             SQLiteCommand command = new SQLiteCommand();
             command.CommandText = "INSERT INTO Applications (ApplicationName) VALUES(@ApplicationName)";
             command.Parameters.Add("@ApplicationName", DbType.String).Value = version.VersionName;
             clientControl.Insert(command);
         }
         for (int i = 0; i < version.Files.Count; i++)
         {
             clientControl = new ClientControlService(Address, Port);
             SQLiteCommand command1 = new SQLiteCommand();
             command1.CommandText = "INSERT INTO FilesVersions (AppVersions,FileHash,CreationDate,FileSize,FilePath,DateCreateDB,Applications)" +
                                    "VALUES(@AppVersions,@FileHash,@CreationDate,@FileSize,@FilePath,@DateCreateDB,@Applications)";
             command1.Parameters.Add("@AppVersions", DbType.String).Value  = version.VersionNumber.ToString();
             command1.Parameters.Add("@FileHash", DbType.String).Value     = version.Files[i].FileHash;
             command1.Parameters.Add("@CreationDate", DbType.String).Value = DateTime.Now.ToString();
             command1.Parameters.Add("@FileSize", DbType.Int32).Value      = version.Files[i].FileSize.FileSize;
             command1.Parameters.Add("@FilePath", DbType.String).Value     = version.Files[i].FilePath;
             command1.Parameters.Add("@DateCreateDB", DbType.String).Value = DateTime.Now.ToString();
             command1.Parameters.Add("@Applications", DbType.String).Value = version.VersionName;
             clientControl.Insert(command1);
         }
         clientControl = new ClientControlService(Address, Port);
         SQLiteCommand command2 = new SQLiteCommand();
         command2.CommandText = "INSERT INTO ApplicationInfo (Application,AppVersion)VALUES(@Applications,@AppVersions)";
         command2.Parameters.Add("@Applications", DbType.String).Value = version.VersionName;
         command2.Parameters.Add("@AppVersions", DbType.String).Value  = version.VersionNumber.ToString();
         clientControl.Insert(command2);
         logger.Add("Запись добавлена!");
         return(true);
     }
     catch (SaveException ex)
     {
         logger.Add(ex);
         throw new SaveException();
     }
 }
Example #2
0
 /// <summary>Сохранение настроек приложения</summary><param name="versionSetting"></param><returns></returns>
 public bool SaveSetting(AppVersionSetting versionSetting)
 {
     try
     {
         clientControl = new ClientControlService(Address, Port);
         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;
         clientControl.Insert(command);
         return(true);
     }
     catch (Exception ex)
     {
         throw new Exception();
     }
 }
Example #3
0
        static string address = "192.168.1.2"; // адрес сервера
        static void Main(string[] args)
        {
            ClientControlService clientControl = new ClientControlService(address, port);
            SQLiteCommand        command       = new SQLiteCommand();

            command.CommandText = "INSERT INTO Applications (ApplicationName) VALUES(@ApplicationName)";
            command.Parameters.Add("@ApplicationName", DbType.String).Value = "Test21";
            var           test1    = clientControl.Insert(command);
            SQLiteCommand command1 = new SQLiteCommand();

            command1.CommandText = "SELECT * FROM FilesVersions";
            var           test2    = clientControl.Select(command1);
            SQLiteCommand command2 = new SQLiteCommand();

            command2.CommandText = "Update ApplicationInfo set AppDiscription=@AppDiscription,Flag=@Flag WHERE Application=@Application AND AppVersion=@AppVersion";
            command2.Parameters.Add("@AppDiscription", DbType.String).Value = "";
            command2.Parameters.Add("@Flag", DbType.String).Value           = "False";
            command2.Parameters.Add("@Application", DbType.String).Value    = "TestA";
            command2.Parameters.Add("@AppVersion", DbType.String).Value     = "1_b0";
            var test3 = clientControl.Update(command2);

            Console.WriteLine();
        }