Exemplo n.º 1
0
    private static void DumpKey(TGroup group, bool exact)
    {
        string    keyName = exact ? "exact" : "float";
        SqlSelect select  = new SqlSelect(group.Table, null);

        try
        {
            if (group.Table == "T_LINK_WIND")
            {
                Console.Write("");
            }

            if (exact)
            {
                group.AddExact(select);
            }
            else
            {
                group.AddFloat(select);
            }

            Console.WriteLine(String.Format("{0}: {1}: {2}", group.Table, keyName, select.ToString()));
        }
        catch (NotImplementedException)
        {
            Console.WriteLine("{0}: {1}: SELECT * FROM {0} [ni]", group.Table, keyName);
        }
        catch (Exception ex)
        {
            Console.WriteLine(String.Format("{0}: failed to add {1}", group.Table, keyName));
            Console.WriteLine(ex.ToString());
        }
    }
Exemplo n.º 2
0
    private static void DumpKeys()
    {
        foreach (string tableName in TableNames)
        {
            try
            {
                Type   type  = Type.GetType(tableName);
                TGroup group = (TGroup)Activator.CreateInstance(type);

                DumpKey(group, true);
                DumpKey(group, false);
            }
            catch (Exception ex)
            {
                Console.WriteLine(tableName + ": failed to create group");
                Console.WriteLine(ex.ToString());
            }
        }

        TSubpoena subpoena = new TSubpoena();
        SqlSelect select   = new SqlSelect(subpoena.Table, null);

        subpoena.AddRegard(select, false);
        Console.WriteLine("T_SUBPOENA: regard: {0}", select.ToString());

        select = new SqlSelect(subpoena.Table, null);
        subpoena.AddMulti(select);
        Console.WriteLine("T_SUBPOENA: multi: {0}", select.ToString());
    }
Exemplo n.º 3
0
 internal void From(SqlSelect nestedSelect)
 {
     _compiler.Unique(Q.From, "(", nestedSelect.ToString(), ")");
 }
Exemplo n.º 4
0
        //                        0                    1                    2                     3                      4                       5                        6                              7                         8
        public void DoUpdate(string sConnectionString)
        {
            // get the set of books that we want to update
            TCore.Sql sql;

            SqlSelect sqls        = new SqlSelect(s_sBaseQuery, s_mpAliases);
            SqlWhere  swInnerJoin = new SqlWhere();

            swInnerJoin.Add("$$upc_dvd$$.ScanCode = $$upc_codes$$.ScanCode", SqlWhere.Op.And);
            sqls.AddInnerJoin(new SqlInnerJoin("$$#upc_codes$$", swInnerJoin));

            UpdateStatus flagsToUpdate = UpdateStatus.MediaType | UpdateStatus.Title | UpdateStatus.Categories | UpdateStatus.CoverSrc | UpdateStatus.Summary;

            if (m_config.ForceUpdateSummary)
            {
                flagsToUpdate |= UpdateStatus.Summary;
            }

            // we want to match any entry that hasn't tried to update ALL of our fields. (if they have tried some,
            // but not others, then try again. after all, we might know more fields now that we want to update.
            sqls.Where.Add($"$$upc_dvd$$.UpdateStatus & {(int)flagsToUpdate} <> {(int)flagsToUpdate}", SqlWhere.Op.And);
            sqls.Where.StartGroup(SqlWhere.Op.And);
            sqls.Where.Add(String.Format("$$upc_dvd$$.LastUpdate < '{0}'", DateTime.Now.ToString("d")), SqlWhere.Op.And);
            sqls.Where.Add("$$upc_dvd$$.LastUpdate IS NULL", SqlWhere.Op.Or);
            sqls.Where.EndGroup();

            // and lets update the latest scanned items first
            sqls.AddOrderBy("$$upc_codes$$.LastScanDate DESC");

            SR sr = Sql.OpenConnection(out sql, sConnectionString);

            if (!sr.Succeeded)
            {
                throw new Exception(sr.Reason);
            }

            // from this point on, we have to release the sql connection!!
            int cFailed = 0;

            try
            {
                sr = Sql.ExecuteQuery(sql, sqls.ToString(), this, null);

                if (!sr.Succeeded)
                {
                    throw new Exception(sr.Reason);
                }

                foreach (DvdElementEx dvdex in m_plDvd)
                {
                    string sError;

                    Console.WriteLine($"Trying to scrape dvd {dvdex.ScanCode}: {dvdex.Title}...");
                    DVD.ScrapeSet scrapedSet = 0;

                    if (m_config.ForceUpdateSummary)
                    {
                        dvdex.Summary = null;
                    }

                    if (DVD.FScrapeDvd(dvdex, out scrapedSet, out sError))
                    {
                        // we might not have scraped everything, but we scraped something...

                        if (scrapedSet.HasFlag(DVD.ScrapeSet.CoverSrc) && !DownloadCoverForDvd(dvdex, m_config.LocalCoverRoot, "covers", out sError))
                        {
                            Console.WriteLine($"FAILED: to download cover art: {sError}");
                            LogDvdUpdateError(dvdex, scrapedSet, sError);
                        }
                        else
                        {
                            Console.WriteLine(
                                $"SUCCEEDED: MediaType: {dvdex.MediaType}, Classification: {dvdex.Classification}");
                            AddDVDToUpdateQueue(dvdex, scrapedSet);
                        }
                    }
                    else
                    {
                        Console.WriteLine($"FAILED: {sError}");
                        LogDvdUpdateError(dvdex, scrapedSet, sError);
                        cFailed++;
                        if (cFailed > 150)
                        {
                            throw new Exception("giving up");
                        }
                    }
                }
            }
            finally
            {
                sql.Close();
            }
        }