NCBI C++ ToolKit
report_dialog.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: report_dialog.cpp 43155 2019-05-22 17:29:04Z asztalos $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Authors: Andrea Asztalos
27 *
28 */
29 
30 #include <ncbi_pch.hpp>
31 #include <corelib/ncbifile.hpp>
35 #include <wx/stdpaths.h>
36 
38 
40 {
41  REPORT_USAGE("editing", .Add("dialog_name", ToStdString(GetLabel())));
42  return wxDialog::Show(show);
43 }
44 
45 namespace NEditingStats
46 {
47  void ReportUsage(const wxString& dialog_name)
48  {
49  REPORT_USAGE("editing", .Add("dialog_name", ToStdString(dialog_name)));
50  }
51 
52  void ReportSubWizardUsage(const string& action_name)
53  {
54  REPORT_USAGE("submission_wizard", .Add("action_name", action_name));
55  }
56 }
57 
58 namespace NMacroStats
59 {
60  void ReportUsage(const wxString& dialog_name, const string& action_name)
61  {
62  REPORT_USAGE("macro", .Add("dialog_name", ToStdString(dialog_name))
63  .Add("action_name", action_name));
64  }
65 
67  {
68  ReportUsage("MacroScript", "execute");
69  }
70 
71  void SaveScriptToFile(const string& macro, const string& filename)
72  {
73  if (macro.empty()) return;
74 
75 
76  wxStandardPaths stdp = wxStandardPaths::Get();
77  const string doc_dir = ToStdString(stdp.GetDocumentsDir());
78  const string macro_dir = CDirEntry::ConcatPathEx(doc_dir, "GbenchMacro");
79 
80  CDir dir(macro_dir);
81  if (!dir.Exists()) {
82  if (!dir.Create()) {
83  LOG_POST(Error << "Cannot create directory '" << macro_dir << "'");
84  return;
85  }
86  }
87 
88  const string macro_file = CDirEntry::ConcatPathEx(macro_dir, filename);
89  CNcbiOfstream ostr(macro_file.c_str(), ios::out | ios::app);
90  ostr << macro << endl;
91  }
92 
93  void SaveScriptCreated(const string& macro)
94  {
95  SaveScriptToFile(macro, "created_macro_log.txt");
96  }
97 
98  void SaveScriptFromLibrary(const string& macro)
99  {
100  SaveScriptToFile(macro, "library_macro_log.txt");
101  }
102 
103  void ReportMacroToBeUpdated(const string& username, const string& filename, const string& action)
104  {
105  REPORT_USAGE("macro_update", .Add("user", username)
106  .Add("file", filename)
107  .Add("action", action));
108  }
109 }
110 
111 
113 
CDir –.
Definition: ncbifile.hpp:1695
virtual bool Show(bool show=1)
Report opening events in dialogs used in the editing package.
std::ofstream out("events_result.xml")
main entry point for tests
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
Definition: ncbidiag.hpp:226
void Error(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1197
virtual bool Exists(void) const
Check if directory "dirname" exists.
Definition: ncbifile.hpp:4065
static string ConcatPathEx(const string &first, const string &second)
Concatenate two parts of the path for any OS.
Definition: ncbifile.cpp:791
bool Create(TCreateFlags flags=fCreate_Default) const
Create the directory using "dirname" passed in the constructor.
Definition: ncbifile.cpp:4071
string GetLabel(const CSeq_id &id)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
IO_PREFIX::ofstream CNcbiOfstream
Portable alias for ofstream.
Definition: ncbistre.hpp:500
const TYPE & Get(const CNamedParameterList *param)
void ReportUsage(const wxString &dialog_name)
Report opening & accepting events in the editing package.
void ReportSubWizardUsage(const string &action_name)
Report usage of the submission wizard dialog.
void SaveScriptFromLibrary(const string &macro)
Save macro obtained from the library.
void ReportUsage(const wxString &dialog_name, const string &action_name)
Report events in the macro_flow_editor and in the macro_editor.
void SaveScriptCreated(const string &macro)
Save macro created by the editor.
void ReportMacroToBeUpdated(const string &username, const string &filename, const string &action)
Report attempt to update a local macro script.
void SaveScriptToFile(const string &macro, const string &filename)
Save macro to a file.
void ReportMacroExecution()
Report when a macro is executed.
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
#define REPORT_USAGE(event, args)
Convenience macro to log usage statisitics.
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Wed Jun 19 17:05:12 2024 by modify_doxy.py rev. 669887