Esempio n. 1
0
            public bool IsIntersecting(BusyTime otherEvent)
            {
                if (startTime >= otherEvent.startTime || endTime <= otherEvent.endTime)
                {
                    return(true);
                }

                return(false);
            }
Esempio n. 2
0
    private void Save()
    {
        AjaxResult result = new AjaxResult();

        result.IsSuccess = false;
        result.Msg       = "保存失败!";
        DateTime date = DateTime.MinValue;

        DateTime.TryParse(Request.Form["BusyDate"], out date);
        BusyTime model = null;

        if (!bll.IsHash(date))//新增
        {
            model = new BusyTime()
            {
                BusyDate      = date,
                BusyBeginTime = new DateTime(date.Year, date.Month, date.Day, int.Parse(Request.Form["BusyBeginTime"].Split(':')[0]), int.Parse(Request.Form["BusyBeginTime"].Split(':')[1]), 0),
                BusyEndTime   = new DateTime(date.Year, date.Month, date.Day, int.Parse(Request.Form["BusyEndTime"].Split(':')[0]), int.Parse(Request.Form["BusyEndTime"].Split(':')[1]), 0),
            };
            if (bll.Add(model))
            {
                result.IsSuccess = true;
                result.Msg       = "增加成功!";
            }
        }
        else//编辑
        {
            model = bll.Get(date);
            if (model != null)
            {
                model.BusyBeginTime = new DateTime(date.Year, date.Month, date.Day, int.Parse(Request.Form["BusyBeginTime"].Split(':')[0]), int.Parse(Request.Form["BusyBeginTime"].Split(':')[1]), 0);
                model.BusyEndTime   = new DateTime(date.Year, date.Month, date.Day, int.Parse(Request.Form["BusyEndTime"].Split(':')[0]), int.Parse(Request.Form["BusyEndTime"].Split(':')[1]), 0);

                if (bll.Update(model))
                {
                    result.IsSuccess = true;
                    result.Msg       = "更新成功!";
                }
            }
        }

        Response.Clear();
        Response.Write(result.ToJsonString());
        Response.ContentType = "application/json";
        Response.End();
    }
Esempio n. 3
0
        private void LoadData()
        {
            var streamReader = new StreamReader(new FileStream(@"App_Data/freebusy.txt", FileMode.Open));

            while (!streamReader.EndOfStream)
            {
                var line   = streamReader.ReadLine();
                var values = line.Split(';');

                // line is irrelevant, so skip it
                if (values.Length < 2)
                {
                    continue;
                }

                // line contains a Employee-record
                if (values.Length == 2)
                {
                    var employee = new Employee
                    {
                        Id   = values[0],
                        Name = values[1]
                    };

                    _employees.Add(employee);
                }
                // line contains a BusyTime-record
                else
                {
                    var busyTime = new BusyTime
                    {
                        EmployeeId = values[0],
                        StartTime  = DateTimeOffset.Parse(values[1]),
                        EndTime    = DateTimeOffset.Parse(values[2])
                    };

                    _busyTimes.Add(busyTime);
                }
            }

            streamReader.Dispose();
        }
Esempio n. 4
0
 public bool Update(BusyTime model)
 {
     return(dal.Update(model) > 0);
 }
Esempio n. 5
0
 public bool Add(BusyTime model)
 {
     return(dal.Add(model) > 0);
 }
Esempio n. 6
0
 public void Combine(BusyTime otherEvent)
 {
     startTime = Math.Min(startTime, otherEvent.startTime);
     endTime   = Math.Max(endTime, otherEvent.endTime);
 }