2015-01-31 5 views
0

반복 일정과 관련된 DHTMLX scheduler 문제가 있습니다.DHTMLX 스케줄러 반복 일정

http://blog.scheduler-net.com/post/recurring-events-calendar-view-asp-net.aspx에있는 설명서를 따르려고했습니다. 그러나 작동시키지 못하는 것 같습니다.

아무런 문제없이 기본 스케줄러를 만들 수 있습니다. 지금 내가 가진 문제는 생성 된 모든 이벤트가 DB에 저장되지 않는다는 것입니다. 이것은 내가 지금까지 가지고있는 것이다.

모델 :

[Key] 
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] 
[DHXJson(Alias = "id")] 
public int Id { get; set; } 

[DHXJson(Alias = "text")] 
public string Description { get; set; } 

[DHXJson(Alias = "start_date")] 
public DateTime StartDate { get; set; } 

[DHXJson(Alias = "end_date")] 
public DateTime EndDate { get; set; } 

[DHXJson(Alias="event_length")] 
public int event_length { get; set; } 

[DHXJson(Alias = "rec_type")] 
public string rec_type { get; set; } 

[DHXJson(Alias = "event_pid")] 
public int event_pid { get; set; } 

컨트롤러 :

public ActionResult Save(int? id, FormCollection actionValues) 
{ 
    var action = new DataAction(actionValues); 
    ApplicationDbContext data = new ApplicationDbContext(); 
    try 
    { 
     var changedEvent = (Appointment)DHXEventsHelper.Bind(typeof(Appointment), actionValues); 
     //operations with recurring events require some additional handling 
     bool isFinished = deleteRelated(action, changedEvent, data); 
     if (!isFinished) 
     { 
      switch (action.Type) 
      { 

       case DataActionTypes.Insert: 
        data.Appointment.Add(changedEvent); 
        if (changedEvent.rec_type == "none")//delete one event from the serie 
         action.Type = DataActionTypes.Delete; 
        break; 
       case DataActionTypes.Delete: 
        changedEvent = data.Appointment.SingleOrDefault(ev => ev.Id == action.SourceId); 
        data.Appointment.Remove(changedEvent); 
        break; 
       default:// "update" 
        var eventToUpdate = data.Appointment.SingleOrDefault(ev => ev.Id == action.SourceId); 
        DHXEventsHelper.Update(eventToUpdate, changedEvent, new List<string>() { "id" }); 
        break; 
      } 
     } 
     data.SaveChanges(); 
     action.TargetId = changedEvent.Id; 
    } 
    catch 
    { 
     action.Type = DataActionTypes.Error; 
    } 

    return (new AjaxSaveResponse(action)); 
} 
protected bool deleteRelated(DataAction action, Appointment changedEvent, ApplicationDbContext context) 
{ 
    bool finished = false; 
    if ((action.Type == DataActionTypes.Delete || action.Type == DataActionTypes.Update) && !string.IsNullOrEmpty(changedEvent.rec_type)) 
    { 
     // context.Recurrings.DeleteAllOnSubmit(from ev in context.Recurrings where ev.event_pid == changedEvent.id select ev); 
    } 
    if (action.Type == DataActionTypes.Delete && (changedEvent.event_pid != 0 && changedEvent.event_pid != null)) 
    { 
    // Recurring changed = (from ev in context.Recurrings where ev.id == action.TargetId select ev).Single(); 
    // changed.rec_type = "none"; 
     finished = true; 
    } 
    return finished; 
} 

어떤 도움이나 아이디어?

답변

0

변경 저장 방법 반환 값을 "ContentResult"로 변경해보십시오. 또한 ApplicationDbContext를 살펴보고 색인이로드 될 때 해당 테이블에서 하드 코드 된 db 값을 가져올 수 있는지 확인하십시오. 여기에 제 사본이 있습니다. 내가 linq 클래스를 모델/EF 만들고 내 컨텍스트를 기반으로 사용할 때까지 동일한 문제가있었습니다. EF를 사용하고 싶지 않기 때문에 "light-weight"인터페이스를 만들 때 같은 문제가 발생했습니다.

public ContentResult Save(int? id, FormCollection actionValues) 
    { 
     var action = new DataAction(actionValues); 
     var context = new SchedulerDataContext(); 
     Int64 source_id = Int64.Parse(actionValues["id"]); 
     try 
     { 
      var changedDelEvent = (Delivery)DHXEventsHelper.Bind(typeof(Delivery), actionValues); 
      var changedRecEvent = (Recurring)DHXEventsHelper.Bind(typeof(Recurring), actionValues); 
      //operations with recurring events require some additional handling 
      bool isFinished = deleteRelated(action, changedRecEvent, context); 
      if (!isFinished) 
      { 
       switch (action.Type) 
       { 
        case DataActionTypes.Insert: 
         context.Recurrings.InsertOnSubmit(changedRecEvent); 
         context.SubmitChanges(); 
         break; 
        case DataActionTypes.Delete: 
         changedRecEvent = context.Recurrings.SingleOrDefault(d => d.id == source_id); 
         if (changedRecEvent != null) 
         { 
          context.Recurrings.DeleteOnSubmit(changedRecEvent); 
         } 
         context.SubmitChanges(); 
         break; 
        default:// "update"           
         var eventToUpdate = context.Deliveries.SingleOrDefault(d => d.DeliveryID == source_id); 
         DHXEventsHelper.Update(eventToUpdate, changedRecEvent, new List<string> { "id" }); 
         if (eventToUpdate != null && eventToUpdate.RouteID != changedRecEvent.id) 
         { 
          var routeToUpdate = context.Routes.SingleOrDefault(d => d.RouteID == changedRecEvent.id); 
          eventToUpdate.Route = routeToUpdate; 
         } 
         context.SubmitChanges(); 
         break; 
       } 
       action.TargetId = changedRecEvent.id; 
      } 
     } 
     catch 
     { 
      action.Type = DataActionTypes.Error; 
     } 

     return (new AjaxSaveResponse(action));   
    } 
+0

당신은 내가 반복적으로 작동하도록 노력하고 있음을 알게 될 것입니다. 그래서 나는 "변경됨"이 두 가지이지만, 반복되는 이벤트에 대해서는 무차별 적입니다. – user1040975

0

되풀이 확장 (dhtmlxscheduler_recurring.js)는 엔터티 클래스 속성 (매우 실망)에서 사용중인 DHXJson 별칭 주석을 인식하지 못합니다. 따라서 기본 스케줄러 API가 DHXJson 별칭 주석을 사용하여 사용자 정의 이름 지정 옵션을 제공하더라도 dhtmlxscheduler_recurring.js에서 기대하는 방식과 정확히 일치해야합니다.

관련 문제