Hello,
I am facing an issue wherein on the page following issue is coming:-
Request Failed. Try Again.
When I debugged the code then I found that the issue is actually coming due to this class file not found:- GanttProvider the actual error in the code is showing that:The type or namespace name 'GanttProvider' could not be found (are you missing a using directive or an assembly reference?)
<%@ WebService Language="C#" Class="GanttService" %>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Services;
using System.Web.Services;
using System.Web.SessionState;
//using Telerik.Web.UIusing Telerik.Web.UI.Gantt;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
publicclassGanttService : System.Web.Services.WebService, IRequiresSessionState
{
private WebServiceController _controller;
public WebServiceController Controller
{
get
{
if (_controller == null)
{
_controller = new WebServiceController(new GanttProvider());
}
return _controller;
}
}
[WebMethod(EnableSession = true)]
public IEnumerable<CustomTaskData> GetTasks()
{
var ddd = Controller.GetTasks<CustomTaskData>();
var provider = new GanttProvider();
foreach (var item in ddd)
{
//item.Dependency = provider.GetSuccessorByTaskID((int)item.ID);
item.Dependency = provider.GetPredecessorByTaskID((int)item.ID);
}
return ddd;
}
[WebMethod(EnableSession = true)]
public IEnumerable<CustomTaskData> InsertTasks(IEnumerable<CustomTaskData> models)
{
var plannerRefId = HttpContext.Current.Session["GanttPlannerRefId"] != null ? Convert.ToInt32(HttpContext.Current.Session["GanttPlannerRefId"]) : 0;
var plannerId = HttpContext.Current.Session["GanttPlannerID"] != null ? Convert.ToInt32(HttpContext.Current.Session["GanttPlannerID"]) : 0;
var plannerType = HttpContext.Current.Session["GanttPlannerType"] != null ? HttpContext.Current.Session["GanttPlannerType"].ToString() : "project";
if (plannerType.Equals("vendor", StringComparison.InvariantCultureIgnoreCase))
{
foreach (var item in models)
{
item.RootVendorID = plannerRefId;
item.PlannerID = plannerId;
}
}else
{
foreach (var item in models)
{
item.ProjectID = plannerRefId;
item.PlannerID = plannerId;
}
}
return Controller.InsertTasks<CustomTaskData>(models);
}
[WebMethod(EnableSession = true)]
public IEnumerable<CustomTaskData> UpdateTasks(IEnumerable<CustomTaskData> models)
{
var plannerRefId = HttpContext.Current.Session["GanttPlannerRefId"] != null ? Convert.ToInt32(HttpContext.Current.Session["GanttPlannerRefId"]) : 0;
var plannerId = HttpContext.Current.Session["GanttPlannerID"] != null ? Convert.ToInt32(HttpContext.Current.Session["GanttPlannerID"]) : 0;
var plannerType = HttpContext.Current.Session["GanttPlannerType"] != null ? HttpContext.Current.Session["GanttPlannerType"].ToString() : "project";
if (plannerType.Equals("vendor", StringComparison.InvariantCultureIgnoreCase))
{
foreach (var item in models)
{
item.RootVendorID = plannerRefId;
item.PlannerID = plannerId;
}
}else
{
foreach (var item in models)
{
item.ProjectID = plannerRefId;
item.PlannerID = plannerId;
}
}
return Controller.UpdateTasks<CustomTaskData>(models);
}
[WebMethod(EnableSession = true)]
public IEnumerable<CustomTaskData> DeleteTasks(IEnumerable<CustomTaskData> models)
{
return Controller.DeleteTasks<CustomTaskData>(models);
}
[WebMethod(EnableSession = true)]
public IEnumerable<DependencyData> GetDependencies()
{
return Controller.GetDependencies();
}
[WebMethod(EnableSession = true)]
public IEnumerable<DependencyData> InsertDependencies(IEnumerable<DependencyData> models)
{
return Controller.InsertDependencies(models);
}
[WebMethod(EnableSession = true)]
public IEnumerable<DependencyData> DeleteDependencies(IEnumerable<DependencyData> models)
{
return Controller.DeleteDependencies(models);
}
[WebMethod(EnableSession = true)]
public IEnumerable<Telerik.Web.UI.Gantt.ResourceData> GetResources()
{
return Controller.GetResources();
}
[WebMethod(EnableSession = true)]
public IEnumerable<AssignmentData> GetAssignments()
{
return Controller.GetAssignments();
}
[WebMethod(EnableSession = true)]
public IEnumerable<AssignmentData> InsertAssignments(IEnumerable<AssignmentData> models)
{
return Controller.InsertAssignments(models);
}
[WebMethod(EnableSession = true)]
public IEnumerable<AssignmentData> UpdateAssignments(IEnumerable<AssignmentData> models)
{
return Controller.UpdateAssignments(models);
}
[WebMethod(EnableSession = true)]
public IEnumerable<AssignmentData> DeleteAssignments(IEnumerable<AssignmentData> models)
{
return Controller.DeleteAssignments(models);
}
}
[System.Runtime.Serialization.DataContract]
publicclassCustomTaskData : TaskData
{
[System.Runtime.Serialization.DataMember]
publicstring Description
{
get;
set;
}
[System.Runtime.Serialization.DataMember]
publicint? ProjectID
{
get;
set;
}
[System.Runtime.Serialization.DataMember]
publicint? PlannerID
{
get;
set;
}
[System.Runtime.Serialization.DataMember]
publicstring CusTaskType
{
get;
set;
}
[System.Runtime.Serialization.DataMember]
publicdouble? CusDuration
{
get;
set;
}
[System.Runtime.Serialization.DataMember]
publicdouble? CusActualHour
{
get;
set;
}
[System.Runtime.Serialization.DataMember]
publicint? VendorID
{
get;
set;
}
[System.Runtime.Serialization.DataMember]
publicstring Vendor
{
get;
set;
}
[System.Runtime.Serialization.DataMember]
publicint? RootVendorID
{
get;
set;
}
[System.Runtime.Serialization.DataMember]
publicstring RootVendorName
{
get;
set;
}
[System.Runtime.Serialization.DataMember]
publicstring ProjectName
{
get;
set;
}
[System.Runtime.Serialization.DataMember]
publicstring Dependency
{
get;
set;
}
[System.Runtime.Serialization.DataMember]
publicint? PlannerTaskID
{
get;
set;
}
[System.Runtime.Serialization.DataMember]
publicint? ItemRefID
{
get;
set;
}
public override void CopyFrom(ITask srcTask)
{
base.CopyFrom(srcTask);
Description = ((CustomTaskData)srcTask).Description;
ProjectID = ((CustomTaskData)srcTask).ProjectID;
PlannerID = ((CustomTaskData)srcTask).PlannerID;
CusTaskType = ((CustomTaskData)srcTask).CusTaskType;
CusDuration = ((CustomTaskData)srcTask).CusDuration;
CusActualHour = ((CustomTaskData)srcTask).CusActualHour;
VendorID = ((CustomTaskData)srcTask).VendorID;
Vendor = ((CustomTaskData)srcTask).Vendor;
RootVendorID = ((CustomTaskData)srcTask).RootVendorID;
RootVendorName = ((CustomTaskData)srcTask).RootVendorName;
ProjectName = ((CustomTaskData)srcTask).ProjectName;
PlannerTaskID = ((CustomTaskData)srcTask).PlannerTaskID;
ItemRefID = ((CustomTaskData)srcTask).ItemRefID;
Dependency = ((CustomTaskData)srcTask).Dependency;
}
public override void CopyTo(ITask destTask)
{
base.CopyTo(destTask);
((CustomTaskData)destTask).Description = Description;
((CustomTaskData)destTask).ProjectID = ProjectID;
((CustomTaskData)destTask).PlannerID = PlannerID;
((CustomTaskData)destTask).CusTaskType = CusTaskType;
((CustomTaskData)destTask).CusDuration = CusDuration;
((CustomTaskData)destTask).CusActualHour = CusActualHour;
((CustomTaskData)destTask).VendorID = VendorID;
((CustomTaskData)destTask).Vendor = Vendor;
((CustomTaskData)destTask).RootVendorID = RootVendorID;
((CustomTaskData)destTask).RootVendorName = RootVendorName;
((CustomTaskData)destTask).ProjectName = ProjectName;
((CustomTaskData)destTask).PlannerTaskID = PlannerTaskID;
((CustomTaskData)destTask).ItemRefID = ItemRefID;
((CustomTaskData)destTask).Dependency = Dependency;
}
}
I am facing issue where I am trying to pass the object of GanntProvider class in WebServiceController constructor. It's an .ASMX file.
Kindly help me resolve this.
Thanks
Varun