首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从Angular6调度器中填充WebApi中的同步数据?

如何从Angular6调度器中填充WebApi中的同步数据?
EN

Stack Overflow用户
提问于 2019-04-13 10:11:13
回答 1查看 322关注 0票数 0

我正在使用调度程序来设置我的Angular6应用程序中的约会。它可以很好地处理静态数据,但不使用Web调用绑定任何数据?

它使用由它们提供的远程Api ( https://js.syncfusion.com/demos/ejservices/api/Schedule/LoadData )和component.ts中的静态数据(而不是本地web )。

我的Component.ts代码如下:

代码语言:javascript
复制
@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:-

代码语言:javascript
复制
[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;

        }

,它可以很好地处理静态数据和这个WebApi https://js.syncfusion.com/demos/ejservices/api/Schedule/LoadData,当我在组件本身中提供数据时,但是当我不得不从WebApi绑定数据时,它就不能工作了。请帮帮忙。

我的要求是将远程数据绑定到调度程序。下面提供了演示,请看一下:-

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

EN

回答 1

Stack Overflow用户

发布于 2019-05-06 06:23:55

在计划中,批处理操作将不能正确地与WebApi适配器一起工作,同样,我们已经记录了下面的特性请求,它将在我们即将发布的任何一个版本中实现。https://www.syncfusion.com/feedback/2373/batch-handler-support-for-asp-net-core-while-using-webapi-adaptor

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55664321

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档