internal static bool ChangeCommitted(this ISessionPersistentObject al,CRUD Operation, IImportContext iic, ISession session) { if (al == null) throw new Exception("Algo Error"); bool needtoregister = false; IObjectStateCycle oa = al; switch (Operation) { case CRUD.Created: needtoregister = true; session.Save(al); break; case CRUD.Update: session.Update(al); oa.HasBeenUpdated(); break; case CRUD.Delete: session.Delete(al); oa.SetInternalState(ObjectState.Removed,iic); break; } al.Context = null; return needtoregister; }
static void Main(string[] args) { var client = new HttpClient { BaseAddress = new Uri("http://localhost:1850/") }; CRUD<Album> crudAlbums = new CRUD<Album>(client, "albums"); //crudAlbums.GetAll(PrintAlbum); //crudAlbums.GetById(1, PrintAlbum); CRUD<Artist> crudArtists = new CRUD<Artist>(client, "Artists"); //crudArtists.GetAll(PrintArtist); CRUD<Song> crudSongs = new CRUD<Song>(client, "Songs"); //crudSongs.GetAll(PrintSong); CRUDXML<Album> crudXmlAlbums = new CRUDXML<Album>(client, "albums"); crudXmlAlbums.GetAll(); //crudXmlAlbums.Post(new Album() //{ // producer = "test producer xml", // title = "test album xml", // year = 1999 //}); }
internal static bool ChangeRequested(this ISessionPersistentObject Al, CRUD Operation, IImportContext iit) { if (Al == null) throw new Exception("Algo Error"); switch (Operation) { case CRUD.Created: Al.Register(iit); break; case CRUD.Delete: Al.SetInternalState(ObjectState.UnderRemove, iit); Al.UnRegisterFromSession(iit); break; case CRUD.Ignore: if (Al.Context != null) throw new Exception("Session transaction managment"); return false; } Al.Context = iit; return true; }
/// <summary> /// PersistenceCommand for CRUD operations and concurrency support based on the command type. Support multiple objects /// for process identified with a string ID. /// </summary> /// <param name="map"></param> /// <param name="cmdType"></param> /// <param name="providerCommand"></param> /// <param name="objectsForProcess"></param> public PersistenceCommand(Map map, CRUD cmdType, object providerCommand, IDictionary<string,object> objectsForProcess) { _appObjs = objectsForProcess; _providerCommand = providerCommand; _cmdMap = map.GetCommandMap(cmdType.ToString()); SetConcurrencySupport(cmdType); }
internal static bool RollBackChanges(this ISessionPersistentObject Al, CRUD Operation, IImportContext iit) { if (Al == null) throw new Exception("Algo Error"); switch (Operation) { case CRUD.Created: Al.UnRegisterFromSession(iit); break; case CRUD.Delete: Al.Register(iit); Al.SetInternalState(ObjectState.Available, iit); break; } Al.Context = null; return true; }
public Boolean HasAccess(User user, Category category, CRUD access) { // TODO: return true; }
public Boolean HasAccess(User user, Forum forum, CRUD access) { // TODO: return true; }
public SqlServerPersistenceCommand(Map map, SqlCommand command, CRUD cmdType, IDictionary<string,object> objectsForProcess) : base(map, cmdType, command, objectsForProcess) { }
//used for Retrieve and delete with an OID and a well-known command type public SqlServerPersistenceCommand(Map map, ObjectIdentifier oid, SqlCommand command, CRUD cmdType) : base(map, oid, command, cmdType) { }
//Used for Update and Delete commands public SqlServerPersistenceCommand(Map map, IPersistable objectForProcess, SqlCommand command, CRUD cmdType) : base(map, objectForProcess, command, cmdType) { }
//Overloaded the constructor to support concurrency (CRUD.UpdateWithTimestamp,...) public SqlServerUpdateCommand(Map map, IPersistable persistent, SqlCommand command, CRUD cmdType) : base(map, persistent, command, cmdType) { }
//Create a known-type command with OID public SqlServerRetrieveCommand(Map map, ObjectIdentifier oid, SqlCommand command, Type type, CRUD cmdType) : base(map, oid, command, cmdType) { _type = type; }
/// <summary> /// PersistenceCommand for CRUD operations and concurrency support based on the command type. /// </summary> /// <param name="map"></param> /// <param name="cmdType"></param> /// <param name="providerCommand"></param> public PersistenceCommand(Map map, CRUD cmdType, object providerCommand) { _providerCommand = providerCommand; _cmdMap = map.GetCommandMap(cmdType.ToString()); SetConcurrencySupport(cmdType); }
protected void SetConcurrencySupport(CRUD cmdType) { //concurrency support settings if ((cmdType == CRUD.DeleteCheckTimestamp) || (cmdType == CRUD.RetrieveWithTimestamp) | (cmdType == CRUD.UpdateCheckTimestamp)) { _optimisticField = PersistenceServiceConfiguration.Default.optimisticFieldName; _pessimisticField = string.Empty; } else if ((cmdType == CRUD.DeleteCheckLock) || (cmdType == CRUD.RetrieveAndLock) || (cmdType == CRUD.UpdateCheckLock)) { _optimisticField = string.Empty; _pessimisticField = PersistenceServiceConfiguration.Default.pessimisticFieldName; } else { _optimisticField = string.Empty; _pessimisticField = string.Empty; } }
/// <summary> /// PersistentSupport for CRUD (retrieve) operations and possible concurrency support /// </summary> /// <param name="map"></param> /// <param name="oid"></param> /// <param name="providerCommand"></param> /// <param name="cmdType"></param> public PersistenceCommand(Map map, ObjectIdentifier oid, object providerCommand, CRUD cmdType) { _providerCommand = providerCommand; _pObj = MakePersistable(null, oid);// Retrieve operations need only the OID _cmdMap = map.GetCommandMap(cmdType.ToString()); //must get the proper command instructions from the map SetConcurrencySupport(cmdType); }
/// <summary> /// PersistentSupport for CRUD (update and delete) operations and possible concurrency support /// </summary> /// <param name="map"></param> /// <param name="objectForProcess"></param> /// <param name="providerCommand"></param> /// <param name="cmdType"></param> public PersistenceCommand(Map map, IPersistable objectForProcess, object providerCommand, CRUD cmdType) { _providerCommand = providerCommand; _pObj = objectForProcess; //insert,updates and delete need the object for processing. Retrieve operations need only the OID _cmdMap = map.GetCommandMap(cmdType.ToString()); //must get the proper command instructions from the map SetConcurrencySupport(cmdType); }
//used for Retrieve all operations public SqlServerPersistenceCommand(Map map, CRUD cmdType, SqlCommand command) : base(map, cmdType, command) { }
public SqlServerTransactionCommand(Map map, SqlCommand command, CRUD cmdType, IDictionary<string,object> objectsForProcess) : base(map, command, cmdType, objectsForProcess) { }