Esempio n. 1
0
        private void ReloadApps(string search = "")
        {
            string str;

            try
            {
                str = (Operators.CompareString(search, "", false) != 0 ? string.Concat("select * from list_app where name like '%", search, "%' order by name") : "select * from list_app order by name");
                SQLiteDataReader sQLiteDataReader = (new SQLiteCommand(str, AppConst.m_dbConnection)).ExecuteReader();
                this.lstApps.Clear();
                this.lstApps.Columns.Add("Apps", checked (base.Width - 30));
                WebClient webClient = new WebClient();
                while (sQLiteDataReader.Read())
                {
                    ExtraData extraDatum = new ExtraData()
                    {
                        DescText     = Conversions.ToString(sQLiteDataReader.get_Item("description")),
                        HeaderText   = Conversions.ToString(sQLiteDataReader.get_Item("name")),
                        MinorText    = Conversions.ToString(Operators.AddObject(Operators.AddObject(string.Concat("from ", Strings.Trim(AppConst.m_lstCydiaRepos[Conversions.ToInteger(sQLiteDataReader.get_Item("cydia_repos"))]), " ["), sQLiteDataReader.get_Item("section")), "]")),
                        AppDetailObj = new AppInfos()
                    };
                    AppInfos appDetailObj = extraDatum.AppDetailObj;
                    appDetailObj.Icon         = sQLiteDataReader.get_Item("icon").ToString();
                    appDetailObj.Architecture = sQLiteDataReader.get_Item("arch").ToString();
                    appDetailObj.Author       = sQLiteDataReader.get_Item("author").ToString();
                    appDetailObj.Depends      = sQLiteDataReader.get_Item("depends").ToString();
                    appDetailObj.Description  = sQLiteDataReader.get_Item("description").ToString();
                    appDetailObj.Filename     = sQLiteDataReader.get_Item("filename").ToString();
                    appDetailObj.Homepage     = sQLiteDataReader.get_Item("homepage").ToString();
                    appDetailObj.Name         = sQLiteDataReader.get_Item("name").ToString();
                    appDetailObj.Package      = sQLiteDataReader.get_Item("package").ToString();
                    appDetailObj.Section      = sQLiteDataReader.get_Item("section").ToString();
                    appDetailObj.Size         = sQLiteDataReader.get_Item("size").ToString();
                    appDetailObj.Version      = sQLiteDataReader.get_Item("version").ToString();
                    appDetailObj = null;
                    if (!(Operators.CompareString(extraDatum.AppDetailObj.Icon, "", false) != 0 & extraDatum.AppDetailObj.Icon.StartsWith("http")))
                    {
                        extraDatum.MainImage = new Bitmap(string.Concat(AppConst.m_rootPath, "\\res\\/apptype_tweak.png"));
                    }
                    else
                    {
                        extraDatum.MainImage = (Bitmap)Image.FromStream(new MemoryStream(webClient.DownloadData(extraDatum.AppDetailObj.Icon)));
                    }
                    this.lstApps.Items.Add("").Tag = extraDatum;
                }
            }
            catch (Exception exception)
            {
                ProjectData.SetProjectError(exception);
                Interaction.MsgBox(exception.Message, MsgBoxStyle.OkOnly, null);
                ProjectData.ClearProjectError();
            }
        }
        public void showApp(AppInfos appinfo)
        {
            ItuneResult ituneResult;

            this.appDetailInfo = appinfo;
            WebClient webClient = new WebClient();

            this.lblAppName.Text  = this.appDetailInfo.Name;
            this.lblAuthor.Text   = this.appDetailInfo.Author;
            this.lblCategory.Text = this.appDetailInfo.Section;
            this.lblVersion.Text  = this.appDetailInfo.Version;
            try
            {
                string str = webClient.DownloadString(string.Concat("https://itunes.apple.com/lookup?id=", this.appDetailInfo.Package));
                ituneResult = JsonConvert.DeserializeObject <ItuneResult>(str);
            }
            catch (Exception exception)
            {
                ProjectData.SetProjectError(exception);
                Interaction.MsgBox("Cannot get app information", MsgBoxStyle.OkOnly, null);
                ProjectData.ClearProjectError();
                return;
            }
            WebClient webClient1 = new WebClient();

            if (ituneResult.resultCount <= 0)
            {
                this.appDetailInfo.Size        = "";
                this.appDetailInfo.Description = "";
            }
            else
            {
                this.appDetailInfo.Size         = ituneResult.results.ElementAt <AppleAppInfo>(0).fileSizeBytes;
                this.appDetailInfo.Description  = ituneResult.results.ElementAt <AppleAppInfo>(0).description.Replace("\n", "\r\n");
                this.appDetailInfo.Architecture = ituneResult.results.ElementAt <AppleAppInfo>(0).minimumOsVersion;
                long num = Conversions.ToLong(this.appDetailInfo.Size);
                if ((double)num / 1024 / 1024 / 1024 > 1)
                {
                    this.lblSize.Text = string.Concat(Conversions.ToString(Math.Round((double)num / 1024 / 1024 / 1024, 2)), " GB");
                }
                else if ((double)num / 1024 / 1024 <= 1)
                {
                    this.lblSize.Text = string.Concat(Conversions.ToString(Math.Round((double)num / 1024, 2)), " KB");
                }
                else
                {
                    this.lblSize.Text = string.Concat(Conversions.ToString(Math.Round((double)num / 1024 / 1024, 2)), " MB");
                }
                this.pic1.Image = Image.FromStream(new MemoryStream(webClient1.DownloadData(ituneResult.results.ElementAt <AppleAppInfo>(0).screenshotUrls.ElementAt <string>(0))));
                this.pic2.Image = Image.FromStream(new MemoryStream(webClient1.DownloadData(ituneResult.results.ElementAt <AppleAppInfo>(0).screenshotUrls.ElementAt <string>(1))));
                this.pic3.Image = Image.FromStream(new MemoryStream(webClient1.DownloadData(ituneResult.results.ElementAt <AppleAppInfo>(0).screenshotUrls.ElementAt <string>(2))));
                this.pic4.Image = Image.FromStream(new MemoryStream(webClient1.DownloadData(ituneResult.results.ElementAt <AppleAppInfo>(0).screenshotUrls.ElementAt <string>(3))));
            }
            if (!(Operators.CompareString(appinfo.Icon, "", false) != 0 & appinfo.Icon.StartsWith("http")))
            {
                this.imgApp.Image = new Bitmap(string.Concat(AppConst.m_rootPath, "\\res\\/apptype_tweak.png"));
            }
            else
            {
                this.imgApp.Image = Image.FromStream(new MemoryStream(webClient1.DownloadData(appinfo.Icon)));
            }
            this.lblSupport.Text = this.appDetailInfo.Architecture;
            this.txtDesc.Text    = this.appDetailInfo.Description;
            base.ShowDialog();
        }
        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();
        }