コード例 #1
0
        private Guid LogRequest(AuditLogConnector logConnector, String appId, String userId)
        {
            Guid g = Guid.NewGuid();

            Logger.Trace($"{DateTime.Now} Log Request Here with GUID: {g}");
            logConnector.LogRequest(g, appId, userId);
            logConnector.StartLogData(g, appId, userId);
            return(g);
        }
コード例 #2
0
        private Row LogRow(AuditLogConnector logConnector, Guid g, String appId, String userId, double numData, double returnData)
        {
            var resultRow = new Row();

            Logger.Trace($"     {g} : {numData.ToString()}");
            resultRow.Duals.Add(new Dual {
                NumData = returnData
            });
            logConnector.LogData(g, numData.ToString());
            return(resultRow);
        }
コード例 #3
0
        private Row LogRow(AuditLogConnector logConnector, Guid g, String appId, String userId, string strData, string returnData)
        {
            var resultRow = new Row();

            Logger.Trace($"     {g} : {strData}");
            resultRow.Duals.Add(new Dual {
                StrData = returnData
            });
            logConnector.LogData(g, strData);
            return(resultRow);
        }
コード例 #4
0
        public override async Task ExecuteFunction(IAsyncStreamReader <BundledRows> requestStream, IServerStreamWriter <BundledRows> responseStream, ServerCallContext context)
        {
            Logger.Trace("-- ExecuteFunction --");

            if (logType == "file")
            {
                logConnector = new FileAuditLogConnector();
            }

            Dictionary <String, String> headerInfo = TraceServerCallContext(context);

            var functionRequestHeaderStream = context.RequestHeaders.SingleOrDefault(header => header.Key == "qlik-functionrequestheader-bin");

            if (functionRequestHeaderStream == null)
            {
                throw new Exception("ExecuteFunction called without Function Request Header in Request Headers.");
            }

            var functionRequestHeader = new FunctionRequestHeader();

            functionRequestHeader.MergeFrom(new CodedInputStream(functionRequestHeaderStream.ValueBytes));

            //Logger.Trace($"FunctionRequestHeader.FunctionId String : {(FunctionConstant)functionRequestHeader.FunctionId}");

            Guid g = LogRequest(logConnector, headerInfo["AppId"], headerInfo["UserId"]);

            switch (functionRequestHeader.FunctionId)
            {
            case (int)FunctionConstant.LogAsSeenStrCheck:
            {
                while (await requestStream.MoveNext())
                {
                    var resultBundle  = new BundledRows();
                    var cacheMetadata = new Metadata
                    {
                        { new Metadata.Entry("qlik-cache", "no-store") }
                    };

                    await context.WriteResponseHeadersAsync(cacheMetadata);

                    foreach (var row in requestStream.Current.Rows)
                    {
                        Row resultRow = LogRow(logConnector, g, headerInfo["AppId"], headerInfo["UserId"], row.Duals[0].StrData, "√");
                        resultBundle.Rows.Add(resultRow);
                    }
                    await responseStream.WriteAsync(resultBundle);
                }

                break;
            }

            case (int)FunctionConstant.LogAsSeenStrEcho:
            {
                while (await requestStream.MoveNext())
                {
                    var resultBundle  = new BundledRows();
                    var cacheMetadata = new Metadata
                    {
                        { new Metadata.Entry("qlik-cache", "no-store") }
                    };

                    await context.WriteResponseHeadersAsync(cacheMetadata);

                    foreach (var row in requestStream.Current.Rows)
                    {
                        Row resultRow = LogRow(logConnector, g, headerInfo["AppId"], headerInfo["UserId"], row.Duals[0].StrData, row.Duals[0].StrData);
                        resultBundle.Rows.Add(resultRow);
                    }
                    await responseStream.WriteAsync(resultBundle);
                }

                break;
            }

            case (int)FunctionConstant.LogAsSeenCheck:
            {
                while (await requestStream.MoveNext())
                {
                    var resultBundle  = new BundledRows();
                    var cacheMetadata = new Metadata
                    {
                        { new Metadata.Entry("qlik-cache", "no-store") }
                    };

                    await context.WriteResponseHeadersAsync(cacheMetadata);

                    foreach (var row in requestStream.Current.Rows)
                    {
                        Row resultRow = LogRow(logConnector, g, headerInfo["AppId"], headerInfo["UserId"], row.Duals[0].NumData, "√");
                        resultBundle.Rows.Add(resultRow);
                    }
                    await responseStream.WriteAsync(resultBundle);
                }

                break;
            }

            case (int)FunctionConstant.LogAsSeenEcho:
            {
                while (await requestStream.MoveNext())
                {
                    var resultBundle  = new BundledRows();
                    var cacheMetadata = new Metadata
                    {
                        { new Metadata.Entry("qlik-cache", "no-store") }
                    };

                    await context.WriteResponseHeadersAsync(cacheMetadata);

                    foreach (var row in requestStream.Current.Rows)
                    {
                        Row resultRow = LogRow(logConnector, g, headerInfo["AppId"], headerInfo["UserId"], row.Duals[0].NumData, row.Duals[0].NumData);
                        resultBundle.Rows.Add(resultRow);
                    }
                    await responseStream.WriteAsync(resultBundle);
                }

                break;
            }

            default:
                break;
            }

            logConnector.EndLogData();

            Logger.Trace("-- (ExecuteFunction) --");
        }