254 lines
9.5 KiB
C#
254 lines
9.5 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Configuration;
|
|
using System.Web;
|
|
using System.Web.Security;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.Web.UI.WebControls.WebParts;
|
|
using System.Web.UI.HtmlControls;
|
|
using Infragistics.WebUI.Data;
|
|
using Infragistics.WebUI.WebSchedule;
|
|
using Infragistics.WebUI.Shared;
|
|
using GZTW.AyaNova.BLL;
|
|
using System.Drawing;
|
|
using System.Collections;
|
|
|
|
/// <summary>
|
|
/// Summary description for AyaScheduleProvider
|
|
/// </summary>
|
|
public class AyaScheduleProvider : WebScheduleDataProviderBase, IDataFetch, IDataUpdate
|
|
{
|
|
public AyaScheduleProvider()
|
|
{
|
|
|
|
}
|
|
|
|
private Guid _activeUserID = Guid.Empty;
|
|
public Guid ActiveUserID
|
|
{
|
|
get
|
|
{
|
|
return _activeUserID;
|
|
}
|
|
set
|
|
{
|
|
_activeUserID = value;
|
|
}
|
|
}
|
|
|
|
|
|
public void Fetch(DataContext context)
|
|
{
|
|
if(context is FetchActivitiesContext)
|
|
{
|
|
FetchActivities((FetchActivitiesContext)context);
|
|
}
|
|
//if (context is FetchResourcesContext)
|
|
//{
|
|
|
|
// FetchResourcesContext r = (FetchResourcesContext)context;
|
|
// Resource rs = new Resource();
|
|
// r.Resources.Clear();
|
|
// rs.Key = "1";
|
|
// rs.Name = "1";
|
|
// ((IList)r.Resources).Add(rs);
|
|
//}
|
|
}
|
|
#region IDataFetch Members
|
|
private void FetchActivities(FetchActivitiesContext context)
|
|
{
|
|
|
|
context.Activities.Clear();
|
|
|
|
//Case 835 commented out
|
|
//User user = null;
|
|
//if (ActiveUserID != Guid.Empty)
|
|
// user = User.GetItem(ActiveUserID);
|
|
|
|
//Case 835
|
|
UserListScheduleable uls = UserListScheduleable.GetList();
|
|
|
|
AppointmentList apl = AppointmentList.GetList(context.FrameInterval.StartDate.Value, context.FrameInterval.EndDate.Value, ActiveUserID);
|
|
foreach (AppointmentList.AppointmentListInfo i in apl)
|
|
{
|
|
switch (i.SourceObjectType)
|
|
{
|
|
case RootObjectTypes.WorkorderItemScheduledUser:
|
|
{
|
|
#region populate woitems
|
|
if (ActiveUserID == i.AppliesToObjectID)
|
|
{
|
|
// create a new appointment with a reference to the ScheduleInfo object that requested the fetch
|
|
Appointment a = new Appointment(this.WebScheduleInfo);
|
|
|
|
//Further update: currently just going to open workorder form, let user
|
|
//find the scheduled item, todo is to modify workorderedit to accept
|
|
//further parameters on the url for the workorderitem, subobject or whatever
|
|
a.Key = "WO," + i.WorkorderID.ToString()+","+i.WorkorderItemID+","+i.SourceObjectID;
|
|
a.Subject = i.Subject;
|
|
a.StartDateTime = new SmartDate(i.StartDateTime);
|
|
a.EndDateTime = new SmartDate(i.EndDateTime);
|
|
|
|
// a.ResourceKey = "1";
|
|
|
|
|
|
|
|
if (i.ShowPriorityFlag)
|
|
{
|
|
a.Style.BorderStyle = BorderStyle.Solid;
|
|
a.Style.BorderColor = Color.FromArgb(i.PriorityARGB);
|
|
a.Style.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(2);
|
|
}
|
|
|
|
|
|
//Workorder status colors
|
|
//if backcolor==0 that means no color was set so
|
|
//leave the appointment to it's natural default colors which are transparent
|
|
//background with black text
|
|
if (i.BackColorARGB != 0)
|
|
{
|
|
a.Style.BackColor = Color.FromArgb(i.BackColorARGB);
|
|
a.Style.ForeColor = Util.InvertColor(a.Style.BackColor);
|
|
|
|
|
|
|
|
}
|
|
|
|
// add appointment to the activities list in the context
|
|
((IList)context.Activities).Add(a);
|
|
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
break;
|
|
case RootObjectTypes.ScheduleMarker:
|
|
{
|
|
|
|
//Don't process for unassigned user
|
|
if (ActiveUserID == Guid.Empty) break;
|
|
|
|
//Could be a bunch by region , global , dispatchzone, schedusergroup
|
|
//or could be a single by one user ID
|
|
switch (i.AppliesToObjectType)
|
|
{
|
|
case RootObjectTypes.User:
|
|
{
|
|
if(i.AppliesToObjectID==ActiveUserID)
|
|
CreateScheduleMarker(context, i);
|
|
|
|
}
|
|
break;
|
|
case RootObjectTypes.Region:
|
|
{
|
|
//Case 835
|
|
if(uls[ActiveUserID].RegionID==i.AppliesToObjectID)
|
|
//if (user.RegionID == i.AppliesToObjectID)
|
|
{
|
|
CreateScheduleMarker(context, i);
|
|
|
|
}
|
|
|
|
}
|
|
break;
|
|
case RootObjectTypes.DispatchZone:
|
|
{
|
|
//Case 835
|
|
if (uls[ActiveUserID].DispatchZoneID == i.AppliesToObjectID)
|
|
//if (user.DispatchZoneID == i.AppliesToObjectID)
|
|
{
|
|
CreateScheduleMarker(context, i);
|
|
|
|
}
|
|
}
|
|
break;
|
|
case RootObjectTypes.ScheduleableUserGroup:
|
|
{
|
|
|
|
ScheduleableUserGroupUsersList ScheduleMarkerGroup = ScheduleableUserGroupUsersList.GetList(i.AppliesToObjectID);
|
|
if (ScheduleMarkerGroup.Contains(ActiveUserID))//Case 835
|
|
{
|
|
CreateScheduleMarker(context, i);
|
|
|
|
}
|
|
|
|
}
|
|
break;
|
|
case RootObjectTypes.Global:
|
|
{
|
|
CreateScheduleMarker(context, i);
|
|
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void CreateScheduleMarker(FetchActivitiesContext context, AppointmentList.AppointmentListInfo i)
|
|
{
|
|
Appointment a = new Appointment(this.WebScheduleInfo);
|
|
|
|
a.Subject = i.Subject;
|
|
a.Key = "SM," + i.SourceObjectID.ToString();
|
|
a.StartDateTime = new SmartDate(i.StartDateTime);
|
|
a.EndDateTime = new SmartDate(i.EndDateTime);
|
|
|
|
if (i.BackColorARGB != 0)
|
|
{
|
|
//a.Style.BackColor = Color.FromArgb(i.BackColorARGB);
|
|
//a.Style.ForeColor = Util.InvertColor(a.Style.BackColor);
|
|
|
|
}
|
|
|
|
// a.Style.CustomRules = "Background-repeat:no-repeat;background-position:Top Right";
|
|
//a.Style.BackgroundImage = "~/graphics/ScheduleMarker16.png";
|
|
|
|
|
|
a.Style.BorderStyle = BorderStyle.Dashed;
|
|
a.Style.BorderColor = Color.FromArgb(i.BackColorARGB);
|
|
a.Style.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(2);
|
|
|
|
// add appointment to the activities list in the context
|
|
//a.ResourceKey = "1";
|
|
((IList)context.Activities).Add(a);
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region IDataUpdate Members
|
|
|
|
public void Update(DataContext context)
|
|
{
|
|
if (context is UpdateActivityContext)
|
|
{
|
|
UpdateActivityContext up = (UpdateActivityContext)context;
|
|
string[] ar = up.Activity.Key.Split(',');
|
|
if (ar[0] == "WO")
|
|
{
|
|
Workorder w = Workorder.GetItem(new Guid(ar[1]));
|
|
WorkorderItemScheduledUser wsu=w.WorkorderItems[ar[2]].ScheduledUsers[ar[3]];
|
|
wsu.StartDate = up.Activity.StartDateTime.DBValue;
|
|
wsu.StopDate = up.Activity.EndDateTime.DBValue;
|
|
w.Save();
|
|
}
|
|
else
|
|
{
|
|
ScheduleMarker sm = ScheduleMarker.GetItem(new Guid(ar[1]));
|
|
sm.StartDate = up.Activity.StartDateTime.DBValue;
|
|
sm.StopDate = up.Activity.EndDateTime.DBValue;
|
|
sm.Save();
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|