Esempio n. 1
0
        private List<GeocacheVisitsItem> processGeocacheVisitsFile(string[] lines)
        {
            List<GeocacheVisitsItem> result = new List<GeocacheVisitsItem>();
            try
            {
                foreach (string s in lines)
                {
                    string[] parts = s.Replace("\0", "").Split(new char[] { ',' }, 4);
                    if (parts.Length == 4)
                    {
                        GeocacheVisitsItem vi = new GeocacheVisitsItem();
                        vi.Code = parts[0];
                        vi.LogDate = DateTime.Parse(parts[1]).ToLocalTime();
                        vi.LogType = Utils.DataAccess.GetLogType(parts[2]);
                        vi.Comment = parts[3].Replace("\"", "");

                        if (vi.Code.IndexOf("GC") > 0)
                        {
                            vi.Code = vi.Code.Substring(vi.Code.IndexOf("GC"));
                        }
                        result.Add(vi);
                    }
                }
            }
            catch(Exception e)
            {
                Core.ApplicationData.Instance.Logger.AddLog(this, e);
            }
            return (from a in result select a).OrderBy(x => x.LogDate).ToList();
        }
Esempio n. 2
0
        private List <GeocacheVisitsItem> processGeocacheVisitsFile(string[] lines)
        {
            List <GeocacheVisitsItem> result = new List <GeocacheVisitsItem>();

            try
            {
                foreach (string s in lines)
                {
                    string[] parts = s.Replace("\0", "").Split(new char[] { ',' }, 4);
                    if (parts.Length == 4)
                    {
                        GeocacheVisitsItem vi = new GeocacheVisitsItem();
                        vi.Code    = parts[0];
                        vi.LogDate = DateTime.Parse(parts[1]).ToLocalTime();
                        vi.LogType = Utils.DataAccess.GetLogType(parts[2]);
                        vi.Comment = parts[3].Replace("\"", "");

                        if (vi.Code.IndexOf("GC") > 0)
                        {
                            vi.Code = vi.Code.Substring(vi.Code.IndexOf("GC"));
                        }
                        result.Add(vi);
                    }
                }
            }
            catch (Exception e)
            {
                Core.ApplicationData.Instance.Logger.AddLog(this, e);
            }
            return((from a in result select a).OrderBy(x => x.LogDate).ToList());
        }
Esempio n. 3
0
        private List<GeocacheVisitsItem> processGeocacheVisitsFile(string[] lines)
        {
            List<GeocacheVisitsItem> result = new List<GeocacheVisitsItem>();
            try
            {
                int i = 0;
                while (i < lines.Length)
                {
                    string s = lines[i];
                    string[] parts = s.Replace("\0", "").Split(new char[] { ',' }, 4);
                    if (parts.Length == 4)
                    {
                        DateTime dt;
                        if (parts[0].StartsWith("GC") && DateTime.TryParse(parts[1], out dt))
                        {
                            GeocacheVisitsItem vi = new GeocacheVisitsItem();
                            vi.Code = parts[0];
                            vi.LogDate = dt.ToLocalTime();
                            vi.LogType = Utils.DataAccess.GetLogType(parts[2]);

                            StringBuilder sb = new StringBuilder();
                            sb.AppendLine(parts[3].Replace("\"", ""));

                            //read till next
                            i++;
                            while (i < lines.Length)
                            {
                                s = lines[i];
                                parts = s.Replace("\0", "").Split(new char[] { ',' }, 4);
                                if (parts.Length == 4)
                                {
                                    if (parts[0].StartsWith("GC") && DateTime.TryParse(parts[1], out dt))
                                    {
                                        break;
                                    }
                                    else
                                    {
                                        sb.AppendLine(s.Trim().Replace("\"", ""));
                                        i++;
                                    }
                                }
                                else
                                {
                                    sb.AppendLine(s.Trim().Replace("\"", ""));
                                    i++;
                                }
                            }
                            vi.Comment = sb.ToString();
                            result.Add(vi);
                        }
                        else
                        {
                            i++;
                        }
                    }
                    else
                    {
                        i++;
                    }
                }
            }
            catch (Exception e)
            {
                Core.ApplicationData.Instance.Logger.AddLog(this, e);
            }
            return result;
        }
Esempio n. 4
0
        private List <GeocacheVisitsItem> processGeocacheVisitsFile(string[] lines)
        {
            List <GeocacheVisitsItem> result = new List <GeocacheVisitsItem>();

            try
            {
                int i = 0;
                while (i < lines.Length)
                {
                    string   s     = lines[i];
                    string[] parts = s.Replace("\0", "").Split(new char[] { ',' }, 4);
                    if (parts.Length == 4)
                    {
                        DateTime dt;
                        if (parts[0].StartsWith("GC") && DateTime.TryParse(parts[1], out dt))
                        {
                            GeocacheVisitsItem vi = new GeocacheVisitsItem();
                            vi.Code    = parts[0];
                            vi.LogDate = dt.ToLocalTime();
                            vi.LogType = Utils.DataAccess.GetLogType(parts[2]);

                            StringBuilder sb = new StringBuilder();
                            sb.AppendLine(parts[3].Replace("\"", ""));

                            //read till next
                            i++;
                            while (i < lines.Length)
                            {
                                s     = lines[i];
                                parts = s.Replace("\0", "").Split(new char[] { ',' }, 4);
                                if (parts.Length == 4)
                                {
                                    if (parts[0].StartsWith("GC") && DateTime.TryParse(parts[1], out dt))
                                    {
                                        break;
                                    }
                                    else
                                    {
                                        sb.AppendLine(s.Trim().Replace("\"", ""));
                                        i++;
                                    }
                                }
                                else
                                {
                                    sb.AppendLine(s.Trim().Replace("\"", ""));
                                    i++;
                                }
                            }
                            vi.Comment = sb.ToString();
                            result.Add(vi);
                        }
                        else
                        {
                            i++;
                        }
                    }
                    else
                    {
                        i++;
                    }
                }
            }
            catch (Exception e)
            {
                Core.ApplicationData.Instance.Logger.AddLog(this, e);
            }
            return(result);
        }