Exemple #1
0
        private AppVersion Result(SQLiteCommand command)
        {
            string appVersion = "";
            string app_name   = "";

            DataRow[] datarows = clientControl.Select(command);
            if (datarows == null)
            {
                logger.Add("Не удалось подключиться к базе данных");
                throw new FilePathIsNullException();
            }
            string[]      versss = (from vers in datarows orderby vers.ItemArray[0] descending select vers.ItemArray[0].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["AppVersion"].ToString().Trim() select dr)
            {
                app_name   = dr["Applications"].ToString();
                appVersion = dr["AppVersion"].ToString().Trim();
                FileOfVersion verss = new FileOfVersion(dr["FileHash"].ToString().Trim(), Convert.ToDateTime(dr["CreationDate"].ToString().Trim()), new AppFileSize(Convert.ToInt32(dr["FileSize"].ToString().Trim())), dr["FilePath"].ToString().Trim());
                fileApp.Add(verss);
            }
            VersionNumber version;

            VersionNumber.TryParse(appVersion, out version);
            AppVersion res = new AppVersion(app_name, version, fileApp);

            return(res);
        }
Exemple #2
0
        /// <summary>Получение версии приложения</summary><param name="appName"></param><returns></returns>
        public AppVersion GetAppVersion(string appName)
        {
            AppVersion AppVersions = null;

            clientControl = new ClientControlService(Address, Port);
            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 = clientControl.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);
        }
Exemple #3
0
 /// <summary>Получение настроек сообщения</summary><param name="appName"></param><param name="appVersion"></param><returns></returns>
 public AppVersionSetting GetSetting(string appName, string appVersion)
 {
     try
     {
         clientControl = new ClientControlService(Address, Port);
         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 = clientControl.Select(command);
         if (datarows == null)
         {
             throw new Exception();
         }
         AppVersionSetting result = new AppVersionSetting();
         foreach (var info in datarows)
         {
             result.ActialAppName    = info["Application"].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();
     }
 }
Exemple #4
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();
        }
Exemple #5
0
        /// <summary>Получение описания приложения</summary><param name="appName"></param><param name="appVersion"></param><returns></returns>
        public string GetDiscription(string appName, string appVersion)
        {
            clientControl = new ClientControlService(Address, Port);
            SQLiteCommand command = new SQLiteCommand();

            command.CommandText = "SELECT * FROM ApplicationInfo WHERE Flag = @Flag AND Application = @Application AND AppVersion = @AppVersion";
            string flag = "True";

            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 = clientControl.Select(command);
            if (datarows == null)
            {
                throw new Exception();
            }
            string discription = "";

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