public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            NavigationController.NavigationBar.Translucent = false;
            LogArea.Font = UIKit.UIFont.FromName("Helvetica", 12f);
            AutomaticallyAdjustsScrollViewInsets = true;

            var set = this.CreateBindingSet <HomeDebugView, HomeDebugViewModel>();

            set.Bind(GeoLabelData).To(v => v.LocationString);
            set.Bind(StartButton).To(v => v.StartCommand);
            set.Bind(StopButton).To(v => v.StopCommand);
            set.Bind(ActivityLabel).To(v => v.MotionTypeString);
            set.Bind(StartButton).For(x => x.Enabled).To(x => x.IsBound).WithConversion(new BoolInverseConverter());
            set.Bind(StopButton).For(x => x.Enabled).To(x => x.IsBound);
            set.Bind(LogArea).To(v => v.LogText);
            set.Bind(StatusLabel).To(v => v.StatusString);
            set.Bind(TollRoadString).To(v => v.TollRoadString);
            set.Bind(NextWaypointString).To(v => v.CurrentWaypointString);
            set.Bind(LogOut).To(v => v.LogOutCommand);
            set.Apply();

            this.AddLinqBinding(ViewModel, vm => vm.LogText, (value) =>
            {
                NSRange bottom = new NSRange(0, value?.Length ?? 0);
                LogArea.ScrollRangeToVisible(bottom);
            });

            // Perform any additional setup after loading the view, typically from a nib.
        }
Example #2
0
        private void LogMessage(DateTime timeStamp, string message)
        {
            const string LineEnd = "\r";

            if (string.IsNullOrWhiteSpace(message))
            {
                message = "no message";
            }
            message = message.Replace("\n", LineEnd);
            message = message.Replace(LineEnd + LineEnd, LineEnd);
            while (message.EndsWith(LineEnd))
            {
                message = message.Substring(0, message.Length - 1);
            }
            string text = _logMessagePrefix + timeStamp.ToString() + ": " + message;

            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { LogArea.AppendText(text); }));
            if (/*no embedded line end(s)?*/ message.IndexOf(LineEnd) < 0)
            {
                _logMessagePrefix = LineEnd;
            }
            else /*complex message; next time add blank line*/
            {
                _logMessagePrefix = LineEnd + LineEnd;
            }
        }
Example #3
0
 private static void Heading(LogArea logArea, string message)
 {
     Info(logArea, "-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+");
     Info(logArea, "Error :-");
     Info(logArea, message);
     Info(logArea, "-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+");
 }
Example #4
0
        public FilePath UniqueLogPath(LogArea area, FileExtension ext = null)
        {
            var first   = new DateTime(2019, 1, 1);
            var current = now();
            var elapsed = (long)(current - first).TotalMilliseconds;

            return(LogPath(area, ext, elapsed));
        }
Example #5
0
        public static void Log(LogArea area, Exception exception, bool recurse = false)
        {
            Log(area, LogType.Error, $"{exception?.Message ?? "null exception"}\n{exception.Source ?? "null source"}\n{exception?.StackTrace ?? "null stack"}");

            if (recurse && exception?.InnerException != null)
            {
                Log(area, exception.InnerException, recurse);
            }
        }
Example #6
0
 private static void Heading(LogArea logArea, Exception exception)
 {
     Info(logArea, "-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+");
     Info(logArea, string.Format("\nMessage        :-\n{0}", exception.Message));
     Info(logArea, string.Format("\nHelpLink       :-\n{0}", exception.HelpLink));
     Info(logArea, string.Format("\nSource         :- \n{0}", exception.Source));
     Info(logArea, string.Format("\nStackTrace     :- \n{0}", exception.StackTrace));
     Info(logArea, string.Format("\nInner Exception:-  \n{0}", exception.InnerException));
     Info(logArea, string.Format("\nTargetSite     :- \n{0}", exception.TargetSite));
     Info(logArea, "-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+");
 }
Example #7
0
 private static void WriteLine(LogArea logArea, string message)
 {
     lock (s_locker)
     {
         using (StreamWriter w = File.AppendText(BuildLogPath(logArea.ToString())))
         {
             w.WriteLine(message);
             w.Flush();
             w.Close();
         }
     }
 }
Example #8
0
        public static void Log(LogArea logArea, LogType logType, string message, object data)
        {
            var connectionString = AppSettings.GetConnectionString("Entities");

            var conn = new SqlConnection(connectionString);

            try
            {
                string messageStr = GeneralHelper.LimitLength(message, 250);

                if (messageStr == null)
                {
                    throw new ArgumentException("Message cannot be null");
                }

                string dataStr = string.Empty;

                if (data != null)
                {
                    try
                    {
                        dataStr = JsonConvert.SerializeObject(data);
                    }
                    catch { }
                }

                var sqlInsert = @"INSERT INTO [dbo].[Logs] ([LogArea], [LogType], [Message], [Data], [Timestamp]) VALUES (@LogArea, @LogType, @Message, @Data, GETDATE())";

                using (var command = new SqlCommand(sqlInsert, conn))
                {
                    conn.Open();

                    command.Parameters.Add(new SqlParameter("@LogArea", logArea.ToString()));
                    command.Parameters.Add(new SqlParameter("@LogType", logType.ToString()));
                    command.Parameters.Add(new SqlParameter("@Message", messageStr));
                    command.Parameters.Add(new SqlParameter("@Data", dataStr));

                    command.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
            finally
            {
                if (conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }
        }
Example #9
0
 internal static void StartActivity(LogArea logArea)
 {
     lock (s_locker)
     {
         Info(logArea, string.Empty);
         Info(logArea, string.Empty);
         Info(logArea, string.Empty);
         foreach (string str in BuildLogHeading(logArea))
         {
             Info(logArea, str);
         }
     }
 }
Example #10
0
        private static string[] BuildLogHeading(LogArea logArea)
        {
            List <string> list = new List <string> {
                "====================================================================", "Administration Log"
            };

            try
            {
                list.Add(string.Format(CultureInfo.InvariantCulture, "DateTime : {0}", new object[] { DateTime.Now }));
                list.Add(string.Format(CultureInfo.InvariantCulture, "Area     : {0}", new object[] { logArea.ToString() }));
                list.Add(string.Format(CultureInfo.InvariantCulture, "IP       : {0}", new object[] {  }));// System.Web.HttpContext.Current.Request.UserHostAddress
            }
            catch (Exception exception)
            {
                list.Add(string.Format(CultureInfo.InvariantCulture, "Error retrieving environment information: ", new object[] { exception.Message }));
            }
            list.Add("====================================================================");
            return(list.ToArray());
        }
Example #11
0
        private static string[] BuildLogHeading(LogArea logArea)
        {
            List <string> list = new List <string> {
                "====================================================================", "Administration Log"
            };

            try
            {
                list.Add(string.Format(CultureInfo.InvariantCulture, "DateTime : {0}", new object[] { DateTime.Now }));
                list.Add(string.Format(CultureInfo.InvariantCulture, "Area     : {0}", new object[] { logArea.ToString() }));
                //list.Add(string.Format(CultureInfo.InvariantCulture, "IP       : {0}", new object[] { httpContext.Features.Get<IHttpConnectionFeature>()?.RemoteIpAddress }));
            }
            catch (Exception exception)
            {
                list.Add(string.Format(CultureInfo.InvariantCulture, "Error retrieving environment information: ", new object[] { exception.Message }));
            }
            list.Add("====================================================================");
            return(list.ToArray());
        }
Example #12
0
        public static void Log(LogArea area, LogType type, string message)
        {
            message = $"[{Details.ModName}] {message}";

            if ((area & LogArea.Console) != LogArea.None)
            {
                LogToConsole(type, message);
            }

            if ((area & LogArea.File) != LogArea.None)
            {
                LogToFile(type, message);
            }

            if ((area & LogArea.Debug) != LogArea.None)
            {
                LogToDebug(type, message);
            }
        }
Example #13
0
File: log.cs Project: 0xCM/arrows
 public static void log(string text, LogArea dst)
 => Log.Get(LogTarget.AreaRoot(dst)).Log(text);
Example #14
0
File: log.cs Project: 0xCM/arrows
 /// <summary>
 /// Writes a message to a log
 /// </summary>
 /// <param name="messages">The message to emit</param>
 /// <param name="dst">The destination log</param>
 public static void log(AppMsg message, LogArea dst)
 => Log.Get(LogTarget.AreaRoot(dst)).Log(message);
Example #15
0
File: log.cs Project: 0xCM/arrows
 /// <summary>
 /// Writes a sequence of messages to a log as a contiguous block
 /// </summary>
 /// <param name="messages">The messages to emit</param>
 /// <param name="dst">The destination log</param>
 public static void log(IEnumerable <AppMsg> messages, LogArea dst)
 => Log.Get(LogTarget.AreaRoot(dst)).Log(messages);
Example #16
0
 protected void AddLogLine(string text)
 {
     LogArea.AppendText(string.Format("{0}\r\n", text));
 }
Example #17
0
 public static LogTarget <LogArea> AreaRoot(LogArea Area)
 => new LogTarget <LogArea>(Area, Area);
Example #18
0
 public static void Logger(LogArea logArea, Exception exception)
 {
     StartActivity(logArea);
     Heading(logArea, exception);
 }
Example #19
0
 public LogItem(LogArea area, string group, string log)
 {
     this.Area  = area;
     this.Group = group;
     this.Log   = log;
 }
Example #20
0
 public FilePath LogPath(LogArea area, string topic, FileExtension ext = null, long?timestamp = null)
 => LogDir(area) + FileName.Define($"{area}.{topic}.{timestamp ?? LogDate}.{ext ?? DefaultExtension}");
Example #21
0
 private static void Info(LogArea logArea, string message)
 {
     WriteLine(logArea, message);
 }
 private void OnMessageReceived(String message)
 {
     Application.Current.Dispatcher.Invoke(new Action(() => { LogArea.Text = LogArea.Text + message; LogArea.ScrollToEnd(); }));
 }
Example #23
0
 private Logger(LogArea area)
 {
     this._area = area;
 }
Example #24
0
 FolderPath LogDir(LogArea target)
 => RootLogDir + FolderName.Define(target.ToString().ToLower());
Example #25
0
 public static LogTarget <T> Define <T>(LogArea Area, T Kind)
     where T : Enum
 => new LogTarget <T>(Area, Kind);
Example #26
0
File: Log.cs Project: 0xCM/arrows
 protected Logger(LogArea Area)
 {
     this.Area = Area;
 }
Example #27
0
 public static void Logger(LogArea logArea, string message)
 {
     StartActivity(logArea);
     Heading(logArea, message);
 }