Ejemplo n.º 1
0
        public static ApiResponseModel IsVerified(HttpContext ctx, IServiceProvider services)
        {
            var          data         = new ActivityLog();
            IActivityLog _activityLog = services.GetRequiredService <IActivityLog>();

            var response    = new ApiResponseModel();
            var validations = new List <Validation>();
            var AuthToken   = (ctx.Request.Headers.TryGetValue("AuthToken", out var authorizationToken)) ? authorizationToken.ToString() : string.Empty;

            data.AuthToken   = AuthToken;
            data.IPAddress   = ctx.Connection.RemoteIpAddress.ToString();
            data.UrlRequest  = ctx.Request.Path.Value;
            data.BodyMessage = ctx.Request.Method;

            _activityLog.saveLog(data);

            if (string.IsNullOrEmpty(AuthToken))
            {
                response.StatusCode = 401;
                validations.Add(new Validation()
                {
                    Key = "Token", Value = "dari api gateway"
                });
            }

            response.Validations = validations;

            return(response);
        }
 protected override void WriteResult(IConfigurable dataObject)
 {
     TaskLogger.LogEnter();
     try
     {
         if (dataObject != null)
         {
             ADUser            user         = (ADUser)dataObject;
             ExchangePrincipal mailboxOwner = ExchangePrincipal.FromADUser(user, null);
             using (MailboxSession mailboxSession = MailboxSession.OpenAsAdmin(mailboxOwner, CultureInfo.InvariantCulture, "Client=Management;Action=Get-MailboxActivityLog"))
             {
                 IActivityLog activityLog = ActivityLogFactory.Current.Bind(mailboxSession);
                 foreach (Activity activity in activityLog.Query())
                 {
                     base.WriteResult(new ActivityLogEntryPresentationObject(activity));
                 }
             }
         }
     }
     catch (StorageTransientException exception)
     {
         base.WriteError(exception, ErrorCategory.ReadError, null);
     }
     catch (StoragePermanentException exception2)
     {
         base.WriteError(exception2, ErrorCategory.ReadError, null);
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
Ejemplo n.º 3
0
 public AnnouncementHandler(IActivityLog activity, IPizzaCore core, IFileStorage storage, BotConfig config)
 {
     _activity = activity ?? throw new ArgumentNullException(nameof(activity));
     _core     = core ?? throw new ArgumentNullException(nameof(core));
     _storage  = storage ?? throw new ArgumentNullException(nameof(storage));
     _config   = config ?? throw new ArgumentNullException(nameof(config));
 }
        public static byte[] Serialize(IActivityLog activityLog)
        {
            List <Activity> list = activityLog.Query().Reverse <Activity>().ToList <Activity>();

            if (list.Count == 0)
            {
                return(Array <byte> .Empty);
            }
            byte[] array;
            using (MemoryStream memoryStream = new MemoryStream(list.Count * 128))
            {
                using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream))
                {
                    binaryWriter.Write(1);
                    binaryWriter.Write(1);
                    binaryWriter.Write(0L);
                    List <ActivityLogSerializer.PropertySerializer> propertySerializers = ActivityLogSerializer.SerializeActivitySchema(binaryWriter);
                    binaryWriter.Write(list.Count);
                    foreach (Activity activity in list)
                    {
                        ActivityLogSerializer.SerializeActivity(binaryWriter, activity, propertySerializers);
                        if (memoryStream.Length > 10485760L)
                        {
                            throw new NotSupportedException(string.Format("Serialization of activity logs longer than {0} is not supported", 10485760));
                        }
                    }
                    array = new byte[memoryStream.Length];
                    Array.Copy(memoryStream.GetBuffer(), array, memoryStream.Length);
                }
            }
            return(array);
        }
 public static void Deserialize(IActivityLog activityLog, byte[] serializedActivityLog)
 {
     Util.ThrowOnNullArgument(serializedActivityLog, "serializedActivityLog");
     if (serializedActivityLog.Length == 0)
     {
         return;
     }
     using (MemoryStream memoryStream = new MemoryStream(serializedActivityLog, true))
     {
         using (BinaryReader binaryReader = new BinaryReader(memoryStream))
         {
             binaryReader.ReadInt32();
             binaryReader.ReadInt32();
             binaryReader.ReadInt64();
             List <ActivityLogSerializer.SerializedPropertyInfo> propertyInfos = ActivityLogSerializer.DeserializeActivitySchema(binaryReader);
             int             num  = binaryReader.ReadInt32();
             List <Activity> list = new List <Activity>(num);
             for (int i = 0; i < num; i++)
             {
                 Activity item = ActivityLogSerializer.DeserializeActivity(binaryReader, propertyInfos);
                 list.Add(item);
             }
             activityLog.Reset();
             activityLog.Append(list);
         }
     }
 }
Ejemplo n.º 6
0
        IEnumerable <ReplayAction> IActionsSource.ReadActions(IActionWatermark watermark)
        {
            MrsTracer.Provider.Function("StorageActionsSource.ReadActions", new object[0]);
            IActivityLog        activityLog = ActivityLogFactory.Current.Bind(this.mailboxSession);
            List <ReplayAction> actionsIndescendingOrder = new List <ReplayAction>(100);

            foreach (Activity activity in activityLog.Query())
            {
                if (activity.ClientId.LoggedViaServerSideInstrumentation)
                {
                    IActionWatermark actionWatermark = new StorageActionWatermark(activity);
                    if (watermark != null && watermark.CompareTo(actionWatermark) >= 0)
                    {
                        break;
                    }
                    ReplayAction replayAction = this.TryConvertToAction(activity, actionWatermark);
                    if (replayAction != null)
                    {
                        actionsIndescendingOrder.Add(replayAction);
                    }
                }
            }
            for (int index = actionsIndescendingOrder.Count - 1; index >= 0; index--)
            {
                yield return(actionsIndescendingOrder[index]);
            }
            yield break;
        }
 public NewTrackLinkModel(ICosmosDBRepository <TrackItem> repositoryService, ICosmosDBRepository <ListCategory> categoryRepository, IActivityLog activityLogRepository)
 {
     this.repository         = repositoryService;
     this.categoryRepository = categoryRepository;
     this.activityLog        = activityLogRepository;
     this.NewTrack           = new TrackItem();
     this.NewTrack.ListName  = "Ausfahrten";
 }
Ejemplo n.º 8
0
 public NewFotoLinkModel(ICosmosDBRepository <CommentedLinkItem> repositoryService, ICosmosDBRepository <ListCategory> categoryRepository, IActivityLog activityLogRepository)
 {
     this.repository         = repositoryService;
     this.categoryRepository = categoryRepository;
     this.activityLog        = activityLogRepository;
     this.NewLink            = new CommentedLinkItem();
     this.NewLink.ListName   = "Fotosammlung";
 }
Ejemplo n.º 9
0
 public OptOutHandler(ILogger logger, BotConfig config, IOptOutState state, IPizzaCore core, IActivityLog activityLog, Func <DateTimeOffset> funcNow)
 {
     _logger      = logger ?? throw new ArgumentNullException(nameof(logger));
     _config      = config ?? throw new ArgumentNullException(nameof(config));
     _state       = state ?? throw new ArgumentNullException(nameof(state));
     _core        = core ?? throw new ArgumentNullException(nameof(core));
     _activityLog = activityLog ?? throw new ArgumentNullException(nameof(activityLog));
     _funcNow     = funcNow ?? throw new ArgumentNullException(nameof(funcNow));
 }
Ejemplo n.º 10
0
 public AccountController(SignInManager <ApplicationUser> signInManager,
                          UserManager <ApplicationUser> userManager,
                          ITokenHelper <ApplicationUser> tokenHelper,
                          IActivityLog activityLog)
 {
     _signInManager = signInManager;
     _userManager   = userManager;
     _tokenHelper   = tokenHelper;
     _activityLog   = activityLog;
 }
Ejemplo n.º 11
0
        public static void Deserialize(StoreSession storeSession, byte[] serializedActivityLog)
        {
            MailboxSession mailboxSession = storeSession as MailboxSession;

            if (mailboxSession != null)
            {
                IActivityLog activityLog = ActivityLogFactory.Current.Bind(mailboxSession);
                ActivityLogSerializer.Deserialize(activityLog, serializedActivityLog);
            }
        }
Ejemplo n.º 12
0
 public PizzaPlanner(ILogger logger, BotConfig config, IFileStorage storage, IPizzaInviter pizzaInviter, IPizzaCore core, IOptOutState optOutState, IActivityLog activityLog, Func <DateTimeOffset> funcNow)
 {
     _activityLog  = activityLog ?? throw new ArgumentNullException(nameof(activityLog));
     _funcNow      = funcNow ?? throw new ArgumentNullException(nameof(funcNow));
     _logger       = logger ?? throw new ArgumentNullException(nameof(logger));
     _storage      = storage ?? throw new ArgumentNullException(nameof(storage));
     _pizzaInviter = pizzaInviter ?? throw new ArgumentNullException(nameof(pizzaInviter));
     _core         = core ?? throw new ArgumentNullException(nameof(core));
     _optOutState  = optOutState ?? throw new ArgumentNullException(nameof(optOutState));
     _config       = config ?? throw new ArgumentNullException(nameof(config));
 }
Ejemplo n.º 13
0
        public static byte[] Serialize(StoreSession storeSession)
        {
            MailboxSession mailboxSession = storeSession as MailboxSession;

            if (mailboxSession != null)
            {
                IActivityLog activityLog = ActivityLogFactory.Current.Bind(mailboxSession);
                return(ActivityLogSerializer.Serialize(activityLog));
            }
            return(Array <byte> .Empty);
        }
Ejemplo n.º 14
0
 public NewEventModel(ICosmosDBRepository <CalendarItem> calendarRepository, ICosmosDBRepository <ListCategory> categoryRepository, IActivityLog activityLogRepository)
 {
     _repository             = calendarRepository;
     _categoryRepository     = categoryRepository;
     _activityLog            = activityLogRepository;
     this.NewEvent           = new CalendarItem();
     this.NewEvent.StartDate = DateTime.Today.AddDays(1.0).AddHours(12.0);
     this.NewEvent.EndDate   = this.NewEvent.StartDate.AddHours(2.0);
     NewEvent.CalendarName   = "Termin";
     NewEvent.TimeToLive     = 16070400;
 }
Ejemplo n.º 15
0
        public PizzaServiceHost(ILogger logger, CancellationTokenSource cts, IPizzaCore pizzaCore, IPizzaInviter inviter, PizzaPlanner planner, IOptOutHandler optOutHandler, IAnnouncementHandler annoucementHandler, IActivityLog activityLog)
        {
            _activityLog = activityLog ?? throw new ArgumentNullException(nameof(activityLog));
            _logger      = logger ?? throw new ArgumentNullException(nameof(logger));
            _cts         = cts ?? throw new ArgumentNullException(nameof(cts));
            _pizzaCore   = pizzaCore ?? throw new ArgumentNullException(nameof(pizzaCore));

            _resources = new List <IMustBeInitialized>()
            {
                inviter, planner, optOutHandler, annoucementHandler
            };
            _handlers = new List <IMessageHandler>()
            {
                inviter, optOutHandler
            };
        }
Ejemplo n.º 16
0
 public LoggedPageModel(IActivityLog activityLog, string pageCategory)
 {
     _activityLogger = activityLog;
     category        = pageCategory;
 }
Ejemplo n.º 17
0
 public NewArticleModel(ICosmosDBRepository <Article> repositoryService, ICosmosDBRepository <ArticleTag> tagRepository, IActivityLog activityLogRepository, IConfiguration configuration) : base(activityLogRepository, "NewArticle")
 {
     this.repository    = repositoryService;
     this.tagRepository = tagRepository;
     this.NewArticle    = new Article();
     this.configuration = configuration;
 }
Ejemplo n.º 18
0
 public AusfahrtenModel(ICosmosDBRepository <TrackItem> repositoryService, IActivityLog activityLogRepository, IFunctionSiteTools functionSiteTools) : base(activityLogRepository, "Rad")
 {
     this.repository    = repositoryService;
     _functionSiteTools = functionSiteTools;
 }
Ejemplo n.º 19
0
 public IndexModel(ICosmosDBRepository <Article> repositoryService, ICosmosDBRepository <ArticleTag> tagService, IActivityLog activityLogRepository) : base(activityLogRepository, "Blog")
 {
     this.repository     = repositoryService;
     this.tagsRepository = tagService;
 }
Ejemplo n.º 20
0
 public ActivityLogsController(IActivityLog activityLog)
 {
     _activityLog = activityLog;
 }
Ejemplo n.º 21
0
 public ArtikelModel(ICosmosDBRepository <Article> articleRepository, IActivityLog activityLog, IFunctionSiteTools functionSiteTools) : base(activityLog, "Blog")
 {
     repository         = articleRepository;
     _functionSiteTools = functionSiteTools;
 }
Ejemplo n.º 22
0
 public AboutModel(IActivityLog activityLog) : base(activityLog, "About")
 {
 }
Ejemplo n.º 23
0
 public AlbumModel(ICosmosDBRepository <CommentedLinkItem> repositoryService, IActivityLog activityLogRepository)
 {
     this.repository  = repositoryService;
     this.activityLog = activityLogRepository;
 }
 private ActivityLogFilter(IActivityLog log)
 {
     _log = log;
 }
Ejemplo n.º 25
0
 public IndexModel(ICosmosDBRepository <CommentedLinkItem> repositoryService, IActivityLog activityLog) : base(activityLog, "Fotos")
 {
     this.repository = repositoryService;
 }
Ejemplo n.º 26
0
 public ActivityController(IActivityLog log)
 {
     _log = log ?? throw new ArgumentNullException(nameof(log));
 }
Ejemplo n.º 27
0
 public IndexModel(ICosmosDBRepository <TrackItem> trackRepository, ICosmosDBRepository <ListCategory> categoryRepository, ICosmosDBRepository <Article> articleRepository, IActivityLog activityLog, IFunctionSiteTools functionSiteTools) : base(activityLog, "Wanderungen")
 {
     this.repository         = trackRepository;
     this.categoryRepository = categoryRepository;
     this.articleRepository  = articleRepository;
     _functionSiteTools      = functionSiteTools;
 }
Ejemplo n.º 28
0
 public IndexModel(ICosmosDBRepository <CalendarItem> calendarRepository, ICosmosDBRepository <ListCategory> categoryRepository, ICosmosDBRepository <Article> articleRepository, IActivityLog activityLog, IFunctionSiteTools functionSiteTools) : base(activityLog, "Termine")
 {
     _calendarRepository = calendarRepository;
     _categoryRepository = categoryRepository;
     _articleRepository  = articleRepository;
     _functionSiteTools  = functionSiteTools;
 }
Ejemplo n.º 29
0
 public ScuderiaModel(ICosmosDBRepository <CommentedLinkItem> repositoryService, IActivityLog activityLogRepository) : base(activityLogRepository, "Rad")
 {
     this.repository  = repositoryService;
     this.activityLog = activityLogRepository;
 }