Skip to content
Snippets Groups Projects
Select Git revision
  • 5263c7a5af047eb2f749e8ab66006a32f0accb3d
  • master default protected
  • gitkeep
  • dev protected
  • Issue/2309-docs
  • Hotfix/2097-fixTimeFormat
  • Issue/1910-MigrationtoNET6.0
  • Sprint/2022-01
  • Sprint/2021-05
  • Product/1188-LoggingExtended
  • Topic/1221-LogginExtendedNew
  • Sprint/2021-03
  • Product/1287-dotnet5Sharepoint
  • Topic/1334-dotnet5migration
  • Topic/1221-LoggingExtended
  • Sprint/2021-01
  • Product/407-net5migration
  • Topic/1226-loggingLibraryMigration
  • v2.2.2
  • v2.2.1
  • v2.2.0
  • v2.1.0
  • v2.0.0
  • v1.3.0
  • v1.2.0
  • v1.1.0
  • v1.0.1
  • v1.0.0
28 results

AnalyticsLogObject.cs

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    AnalyticsLogObject.cs 6.85 KiB
    using Newtonsoft.Json.Linq;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace Coscine.Logging
    {
        [Serializable]
        public class AnalyticsLogObject
        {
            private string _type = "";
            public string Type { 
                get
                {
                    return _type;
                }
                set
                {
                    if (value == null)
                    {
                        _type = "";
                    }
                    else
                    {
                        _type = value;
                    }
                }
            }
    
            private string _operation = "";
    
            public string Operation {
                get
                {
                    return _operation;
                }
                set
                {
                    if (value == null)
                    {
                        _operation = "";
                    }
                    else
                    {
                        _operation = value;
                    }
                }
            }
    
            // Default is the current time
            private string _timestamp = FormatTimestamp(DateTime.UtcNow);
    
            public string Timestamp
            {
                get
                {
                    return _timestamp;
                }
                set
                {
                    if (value == null)
                    {
                        _timestamp = FormatTimestamp(DateTime.UtcNow);
                    }
                    else
                    {
                        _timestamp = value;
                    }
                }
            }
    
            private string _userId = "";
    
            public string UserId
            {
                get
                {
                    return _userId;
                }
                set
                {
                    if (value == null)
                    {
                        _userId = "";
                    }
                    else
                    {
                        _userId = value;
                    }
                }
            }
    
            private string _roleId = "";
    
            public string RoleId
            {
                get
                {
                    return _roleId;
                }
                set
                {
                    if (value == null)
                    {
                        _roleId = "";
                    }
                    else
                    {
                        _roleId = value;
                    }
                }
            }
    
            private string _sessionId = "";
    
            public string SessionId
            {
                get
                {
                    return _sessionId;
                }
                set
                {
                    if (value == null)
                    {
                        _sessionId = "";
                    }
                    else
                    {
                        _sessionId = value;
                    }
                }
            }
    
            private string _clientCorrolationId = "";
    
            public string ClientCorrolationId
            {
                get
                {
                    return _clientCorrolationId;
                }
                set
                {
                    if (value == null)
                    {
                        _clientCorrolationId = "";
                    }
                    else
                    {
                        _clientCorrolationId = value;
                    }
                }
            }
    
            private string _projectId = "";
    
            public string ProjectId
            {
                get
                {
                    return _projectId;
                }
                set
                {
                    if (value == null)
                    {
                        _projectId = "";
                    }
                    else
                    {
                        _projectId = value;
                    }
                }
            }
    
            private string _resourceId = "";
    
            public string ResourceId
            {
                get
                {
                    return _resourceId;
                }
                set
                {
                    if (value == null)
                    {
                        _resourceId = "";
                    }
                    else
                    {
                        _resourceId = value;
                    }
                }
            }
    
            private string _fileId = "";
    
            public string FileId
            {
                get
                {
                    return _fileId;
                }
                set
                {
                    if (value == null)
                    {
                        _fileId = "";
                    }
                    else
                    {
                        _fileId = value;
                    }
                }
            }
    
            private List<string> _projectList = new List<string>();
    
            public List<string> ProjectList
            {
                get
                {
                    return _projectList;
                }
                set
                {
                    if (value == null)
                    {
                        _projectList = new List<string>();
                    }
                    else
                    {
                        _projectList = value;
                    }
                }
            }
    
            private List<string> _resourceList = new List<string>();
    
            public List<string> ResourceList
            {
                get
                {
                    return _resourceList;
                }
                set
                {
                    if (value == null)
                    {
                        _resourceList = new List<string>();
                    }
                    else
                    {
                        _resourceList = value;
                    }
                }
            }
    
            private List<string> _userList = new List<string>();
    
            public List<string> UserList
            {
                get
                {
                    return _userList;
                }
                set
                {
                    if (value == null)
                    {
                        _userList = new List<string>();
                    }
                    else
                    {
                        _userList = value;
                    }
                }
            }
    
            public AnalyticsLogObject (string type, string operation, DateTime timestamp, string userId, string roleId, string sessionId, string clientCorrolationId, string projectId, string resourceId, string fileId, List<string> projectList, List<string> resourceList, List<string> userList)
            {
                Type = type;
                Operation = operation;
                Timestamp = FormatTimestamp(timestamp);
                UserId = userId;
                RoleId = roleId;
                SessionId = sessionId;
                ClientCorrolationId = clientCorrolationId;
                ProjectId = projectId;
                ResourceId = resourceId;
                FileId = fileId;
                ProjectList = projectList;
                ResourceList = resourceList;
                UserList = userList;
            }
    
            public AnalyticsLogObject()
            {
            }
    
            private static string FormatTimestamp(DateTime timestamp)
            {
                string formattedDateTime = String.Format("{0:yyyy-MM-dd hh:mm:ss.fff}", timestamp);
                return formattedDateTime;
            }
        }
    }