3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.1 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 /*@file: IntPresentationModelBase.cpp
20 *@brief: Defines the database/storage functions.
26 #include "IntPresentationModelBase.h"
29 const wchar_t* BOOKMARK_URL_TABLE = L"Bookmarks";
30 //const wchar_t* BOOKMARK_FOLDER_TABLE = L"BookmarkFolder";
31 const wchar_t* HISTORY_DATA_TABLE = L"History";
33 using namespace Tizen::App;
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Collection;
36 using namespace Tizen::Base::Utility;
37 using namespace Tizen::Io;
38 using namespace Tizen::Locales;
39 using namespace Tizen::System;
41 const int PresentationModelBase::MAX_DB_QUERY_SIZE = 21474836;
42 const int PresentationModelBase::QUERY_TYPE_LENGTH = 6;
44 PresentationModelBase::PresentationModelBase(void)
48 __pDbStatement = null;
49 __isBeginTransaction = false;
50 DB_FILE_PATH = L"/opt/usr/dbspace/.browser-history.db";
53 PresentationModelBase::~PresentationModelBase(void)
59 PresentationModelBase::Initialize(void)
69 PresentationModelBase::UnInitialize(void)
73 r = PresentationModelBase::CloseDb();
79 PresentationModelBase::OpenDb(void)
83 if (__pDataBase != null)
85 if (__pDbEnum != null)
90 if (__pDbStatement != null)
92 delete __pDbStatement;
93 __pDbStatement = null;
97 __pDataBase = new(std::nothrow) Database();
98 if (null == __pDataBase)
100 return E_OUT_OF_MEMORY;
102 String dbName = DB_FILE_PATH;
104 r = __pDataBase->Construct(dbName, true);
107 AppLogDebug("DB construction failed:%s", GetErrorMessage(r));
114 __isBeginTransaction = false;
115 if (File::IsFileExist(dbName))
117 r = InitializeDBTables();
129 PresentationModelBase::CloseDb(void)
131 if (__pDbEnum != null)
136 if (__pDbStatement != null)
138 delete __pDbStatement;
139 __pDbStatement = null;
141 if (__pDataBase != null)
147 __isBeginTransaction = false;
153 PresentationModelBase::CreateDBTables(BrowserDbTableTypes tableType)
155 result r = E_FAILURE;
157 int resultCount = -1;
159 if (DB_FILE_PATH.CompareTo(L"/opt/usr/dbspace/.internet_bookmark.db") == 0)
163 case DB_TYPE_BOOKMARKURLS:
165 query.Append(L"CREATE TABLE IF NOT EXISTS ");
166 query.Append(BOOKMARK_URL_TABLE);
167 //query.Append(L" ( ID INTEGER PRIMARY KEY AUTOINCREMENT, TITLE TEXT, URL TEXT, PARENT_BOOKMARK_ID INTEGER DEFAULT -1, CREATED_TIME DATETIME, MODIFIED_TIME DATETIME, ICON_PATH TEXT, FAVICON_ID INTEGER)");
168 query.Append(L" ( ID INTEGER PRIMARY KEY AUTOINCREMENT, TYPE INTEGER, PARENT INTEGER DEFAULT -1, ADDRESS TEXT, TITLE TEXT, CREATIONDATE DATETIME, SEQUENCE INTEGER, UPDATEDATE DATETIME, VISITDATE DATETIME, EDITABLE INTEGER, ACCESSACCOUNT INTEGER, FAVICON BLOB, FAVICON_LENGTH INTEGER, FAVICON_W INTEGER, FAVICON_H INTEGER, CREATED_DATE DATETIME, ACCOUNT_NAME TEXT, ACCOUNT_TYPE TEXT, THUMBNAIL BLOB, THUMBNAIL_LENGTH INTEGER, THUMBNAIL_W INTEGER, THUMBNAIL_H INTEGER, VERSION INTEGER, SYNC TEXT, TAG1 TEXT, TAG2 TEXT, TAG3 TEXT, TAG4 TEXT)");
172 case DB_TYPE_FAVICON:
174 query.Append(L"CREATE TABLE IF NOT EXISTS FaviconData ( ID INTEGER PRIMARY KEY AUTOINCREMENT, URL TEXT, FILE_PATH TEXT )");
179 AppLogDebug("PresentationModelBase::CreateDBTables: Table Type:%d is invalid", tableType);
184 else if(DB_FILE_PATH.CompareTo(L"/opt/usr/dbspace/.browser-history.db") == 0)
188 case DB_TYPE_HISTORYDATA:
190 query.Append(L"CREATE TABLE IF NOT EXISTS ");
191 query.Append(HISTORY_DATA_TABLE);
192 //query.Append(L" ( ID INTEGER PRIMARY KEY AUTOINCREMENT, TITLE TEXT, URL TEXT, VISITED_TIME DATETIME, ICON_PATH TEXT, FAVICON_ID INTEGER, THUMBNAIL_PATH TEXT)");
193 query.Append(L"(ID INTEGER PRIMARY KEY AUTOINCREMENT, ADDRESS TEXT, TITLE TEXT, COUNTER INTEGER, VISITDATE DATETIME, FAVICON BLOB, FAVICON_LENGTH INTEGER, FAVICON_W INTEGER, FAVICON_H INTEGER, SNAPSHOT BLOB, SNAPSHOT_STRIDE INTEGER, SNAPSHOT_W INTEGER, SNAPSHOT_H INTEGER)");
196 case DB_TYPE_FAVICON:
198 query.Append(L"CREATE TABLE IF NOT EXISTS FaviconData ( ID INTEGER PRIMARY KEY AUTOINCREMENT, URL TEXT, FILE_PATH TEXT )");
203 AppLogDebug("PresentationModelBase::CreateDBTables: Table Type:%d is invalid", tableType);
209 r = PresentationModelBase::ExecuteQuery(query, resultCount);
210 TryCatch(!IsFailed(r),,"PresentationModelBase::CreateDBTables query failed %s",GetErrorMessage(r));
216 PresentationModelBase::InitializeDBTables(void)
218 result r = E_FAILURE;
219 AppLog("DB_FILE_PATH :%ls", String(DB_FILE_PATH).GetPointer());
220 for (register int nDbTblIndex = DB_TYPE_INVALID + 1; nDbTblIndex < DB_TYPE_MAX; nDbTblIndex++)
222 r = CreateDBTables((BrowserDbTableTypes) nDbTblIndex);
223 TryCatch(!IsFailed(r),,"PresentationModelBase::InitializeDBTables failed %s",GetErrorMessage(r));
230 PresentationModelBase::DropDBTables(void)
232 result r = E_FAILURE;
234 int resultCount = -1;
236 for (register int tableIndex = DB_TYPE_INVALID + 1; tableIndex < DB_TYPE_MAX; tableIndex++)
240 case DB_TYPE_BOOKMARKURLS:
243 query.Format(MAX_DB_QUERY_SIZE, L"DROP TABLE IF EXISTS Bookmark");
246 /*case DB_TYPE_BOOKMARKFOLDERS:
249 query.Format(MAX_DB_QUERY_SIZE, L"DROP TABLE IF EXISTS BookmarkFolder");
253 case DB_TYPE_HISTORYDATA:
256 query.Format(MAX_DB_QUERY_SIZE, L"DROP TABLE IF EXISTS HistoryData");
260 case DB_TYPE_FAVICON:
263 query.Format(MAX_DB_QUERY_SIZE, L"DROP TABLE IF EXISTS FaviconData");
268 r = PresentationModelBase::ExecuteQuery(query, resultCount);
269 TryCatch( !IsFailed(r),,"PresentationModelBase::DropDBTables query failed %s",GetErrorMessage(r));
276 PresentationModelBase::ExecuteQuery(const String& formatQuery, int& count)
278 AppLogDebug("rahul Query: %ls", formatQuery.GetPointer());
280 result r = E_FAILURE;
283 if (__pDataBase == null)
285 return E_INIT_FAILED;
288 if (__pDbEnum != null)
294 if (__pDbStatement != null)
296 delete __pDbStatement;
297 __pDbStatement = null;
301 #if defined(FBK_DB_QUERY_LOG)
304 file.Construct(L"/Home/Query.txt", "a+", true);
305 file.Write(formatQuery);
306 file.Write(String("\r\n"));
310 r = formatQuery.SubString(0, QUERY_TYPE_LENGTH, queryType);
313 if (queryType == "SELECT")
315 __pDbEnum = __pDataBase->QueryN(formatQuery);
319 AppLogException("Failed Database::QueryN(). (error: %s, query: %ls)", GetErrorMessage(r), formatQuery.GetPointer());
324 if (__pDbEnum != null)
326 while (__pDbEnum->MoveNext() == E_SUCCESS)
336 if (__isBeginTransaction == false &&
337 (queryType == L"INSERT" || queryType == L"UPDATE" || queryType == L"DELETE"))
339 r = __pDataBase->BeginTransaction();
342 AppLogException("Failed Database::BeginTransaction() . (error: %s)", GetErrorMessage(r));
346 __isBeginTransaction = true;
349 r = __pDataBase->ExecuteSql(formatQuery, false);
352 AppLogException("Failed Database::ExecuteSql(). (error: %s, query: %ls)", GetErrorMessage(r), formatQuery.GetPointer());
363 PresentationModelBase::ExecuteBookmarkQuery(const Tizen::Base::String& formatQuery, int& count, BookmarkData& bookmark)
365 AppLogDebug("PresentationModelBase::ExecuteBookmarkQuery Query: %ls", formatQuery.GetPointer());
367 result r = E_FAILURE;
372 String bookmarkTitle = bookmark.GetBookmarkTitle();
373 bookmarkTitle.Replace(L"'", L"\'");
374 String bookmarkUrl = bookmark.GetUrl();
375 bookmarkUrl.Replace(L"'", L"\'");
377 PresentationModelBase::GetCurrentDateTime(dt);
379 if (__pDataBase == null)
381 return E_INIT_FAILED;
384 if (__pDbEnum != null)
390 if (__pDbStatement != null)
392 delete __pDbStatement;
393 __pDbStatement = null;
397 #if defined(FBK_DB_QUERY_LOG)
400 file.Construct(L"/Home/Query.txt", "a+", true);
401 file.Write(formatQuery);
402 file.Write(String("\r\n"));
406 r = formatQuery.SubString(0, QUERY_TYPE_LENGTH, queryType);
409 if (queryType == "SELECT")
411 __pDbEnum = __pDataBase->QueryN(formatQuery);
415 AppLogException("Failed Database::QueryN(). (error: %s, query: %ls)", GetErrorMessage(r), formatQuery.GetPointer());
420 if (__pDbEnum != null)
422 while (__pDbEnum->MoveNext() == E_SUCCESS)
431 if (__isBeginTransaction == false && (queryType == L"INSERT" ))
433 r = __pDataBase->BeginTransaction();
436 AppLogException("Failed Database::BeginTransaction() . (error: %s)", GetErrorMessage(r));
440 __isBeginTransaction = true;
441 __pDbStatement = __pDataBase->CreateStatementN(formatQuery);
442 __pDbStatement->BindInt(0,bookmark.GetBookmarkType());
443 __pDbStatement->BindString(1,bookmark.GetParentId());
444 __pDbStatement->BindString(2,bookmarkUrl);
445 __pDbStatement->BindString(3,bookmarkTitle);
446 DateTimeFormatter *pFormatter = DateTimeFormatter::CreateDateFormatterN(DATE_TIME_STYLE_DEFAULT);
447 pFormatter->ApplyPattern(L"yyyy-mm-dd hh:mm:ss");
449 pFormatter->Format(dt, dateStr);
450 AppLog("DateStr: %ls", dateStr.GetPointer());
451 __pDbStatement->BindString(4,dateStr);
452 __pDbStatement->BindString(5,dateStr);
454 if(bookmark.GetFavIconBuffer() != null)
456 __pDbStatement->BindBlob(6,*(bookmark.GetFavIconBuffer()));
458 __pDbStatement->BindInt(7,bookmark.GetFavIconWidth());
459 __pDbStatement->BindInt(8,bookmark.GetFavIconHeight());
461 __pDataBase->ExecuteStatementN(*__pDbStatement);
463 if (IsFailed(GetLastResult()))
465 AppLog("PresentationModelBase::ExecuteBookmarkQuery Failed Database::ExecuteSql(). (error: %s, query: %ls)", GetErrorMessage(r), formatQuery.GetPointer());
470 AppLog("PresentationModelBase::ExecuteBookmarkQuery success database");
474 else if (__isBeginTransaction == false && (queryType == L"UPDATE" || queryType == L"DELETE"))
476 r = __pDataBase->ExecuteSql(formatQuery, false);
479 AppLogException("Failed Database::ExecuteSql(). (error: %s, query: %ls)", GetErrorMessage(r), formatQuery.GetPointer());
492 PresentationModelBase::ExecuteHistoryQuery(const Tizen::Base::String& formatQuery, int& nRowCount, History& history)
495 AppLogDebug("Query: %ls", formatQuery.GetPointer());
497 result r = E_FAILURE;
502 String historyTitle = history.GetHistoryTitle();
503 historyTitle.Replace(L"'", L"\'");
505 String historyUrl = history.GetHistoryUrl();
506 historyUrl.Replace(L"'", L"\'");
508 GetCurrentDateTime(date);
510 if (__pDataBase == null)
512 return E_INIT_FAILED;
515 if (__pDbEnum != null)
521 if (__pDbStatement != null)
523 delete __pDbStatement;
524 __pDbStatement = null;
527 r = formatQuery.SubString(0, QUERY_TYPE_LENGTH, queryType);
530 if (queryType == "SELECT")
532 __pDbEnum = __pDataBase->QueryN(formatQuery);
536 AppLogException("Failed Database::QueryN(). (error: %s, query: %ls)", GetErrorMessage(r), formatQuery.GetPointer());
541 if (__pDbEnum != null)
543 while (__pDbEnum->MoveNext() == E_SUCCESS)
553 if (__isBeginTransaction == false && (queryType == L"INSERT"))
555 r = __pDataBase->BeginTransaction();
558 AppLogException("Failed Database::BeginTransaction() . (error: %s)", GetErrorMessage(r));
562 __isBeginTransaction = true;
563 __pDbStatement = __pDataBase->CreateStatementN(formatQuery);
564 if(GetLastResult() != E_SUCCESS)
566 AppLog("CreateStatementN error: %s", GetErrorMessage(GetLastResult()));
567 return GetLastResult();
569 r = __pDbStatement->BindString(0,historyUrl);
570 AppLog("BindString result historyUrl %s",GetErrorMessage(r));
571 r = __pDbStatement->BindString(1,historyTitle);
572 AppLog("BindString result historyTitle %s historyTitle %ls",GetErrorMessage(r),historyTitle.GetPointer());
574 String visitedTime = GetStringFromDate(date);
575 /*DateTimeFormatter *pFormatter = DateTimeFormatter::CreateDateFormatterN(DATE_TIME_STYLE_DEFAULT);
576 pFormatter->ApplyPattern(L"YYYY-MM-dd hh:mm:ss");
578 pFormatter->Format(date, dateStr);
579 AppLog("DateStr: %ls", dateStr.GetPointer());*/
580 __pDbStatement->BindString(2, visitedTime);
581 if(history.GetFavIconBuffer() != null)
583 __pDbStatement->BindBlob(3,*(history.GetFavIconBuffer()));
585 __pDbStatement->BindInt(4,history.GetFavIconWidth());
586 __pDbStatement->BindInt(5,history.GetFavIconHeight());
588 __pDataBase->ExecuteStatementN(*__pDbStatement);
590 if (IsFailed(GetLastResult()))
592 AppLog("PresentationModelBase::ExecuteBookmarkQuery Failed Database::ExecuteSql(). (error: %s, query: %ls)", GetErrorMessage(r), formatQuery.GetPointer());
597 AppLog("PresentationModelBase::ExecuteBookmarkQuery success database");
600 else if(__isBeginTransaction == false && (queryType == L"UPDATE" || queryType == L"DELETE"))
602 r = __pDataBase->ExecuteSql(formatQuery, false);
605 AppLogException("Failed Database::ExecuteSql(). (error: %s, query: %ls)", GetErrorMessage(r), formatQuery.GetPointer());
616 result PresentationModelBase::ExecuteUpdateHistoryFavIconQuery(const Tizen::Base::String& formatQuery, int& nRowCount, History& history)
618 result r = E_FAILURE;
621 r = Integer::Parse(history.GetHistoryId(), historyID);
623 if (__pDataBase == null)
625 return E_INIT_FAILED;
628 if (__pDbEnum != null)
634 if (__pDbStatement != null)
636 delete __pDbStatement;
637 __pDbStatement = null;
639 r = formatQuery.SubString(0, QUERY_TYPE_LENGTH, queryType);
641 if (__isBeginTransaction == false )
643 r = __pDataBase->BeginTransaction();
646 AppLogException("Failed Database::BeginTransaction() . (error: %s)", GetErrorMessage(r));
650 __isBeginTransaction = true;
651 __pDbStatement = __pDataBase->CreateStatementN(formatQuery);
652 if(GetLastResult() != E_SUCCESS)
654 AppLog("CreateStatementN error: %s", GetErrorMessage(GetLastResult()));
655 return GetLastResult();
657 __pDbStatement->BindBlob(0,*(history.GetFavIconBuffer()));
658 __pDbStatement->BindInt(1,history.GetFavIconWidth());
659 __pDbStatement->BindInt(2,history.GetFavIconHeight());
660 __pDbStatement->BindInt(3,historyID);
662 __pDataBase->ExecuteStatementN(*__pDbStatement);
664 if (IsFailed(GetLastResult()))
666 AppLog("PresentationModelBase::ExecuteBookmarkQuery Failed Database::ExecuteSql(). (error: %s, query: %ls)", GetErrorMessage(r), formatQuery.GetPointer());
671 AppLog("PresentationModelBase::ExecuteBookmarkQuery success database");
679 PresentationModelBase::DbIsNextRowPresent(bool& nextRowpresent)
681 result r = E_FAILURE;
683 if (null == __pDataBase || null == __pDbEnum)
685 if (__pDbEnum == null)
687 AppLogException("PresentationModelBase : pdbenum is null");
689 if (__pDataBase == null)
691 AppLogException("PresentationModelBase : __pDataBase is null");
693 return E_OUT_OF_MEMORY;
695 r = __pDbEnum->MoveNext();
698 nextRowpresent = false;
701 nextRowpresent = true;
706 PresentationModelBase::IsNullColumn(int index, bool& isColumNull)
708 if (null == __pDataBase || null == __pDbEnum)
712 isColumNull = (__pDbEnum->GetColumnType(index) == DB_COLUMNTYPE_NULL ? true : false);
718 PresentationModelBase::GetColumn(int index, String& stringValue)
720 result r = E_FAILURE;
721 DbColumnType columnType;
723 if (null == __pDataBase || null == __pDbEnum)
725 return E_OUT_OF_MEMORY;
728 columnType = __pDbEnum->GetColumnType(index);
730 //if column type is null then assign empty string and return
731 if (columnType == DB_COLUMNTYPE_NULL)
737 r = __pDbEnum->GetStringAt(index, stringValue);
740 AppLogDebug("GetStringAt: Failed");
747 PresentationModelBase::GetColumn(int index, int& intValue)
749 result r = E_FAILURE;
750 DbColumnType columnType;
752 if (null == __pDataBase || null == __pDbEnum)
754 return E_OUT_OF_MEMORY;
757 columnType = __pDbEnum->GetColumnType(index);
759 //if column type is null then assign empty string and return
760 if (columnType == DB_COLUMNTYPE_NULL)
766 r = __pDbEnum->GetIntAt(index, intValue);
767 TryCatch(!IsFailed(r),,"GetIntAt:failed %s",GetErrorMessage(r));
774 PresentationModelBase::GetColumn(int index, DateTime& dateValue)
776 result r = E_FAILURE;
779 if (null == __pDataBase || null == __pDbEnum)
781 AppLogDebug("__pDataBase or __pDbEnum is null");
782 return E_OUT_OF_MEMORY;
785 nType = __pDbEnum->GetColumnType(index);
786 //if column type is null then assign empty string and return
787 if (nType == DB_COLUMNTYPE_NULL)
792 r = __pDbEnum->GetDateTimeAt(index, dateValue);
795 AppLogDebug("GetDateTimeAt: Failed");
808 String dbColoumn = "";
809 __pDbEnum->GetStringAt(index, dbColoumn);
810 dbColoumn.IndexOf("-", 0, currIndex);
813 dbColoumn.SubString(0, currIndex ,temp);
814 Integer::Parse(temp, 10, year);
817 dbColoumn.IndexOf("-", currIndex + 1, nextIndex);
820 dbColoumn.SubString(currIndex + 1, nextIndex - currIndex - 1 ,temp);
821 Integer::Parse(temp, 10, month);
823 currIndex = nextIndex;
825 dbColoumn.IndexOf(" ", currIndex + 1, nextIndex);
828 dbColoumn.SubString(currIndex + 1, nextIndex - currIndex -1 ,temp);
829 Integer::Parse(temp, 10, day);
831 currIndex = nextIndex;
833 dbColoumn.IndexOf(":", currIndex + 1, nextIndex);
836 dbColoumn.SubString(currIndex + 1, nextIndex - currIndex -1 ,temp);
837 Integer::Parse(temp, 10, hour);
839 currIndex = nextIndex;
841 dbColoumn.IndexOf(":", currIndex + 1, nextIndex);
844 dbColoumn.SubString(currIndex + 1, nextIndex - currIndex -1 ,temp);
845 Integer::Parse(temp, 10, min);
847 currIndex = nextIndex;
849 dbColoumn.SubString(currIndex + 1, temp);
850 Integer::Parse(temp, 10, sec);
852 dateValue.SetValue(year, month, day, hour, min, sec);
860 PresentationModelBase::GetColumn(int index, double& doubleValue)
862 result r = E_FAILURE;
863 DbColumnType columnType;
865 if (null == __pDataBase || null == __pDbEnum)
867 return E_OUT_OF_MEMORY;
870 columnType = __pDbEnum->GetColumnType(index);
872 //if column type is null then assign empty string and return
873 if (columnType == DB_COLUMNTYPE_NULL)
879 r = __pDbEnum->GetDoubleAt(index, doubleValue);
882 AppLogDebug("GetDateTimeAt: Failed");
890 PresentationModelBase::GetColumn(int index,Tizen::Base::ByteBuffer& favIconBuffer)
892 result r = E_FAILURE;
893 DbColumnType columnType;
895 if (null == __pDataBase || null == __pDbEnum)
897 return E_OUT_OF_MEMORY;
900 columnType = __pDbEnum->GetColumnType(index);
902 //if column type is null then assign empty string and return
903 if (columnType == DB_COLUMNTYPE_NULL)
907 favIconBuffer.Construct(__pDbEnum->GetColumnSize(index));
909 r = __pDbEnum->GetBlobAt(index, favIconBuffer);
910 AppLog("PresentationModelBase::GetColumn favicon result is %s", GetErrorMessage(r));
915 AppLogDebug("GetDateTimeAt: Failed");
923 PresentationModelBase::RollbackDb()
925 result r = E_FAILURE;
927 if (__pDataBase != null && __isBeginTransaction == true)
929 r = __pDataBase->RollbackTransaction();
934 __isBeginTransaction = false;
940 PresentationModelBase::CommitDb()
943 result r = E_FAILURE;
945 if (__pDataBase != null && __isBeginTransaction == true)
947 r = __pDataBase->CommitTransaction();
948 TryCatch(!IsFailed(r),,"PresentationModelBase::Commit Transaction:failed %s",GetErrorMessage(r));
950 __isBeginTransaction = false;
958 PresentationModelBase::GetLastInsertedId(String& tableName, int& rowId)
961 result r = E_FAILURE;
963 bool nextRowpresent = false;
965 query.Append(L"SELECT last_insert_rowid() FROM ");
966 query.Append(tableName);
968 r = PresentationModelBase::ExecuteQuery(query, count);
969 TryCatch(!IsFailed(r),,"PresentationModelBase::GetLastInsertedId query failed %s",GetErrorMessage(r));
971 r = PresentationModelBase::DbIsNextRowPresent(nextRowpresent);
973 if (nextRowpresent == true)
975 r = PresentationModelBase::GetColumn(0, rowId);
978 AppLogDebug("PresentationModelBase::GetLstInsertedId -(%s)\n", GetErrorMessage(r));
986 PresentationModelBase::GetCurrentDateTime(DateTime& dt)
989 LocaleManager localManager;
990 result r = E_FAILURE;
993 r = SystemTime::GetCurrentTime(dt);
998 PresentationModelBase::GetStringFromDate(DateTime& date)
1000 String dateFormat = L"";
1001 dateFormat.Append(date.GetYear());
1002 dateFormat.Append('-');
1003 if(date.GetMonth() < 10)
1005 dateFormat.Append('0');
1007 dateFormat.Append(date.GetMonth());
1008 dateFormat.Append('-');
1009 if(date.GetDay() < 10)
1011 dateFormat.Append('0');
1013 dateFormat.Append(date.GetDay());
1014 dateFormat.Append(' ');
1015 if(date.GetHour() < 10)
1017 dateFormat.Append('0');
1019 dateFormat.Append(date.GetHour());
1020 dateFormat.Append(':');
1021 if(date.GetMinute() < 10)
1023 dateFormat.Append('0');
1025 dateFormat.Append(date.GetMinute());
1026 dateFormat.Append(':');
1027 if(date.GetSecond() < 10)
1029 dateFormat.Append('0');
1031 dateFormat.Append(date.GetSecond());