public ScheduleProfile(ScheduleProfile oldProfile)
 {
     ServerHostID = oldProfile.ServerHostID;
     EventHour    = oldProfile.EventHour;
     EventMinute  = oldProfile.EventMinute;
     Backup       = oldProfile.Backup;
     BackupPath   = oldProfile.BackupPath;
 }
        public void Setup()
        {
            var profile = new ScheduleProfile();
            var config  = new MapperConfiguration(opt =>
            {
                opt.AddProfile(profile);
            });

            mapper = config.CreateMapper();
        }
Exemple #3
0
        private void CreateNewSchedule()
        {
            int minInternal = DateTime.Now.Minute / 15;

            TempSchedule = new ScheduleProfile(
                -2, // Indicates that this is a new schedule profile!
                DateTime.Now.Hour,
                minInternal
                );
        }
Exemple #4
0
 private void lstSchedules_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lstSchedules.SelectedIndex > -1)
     {
         // An entry was selected
         TempSchedule = new ScheduleProfile(mvarScheduleProfiles[lstSchedules.SelectedIndex]);
         EditSchedule();
     }
     else
     {
         // No entries are selected
         grpEdit.Visible = false;
         btnNew.Visible  = true;
     }
 }
Exemple #5
0
        /*
         * This is one way of implementing this kind of sorting
         * using plain loops and simple methods.
         * There are tons of newer and better ways of implementing
         * a sorting function which are preferrable over this
         * implementation any day.
         *
         */

        private void SortScheduleProfiles()
        {
            int[] hours   = new int[0];
            int[] minutes = new int[0];
            bool  found   = false;

            for (int s = 0; s < mvarScheduleProfiles.Length; s++)
            {
                found = false;
                for (int h = 0; h < hours.Length; h++)
                {
                    if (hours[h] == mvarScheduleProfiles[s].EventHour)
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    Array.Resize(ref hours, hours.Length + 1);
                    hours[hours.Length - 1] = mvarScheduleProfiles[s].EventHour;
                }

                found = false;
                for (int m = 0; m < minutes.Length; m++)
                {
                    if (minutes[m] == mvarScheduleProfiles[s].EventMinute)
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    Array.Resize(ref minutes, minutes.Length + 1);
                    minutes[minutes.Length - 1] = mvarScheduleProfiles[s].EventMinute;
                }
            }

            Array.Sort(hours);
            Array.Sort(minutes);

            ScheduleProfile[] temp = new ScheduleProfile[mvarScheduleProfiles.Length];
            int targetIndex        = -1;

            for (int h = 0; h < hours.Length; h++)
            {
                for (int m = 0; m < minutes.Length; m++)
                {
                    for (int s = 0; s < mvarScheduleProfiles.Length; s++)
                    {
                        if (mvarScheduleProfiles[s].EventHour == hours[h] && mvarScheduleProfiles[s].EventMinute == minutes[m])
                        {
                            // We found a schedule entry that matches the hours : minutes combination
                            // so, we'll add this entry to the new list and tag the old one as done ...

                            targetIndex++;

                            temp[targetIndex] = new ScheduleProfile(mvarScheduleProfiles[s]);
                            mvarScheduleProfiles[s].EventHour = -1;

                            break;
                        }
                    }
                }
            }

            Array.Copy(temp, 0, mvarScheduleProfiles, 0, temp.Length);

            temp = new ScheduleProfile[0];

            // The quick and easy way of performing the sort:
            // jobun44's solution using Linq :)
            // mvarScheduleProfiles = mvarScheduleProfiles.OrderBy(x => x.EventHour * 60 + x.EventMinute).ToArray();
            // Using the Linq method should be overall faster than the oldschool implementation above
        }