BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
Goodday, I just made sure that RecurrenceId and RecurrenceExDate are saved into the Db but still not working. Find below my controller function for Add, remove and Crud.
Add
public JsonResult AddScheduledRoutes(int companyid, ScheduleDataDto value)
{
var route = _routeService.GetRoute(value.RouteId);
var company = _companyService.Get(companyid);
var sched = value.ToScheduleData();
sched.Route = route;
sched.Company = company;
sched.RouteName = route.Name;
sched.CompanyName = company.Name;
var resultsched =_routeService.AddScheduledRoute(sched);
var finalresult = resultsched.ToDto();
if (!resultsched.Recurrence)
{
_routeService.AddScheduleRouteDetails(resultsched);
}
if (resultsched.Recurrence && RecurrenceHelper.IsRecurEdit(resultsched.RecurrenceRule))
{
_routeService.AddScheduleRouteDetails(resultsched, true);
}
if (resultsched.Recurrence && !RecurrenceHelper.IsRecurEdit(resultsched.RecurrenceRule))
{
List<DateTime> dates = new List<DateTime>();
var startdate = new DateTime(resultsched.EndTime.Year, resultsched.EndTime.Month, resultsched.EndTime.Day);
dates = RecurrenceHelper.GetRecurrenceDateTimeCollection(resultsched.RecurrenceRule, startdate).ToList();
_routeService.AddScheduleRouteDetails(resultsched, dates);
}
return GetCompanyScheduledRoutes(companyid, sched.Route.Id);
}
Update
public JsonResult UpdateCompanyScheduledRoutes(int companyid, ScheduleDataDto value)
{
var oldsched = _routeService.GetScheduledRoute(Convert.ToInt32(value.Id));
if (oldsched != null)
{
DateTime startTime = Convert.ToDateTime(value.StartTime);
DateTime endTime = Convert.ToDateTime(value.EndTime);
oldsched.StartTime = startTime;
oldsched.EndTime = endTime;
oldsched.Subject = value.Subject;
oldsched.StartTimeZone = value.StartTimeZone;
oldsched.EndTimeZone = value.EndTimeZone;
oldsched.Description = value.Description;
oldsched.Recurrence = Convert.ToBoolean(value.Recurrence);
oldsched.AllDay = value.AllDay;
oldsched.RecurrenceRule = value.RecurrenceRule;
oldsched.RecurrenceExDate = value.RecurrenceExDate;
_routeService.UpdateSchedule(oldsched);
_routeService.UpdateScheduleDetail(oldsched);
}
return GetCompanyScheduledRoutes(companyid, Convert.ToInt32(value.RouteId));
}
CRUD
public JsonResult Crud(EditParams param)
{
var companyid = 0;
if (param.action == "insert" || (param.action == "batch" && param.added != null)) // this block of code will execute while inserting the appointments
{
foreach (var apps in param.added)
{
var value = param.action == "insert" ? param.value : apps;
var route = _routeService.GetRoute(value.RouteId);
var company = route.Company;
companyid = company.Id;
var sched = value.ToScheduleData();
sched.Route = route;
sched.Company = company;
sched.RouteName = route.Name;
sched.CompanyName = company.Name;
var resultsched =_routeService.AddScheduledRoute(sched);
if (resultsched.Recurrence && !RecurrenceHelper.IsRecurEdit(resultsched.RecurrenceRule))
{
List<DateTime> dates = new List<DateTime>();
var startdate = new DateTime(resultsched.EndTime.Year, resultsched.EndTime.Month, resultsched.EndTime.Day);
dates = RecurrenceHelper.GetRecurrenceDateTimeCollection(resultsched.RecurrenceRule, startdate).ToList();
_routeService.AddScheduleRouteDetails(resultsched, dates);
}
if (resultsched.Recurrence && RecurrenceHelper.IsRecurEdit(resultsched.RecurrenceRule))
{
_routeService.AddScheduleRouteDetails(resultsched, true);
// _routeService.AddScheduleRouteDetails(resultsched);
}
}
}
if ((param.action == "batch" && param.changed != null) || param.action == "update") // this block of code will execute while updating the appointment
{
var value = param.action == "update" ? param.value : param.changed[0];
var oldsched = _routeService.GetScheduledRoute(Convert.ToInt32(value.Id)) ;
if (oldsched != null)
{
DateTime startTime = Convert.ToDateTime(value.StartTime);
DateTime endTime = Convert.ToDateTime(value.EndTime);
oldsched.StartTime = startTime;
oldsched.EndTime = endTime;
oldsched.Subject = value.Subject;
oldsched.StartTimeZone = value.StartTimeZone;
oldsched.EndTimeZone = value.EndTimeZone;
oldsched.Description = value.Description;
oldsched.Recurrence = Convert.ToBoolean(value.Recurrence);
oldsched.AllDay = value.AllDay;
oldsched.RecurrenceRule = value.RecurrenceRule;
oldsched.RecurrenceExDate = value.RecurrenceExDate;
}
_routeService.UpdateSchedule(oldsched);
_routeService.UpdateScheduleDetail(oldsched, true);
}
ScheduleDataSearchQuery search = new ScheduleDataSearchQuery { CompanyId = companyid };
var result = _routeService.GetAllScheduledRoutes(search).Entity;
return Json(result.ToDtoWithoutList(), JsonRequestBehavior.AllowGet);
}
Have not added the remove block for the Crud Function. Want to sort this out first.
I decided to Check the clear my db and recreate from scratch and use chrome inspector to check the schedule values. They are the same with what is in my Db, don't understand why whenever I want to edit a detached recurrence appointment, it sends added params and not update params. Find below another Json object from my Db and also the image of google inspector. I check the _currentAppointmentData property on the Schedule control and the contents are the same with what is in my Db.
My Db Data
[{
"Subject": "5:00 PM",
"Description": null,
"StartTime": "2017-07-31T16:15:00",
"EndTime": "2017-07-31T17:00:00",
"StartTimeZone": "UTC +01:00",
"EndTimeZone": "UTC +01:00",
"Categorize": null,
"AllDay": false,
"Recurrence": false,
"RecurrenceRule": null,
"RecurrenceExDate": null,
"Territory": "EDO",
"RouteId": 31,
"CompanyId": 1,
"Id": 1,
"TerritoryId": 2,
"TerritoryRoutes": "EDO-BENIN(UGBOWO) -> LAGOS-Lagos(Yaba)",
"CompanyName": "EDEGBE MOTORS NIGERIA",
"RoomId": 2,
"OwnerId": 31,
"RecurrenceList": null,
"FullRecurrenceList": null,
"RecurrenceId": 0
}, {
"Subject": "11:00 AM",
"Description": null,
"StartTime": "2017-08-02T10:15:00",
"EndTime": "2017-08-02T11:00:00",
"StartTimeZone": "UTC +01:00",
"EndTimeZone": "UTC +01:00",
"Categorize": null,
"AllDay": false,
"Recurrence": true,
"RecurrenceRule": "FREQ=DAILY;INTERVAL=1;COUNT=8;EXDATE=8/3/2017,8/3/2017",
"RecurrenceExDate": "8/3/2017",
"Territory": "EDO",
"RouteId": 31,
"CompanyId": 1,
"Id": 2,
"TerritoryId": 2,
"TerritoryRoutes": "EDO-BENIN(UGBOWO) -> LAGOS-Lagos(Yaba)",
"CompanyName": "EDEGBE MOTORS NIGERIA",
"RoomId": 2,
"OwnerId": 31,
"RecurrenceList": null,
"FullRecurrenceList": null,
"RecurrenceId": 2
}, {
"Subject": "10:30 AM",
"Description": null,
"StartTime": "2017-08-03T09:45:00",
"EndTime": "2017-08-03T10:30:00",
"StartTimeZone": "UTC +01:00",
"EndTimeZone": "UTC +01:00",
"Categorize": null,
"AllDay": false,
"Recurrence": true,
"RecurrenceRule": "FREQ=DAILY;INTERVAL=1;COUNT=8;EXDATE=8/3/2017;RECUREDITID=2",
"RecurrenceExDate": null,
"Territory": "EDO",
"RouteId": 31,
"CompanyId": 1,
"Id": 3,
"TerritoryId": 2,
"TerritoryRoutes": "EDO-BENIN(UGBOWO) -> LAGOS-Lagos(Yaba)",
"CompanyName": "EDEGBE MOTORS NIGERIA",
"RoomId": 2,
"OwnerId": 31,
"RecurrenceList": null,
"FullRecurrenceList": null,
"RecurrenceId": 2
}
]
Good morning,
I am using a Custom appointment window open, I notice that
if I disable that and use the default appointment window open, everything works
fine but when I use my custom window open, it doesn't work. Find below my
codes.
I couldn't paste my codes, seems they are more than required word limit.
Find attached is a zipped file that contains 2 files Appointment and Save.js (a js file that I just pasted my onAppointmentWindowOpen and Save functions) and Schedule.js that has my full js functions. I believe the error should be in my onAppointmentWindowOpen or Save Function.
@(Html.EJ().Schedule("routeSchedule")
.Width("100%")
.Height("725px")
.CurrentDate(schedulableDay)
.HighlightBusinessHours(true)
.ShowNextPrevMonth(true)
.WorkHours(x =>
x.Highlight(true).Start(Model.Setting.BusinessStartHour).End(Model.Setting.BusinessEndHour))
.StartHour(Model.Setting.ScheduleStartHour)
.EndHour(Model.Setting.ScheduleEndHour)
.AgendaViewSettings(i
=> i.DaysInAgenda(14))
.TimeMode(timemode)
.Resources(res =>
{ res.Field("TerritoryId").Title("Territory").Name("Territories").AllowMultiple(true).ResourceSettings(fld => fld.Datasource(initialTerrittory)
.Text("Text").Id("Id")).Add();
res.Field("RouteId").Title("Route").Name("Routes").AllowMultiple(true).ResourceSettings(flds =>
flds.Datasource(initialTerritoryRoutes)
.Text("Text").Id("Id").GroupId("GroupId").Color("Color")).Add();
})
.Group(gr =>
gr.Resources(Group))
.ShowLocationField(true)
.CategorizeSettings(cat =>
cat.Enable(true))
.ShowAllDayRow(false)
.ShowCurrentTimeIndicator(true)
.Views(view)
.CurrentView(CurrentView.Month)
.WorkWeek(workWeek)
.AppointmentSettings(fields => fields.Datasource(ds =>
ds.URL(@Url.Action("GetCompanyScheduledRoutes", "Route", new {
companyid = Model.Id, routeid = firstroute, territoryid = firstterritory
})).InsertURL(Url.Action("AddScheduledRoutes", "Route", new {
companyid = Model.Id }))
.BatchURL(@Url.Action("Crud", "Route")).RemoveURL(@Url.Action("RemoveCompanyScheduledRoutes", "Route", new {
companyid = Model.Id }))
.UpdateURL(@Url.Action("UpdateCompanyScheduledRoutes", "Route", new {
companyid = Model.Id })).Adaptor(AdaptorType.UrlAdaptor))
.Id("Id")
.Subject("Subject")
.StartTime("StartTime")
.EndTime("EndTime")
.StartTimeZone("StartTimeZone")
.EndTimeZone("EndTimeZone")
.Description("Comments")
.AllDay("AllDay")
.Recurrence("Recurrence")
.RecurrenceRule("RecurrenceRule")
.RecurrenceId("RecurrenceId")
.RecurrenceExDate("RecurrenceExDate")
.Location("Location")
.ResourceFields("TerritoryId, RouteId"))
.ScheduleClientSideEvents(eve => eve.Navigation("OnNavigation").QueryCellInfo("OnQueryCellInfo").CellClick("OnCellClick").AppointmentWindowOpen("onAppointmentWindowOpen").Create("onCreate").ActionBegin("onBegin").DragStop("onAction").ResizeStop("onAction").ActionComplete("onComplete").CellHover("onCellHover").DragStart("onStart")
.ResizeStart("onStart").BeforeAppointmentCreate("OnBeforeAppointmentCreate").BeforeAppointmentChange("OnBeforeAppointmentChange")))
@Html.EJ().Dialog("customWindow").Width("600").Height("auto").ShowOnInit(false).EnableModal(true).Title("Create Route Schedule").EnableResize(false).AllowKeyboardNavigation(false).ClientSideEvents(eve => eve.Close("clearFields")).ContentTemplate(
@<div>
<div id="appWindow" class="e-windowmargin">
<form id="custom">
<div class="container-fluid">
<div class="row epadding" style="display: none;">
<div class="col-md-3">Id</div>
<div class="col-md-9">
<input id="customId" type="text" name="Id" />
</div>
</div>
<div class="row epadding">
<div class="col-md-3">Subject</div>
<div class="col-md-9">
<input id="subject" type="text" value="" name="Subject" onfocus="temp()" style="width: 100%" readonly="readonly" />
</div>
</div>
<div class="row epadding">
<div class="col-md-3">Passenger ETA</div>
<div class="col-md-4">
@Html.EJ().DateTimePicker("StartTime").Width("150px").MinDateTime(minDateTime).MaxDateTime(maxDateTime).Interval(Model.Setting.ScheduleTimeInterval).TimeDisplayFormat(timedisplayformat).Enabled(false)
</div>
<div class="col-md-5">
@Html.EJ().CheckBox("enableStartTime").ClientSideEvents(s
=> s.Change("changeState")).Text("Enable Passenger ETA")
</div>
</div>
<div class="row epadding">
<div class="col-md-3">Departure Time</div>
<div class="col-md-4">
@(Html.EJ().DateTimePicker("EndTime").Width("150px").MinDateTime(minDateTime).MaxDateTime(maxDateTime).Enabled(true)
.Interval(Model.Setting.ScheduleTimeInterval)
.ClientSideEvents(evt => evt.Change("changeDepartureTime"))
.TimeDisplayFormat(timedisplayformat))
</div>
<div class="col-md-2">
@Html.EJ().CheckBox("recurrence").Name("Recurrence").Checked(false).Enabled(true).ClientSideEvents(eve =>
eve.Change("recurCheck")).Text("Repeat")
</div>
<div class="col-md-2 e-recuredit" id="editApp" style="display: block;"><a class="recuredit" rel='nofollow' href="#" style="float: left; padding-left: 10px;">Edit</a></div>
</div>
<div class="row epadding">
<div class="col-md-3">Territory</div>
<div class="col-md-9">
<input type="text" id="Territory" style="width: 100%" />
</div>
</div>
<div class="row epadding">
<div class="col-md-3 ">Route</div>
<div class="col-md-9">
<input type="text" id="TerritoryRoutes" style="width: 100%" />
</div>
</div>
<div class="row epadding">
<div class="col-md-3">Comments</div>
<div class="col-md-9">
<textarea id="customdescription" name="Description" rows="3" cols="50" style="width: 100%; resize: vertical"></textarea>
</div>
</div>
</div>
</form>
<br />
<div class="pull-right" style="margin-bottom: 20px; padding-right: 20px">
<button type="submit" id="appsubmit">Submit</button>
<button type="submit" id="appcancel">Cancel</button>
</div>
</div>
<div id="recWindow" style="display: none">
@Html.EJ().RecurrenceEditor("recurrenceEditor").SelectedRecurrenceType(0).RecurrenceEditorClientSideEvents(evt
=> evt.Change("onRecurChange")).Frequencies(new List<string> { "daily", "weekly", "monthly", "yearly", "everyweekday" })
<br />
<div>
<button type="submit" id="reccancel">Cancel</button>
<button type="submit" id="recsubmit">Submit</button>
</div>
</div>
</div>)
On deeper investigation into the difference between the object sent to the Default Appointment window and that sent to the custom Appointment window. I noticed no difference in the object sent but where the difference was inside the Schedule saveAppointment method itself. I added some code to the actionComplete event
function onComplete(args) {
if (args.requestType === "dateNavigate" || args.requestType === "viewNavigate") {
onCreate();
}
if (args.requestType === "appointmentEdit") {
console.log(args.requestType);
console.log(args);
}
}
So I got out the object actually inside the saveAppointment() method of the Schedule Control and saw the differences as shown below.
1) Sample of Object passed with Id = 3 which is the Id of the Appointment. This is the Object created before saving and still remain the same after saving.
2) But the some properties of the Object changed while inside the Schedule Control saveAppointment() method. I noticed that the Id changed to 13 which is
the AppTaskId. More so, the currentAction is shown as "editOccurence" while that of the default appointment window showed "edit" The recurrenceRule seems to repeat the date also, though I don't think that has anything to do with the issue.
3) The Default Window gave the correct properties and nothing changed from the intended object. The Id remains the same and the recurrence rule seems Ok.
What could have been making the properties to change in the custom appointment window as shown above.
After digging deeper, I noticed that the recurrence value is changing from true to integer value of 1 in the save function. when populating the object, the value is true but thereafter the value somehow changes to integer 1. I checked it out for new Creation of Appointment, it value of recurrence false, stays the same. It doesn't change to any integer value.For Creation of New Appointment, the recurrence remained false, didn't change to any integer value. So what could causing this.
For Creation of New Appointed, the value of false for recurrence property remains the same, it doesn't change to any integer value.
By commenting out the schObj.saveAppointment(obj) and trying to get the actual properties of the object passed into the saveAppointment function, I realized that it was the saveAppointment function that is changing the values of the object since it is a reference object, the changed value is passed back.
Good evening,
Here is a link to a running sample.
http://jsplayground.syncfusion.com/dvq303oh
The interesting thing is that it is running perfectly well in the playground, though am using local data in the sample and am using MVC controller on my system and my datamanager is like below on my system.
var dataManager = ej.DataManager({
url: "/Admin/Apps/SyncBus/Route/getCompanyscheduledroutes?companyid=" + companyid + "&routeid=" + currentRouteList[0].Id, // This will trigger to bind the appointments data to schedule control
batchUrl: "/Admin/Apps/SyncBus/Route/Crud", // This will trigger while saving the appointment through detail window
insertUrl: "/Admin/Apps/SyncBus/Route/AddScheduledRoutes?companyid=" + companyid, // This will trigger while saving the appointment through quick window
updateUrl: "/Admin/Apps/SyncBus/Route/UpdateCompanyScheduledRoutes?companyid=" + companyid, //This will trigger while saving the resize or drag and drop the appointment
removeUrl: "/Admin/Apps/SyncBus/Route/RemoveCompanyScheduledRoutes?companyid=" + companyid, // This will trigger to delete the single appointment
adaptor: new ej.UrlAdaptor()
});
I don't understand at all, the data posted to my server contains both add (new Id) and change (Id = 2) parameters instead of just change parameter for (Id = 3)I still wonder why the recurrence changes to Integer whenever it is true, even in my sample on playground and also on my computer system, it always send the Id of the main appointment series which is 2 instead of the Id 3 of the intended appointment.