Exemple #1
0
void db_set_panel::Save(void){
    confi->Write(_T("/mysql/host"), TextCtrl1->GetValue());
    confi->Write(_T("/mysql/user"), TextCtrl2->GetValue());
    confi->Write(_T("/mysql/pass"), TextCtrl3->GetValue());
    confi->Write(_T("/mysql/dbase"), TextCtrl4->GetValue());
    confi->Write(_T("/program/run"), _T("1"));

if(CheckBox1->GetValue())
    confi->Write(_T("/program/run_again"), _T("1"));
    else
    confi->Write(_T("/program/run_again"), _T("0"));



if(dbase_connected == false){
conn->connect("", wx2std(TextCtrl1->GetValue(),wxConvUI).c_str(),wx2std(TextCtrl2->GetValue(),wxConvUI).c_str(),wx2std(TextCtrl3->GetValue(),wxConvUI).c_str());
   if (*conn)
    {
         dbase_connected = true;
}
    else
    {
       wxMessageBox(std2wx(conn -> error(),wxConvUI));
        dbase_connected = false;
    }
}




    }
bool FieldPropertiesDialog::getNotNullConstraintName(const wxString& fieldName,
    wxString& constraintName)
{
    if (DatabasePtr db = tableM->getDatabase())
    {
        wxMBConv* conv = db->getCharsetConverter();
        MetadataLoader* loader = db->getMetadataLoader();
        MetadataLoaderTransaction tr(loader);

        IBPP::Statement& st1 = loader->getStatement(
            "SELECT rc.RDB$CONSTRAINT_NAME FROM RDB$RELATION_CONSTRAINTS rc "
            "JOIN RDB$CHECK_CONSTRAINTS cc "
            "ON rc.RDB$CONSTRAINT_NAME = cc.RDB$CONSTRAINT_NAME "
            "WHERE rc.RDB$CONSTRAINT_TYPE = 'NOT NULL' "
            "AND rc.RDB$RELATION_NAME = ?"
            "AND cc.RDB$TRIGGER_NAME = ?");

        st1->Set(1, wx2std(tableM->getName_(), conv));
        st1->Set(2, wx2std(fieldName, conv));
        st1->Execute();
        if (st1->Fetch())
        {
            std::string s;
            st1->Get(1, s);
            constraintName = std2wxIdentifier(s, conv);
            return true;
        }
    }

    return false;
}
Exemple #3
0
int  kitchenFrame::connect_to_db(void)
{

    host = config->Read(_T("/mysql/host"));
    user = config->Read(_T("/mysql/user"));
    pass = config->Read(_T("/mysql/pass"));
    dbase = config->Read(_T("/mysql/dbase"));



    if (conn->connect(wx2std(dbase,wxConvUI).c_str(),wx2std(host,wxConvUI).c_str(),wx2std(user,wxConvUI).c_str(),wx2std(pass,wxConvUI).c_str()))
    {
        StatusBar1->SetStatusText(_("Connected to the database."));
//        dbase_connected = true;
        return 0;
    }
    else
    {
        StatusBar1->SetStatusText(_("Unable no connect to database '") + dbase + _("' on ") + host,0);

        wxMessageBox(_("Unable to connect to the database. Reason:\n") + std2wx(conn -> error(),wxConvUI),_("Not connected."), wxOK);
        //      dbase_connected = false;
        return 1;
    }



}
Exemple #4
0
void* RestoreThread::Entry()
{
    wxDateTime now;
    wxString msg;

    try
    {
        msg.Printf(_("Connecting to server %s..."), serverM.c_str());
        logImportant(msg);
        IBPP::Service svc = IBPP::ServiceFactory(wx2std(serverM),
            wx2std(usernameM), wx2std(passwordM));
        svc->Connect();

        now = wxDateTime::Now();
        msg.Printf(_("Database restore started %s"), now.FormatTime().c_str());
        logImportant(msg);
        svc->StartRestore(wx2std(bkfileM), wx2std(dbfileM), pagesizeM, brfM);
        while (true)
        {
            if (TestDestroy())
            {
                now = wxDateTime::Now();
                msg.Printf(_("Database restore canceled %s"),
                    now.FormatTime().c_str());
                logImportant(msg);
                break;
            }
            const char* c = svc->WaitMsg();
            if (c == 0)
            {
                now = wxDateTime::Now();
                msg.Printf(_("Database restore finished %s"),
                    now.FormatTime().c_str());
                logImportant(msg);
                break;
            }
            msg = c;
            logProgress(msg);
        }
        svc->Disconnect();
    }
    catch (IBPP::Exception& e)
    {
        now = wxDateTime::Now();
        msg.Printf(_("Database restore canceled %s due to IBPP exception:\n\n"),
            now.FormatTime().c_str());
        msg += e.what();
        logError(msg);
    }
    catch (...)
    {
        now = wxDateTime::Now();
        msg.Printf(_("Database restore canceled %s due to exception"),
            now.FormatTime().c_str());
        logError(msg);
    }
    return 0;
}
void WindowLevelToolPanel::PushToSkinner()
{
  SCIRun::ThrowSkinnerSignalEvent *tsse =
    new SCIRun::ThrowSkinnerSignalEvent("Painter::UpdateWindowLevelTool");
  tsse->add_var("Painter::windowleveltool_window",
                wx2std(mWindowValue->GetValue()));
  tsse->add_var("Painter::windowleveltool_level",
                wx2std(mLevelValue->GetValue()));
  SCIRun::Painter::ThrowSkinnerSignal(tsse, false);

#ifndef _WIN32
  CreateHistogramImage();
#endif
}
void EventWatcherFrame::defineMonitoredEvents()
{
    if (eventsM != 0)
    {
        // prevent timer from messing our business
        bool timerRunning = timerM.IsRunning();
        setTimerActive(false);

        // get a list of events to be monitored
        std::vector<std::string> events;
        for (int i = 0; i < (int)listbox_monitored->GetCount(); i++)
            events.push_back(wx2std(listbox_monitored->GetString(i)));

        eventsM->Clear();
        std::vector<std::string>::const_iterator it;
        for (it = events.begin(); it != events.end(); it++)
        {
            eventsM->Add(*it, this);
            // make IBPP::Events pick up the initial event count
            eventsM->Dispatch();
        }

        updateControls();
        if (timerRunning)
            setTimerActive(true);
    }
}
Exemple #7
0
void taxes::OnButton1Click(wxCommandEvent& event)
{
    // if (ListBox1->GetSelection() != wxNOT_FOUND)
    if (!TextCtrl1->IsEmpty())
    {
        int exist=0;
        for (unsigned int i = 0; i<ListBox1->GetCount(); i++)
        {
            if (TextCtrl1->GetValue() == ListBox1->GetString(i))
            {
                wxMessageBox(_("This TAX group already exists."));
                exist = 1;
                i=ListBox1->GetCount();
            }
        }
        if (exist == 0)
        {

            double tax_rate;
            TextCtrl2 -> GetValue().ToDouble(&tax_rate);
            mysqlpp::Query query = conn_taxes -> query();
            query << "INSERT INTO `taxes` (`id`, `name`, `value`) VALUES (NULL, '"<< wx2std(TextCtrl1->GetValue(), wxConvUI) <<"', '"<< tax_rate <<"')";
            query.execute();
            fill_all();
            TextCtrl2->Clear();
            TextCtrl1->Clear();
        }


    }


}
Exemple #8
0
void taxes::OnButton2Click(wxCommandEvent& event)
{
    if (ListBox1->GetSelection() != wxNOT_FOUND)
    {


        if (!TextCtrl1->IsEmpty())
        {
//                int selected = ListBox1 -> GetSelection();
            double tax_rate;
            TextCtrl2 -> GetValue().ToDouble(&tax_rate);

            mysqlpp::Query query = conn_taxes -> query();
            query << "UPDATE `taxes` SET `name` = '"<<wx2std(TextCtrl1->GetValue(), wxConvUI)<<"', `value` = '" << tax_rate << "' WHERE `taxes`.`id` = "<< tax_ids[ListBox1 -> GetSelection()] <<" LIMIT 1;";
            query.execute();


            fill_all();
            TextCtrl2->Clear();
            TextCtrl1->Clear();
//           ListBox1 -> SetSelection(selected);

        }
    }
}
Exemple #9
0
bool DropUserHandler::handleURI(URI& uri)
{
    if (uri.action != "drop_user")
        return false;

    wxWindow* w = getParentWindow(uri);
    UserPtr u = extractMetadataItemPtrFromURI<User>(uri);
    if (!u || !w)
        return true;
    ServerPtr s = u->getServer();
    if (!s)
        return true;

    if (wxNO == wxMessageBox(_("Are you sure?"), _("Removing User"),
        wxYES_NO|wxICON_QUESTION))
        return true;

    ProgressDialog pd(w, _("Connecting to Server..."), 1);
    pd.doShow();
    IBPP::Service svc;
    if (!getService(s.get(), svc, &pd, true)) // true = need SYSDBA password
        return true;

    try
    {
        svc->RemoveUser(wx2std(u->getUsername()));
        s->notifyObservers();
    }
    catch(IBPP::Exception& e)
    {
        wxMessageBox(e.what(), _("Error"),
            wxOK | wxICON_WARNING);
    }
    return true;
}
Exemple #10
0
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
void
PropertiesView::onPropertyGridChanging(wxPropertyGridEvent& _event)
{
    wxPGProperty* const pWXProperty = _event.GetProperty();

    // TODO Don't assume this is a string.
    std::string newValue = wx2std(_event.GetValue().GetString());

    if (pWXProperty->GetClientData() != NULL)
    {
        I_Property* pProperty = static_cast<I_Property*>(pWXProperty->GetClientData());

        assert(pProperty != NULL);

        if (!pProperty->getPublisher().getController().canChangeProperty(*pProperty, newValue))
        {
            // Veto the event.
            _event.Veto();

            // Set the validation failure behavior.
            _event.SetValidationFailureBehavior(wxPG_VFB_STAY_IN_PROPERTY
                //| wxPG_VFB_BEEP
                //| wxPG_VFB_SHOW_MESSAGE
                );
        }
    }
}
Exemple #11
0
//! reads checks info from database
void Table::loadCheckConstraints()
{
    if (checkConstraintsLoadedM)
        return;
    checkConstraintsM.clear();

    DatabasePtr db = getDatabase();
    wxMBConv* conv = db->getCharsetConverter();
    MetadataLoader* loader = db->getMetadataLoader();
    // first start a transaction for metadata loading, then lock the table
    // when objects go out of scope and are destroyed, table will be unlocked
    // before the transaction is committed - any update() calls on observers
    // can possibly use the same transaction
    MetadataLoaderTransaction tr(loader);
    SubjectLocker lock(this);

    IBPP::Statement& st1 = loader->getStatement(
        "select r.rdb$constraint_name, t.rdb$trigger_source, d.rdb$field_name "
        " from rdb$relation_constraints r "
        " join rdb$check_constraints c on r.rdb$constraint_name=c.rdb$constraint_name and r.rdb$constraint_type = 'CHECK'"
        " join rdb$triggers t on c.rdb$trigger_name=t.rdb$trigger_name and t.rdb$trigger_type = 1 "
        " left join rdb$dependencies d on t.rdb$trigger_name = d.rdb$dependent_name "
        "      and d.rdb$depended_on_name = r.rdb$relation_name "
        "      and d.rdb$depended_on_type = 0 "
        " where r.rdb$relation_name=? "
        " order by 1 "
    );

    st1->Set(1, wx2std(getName_(), conv));
    st1->Execute();
    CheckConstraint *cc = 0;
    while (st1->Fetch())
    {
        std::string s;
        st1->Get(1, s);
        wxString cname(std2wxIdentifier(s, conv));
        if (!cc || cname != cc->getName_()) // new constraint
        {
            wxString source;
            readBlob(st1, 2, source, conv);

            CheckConstraint c;
            c.setParent(this);
            c.setName_(cname);
            c.sourceM = source;
            checkConstraintsM.push_back(c);
            cc = &checkConstraintsM.back();
        }

        if (!st1->IsNull(3))
        {
            st1->Get(3, s);
            wxString fname(std2wxIdentifier(s, conv));
            cc->columnsM.push_back(fname);
        }
    }
    checkConstraintsLoadedM = true;
}
void IntensityCorrectionFilterPanel::OnStartButtonClick( wxCommandEvent& event )
{
  SCIRun::ThrowSkinnerSignalEvent *tsse =
    new SCIRun::ThrowSkinnerSignalEvent("Painter::FinishTool");
  tsse->add_var("Painter::IntensityCorrection::order",
                SCIRun::to_string(mOrder->GetValue()));
  tsse->add_var("Painter::IntensityCorrection::::edge",
                wx2std(mEdge->GetValue()));
  SCIRun::Painter::ThrowSkinnerSignal(tsse, false);
}
/*!
 * wxEVT_COMMAND_BUTTON_CLICKED event handler for START_BUTTON
 */
void ITKCurvatureAnistopricDiffusionFilter::OnStartButtonClick( wxCommandEvent& event )
{
  SCIRun::ThrowSkinnerSignalEvent *tsse =
    new SCIRun::ThrowSkinnerSignalEvent("Painter::FinishTool");
  tsse->add_var("ITKCurvatureAnisotropicDiffusionImageFilterTool::numberOfIterations",
                SCIRun::to_string(mIterations->GetValue()));
  tsse->add_var("ITKCurvatureAnisotropicDiffusionImageFilterTool::timeStep",
                wx2std(mTimeSteps->GetValue()));
  tsse->add_var("ITKCurvatureAnisotropicDiffusionImageFilterTool::conductanceParameter",
                SCIRun::to_string(mConductance->GetValue()));
  SCIRun::Painter::ThrowSkinnerSignal(tsse, false);
}
Exemple #14
0
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
wxWindow*
Notebook::getPage(const std::string& _title)
{
    for(unsigned x = 0; x < GetPageCount(); x++)
    {
        if (wx2std(GetPageText(x)) == _title)
        {
            return GetPage(x);
        }
    }

    return NULL;
}
Exemple #15
0
/*!
 * wxEVT_COMMAND_BUTTON_CLICKED event handler for START_BUTTON
 */
void HistoEqFilter::OnStartButtonClick( wxCommandEvent& event )
{
  // Call synchronously and wait.
  wxBeginBusyCursor();
  SCIRun::ThrowSkinnerSignalEvent *tsse =
    new SCIRun::ThrowSkinnerSignalEvent("Painter::HistoEqFilter");
  tsse->add_var("Painter::HistoEq::bins",
                SCIRun::to_string(mIgnore->GetValue()));
  tsse->add_var("Painter::HistoEq::alpha",
                wx2std(mAlpha->GetValue()));
  SCIRun::Painter::ThrowSkinnerSignal(tsse);
  wxEndBusyCursor();
}
Exemple #16
0
//! reads uniques from database
void Table::loadUniqueConstraints()
{
    if (uniqueConstraintsLoadedM)
        return;
    uniqueConstraintsM.clear();

    DatabasePtr db = getDatabase();
    wxMBConv* conv = db->getCharsetConverter();
    MetadataLoader* loader = db->getMetadataLoader();
    // first start a transaction for metadata loading, then lock the table
    // when objects go out of scope and are destroyed, table will be unlocked
    // before the transaction is committed - any update() calls on observers
    // can possibly use the same transaction
    MetadataLoaderTransaction tr(loader);
    SubjectLocker lock(this);

    IBPP::Statement& st1 = loader->getStatement(
        "select r.rdb$constraint_name, i.rdb$field_name, r.rdb$index_name "
        "from rdb$relation_constraints r, rdb$index_segments i "
        "where r.rdb$relation_name=? and r.rdb$index_name=i.rdb$index_name and "
        "(r.rdb$constraint_type='UNIQUE') order by r.rdb$constraint_name, i.rdb$field_position"
    );

    st1->Set(1, wx2std(getName_(), conv));
    st1->Execute();
    UniqueConstraint *cc = 0;
    while (st1->Fetch())
    {
        std::string s;
        st1->Get(1, s);
        wxString cname(std2wxIdentifier(s, conv));
        st1->Get(2, s);
        wxString fname(std2wxIdentifier(s, conv));
        st1->Get(3, s);
        wxString ixname(std2wxIdentifier(s, conv));

        if (cc && cc->getName_() == cname)
            cc->columnsM.push_back(fname);
        else
        {
            UniqueConstraint c;
            uniqueConstraintsM.push_back(c);
            cc = &uniqueConstraintsM.back();
            cc->indexNameM = ixname;
            cc->setName_(cname);
            cc->columnsM.push_back(fname);
            cc->setParent(this);
        }
    }
    uniqueConstraintsLoadedM = true;
}
Exemple #17
0
/*!
 * wxEVT_COMMAND_BUTTON_CLICKED event handler for START_BUTTON
 */
void ResampleTool::OnStartButtonClick( wxCommandEvent& event )
{
  wxBeginBusyCursor();
  SCIRun::ThrowSkinnerSignalEvent *tsse =
    new SCIRun::ThrowSkinnerSignalEvent("Painter::FinishTool");
  tsse->add_var( "Painter::Resample::x", SCIRun::to_string( mX->GetValue() ) );
  tsse->add_var( "Painter::Resample::y", SCIRun::to_string( mY->GetValue() ) );
  tsse->add_var( "Painter::Resample::z", SCIRun::to_string( mZ->GetValue() ) );
  tsse->add_var( "Painter::Resample::filter", wx2std( mFilter->GetStringSelection() ) );
  SCIRun::Painter::ThrowSkinnerSignal(tsse);
  wxEndBusyCursor();

  SCIRun::Painter::global_seg3dframe_pointer_->HideTool();
}
Exemple #18
0
void kitchenFrame::OnUrlClick(wxHtmlLinkEvent& event)
{
    long templong;

    wxString link = event.GetLinkInfo().GetHref();

    link.Mid(0,link.Find(_T(":"))).ToLong(&templong);
    href=true;
    int num = templong;
    wxString temp;
    temp << num;

    mysqlpp::Query query = conn->query();
    wxString dishId = link.Mid(link.Find(_T(":"))+1);
    query <<"UPDATE `orders_dishes` SET `ready` = '1' \
   WHERE `orders_dishes`.`id` =" << wx2std(dishId, wxConvUI) << " LIMIT 1";
    query.execute(); //we just set to ready only one dish from order


    int orderId;
    query << "SELECT `order_id` FROM `orders_dishes` WHERE `id`="<< wx2std(dishId, wxConvUI);
    mysqlpp::StoreQueryResult res = query.store();
    if(res)
    {
        mysqlpp::Row row;
        row = res.at(0);
        orderId = int(row["order_id"]);
    }
    query << "SELECT `id` FROM `orders_dishes` WHERE `ready`=0 AND `order_id`="<< orderId;
    res = query.store();

    if(res)
    {
        if(!res.num_rows())  //no dishes to prepare
        {
            query << "UPDATE `orders` SET `status` = '4' WHERE `orders`.`id` ="<< orderId <<" LIMIT 1 ";
            query.execute(); //set the whole order to ready state
            //redo the pages to update status
            fillAll();
            wxString tem;
            tem << _T("r:") << orderId;
            sendMessageToServer(SocketClient1, tem);
        }
    }

    wxString prodName = StaticText9->GetLabel();
    fillDetails(prodName);
    fillMain();
}
void WindowLevelToolPanel::OnWindowText( wxCommandEvent& event )
{
  if (mWindowValue && mWindowValue->IsModified())
  {
    const string str = wx2std(mWindowValue->GetValue());
    std::istringstream sstr(str);
    sstr >> window_;

    // Update the slider
    double window = (window_) / (maxval_ - minval_);
    if (window < 0.0) window = 0.0;
    if (window > 1.0) window = 1.0;
    mWindowSlider->SetValue((int)(1000.0 * window));

    PushToSkinner();
  }
}
void WindowLevelToolPanel::OnLevelText( wxCommandEvent& event )
{
  if (mLevelValue && mLevelValue->IsModified())
  {
    const string str = wx2std(mLevelValue->GetValue());
    std::istringstream sstr(str);
    sstr >> level_;

    // Update the slider
    double level = (level_ - minval_) / (maxval_ - minval_);
    if (level < 0.0) level = 0.0;
    if (level > 1.0) level = 1.0;
    mLevelSlider->SetValue((int)(1000.0 * level));

    PushToSkinner();
  }
}
Exemple #21
0
void Exception::loadProperties()
{
    setPropertiesLoaded(false);

    DatabasePtr db = getDatabase();
    MetadataLoader* loader = db->getMetadataLoader();
    MetadataLoaderTransaction tr(loader);
    wxMBConv* converter = db->getCharsetConverter();

    IBPP::Statement& st1 = loader->getStatement(getLoadStatement(false));
    st1->Set(1, wx2std(getName_(), converter));
    st1->Execute();
    if (!st1->Fetch())
        throw FRError(_("Exception not found: ") + getName_());

    loadProperties(st1, converter);
}
Exemple #22
0
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
void
PropertiesView::onPropertyGridChanged(wxPropertyGridEvent& _event)
{
    wxPGProperty* const pWXProperty = _event.GetProperty();

    // TODO Don't assume this is a string.
    std::string newValue = wx2std(_event.GetProperty()->GetValueAsString());

    if (pWXProperty->GetClientData() != NULL)
    {
        I_Property* pProperty = static_cast<I_Property*>(pWXProperty->GetClientData());

        assert(pProperty != NULL);

        pProperty->getPublisher().getController().setPropertyValue(*pProperty, newValue);
    }
}
Exemple #23
0
void kitchenFrame::fillPanels()
{
    int pages = Notebook1->GetPageCount()-1;
    for(int t = pages; t > 0; --t) //deleting unnecessary pages
    {
        Notebook1->RemovePage(t);
    }
    OrderPanels.Clear();

    wxDateTime current = wxDateTime::Now();
    mysqlpp::Query query = conn->query();
    query << "SELECT `id`, `number` FROM `orders` WHERE `time` > '"<< wx2std(current.FormatISODate(), wxConvUI) <<"' AND `status` = 3";
    mysqlpp::StoreQueryResult res = query.store();
    if (res)
    {
        if(res.num_rows() != 0)
        {
            mysqlpp::Row row;
            mysqlpp::StoreQueryResult::size_type i;
            wxString panTitle;
            wxArrayInt orderIds;
            for (i = 0; i < res.num_rows(); ++i)
            {
                row = res[i];

                if(i % 3 == 0 && i != 0)
                {
                    addPanel(panTitle, orderIds);
                    panTitle.Clear();
                    orderIds.Clear();
                    panTitle << std2wx(std::string(row["number"]), wxConvUI);
                    orderIds.Add(int(row["id"]));
                }
                else
                {
                    wxString delim;
                    if(i != 0) delim = _T(" - ");
                    panTitle <<  delim << std2wx(std::string(row["number"]), wxConvUI);
                    orderIds.Add(int(row["id"]));
                }
            }
            addPanel(panTitle, orderIds);
        }
    }
}
Exemple #24
0
int time_loggerFrame::getEmployeeId(){
    int toRet;
    mysqlpp::Query query = conn->query();
    query << "SELECT `emp_id`, `emp_name` FROM `employees` WHERE `emp_ssn` ="<< wx2std(StaticText1->GetLabel(),wxConvUI) <<" LIMIT 1";
    mysqlpp::StoreQueryResult res = query.store();
if(res.num_rows() != 0){
if(res){
        mysqlpp::Row row = res.at(0);
        empId = int(row["emp_id"]);
        empName = std2wx(std::string(row["emp_name"]), wxConvUI);
toRet = 0;
}
}else{
        empId = 0;
toRet = 1;
}
return toRet;
    }
Exemple #25
0
int restoreFromDump(mysqlpp::Connection* conn, const wxString& filename)
{
    int toRet = 1;
    wxFFile backup_file(filename);
    if(backup_file.IsOpened())
    {
        wxString fileContent;
        backup_file.ReadAll(&fileContent);
//   wxMessageBox(fileContent);
//wxRegEx comments(_("--[^x22\\x27].*"), wxRE_NEWLINE);
// \x22[^\x22]*\x22|\x27[^\x27]*\x27|/\*.*?\*/|(\#|--)([^\x22\x27]*?)$ - groups 1 and 2
        wxRegEx comments(_("\\x22\\x27[^\\x22\\x27]*\\x22\\x27|/\\*.*?\\*/|(\\#|--)[^\\x22\\x27]*?$"), wxRE_ADVANCED|wxRE_NEWLINE);
//wxRegEx comments(_("\\x22[^\\x22]*\\x22|\\x27[^\\x27]*\\x27|/\\*.*?\\*/|(\\#|--)([^\\x22\\x27]*?)$"), wxRE_ADVANCED|wxRE_NEWLINE);


        comments.ReplaceAll(&fileContent, _(""));
//comments.ReplaceAll(&fileContent, _("*\\2"));

        fileContent.Trim();
        wxRegEx semicolons(_("(?m);\\s*$"), wxRE_ADVANCED|wxRE_NEWLINE);
        semicolons.ReplaceAll(&fileContent, _("^")); //in the future take care of that - if ^ symbol is inside the satatement

//wxMessageBox(fileContent);

        wxStringTokenizer tkz(fileContent, _("^"));
        while ( tkz.HasMoreTokens() )
        {
            wxString sql_query = tkz.GetNextToken().Trim(false);
//wxMessageBox(sql_query);

            mysqlpp::Query query = conn->query();
            query << wx2std(sql_query, wxConvUI);
            query.execute();

        }

    }
    else
    {
        wxMessageBox(_T("Failed to open backup file."));
        toRet = 0;
    }
    return toRet;
}
Exemple #26
0
School* subPageSpells::GetSelectedSchool()
{
	wxArrayInt selected;
	if ( schoolList->GetSelections(selected) == 0 )
		return 0;

	wxArrayString *pSchoolStrArray = schoolStrArray;
	wxString *schoolName = &(*pSchoolStrArray)[ (selected[0]) ];

	for ( unsigned int i = 0; i < dfSpells->data.size(); i++ )
		if ( dfSpells->data[i]->name == wx2std(*schoolName) )
			currentSchool = dfSpells->data[i];

	spellItr = currentSchool->spells.begin();
	currentSpell = *spellItr;
	spellNumber = 1;

	schoolNameText->SetLabel( *schoolName );

	return currentSchool;
Exemple #27
0
//-----------------------------------------------------------------------------
void Exception::loadProperties()
{
    setPropertiesLoaded(false);

    DatabasePtr db = getDatabase();
    MetadataLoader* loader = db->getMetadataLoader();
    MetadataLoaderTransaction tr(loader);

    IBPP::Statement& st1 = loader->getStatement(
        "select RDB$MESSAGE, RDB$EXCEPTION_NUMBER from RDB$EXCEPTIONS"
        " where RDB$EXCEPTION_NAME = ?");
    st1->Set(1, wx2std(getName_(), db->getCharsetConverter()));
    st1->Execute();
    st1->Fetch();
    std::string message;
    st1->Get(1, message);
    messageM = std2wx(message, db->getCharsetConverter());
    st1->Get(2, numberM);

    setPropertiesLoaded(true);
}
Exemple #28
0
//-----------------------------------------------------------------------------
void Server::createDatabase(DatabasePtr db, int pagesize, int dialect)
{
    QString extra_params;
    if (pagesize)
        extra_params += (QString::fromLatin1(" PAGE_SIZE ") + pagesize);

    QString charset(db->getConnectionCharset());
    if (!charset.isEmpty())
        extra_params += (QString::fromLatin1(" DEFAULT CHARACTER SET ") + charset);

    IBPP::Database db1;
    db1 = IBPP::DatabaseFactory(wx2std(getConnectionString()),
                                wx2std(db->getPath()), wx2std(db->getUsername()),
                                wx2std(db->getDecryptedPassword()), "", wx2std(charset),
                                wx2std(extra_params));
    db1->Create(dialect);
}
Exemple #29
0
//-----------------------------------------------------------------------------
void Generator::loadProperties()
{
    setPropertiesLoaded(false);

    DatabasePtr db = getDatabase();
    MetadataLoader* loader = db->getMetadataLoader();
    MetadataLoaderTransaction tr(loader);

    // IMPORTANT: for all other loading where the name of the db object is
    // Set() into a parameter getName_() is used, but for dynamically
    // building the SQL statement getQuotedName() must be used!
    std::string sqlName(wx2std(getQuotedName(), db->getCharsetConverter()));
    // do not use cached statements, because this can not be reused
    IBPP::Statement st1 = loader->createStatement(
        "select gen_id(" + sqlName + ", 0) from rdb$database");
        
    st1->Execute();
    st1->Fetch();
    st1->Get(1, &valueM);

    setPropertiesLoaded(true);
    notifyObservers();
}
Exemple #30
0
DomainPtr DomainCollectionBase::getDomain(const wxString& name)
{
    DomainPtr domain = findByName(name);
    if (!domain)
    {
        SubjectLocker lock(this);

        DatabasePtr db = getDatabase();
        MetadataLoader* loader = db->getMetadataLoader();
        MetadataLoaderTransaction tr(loader);
        wxMBConv* converter = db->getCharsetConverter();

        IBPP::Statement& st1 = loader->getStatement(
            Domain::getLoadStatement(false));
        st1->Set(1, wx2std(name, converter));
        st1->Execute();
        if (st1->Fetch())
        {
            domain = insert(name);
            domain->loadProperties(st1, converter);
        }
    }
    return domain;
}