×

Notice

The forum is in read only mode.
×
Getting new Releases

To get notified on new releases you may follow us on twitter @expandframework or subscribe in our main RSS feed.

Topic-icon custom OnSaving

  • xafGna
  • xafGna's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
3 years 5 months ago #9342 by xafGna
custom OnSaving was created by xafGna
hello,
CreateRescueEpuipment action is working when i execute it. :)

how to work it when i use OnSaving() ?
:unsure: :unsure:

1.
private void CreateRescueEpuipment_Execute(object sender, SimpleActionExecuteEventArgs e)
{

IObjectSpace ios = Application.CreateObjectSpace();
RECheck currentObject = ios.GetObject<RECheck>(e.CurrentObject as RECheck);

if (currentObject.Position != null && IsAdminRoleCheck())
{
REStandard checkStandard = currentObject.Position.Standard;
foreach (REStandardEquipment standartEquipment in checkStandard.REStandardEquipments)
{

RECheckEquipment checkEquipment = ios.FindObject<RECheckEquipment>(CriteriaOperator.Parse("Equipment.Oid=? AND Check.Oid=?", standartEquipment.Equipment.Oid, currentObject.Oid));

if (checkEquipment == null)
{
checkEquipment = ios.CreateObject<RECheckEquipment>();
checkEquipment.Check = currentObject;
checkEquipment.Equipment = standartEquipment.Equipment;
checkEquipment.Size = standartEquipment.Size;
checkEquipment.Save();
currentObject.RECheckEquipments.Add(checkEquipment);
currentObject.Save();
}

}
ios.CommitChanges();
View.ObjectSpace.Refresh();
}
}



2. protected override void OnSaving()
{
base.OnSaving();

IObjectSpace ios = Application.CreateObjectSpace();
RECheck currentObject = Session.GetObjectByKey<RECheck>(e.CurrentObject as RECheck);


if (this.Position != null)
{
REStandard checkStandard = this.Position.Standard;
foreach (REStandardEquipment standartEquipment in checkStandard.REStandardEquipments)
{
// error its
RECheckEquipment checkEquipment = Session.FindObject<RECheckEquipment>(CriteriaOperator.Parse("Equipment.Oid=? AND Check.Oid=?", standartEquipment.Equipment.Oid, this.Oid));

if (checkEquipment == null)
{
checkEquipment = new RECheckEquipment(Session);
//checkEquipment = ios.CreateObject<RECheckEquipment>();
checkEquipment.Check = this;
checkEquipment.Equipment = standartEquipment.Equipment;
checkEquipment.Size = standartEquipment.Size;
checkEquipment.Save();
this.RECheckEquipments.Add(checkEquipment);
this.Save();
}

}
//View.ObjectSpace.Refresh();
}
}
Moderators: expand
Time to create page: 0.185 seconds