Как я могу заполнить данные в Syncfusion в планировщике Angular6 из WebApi? - PullRequest
0 голосов
/ 13 апреля 2019

Я использую планировщик для настройки встреч в моем приложении Angular6.Он отлично работает со статическими данными, но не связывает никакие данные с вызовом Web Api?

Он работает с этим удаленным Api, предоставленным ими https://js.syncfusion.com/demos/ejservices/api/Schedule/LoadData, и со статическими данными в component.ts, но не с моим локальнымВеб-API

Мой код Component.ts выглядит следующим образом: -

@Component({
  selector: 'app-scheduler',
  templateUrl: './scheduler.component.html',
  styleUrls: ['./scheduler.component.css'],
  providers: [DayService, WeekService, MonthService],
})
export class SchedulerComponent implements OnInit {
  scheduler: any = {
    _id: "",
    id: "",
    Subject: "",
    StartTime: "",
    EndTime: "",
    StartTimezone: "",
    EndTimezone: "",
    Location: "",
    Description: "",
    IsAllDay: false,
    Recurrence: "",
    RecurrenceRule: "",
    Frequency: "",
    Interval: "",
    Count: "",
    IsReadonly: false,
    IsBlock: false,
    Untill: "",
    ByDay: "",
    BYMonthDay: "",
    BYMonth: "",
    BYSetPOS: ""
  }
  //public dataManager: any;
  public query;
  public ajax: any;

  actionModel: any;
  ds: any;
  public currentView: View = 'Month';
  public selectedDate: Date = new Date();

  private dataManager: DataManager = new DataManager({
    url: 'https://localhost:44369/api/Scheduler/getcalls',

    adaptor: new WebApiAdaptor,
    crossDomain: true
  });

  public eventSettings: EventSettingsModel = { dataSource: this.dataManager };



  constructor(
    protected service: SchedulerService, protected callService: CallService, protected meetingService: MeetingService,
    protected taskService: TaskService,  protected commentService: CommentService
  )
  {
    this.UpdateScheduler();
  }

  ngOnInit() {
    this.ds = [];
  }
  async UpdateScheduler() {
    debugger
    await this.service.getSchedulerData<any>()
      .subscribe(data => {
        data.map((x) => {
          this.ds.push({
            Id: x.id,
            Subject: x.subject,
            StartTime: new Date(x.startTime).toISOString().slice(0, -1),
            EndTime: new Date(x.endTime).toISOString().slice(0, -1),
            IsAllDay: x.allDay,
            Recurrence: true,
            RecurrenceID: x.Id,
            RecurrenceRule: 'FREQ=DAILY;INTERVAL=1;COUNT=5',
            Location: x.location,
            Description: x.description,
            StartTimezone: x.startTimezone,
            EndTimezone: x.EndTimezone,
          })
          console.log("ds1", this.ds);
          this.eventSettings.dataSource = this.ds;
          console.log("finalDataSource",this.eventSettings.dataSource);
        });
      }, error => {
        console.log("error1", error);
      }, () => { });
    //this.service.getSchedulerData();
   // this.eventSettings.dataSource = this.ds;
  }



  fnSchedulerModel(): any {
    return {
      _id: "",
      Subject: "",
      Location: "",
      ResponsiblePerson: "",
      Priority: "",
      Types: "",
      CreatedBy: "",
      UpdatedBy: "",
      CreatedDate: "",
      UpdatedDate: "",
      EventStartDate: "",
      EventEndDate: "",
      ReminderNotification: "",
      Completed: false,
      Description: "",
      RepeatTask: 0,
      Interval: "",
      RepeatAfter: "",
      Untill: "",
      UntillDate: "",
      UntillCompile: "",
      RemindUsing: "",
      RemindTo: "",
      RepeatEvery: "",
      RepeatOnWeekDay: "",
      RepeatOnDay: "",
      WillRepeat: "",
      WillRepeatWeekDay: "",
      RepeatOnMonth: ""
    }
  }

}

API, который я вызываю: -

WebApiCode : -

[HttpGet("GetCalls")]
        public List<DefaultSchedule> GetCalls(String CurrentDate, String CurrentView, String CurrentAction)
        {
            IEnumerable<Calls> model = _callRepository.GetAllCalls();
            List<DefaultSchedule> schedulerModelList = new List<DefaultSchedule>();
            int Id = 0;
            foreach (var call in model.ToList())
            {

                DefaultSchedule schedulerModel = new DefaultSchedule();
                schedulerModel.Id = 100;
                schedulerModel.AllDay = call.IsAllDay;
                schedulerModel.Description = call.Description;
                schedulerModel.StartTime = DateTime.Today;
                schedulerModel.StartTimeZone = call.StartTimeZone;
                schedulerModel.EndTime = DateTime.Today.AddDays(1);
                schedulerModel.Priority = true;
                schedulerModel.Subject = "CJECL";
                schedulerModel.Owner = 1;
                schedulerModelList.Add(schedulerModel);
                break;
            }
            return schedulerModelList;

        }

Прекрасно работает со статическими данными и с этим веб-интерфейсом Api https://js.syncfusion.com/demos/ejservices/api/Schedule/LoadData когда я предоставляю данные в самом компоненте, но когда мне нужно связать данные из WebApi, это не работает.Пожалуйста, помогите.

Мое требование - привязать удаленные данные к планировщику.Демо-версия представлена ​​ниже, пожалуйста, посмотрите: -

https://help.syncfusion.com/angular/schedule/data-binding#binding-remote-data-service

1 Ответ

0 голосов
/ 06 мая 2019

Привет от Syncfusion.

В расписании пакетная операция не будет работать корректно с адаптером WebApi, и для этого мы зарегистрировали нижеприведенный запрос, который будет реализован в любом из наших будущих выпусков. https://www.syncfusion.com/feedback/2373/batch-handler-support-for-asp-net-core-while-using-webapi-adaptor

С уважением, Karthi

...