Wtx ~ Wt Extension Library
WtxLib
docnotes.h
1 /**************************************************************************
2 ###########################################################################
3 ##
4 ## $SHOWOFFDB_BEGIN_LICENSE$
5 ## Copyright (C) 2011 Lorimark Solutions, LLC and/or its subsidiary(-ies).
6 ## All rights reserved.
7 ## Contact: Lorimark Solutions, LLC (info@showoff-db.org)
8 ##
9 ## This file is part of the Showoff Database Application Framework.
10 ##
11 ## Commercial Usage
12 ## Licensees holding valid ShowoffDB Commercial licenses may use this file in
13 ## accordance with the ShowoffDB Commercial License Agreement provided with the
14 ## Software or, alternatively, in accordance with the terms contained in
15 ## a written agreement between you and Lorimark Solutions, LLC.
16 ##
17 ## GNU Lesser General Public License Usage
18 ## Alternatively, this file may be used under the terms of the GNU Lesser
19 ## General Public License version 2.1 as published by the Free Software
20 ## Foundation and appearing in the file LICENSE.LGPL included in the
21 ## packaging of this file. Please review the following information to
22 ## ensure the GNU Lesser General Public License version 2.1 requirements
23 ## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ##
25 ## In addition, as a special exception, Lorimark Solutions, LLC gives
26 ## you certain additional rights. These rights are described in the
27 ## Lorimark Solutions, LLC ShowoffDB LGPL Exception version 1.0, included in
28 ## the file LGPL_EXCEPTION.txt in this package.
29 ##
30 ## GNU General Public License Usage
31 ## Alternatively, this file may be used under the terms of the GNU
32 ## General Public License version 3.0 as published by the Free Software
33 ## Foundation and appearing in the file LICENSE.GPL included in the
34 ## packaging of this file. Please review the following information to
35 ## ensure the GNU General Public License version 3.0 requirements will be
36 ## met: http://www.gnu.org/copyleft/gpl.html.
37 ##
38 ## If you have questions regarding the use of this file, please contact
39 ## Lorimark Solutions, LLC at info@showoff-db.org.
40 ## $SHOWOFFDB_END_LICENSE$
41 ##
42 #############################################################################
43 ****************************************************************************/
44 
45 
985 ** static std::vector<std::string> exceptions =
986 ** {
987 ** "session was killed",
988 ** "all threads are busy"
989 ** };
990 **
991 ** static std::vector<std::string> pop_exceptions =
992 ** {
993 ** "basic_string::at: __n", // this happens when a <space> is put after the time in a WTimeEdit field
994 ** "bad lexical cast" // this happens when a '' nothing character is put where a number '0' is expected
995 ** };
996 **
997 ** /*
998 ** ** Try to notify the main application loop.
999 ** */
1000 ** try
1001 ** {
1002 ** Wt::WApplication::notify(event);
1003 ** }
1004 **
1005 ** /*
1006 ** ** Handle the application exception.
1007 ** */
1008 ** catch( std::exception & exception )
1009 ** {
1010 ** /*
1011 ** ** If this is an expected exception, then ignore it. It just means
1012 ** ** it's a dead session, that we don't really care about.
1013 ** */
1014 ** for( auto except : exceptions )
1015 ** if( std::string(exception.what()).find(except) != std::string::npos )
1016 ** {
1017 ** COUT_( "redirecting to: " + originalUrl( internalPath() ) );
1018 ** redirect( originalUrl( internalPath() ) );
1019 ** quit();
1020 **
1021 ** return;
1022 ** }
1023 **
1024 ** /*
1025 ** ** prepare a message that we can send to the logs
1026 ** **
1027 ** */
1028 ** auto message =
1029 ** Wt::WString("EXCEPTION: '{1}'")
1030 ** .arg( exception.what() )
1031 ** .toUTF8()
1032 ** ;
1033 **
1034 ** /*
1035 ** ** Log the exception, and display it to the console as well.
1036 ** ** Note that if you also are logging field-level-changes and
1037 ** ** during one of those changes an exception is thrown, then
1038 ** ** even if the exception does not reveal much about what
1039 ** ** the source of the failure was, the log may contain everything
1040 ** ** that was going on right before the exception was thrown.
1041 ** **
1042 ** */
1043 ** txtLog( message, true );
1044 **
1045 ** /*
1046 ** ** This may be an exception that we just want to pop-up
1047 ** ** to the user.
1048 ** **
1049 ** */
1050 ** for( auto except : pop_exceptions )
1051 ** if( std::string(exception.what()).find(except) != std::string::npos )
1052 ** {
1053 ** Wt::WMessageBox::show
1054 ** (
1055 ** "Exception",
1056 ** "<center>"
1057 ** " Oh oh, something went wrong,<br />"
1058 ** " please check what you are editing "
1059 ** " and try again"
1060 ** "</center>"
1061 ** , Wt::Ok
1062 ** );
1063 **
1064 ** return;
1065 ** }
1066 **
1067 ** COUT_( "\n\n\n\n\n\n<<<<< EXCEPTION >>>>>>>" );
1068 ** COUT_( exception.what() );
1069 **
1070 ** /*
1071 ** ** This exception was not expected, so send a text message to an administrator
1072 ** ** that can hopefully deal with it.
1073 ** **
1074 ** */
1075 ** auto result =
1076 ** system
1077 ** (
1078 ** emailText
1079 ** (
1080 ** "exception",
1081 ** message,
1082 ** {"adminemail@somesuchthing.com"}
1083 ** ).c_str()
1084 ** );
1085 ** (void)result;
1086 **
1087 ** /*
1088 ** ** since this is a fatal exception, just refresh the app so that
1089 ** ** everything properly reloads.
1090 ** **
1091 ** */
1092 ** COUT_( "redirecting to: " + originalUrl( internalPath() ) );
1093 ** redirect( originalUrl( internalPath() ) );
1094 ** quit();
1095 **
1096 ** } // endcatch( std::exception & exception )
1097 **
1098 ** } // endvoid CCB::BaseApp::notify( const Wt::WEvent & event )
1099 ** \endcode
1100 **
1101 */
1102 
1103 
2148 201 if( !app )
2149 202 return;
2150 203
2151 204 /*
2152 205 ** This task just runs forever, sleeping for a bit, and then
2153 206 ** waking the app.
2154 207 **
2155 208 */
2156 209 while( true )
2157 210 {
2158 211 /*
2159 212 ** Sleep this thread for just one second
2160 213 ** before doing anything
2161 214 **
2162 215 */
2163 216 std::this_thread::sleep_for( std::chrono::seconds(1) );
2164 217
2165 218 /*
2166 219 ** If the application has already quit, then there's nothing to do.
2167 220 **
2168 221 */
2169 222 if( app-> hasQuit() )
2170 223 return;
2171 224
2172 225 /*
2173 226 ** Acquire an application lock. If the application is busy handling
2174 227 ** some user interaction, this call will block until that other
2175 228 ** task has completed.
2176 229 **
2177 230 */
2178 231 Wt::WApplication::UpdateLock lock( app );
2179 232
2180 233 /*
2181 234 ** If we could not get a lock, then quit. If we could not get a lock,
2182 235 ** then it sort of implies that the application was being destroyed.
2183 236 ** In that case, we don't want to do anything more anyhow, so we just
2184 237 ** quit.
2185 238 **
2186 239 */
2187 240 if( !lock )
2188 241 return;
2189 242
2190 243 /*
2191 244 ** Make the tic happen
2192 245 **
2193 246 */
2194 247 app-> tic();
2195 248
2196 249 /*
2197 250 ** After everything has fired, trigger an update.
2198 251 **
2199 252 */
2200 253 app-> triggerUpdate();
2201 254
2202 255 } // endwhile( true )
2203 256
2204 257 } // endvoid Rtm::AppBase::tic_handler( Rtm::AppBase * app )
2205 258
2206 
2207 2024 void AdminWidget::hold_me()
2208 2025 {
2209 2026 for( int i = 0; i < 10; i++ )
2210 2027 {
2211 2028 std::cout << __FILE__ << ":" << __LINE__ << " holding... " << i << std::endl;
2212 2029
2213 2030 std::this_thread::sleep_for( std::chrono::seconds(1) );
2214 2031 }
2215 2032
2216 2033 std::cout << __FILE__ << ":" << __LINE__ << " held." << std::endl;
2217 2034
2218 2035 }
2219 2036
2220 
2221 
2222 AppBase.cpp:198 0
2223 [2020-Jul-08 08:45:25.400] AppBase.cpp:298 logs/Admin(1)/2020-07-08.log Admin(1) buildSite logon ip:71.170.246.90 w:1920 h:1080
2224 [2020-Jul-08 13:45:26.471] 26022 [/staff2 tg4JC7kUmbwSwunn] [warning] "WApplication: WApplication::addMetaHeader() with no effect"
2225 AppBase.cpp:198 1
2226 [2020-Jul-08 13:45:27.406] 26022 [/staff2 tg4JC7kUmbwSwunn] [error] "Wt: decodeSignal(): signal 'orp26iu.render' not exposed"
2227 AppBase.cpp:198 2
2228 AppBase.cpp:198 3
2229 AppBase.cpp:198 4
2230 AppBase.cpp:198 5
2231 src/AppStaff.cpp:2028 holding... 0
2232 src/AppStaff.cpp:2028 holding... 1
2233 src/AppStaff.cpp:2028 holding... 2
2234 src/AppStaff.cpp:2028 holding... 3
2235 src/AppStaff.cpp:2028 holding... 4
2236 src/AppStaff.cpp:2028 holding... 5
2237 src/AppStaff.cpp:2028 holding... 6
2238 src/AppStaff.cpp:2028 holding... 7
2239 src/AppStaff.cpp:2028 holding... 8
2240 src/AppStaff.cpp:2028 holding... 9
2241 src/AppStaff.cpp:2033 held.
2242 AppBase.cpp:198 6
2243 AppBase.cpp:198 7
2244 AppBase.cpp:198 8
2245 AppBase.cpp:198 9
2246 ^Csleep for 1
2247 ** \endcode
2248 **
2249 */
2250 
2251 
2252