当前位置: 首页>>代码示例>>C++>>正文


C++ WApplication::internalPath方法代码示例

本文整理汇总了C++中wt::WApplication::internalPath方法的典型用法代码示例。如果您正苦于以下问题:C++ WApplication::internalPath方法的具体用法?C++ WApplication::internalPath怎么用?C++ WApplication::internalPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wt::WApplication的用法示例。


在下文中一共展示了WApplication::internalPath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setConnectionPool

/* ****************************************************************************
 * Menu Manager Session
 * appPath:
 * useDb:
 * lang: FIXME: default|lang1|lang2|lang3
 * connectionPool:
 */
MenuManSession::MenuManSession(const std::string& appPath, const std::string& useDb, const std::string& lang, Wt::Dbo::SqlConnectionPool& connectionPool) : appPath_(appPath), useDb_(useDb), lang_(lang), connectionPool_(connectionPool)
{
    if (useDb == "1")
    {
        setConnectionPool(connectionPool_);
        mapClass<MenuMan>("menuman"); // table name menuman
        Wt::WApplication* app = Wt::WApplication::instance();
        std::string path = app->internalPath(); // /lang/menuman/
        bool doXmlUpdate = false;
        // FIXME add security for logon or certificate
        // hard code /admin/menuman/updatexml for admin work
        if (path.find("/admin/menuman/updatexml") != std::string::npos) { doXmlUpdate = true; }
        //Wt::log("start") << " *** MenuManSession::MenuManSession() useDb | path = " << path << " | doXmlUpdate = " << doXmlUpdate << " *** ";
        if (CrystalBall::InitDb || doXmlUpdate)
        {
            try
            {
                Wt::Dbo::Transaction t(*this);
                // Note: you must drop table to do update
                if (doXmlUpdate)
                {
                    Wt::log("warning") << "MenuManSession::MenuManSession() SQL Drop Table menuman";
                    dropTables();
                }
                createTables();
                Wt::log("warning") << "Created database: menuman ";
                if (!ImportXML())
                {
                    Wt::log("error") << " *** MenuManSession::MenuManSession() ImportXML failed! *** ";
                    return;
                }
                t.commit();
            }
            catch (std::exception& e)
            {
                Wt::log("warning") << " *** MenuManSession::MenuManSession()  Using existing menuman database = " << e.what();
            }
        }
    } // end if (useDb == "1")
    //Wt::log("end") << " *** MenuManSession::MenuManSession() *** ";
} // end MenuManSession
开发者ID:WittyWizard,项目名称:install,代码行数:48,代码来源:MenuManSession.cpp

示例2: GetHits

/* ****************************************************************************
 * Get Hits
 */
std::string HitCounterManImpl::GetHits()
{
    // Create an instance of app to access Internal Paths
    Wt::WApplication* app = Wt::WApplication::instance();
    try
    {
        // Start a Transaction
        Wt::Dbo::Transaction t(session_);

        hits = session_.query<int>("select count(*) from hitcounterman").where("page = ?").bind(app->internalPath());
        //Wt::log("notice") << "HitCounterManImpl::GetHits()  hits = " << hits << " | page = " << app->internalPath();

        // Commit Transaction
        t.commit();    }
    catch (std::exception& e)
    {
        std::cerr << e.what() << std::endl;
        //Wt::log("error") << "HitCounterManImpl::GetHits()  Failed reading from hitcounterman database.";
        hits = 0;
    }

    try
    {
        Wt::WLocale myString = Wt::WLocale(theLocale.c_str());
        // Note: this only works if you set the Separator, use case to set it
        myString.setGroupSeparator(",");
        std::string myReturn = myString.toString(hits).toUTF8();
        return myReturn;
        /*
         * This requires locale to be installed and configured on server
        std::stringstream ss;
        ss.imbue(std::locale(theLocale.c_str()));
        ss << std::fixed << hits;
        return ss.str();
        */
    }
    catch (std::exception& e)
    {
        std::cerr << e.what() << std::endl;
        std::cerr << "HitCounterManImpl::GetHits: Failed local not installed";
        Wt::log("error") << "HitCounterManImpl::GetHits() Failed local not installed";
    }

    return std::to_string(hits);
} // end GetHits
开发者ID:WittyWizard,项目名称:install,代码行数:48,代码来源:HitCounterManImpl.cpp

示例3: Set

/* ****************************************************************************
 * Set
 */
void HitCounterManImpl::Set()
{
    // Create an instance of app to access Internal Paths
    Wt::WApplication* app = Wt::WApplication::instance();
    try
    {
        // Start a Transaction
        Wt::Dbo::Transaction t(session_);
        HitCounterMans myHitCounterMan = session_.find<HitCounterMan>();
        //
        hits = myHitCounterMan.size();
        //
        // Commit Transaction
        t.commit();
    }
    catch (std::exception& e)
    {
        std::cerr << e.what() << std::endl;
        std::cerr << "HitCounterManImpl::Update: Failed reading from hitcounterman database";
        Wt::log("error") << "HitCounterManImpl::Update()  Failed reading from hitcounterman database";
    }

    try
    {
        // Start a Transaction
        Wt::Dbo::Transaction t(session_);
        //
        uniqueHits = session_.query<int>("select COUNT(distinct ipaddress) from hitcounterman").where("page = ?").bind(app->internalPath());;
        // Commit Transaction
        t.commit();
    }
    catch (std::exception& e)
    {
        std::cerr << e.what() << std::endl;
        std::cerr << "HitCounterManImpl::Update: Failed reading from hitcounterman database";
        Wt::log("error") << "HitCounterManImpl::Update()  Failed reading from hitcounterman database";
    }

} // end
开发者ID:WittyWizard,项目名称:install,代码行数:42,代码来源:HitCounterManImpl.cpp


注:本文中的wt::WApplication::internalPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。