public override bool Execute() { using (BtsCatalogExplorer catalog = BizTalkCatalogExplorerFactory.GetCatalogExplorer()) { Application application = catalog.Applications[_applicationName]; if (application == null) { this.Log.LogError("Unable to find BizTalk application '{0}'.", _applicationName); return(false); } foreach (ITaskItem ti in _appsToReference) { Application appToRef = catalog.Applications[ti.ItemSpec]; if (appToRef == null) { this.Log.LogError("Unable to find BizTalk application '{0}' to reference from application '{1}'.", ti.ItemSpec, _applicationName); return(false); } this.Log.LogMessage("Adding reference to BizTalk application '{0}' from BizTalk application '{1}'.", _applicationName, ti.ItemSpec); application.AddReference(appToRef); } if (_appsToReference.Length > 0) { catalog.SaveChanges(); } this.Log.LogMessage("Finished adding application references to BizTalk application '{0}'.", _applicationName); } return(true); }
public override bool Execute() { try { using (BtsCatalogExplorer catalog = BizTalkCatalogExplorerFactory.GetCatalogExplorer()) { Application application = catalog.Applications[_applicationName]; if (application == null) { this.Log.LogError("Unable to find application '{0}' in catalog.", _applicationName); return(false); } // First, get all of the artifacts associated with the BizTalk application Dictionary <string, Dictionary <string, object> > artifacts = GetArtifactsWithDefaultAction(application); if (artifacts == null) { return(false); } // Next, reconcile the user-specified artifacts with the actual artifacts if (_artifacts != null) { foreach (ITaskItem ti in _artifacts) { if (!artifacts.ContainsKey(ti.ItemSpec)) { base.Log.LogWarning(_artifactName + " '" + ti.ItemSpec + "' does not exist in the BizTalk application."); continue; } Dictionary <string, object> metadata = artifacts[ti.ItemSpec] as Dictionary <string, object>; CopyMetadata(ti, metadata); string actionMetadataName = (_mode == ModeType.Deploy) ? "DeployAction" : "UndeployAction"; object actionMetadataValue = null; if (metadata.TryGetValue(actionMetadataName, out actionMetadataValue)) { metadata[ActionMetadataKey] = GetAction((string)actionMetadataValue); } } } // Finally, carry out the actions against the artifacts ControlArtifacts(catalog, application, artifacts); } return(true); } catch (Exception ex) { this.Log.LogErrorFromException(ex, false); return(false); } }
public override bool Execute() { this.Log.LogMessage("Checking for existence of BizTalk application '{0}'...", _applicationName); using (BtsCatalogExplorer catalog = BizTalkCatalogExplorerFactory.GetCatalogExplorer()) { Application application = catalog.Applications[_applicationName]; _appExists = (application != null); } if (_appExists) { this.Log.LogMessage("Found BizTalk application '{0}'.", _applicationName); } else { this.Log.LogMessage("Did not find BizTalk application '{0}'.", _applicationName); } return(true); }
public override bool Execute() { int retryCount = 5; if ((string.IsNullOrEmpty(_startOption) && string.IsNullOrEmpty(_stopOption)) || (!string.IsNullOrEmpty(_startOption) && !string.IsNullOrEmpty(_stopOption))) { this.Log.LogError("Please specify either StartOption or StopOption."); return(false); } using (BtsCatalogExplorer catalog = BizTalkCatalogExplorerFactory.GetCatalogExplorer()) { Application application = catalog.Applications[_applicationName]; if (application == null) { this.Log.LogError("Unable to find application '{0}' in catalog.", _applicationName); return(false); } ApplicationStartOption startOption = 0; ApplicationStopOption stopOption = 0; if (!string.IsNullOrEmpty(_startOption)) { startOption = ParseStartEnum(_startOption); } else { stopOption = ParseStopEnum(_stopOption); } for (int i = 0; i < retryCount; i++) { this.Log.LogMessage("(Retry count {0})", i); try { if (startOption != 0) { this.Log.LogMessage("Starting {0} application...", _applicationName); application.Start(startOption); } else { this.Log.LogMessage("Stopping {0} application...", _applicationName); application.Stop(stopOption); } catalog.SaveChanges(); break; } catch (Exception ex) { catalog.DiscardChanges(); if (!ex.Message.Contains("deadlocked")) { this.Log.LogErrorFromException(ex, false); return(false); } } } } return(true); }