The method or object is not implementedThe method or object is not implemented
Old forum URL: forums.lhotka.net/forums/t/6261.aspx
oneinone posted on Tuesday, January 27, 2009
hi,
Im getting error in this.This is my business object creation
public class IssueTracker : BusinessBase<IssueTracker>
{
#region Business Methods
private Guid _id;
private string _subject = string.Empty;
private string _description = string.Empty;
private string _status = string.Empty;
private SmartDate _repdate;
private IssueTracker _resources;
[System.ComponentModel.DataObjectField(true, true)]
public Guid Id
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _id;
}
}
public string Subject
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _subject;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_subject != value)
{
_subject = value;
PropertyHasChanged();
}
}
}
public string Description
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _description;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_description != null)
{
_description = value;
PropertyHasChanged();
}
}
}
public string Status
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _status;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_status != null)
{
_status = value;
PropertyHasChanged();
}
}
}
public string Repdate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _repdate.Text;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_repdate != null)
{
_repdate.Text = value;
PropertyHasChanged();
}
}
}
protected override object GetIdValue()
{
return _id;
}
public override bool IsValid
{
get { return base.IsValid && _resources.IsValid; }
}
public override bool IsDirty
{
get { return base.IsDirty || _resources.IsDirty; }
}
#endregion
#region Validation Rules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(Csla.Validation.CommonRules.StringRequired,
new Csla.Validation.RuleArgs("Subject", "Subject"));
ValidationRules.AddRule(Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Subject", 50));
ValidationRules.AddRule(Csla.Validation.CommonRules.StringRequired,
new Csla.Validation.RuleArgs("Description", "Description"));
ValidationRules.AddRule(Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Description", 250));
ValidationRules.AddRule(Csla.Validation.CommonRules.StringRequired,
new Csla.Validation.RuleArgs("Status", "Status"));
}
#endregion
#region Authorization Rules
public static bool CanAddObject()
{
return Csla.ApplicationContext.User.IsInRole(
"ProjectManager");
}
public static bool CanGetObject()
{
return true;
}
public static bool CanDeleteObject()
{
bool result = false;
if (Csla.ApplicationContext.User.IsInRole(
"ProjectManager"))
result = true;
if (Csla.ApplicationContext.User.IsInRole(
"Administrator"))
result = true;
return result;
}
public static bool CanEditObject()
{
return Csla.ApplicationContext.User.IsInRole("ProjectManager");
}
#endregion
#region Factory Methods
internal static IssueTracker NewProjectResources()
{
return new IssueTracker();
}
public static IssueTracker NewProject()
{
if (!CanAddObject())
throw new System.Security.SecurityException(
"User not authorized to add a project");
return DataPortal.Create<IssueTracker>();
}
public static IssueTracker GetProject(Guid id)
{
if (!CanGetObject())
throw new System.Security.SecurityException(
"User not authorized to view a project");
return DataPortal.Fetch<IssueTracker>(new Criteria(id));
}
private IssueTracker()
{
_resources = IssueTracker.NewProjectResources();
}
void _resources_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e)
{
OnPropertyChanged(null);
}
public override IssueTracker Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException(
"User not authorized to remove a project");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException(
"User not authorized to add a project");
else if (!CanEditObject())
throw new System.Security.SecurityException(
"User not authorized to update a project");
return base.Save();
}
#endregion
#region Data Access
[Serializable()]
private class Criteria
{
private Guid _id;
public Guid Id
{
get { return _id; }
}
public Criteria(Guid id)
{ _id = id; }
}
private void Fetch(Guid id)
{
_id = id;
}
private void DataPortal_Fetch(Criteria criteria)
{
using (SqlConnection cn = new SqlConnection(Database.PTrackerConnection))
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getIssueTrackProject";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
dr.Read();
_id = dr.GetGuid("Id");
_subject = dr.GetString("Subject");
_description = dr.GetString("Description");
_status = dr.GetString("Status");
_repdate = dr.GetSmartDate("Repdate");
}
}
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
{
using (SqlConnection cn = new SqlConnection(Database.PTrackerConnection))
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandText = "InsertIssueTracker";
DoInsertUpdate(cm);
}
}
}
}
private void DoInsertUpdate(SqlCommand cm)
{
cm.CommandType = CommandType.StoredProcedure;
cm.Parameters.AddWithValue("@Pjtid", _id);
cm.Parameters.AddWithValue("@resid", _id);
cm.Parameters.AddWithValue("@subject", _subject);
cm.Parameters.AddWithValue("@description", _description);
cm.Parameters.AddWithValue("@repdate", _repdate);
cm.Parameters.AddWithValue("@status", _status);
cm.ExecuteNonQuery();
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(Criteria criteria)
{
using (SqlConnection cn = new SqlConnection(Database.PTrackerConnection))
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteIssueTracker";
cm.Parameters.AddWithValue("@id", criteria.Id);
cm.ExecuteNonQuery();
}
}
}
#endregion
}
please help me..
esteban404 replied on Tuesday, January 27, 2009
Your object isn't implementing a DataPortal_Create method.oneinone replied on Tuesday, January 27, 2009
hi,
I have created Dataportal_Create method also,
but still im getting the same problem.
[RunLocal()]
protected override void DataPortal_Create()
{
_id = Guid.NewGuid();
ValidationRules.CheckRules();
}
pls help me
esteban404 replied on Wednesday, January 28, 2009
Try this method signature:
[RunLocal()]
private void DataPortal_Create()
{
_id = Guid.NewGuid();
ValidationRules.CheckRules();
}
If you need to pass in criteria, then embed the criteria class and use this type:
[RunLocal()]
private void DataPortal_Create(Criteria criteria)
{
_id = criteria.ID;
ValidationRules.CheckRules();
}
Step throught the creation and you'll see the failure happen when the method getter tries to find the Create method in your object and can't.
_Estebanoneinone replied on Thursday, January 29, 2009
thank you...i got it
Copyright (c) Marimer LLC