diff --git a/frm/frmMain.cpp b/frm/frmMain.cpp index c9cb432..c563f42 100644 --- a/frm/frmMain.cpp +++ b/frm/frmMain.cpp @@ -432,7 +432,8 @@ void frmMain::CreateMenus() new reportObjectDependentsFactory(menuFactories, reportMenu, 0); new reportObjectListFactory(menuFactories, reportMenu, 0); new reportCompareFactory(menuFactories, reportMenu, 0); - + choiceSelectOpts.Add(0); + choiceSelectOpts.Add(1); toolsMenu->AppendSeparator(); diff --git a/frm/frmReport.cpp b/frm/frmReport.cpp index 01a97b4..fe0c827 100644 --- a/frm/frmReport.cpp +++ b/frm/frmReport.cpp @@ -14,6 +14,7 @@ // App headers #include "pgAdmin3.h" #include +#include #include "frm/frmMain.h" #include "frm/frmReport.h" @@ -1222,6 +1223,59 @@ wxString reportCompareFactory::GetNodePath(wxTreeItemId node) { return path; +} +wxString reportCompareFactory::ApplyCompareOpts(wxString sql,int metatype) { + if (sql.IsEmpty()) return ""; + bool no_comment = parent->getChoiceSelect(1); + bool no_priv = parent->getChoiceSelect(0); + if (no_comment) { + int last = 0; + while (last!=-1) { + last = sql.Find("\nCOMMENT ON"); + int start = last; + int end = -1; + while (last!=-1) { + last++; + if (sql.Length() == last) { last = -1; continue; } + wxChar c = sql.GetChar(last); + if (c == '\'') { + last++; + if (sql.GetChar(last) == '\'') { continue; } + if (sql.GetChar(last) == ';') { end = last; last = -1; continue; } + + } + }; + if (end != -1) { + sql=sql.Remove(start, end - start+1); + last = 0; + } + } + + } + if (no_priv &&(metatype != PGM_ROLE)) { + int last = 0; + while (last != -1) { + last = sql.Find("\nGRANT "); + if (last==-1) last = sql.Find("\nREVOKE "); + int start = last; + int end = -1; + while (last != -1) { + last++; + if (sql.Length() == last) { last = -1; continue; } + wxChar c = sql.GetChar(last); + if (c == ';') { + end = last; last = -1; + } + }; + if (end != -1) { + sql = sql.Remove(start, end - start + 1); + last = 0; + } + } + + } + return sql; + } void reportCompareFactory::GetExpandedChildNodes(wxTreeItemId node, wxArrayString &expandedNodes, ArraySQL &list, time_t *t, wxBusyInfo *w, MyHashSQL &h_path,int lvl) { @@ -1312,6 +1366,7 @@ void reportCompareFactory::GetExpandedChildNodes(wxTreeItemId node, wxArrayStrin if (obj ) { wxString s=obj->GetSql(browser); if (obj->GetMetaType()==PGM_SEQUENCE) s=""; + s = ApplyCompareOpts(s, obj->GetMetaType()); int c=browser->GetChildrenCount(child,false); if (size>0) { wxString srcpath(path); @@ -1492,6 +1547,7 @@ if (lastdb!=NULL) { wxMessageBox(msg, _("Error"), wxOK | wxICON_INFORMATION); return 0; } +if (!parent->StartChoiceDialog()) return 0; time_t timer=wxDateTime::GetTimeNow(); wxArrayString expandedNodes; ArraySQL list; @@ -1499,12 +1555,14 @@ time_t timer=wxDateTime::GetTimeNow(); wxWindowDisabler disableAll; { +#ifndef DEBUG wxBusyInfo waiting(wxString::Format(" Обход исходной БД Path = %s ,Стартовый объект = %s", browser->GetItemText(obj->GetServer()->GetId()).c_str(), obj->GetName().c_str(),parent)); // Give the UI a chance to redraw wxSafeYield(); wxMilliSleep(50); wxSafeYield(); +#endif // waiting->~wxBusyInfo(); GetExpandedChildNodes(obj->GetId(),expandedNodes,list,&timer, NULL,h_path,0); } @@ -1809,7 +1867,7 @@ std::wstring reportCompareFactory::printdiff(std::wstring str1, std::wstring str ++it; } #ifdef _DEBUG - wxFileName fn("D:\\PostgreSQL\\cmp.txt"); + wxFileName fn("cmp_debug.txt"); fn.MakeAbsolute(); wxFile file(fn.GetFullPath(), wxFile::write); diff --git a/include/frm/frmMain.h b/include/frm/frmMain.h index 90cea9a..1187370 100644 --- a/include/frm/frmMain.h +++ b/include/frm/frmMain.h @@ -107,7 +107,28 @@ public: currentObject = data; } bool CheckAlive(); - + // + bool getChoiceSelect(int index) { + for (size_t n = 0; n < choiceSelectOpts.GetCount(); n++) { + if (choiceSelectOpts[n] == index) return true; + } + return false; + } + bool StartChoiceDialog() { + choiceCmpOpts.Clear(); + choiceCmpOpts.Add("Priveleges ignore"); + choiceCmpOpts.Add("Comment ignore"); + wxMultiChoiceDialog dialog(this, + wxT("A multi-choice convenience dialog"), + wxT("Please select several compare options"), + choiceCmpOpts); + dialog.SetSelections(choiceSelectOpts); + if (dialog.ShowModal() == wxID_OK) { + choiceSelectOpts = dialog.GetSelections(); + return true; + } + return false; + } void execSelChange(wxTreeItemId item, bool currentNode); void Refresh(pgObject *data); void ExecDrop(bool cascaded); @@ -203,6 +224,8 @@ private: long msgLevel; bool m_refreshing; + wxArrayString choiceCmpOpts; + wxArrayInt choiceSelectOpts; wxTreeItemId denyCollapseItem; pgObject *currentObject; diff --git a/include/frm/frmReport.h b/include/frm/frmReport.h index 3eb0bbf..455178c 100644 --- a/include/frm/frmReport.h +++ b/include/frm/frmReport.h @@ -141,6 +141,7 @@ private: protected: //reportCompareFactory(menuFactoryList *list) : actionFactory(list) {} wxString reportCompareFactory::GetNodePath(wxTreeItemId node); + wxString ApplyCompareOpts(wxString sql, int metatype); wxWindow *StartDialog(frmMain *form, pgObject *obj); void reportCompareFactory::GetExpandedChildNodes(wxTreeItemId node, wxArrayString &expandedNodes, ArraySQL &list,time_t *t,wxBusyInfo *w, MyHashSQL &h_path,int lvl); std::wstring reportCompareFactory::printdiff(std::wstring str1, std::wstring str2 );