Example #1
0
        public void LogMessage(string logMessage, bool errorMessage, bool warning, bool error, bool logToFile, bool logToConsole, bool logToDatabase)
        {
            logMessage = logMessage.Trim();
            if (string.IsNullOrEmpty(logMessage))
            {
                throw new Exception("Empty Message");
            }

            if (!logToConsole && !logToFile && !logToDatabase)
            {
                throw new Exception("Invalid configuration");
            }

            if (!errorMessage && !warning && !error)
            {
                throw new Exception("Error or Warning or Message must be specified");
            }

            int          messageTypeCode;
            ConsoleColor consoleColor;

            if (errorMessage)
            {
                messageTypeCode = 1;
                consoleColor    = ConsoleColor.White;
            }
            else if (error)
            {
                messageTypeCode = 2;
                consoleColor    = ConsoleColor.Red;
            }
            else
            {
                messageTypeCode = 3;
                consoleColor    = ConsoleColor.Yellow;
            }

            if (logToDatabase)
            {
                var logValue = new LogValue()
                {
                    Code    = messageTypeCode,
                    Message = logMessage
                };
                _jobLoggerRepository.SaveIntoLogValue(logValue);
            }

            var logMessageTowrite = DateTime.Now.ToShortDateString() + " " + logMessage;

            if (logToFile)
            {
                var dateLogName = DateTime.Now.ToShortDateString().Replace("/", "_");
                _jobLoggerHelper.FileWriteLine(dateLogName, logMessageTowrite);
            }

            if (logToConsole)
            {
                _jobLoggerHelper.WriteConsoleOutput(logMessageTowrite, consoleColor);
            }
        }
        public void ConfirmFirstExample()
        {
            var firstNumber = new LogValue("2,11");
            var secondNumber = new LogValue("3,7");

            var larger = FindLargerValue(firstNumber, secondNumber);
            larger.Should().Be(secondNumber);
        }
        public void ConfirmSecondExample()
        {
            var firstNumber = new LogValue("632382,518061");
            var secondNumber = new LogValue("519432,525806");

            var larger = FindLargerValue(firstNumber, secondNumber);

            larger.Should().Be(firstNumber);
        }
        public ActLogActionPage(ActLogAction act)
        {
            InitializeComponent();

            mAct = act;

            GingerCore.General.FillComboFromEnumObj(LogTypeComboBox, mAct.SelectedLogLevel);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(LogTypeComboBox, ComboBox.SelectedValueProperty, mAct, nameof(ActLogAction.SelectedLogLevel));

            LogValue.BindControl(Context.GetAsContext(mAct.Context), mAct, ActLogAction.Fields.LogText);
        }
Example #5
0
 public void SaveIntoLogValue(LogValue logValue)
 {
     using (var connection = new ApplicationDbContext())
     {
         connection.LogValues.Add(new LogValue()
         {
             Id             = Guid.NewGuid(),
             Code           = logValue.Code,
             Message        = logValue.Message,
             InsertDateTime = DateTime.Now
         });
         connection.SaveChanges();
     }
 }
Example #6
0
        private string GetAction()
        {
            if (LogValue.Contains("NoLoaded"))
            {
                return("Loaded");
            }

            if (LogValue.Contains("NoSent"))
            {
                return("Sent");
            }

            return(string.Empty);
        }
Example #7
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            while (ConsoleData.Count > 0)
            {
                /* Enqueue the console_data to display it console. */
                LogValue Data = ConsoleData.Dequeue();

                richTextBox1.SelectionColor = GetColor(Data.Value);
                richTextBox1.SelectedText  += Data.Data + Environment.NewLine;

                /* Store the enqueued data on Consoledata_mirror for backup during re instantiating of this window. */
                ConsoleData_Mirror.Enqueue(Data);
            }
        }
Example #8
0
    public TessParamGUI() : base()
    {
        m_MaxLength    = new LogValue(m_maxLength_Def, m_maxLength_Min, m_maxLength_Max);
        m_NumVertices  = new LogValue(m_numVertices_Def, m_numVertices_Min, m_numVertices_Max);
        m_MinBoxLength = new LogValue(m_minBoxLength_Def, m_minBoxLength_Min, m_minBoxLength_Max);

        // 簡単設定テーブル
        int nTableSize = m_easySettingTable.Length;

        m_easyToleranceTable = new TessellationTolerance[nTableSize];
        for (int i = 0; i < nTableSize; ++i)
        {
            var easySetting = m_easySettingTable[i];
            var tole        = TessellationTolerance.Default;
            tole.TessAngle       = MoNo.Angle.FromDegree(easySetting.tessAngle);
            tole.TessAspectRatio = (easySetting.tessApectRatio == 0)
                             ? FSharpOption <TessellationAspectRatio> .None
                             : FSharpOption <TessellationAspectRatio> .Some(
                new TessellationAspectRatio()
            {
                MaxRatio  = easySetting.tessApectRatio,
                MinLength = FSharpOption <double> .None
            });

            m_easyToleranceTable[i] = tole;
        }

        // 初期値は真ん中で
        m_nEasyTessLevel = m_nLastEasyTessLevel = nTableSize / 2;
        var src = m_easyToleranceTable[m_nEasyTessLevel];

        m_tolerance = new TessellationTolerance()
        {
            TessAngle       = src.TessAngle,
            TessAspectRatio = src.TessAspectRatio,
            TessMaxLength   = src.TessMaxLength,
            TessDeviation   = src.TessDeviation
        };

#if UNITY_2017_3_OR_NEWER
        // Unity Version 2017.3以降では、頂点数65000でメッシュを分割しない
        m_isDivideAt65kVertices = false;
#else
        // それより前のバージョンでは、頂点数65000でメッシュを分割する
        m_isDivideAt65kVertices = true;
#endif
    }
Example #9
0
        private void Tick()
        {
            if (Progress.Count > 0)
            {
                                #if MONO_GTK
                this.progressBar.Text     = string.Format("{0}/{1}", Progress.Current, Progress.Count);
                this.progressBar.Fraction = Convert.ToDouble(Progress.Current) / Convert.ToDouble(Progress.Count);
                                #else
                this.progressLabel.Text = string.Format("{0}/{1}", Progress.Current, Progress.Count);
                this.progressBar.Value  = Math.Min(Convert.ToInt32(Progress.Current * 100 / Progress.Count), 100);
                                #endif
            }
            lock (ConversionLogger.OutMessage) {
                using (FileStream stream = new FileStream(ConversionUtil.GetPath("log.log"), FileMode.Append, FileAccess.Write)) {
                    while (ConversionLogger.OutMessage.Count > 0)
                    {
                        LogValue value = ConversionLogger.OutMessage.Dequeue();
                        string   str   = DateTime.Now.ToString() + "  [" + value.type + "]" + value.message + "\r\n";
#if MONO_GTK
                        TextIter iter = TextIter.Zero;
                        builder.Append(str);
                        richTextBoxLog.Buffer.Text = builder.ToString();
                        richTextBoxLog.ScrollToIter(richTextBoxLog.Buffer.EndIter, 0, true, 0, 0);
#else
                        richTextBoxLog.SelectionStart = richTextBoxLog.Text.Length;
                        if (value.type == LogType.Info)
                        {
                            richTextBoxLog.SelectionColor = System.Drawing.Color.Black;
                        }
                        else if (value.type == LogType.Warn)
                        {
                            richTextBoxLog.SelectionColor = System.Drawing.Color.Red;
                        }
                        else
                        {
                            richTextBoxLog.SelectionColor = System.Drawing.Color.Red;
                        }
                        richTextBoxLog.AppendText(str);
                        richTextBoxLog.ScrollToCaret();
#endif
                        byte[] buffer = Encoding.UTF8.GetBytes(str);
                        stream.Write(buffer, 0, buffer.Length);
                    }
                }
            }
        }
        public void ConfirmReadingFile()
        {
            var fileContent = FileHelper.GetEmbeddedResourceContent("Puzzles.ProjectEuler.DataFiles.Problem_0099_base_exp.txt");
            var lines = fileContent.Split('\n');
            lines.Length.Should().BeGreaterOrEqualTo(1000);

            var firstLine = lines[0];
            var secondLine = lines[1];

            var firstNumber = new LogValue(firstLine);
            var secondNumber = new LogValue(secondLine);

            firstNumber.BaseNumber.Should().Be(519432);
            firstNumber.Exponent.Should().Be(525806);

            secondNumber.BaseNumber.Should().Be(632382);
            secondNumber.Exponent.Should().Be(518061);
        }
Example #11
0
        private int GetRank()
        {
            if (LogValue.Contains("NoLoaded") && Name == "CareTreatment")
            {
                return(1);
            }

            if (LogValue.Contains("NoSent") && Name == "CareTreatment")
            {
                return(2);
            }

            if (LogValue.Contains("NoLoaded") && Name == "HivTestingService")
            {
                return(3);
            }

            if (LogValue.Contains("NoSent") && Name == "HivTestingService")
            {
                return(4);
            }

            if (LogValue.Contains("NoLoaded") && Name == "MasterPatientIndex")
            {
                return(5);
            }

            if (LogValue.Contains("NoSent") && Name == "MasterPatientIndex")
            {
                return(6);
            }

            if (LogValue.Contains("NoLoaded") && Name == "MigrationService")
            {
                return(7);
            }

            if (LogValue.Contains("NoSent") && Name == "MigrationService")
            {
                return(8);
            }

            return(99);
        }
Example #12
0
        public void LogValue(LogValue log)
        {
            ValidateRequiredMetadata(log);
            Ensure.Nonnegative(log.Value, nameof(log.Value));
            Ensure.Nonnegative(log.MmolValue, nameof(log.MmolValue));

            if (log.Value > 0)
            {
                if (log.Value > 0 && log.Value < 20)
                {
                    throw new Exception("warning: value is very low");
                }
                if (log.Value < 10)
                {
                    throw new Exception("error: value is too low");
                }
                if (log.Value > 800)
                {
                    throw new Exception("error: value is too high");
                }
            }
            if (log.MmolValue > 0)
            {
                if (log.MmolValue > 0 && log.MmolValue < 2)
                {
                    throw new Exception("warning: mmolvalue is very low");
                }
                if (log.MmolValue < 1)
                {
                    throw new Exception("error: mmolvalue is too low");
                }
                if (log.MmolValue > 35)
                {
                    throw new Exception("error: mmolvalue is too high");
                }
            }
            if (log.Value > 0 || log.MmolValue > 0)
            {
                RaiseEvent(new GlucoseLoggedV1(log.Value, log.MmolValue, log.Message, log.Metadata));
            }
        }
        public void FindLargestExponentInTheFile()
        {
            var fileContent = FileHelper.GetEmbeddedResourceContent("Puzzles.ProjectEuler.DataFiles.Problem_0099_base_exp.txt");
            var lines = fileContent.Split('\n');
            lines.Length.Should().BeGreaterOrEqualTo(1000);

            double largestNumber = 0;
            int lineNumberWithLargest = 0;

            for (var idx = 0; idx < lines.Length; ++idx)
            {
                var logValue = new LogValue(lines[idx]);
                if (logValue.Log > largestNumber)
                {
                    lineNumberWithLargest = idx + 1; // Avoid zero-base
                    largestNumber = logValue.Log;
                }
            }

            Console.WriteLine("Line with the larges number is: {0}", lineNumberWithLargest);
            lineNumberWithLargest.Should().Be(709);
        }
Example #14
0
    public TessParamGUI() : base()
    {
        m_MaxLength    = new LogValue(m_maxLength_Def, m_maxLength_Min, m_maxLength_Max);
        m_NumVertices  = new LogValue(m_numVertices_Def, m_numVertices_Min, m_numVertices_Max);
        m_MinBoxLength = new LogValue(m_minBoxLength_Def, m_minBoxLength_Min, m_minBoxLength_Max);

        // 簡単設定テーブル
        int nTableSize = m_easySettingTable.Length;

        m_easyToleranceTable = new TessellationTolerance[nTableSize];
        for (int i = 0; i < nTableSize; ++i)
        {
            var easySetting = m_easySettingTable[i];
            var tole        = TessellationTolerance.Default;
            tole.TessAngle       = MoNo.Angle.FromDegree(easySetting.tessAngle);
            tole.TessAspectRatio = (easySetting.tessApectRatio == 0)
                             ? FSharpOption <TessellationAspectRatio> .None
                             : FSharpOption <TessellationAspectRatio> .Some(
                new TessellationAspectRatio()
            {
                MaxRatio  = easySetting.tessApectRatio,
                MinLength = FSharpOption <double> .None
            });

            m_easyToleranceTable[i] = tole;
        }

        // 初期値は真ん中で
        m_nEasyTessLevel = m_nLastEasyTessLevel = nTableSize / 2;
        var src = m_easyToleranceTable[m_nEasyTessLevel];

        m_tolerance = new TessellationTolerance()
        {
            TessAngle       = src.TessAngle,
            TessAspectRatio = src.TessAspectRatio,
            TessMaxLength   = src.TessMaxLength,
            TessDeviation   = src.TessDeviation
        };
    }
Example #15
0
        public void LogMessage_Warning_DataBase()
        {
            _logToDatabase = true;
            _message       = "This is a Test_Warning Message To Log";
            _isWarning     = true;
            var logValue = new LogValue()
            {
                Code    = 3,
                Message = _message
            };

            var mockHelper = new Mock <IJobLoggerHelper>();

            var mockRepository = new Mock <IJobLoggerRepository>();

            mockRepository.Setup(x => x.SaveIntoLogValue(logValue));

            var core = new JobLoggerCore(mockHelper.Object, mockRepository.Object);

            core.LogMessage(_message, _isMessage, _isWarning, _isError, _logToFile, _logToConsole, _logToDatabase);

            //Asserts
            mockRepository.Verify(x => x.SaveIntoLogValue(It.Is <LogValue>(c => c.Code == 3)), Times.Once);
        }
 public static string GetTemplate(LogValue logValue)
 {
     return($":{logValue.ToString()}");
 }
Example #17
0
 public _Predicate_312(LogValue _enclosing)
 {
     this._enclosing = _enclosing;
 }
Example #18
0
 public LogEntry(LogSource _type, LogInstanceType _instanceType, LogValue _value, String _commend)
 {
     Time = DateTime.Now;
     Source = _type;
     InstanceType = _instanceType;
     Comment = _commend;
     Value = _value;
 }
Example #19
0
 public static void UpdateLog(LogSource _type, LogInstanceType _instanceType, LogValue _value)
 {
     LogFile.Add(new LogEntry(_type, _instanceType, _value, ""));
 }
Example #20
0
 public static void UpdateLog(LogSource _type, LogInstanceType _instanceType, LogValue _value, String _comment)
 {
     LogFile.Add(new LogEntry(_type, _instanceType, _value, _comment));
 }
Example #21
0
 internal static void LogMessage(string owner, string message, LogValue priority = LogValue.Normal)
 {
     LogMessage(new LogEventArgs(owner, message, priority));
 }
Example #22
0
 internal LogEventArgs(string owner, string message, LogValue priority = LogValue.Normal)
 {
     OwnerName = owner;
     Message   = message;
     Priority  = priority;
 }
Example #23
0
 public static void LogMessage(Owner owner, string message, LogValue priority)
 {
     LogMessage(new LogEventArgs(owner, message, priority));
 }
Example #24
0
 public LogEventArgs(Owner owner, string message, LogValue priority)
 {
     Owner    = owner;
     Message  = message;
     Priority = priority;
 }
Example #25
0
 public LogEventArgs(Owner owner, string message)
 {
     Owner    = owner;
     Message  = message;
     Priority = LogValue.Normal;
 }
        public SynapseTracability()
        {
            InitializeComponent();

            gbTracability.Left  = 0;
            gbTracability.Width = this.Width;

            if (_UseBuiltinFilters)
            {
                gbFilter.Visible = true;

                gbTracability.Top    = gbFilter.Height + 7;
                gbTracability.Height = this.Height - (gbFilter.Height + 7);
            }
            else
            {
                gbFilter.Visible = false;

                gbTracability.Top    = 0;
                gbTracability.Height = this.Height;
            }

            gbFilter.Dock        = DockStyle.Top;
            gbTracability.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);

            gbFilter.Text           = _LabelOfFilters;
            lbDateFrom.Text         = _LabelOfDateFrom;
            lbDateTo.Text           = _LabelOfDateTo;
            lbFreeText.Text         = _LabelOfFreeText;
            lbObject.Text           = _LabelOfObjectName;
            lbValue.Text            = _LabelOfObjectValue;
            btApply.Text            = _LabelOfApplyButton;
            btReset.Text            = _LabelOfResetButton;
            gbTracability.Text      = _LabelOfTraceList;
            treeLog.Columns[0].Text = _LabelOfObjectName;
            treeLog.Columns[1].Text = _LabelOfObjectValue;
            treeLog.Columns[2].Text = _LabelOfAction;
            treeLog.Columns[3].Text = _LabelOfWho;
            treeLog.Columns[4].Text = _LabelOfWhen;
            treeLog.Columns[5].Text = _LabelOfOldValue;
            treeLog.Columns[6].Text = _LabelOfNewValue;
            tsbExpand.Text          = _LabelOfExpand;
            tsbCollapse.Text        = _LabelOfCollapse;
            tsbPrint.Text           = _LabelOfPrint;

            treeLog.EmptyListMsg = "";

            #region Aspect Getters
            colAction.AspectToStringConverter = delegate(object x)
            {
                if (x is string && !x.ToString().Contains("is not a parameter-less method, property or field"))
                {
                    switch ((String)x)
                    {
                    case "INSERT":
                        return(SynapseForm.GetLabel("global.Create"));

                    case "MODIFY":
                        return(SynapseForm.GetLabel("global.Edit"));

                    case "DELETE":
                        return(SynapseForm.GetLabel("global.Delete"));

                    default:
                        return((String)x);
                    }
                }
                else
                {
                    return(string.Empty);
                }
            };

            colWho.AspectToStringConverter = delegate(object x)
            {
                if (x is string && !x.ToString().Contains("is not a parameter-less method, property or field"))
                {
                    return(x.ToString());
                }
                else
                {
                    return(string.Empty);
                }
            };

            colWhen.AspectToStringConverter = delegate(object x)
            {
                if (x is string && !x.ToString().Contains("is not a parameter-less method, property or field"))
                {
                    if (x is DateTime)
                    {
                        return(((DateTime)x).ToString("dd/MM/yyyy HH:mm:ss"));
                    }
                    else
                    {
                        return(string.Empty);
                    }
                }
                else
                if (x is DateTime)
                {
                    return(((DateTime)x).ToString("dd/MM/yyyy HH:mm:ss"));
                }
                else
                {
                    return(string.Empty);
                }
            };

            colObjectName.ImageGetter = delegate(object x)
            {
                if (x is LogEntry)
                {
                    LogEntry _logEntry = (LogEntry)x;
                    switch (_logEntry.ACTION_CODE)
                    {
                    case "INSERT":
                        return("new");

                    case "MODIFY":
                        return("edit");

                    case "DELETE":
                        return("delete");
                    }
                    return("");
                }

                return("");
            };

            colObjectName.AspectToStringConverter = delegate(object x)
            {
                if (x is string && !x.ToString().Contains("is not a parameter-less method, property or field"))
                {
                    return(SynapseForm.GetLabel(((SynapseModule)SynapseForm.FormUser.Modules.Where(m => m.ID == SynapseForm.FormUser.CurrentModuleID).FirstOrDefault()).TECHNICALNAME + "_" + x.ToString()));
                }
                else
                {
                    return(string.Empty);
                }
            };

            colObjectValue.AspectToStringConverter = delegate(object x)
            {
                if (x is string && !x.ToString().Contains("is not a parameter-less method, property or field"))
                {
                    return(x.ToString());
                }
                else
                {
                    return(string.Empty);
                }
            };


            colOld.AspectToStringConverter = delegate(object x)
            {
                if (x is string && !x.ToString().Contains("is not a parameter-less method, property or field"))
                {
                    return(x.ToString());
                }
                else
                {
                    return(string.Empty);
                }
            };

            colNew.AspectToStringConverter = delegate(object x)
            {
                if (x is string && !x.ToString().Contains("is not a parameter-less method, property or field"))
                {
                    return(x.ToString());
                }
                else
                {
                    return(string.Empty);
                }
            };

            treeLog.CanExpandGetter = delegate(object x)
            {
                if (x is LogEntry)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            };

            treeLog.ChildrenGetter = delegate(object x)
            {
                LogEntry         _logEntry = (LogEntry)x;
                IList <LogValue> _logValue = LogValue.LoadFromQuery("SELECT * FROM " + logValueTableName + " WHERE " + logValueTableName + ".FK_LOGENTRY=" + _logEntry.ID + " ORDER BY ID");

                return(_logValue);
            };
            #endregion
        }
Example #27
0
        /// <summary>
        /// The List Log operation lists the logs for the resource.
        /// </summary>
        /// <param name='resourceUri'>
        /// Optional.
        /// </param>
        /// <param name='filterString'>
        /// Optional.
        /// </param>
        /// <param name='definitions'>
        /// Optional.
        /// </param>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        /// <returns>
        /// The List Log values operation response.
        /// </returns>
        public async Task <LogListResponse> GetLogsAsync(string resourceUri, string filterString, IEnumerable <LogDefinition> definitions, CancellationToken cancellationToken)
        {
            // Validate

            // Tracing
            bool   shouldTrace  = TracingAdapter.IsEnabled;
            string invocationId = null;

            if (shouldTrace)
            {
                invocationId = TracingAdapter.NextInvocationId.ToString();
                Dictionary <string, object> tracingParameters = new Dictionary <string, object>();
                tracingParameters.Add("resourceUri", resourceUri);
                tracingParameters.Add("filterString", filterString);
                tracingParameters.Add("definitions", definitions);
                TracingAdapter.Enter(invocationId, this, "GetLogsAsync", tracingParameters);
            }

            // Construct URL
            string url = "";

            url = url + "/providers/microsoft.insights/logs";
            string baseUrl = this.Client.BaseUri.AbsoluteUri;

            // Trim '/' character from the end of baseUrl and beginning of url.
            if (baseUrl[baseUrl.Length - 1] == '/')
            {
                baseUrl = baseUrl.Substring(0, baseUrl.Length - 1);
            }
            if (url[0] == '/')
            {
                url = url.Substring(1);
            }
            url = baseUrl + "/" + url;
            url = url.Replace(" ", "%20");

            // Create HTTP transport objects
            HttpRequestMessage httpRequest = null;

            try
            {
                httpRequest            = new HttpRequestMessage();
                httpRequest.Method     = HttpMethod.Get;
                httpRequest.RequestUri = new Uri(url);

                // Set Headers
                httpRequest.Headers.Add("Accept", "application/json");
                httpRequest.Headers.Add("x-ms-version", "2014-04-01");

                // Set Credentials
                cancellationToken.ThrowIfCancellationRequested();
                await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false);

                // Send Request
                HttpResponseMessage httpResponse = null;
                try
                {
                    if (shouldTrace)
                    {
                        TracingAdapter.SendRequest(invocationId, httpRequest);
                    }
                    cancellationToken.ThrowIfCancellationRequested();
                    httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);

                    if (shouldTrace)
                    {
                        TracingAdapter.ReceiveResponse(invocationId, httpResponse);
                    }
                    HttpStatusCode statusCode = httpResponse.StatusCode;
                    if (statusCode != HttpStatusCode.OK)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false));
                        if (shouldTrace)
                        {
                            TracingAdapter.Error(invocationId, ex);
                        }
                        throw ex;
                    }

                    // Create Result
                    LogListResponse result = null;
                    // Deserialize Response
                    if (statusCode == HttpStatusCode.OK)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

                        result = new LogListResponse();
                        JToken responseDoc = null;
                        if (string.IsNullOrEmpty(responseContent) == false)
                        {
                            responseDoc = JToken.Parse(responseContent);
                        }

                        if (responseDoc != null && responseDoc.Type != JTokenType.Null)
                        {
                            LogCollection logCollectionInstance = new LogCollection();
                            result.LogCollection = logCollectionInstance;

                            JToken valueArray = responseDoc["value"];
                            if (valueArray != null && valueArray.Type != JTokenType.Null)
                            {
                                foreach (JToken valueValue in ((JArray)valueArray))
                                {
                                    Log logInstance = new Log();
                                    logCollectionInstance.Value.Add(logInstance);

                                    JToken categoryValue = valueValue["category"];
                                    if (categoryValue != null && categoryValue.Type != JTokenType.Null)
                                    {
                                        LocalizableString categoryInstance = new LocalizableString();
                                        logInstance.Category = categoryInstance;

                                        JToken valueValue2 = categoryValue["value"];
                                        if (valueValue2 != null && valueValue2.Type != JTokenType.Null)
                                        {
                                            string valueInstance = ((string)valueValue2);
                                            categoryInstance.Value = valueInstance;
                                        }

                                        JToken localizedValueValue = categoryValue["localizedValue"];
                                        if (localizedValueValue != null && localizedValueValue.Type != JTokenType.Null)
                                        {
                                            string localizedValueInstance = ((string)localizedValueValue);
                                            categoryInstance.LocalizedValue = localizedValueInstance;
                                        }
                                    }

                                    JToken startTimeValue = valueValue["startTime"];
                                    if (startTimeValue != null && startTimeValue.Type != JTokenType.Null)
                                    {
                                        DateTime startTimeInstance = ((DateTime)startTimeValue);
                                        logInstance.StartTime = startTimeInstance;
                                    }

                                    JToken endTimeValue = valueValue["endTime"];
                                    if (endTimeValue != null && endTimeValue.Type != JTokenType.Null)
                                    {
                                        DateTime endTimeInstance = ((DateTime)endTimeValue);
                                        logInstance.EndTime = endTimeInstance;
                                    }

                                    JToken valueArray2 = valueValue["value"];
                                    if (valueArray2 != null && valueArray2.Type != JTokenType.Null)
                                    {
                                        foreach (JToken valueValue3 in ((JArray)valueArray2))
                                        {
                                            LogValue logValueInstance = new LogValue();
                                            logInstance.Value.Add(logValueInstance);

                                            JToken timeValue = valueValue3["time"];
                                            if (timeValue != null && timeValue.Type != JTokenType.Null)
                                            {
                                                DateTime timeInstance = ((DateTime)timeValue);
                                                logValueInstance.Time = timeInstance;
                                            }

                                            JToken resourceIdValue = valueValue3["resourceId"];
                                            if (resourceIdValue != null && resourceIdValue.Type != JTokenType.Null)
                                            {
                                                string resourceIdInstance = ((string)resourceIdValue);
                                                logValueInstance.ResourceId = resourceIdInstance;
                                            }

                                            JToken operationNameValue = valueValue3["operationName"];
                                            if (operationNameValue != null && operationNameValue.Type != JTokenType.Null)
                                            {
                                                string operationNameInstance = ((string)operationNameValue);
                                                logValueInstance.OperationName = operationNameInstance;
                                            }

                                            JToken operationVersionValue = valueValue3["operationVersion"];
                                            if (operationVersionValue != null && operationVersionValue.Type != JTokenType.Null)
                                            {
                                                string operationVersionInstance = ((string)operationVersionValue);
                                                logValueInstance.OperationVersion = operationVersionInstance;
                                            }

                                            JToken categoryValue2 = valueValue3["category"];
                                            if (categoryValue2 != null && categoryValue2.Type != JTokenType.Null)
                                            {
                                                string categoryInstance2 = ((string)categoryValue2);
                                                logValueInstance.Category = categoryInstance2;
                                            }

                                            JToken resultTypeValue = valueValue3["resultType"];
                                            if (resultTypeValue != null && resultTypeValue.Type != JTokenType.Null)
                                            {
                                                string resultTypeInstance = ((string)resultTypeValue);
                                                logValueInstance.ResultType = resultTypeInstance;
                                            }

                                            JToken resultSignatureValue = valueValue3["resultSignature"];
                                            if (resultSignatureValue != null && resultSignatureValue.Type != JTokenType.Null)
                                            {
                                                string resultSignatureInstance = ((string)resultSignatureValue);
                                                logValueInstance.ResultSignature = resultSignatureInstance;
                                            }

                                            JToken resultDescriptionValue = valueValue3["resultDescription"];
                                            if (resultDescriptionValue != null && resultDescriptionValue.Type != JTokenType.Null)
                                            {
                                                string resultDescriptionInstance = ((string)resultDescriptionValue);
                                                logValueInstance.ResultDescription = resultDescriptionInstance;
                                            }

                                            JToken durationMsValue = valueValue3["durationMs"];
                                            if (durationMsValue != null && durationMsValue.Type != JTokenType.Null)
                                            {
                                                int durationMsInstance = ((int)durationMsValue);
                                                logValueInstance.DurationMs = durationMsInstance;
                                            }

                                            JToken callerIpAddressValue = valueValue3["callerIpAddress"];
                                            if (callerIpAddressValue != null && callerIpAddressValue.Type != JTokenType.Null)
                                            {
                                                string callerIpAddressInstance = ((string)callerIpAddressValue);
                                                logValueInstance.CallerIpAddress = callerIpAddressInstance;
                                            }

                                            JToken correlationIdValue = valueValue3["correlationId"];
                                            if (correlationIdValue != null && correlationIdValue.Type != JTokenType.Null)
                                            {
                                                string correlationIdInstance = ((string)correlationIdValue);
                                                logValueInstance.CorrelationId = correlationIdInstance;
                                            }

                                            JToken identityValue = valueValue3["identity"];
                                            if (identityValue != null && identityValue.Type != JTokenType.Null)
                                            {
                                                string identityInstance = ((string)identityValue);
                                                logValueInstance.Identity = identityInstance;
                                            }

                                            JToken levelValue = valueValue3["level"];
                                            if (levelValue != null && levelValue.Type != JTokenType.Null)
                                            {
                                                string levelInstance = ((string)levelValue);
                                                logValueInstance.Level = levelInstance;
                                            }

                                            JToken locationValue = valueValue3["location"];
                                            if (locationValue != null && locationValue.Type != JTokenType.Null)
                                            {
                                                string locationInstance = ((string)locationValue);
                                                logValueInstance.Location = locationInstance;
                                            }

                                            JToken propertiesSequenceElement = ((JToken)valueValue3["properties"]);
                                            if (propertiesSequenceElement != null && propertiesSequenceElement.Type != JTokenType.Null)
                                            {
                                                foreach (JProperty property in propertiesSequenceElement)
                                                {
                                                    string propertiesKey   = ((string)property.Name);
                                                    string propertiesValue = ((string)property.Value);
                                                    logValueInstance.Properties.Add(propertiesKey, propertiesValue);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    result.StatusCode = statusCode;
                    if (httpResponse.Headers.Contains("x-ms-request-id"))
                    {
                        result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
                    }

                    if (shouldTrace)
                    {
                        TracingAdapter.Exit(invocationId, result);
                    }
                    return(result);
                }
                finally
                {
                    if (httpResponse != null)
                    {
                        httpResponse.Dispose();
                    }
                }
            }
            finally
            {
                if (httpRequest != null)
                {
                    httpRequest.Dispose();
                }
            }
        }
Example #28
0
        public void Add(string columnName, LogValue logValue)
        {
            var value = Log.GetTemplate(logValue);

            Add(columnName, value);
        }
Example #29
0
        private void uc_EntityHistory_Load(object sender, EventArgs e)
        {
            col_object.AspectGetter = delegate(object x)
            {
                if (x is HistoryTreeviewL2)
                {
                    return(((HistoryTreeviewL2)x).ObjectString);
                }
                if (x is string)
                {
                    return(x.ToString());
                }
                else
                {
                    return("");
                }
            };
            col_Field.AspectGetter = delegate(object x)
            {
                if (!(x is LogValue))
                {
                    return("");
                }
                else
                {
                    return(((LogValue)x).FIELD);
                }
            };
            col_OldValue.AspectGetter = delegate(object x)
            {
                if (!(x is LogValue))
                {
                    return("");
                }
                else
                {
                    return(((LogValue)x).OLD_VALUE);
                }
            };
            col_NewValue.AspectGetter = delegate(object x)
            {
                if (!(x is LogValue))
                {
                    return("");
                }
                else
                {
                    return(((LogValue)x).NEW_VALUE);
                }
            };
            treeListView1.CanExpandGetter = delegate(object x)
            {
                if (x is HistoryTreeviewL2)
                {
                    return(true);
                }
                if (x is string)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            };
            treeListView1.ChildrenGetter = delegate(object x)
            {
                if (x is HistoryTreeviewL2)
                {
                    return(LogValue.Load("where FK_LOGENTRY = " + ((HistoryTreeviewL2)x).ID));
                }
                if (x is string)
                {
                    return(from E in Entries where E.OBJECT_NAME == x.ToString() select new HistoryTreeviewL2(E));
                }
                else
                {
                    return(null);
                }
            };

            LogEntry.TableName = "LogEntry_" + Assembly.GetEntryAssembly().GetName().Name;
            LogValue.TableName = "LogValue_" + Assembly.GetEntryAssembly().GetName().Name;

            Entries = LogEntry.Load();

            treeListView1.SetObjects((from E in Entries select E.OBJECT_NAME).Distinct());
        }
 /// <summary>
 /// Using the fact that log(x^y) = y log (x) to find values faster - multiplication rather than power calculation
 /// </summary>
 /// <param name="first"></param>
 /// <param name="second"></param>
 /// <returns></returns>
 private static LogValue FindLargerValue(LogValue first, LogValue second)
 {
     if (first.Log < second.Log) return second;
     return first;
 }