Simple Remoting Q
Dear All I'm new to remoting but have been programming c# for a while.
I have a remoting working use IIS as the server and windows forms as the client.
Here is the question I create an new object on the client that is compatable with my interface ISaveI
public interface ISaveI : IDirty
{
int SaveI();
}
public interface ISaveTranI : ISaveI
{
int SaveI( SqlTransaction tran );
void AfterAllGoodSave();
}
I then call the save on the object though a retomed object say
Feline.Remoting.Helper.SaveI( isWriteMode, Item as ISaveLockI );
It all runs with out error and if I debig the ASP.NET app I can see the object been updated.
The Dirty flag is set to false and other parameter updated during the save.
However when I get after the call the client object has not changed is this corect behaevour or I have got something wrong.
What I what to happen is that the object is saved on the server then the update object is avalable on the client.
Please help
hdl_jianghuiyangPosted Jul 26, 2004, 11:43 AM
//Save method in form public virtual bool SaveI(bool isWriteMode) { int r = Feline.Remoting.Helper.SaveI( isWriteMode, Item as ISaveLockI ); if ( r == 0) { Feline.Windows.UI.Helper.ErrorDisplay( r, this, Item ); Item_IsVaildChanged( null, EventArgs.Empty ); } return r == 0; } ///
/// One save methods for remoted SaveI compatable interface objects
///
/// retain the lock on the item when saving
/// All objects to save
/// 0 : good any thing else bad
public static int SaveI(bool keepLockOnSave, Feline.Helper.ISaveLockI items)
{
try
{
Feline.Remoting.ISaveLockRemoteI s = new Feline.Remoting.ISaveLockRemoteI();
int r = s.SaveI( keepLockOnSave, items );
return r;
}
catch(System.Runtime.Remoting.RemotingException exc)
{
Feline.ExceptionManagement.ExceptionManager.Publish ( exc );
return (int)Feline.Helper.ERROR_LIST.REMOTING_EXCEPTION;
}
catch(Exception exc )
{
Feline.ExceptionManagement.ExceptionManager.Publish ( exc );
return (int)Feline.Helper.ERROR_LIST.GENRAL_CLIENT_EXCEPTION ;
}
}
// SAve method of MarshalByRefObject
public int SaveI(bool KeepLockOnSave, params ISaveLockI[] items)
{
using (SqlConnection con = new SqlConnection( System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"] ) )
{
con.Open();
int r = 0;
foreach (Feline.Helper.ISaveLockI s in items)
{
SqlTransaction tran = con.BeginTransaction();
try
{
r = s.SaveI( KeepLockOnSave, tran );
}
catch(SqlException exc )
{
ExceptionManagement.ExceptionManager.Publish( exc );
return exc.Number;
}
catch(Exception exc )
{
ExceptionManagement.ExceptionManager.Publish( exc );
return (int)ERROR_LIST.GENRAL_CLIENT_EXCEPTION;
}
finally
{
if ( r != 0)
{
tran.Rollback();
con.Close();
}
}
if ( r != 0)
return r;
else
{
tran.Commit();
s.AfterAllGoodSave();
}
}
con.Close();
}
return 0;
}
// There is the save method of the object as well but this just access sql server and I've stepped though the code so know it works
can post if you like though
david 0Posted Jul 26, 2004, 11:30 AM