/// <summary> /// Deletes the property definition and removes it from the database. /// </summary> /// <param name="PropDef">The prop def.</param> /// <returns></returns> public OperationReport DeletePropertyDefinition(PropertyDefinition PropDef) { OperationReport validationReport = GuardAgainstNulls.ArgsContainsNull(new object[] { PropDef }); if (!validationReport.Success) { throw new OrcaArgumentNullException(validationReport); } if (PropDef.IsPublished) { throw new CanNotDeletePublishedDomainObject(PropDef.Name); } if (newPropertyDefintions.ContainsKey(PropDef.Id)) { newPropertyDefintions.Remove(PropDef.Id); persistor.CancelTransaction(PropDef.Id); return(new OperationReport("", true)); } var trans = GetPersistTransactionFor(PropDef.Id); trans.Delete(PropDef); return(persistor.ProcessCommandsTransaction(trans)); }
private OperationReport RemoveDefaultPropertyValue(ISupportDefaultPropertyValues supportPropertiesObject, PropertyDefinition PropertyDef) { OperationReport result = new OperationReport(); var defaultPropValue = GetDefaultPropertyValue(supportPropertiesObject, PropertyDef); if (defaultPropValue == null) { result.Success = false; result.AddNotification(string.Format("The {0} domain object does not contain the property {1}", supportPropertiesObject.Name, PropertyDef.Name)); return(result); } supportPropertiesObject.RemoveDefaultPropertyValue(defaultPropValue); var trans = persistor.GetTransaction(supportPropertiesObject.Id); trans.Delete(defaultPropValue); result.Success = true; lock (typeProperties) { typeProperties[supportPropertiesObject.UserTypeID].Remove(defaultPropValue.Name); } return(result); }
private DefaultPropertyValue CreateAndAssignDefaultPropertyValue(ISupportDefaultPropertyValues supportPropertiesObject, PropertyDefinition propertyDef, OperationReport operationReport) { OperationReport report = GuardAgainstNulls.ArgsContainsNull(new object[] { supportPropertiesObject, propertyDef }); if (!report.Success) { operationReport.SetValues(report); return(null); } report = ValidateCanAssociateDefaultPropertyValueToObject(supportPropertiesObject, propertyDef); if (!report.Success) { operationReport.SetValues(report); return(null); } var propDefaultValue = new DefaultPropertyValue(propertyDef); supportPropertiesObject.AddDefaultPropertyValue(propDefaultValue); lock (typeProperties) { typeProperties[supportPropertiesObject.UserTypeID].Add(propDefaultValue.Name, propDefaultValue); } return(propDefaultValue); }
public OperationReport UpdatePropertyDefinition(ISupportDefaultPropertyValues domainObject, DefaultPropertyValue propDefValue) { OperationReport newOperationReport = new OperationReport { Success = true }; if (!domainObject.HasProperty(propDefValue.StaticInstanceID)) { newOperationReport.Success = false; newOperationReport.AddNotification(string.Format("The domain object {0} does not contain the property definition value {1}", domainObject.Name, propDefValue.Name)); return(newOperationReport); } //get the transaction for the worktype name or id? need to be consistent. try { var Trans = GetPersistTransactionFor(domainObject.Id); Trans.SaveOrUpdate(propDefValue); //save the newly defined propertydefinition value object (to get the id) and add to the worktype } catch (Exception ex) { newOperationReport.AddNotification(ex.Message, ex); } return(newOperationReport); }
public void ConstructorSetsValues() { var message = "Some Message"; var report = new OperationReport(true, message); Assert.IsTrue(report.WasSuccess); Assert.AreEqual(message, report.Message); }
private OperationReport ValidateCanAssociateDefaultPropertyValueToObject(ISupportDefaultPropertyValues dynamicPropertyObject, PropertyDefinition PropertyDef) { OperationReport report = new OperationReport(); report.Success = true; //ISupportDefaultPropertyValues dynamicPropertyObject = dynamicPropertyObject.As<ISupportDefaultPropertyValues>(); if (!PropertyDef.IsPublished) { //var ex = ; report.AddNotification(string.Format("The property Definition {0} has not been published", PropertyDef.Name), new PropertyDefinitionMustBePublishedException(PropertyDef.Name)); report.Success = false; } if (HasDefaultPropertyValue(dynamicPropertyObject, PropertyDef)) { report.AddNotification(string.Format("The domain object {0} already has the property {1} .", dynamicPropertyObject.Name, PropertyDef.Name), new PropertyAlreadyExistException(PropertyDef.Name, dynamicPropertyObject.Name)); report.Success = false; } return(report); }
public PropertyDefinition DefinePropertyDefinition(object DefaultValue, string Name) { OperationReport validationReport = GuardAgainstNulls.ArgsContainsNull(new object[] { DefaultValue, Name }); if (!validationReport.Success) { throw new OrcaArgumentNullException(validationReport); } OperationReport result = new OperationReport(); PropertyDefinition def = new PropertyDefinition(Name, DefaultValue); persistor.AssignNewID(def); //the save only saves to the session, not persisted to the db //so the only way to get the object again is by its id //to allow for lookup by name we need to keep an assocation of name to id //when the object has been persisted out to the db then we remove it from the collection. lock (newPropertyDefintions) { newPropertyDefintions.Add(def.Id, def); } return(def); }
/// <summary>Runs a delegate in a seperate thread.</summary> /// <param name="run">The delegate to run in the background with reporting.</param> /// <param name="report">The delegate for reporting</param> /// <param name="resolve">The delegate for handling the completion of the background thread.</param> public static IAsyncResult Thread( OperationReport run, Callback report, Resolve resolve) { if (run == null) { throw new System.ArgumentNullException("run"); } if (report == null) { throw new System.ArgumentNullException("report"); } if (resolve == null) { throw new System.ArgumentNullException("resolve"); } SynchronizationContext context = SynchronizationContext.Current; return(run.BeginInvoke( () => { context.Post((object state) => { report(); }, null); }, (IAsyncResult ar) => { context.Post((object state) => { resolve(ar); }, null); }, null)); }
public OperationReport RemovePropertyValueFromDomainObject(ISupportDefaultPropertyValues UserTypeObject, PropertyDefinition PropertyDef) { OperationReport report = GuardAgainstNulls.ArgsContainsNull(new object[] { UserTypeObject, PropertyDef }); if (!report.Success) { throw new OrcaArgumentNullException(report); } return(RemoveDefaultPropertyValue(UserTypeObject, PropertyDef)); }
/// <summary> /// Saves the specified property definition and commits it to the database. /// </summary> /// <param name="PropertyDef">The PropertyDefinition.</param> /// <returns></returns> public OperationReport Save(PropertyDefinition PropertyDef) { OperationReport validationReport = GuardAgainstNulls.ArgsContainsNull(new object[] { PropertyDef }); if (!validationReport.Success) { throw new OrcaArgumentNullException(validationReport); } OperationReport result = new OperationReport(); try { IPersistCommandsTransaction trans = GetPersistTransactionFor(PropertyDef.Id); if (trans != null) { if (newPropertyDefintions.ContainsKey(PropertyDef.Id)) { if (PropertyDefinitionNameAvaliable(PropertyDef.Name)) { NameToTypeAssociation propertyDefNameRegistration = RegisterPropertyDefintionName(PropertyDef.Name); trans.Save(propertyDefNameRegistration); } else { throw new PropertyNameAlreadyDefinedException(PropertyDef.Name); } } else { trans.SaveOrUpdate(PropertyDef); } result = persistor.ProcessCommandsTransaction(trans); if (result.Success) { lock (newPropertyDefintions) { newPropertyDefintions.Remove(PropertyDef.Id); } } else { //not sure what to do } } } catch (Exception ex) { result.Success = false; result.AddNotification(ex.Message, ex); } return(result); }
public OperationReport CanPublish(PropertyDefinition propertyDef) { OperationReport validationReport = GuardAgainstNulls.ArgsContainsNull(new object[] { propertyDef }); if (!validationReport.Success) { throw new OrcaArgumentNullException(validationReport); } return(publishService.CanPublish(propertyDef)); }
public DefaultPropertyValue AddPropertyDefintionToDomainObject(ISupportDefaultPropertyValues DomainObjectForProperty, PropertyDefinition PropertyDef, OperationReport Report) { OperationReport validationReport = GuardAgainstNulls.ArgsContainsNull(new object[] { DomainObjectForProperty, PropertyDef }); if (!validationReport.Success) { throw new OrcaArgumentNullException(validationReport); } return(CreateAndAssignDefaultPropertyValue(DomainObjectForProperty, PropertyDef, Report)); }
public void ValuesArePassedCorrectly() { var message = "Some Message"; var report = new OperationReport { WasSuccess = false, Message = message }; var result = report.DoRoundTripTest(); Assert.IsFalse(result.WasSuccess); Assert.AreEqual(message, result.Message); }
public void BuildPropertyValuesForObject(ISupportPropertyValues domainObject) { OperationReport report = GuardAgainstNulls.ArgsContainsNull(new object[] { domainObject }); if (!report.Success) { throw new OrcaArgumentNullException(report); } foreach (DefaultPropertyValue propertyDef in GetDefaultPropertyValuesDomainObject(domainObject.Id)) { if (domainObject.HasProperty(propertyDef.StaticInstanceID)) { continue; } CreateAndAssignPropertyValue(domainObject, propertyDef); } }
public object BeforeCall(string operationName, object[] inputs) { _stopwatch = Stopwatch.StartNew(); _paramatersInspectorMetricsReport = new OperationReport() { OperationName = operationName, MetricsReportType = MetricsReportTypes.Operation, Tags = new List <Tag>() { new Tag() { Key = TagsKeyTypes.SourceName.ToString(), Value = nameof(ParametersInspector) } } }; return(null); }
public DefaultPropertyValue GetDefaultPropertyValue(ISupportDefaultPropertyValues dynamicPropertyObject, PropertyDefinition propertyDef) { OperationReport report = GuardAgainstNulls.ArgsContainsNull(new object[] { dynamicPropertyObject, propertyDef }); if (!report.Success) { throw new OrcaArgumentNullException(report); } if (!typeProperties[dynamicPropertyObject.UserTypeID].ContainsKey(propertyDef.Name)) { var result = _repository.GetFirst <DefaultPropertyValue>(x => x.PropertyDefinitionStaticID == propertyDef.StaticInstanceID && x.PropertyOwnerId == dynamicPropertyObject.Id); // var result = _repository.Query<DefaultPropertyValue>().Where( // x => x.PropertyDefinition.StaticInstanceID == propertyDef.StaticInstanceID && x.UserTypeID == dynamicPropertyObject.UserTypeID).FirstOrDefault(); return(result); } return(typeProperties[dynamicPropertyObject.UserTypeID][propertyDef.Name]); }
public bool HasDefaultPropertyValue(ISupportDefaultPropertyValues dynamicPropertyObject, PropertyDefinition propertyDef) { OperationReport report = GuardAgainstNulls.ArgsContainsNull(new object[] { dynamicPropertyObject, propertyDef }); if (!report.Success) { throw new OrcaArgumentNullException(report); } if (typeProperties[dynamicPropertyObject.UserTypeID].ContainsKey(propertyDef.Name)) { return(true); } var count = _repository.GetCount <DefaultPropertyValue>( x => x.PropertyDefinitionStaticID == propertyDef.StaticInstanceID && x.PropertyOwnerId == dynamicPropertyObject.Id); return(count != 0); }
/// <summary>Runs a delegate in a seperate thread.</summary> /// <param name="run">The delegate to run in the background with reporting.</param> /// <param name="report">The delegate for reporting</param> public static IAsyncResult Thread( OperationReport run, Callback report) { if (run is null) { throw new ArgumentNullException(nameof(run)); } if (report is null) { throw new ArgumentNullException(nameof(report)); } SynchronizationContext context = SynchronizationContext.Current; return(run.BeginInvoke( () => { context.Post((object state) => { report(); }, null); }, (IAsyncResult ar) => { }, null)); }
public OrcaArgumentNullException(OperationReport report) : base(report.GetNotifications()) { }
/// <summary> /// Initializes a new instance of the MethodFailureMessageCommand class. /// </summary> public MethodFailureMessageCommand(OperationReport operationResult) { ClassName = string.Empty; MethodName = string.Empty; OperationResult = operationResult; }
/// <summary> /// Initializes a new instance of the MethodFailureMessageCommand class. /// </summary> public MethodFailureMessageCommand(OperationReport operationResult, string className, string methodName) : this(operationResult) { ClassName = className; MethodName = methodName; }