public async Task <IActionResult> Index(ScheduleDate dates)
        {
            try
            {
                _token = HttpContext.Session.GetString("token");
                HttpResponseMessage response = await _repProvider.GetSchedule(dates.Date, _token);

                if (response.IsSuccessStatusCode)
                {
                    var result = response.Content.ReadAsStringAsync().Result;
                    TempData["result"] = result;
                    return(RedirectToAction("Schedule"));
                }
                else if (response.StatusCode == HttpStatusCode.NotFound)
                {
                    _log.Error("could not schedule");
                    return(View("NoSchedule"));
                }
                else if (response.StatusCode == HttpStatusCode.Unauthorized)
                {
                    return(View("Unauthorized"));
                }
                else
                {
                    _log.Error("Error occured in Micro-Service called for scheduling");
                    return(View("Error"));
                }
            }
            catch (Exception e)
            {
                _log.Error("Error in Schedule Controller while displaying schedule - " + e.Message);
                return(View("Error"));
            }
        }
Пример #2
0
        public async Task <IActionResult> Index(ScheduleDate dates)
        {
            List <RepSchedule> response = await _repProvider.GetSchedule(dates.Date.Date);

            ViewBag.schedule = response;
            return(View("Schedule"));
        }
        public bool AddDate2(ScheduleDate scheduleDate)
        {
            var c = db.ScheduleDates.Where(b => b.ExtendSchedule == "Yes").Select(b => b.Count).FirstOrDefault();

            if (c > 0)
            {
                c = db.ScheduleDates.Where(b => b.ExtendSchedule == "Yes").Select(b => b.Count).Max();
            }
            else
            {
                c = 0;
            }

            try
            {
                scheduleDate.Count  = c + 1;
                scheduleDate.DateTo = scheduleDate.DateFrom.AddDays(7);
                db.ScheduleDates.Add(scheduleDate);
                db.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Пример #4
0
    /// <summary>
    /// Creates a ScheduledTask.
    /// </summary>
    /// <param name="taskName">The name of the task.</param>
    /// <param name="taskDescription">A description for this task.</param>
    /// <param name="enabled">The status of whether or not the task is enabled.</param>
    /// <param name="frequency">How often (on what days) this task should be run.</param>
    /// <param name="dailyFrequencyInterval">How often (at what times) this task should be run.</param>
    public ScheduledTask(string taskName, string taskDescription, bool enabled, Frequency frequency, FrequencyTime dailyFrequencyInterval)
    {
        TaskName        = taskName;
        TaskDescription = taskDescription;
        Enabled         = enabled;

        Schedule = new ScheduleDate(frequency, dailyFrequencyInterval);
    }
        public void OneTimeOnlyDateTest2()
        {
            // no need for a schedule
            var d1 = new ScheduleDate(DateTime.Today);

            Assert.IsTrue(d1.Includes(DateTime.Today));
            Assert.IsFalse(d1.Includes(DateTime.Today.AddDays(1)));
        }
        private void setWeekStart()
        {
            var usr = LoginHelper.GetLoggedInUser().User;

            while (ScheduleDate.DayOfWeek != (DayOfWeek)usr.Company.WeekStart.GetValueOrDefault())
            {
                ScheduleDate = ScheduleDate.AddDays(-1);
            }
        }
Пример #7
0
 public ActionResult CreateManualy(ScheduleDate scheduleDate)
 {
     if (ModelState.IsValid)
     {
         logic.AddDate2(scheduleDate);
         return(RedirectToAction("Index"));
     }
     return(View(scheduleDate));
 }
        private void CreateScheduleButton_Click(object sender, EventArgs e)
        {
            DateTime     sd      = StartDateCalenedar.SelectionStart;
            DateTime     se      = EndDateCalendar.SelectionStart;
            ScheduleDate shedate = manager.CreateScheduleDates(sd, se, Scheduler.CongregationId, Scheduler.Id);

            currentHp.CurrentScheduleGridView = cc.Schedule(currentHp.CurrentScheduleGridView, shedate);
            this.Close();
        }
        public void OneTimeOnlyDateTest1()
        {
            // no need for a schedule
            var date = new DateTime(2030, 6, 5);
            var d1   = new ScheduleDate(date);

            Assert.IsTrue(d1.Includes(date));
            Assert.IsFalse(d1.Includes(new DateTime(2030, 6, 6)));
        }
Пример #10
0
        public void LowLevelSimpleDateTest1()
        {
            var aDate        = new DateTime(2040, 7, 4);
            var scheduleDate = new ScheduleDate(aDate);

            var ludwigWittgensteinBirthday = new DateTime(1889, 4, 26);

            Assert.IsTrue(scheduleDate.Includes(new DateTime(2040, 7, 4)));
            Assert.IsFalse(scheduleDate.Includes(ludwigWittgensteinBirthday));
        }
Пример #11
0
        public string InsertSQL()
        {
            String sql = "insert into workorder (productorder,type,scheduledate,lenth,width," +
                         "thickness,gross,done,undone,completedate,machinecode,worker,worth,remark,status,receivedate,grosswidth) " +
                         "values ('{0}','{1}','{2}',{3},{4},{5},{6},{7},{8},'{9}','{10}','{11}',{12},'{13}',{14},'{15}',{16})";

            return(String.Format(sql, ProductOrder, Type, ScheduleDate.ToString("yyyy-MM-dd"), Length.ToString(), Width.ToString(),
                                 Thickness.ToString(), Gross.ToString(), Done.ToString(), Undo.ToString(), CompleteDate.ToString("yyyy-MM-dd"),
                                 MachineCode, Worker, Worth.ToString(), Remark, Status.ToString(), ReceiveDate.ToString("yyyy-MM-dd HH:mm:ss"), GrossWidth.ToString()));
        }
Пример #12
0
        public string UndateSQL()
        {
            String sql = "update workorder set productorder = '{0}',type = '{1}',scheduledate='{2}',lenth={3},width = {4}," +
                         "thickness={5},gross={6},done={7},undone={8},completedate='{9}',machinecode='{10}',worker='{11}'," +
                         "worth={12},remark='{13}',status={14} ,receivedate = '{15}',grosswidth = {16} where id = {17} ";

            return(String.Format(sql, ProductOrder, Type, ScheduleDate.ToString("yyyy-MM-dd"), Length.ToString(), Width.ToString(),
                                 Thickness.ToString(), Gross.ToString(), Done.ToString(), Undo.ToString(), CompleteDate.ToString("yyyy-MM-dd"),
                                 MachineCode, Worker, Worth.ToString(), Remark, Status.ToString(), ReceiveDate.ToString("yyyy-MM-dd HH:mm:ss"),
                                 GrossWidth.ToString(), id.ToString()));
        }
        public override async System.Threading.Tasks.Task ExecuteLoadSchedulesCommand()
        {
            if (IsBusy)
            {
                return;
            }

            if (!IsRefreshing)
            {
                IsBusy = true;
            }

            try
            {
                if (!Users.Any())
                {
                    var lookups = await DataService.GetLookups(1000);

                    lookups.Users.ForEach(u => Users.Add(u));
                }

                ScheduleDateFormatted = ScheduleDate.ToShortDateString();
                OnPropertyChanged("ScheduleDateFormatted");

                Schedules.Clear();
                var items = await DataService.GetItemsAsync <Schedule>($"schedules?start={ScheduleDate.ToString("MM-dd-yyyy")}&end={ScheduleDate.ToString("MM-dd-yyyy")}{(CanManageSchedule ? "" : "&assigned=true")}");

                NoSchedules = !items.Data.Any();
                OnPropertyChanged("NoSchedules");
                this.WeekUnpublished = false;
                foreach (var item in items.Data.OrderBy(d => d.User == null ? "zzzzzz" : d.User.FirstName))
                {
                    if (item.UserId != null && !item.PublishedValue)
                    {
                        this.WeekUnpublished = true;
                    }
                    var displayItem = new DisplayItem();
                    scheduleToDisplayItem(displayItem, item);
                    Schedules.Add(displayItem);
                }
            }
            catch (Exception ex)
            {
                IsBusy       = false;
                IsRefreshing = false;
                ExceptionHelper.ShowException(ex);
            }
            finally
            {
                IsBusy       = false;
                IsRefreshing = false;
            }
        }
Пример #14
0
        }         // Fill

        public override string ToString()
        {
            return(string.Format(
                       "LoanID: {0}, Schedule: {1} at {2}, Transaction: {3} at {4}, Delay: {5}",
                       LoanID,
                       ScheduleID,
                       ScheduleDate.ToString("d/MMM/yyyy H:mm:ss", CultureInfo.InvariantCulture),
                       TransactionID,
                       TransactionTime.ToString("d/MMM/yyyy H:mm:ss", CultureInfo.InvariantCulture),
                       Delay
                       ));
        } // ToString
 public bool Update(ScheduleDate scheduleDate)
 {
     try
     {
         //  db.Entry(scheduleDate).State = EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
 public bool Delete(ScheduleDate scheduleDate)
 {
     try
     {
         db.ScheduleDates.Remove(scheduleDate);
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Пример #17
0
        protected async void SelectCallback(PatientUI p)
        {
            Scheduler.patient      = p;
            Scheduler.MRN          = p.MRN;
            Scheduler.ScheduleTime = ScheduleDate.ToString();
            Console.WriteLine(Scheduler.patient.Firstname);
            Console.WriteLine(Scheduler.MRN);
            Console.WriteLine(Scheduler.ScheduleTime);
            //We need to save the schedule here to the database
            await ScheduleService.Update(Scheduler);

            StateHasChanged();
        }
Пример #18
0
        public async Task <IActionResult> Get(int restaurantId, [FromBody] ScheduleDate scheduleDate)
        {
            try
            {
                var results = await _repo.GetScheduleByRestaurant(restaurantId);

                return(Ok(results));
            }
            catch (System.Exception ex)
            {
                string innerEx   = "";//ex.InnerException.Message;
                string exMessage = ex.Message;
                return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Banco Dados Falhou{exMessage + "|" + innerEx}"));
            }
        }
        public void EasterWesternDateTest()
        {
            var d2020 = new DateTime(2020, 4, 12);
            var d2021 = new DateTime(2021, 4, 4);
            var d2022 = new DateTime(2022, 4, 17);
            var d2023 = new DateTime(2023, 4, 9);
            var d2024 = new DateTime(2024, 3, 31);
            var d2025 = new DateTime(2025, 4, 20);
            var d2026 = new DateTime(2026, 4, 5);
            var d2027 = new DateTime(2027, 3, 28);
            var d2028 = new DateTime(2028, 4, 16);
            var d2029 = new DateTime(2029, 4, 1);
            var d2030 = new DateTime(2030, 4, 21);

            //var dateList = Easter.GetEasterSundays(2020, 2030);
            //foreach (var date in dateList)
            //{
            //    Debug.WriteLine(date.ToShortDateString());
            //}

            var s2020 = new ScheduleDate(Easter.GetEasterSunday(2020));
            var s2021 = new ScheduleDate(Easter.GetEasterSunday(2021));
            var s2022 = new ScheduleDate(Easter.GetEasterSunday(2022));
            var s2023 = new ScheduleDate(Easter.GetEasterSunday(2023));
            var s2024 = new ScheduleDate(Easter.GetEasterSunday(2024));
            var s2025 = new ScheduleDate(Easter.GetEasterSunday(2025));
            var s2026 = new ScheduleDate(Easter.GetEasterSunday(2026));
            var s2027 = new ScheduleDate(Easter.GetEasterSunday(2027));
            var s2028 = new ScheduleDate(Easter.GetEasterSunday(2028));
            var s2029 = new ScheduleDate(Easter.GetEasterSunday(2029));
            var s2030 = new ScheduleDate(Easter.GetEasterSunday(2030));

            Assert.IsTrue(s2020.Includes(d2020));
            Assert.IsTrue(s2021.Includes(d2021));
            Assert.IsTrue(s2022.Includes(d2022));
            Assert.IsTrue(s2023.Includes(d2023));
            Assert.IsTrue(s2024.Includes(d2024));
            Assert.IsTrue(s2025.Includes(d2025));
            Assert.IsTrue(s2026.Includes(d2026));
            Assert.IsTrue(s2027.Includes(d2027));
            Assert.IsTrue(s2028.Includes(d2028));
            Assert.IsTrue(s2029.Includes(d2029));
            Assert.IsTrue(s2030.Includes(d2030));
        }
Пример #20
0
        public Schedule Get(DateTime startDate)
        {
            DateTime monday = startDate.AddDays(-(int)DateTime.Today.DayOfWeek
                                                + (int)DayOfWeek.Monday).Date;

            Func <SupportSlot, bool> where = (p => p.Date >= monday);

            List <SupportSlot> slots = _supportSlotRepo.Find(where).ToList().OrderBy(e => e.Date).ThenBy(e => e.Slot).ToList();

            Schedule schedule = new Schedule();

            if (slots.Count > 0)
            {
                schedule.Dates = new List <ScheduleDate>();
                DateTime endDate     = slots.Max(e => e.Date);
                DateTime currentDate = monday;
                while (currentDate <= endDate)
                {
                    if (currentDate.DayOfWeek != DayOfWeek.Saturday && currentDate.DayOfWeek != DayOfWeek.Sunday)
                    {
                        ScheduleDate newCalendarDate = new ScheduleDate();
                        newCalendarDate.When  = currentDate;
                        newCalendarDate.Slots = new List <ScheduleSlot>();

                        List <SupportSlot> slotstoday = slots.Where(e => e.Date == currentDate).ToList();
                        foreach (var slot in slotstoday)
                        {
                            newCalendarDate.Slots.Add(new ScheduleSlot {
                                EngineerID = slot.Engineer.ID, EngineerName = slot.Engineer.FirstName + " " + slot.Engineer.LastName
                            });
                        }


                        schedule.Dates.Add(newCalendarDate);
                    }
                    currentDate = currentDate.AddDays(1);
                }
            }

            return(schedule);
        }
Пример #21
0
        public async Task <IActionResult> Index(ScheduleDate dates)
        {
            try
            {
                if (HttpContext.Session.GetString("token") == null)
                {
                    return(RedirectToAction("Login", "User"));
                }
                else
                {
                    _token = HttpContext.Session.GetString("token");
                    HttpResponseMessage response = await _repProvider.GetSchedule(dates.Date, _token);

                    if (response.IsSuccessStatusCode)
                    {
                        var result = response.Content.ReadAsStringAsync().Result;
                        TempData["result"] = result;
                        return(RedirectToAction("Schedule"));
                    }
                    else if (response.StatusCode == HttpStatusCode.NotFound)
                    {
                        return(View("NoSchedule"));
                    }
                    else if (response.StatusCode == HttpStatusCode.Unauthorized)
                    {
                        return(View("Unauthorized"));
                    }
                    else
                    {
                        return(View("Error"));
                    }
                }
            }
            catch (Exception)
            {
                return(View("Error"));
            }
        }
Пример #22
0
        public override int GetHashCode()
        {
            unchecked {
                int hash = 17;
                if (Schedule != default(string))
                {
                    hash = hash * 23 + Schedule.GetHashCode();
                }
                if (ScheduleDate != default(DateTime))
                {
                    hash = hash * 23 + ScheduleDate.GetHashCode();
                }
                if (RetryDate != default(DateTime))
                {
                    hash = hash * 23 + RetryDate.GetHashCode();
                }
                if (ProcessedAt != default(DateTime))
                {
                    hash = hash * 23 + ProcessedAt.GetHashCode();
                }
                if (Status != default(OccurrenceStatus))
                {
                    hash = hash * 23 + Status.GetHashCode();
                }
                if (Message != default(String))
                {
                    hash = hash * 23 + Message.GetHashCode();
                }
                if (Result != default(String))
                {
                    hash = hash * 23 + Result.GetHashCode();
                }

                return(hash);
            }
        }
Пример #23
0
        //called by the system once a minute when a payment should be attempted
        public BillPayResultBag doScheduledPayment()
        {
            if (Blocked)
            {
                return(new BillPayResultBag(ScheduledBillPayResult.BLOCKED));
            }
            ModifyDate   = roundDown(ModifyDate);
            ScheduleDate = roundDown(ScheduleDate);
            var now = roundDown(DateTime.Now);

            if (ScheduleDate > now)
            {
                return(new BillPayResultBag(ScheduledBillPayResult.OK_NOT_PAID));
            }

            DateTime nextDue = ScheduleDate.AddDays(0);

            switch (Period)
            {
            case BillingPeriod.Minutes:
                nextDue = now;
                break;

            case BillingPeriod.Annually:
                while (nextDue < now)
                {
                    nextDue = nextDue.AddYears(1);
                }
                break;

            case BillingPeriod.Quarterly:
                while (nextDue < now)
                {
                    nextDue = nextDue.AddMonths(3);
                }
                break;

            case BillingPeriod.Once_Off:
                break;
            }

            if (nextDue != now)
            {
                return(new BillPayResultBag(ScheduledBillPayResult.OK_NOT_PAID));
            }

            Transaction transaction;

            //attempt payment
            if (Account.Balance - Amount < Account.minimumBalance())
            {
                transaction = new Transaction
                {
                    TransactionType = TransactionType.BillPay,
                    AccountId       = AccountId,
                    Amount          = 0,
                    TransactionTime = DateTime.Now,
                    //hijack unused comment field to store amount to display in the error message
                    Comment = Amount.ToString()
                };
                return(new BillPayResultBag(
                           ScheduledBillPayResult.FAIL_NOT_ENOUGH,
                           transaction
                           ));
            }

            //commit payment
            transaction = new Transaction
            {
                TransactionType = TransactionType.BillPay,
                AccountId       = AccountId,
                Amount          = Amount,
                TransactionTime = DateTime.Now
            };


            ModifyDate       = DateTime.Now;
            Account.Balance -= Amount;
            return(new BillPayResultBag(
                       ScheduledBillPayResult.OK_PAID,
                       transaction
                       ));
        }
        public override async System.Threading.Tasks.Task ExecuteLoadSchedulesCommand()
        {
            await runTask(async() =>
            {
                if (!Users.Any())
                {
                    Users.Add(new User()
                    {
                        FirstName = "(All)", UserId = _allGuid
                    });
                    Users.Add(new User()
                    {
                        FirstName = "(Unassigned)", UserId = _unassignedGuid
                    });
                    Users.Add(new User()
                    {
                        FirstName = "(Assigned)", UserId = _assignedGuid
                    });
                    var lookups = await DataService.GetLookups(4);
                    lookups.Users.ForEach(u => Users.Add(u));

                    Shifts.Add(new Shift()
                    {
                        ShiftName = "(All)", ShiftId = _allGuid
                    });
                    lookups.Shifts.ForEach(s => Shifts.Add(s));

                    Tasks.Add(new Task()
                    {
                        TaskName = "(All)", TaskId = _allGuid
                    });
                    lookups.Tasks.ForEach(t => Tasks.Add(t));
                }

                Schedules.Clear();
                var items            = await DataService.GetItemsAsync <Schedule>($"schedules?start={ScheduleDate.ToString("MM-dd-yyyy")}&end={ScheduleDate.AddDays(6).ToString("MM-dd-yyyy")}");
                NoSchedules          = !items.Data.Any();
                this.WeekUnpublished = false;
                foreach (var item in items.Data.OrderBy(d => d.ScheduleDateValue).ThenBy(d => d.StartTimeValue).ThenBy(d => d.User == null ? "aaaaaaa" : d.User.FirstName))
                {
                    if (item.UserId != null && !item.PublishedValue)
                    {
                        this.WeekUnpublished = true;
                    }
                    _weekSchedules = items.Data;
                    if (SelectedUser != null && SelectedUser.UserIdValue != _allGuid)
                    {
                        if (SelectedUser.UserIdValue == _unassignedGuid && item.User != null)
                        {
                            continue;
                        }
                        if (SelectedUser.UserIdValue == _assignedGuid && item.User == null)
                        {
                            continue;
                        }
                        if (SelectedUser.UserIdValue != _assignedGuid && SelectedUser.UserIdValue != _unassignedGuid && SelectedUser.UserIdValue != item.UserIdValue)
                        {
                            continue;
                        }
                    }

                    if (SelectedShift != null && SelectedShift.ShiftIdValue != _allGuid && SelectedShift.ShiftIdValue != item.ShiftIdValue)
                    {
                        continue;
                    }

                    if (SelectedTask != null && SelectedTask.TaskIdValue != _allGuid && SelectedTask.TaskIdValue != item.TaskIdValue)
                    {
                        continue;
                    }

                    var displayItem = new DisplayItem();
                    scheduleToDisplayItem(displayItem, item);
                    Schedules.Add(displayItem);
                }
                OnPropertyChanged("WeekUnpublished");

                return(items);
            });

            OnPropertyChanged("NoSchedules");
        }
Пример #25
0
 public override string ToString()
 {
     return(ScheduleDate.ToShortDateString());
 }
Пример #26
0
 private void ScheduleGridBox_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     selected = manager.ScheduleDatesByScheduleDateId(Convert.ToInt32(ScheduleGridBox.Rows[e.RowIndex].Cells[0].Value));
     SelectedScheduleLabel.Text = "Schedule selected: " + selected.StartDate.ToShortDateString() + "-" + selected.EndDate.ToShortDateString();
 }
Пример #27
0
        public DataGridView Schedule(DataGridView data, ScheduleDate sd)
        {
            data.Rows.Clear();
            data.Refresh();

            List <MeetingAssignment> ma = new List <MeetingAssignment>();

            if (sd == null)
            {
                return(null);
            }
            else if (manager.MeetingAssignmentsForExistingSchedule(sd.Id).Count != 0)
            {
                ma = manager.MeetingAssignmentsForExistingSchedule(sd.Id);
            }
            else
            {
                ma = manager.MeetingAssignmentsForSchedule(sd, sd.CongregationId);
            }

            ma = ma.OrderBy(o => o.Meeting.MeetingDate).ThenBy(y => y.Assignment.PositionOnSchedule).ToList();

            data.ColumnCount           = ma[0].Meeting.MeetingAssignments.Count + 2;
            data.RowHeadersVisible     = false;
            data.Columns[0].Name       = "MeetingId";
            data.Columns[0].Visible    = false;
            data.Columns[1].Name       = "MeetingDate";
            data.Columns[1].HeaderText = "Meeting Date";
            data.Columns[1].SortMode   = DataGridViewColumnSortMode.NotSortable;


            List <MeetingAssignment> test = ma[0].Meeting.MeetingAssignments.ToList();

            test = test.OrderBy(o => o.Assignment.PositionOnSchedule).ToList();
            int columnCounter     = test.Count + 1;
            int assignmentcounter = test.Count - 1;

            while (assignmentcounter >= 0)
            {
                data.Columns[columnCounter].Name       = test[assignmentcounter].Assignment.Label;
                data.Columns[columnCounter].HeaderText = data.Columns[columnCounter].Name;
                data.Columns[columnCounter].SortMode   = DataGridViewColumnSortMode.NotSortable;
                if (columnCounter == test.Count + 1)
                {
                    data.Columns[columnCounter].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                }
                columnCounter--;
                assignmentcounter--;
            }

            List <Meeting> meetings = (from meet in ma
                                       select meet.Meeting).ToList();

            meetings = meetings.Select(z => z).Distinct().ToList();

            List <UnavailableDate> cancelled = manager.UnavailableDateByCongregationId(sd.CongregationId);

            cancelled = cancelled.Where(z => z.DateUnavailable > sd.StartDate && z.DateUnavailable < sd.EndDate).ToList();
            if (cancelled.Count != 0)
            {
                foreach (UnavailableDate u in cancelled)
                {
                    Meeting nm = new Meeting();
                    nm.MeetingDate = u.DateUnavailable;
                    meetings.Add(nm);
                }
            }

            meetings = meetings.OrderBy(o => o.MeetingDate).ToList();

            int rowCounter = 0;

            foreach (Meeting meet in meetings)
            {
                data.Rows.Add();
                data.Rows[rowCounter].Cells[0].Value = meet.Id;
                data.Rows[rowCounter].Cells[1].Value = meet.MeetingDate.DayOfWeek + " " + meet.MeetingDate.ToString("MMM") + " " + meet.MeetingDate.Day;

                List <MeetingAssignment> cahi = manager.MeetingAssignmentsByMeetingId(meet.Id);
                if (cahi.Count == 0)
                {
                    rowCounter++;
                    continue;
                }

                cahi.OrderBy(o => o.Assignment.PositionOnSchedule).ToList();

                int CellCounter = 2;
                foreach (MeetingAssignment am in cahi)
                {
                    data.Rows[rowCounter].Cells[CellCounter].Value = ((am.Member.PreferredName) ?? am.Member.FirstName + " " + am.Member.LastName);
                    CellCounter++;
                }
                rowCounter++;
            }

            return(data);
        }
Пример #28
0
        public async Task 导出所有日程()
        {
            //准备数据
            string curDir  = Environment.CurrentDirectory;
            string fileUrl = Path.Combine(curDir, DateTime.Now.ToString("yyyyMMddHHmmss") + ".docx");

            var date1 = new ScheduleDate()
            {
                DateTimeStr = "2019年5月5日 星期八",
                Addresses   = new List <Address>()
            };

            var address1 = new Address()
            {
                Name       = "会场一",
                Categories = new List <Category>()
            };

            var cate1 = new Category()
            {
                Name      = "分类1",
                Schedules = new List <Schedule>()
            };

            var schedule1 = new Schedule()
            {
                Name       = "日程1",
                TimeString = "上午9:00 - 上午12:00",
                Speakers   = new List <Speaker>()
            };
            var schedule2 = new Schedule()
            {
                Name       = "日程2",
                TimeString = "下午13:00 - 下午14:00",
                Speakers   = new List <Speaker>()
            };

            var speaker1 = new Speaker()
            {
                Name     = "张三",
                Position = "总经理"
            };
            var speaker2 = new Speaker()
            {
                Name     = "李四",
                Position = "副总经理"
            };

            schedule1.Speakers.Add(speaker1);
            schedule1.Speakers.Add(speaker2);
            cate1.Schedules.Add(schedule1);
            cate1.Schedules.Add(schedule2);
            address1.Categories.Add(cate1);
            date1.Addresses.Add(address1);

            var dates = new List <ScheduleDate>()
            {
                date1, date1, date1
            };

            var tables = new List <Table>();

            //从空白生成Word
            var table = new Table()
            {
                Rows = new List <TableRow>()
            };

            foreach (var date in dates)
            {
                //会议日期行
                var rowDate = new TableRow()
                {
                    Cells = new List <TableCell>()
                };
                rowDate.Cells.Add(new TableCell()
                {
                    Color      = "lightblue",
                    Paragraphs = new List <Paragraph>()
                    {
                        new Paragraph()
                        {
                            Run = new Run()
                            {
                                Text = date.DateTimeStr
                            },
                            Alignment = Alignment.CENTER //段落居中
                        }
                    }
                });
                table.Rows.Add(rowDate);

                //会场
                foreach (var addr in date.Addresses)
                {
                    //分类
                    foreach (var cate in addr.Categories)
                    {
                        var rowCate = new TableRow()
                        {
                            Cells = new List <TableCell>()
                        };

                        //会场名称
                        rowCate.Cells.Add(new TableCell()
                        {
                            Paragraphs = new List <Paragraph> {
                                new Paragraph()
                                {
                                    Run = new Run()
                                    {
                                        Text = addr.Name,
                                    }
                                }
                            }
                        });

                        rowCate.Cells.Add(new TableCell()
                        {
                            Paragraphs = new List <Paragraph>()
                            {
                                new Paragraph()
                                {
                                    Run = new Run()
                                    {
                                        Text = cate.Name,
                                    }
                                }
                            }
                        });
                        table.Rows.Add(rowCate);

                        //日程
                        foreach (var sche in cate.Schedules)
                        {
                            var rowSche = new TableRow()
                            {
                                Cells = new List <TableCell>()
                            };

                            var scheCell = new TableCell()
                            {
                                Paragraphs = new List <Paragraph>()
                                {
                                    new Paragraph()
                                    {
                                        Run = new Run()
                                        {
                                            Text = sche.Name
                                        }
                                    },
                                    {
                                        new Paragraph()
                                        {
                                            Run = new Run()
                                            {
                                                Text = sche.TimeString
                                            }
                                        }
                                    }
                                }
                            };

                            foreach (var speaker in sche.Speakers)
                            {
                                scheCell.Paragraphs.Add(new Paragraph()
                                {
                                    Run = new Run()
                                    {
                                        Text = $"{speaker.Position}:{speaker.Name}"
                                    }
                                });
                            }

                            rowSche.Cells.Add(scheCell);

                            table.Rows.Add(rowSche);
                        }
                    }
                }
            }

            tables.Add(table);

            var word = await _wordExportService.CreateWordAsync(tables);

            File.WriteAllBytes(fileUrl, word.WordBytes);
        }
Пример #29
0
 public static ScheduleDateDTO MapFromDatabaseEntity(ScheduleDate projectScheduleDate)
 {
     return(new ScheduleDateDTO());
 }