void HostControl.Stop() { _log.Debug("Stop requested by hosted service"); // this should ask the role to restart RoleEnvironment.RequestRecycle(); }
void StartService() { if (_serviceHandle != null) { _log.Debug("Attempted to start service, but it is already started"); return; } string reason; if (!CanStartService(out reason)) { _log.DebugFormat("Attempted to start service, but it is not available: {0}", reason); return; } _log.Debug("Starting supervised service"); var arguments = new CommandScriptStepArguments { _serviceBuilderFactory }; var script = new CommandScript { new CommandScriptStep <CreateServiceCommand>(arguments), new CommandScriptStep <StartServiceCommand>(arguments), }; bool started = Execute(script); if (started) { _serviceHandle = arguments.Get <ServiceHandle>(); } }
public void Push() { try { _logger.Info(string.Format("Beginning synchronization of {0}", Options.LocalDirectory)); using (Session session = new Session()) { byte[] pw = new byte[Options.Password.Length]; Options.Password.CopyTo(pw, 0); ProtectedMemory.Unprotect(pw, MemoryProtectionScope.SameProcess); SessionOptions options = new SessionOptions { UserName = Options.Username, Password = Encoding.UTF8.GetString(pw), HostName = Options.Hostname, PortNumber = 443, Protocol = Protocol.Webdav, WebdavSecure = true }; session.FileTransferred += ResultHandler; session.Open(options); SynchronizationResult result = session.SynchronizeDirectories(SynchronizationMode.Remote, Options.LocalDirectory, Options.RemoteDirectory, false); } } catch (SessionException e) { _logger.Debug(e.ToString()); throw; } }
public TopshelfExitCode Run() { Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); AppDomain.CurrentDomain.UnhandledException += CatchUnhandledException; ExitCode = (int)TopshelfExitCode.Ok; _log.Info("Starting as a Windows service"); if (!_environment.IsServiceInstalled(_settings.ServiceName)) { string message = string.Format("The {0} service has not been installed yet. Please run '{1} install'.", _settings, Assembly.GetEntryAssembly().GetName()); _log.Fatal(message); ExitCode = (int)TopshelfExitCode.ServiceNotInstalled; throw new TopshelfException(message); } _log.Debug("[Topshelf] Starting up as a windows service application"); Run(this); return((TopshelfExitCode)Enum.ToObject(typeof(TopshelfExitCode), ExitCode)); }
public bool RunAsAdministrator() { if (Environment.OSVersion.Version.Major == 6) { string commandLine = CommandLine.Replace("--sudo", ""); var startInfo = new ProcessStartInfo(Assembly.GetEntryAssembly().Location, commandLine) { Verb = "runas", UseShellExecute = true, CreateNoWindow = true, }; try { HostLogger.Shutdown(); Process process = Process.Start(startInfo); process.WaitForExit(); return(true); } catch (Win32Exception ex) { _log.Debug("Process Start Exception", ex); } } return(false); }
private void RunService() { try { var hasSecret = ConfigurationManager.AppSettings .OfType <string>() .Any(x => x.Equals("Secret")); if (!hasSecret || string.IsNullOrEmpty(ConfigurationManager.AppSettings["Secret"])) { InitializeConfig(hasSecret); } var configDict = ConfigurationManager.AppSettings.AllKeys .ToDictionary(key => key, key => ConfigurationManager.AppSettings[key]); byte[] entropy = DecryptValue(configDict["Secret"], null); byte[] bytes = DecryptValue(configDict["Password"], entropy); configDict["Password"] = Encoding.UTF8.GetString(bytes); var _sync = new Synchronizer(configDict); _monitor = new DirectoryMonitor(configDict["LocalDirectory"], _sync); _logger.Debug("Sync Service object init end"); _monitor.StartMonitoring(); } catch (CryptographicException ex) { _logger.Debug(ex); _logger.Error("Could not decrypt password. Clear the secret value and replace the password value in " + "the config file in order to re-encrpyt password on next run."); _control.Stop(); } catch (SessionException) { _logger.Error("Failed to initialize connection to remote host. Verify config information"); _control.Stop(); } }
/// <summary> /// Initialize ListForm. /// </summary> /// <param name="ListOfCharacters">List of all characters</param> /// <param name="Logs">Log Writer</param> public ListForm(List <Character> ListOfCharacters, LogWriter Logs) { try { Logs.Debug("Initializing ListForm..."); InitializeComponent(); this.Characters = ListOfCharacters; this.Logs = Logs; Logs.Debug("ListForm : OK."); Logs.Debug("Preparing ListChoices..."); ListChoices = new List <string>(); ListChoices.Add("Last Name"); ListChoices.Add("First Name"); ListChoices.Add("Hair Color"); ListChoices.Add("Hair Length"); ListChoices.Add("Eyes Color"); ListChoices.Add("Race"); ListChoices.Add("Height"); ListChoices.Add("Birth Date"); ListChoices.Add("Timeline"); ListChoices.Add("Elements"); ListChoices.Add("Powers"); ListChoices.Add("Likes"); ListChoices.Add("Unlikes"); ListChoices.Add("Activities"); ListChoices.Add("Backstory"); ListChoices.Add("Weapons"); ListChoices.Add("Alternative"); foreach (string value in ListChoices) { ChoiceBox1.Items.Add(value); ChoiceBox2.Items.Add(value); ChoiceBox3.Items.Add(value); ChoiceBox4.Items.Add(value); } ListTable.Columns.Add("", 200, HorizontalAlignment.Left); ListTable.Columns.Add("", 200, HorizontalAlignment.Left); ListTable.Columns.Add("", 200, HorizontalAlignment.Left); ListTable.Columns.Add("", 200, HorizontalAlignment.Left); foreach (Character value in Characters) { ListViewItem item = new ListViewItem(); item.Text = ""; item.SubItems.Add(""); item.SubItems.Add(""); item.SubItems.Add(""); ListTable.Items.Add(item); } Logs.Debug("Choices and Lists prepared."); } catch (Exception ex) { Logs.Error(ex); } }
private Host CreateHost(ServiceHandle serviceHandle) { if (Environment.IsRunningAsAService) { _log.Debug("Running as a service, creating service host."); return(Environment.CreateServiceHost(Settings, serviceHandle)); } _log.Debug("Running as an application, creating the application host."); return(new ApplicationHost(Settings, serviceHandle)); }
private void TimerElapsed(object state) { //logger.Debug("Timer Elapsed."); DatapoolSvr_ConnectionChange(CheckDatapoolConnectionStatus()); if (datapool.IsConnected == false) { return; } if (RecipeChanged() & isUpdating == false) // check for recipe change if not already in the middle of an update. Checks for new Recipe (not a target change). { logger.Debug("Recipe Changed, call clearing QC List and rebuilding."); if (tags.Count > 0) { ClearQcsAndUnsubscribe(); } AddQCsToTagsList(); } // Check for data changes else // target change if updateDatapool == true and isUpdating == false { if (updateDatapool & isUpdating == false) // recipe target changed { foreach (var tag in tags) { tag.m_double = ramos.Recipe.Items.FirstOrDefault(t => t.QcName == tag.m_tag).Setpoint; datapool.Write(datapoolGroupName, tag.m_tag, tag.m_double); logger.Info($"Writing recipe target to datapool. tag: {tag.m_tag}, value: {tag.m_double}."); } updateDatapool = false; } } var oldValues = tags.Select(t => t.m_double).ToList(); // set oldValues to the current values. datapool.Read(ref tags); // datapool read current values. if (isUpdating == false & oldValues.Count > 0) { for (int i = 0; i < tags.Count; i++) { if (oldValues[i] != tags[i].m_double) { logger.Info($"Datapool tag updated: {tags[i].m_tag}. OldValue = {oldValues[i]}, NewValue = {tags[i].m_double} "); isUpdating = true; UpdateRecipe(tags[i].m_tag, tags[i].m_double); } } return; } if (isUpdating) { isUpdating = false; return; } }
Host CreateHost(ServiceHandle serviceHandle) { if (Environment.IsRunningAsAService) { _log.Debug("Running as a service, creating service host."); return(Environment.CreateServiceHost(Settings, serviceHandle)); } _log.Debug("Running as a console application, creating the console host."); return(new ConsoleRunHost(Settings, Environment, serviceHandle)); }
/// <summary> /// Checks whether the command applies to the reference provided as a serialized XML document. /// </summary> /// <param name="document">The serialized reference as an XML document.</param> /// <returns>A boolean flag indicating whether the command applies to the provided XML document.</returns> public bool AppliesToReference(XmlDocument document) { bool doesApply = false; using (LogGroup logGroup = LogGroup.Start("Checking whether the command applies to the provided XML document.", LogLevel.Debug)) { XmlNode type1Node = document.DocumentElement.SelectSingleNode("Type1Name"); XmlNode type2Node = document.DocumentElement.SelectSingleNode("Type2Name"); if (type1Node == null) { throw new ArgumentException("The provided document doesn't have a 'Type1Name' node."); } if (type2Node == null) { throw new ArgumentException("The provided document doesn't have a 'Type2Name' node."); } LogWriter.Debug("Type 1 name: " + type1Node.InnerText); LogWriter.Debug("Type 2 name: " + type2Node.InnerText); LogWriter.Debug("Expected type name: " + TypeName); // The command applies if either of the type nodes match the type on the command doesApply = type1Node.InnerText == TypeName || type2Node.InnerText == TypeName; } return(doesApply); }
/// <summary> /// Checks whether the provided type is a element. /// </summary> /// <param name="type"></param> /// <returns></returns> public bool IsElement(Type type) { bool isElement = false; using (LogGroup logGroup = LogGroup.Start("Checks whether the provided type is a element.", NLog.LogLevel.Debug)) { LogWriter.Debug("Type: " + type.ToString()); bool matchesInterface = false; bool isNotInterface = false; bool isNotAbstract = false; bool hasAttribute = false; matchesInterface = (type.GetInterface("IElement") != null); isNotInterface = !type.IsInterface; isNotAbstract = !type.IsAbstract; hasAttribute = type.GetCustomAttributes(typeof(ElementAttribute), true).Length > 0; LogWriter.Debug("Matches interface: " + matchesInterface); LogWriter.Debug("Is not element interface: " + isNotInterface); LogWriter.Debug("Has attribute: " + isNotAbstract); isElement = matchesInterface && isNotInterface && isNotAbstract && hasAttribute; LogWriter.Debug("Is element: " + isElement.ToString()); } return(isElement); }
/// <summary> /// Initializes the strategies and loads all strategies to state. Note: Skips initialization if already initialized. /// </summary> public void Initialize(bool includeTestStrategies) { using (LogGroup logGroup = LogGroup.StartDebug("Initializing the business strategies.")) { if (!StrategyState.IsInitialized) { StrategyInfo[] strategies = new StrategyInfo[] {}; if (IsCached) { LogWriter.Debug("Is cached. Loading from XML."); strategies = LoadStrategies(); } else { LogWriter.Debug("Is not cached. Scanning from type attributes."); strategies = FindStrategies(includeTestStrategies); Saver.SaveToFile(strategies); } Initialize(strategies); } else { LogWriter.Debug("Already initialized."); } } }
/// <summary> /// Creates a new instance of the specified type of entity. /// </summary> /// <param name="shortTypeName">The short name of the type of entity to create an instance of.</param> public override IEntity Create() { // TODO: Check if needed. Should be unnecessary ISubEntity entity = null; using (LogGroup logGroup = LogGroup.Start("Creating a new entity of type '" + TypeName + "'.", NLog.LogLevel.Debug)) { if (!EntityState.IsType(TypeName)) { throw new InvalidOperationException("The TypeName property needs to be set to the type of an entity. Invalid type: " + TypeName); } Type type = EntityState.GetType(TypeName); LogWriter.Debug("Authorisation required: " + RequireAuthorisation.ToString()); if (RequireAuthorisation) { AuthoriseCreateStrategy.New(TypeName).EnsureAuthorised(TypeName); } entity = (ISubEntity)base.Create(); entity.ID = Guid.NewGuid(); } return(entity); }
/// <summary> /// Retrieves the entities of the specified type. /// </summary> /// <returns></returns> public virtual T[] Index <T>() where T : IEntity { T[] entities = new T[] {}; using (LogGroup logGroup = LogGroup.Start("Indexing entities that have the specified reference.", NLog.LogLevel.Debug)) { LogWriter.Debug("Type name: " + typeof(T).ToString()); LogWriter.Debug("Enable paging: " + EnablePaging.ToString()); LogWriter.Debug("Require authorisation: " + RequireAuthorisation.ToString()); if (EnablePaging) { entities = DataAccess.Data.Indexer.GetPageOfEntities <T>(Location, SortExpression); } else { entities = DataAccess.Data.Indexer.GetEntities <T>(); } if (RequireAuthorisation) { AuthoriseIndexStrategy.New <T>().EnsureAuthorised(ref entities); } LogWriter.Debug("Entity count: " + entities.Length); AssignStrategies(entities); React(entities); } return(entities); }
public static MvcHtmlString PluploadDynamicPlaceholder <T>(this HtmlHelper <T> html, PluploadConfiguration configuration) { LogWriter.Debug("create plupload..."); PluploadContext.Instance.SetConfiguration(configuration); return(html.Action("PluploadDynamicLoader", "Plupload")); }
/// <summary> /// Counts the specified references. /// </summary> /// <param name="entityType"></param> /// <param name="entityID"></param> /// <param name="propertyName"></param> /// <returns>The total number of references counted.</returns> public override int CountEntitiesWithReference(Type entityType, Guid entityID, string propertyName, Type referencedEntityType, string mirrorPropertyName) { int count = 0; using (LogGroup logGroup = LogGroup.StartDebug("Querying the data store based on the provided parameters.")) { LogWriter.Debug("Entity type: " + entityType.FullName); LogWriter.Debug("Property name: " + propertyName); LogWriter.Debug("Entity ID: " + entityID); LogWriter.Debug("Mirror property name: " + mirrorPropertyName); LogWriter.Debug("Referenced entity type: " + referencedEntityType.FullName); Db4oDataStore store = (Db4oDataStore)GetDataStore(referencedEntityType); IObjectContainer container = store.ObjectContainer; Predicate matches = new MatchReferencePredicate(Provider, referencedEntityType, mirrorPropertyName, entityType, entityID, propertyName); IObjectSet os = store.ObjectContainer.Query(matches); count = os.Count; LogWriter.Debug("Total objects: " + count); } return(count); }
/// <summary> /// Gets the name of the data store that the provided entity is stored in. /// </summary> /// <param name="entity">The entity to get the data store name for.</param> /// <param name="throwErrorIfNotFound">A flag indicating whether an error should be thrown when no data store attribute is found.</param> /// <returns>The data store that the provided entity is stored in.</returns> static public string GetDataStoreName(IEntity entity, bool throwErrorIfNotFound) { if (entity == null) { throw new ArgumentNullException("entity"); } string dataStoreName = String.Empty; Type type = entity.GetType(); using (LogGroup logGroup = LogGroup.Start("Retrieving data store name for entity of type '" + type.ToString() + "'.", LogLevel.Debug)) { if (EntitiesUtilities.IsReference(entity)) { LogWriter.Debug("Provided entity is an EntityReference"); EntityReference reference = (EntityReference)entity; dataStoreName = GetDataStoreName(new string[] { reference.Type1Name, reference.Type2Name }); } else { LogWriter.Debug("Provided entity is NOT an EntityReference."); dataStoreName = GetDataStoreName(entity.GetType()); } LogWriter.Debug("Data store name: " + dataStoreName); } return(dataStoreName); }
static public Type GetEntityType(IEntity entity, PropertyInfo property) { Type type = null; using (LogGroup group = LogGroup.Start("Retrieving the type of entity being referenced by the provided property.", LogLevel.Debug)) { if (entity == null) { throw new ArgumentNullException("entity"); } if (property == null) { throw new ArgumentNullException("property"); } LogWriter.Debug("Entity type: " + entity.GetType().ToString()); LogWriter.Debug("Property name: " + property.Name); LogWriter.Debug("Property type: " + property.PropertyType.Name); type = EntitiesUtilities.GetReferenceType(entity, property); } if (type == null) { LogWriter.Debug("return type == null"); } else { LogWriter.Debug("return type == " + type.ToString()); } return(type); }
/// <summary> /// Index the entity with a references that matches the provided parameters. /// </summary> /// <param name="propertyName">The name of the property containing the references.</param> /// <param name="referencedEntityType">The type of the entity being referenced.</param> /// <param name="referencedEntityID">The ID of the entity being referenced.</param> /// <returns>The entity matching the provided parameters.</returns> public virtual IEntity[] IndexWithReference(string propertyName, string referencedEntityType, Guid referencedEntityID) { IEntity[] entities = new IEntity[] {}; using (LogGroup logGroup = LogGroup.Start("Indexing entities that have the specified reference.", NLog.LogLevel.Debug)) { LogWriter.Debug("Type name: " + TypeName); LogWriter.Debug("Property name: " + propertyName); LogWriter.Debug("Reference entity type: " + referencedEntityType); LogWriter.Debug("Referenced entity ID: " + referencedEntityID.ToString()); LogWriter.Debug("Enable paging: " + EnablePaging.ToString()); LogWriter.Debug("Require authorisation: " + RequireAuthorisation.ToString()); entities = (IEntity[])Reflector.InvokeGenericMethod(this, "IndexWithReference", new Type[] { EntityState.Entities[TypeName].GetEntityType() }, new object[] { propertyName, referencedEntityType, referencedEntityID }); if (RequireAuthorisation) { AuthoriseIndexStrategy.New(TypeName).EnsureAuthorised(ref entities); } React(entities); LogWriter.Debug("Entity count: " + entities.Length); } return(entities); }
// TODO: Check if function should be removed static public void StripReferences(IEntity entity) { using (LogGroup logGroup2 = LogGroup.Start("Clearing all the object references so that they don't cascade automatically.", LogLevel.Debug)) { if (entity is EntityReference) { ((EntityReference)entity).Deactivate(); } else { // Clear all the references from the entity once they're ready to be saved separately foreach (PropertyInfo property in entity.GetType().GetProperties()) { LogWriter.Debug("Property name: " + property.Name); LogWriter.Debug("Property type: " + property.PropertyType.ToString()); // If the property is a reference // OR the actual provided entity is a reference AND the property holds an IEntity instance if (EntitiesUtilities.IsReference(entity.GetType(), property.Name, property.PropertyType)) { LogWriter.Debug("Cleared property. (Set to null)"); Reflector.SetPropertyValue(entity, property.Name, null); } } } } }
public override void NavigateAfterUpdate() { using (LogGroup logGroup = LogGroup.Start("Navigating after a update operation.", NLog.LogLevel.Debug)) { if (DataSource == null) { throw new InvalidOperationException("The DataSource property isn't set."); } ISubEntity entity = (ISubEntity)DataSource; if (entity.Parent == null) { LogWriter.Debug("No parent found. Activating entity.Parent."); ActivateStrategy.New <ISubEntity>().Activate(entity, entity.ParentPropertyName); } if (entity.Parent == null) { throw new Exception("No parent assigned to entity."); } Navigator.Current.NavigateAfterOperation("View", entity.Parent); } }
/// <summary> /// Deletes the provided entity. /// </summary> /// <param name="entity"></param> public virtual void ExecuteDelete(IEntity entity) { using (LogGroup logGroup = LogGroup.Start("Deleting the provided entity.", NLog.LogLevel.Debug)) { if (entity == null) { throw new ArgumentNullException("entity"); } if (EnsureAuthorised(entity)) { if (entity == null) { LogWriter.Debug("Entity: [null]"); } else { LogWriter.Debug("Entity: " + entity.GetType().FullName); } Deleter.Delete(entity); LogWriter.Debug("Done"); // Display the result Result.Display(DynamicLanguage.GetEntityText("EntityDeleted", entity.ShortTypeName)); NavigateAfterDelete(entity); } } }
/// <summary> /// Prepares the provided entity for saving. /// </summary> /// <param name="entity">The entity to prepare for saving.</param> /// <param name="handleReferences">A value indicating whether to delete old references and save new references.</param> public override void PreSave(IEntity entity, bool handleReferences) { using (LogGroup logGroup = LogGroup.StartDebug("Preparing entity for saving: " + entity.GetType().ToString())) { if (entity == null) { throw new ArgumentNullException("entity"); } entity.PreStore(); // If the entity is NOT a reference object (ie. it's a standard entity) // then prepare the save. // If is IS a reference object the preparation is not needed and should be skipped if (!(entity is EntityReference)) { Type entityType = entity.GetType(); LogWriter.Debug("Entity type: " + entityType.ToString()); if (handleReferences) { // Maintain the entity references Provider.Referencer.MaintainReferences(entity); } LogWriter.Debug("Presave complete."); } } }
/// <summary> /// Creates a filter for the active data source based on the specified type. /// </summary> public override IDataFilter CreateFilter(Type filterType) { using (LogGroup logGroup = LogGroup.Start("Creating filter", NLog.LogLevel.Debug)) { LogWriter.Debug("Type: " + filterType.ToString()); if (filterType.Equals(typeof(PropertyFilter))) { LogWriter.Debug("Filter type supported."); return(new Db4oPropertyFilter()); } else if (filterType.Equals(typeof(ReferenceFilter))) { LogWriter.Debug("Filter type supported."); return(new Db4oReferenceFilter()); } else { LogWriter.Debug("Creation failed. " + filterType.ToString() + " isn't a supported filter."); throw new NotSupportedException(filterType.ToString() + " isn't yet supported."); } } }
protected async override Task<NodeResultStatus> PerformExecuteAsync(IExecutionContext<T> context) { if (!string.IsNullOrEmpty(ExecutedScript)) { LogWriter.Debug("ExecutedScript exists, running this script."); var result = new NodeResult{IsSuccess = true}; using (var scope = new ManagerScope()) { SetScriptIdIfEmpty(); var options = new ClearScript.Manager.ExecutionOptions { HostObjects = SetupHostObjects(context, result), HostTypes = SetupHostTypes() }; await scope.RuntimeManager.ExecuteAsync(ScriptId, ExecutedScript, options); if (!result.IsSuccess) { return NodeResultStatus.Failed; } } } LogWriter.Debug("ExecutedScript doesn't exist."); return NodeResultStatus.Succeeded; }
public virtual int SetNumber(ISubEntity entity) { using (LogGroup logGroup = LogGroup.Start("Setting the number of the new sub entity.", NLog.LogLevel.Debug)) { if (entity == null) { throw new ArgumentNullException("entity"); } if (entity.Parent == null) { throw new Exception("No parent is assigned to this item."); } IEntity parent = entity.Parent; ActivateStrategy.New(parent).Activate(parent, entity.ItemsPropertyName); ISubEntity[] items = Collection <ISubEntity> .ConvertAll(EntitiesUtilities.GetPropertyValue(parent, entity.ItemsPropertyName)); LogWriter.Debug("Existing items: " + items.Length.ToString()); entity.Number = items.Length + 1; LogWriter.Debug("Entity number: " + entity.Number.ToString()); } return(entity.Number); }
/// <summary> /// Prepares the edit form with the entity specified by the ID or unique key in the query string. /// </summary> /// <returns>The entity specified in the query string.</returns> public virtual IEntity PrepareEdit() { IEntity entity = null; using (LogGroup logGroup = LogGroup.Start("Preparing to edit an entity.", NLog.LogLevel.Debug)) { Guid id = GetID(); string uniqueKey = GetUniqueKey(); if (id != Guid.Empty) { LogWriter.Debug("ID: " + id.ToString()); entity = PrepareEdit(id); } else if (uniqueKey != String.Empty) { LogWriter.Debug("Unique key: " + uniqueKey); entity = PrepareEdit(uniqueKey); } else { throw new InvalidOperationException("Cannot edit entity. No identifier found."); } } return(entity); }
public IEntity GetParent(string parentTypeName, Guid parentID, string parentUniqueKey) { IEntity parent = null; using (LogGroup logGroup = LogGroup.Start("Retrieving the parent for entity being created.", NLog.LogLevel.Debug)) { LogWriter.Debug("Parent ID: " + parentID.ToString()); LogWriter.Debug("Parent unique key: " + parentUniqueKey); LogWriter.Debug("Parent type: " + parentTypeName); IRetrieveStrategy retrieveStrategy = RetrieveStrategy.New(parentTypeName, RequireAuthorisation); if (parentUniqueKey != String.Empty) { parent = retrieveStrategy.Retrieve("UniqueKey", parentUniqueKey); } else if (parentID != Guid.Empty) { parent = retrieveStrategy.Retrieve("ID", parentID); } else { throw new Exception("No unique key or ID found for the parent."); } } return(parent); }
/// <summary> /// Updates the provided entity back to the data store. /// </summary> /// <param name="entity"></param> /// <returns>A bool value indicating the success of the update. If it fails it's due to the entity being invalid.</returns> public virtual bool ExecuteUpdate(IEntity entity) { bool didSucceed = false; using (LogGroup logGroup = LogGroup.Start("Updating the provided entity.", NLog.LogLevel.Debug)) { if (EnsureAuthorised()) { DataSource = entity; if (entity == null) { throw new ArgumentNullException("entity"); } // Update the entity if (Updater.Update(entity)) { Result.Display(DynamicLanguage.GetEntityText(EntityUpdatedLanguageKey, Command.TypeName)); didSucceed = true; } else { // Add the validation error to the result control Validation.DisplayError(entity); didSucceed = false; } } LogWriter.Debug("Did succeed: " + didSucceed.ToString()); } return(didSucceed); }