public override string CSVFromDataTable(DataTable dt)
        {
            // We ignore the data table passed in - we have our data from Matches, which was initialized in CanParse.

            IEnumerable <CustomPropertyType> rgcpt = CustomPropertyType.GetCustomPropertyTypes();

            // Build up the list of RosterBuster objects first
            List <RosterBuster> lstRb = new List <RosterBuster>();

            foreach (Match ctMatch in Matches)
            {
                GroupCollection gc = ctMatch.Groups;

                try
                {
                    DateTime dtStart = Convert.ToDateTime(gc["StartDate"].Value, CultureInfo.CurrentCulture);
                    DateTime dtEnd   = Convert.ToDateTime(gc["EndDate"].Value, CultureInfo.CurrentCulture);
                    int      hStart  = Convert.ToInt32(gc["startZ"].Value.Substring(0, 2), CultureInfo.InvariantCulture);
                    int      mStart  = Convert.ToInt32(gc["startZ"].Value.Substring(2, 2), CultureInfo.InvariantCulture);
                    int      hEnd    = Convert.ToInt32(gc["endZ"].Value.Substring(0, 2), CultureInfo.InvariantCulture);
                    int      mEnd    = Convert.ToInt32(gc["endZ"].Value.Substring(2, 2), CultureInfo.InvariantCulture);

                    DateTime dtStartUtc = new DateTime(dtStart.Year, dtStart.Month, dtStart.Day, hStart, mStart, 0, DateTimeKind.Utc);
                    DateTime dtEndUtc   = new DateTime(dtStart.Year, dtStart.Month, dtStart.Day, hEnd, mEnd, 0, DateTimeKind.Utc);

                    if (dtEndUtc.CompareTo(dtStartUtc) < 0)
                    {
                        dtEndUtc = dtEndUtc.AddDays(1);
                    }

                    lstRb.Add(new RosterBuster()
                    {
                        FlightDate   = dtStart,
                        FlightNumber = gc["FlightNum"].Value,
                        BlockOut     = dtStartUtc,
                        BlockIn      = dtEndUtc,
                        Route        = gc["route"].Value,
                        TimeZone     = gc["Timezone"].Value
                    });
                }
                catch (FormatException) { }
            }

            using (DataTable dtDst = new DataTable())
            {
                dtDst.Locale = CultureInfo.CurrentCulture;
                CSVImporter.InitializeDataTable(dtDst);
                foreach (RosterBuster rb in lstRb)
                {
                    CSVImporter.WriteEntryToDataTable(rb.ToLogbookEntry(), dtDst);
                }
                return(CsvWriter.WriteToString(dtDst, true, true));
            }
        }
Exemple #2
0
        public override string CSVFromDataTable(DataTable dt)
        {
            // We ignore the data table passed in - we have our data from Matches, which was initialized in PreProcess.

            using (DataTable dtDst = new DataTable())
            {
                dtDst.Locale = CultureInfo.CurrentCulture;
                CSVImporter.InitializeDataTable(dtDst);
                foreach (TASCFlight rb in lstMatches)
                {
                    CSVImporter.WriteEntryToDataTable(rb.ToLogbookEntry(), dtDst);
                }
                return(CsvWriter.WriteToString(dtDst, true, true));
            }
        }
Exemple #3
0
 public override string CSVFromDataTable(DataTable dt)
 {
     if (dt == null)
     {
         throw new ArgumentNullException(nameof(dt));
     }
     using (DataTable dtDst = new DataTable())
     {
         dtDst.Locale = dt.Locale;
         CSVImporter.InitializeDataTable(dtDst);
         foreach (DataRow dr in dt.Rows)
         {
             MccPilot mcc = new MccPilot(dr);
             CSVImporter.WriteEntryToDataTable(mcc.ToLogbookEntry(), dtDst);
         }
         return(CsvWriter.WriteToString(dtDst, true, true));
     }
 }
Exemple #4
0
 public override string CSVFromDataTable(DataTable dt)
 {
     if (dt == null)
     {
         throw new ArgumentNullException("dt");
     }
     using (DataTable dtDst = new DataTable())
     {
         dtDst.Locale = dt.Locale;
         CSVImporter.InitializeDataTable(dtDst);
         foreach (DataRow dr in dt.Rows)
         {
             CrewLogFlight clf = new CrewLogFlight(dr);
             CSVImporter.WriteEntryToDataTable(clf.ToLogbookEntry(), dtDst);
         }
         return(CsvWriter.WriteToString(dtDst, true, true));
     }
 }
 public override string CSVFromDataTable(DataTable dt)
 {
     if (dt == null)
     {
         throw new ArgumentNullException(nameof(dt));
     }
     NormalizeColumnNames(dt);
     using (DataTable dtDst = new DataTable())
     {
         dtDst.Locale = dt.Locale;
         CSVImporter.InitializeDataTable(dtDst);
         foreach (DataRow dr in dt.Rows)
         {
             eLogSite els = new eLogSite(dr);
             CSVImporter.WriteEntryToDataTable(els.ToLogbookEntry(), dtDst);
         }
         return(CsvWriter.WriteToString(dtDst, true, true));
     }
 }
Exemple #6
0
        public override string CSVFromDataTable(DataTable dt)
        {
            if (dt == null)
            {
                throw new ArgumentNullException("dt");
            }
            IEnumerable <CustomPropertyType> rgcpt = CustomPropertyType.GetCustomPropertyTypes();

            using (DataTable dtDst = new DataTable())
            {
                dtDst.Locale = dt.Locale;
                CSVImporter.InitializeDataTable(dtDst);
                foreach (DataRow dr in dt.Rows)
                {
                    ForeFlight ltp = new ForeFlight(dr, dictAircraft, rgcpt);
                    CSVImporter.WriteEntryToDataTable(ltp.ToLogbookEntry(), dtDst);
                }
                return(CsvWriter.WriteToString(dtDst, true, true));
            }
        }
Exemple #7
0
        public override string CSVFromDataTable(DataTable dt)
        {
            if (dt == null)
            {
                throw new ArgumentNullException("dt");
            }
            IEnumerable <CustomPropertyType> rgcpt = CustomPropertyType.GetCustomPropertyTypes();

            NormalizeColumnNames(dt);
            using (DataTable dtDst = new DataTable())
            {
                dtDst.Locale = dt.Locale;
                CSVImporter.InitializeDataTable(dtDst);
                foreach (DataRow dr in dt.Rows)
                {
                    eLogSite els = new eLogSite(dr, rgcpt);
                    CSVImporter.WriteEntryToDataTable(els.ToLogbookEntry(), dtDst);
                }
                return(CsvWriter.WriteToString(dtDst, true, true));
            }
        }
        public override string CSVFromDataTable(DataTable dt)
        {
            // We ignore the data table passed in - we have our data from Matches, which was initialized in CanParse.

            // Build up the list of CrewTrac objects first; we'll then fill in cross-country time.
            List <CrewTrac> lstCt = new List <CrewTrac>();

            foreach (Match ctMatch in Matches)
            {
                GroupCollection gc = ctMatch.Groups;

                string szEmployees = gc["employees"].Value;
                // replace runs of 2 or more spaces with a tab for better finding boundaries (e.g., multiple employees).
                while (szEmployees.Contains("  "))
                {
                    szEmployees = szEmployees.Replace("  ", "\t");
                }

                MatchCollection mcEmployees = regCrewMember.Matches(szEmployees);

                List <CrewTracEmployee> lst = new List <CrewTracEmployee>();
                foreach (Match empMatch in mcEmployees)
                {
                    GroupCollection gcEmployee = empMatch.Groups;
                    if (!Enum.TryParse <CrewTracEmployee.CrewTracRole>(gcEmployee["pos"].Value, out CrewTracEmployee.CrewTracRole role))
                    {
                        role = CrewTracEmployee.CrewTracRole.CA;
                    }
                    lst.Add(new CrewTracEmployee()
                    {
                        Role = role, Name = gcEmployee["empname"].Value
                    });
                }

                try
                {
                    CrewTrac ct = new CrewTrac()
                    {
                        FlightNumber = String.IsNullOrEmpty(gc["flightnum"].Value) ? 0 : Convert.ToInt32(gc["flightnum"].Value, CultureInfo.CurrentCulture),
                        Date         = Convert.ToDateTime(gc["date"].Value, CultureInfo.CurrentCulture),
                        From         = gc["from"].Value,
                        To           = gc["to"].Value,
                        BlockHours   = gc["block"].Value.DecimalFromHHMM(),
                        Tail         = gc["tail"].Value,
                        Model        = gc["model"].Value,
                        Landings     = String.IsNullOrEmpty(gc["landings"].Value) ? 0 : Convert.ToInt32(gc["landings"].Value, CultureInfo.CurrentCulture),
                        Employees    = lst
                    };
                    lstCt.Add(ct);
                }
                catch (Exception ex) when(ex is FormatException)
                {
                }
            }

            // Build up a list of airports so that we can determine cross-country time.
            StringBuilder sbRoutes = new StringBuilder();

            foreach (CrewTrac ct in lstCt)
            {
                sbRoutes.AppendFormat(CultureInfo.CurrentCulture, " {0} {1}", ct.From, ct.To);
            }
            AirportList alRoutes = new AirportList(sbRoutes.ToString());

            foreach (CrewTrac ct in lstCt)
            {
                AirportList alFlight = alRoutes.CloneSubset(ct.From + " " + ct.To);
                if (alFlight.MaxDistanceForRoute() > 50.0)
                {
                    ct.CrossCountry = ct.BlockHours;
                }
            }

            using (DataTable dtDst = new DataTable())
            {
                dtDst.Locale = CultureInfo.CurrentCulture;
                CSVImporter.InitializeDataTable(dtDst);
                foreach (CrewTrac ct in lstCt)
                {
                    CSVImporter.WriteEntryToDataTable(ct.ToLogbookEntry(), dtDst);
                }
                return(CsvWriter.WriteToString(dtDst, true, true));
            }
        }
        public override string CSVFromDataTable(DataTable dt)
        {
            // We ignore the data table passed in - we have our data from Matches, which was initialized in CanParse.

            // Build up the list of CrewTrac objects first; we'll then fill in cross-country time.
            List <AAScheduler> lstAA = new List <AAScheduler>();

            foreach (Match aaMatch in Matches)
            {
                GroupCollection gc = aaMatch.Groups;

                try
                {
                    DateTime    dtDep = Convert.ToDateTime(String.Format(CultureInfo.CurrentCulture, "{0} {1}", gc["startdate"].Value, gc["starttime"].Value), CultureInfo.CurrentCulture);
                    DateTime    dtArr = Convert.ToDateTime(String.Format(CultureInfo.CurrentCulture, "{0} {1}", gc["enddate"].Value, gc["endtime"].Value), CultureInfo.CurrentCulture);
                    AAScheduler aas   = new AAScheduler()
                    {
                        ScheduledDeparture = dtDep,
                        ScheduledArrival   = dtArr,
                        BlockTime          = gc["blocktime"].Value.DecimalFromHHMM(),
                        FlightNumber       = gc["flightnum"].Value,
                        Deadhead           = !String.IsNullOrEmpty(gc["deadhead"].Value),
                        From     = gc["from"].Value,
                        To       = gc["to"].Value,
                        Sequence = gc["seq"].Value,
                        Leg      = String.IsNullOrEmpty(gc["leg"].Value) ? 0 : Convert.ToInt32(gc["leg"].Value, CultureInfo.CurrentCulture)
                    };
                    lstAA.Add(aas);
                }
                catch (Exception ex) when(ex is FormatException)
                {
                }

                // Build up a list of airports so that we can determine cross-country time.
                StringBuilder sbRoutes = new StringBuilder();
                foreach (AAScheduler aas in lstAA)
                {
                    sbRoutes.AppendFormat(CultureInfo.CurrentCulture, " {0} {1}", aas.From, aas.To);
                }
                AirportList alRoutes = new AirportList(sbRoutes.ToString());

                foreach (AAScheduler aas in lstAA)
                {
                    AirportList alFlight = alRoutes.CloneSubset(aas.From + " " + aas.To);
                    if (alFlight.MaxDistanceForRoute() > 50.0)
                    {
                        aas.CrossCountry = aas.BlockTime;
                    }
                }
            }

            using (DataTable dtDst = new DataTable())
            {
                dtDst.Locale = CultureInfo.CurrentCulture;
                CSVImporter.InitializeDataTable(dtDst);
                foreach (AAScheduler aa in lstAA)
                {
                    CSVImporter.WriteEntryToDataTable(aa.ToLogbookEntry(), dtDst);
                }
                return(CsvWriter.WriteToString(dtDst, true, true));
            }
        }