Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ WebHandler Language="C#" Class="schedulerConnector" %>
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Services;
- using dhtmlxConnectors;
- using System.Configuration;
- using Bluesoft;
- using CMS.Helpers;
- using CMS.UIControls;
- using CMS.DataEngine;
- using CMS.Membership;
- /// <summary>
- /// Connector body
- /// </summary>
- [WebService(Namespace = "http://tempuri.org/")]
- [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
- public class schedulerConnector : dhtmlxRequestHandler
- {
- public override IdhtmlxConnector CreateConnector(HttpContext context)
- {
- var connector = new dhtmlxSchedulerConnector(
- "BluesoftCRM_CalendarEvent"
- , "CalendarEventID"
- , dhtmlxDatabaseAdapterType.SqlServer2005
- , ConfigurationManager.ConnectionStrings["CMSConnectionString"].ConnectionString
- , "CalendarEventStartDate"
- , "CalendarEventEndDate"
- , "CalendarEventText as text, CalendarEventDetails as details, CalendarEventRecType as rec_type, CalendarEventEventPid as event_pid, CalendarEventEventLength as event_length, CalendarEventUserID"
- );
- // attach handlers
- connector.BeforeProcessing += new EventHandler<DataActionProcessingEventArgs>(onBeforeProcessing);
- connector.AfterProcessing += new EventHandler<DataActionProcessingEventArgs>(onAfterProcessing);
- return connector;
- }
- // is called delete_related in PHP example
- protected void onBeforeProcessing(object sender, DataActionProcessingEventArgs e)
- {
- string type = e.DataAction.Data[Connector.DecodeField("rec_type")].ToString();
- if ((e.DataAction.ActionType == ActionType.Deleted || e.DataAction.ActionType == ActionType.Updated) && !string.IsNullOrEmpty(type))
- {
- Connector.Request.Adapter.ExecuteScalar("DELETE FROM BluesoftCRM_CalendarEvent WHERE CalendarEventEventPid='" + e.DataAction.PrimaryKeyValue.ToString() + "'");
- }
- if (e.DataAction.ActionType == ActionType.Deleted && e.DataAction.Data[Connector.DecodeField("event_pid")].ToString() != "0")
- {
- Connector.Request.Adapter.ExecuteScalar("UPDATE BluesoftCRM_CalendarEvent SET CalendarEventRecType='none' WHERE CalendarEventID='" + e.DataAction.PrimaryKeyValue.ToString() + "'");
- e.DataAction.SetCompleted();
- }
- }
- // is called insert_related in PHP example
- protected void onAfterProcessing(object sender, DataActionProcessingEventArgs e)
- {
- if (e.DataAction.ActionType == ActionType.Inserted && e.DataAction.Data[Connector.DecodeField("rec_type")].ToString() == "none")
- {
- e.DataAction.ChangeActionType(ActionType.Deleted);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment