Example #1
0
void Banner::SetProperty(string const & name, string const & value)
{
  if (name == "messages")
  {
    m_messageBase = value;
  }
  else if (name == "icon")
  {
    m_iconName = value;
  }
  else if (name == "url")
  {
    CHECK(strings::StartsWith(value, "http://") || strings::StartsWith(value, "https://"),
          ("URL without a protocol for banner", m_id));
    m_defaultUrl = value;
  }
  else if (name == "start")
  {
    if (!StringToTimestamp(value, m_activeAfter))
      LOG(LERROR, ("Wrong start date", value, "for banner", m_id));
  }
  else if (name == "end")
  {
    if (!StringToTimestamp(value, m_activeBefore))
      LOG(LERROR, ("Wrong end date", value, "for banner", m_id));
    else
      m_activeBefore += 24 * 60 * 60;  // Add a day so we don't miss one
  }
  else
  {
    m_properties.emplace(make_pair(name, value));
  }
}
	bool BeginReadWriteRecords()
	{
		SessionRecords.Empty();

		// Lock and read the list of sessions in storage
		FString ListSectionName = GetStoreSectionString(EditorAnalyticsDefs::SessionRecordListSection);

		// Write list to SessionRecords member
		FString SessionListString;
		FPlatformMisc::GetStoredValue(EditorAnalyticsDefs::StoreId, ListSectionName, TEXT("SessionList"), SessionListString);

		// Parse SessionListString for session ids
		TArray<FString> SessionIds;
		SessionListString.ParseIntoArray(SessionIds, TEXT(","));

		// Retrieve all the sessions in the list from storage
		for (FString& SessionId : SessionIds)
		{
			FString SectionName = GetStoreSectionString(SessionId);

			FString IsCrashString;
			FString EngineVersionString;
			FString TimestampString;
			FString IsDebuggerString;

			if (FPlatformMisc::GetStoredValue(EditorAnalyticsDefs::StoreId, SectionName, EditorAnalyticsDefs::CrashStoreKey, IsCrashString) &&
				FPlatformMisc::GetStoredValue(EditorAnalyticsDefs::StoreId, SectionName, EditorAnalyticsDefs::EngineVersionStoreKey, EngineVersionString) &&
				FPlatformMisc::GetStoredValue(EditorAnalyticsDefs::StoreId, SectionName, EditorAnalyticsDefs::TimestampStoreKey, TimestampString) &&
				FPlatformMisc::GetStoredValue(EditorAnalyticsDefs::StoreId, SectionName, EditorAnalyticsDefs::DebuggerStoreKey, IsDebuggerString))
			{
				FSessionRecord NewRecord;
				NewRecord.SessionId = SessionId;
				NewRecord.EngineVersion = EngineVersionString;
				NewRecord.Timestamp = StringToTimestamp(TimestampString);
				NewRecord.bCrashed = IsCrashString == EditorAnalyticsDefs::TrueValueString;
				NewRecord.bIsDebugger = IsDebuggerString == EditorAnalyticsDefs::TrueValueString;

				SessionRecords.Add(NewRecord);
			}
			else
			{
				// Clean up orphaned values, if there are any
				FPlatformMisc::DeleteStoredValue(EditorAnalyticsDefs::StoreId, SectionName, EditorAnalyticsDefs::CrashStoreKey);
				FPlatformMisc::DeleteStoredValue(EditorAnalyticsDefs::StoreId, SectionName, EditorAnalyticsDefs::EngineVersionStoreKey);
				FPlatformMisc::DeleteStoredValue(EditorAnalyticsDefs::StoreId, SectionName, EditorAnalyticsDefs::TimestampStoreKey);
				FPlatformMisc::DeleteStoredValue(EditorAnalyticsDefs::StoreId, SectionName, EditorAnalyticsDefs::DebuggerStoreKey);
			}
		}

		return true;
	}