public static void SaveAccount(string appId, string pass)
        {
            string        str           = Common.AES_Encrypt(pass, string.Concat(AppConst.m_randomKey, appId));
            string        str1          = "select * from account where appleId=@appleId";
            SQLiteCommand sQLiteCommand = new SQLiteCommand(str1, AppConst.m_dbConnection);

            sQLiteCommand.get_Parameters().AddWithValue("@appleId", appId);
            AppConst.logger.Debug(string.Concat("SaveAccount: 1. ", str1, ", ", appId));
            SQLiteDataReader sQLiteDataReader = sQLiteCommand.ExecuteReader();

            if (!sQLiteDataReader.Read())
            {
                str1          = "INSERT INTO account(appleId, password) VALUES(@appleId, @password)";
                sQLiteCommand = new SQLiteCommand(str1, AppConst.m_dbConnection);
                SQLiteParameterCollection parameters = sQLiteCommand.get_Parameters();
                parameters.AddWithValue("@appleId", appId);
                parameters.AddWithValue("@password", str);
                parameters = null;
                AppConst.logger.Debug(string.Concat(new string[] { "SaveAccount: 3. ", str1, ", ", appId, ",", str }));
                sQLiteCommand.ExecuteNonQuery();
            }
            else if (!Operators.ConditionalCompareObjectEqual(sQLiteDataReader.get_Item("password"), str, false))
            {
                str1          = "UPDATE account SET appleId=@appleId, password=@password";
                sQLiteCommand = new SQLiteCommand(str1, AppConst.m_dbConnection);
                SQLiteParameterCollection sQLiteParameterCollection = sQLiteCommand.get_Parameters();
                sQLiteParameterCollection.AddWithValue("@appleId", appId);
                sQLiteParameterCollection.AddWithValue("@password", str);
                sQLiteParameterCollection = null;
                AppConst.logger.Debug(string.Concat(new string[] { "SaveAccount: 2. ", str1, ", ", appId, ",", str }));
                sQLiteCommand.ExecuteNonQuery();
            }
        }
示例#2
0
 public void AddToParameters(SQLiteParameterCollection parameters)
 {
     parameters.Clear();
     parameters.AddWithValue("id", this.Id);
     parameters.AddWithValue("text", this.Text);
     parameters.AddWithValue("lang", this.Language);
     parameters.AddWithValue("trans_of", this.TranslationOf);
 }
示例#3
0
        void ProcessAirBasePlaneDeploymentConsumption(StringBuilder rpBuilder, SQLiteParameterCollection rpParameters, MapInfo rpMap, AirForceGroup[] rpGroups)
        {
            var rStatement = string.Join(", ", rpGroups.Select(r => r.ID));

            rpBuilder.AppendFormat("INSERT OR IGNORE INTO sortie_consumption_detail(id, type, bauxite) VALUES(@id, 3, (SELECT sum(bauxite) FROM airbase_plane_deployment_consumption WHERE area = @area AND [group] IN ({0})));{1}" +
                                   "DELETE FROM sortie_consumption_detail WHERE id = @id AND type = 3 AND bauxite IS NULL;{1}" +
                                   "DELETE FROM airbase_plane_deployment_consumption WHERE area = @area AND [group] IN ({0});", rStatement, Environment.NewLine);
            rpBuilder.AppendLine();
            rpParameters.AddWithValue("@area", rpMap.MasterInfo.AreaID);
            rpParameters.AddWithValue("@group", rpMap.AvailableAirBaseGroupCount);
        }
示例#4
0
        public override string Build(SQLiteParameterCollection parameters)
        {
            string parameter_name = "@CONSTANT_" + id;

            parameters.AddWithValue(parameter_name, constant);
            return(parameter_name);
        }
 /// <summary>
 ///     A SQLiteParameterCollection extension method that adds a range with value to 'values'.
 /// </summary>
 /// <param name="this">The @this to act on.</param>
 /// <param name="values">The values.</param>
 public static void AddRangeWithValue(this SQLiteParameterCollection @this, Dictionary <string, object> values)
 {
     foreach (var keyValuePair in values)
     {
         @this.AddWithValue(keyValuePair.Key, keyValuePair.Value);
     }
 }
示例#6
0
        public static void AddIfSet(
            this SQLiteParameterCollection parameters,
            string paramName,
            string[] tokens,
            int index,
            Func <string, string> modifier = null)
        {
            if (index >= tokens.Length)
            {
                return;
            }

            if (!string.IsNullOrWhiteSpace(tokens[index]) && tokens[index] != "\\N")
            {
                var value = tokens[index];
                if (modifier != null)
                {
                    value = modifier(value);
                }

                if (string.IsNullOrWhiteSpace(value))
                {
                    return;
                }

                parameters.AddWithValue(paramName, value);
            }
        }
示例#7
0
 /// <summary>
 /// Adds a parameter to the given parameter collection, serialising to the types respective DB type, performing serialisation as needed
 /// </summary>
 /// <param name="paramName"></param>
 /// <param name="reflectedValueInfo"></param>
 /// <param name="queryParameters"></param>
 private void AddValueToQueryParameters(string paramName, ReflectedValueInfo reflectedValueInfo, SQLiteParameterCollection queryParameters)
 {
     if (reflectedValueInfo.IsNull == true)
     {
         queryParameters.AddWithValue(paramName, DBNull.Value);
     }
     else if (reflectedValueInfo.ValueType == typeof(DateTime))
     {
         queryParameters.AddWithValue(paramName, DateTimeToISO8601String((DateTime)reflectedValueInfo.Value));
     }
     else if (reflectedValueInfo.ValueType == typeof(DateTimeOffset))
     {
         queryParameters.AddWithValue(paramName, DateTimeOffsetToString((DateTimeOffset)reflectedValueInfo.Value));
     }
     else if (reflectedValueInfo.ValueType == typeof(decimal))
     {
         queryParameters.AddWithValue(paramName, ValueToLosslessDecimal((decimal)reflectedValueInfo.Value));
     }
     else if (reflectedValueInfo.ValueType == typeof(TimeSpan))
     {
         queryParameters.AddWithValue(paramName, TimeSpanToString((TimeSpan)reflectedValueInfo.Value));
     }
     else if (reflectedValueInfo.ValueType == typeof(Guid))
     {
         queryParameters.AddWithValue(paramName, reflectedValueInfo.Value.ToString());
     }
     else if (reflectedValueInfo.ValueType == typeof(uint))
     {
         var byteValue = BitConverter.GetBytes((uint)reflectedValueInfo.Value);
         queryParameters.AddWithValue(paramName, byteValue);
     }
     else if (reflectedValueInfo.ValueType == typeof(ulong))
     {
         var byteValue = BitConverter.GetBytes((ulong)reflectedValueInfo.Value);
         queryParameters.AddWithValue(paramName, byteValue);
     }
     else if (reflectedValueInfo.ValueType == typeof(char))
     {
         // Chars are stored as a byte pair BLOB to reduce string conversions
         queryParameters.AddWithValue(paramName, BitConverter.GetBytes((char)reflectedValueInfo.Value));
     }
     else
     {
         queryParameters.AddWithValue(paramName, reflectedValueInfo.Value);
     }
 }
示例#8
0
 private void SetParam <T>(string name, T value, SQLiteParameterCollection param)
 {
     if (!param.Contains(name))
     {
         param.AddWithValue(name, value);
         return;
     }
     param[name].Value = value;
 }
示例#9
0
        void ProcessAirForceGroupSortieConsumption(StringBuilder rpBuilder, SQLiteParameterCollection rpParameters, AirForceGroup[] rpGroups)
        {
            var rFuelConsumption   = 0;
            var rBulletConsumption = 0;

            foreach (var rGroup in rpGroups)
            {
                rFuelConsumption   += rGroup.LBASFuelConsumption;
                rBulletConsumption += rGroup.LBASBulletConsumption;
            }

            if (rFuelConsumption == 0 && rBulletConsumption == 0)
            {
                return;
            }

            rpBuilder.AppendLine("INSERT OR IGNORE INTO sortie_consumption_detail(id, type, fuel, bullet) VALUES(@id, 4, @afgs_fuel, @afgs_bullet);");
            rpParameters.AddWithValue("@afgs_fuel", rFuelConsumption);
            rpParameters.AddWithValue("@afgs_bullet", rBulletConsumption);
        }
示例#10
0
        public static void AddIfSet(
            this SQLiteParameterCollection parameters,
            string paramName,
            string value,
            Func <string, string> modifier = null)
        {
            if (modifier != null)
            {
                value = modifier(value);
            }

            parameters.AddWithValue(paramName, value);
        }
        public static void updateInstalledApp(string package, string appleId, string fileIpa, string udid)
        {
            TimeSpan                  utcNow;
            SQLiteCommand             sQLiteCommand = new SQLiteCommand("select * from list_installed_app where installed_appleid_email=@appleId AND package=@package AND udid=@udid", AppConst.m_dbConnection);
            SQLiteParameterCollection parameters    = sQLiteCommand.get_Parameters();

            parameters.AddWithValue("@appleId", appleId);
            parameters.AddWithValue("@package", package);
            parameters.AddWithValue("@udid", udid);
            parameters = null;
            if (sQLiteCommand.ExecuteReader().Read())
            {
                sQLiteCommand = new SQLiteCommand("UPDATE list_installed_app SET file_ipa=@fileIpa, installed_time=@timenow WHERE installed_appleid_email=@appleId AND package=@package AND udid=@udid", AppConst.m_dbConnection);
                SQLiteParameterCollection sQLiteParameterCollection = sQLiteCommand.get_Parameters();
                sQLiteParameterCollection.AddWithValue("@fileIpa", fileIpa);
                utcNow = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0);
                sQLiteParameterCollection.AddWithValue("@timenow", utcNow.TotalSeconds);
                sQLiteParameterCollection.AddWithValue("@appleId", appleId);
                sQLiteParameterCollection.AddWithValue("@package", package);
                sQLiteParameterCollection.AddWithValue("@udid", udid);
                sQLiteParameterCollection = null;
                sQLiteCommand.ExecuteNonQuery();
            }
            else
            {
                sQLiteCommand = new SQLiteCommand("INSERT INTO list_installed_app(installed_appleid_email, package, file_ipa, installed_time, udid) VALUES(@appleId, @package, @fileIpa, @timenow, @udid)", AppConst.m_dbConnection);
                SQLiteParameterCollection parameters1 = sQLiteCommand.get_Parameters();
                parameters1.AddWithValue("@appleId", appleId);
                parameters1.AddWithValue("@package", package);
                parameters1.AddWithValue("@fileIpa", fileIpa);
                parameters1.AddWithValue("@udid", udid);
                utcNow = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0);
                parameters1.AddWithValue("@timenow", utcNow.TotalSeconds);
                parameters1 = null;
                sQLiteCommand.ExecuteNonQuery();
            }
        }
        public static void MapSQLiteParameters(this SQLiteParameterCollection sqliteParameter, string sql, params object[] parameters)
        {
            var paramsInSql = Regex.Matches(sql, "@[a-zA-Z0-9_]*").Cast <Match>().Select(match => match.Value).ToList();

            if (paramsInSql.Count != parameters.Length)
            {
                throw new ArgumentException($"No of argument in sql({paramsInSql.Count}) doesn't match with arguments in parameter list ({parameters?.Length})." +
                                            $" Require parameters : {string.Join(" , ", paramsInSql)}");
            }

            for (int i = 0; i < paramsInSql.Count; i++)
            {
                sqliteParameter.AddWithValue(paramsInSql[i], parameters[i]);
            }
        }
示例#13
0
 public static SQLiteParameterCollection AddSlidingExpirationInSeconds(this SQLiteParameterCollection parameters, TimeSpan?value) =>
 parameters.AddWithValue(Columns.Names.SlidingExpirationInSeconds, DbType.Int64, value.HasValue ? (object)value.Value.TotalSeconds : DBNull.Value);
示例#14
0
 public static SQLiteParameterCollection AddCacheItemValue(this SQLiteParameterCollection parameters, byte[] value) =>
 value != null && value.Length < DefaultValueColumnWidth
         ? parameters.AddWithValue(Columns.Names.CacheItemValue, DbType.Binary, DefaultValueColumnWidth, value)
         : parameters.AddWithValue(Columns.Names.CacheItemValue, DbType.Binary, value);
示例#15
0
 public static SQLiteParameterCollection AddCacheItemId(this SQLiteParameterCollection parameters, string value) =>
 parameters.AddWithValue(Columns.Names.CacheItemId, DbType.String, CacheItemIdColumnWidth, value);
示例#16
0
 public static void AddGuid(this SQLiteParameterCollection parmeters, string parameterName, Guid?guid)
 {
     parmeters.AddWithValue(parameterName, guid?.ToString("D"));
 }
        public static void ParsePackages(int cydiaId, UpdateCydia frm = null, object fn = null, string cydiaUrl = "")
        {
            string str = File.ReadAllText("Packages");

            string[]          strArrays         = str.Split(new string[] { "Package:" }, StringSplitOptions.RemoveEmptyEntries);
            string            str1              = "INSERT INTO list_app(cydia_repos,package,version,section,depends,arch,filename,size,icon,description,name,author,homepage) \r\n                                                VALUES(@cydia_repos,@package,@version,@section,@depends,@arch,@filename,@size,@icon,@description,@name,@author,@homepage)";
            SQLiteTransaction sQLiteTransaction = AppConst.m_dbConnection.BeginTransaction();
            int num  = Information.LBound(strArrays, 1);
            int num1 = Information.UBound(strArrays, 1);

            for (int i = num; i <= num1; i = checked (i + 1))
            {
                string[] strArrays1 = strArrays[i].Split(new char[] { '\n' });
                AppInfos appInfo    = new AppInfos()
                {
                    Package = Strings.Trim(strArrays1[0])
                };
                int num2 = Information.UBound(strArrays1, 1);
                for (int j = 1; j <= num2; j = checked (j + 1))
                {
                    string str2 = strArrays1[j];
                    if (str2.StartsWith("Section:"))
                    {
                        appInfo.Section = Strings.Trim(strArrays1[j].Substring(8));
                    }
                    else if (str2.StartsWith("Version:"))
                    {
                        appInfo.Version = Strings.Trim(strArrays1[j].Substring(8));
                    }
                    else if (str2.StartsWith("Depends:"))
                    {
                        appInfo.Depends = Strings.Trim(strArrays1[j].Substring(8));
                    }
                    else if (str2.StartsWith("Architecture:"))
                    {
                        appInfo.Architecture = Strings.Trim(strArrays1[j].Substring(13));
                    }
                    else if (str2.StartsWith("Filename:"))
                    {
                        appInfo.Filename = Strings.Trim(strArrays1[j].Substring(9));
                        if (!appInfo.Filename.StartsWith("http"))
                        {
                            appInfo.Filename = string.Concat(cydiaUrl, "/", appInfo.Filename);
                        }
                    }
                    else if (str2.StartsWith("Size:"))
                    {
                        appInfo.Size = Strings.Trim(strArrays1[j].Substring(5));
                    }
                    else if (str2.StartsWith("Icon:"))
                    {
                        appInfo.Icon = Strings.Trim(strArrays1[j].Substring(5));
                    }
                    else if (str2.StartsWith("Description:"))
                    {
                        appInfo.Description = Strings.Trim(strArrays1[j].Substring(12));
                    }
                    else if (str2.StartsWith("Name:"))
                    {
                        appInfo.Name = Strings.Trim(strArrays1[j].Substring(5));
                    }
                    else if (str2.StartsWith("Author:"))
                    {
                        appInfo.Author = Strings.Trim(strArrays1[j].Substring(7));
                    }
                    else if (str2.StartsWith("Homepage:"))
                    {
                        appInfo.Homepage = Strings.Trim(strArrays1[j].Substring(9));
                    }
                }
                SQLiteCommand             sQLiteCommand = new SQLiteCommand(str1, AppConst.m_dbConnection);
                SQLiteParameterCollection parameters    = sQLiteCommand.get_Parameters();
                parameters.AddWithValue("@cydia_repos", cydiaId);
                parameters.AddWithValue("@package", appInfo.Package);
                parameters.AddWithValue("@version", appInfo.Version);
                parameters.AddWithValue("@section", appInfo.Section);
                parameters.AddWithValue("@depends", appInfo.Depends);
                parameters.AddWithValue("@arch", appInfo.Architecture);
                parameters.AddWithValue("@filename", appInfo.Filename);
                parameters.AddWithValue("@size", appInfo.Size);
                parameters.AddWithValue("@icon", appInfo.Icon);
                parameters.AddWithValue("@description", appInfo.Description);
                parameters.AddWithValue("@name", appInfo.Name);
                parameters.AddWithValue("@author", appInfo.Author);
                parameters.AddWithValue("@homepage", appInfo.Homepage);
                parameters = null;
                sQLiteCommand.ExecuteNonQuery();
                if (i % 10 == 0)
                {
                    if (frm != null)
                    {
                        frm.Invoke((Delegate)fn, new object[] { "", checked ((int)Math.Round((double)(checked (i * 100)) / (double)Information.UBound(strArrays, 1))) });
                    }
                }
            }
            sQLiteTransaction.Commit();
        }
        private void cmdAdd_Click(object sender, EventArgs e)
        {
            string str = Interaction.InputBox("Enter URL of Cydia Repos", "Add Cydia Repos", "", -1, -1);

            if (Operators.CompareString(Strings.Trim(str), "", false) != 0)
            {
                if (!str.StartsWith("http"))
                {
                    str = string.Concat("http://", str);
                }
                int count = checked (this.lstCydia.Items.Count - 1);
                int num   = 0;
                while (num <= count)
                {
                    if (Operators.CompareString(this.lstCydia.Items[num].SubItems[1].Text, str, false) != 0)
                    {
                        num = checked (num + 1);
                    }
                    else
                    {
                        Interaction.MsgBox("Cydia existed!", MsgBoxStyle.OkOnly, "Error");
                        return;
                    }
                }
                File.Delete("Release.txt");
                string str1 = "Noname";
                try
                {
                    (new WebClient()).DownloadFile(string.Concat(str, "/Release"), "Release.txt");
                    string[] strArrays = File.ReadAllLines("Release.txt");
                    int      num1      = Information.LBound(strArrays, 1);
                    int      num2      = Information.UBound(strArrays, 1);
                    int      num3      = num1;
                    while (num3 <= num2)
                    {
                        if (!strArrays[num3].StartsWith("Label:"))
                        {
                            num3 = checked (num3 + 1);
                        }
                        else
                        {
                            str1 = strArrays[num3].Substring(6);
                            break;
                        }
                    }
                }
                catch (Exception exception)
                {
                    ProjectData.SetProjectError(exception);
                    ProjectData.ClearProjectError();
                }
                SQLiteCommand             sQLiteCommand = new SQLiteCommand("INSERT INTO cydia_repos(name, path) VALUES(@name, @path)", AppConst.m_dbConnection);
                SQLiteParameterCollection parameters    = sQLiteCommand.get_Parameters();
                parameters.AddWithValue("@name", str1);
                parameters.AddWithValue("@path", str);
                parameters = null;
                sQLiteCommand.ExecuteNonQuery();
                object objectValue = RuntimeHelpers.GetObjectValue(this.LoadCydiaRepos(str));
                CydiaRepoManager.LoadPackages(str);
                if (File.Exists("Packages"))
                {
                    CydiaRepoManager.ParsePackages(Conversions.ToInteger(objectValue), null, null, "");
                }
            }
            else
            {
                Interaction.MsgBox("Incorrect URL", MsgBoxStyle.OkOnly, "Error");
            }
        }
示例#19
0
 public static SQLiteParameterCollection AddAbsoluteExpiration(this SQLiteParameterCollection parameters, DateTimeOffset?utcTime) =>
 parameters.AddWithValue(Columns.Names.AbsoluteExpiration, DbType.DateTimeOffset, utcTime.HasValue ? (object)utcTime.Value.ToString("o") : DBNull.Value);
示例#20
0
 void ProcessAirForceGroupSortieConsumption(StringBuilder rpBuilder, SQLiteParameterCollection rpParameters, AirForceGroup[] rpGroups)
 {
     rpBuilder.AppendLine("INSERT OR IGNORE INTO sortie_consumption_detail(id, type, fuel, bullet) VALUES(@id, 4, @afgs_fuel, @afgs_bullet);");
     rpParameters.AddWithValue("@afgs_fuel", rpGroups.Sum(r => r.LBASFuelConsumption));
     rpParameters.AddWithValue("@afgs_bullet", rpGroups.Sum(r => r.LBASBulletConsumption));
 }
示例#21
0
 /// <summary>
 /// Adds a parameter to the parameterized SQLite query.
 /// Use this before executing the query.
 /// </summary>
 /// <param name="name">The name of the parameter</param>
 /// <param name="param">The value of the parameter</param>
 public static void AddParams(string name, object param)
 {
     parameters.AddWithValue(name, param);
 }
 public static void Add(this SQLiteParameterCollection @this, KeyValuePair <string, object> keyValuePair)
 {
     @this.AddWithValue(keyValuePair.Key, keyValuePair.Value);
 }