Beispiel #1
0
        public static OrgSchedule ParseSchedule(string s)
        {
            var m = Regex.Match(s, @"\A(?<dow>.*)\s(?<time>\d{1,2}:\d{2}\s(A|P)M)", RegexOptions.IgnoreCase);
            var d = new Dictionary <string, int>
            {
                { "sun", 0 },
                { "mon", 1 },
                { "tue", 2 },
                { "wed", 3 },
                { "thu", 4 },
                { "fri", 5 },
                { "sat", 6 },
                { "any", 10 },
            };
            var dow  = m.Groups["dow"].Value.ToLower();
            var time = DateTime.Parse(m.Groups["time"].Value);
            var mt   = Util.Now.Sunday().AddDays(d[dow]).Add(time.TimeOfDay);
            var sc   = new OrgSchedule
            {
                SchedDay       = d[dow],
                SchedTime      = mt,
                AttendCreditId = 1
            };

            return(sc);
        }
Beispiel #2
0
 public void Update(OrgSchedule schedule)
 {
     AttendCreditId = schedule.AttendCreditId;
     Id             = schedule.Id;
     MeetingTime    = schedule.MeetingTime;
     SchedDay       = schedule.SchedDay;
     SchedTime      = schedule.SchedTime;
 }
Beispiel #3
0
        public static OrgSchedule ParseSchedule(string dow, string time, int i = 1)
        {
            var d = new Dictionary <string, int>(StringComparer.OrdinalIgnoreCase)
            {
                { "sun", 0 },
                { "mon", 1 },
                { "tue", 2 },
                { "wed", 3 },
                { "thu", 4 },
                { "fri", 5 },
                { "sat", 6 },
                { "any", 10 },
            };

            if (!dow.HasValue())
            {
                dow = "sun";
            }

            dow = dow.Truncate(3);
            var re = new Regex(@"(?<h>\d+)(?::?)(?<s>\d{2})?\s*(?<a>(?:A|P)M)?", RegexOptions.IgnoreCase);
            var m  = re.Match(time);
            var h  = m.Groups["h"].Value;
            var s  = Util.PickFirst(m.Groups["s"].Value, "00");
            var a  = Util.PickFirst(m.Groups["a"].Value, "AM");
            var ts = $"{h}:{s} {a}";
            var t  = DateTime.Parse(ts);
            var mt = Util.Now.Sunday().AddDays(d[dow]).Add(t.TimeOfDay);
            //SELECT @id = (ISNULL(@day, DATEPART(dw, @time)-1) + 1) * 10000 + DATEPART(hour, @time) * 100 + DATEPART(mi, @time)
            var schedid = (d[dow] + 1) * 10000 + t.TimeOfDay.Hours * 100 + t.TimeOfDay.Minutes;
            var sc      = new OrgSchedule
            {
                Id             = i,
                SchedDay       = d[dow],
                SchedTime      = mt,
                AttendCreditId = 1,
                ScheduleId     = schedid
            };

            return(sc);
        }
Beispiel #4
0
        public static OrgSchedule ParseSchedule(string s)
        {
            var m = Regex.Match(s, @"\A(?<dow>.*)\s(?<time>\d{1,2}:\d{2}\s(A|P)M)", RegexOptions.IgnoreCase);
            var d = new Dictionary <string, int>
            {
                { "Sun", 0 },
                { "Mon", 1 },
                { "Tue", 2 },
                { "Wed", 3 },
                { "Thu", 4 },
                { "Fri", 5 },
                { "Sat", 6 },
            };
            var dow  = m.Groups["dow"].Value;
            var time = m.Groups["time"].Value;
            var sc   = new OrgSchedule
            {
                SchedDay       = d[dow],
                SchedTime      = DateTime.Parse(time),
                AttendCreditId = 1
            };

            return(sc);
        }
Beispiel #5
0
 public static OrgSchedule ParseSchedule(string s)
 {
     var m = Regex.Match(s, @"\A(?<dow>.*)\s(?<time>\d{1,2}:\d{2}\s(A|P)M)", RegexOptions.IgnoreCase);
     var d = new Dictionary<string, int>
     {
         { "sun", 0 },
         { "mon", 1 },
         { "tue", 2 },
         { "wed", 3 },
         { "thu", 4 },
         { "fri", 5 },
         { "sat", 6 },
         { "any", 10 },
     };
     var dow = m.Groups["dow"].Value.ToLower();
     var time = DateTime.Parse(m.Groups["time"].Value);
     var mt = Util.Now.Sunday().AddDays(d[dow]).Add(time.TimeOfDay);
     var sc = new OrgSchedule
     {
         SchedDay = d[dow],
         SchedTime = mt,
         AttendCreditId = 1
     };
     return sc;
 }
Beispiel #6
0
        public static OrgSchedule ParseSchedule(string dow, string time, int i = 1)
        {
            var d = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
            {
                { "sun", 0 },
                { "mon", 1 },
                { "tue", 2 },
                { "wed", 3 },
                { "thu", 4 },
                { "fri", 5 },
                { "sat", 6 },
                { "any", 10 },
            };

            if (!dow.HasValue())
                dow = "sun";
            dow = dow.Truncate(3);
            var re = new Regex(@"(?<h>\d+)(?::?)(?<s>\d{2})?\s*(?<a>(?:A|P)M)?", RegexOptions.IgnoreCase);
            var m = re.Match(time);
            var h = m.Groups["h"].Value;
            var s = Util.PickFirst(m.Groups["s"].Value, "00");
            var a = Util.PickFirst(m.Groups["a"].Value, "AM");
            var ts = $"{h}:{s} {a}";
            var t = DateTime.Parse(ts);
            var mt = Util.Now.Sunday().AddDays(d[dow]).Add(t.TimeOfDay);
            //SELECT @id = (ISNULL(@day, DATEPART(dw, @time)-1) + 1) * 10000 + DATEPART(hour, @time) * 100 + DATEPART(mi, @time)
            var schedid = (d[dow] + 1) * 10000 + t.TimeOfDay.Hours * 100 + t.TimeOfDay.Minutes;
            var sc = new OrgSchedule
            {
                Id = i,
                SchedDay = d[dow],
                SchedTime = mt,
                AttendCreditId = 1,
                ScheduleId = schedid
            };
            return sc;
        }
Beispiel #7
0
 private void detach_OrgSchedules(OrgSchedule entity)
 {
     this.SendPropertyChanging();
     entity.Organization = null;
 }
Beispiel #8
0
 public ScheduleInfo()
 {
     sc = new OrgSchedule();
 }
Beispiel #9
0
 public ScheduleInfo(OrgSchedule sc)
 {
     this.sc = sc;
     SchedDay = new CodeInfo(sc.SchedDay, "SchedDay");
     AttendCredit = new CodeInfo(sc.AttendCreditId, "AttendCredit");
 }
Beispiel #10
0
 public ScheduleInfo(OrgSchedule sc)
 {
     this.sc = sc;
 }
Beispiel #11
0
        public static OrgSchedule ParseSchedule(string dow, string time)
        {
            var d = new Dictionary<string, int>
            {
                { "sun", 0 },
                { "mon", 1 },
                { "tue", 2 },
                { "wed", 3 },
                { "thu", 4 },
                { "fri", 5 },
                { "sat", 6 },
                { "any", 10 },
            };

            if (!dow.HasValue())
                dow = "sun";
            var t = DateTime.Parse(time);
            var mt = Util.Now.Sunday().AddDays(d[dow.ToLower()]).Add(t.TimeOfDay);
            var sc = new OrgSchedule
            {
                SchedDay = d[dow],
                SchedTime = mt,
                AttendCreditId = 1
            };
            return sc;
        }