private static WatsonClientReport CreateClientWatsonReportAndUpdateCache(ClientWatsonReportData reportData, out string[] watsonParameters)
        {
            WatsonClientReport watsonClientReport = new WatsonClientReport(reportData.TraceComponent, reportData.FunctionName, reportData.ExceptionMessage, reportData.ExceptionType, reportData.OriginalCallStack, reportData.NormalizedCallStack, reportData.CallStackHash, reportData.PackageName);

            watsonParameters = watsonClientReport.GetWatsonParameters();
            ClientWatsonDatapointHandler.cachedFlavor  = watsonParameters[0];
            ClientWatsonDatapointHandler.cachedVersion = watsonParameters[1];
            return(watsonClientReport);
        }
        public ProcessingResult TryExtractClientWatsonData(ClientLogEvent watsonEvent, out ClientWatsonReportData reportData)
        {
            reportData = default(ClientWatsonReportData);
            string text;

            if (watsonEvent.TryGetValue <string>("BuildType", out text))
            {
                return(new ProcessingResult
                {
                    Code = ResultCode.DebugBuild
                });
            }
            bool flag = watsonEvent.TryGetValue <string>("est", out reportData.OriginalCallStack);

            if (!flag && !watsonEvent.TryGetValue <string>("st", out reportData.OriginalCallStack))
            {
                return(new ProcessingResult
                {
                    Code = ResultCode.NoStackTrace
                });
            }
            reportData.IsUnhandledException = new bool?(flag);
            if (!reportData.OriginalCallStack.Contains(this.parameters.OwaVersion))
            {
                return(new ProcessingResult
                {
                    Code = ResultCode.VersionMismatch
                });
            }
            if (!watsonEvent.TryGetValue <string>("s", out reportData.TraceComponent))
            {
                return(new ProcessingResult
                {
                    Code = ResultCode.NoTraceComponent
                });
            }
            StringBuilder stringBuilder = new StringBuilder(reportData.OriginalCallStack.Length);
            bool          flag2         = true;
            string        functionName  = null;
            string        packageName   = null;

            foreach (string frame in ClientWatsonDatapointHandler.EnumerateFrames(reportData.OriginalCallStack))
            {
                CallStackFrameInfo callStackFrameInfo;
                ProcessingResult   result = this.TryProcessCallStackFrame(frame, out callStackFrameInfo);
                if (result.Code != ResultCode.Success)
                {
                    return(result);
                }
                if (flag2)
                {
                    functionName = callStackFrameInfo.SanitizedFunctionName;
                    packageName  = callStackFrameInfo.PackageName;
                }
                if (reportData.FunctionName == null && !ClientWatsonDatapointHandler.ExternalScriptRegex.IsMatch(callStackFrameInfo.PackageName) && (flag || !flag2))
                {
                    reportData.FunctionName = callStackFrameInfo.SanitizedFunctionName;
                    reportData.PackageName  = callStackFrameInfo.PackageName;
                }
                callStackFrameInfo.UpdateHash(ref reportData.CallStackHash);
                stringBuilder.AppendFormat(callStackFrameInfo.ToString(), new object[0]);
                flag2 = false;
            }
            if (!flag2)
            {
                reportData.NormalizedCallStack = stringBuilder.ToString();
                if (!watsonEvent.TryGetValue <string>("em", out reportData.ExceptionMessage))
                {
                    reportData.ExceptionMessage = "unknown";
                }
                if (!watsonEvent.TryGetValue <string>("en", out reportData.ExceptionType))
                {
                    string text2;
                    if (!flag && watsonEvent.TryGetValue <string>("f", out text2) && !string.IsNullOrEmpty(text2))
                    {
                        reportData.ExceptionType    = ClientWatsonDatapointHandler.SanitizeExceptionType(text2);
                        reportData.ExceptionMessage = ClientWatsonDatapointHandler.FormatExceptionMessage(text2, watsonEvent);
                    }
                    else
                    {
                        reportData.ExceptionType = "unknown";
                    }
                }
                if (string.IsNullOrEmpty(reportData.FunctionName))
                {
                    reportData.FunctionName = functionName;
                    reportData.PackageName  = packageName;
                }
                return(new ProcessingResult
                {
                    Code = ResultCode.Success
                });
            }
            return(new ProcessingResult
            {
                Code = ResultCode.NoFrames
            });
        }