/// <summary> /// Load data into the WebReferenceRelation instance. /// </summary> /// <param name='referenceRelation'>Reference relation.</param> /// <param name='dataReader'>An open data reader.</param> public static void LoadData(this WebReferenceRelation referenceRelation, DataReader dataReader) { referenceRelation.Id = dataReader.GetInt32(ReferenceRelationData.ID); referenceRelation.RelatedObjectGuid = dataReader.GetString(ReferenceRelationData.RELATEDOBJECTGUID); referenceRelation.ReferenceId = dataReader.GetInt32(ReferenceRelationData.REFERENCEID); referenceRelation.TypeId = dataReader.GetInt32(ReferenceRelationData.TYPE); }
/// <summary> /// Create a reference relation. /// </summary> /// <param name="clientInformation">Information about the client that makes this web service call.</param> /// <param name="referenceRelation">Information about the new reference relation.</param> /// <returns>The new reference relation.</returns> public WebReferenceRelation CreateReferenceRelation(WebClientInformation clientInformation, WebReferenceRelation referenceRelation) { using (ClientProxy client = new ClientProxy(this, 1)) { return(client.Client.CreateReferenceRelation(clientInformation, referenceRelation)); } }
/// <summary> /// Check the data in current object /// </summary> /// <param name='referenceRelation'>ReferenceRelation</param> public static void CheckData(this WebReferenceRelation referenceRelation) { if (!referenceRelation.IsDataChecked) { referenceRelation.CheckStrings(); referenceRelation.IsDataChecked = true; } }
/// <summary> /// Copy data from WebReferenceRelation to IReferenceRelation. /// </summary> /// <param name="userContext">User context.</param> /// <param name="referenceRelation">IReferenceRelation object.</param> /// <param name="webReferenceRelation">WebReferenceRelation object.</param> private void UpdateReferenceRelation(IUserContext userContext, IReferenceRelation referenceRelation, WebReferenceRelation webReferenceRelation) { referenceRelation.DataContext = GetDataContext(userContext); referenceRelation.Id = webReferenceRelation.Id; referenceRelation.RelatedObjectGuid = webReferenceRelation.RelatedObjectGuid; referenceRelation.Reference = null; referenceRelation.ReferenceId = webReferenceRelation.ReferenceId; referenceRelation.Type = CoreData.ReferenceManager.GetReferenceRelationType(userContext, webReferenceRelation.TypeId); }
/// <summary> /// Convert a WebReferenceRelation instance /// to a IReferenceRelation instance. /// </summary> /// <param name="userContext"> /// Information about the user that makes this method call. /// </param> /// <param name="webReferenceRelation">A WebReferenceRelation object.</param> /// <returns>A IReferenceRelation instance.</returns> private IReferenceRelation GetReferenceRelation(IUserContext userContext, WebReferenceRelation webReferenceRelation) { IReferenceRelation referenceRelation; referenceRelation = new ReferenceRelation(); UpdateReferenceRelation(userContext, referenceRelation, webReferenceRelation); return(referenceRelation); }
public void CreateReferenceRelation() { WebReferenceRelation newReferenceRelation, referenceRelation; referenceRelation = new WebReferenceRelation(); referenceRelation.RelatedObjectGuid = "test:dyntaxa.se:1"; referenceRelation.TypeId = 1; referenceRelation.ReferenceId = 171; newReferenceRelation = ReferenceManager.CreateReferenceRelation(GetContext(), referenceRelation); Assert.IsNotNull(newReferenceRelation); Assert.IsTrue(newReferenceRelation.Id > 0); }
/// <summary> /// Creates a reference relation. /// </summary> /// <param name="clientInformation">Information about the client that makes this web service call.</param> /// <param name="referenceRelation">Reference relation object to be created.</param> /// <returns>A WebReferenceRelation object with the created relation.</returns> public WebReferenceRelation CreateReferenceRelation(WebClientInformation clientInformation, WebReferenceRelation referenceRelation) { using (WebServiceContext context = GetWebServiceContext(clientInformation)) { try { return(ReferenceManager.CreateReferenceRelation(context, referenceRelation)); } catch (Exception exception) { WebServiceData.LogManager.LogError(context, exception); throw; } } }
/// <summary> /// Convert an IReferenceRelation instance /// to a WebReferenceRelation instance. /// </summary> /// <param name="referenceRelation">An IReferenceRelation instance.</param> /// <returns>A WebReferenceRelation instance.</returns> private WebReferenceRelation GetReferenceRelation(IReferenceRelation referenceRelation) { WebReferenceRelation webReferenceRelation; webReferenceRelation = null; if (referenceRelation.IsNotNull()) { webReferenceRelation = new WebReferenceRelation(); webReferenceRelation.Id = referenceRelation.Id; webReferenceRelation.ReferenceId = referenceRelation.ReferenceId; webReferenceRelation.RelatedObjectGuid = referenceRelation.RelatedObjectGuid; webReferenceRelation.TypeId = referenceRelation.Type.Id; } return(webReferenceRelation); }
/// <summary> /// Get information about a reference relation. /// </summary> /// <param name="context">Web service request context.</param> /// <param name="referenceRelationId">Id of reference relation record.</param> /// <returns>Returns reference relation or null if id doesn't match.</returns> public static WebReferenceRelation GetReferenceRelationById(WebServiceContext context, int referenceRelationId) { WebReferenceRelation referenceRelation; // Get information from database. using (DataReader dataReader = context.GetReferenceDatabase().GetReferenceRelationById(referenceRelationId)) { if (dataReader.Read()) { referenceRelation = new WebReferenceRelation(); referenceRelation.LoadData(dataReader); } else { throw new ArgumentException("Reference relation not found. Id = " + referenceRelationId); } } return(referenceRelation); }
/// <summary> /// Get reference relations that are related to specified object. /// </summary> /// <param name="context">Web service request context.</param> /// <param name="relatedObjectGuid">GUID for the related object.</param> /// <returns>Reference relations that are related to specified object.</returns> public static List <WebReferenceRelation> GetReferenceRelationsByGuid(WebServiceContext context, String relatedObjectGuid) { List <WebReferenceRelation> referenceRelations; WebReferenceRelation referenceRelation; // Check data. relatedObjectGuid.CheckNotEmpty("relatedObjectGuid"); // Get information from database. referenceRelations = new List <WebReferenceRelation>(); using (DataReader dataReader = context.GetReferenceDatabase().GetReferenceRelationsByGuid(relatedObjectGuid)) { while (dataReader.Read()) { referenceRelation = new WebReferenceRelation(); referenceRelation.LoadData(dataReader); referenceRelations.Add(referenceRelation); } } return(referenceRelations); }
/// <summary> /// Creates a reference relation. /// </summary> /// <param name="context">Web service request context.</param> /// <param name="referenceRelation">Information about the reference relation that should be created.</param> /// <returns>The created reference relation.</returns> public static WebReferenceRelation CreateReferenceRelation(WebServiceContext context, WebReferenceRelation referenceRelation) { Int32 referenceRelationId; // Check access rights. WebServiceData.AuthorizationManager.CheckAuthorization(context, AuthorityIdentifier.EditReference); // Check data. context.CheckTransaction(); referenceRelation.CheckData(); // Create reference relation. referenceRelationId = context.GetReferenceDatabase().CreateReferenceRelation(referenceRelation.RelatedObjectGuid, referenceRelation.ReferenceId, referenceRelation.TypeId); return(GetReferenceRelationById(context, referenceRelationId)); }