Пример #1
0
        /// <summary>
        /// Write the trace information to the trace table
        /// </summary>
        /// <param name="ado"></param>
        /// <param name="request"></param>
        /// <param name="inTransaction"></param>
        /// <returns></returns>
        internal static int Execute(ADO ado, JSONRPC_API request)
        {
            //Check in case the NoTrace attribute is set for the requested API method
            //If so, don't proceed with the trace.
            if (Resources.MethodReader.MethodHasAttribute(request.method, "NoTrace"))
            {
                return(0);
            }

            Trace_ADO        tAdo = new Trace_ADO();
            Trace_DTO_Create dto  = new Trace_DTO_Create();

            if (ActiveDirectory.IsAuthenticated(request.userPrincipal))
            {
                dto.CcnUsername = request.userPrincipal.SamAccountName.ToString();
            }

            dto.TrcIp        = request.ipAddress;
            dto.TrcMethod    = request.method;
            dto.TrcParams    = JSONRPC.MaskParameters(request.parameters.ToString());
            dto.TrcUseragent = request.userAgent;

            int created = tAdo.Create(ado, dto);

            if (created == 0)
            {
                Log.Instance.Debug("Can't create trace");
            }
            return(created);
        }
Пример #2
0
        /// <summary>
        /// Creates a Trace
        /// </summary>
        /// <param name="ado"></param>
        /// <param name="trace"></param>
        /// <param name="inTransaction"></param>
        /// <returns></returns>
        internal int Create(ADO ado, Trace_DTO_Create trace)
        {
            List <ADO_inputParams> inputParamList = new List <ADO_inputParams>()
            {
                new ADO_inputParams()
                {
                    name = "@TrcMethod", value = trace.TrcMethod
                },
                new ADO_inputParams()
                {
                    name = "@TrcParams", value = trace.TrcParams
                },
                new ADO_inputParams()
                {
                    name = "@TrcIp", value = trace.TrcIp
                },
                new ADO_inputParams()
                {
                    name = "@TrcUseragent", value = trace.TrcUseragent
                }
            };

            if (!string.IsNullOrEmpty(trace.CcnUsername))
            {
                inputParamList.Add(new ADO_inputParams()
                {
                    name = "@CcnUsername", value = trace.CcnUsername
                });
            }

            // A return parameter is required for the operation
            ADO_returnParam retParam = new ADO_returnParam();

            retParam.name  = "return";
            retParam.value = 0;

            //Executing the stored procedure
            ado.ExecuteNonQueryProcedure("Security_Trace_Create", inputParamList, ref retParam);

            return(retParam.value);
        }