Exemplo n.º 1
0
        private void GenerateLogsInternal(int numberOfLogs, Action <RawLogData> actionToAdd, Action <List <RawLogData> > actionToSend)
        {
            var logsToCreate    = 20;
            var numberOfThreads = numberOfLogs / 20;

            if (numberOfLogs < logsToCreate)
            {
                logsToCreate    = numberOfLogs;
                numberOfThreads = 1;
            }

            Parallel.For(0, numberOfThreads, item =>
            {
                log.Error($"Sending batch - {item} of {numberOfLogs / 20}");
                var lst = new List <RawLogData>();
                GetAppLogs(logsToCreate).ForEach(appItem =>
                {
                    var entry = new RawLogData()
                    {
                        Type = StoredLogType.AppLog, Data = JsonUtils.Serialize(appItem), ReceiveDate = DateTime.UtcNow
                    };
                    if (actionToAdd != null)
                    {
                        actionToAdd(entry);
                    }
                    lst.Add(entry);
                });

                if (actionToSend != null)
                {
                    actionToSend(lst);
                }
            });
        }
Exemplo n.º 2
0
        public void SaveLog(RawLogData data)
        {
            if (data == null)
            {
                log.Error("Error ");
                return;
            }

            SaveLog(new List <RawLogData> {
                data
            });
        }
Exemplo n.º 3
0
        static void SendAppLogToServer(AppLog appLog)
        {
            var serverUrl = "http://localhost:9090";

            FlurlHttp.Configure(settings => settings.OnErrorAsync = HandleFlurlErrorAsync);

            var entry = new RawLogData()
            {
                Type = StoredLogType.AppLog, Data = JsonUtils.Serialize(appLog), ReceiveDate = DateTime.UtcNow
            };

            var result = (serverUrl + ControllerConstants.AddAppLogUrl.AddFirstChar('/'))
                         .WithHeader(HeaderContants.AppId, "APPID_1")
                         .PostJsonAsync(entry).Result;
        }
 public void SaveLog(RawLogData data)
 {
     throw new NotImplementedException();
 }