Example #1
0
        private void BuildPairingView(string pairingFileName)
        {
            PairingListParser pairingListParser = new PairingListParser(pairingFileName);
            DataTable         pairingTable      = pairingListParser.Read();

            //to-do
            if (pairingTable.Rows == null)
            {
                return;
            }

            string          formatString  = "yyyyMMddHHmmss";
            DateTime        startTime     = DateTime.Now;
            DateTime        endTime       = DateTime.Now;
            List <DateTime> startTimeList = new List <DateTime>();
            List <DateTime> endTimeList   = new List <DateTime>();
            bool            newAppGroup   = true;

            pairing.Clear();

            int i = 0;

            foreach (DataRow dr in pairingTable.Rows)
            {
                startTime = DateTime.ParseExact(dr.ItemArray[4].ToString(), formatString, null);
                endTime   = DateTime.ParseExact(dr.ItemArray[5].ToString(), formatString, null);
                startTimeList.Add(startTime);
                endTimeList.Add(endTime);

                //ag2.WorkTimes.Add(new TimeRange() { startTime = DateTime.Today.AddHours(9), endTime = DateTime.Today.AddHours(15) });
                //ag2.WorkTimes.Add(new TimeRange() { startTime = DateTime.Today.AddHours(17), endTime = DateTime.Today.AddHours(18) });

                foreach (AppointmentGroup _ag in pairing)
                {
                    var confs = _ag.Where(a => (this.IsTimeCrossing(startTime, endTime, a.StartTime, a.EndTime)));
                    if (confs.Count() == 0)
                    {
                        Appointment ap = new Appointment()
                        {
                            Title     = dr.ItemArray[0].ToString(),
                            GroupId   = _ag.GroupId,
                            StartTime = startTime,
                            EndTime   = endTime,
                            Percent   = 0.7f,
                            Tooltip   = dr.ItemArray[1].ToString() + " " + "Flight Time " + dr.ItemArray[6]
                        };
                        _ag.Add(ap);
                        newAppGroup = false;
                        break;
                    }
                }

                if (newAppGroup)
                {
                    AppointmentGroup ag = new AppointmentGroup();
                    ag.GroupTitle = "Pairing";
                    ag.GroupId    = i++;

                    Appointment ap = new Appointment()
                    {
                        Title     = dr.ItemArray[0].ToString(),
                        GroupId   = ag.GroupId,
                        StartTime = startTime,
                        EndTime   = endTime,
                        Percent   = 0.7f,
                        Tooltip   = dr.ItemArray[1].ToString() + " " + "Flight Time " + dr.ItemArray[6]
                    };
                    ag.Add(ap);
                    pairing.Add(ag);
                }
            }

            TimeRange(startTimeList, endTimeList);

            this.rosterGanttControl2.StartTime = _startTime;
            if (_totalHour > 1)
            {
                this.rosterGanttControl2.TotalHour = _totalHour;
            }
            this.rosterGanttControl2.Invalidate();
        }
Example #2
0
        private void BuildPairingView(string pairingFileName)
        {
            PairingListParser pairingListParser = new PairingListParser(pairingFileName);
            DataTable pairingTable = pairingListParser.Read();

            //to-do
            if (pairingTable.Rows == null)
            {
                return;
            }

            string formatString = "yyyyMMddHHmmss";
            DateTime startTime = DateTime.Now;
            DateTime endTime = DateTime.Now;
            List<DateTime> startTimeList = new List<DateTime>();
            List<DateTime> endTimeList = new List<DateTime>();
            bool newAppGroup = true;

            pairing.Clear();

            int i = 0;
            foreach (DataRow dr in pairingTable.Rows)
            {
                startTime = DateTime.ParseExact(dr.ItemArray[4].ToString(), formatString, null);
                endTime = DateTime.ParseExact(dr.ItemArray[5].ToString(), formatString, null);
                startTimeList.Add(startTime);
                endTimeList.Add(endTime);

                //ag2.WorkTimes.Add(new TimeRange() { startTime = DateTime.Today.AddHours(9), endTime = DateTime.Today.AddHours(15) });
                //ag2.WorkTimes.Add(new TimeRange() { startTime = DateTime.Today.AddHours(17), endTime = DateTime.Today.AddHours(18) });

                foreach (AppointmentGroup _ag in pairing)
                {
                    var confs = _ag.Where(a => (this.IsTimeCrossing(startTime, endTime, a.StartTime, a.EndTime)));
                    if (confs.Count() == 0)
                    {
                        Appointment ap = new Appointment()
                        {
                            Title = dr.ItemArray[0].ToString(),
                            GroupId = _ag.GroupId,
                            StartTime = startTime,
                            EndTime = endTime,
                            Percent = 0.7f,
                            Tooltip = dr.ItemArray[1].ToString() + " " + "Flight Time " + dr.ItemArray[6]
                        };
                        _ag.Add(ap);
                        newAppGroup = false;
                        break;
                    }
                }

                if (newAppGroup)
                {
                    AppointmentGroup ag = new AppointmentGroup();
                    ag.GroupTitle = "Pairing";
                    ag.GroupId = i++;

                    Appointment ap = new Appointment()
                    {
                        Title = dr.ItemArray[0].ToString(),
                        GroupId = ag.GroupId,
                        StartTime = startTime,
                        EndTime = endTime,
                        Percent = 0.7f,
                        Tooltip = dr.ItemArray[1].ToString() + " " + "Flight Time " + dr.ItemArray[6]
                    };
                    ag.Add(ap);
                    pairing.Add(ag);
                }
            }

            TimeRange(startTimeList, endTimeList);

            this.rosterGanttControl2.StartTime = _startTime;
            if (_totalHour > 1) this.rosterGanttControl2.TotalHour = _totalHour;
            this.rosterGanttControl2.Invalidate();
        }