private string GetXmlContent(BtsOrchestration orchestration) { StringBuilder sb = new StringBuilder(); try { string xmlContent = string.Empty; string path = Microsoft.BizTalk.Gac.Gac.GetAssemblyPath(orchestration.BtsAssembly.Name); BizTalkAssembly assembly1 = new BizTalkAssembly(); Microsoft.BizTalk.Deployment.Assembly.BtsAssemblyManager manager = new Microsoft.BizTalk.Deployment.Assembly.BtsAssemblyManager(path, assembly1); IBizTalkAssembly ass = (IBizTalkAssembly)manager.AssemblyBase; IEnumerator orList = ass.Orchestrations; while (orList.MoveNext()) { IBizTalkOrchestration or = (IBizTalkOrchestration)orList.Current; xmlContent = or.XmlContent; xmlContent = xmlContent.Replace("'", "\""); sb.AppendLine("#if __DESIGNER_DATA"); sb.AppendLine("#error Do not define __DESIGNER_DATA."); sb.AppendLine(xmlContent); sb.AppendLine("#endif // __DESIGNER_DATA"); } } catch (Exception exe) { sb.Append("Can not load Odx content: " + exe.Message); } return(sb.ToString()); }
public Orchestration(BtsOrchestration orchestration) { if (orchestration == null) { throw new ArgumentNullException("orchestration"); } BizTalkOrchestration = orchestration; }
/// <summary> /// extract orchestration XML from BizTalk runtime using application and orchestration name /// </summary> /// <param name="appName">application name</param> /// <param name="orchName">orchestration name</param> private void ExtractOrchestrationFromRuntimeAssembly(string appName, string orchName) { _btsApp = ApplicationS.GetApplication(appName); _thisOrch = _btsApp.Orchestrations[orchName]; _name = _thisOrch.FullName; #if DEBUG Debug.Assert(null != _btsApp); Debug.Assert(null != _thisOrch); #endif try { Type type1 = BtsAssemblyFactory.GetAssembly(_thisOrch.BtsAssembly.DisplayName).GetType(_thisOrch.FullName); object obj = type1.GetField("_symInfo", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static). GetValue(type1); ViewData = new XmlDocument(); ViewData.LoadXml((string) obj); //artifact data - the xml representation of the orchestration obj = type1.GetField("_symODXML", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static). GetValue(type1); ArtifactData = new XmlDocument(); ArtifactData.LoadXml(((string) obj).Replace("\n", "")); //assign Module XmlNode object for gathering BtsOrch properties //_module = _xmlArtifactData.SelectSingleNode("om:Element[@Name='Module']"); GetCommonOrchProperties(); #if DEBUG //Debug.WriteLine(obj.ToString()); var fields = type1.GetFields(); foreach (var fi in fields) { Debug.WriteLine(String.Format("[{0}] field {1} ", fi.FieldType, fi.Name)); } #endif } catch (FileLoadException fle) { #if DEBUG Debug.WriteLine(fle.FusionLog); Debugger.Break(); #endif } catch (Exception e) { #if DEBUG Debug.WriteLine(e.Message); Debugger.Break(); #endif } }
private void AddRange(List<BtsOrchestration> computedList, BtsOrchestration btsOrchestration) { foreach (BtsOrchestration orch in btsOrchestration.InvokedOrchestrations) { if (computedList.All(x => x.FullName != orch.FullName)) { computedList.Add(orch); } AddRange(computedList, orch); } }
protected override bool ControlIndividualArtifact(string name, Dictionary <string, object> metadata, BtsCatalogExplorer catalog, Application app) { BtsOrchestration inst = app.Orchestrations[name]; OrchestrationStatus status = inst.Status; ActionType action = (ActionType)metadata[ActionMetadataKey]; switch (action) { case ActionType.Enlist: if (status == OrchestrationStatus.Unenlisted) { this.Log.LogMessage("Enlisting orchestration '" + name + "'..."); inst.Status = OrchestrationStatus.Enlisted; return(true); } break; case ActionType.Unenlist: if (status != OrchestrationStatus.Unenlisted) { this.Log.LogMessage("Unenlisting orchestration '" + name + "'..."); inst.AutoTerminateInstances = false; inst.Status = OrchestrationStatus.Unenlisted; return(true); } break; case ActionType.Start: if (status != OrchestrationStatus.Started) { StartOrchestration(name, metadata, catalog, inst); return(true); } break; case ActionType.Stop: if (status == OrchestrationStatus.Started) { this.Log.LogMessage("Stopping orchestration '" + name + "'..."); // No auto disable receive locations // Auto suspend running instances inst.AutoSuspendRunningInstances = true; inst.Status = OrchestrationStatus.Enlisted; return(true); } break; } return(false); }
public BtsOrchestrationHelper(BtsOrchestration orchestration) { AssemblyQualifiedName = orchestration.AssemblyQualifiedName; AutoResumeSuspendedInstances = orchestration.AutoResumeSuspendedInstances; AutoSuspendRunningInstances = orchestration.AutoSuspendRunningInstances; AutoTerminateInstances = orchestration.AutoTerminateInstances; Description = orchestration.Description; FullName = orchestration.FullName; Status = orchestration.Status.ToString(); HostName = orchestration.Host != null ? orchestration.Host.Name : ""; Hostype = orchestration.Host != null?orchestration.Host.Type.ToString() : ""; OdxXmlView = this.GetXmlContent(orchestration); }
//TODO: clean up futher public static Bitmap GetOrchestationImage(OrchestrationOverviewImage orchestrationImage, BtsOrchestration orchestration) { var ov = new OrchViewer(); string text1 = string.Empty; if (!string.IsNullOrEmpty(orchestrationImage.ViewData)) { XLANGView.XsymFile.ReadXsymFromString(ov.Root, orchestrationImage.ViewData, false, ref text1); var ps = new PageSettings(); Rectangle maxRect = GetOrchImageSize(orchestrationImage); const int maxWidth = 6000; const int maxHeight = 6000; int w = maxRect.Width, h = maxRect.Height; float scaleX = 1, scaleY = 1; if (w > maxWidth) { scaleX = maxWidth / (float)w; scaleY = scaleX; w = maxWidth; h = (int)Math.Floor(h * scaleY); } if (h > maxHeight) { scaleY *= maxWidth / (float)h; scaleX *= scaleY; h = maxHeight; w = (int)Math.Floor(w * scaleX); } var realBmp = new Bitmap(w, h); var realGraphic = Graphics.FromImage(realBmp); realGraphic.ScaleTransform(scaleX, scaleY); realGraphic.SmoothingMode = SmoothingMode.AntiAlias; realGraphic.InterpolationMode = InterpolationMode.HighQualityBicubic; var realArgs = new PrintPageEventArgs( realGraphic, maxRect, maxRect, ps); // Set background colour //realGraphic.FillRectangle(new SolidBrush(Color.White), maxRect); realGraphic.Clear(Color.White); // Draw the orch image ov.DoPrintWithSize(realArgs); //bool drawHotspots = false; //try //{ // // Decide whether we need hotspots or not // object drawHotspotsObj = new AppSettingsReader().GetValue("ShowHotSpots", typeof(int)); // if (drawHotspotsObj != null) // { // int tmp = Convert.ToInt32(drawHotspotsObj); // if (tmp == 1) drawHotspots = true; // } //} //catch(Exception ex) //{ // ErrorLogger.Log(TraceEventType.Error, ex.NestedExceptionMessage()); //} GetSelectionAreas(realGraphic, ov.Root, orchestrationImage); ps = null; realArgs = null; ov.Dispose(); realGraphic.Dispose(); return realBmp; } else { const string errorText = "Unable to load image for orchestration"; var f = new Font("Arial", 9, FontStyle.Bold); int fontHeight = (int)f.GetHeight() + 5; int errorWidth = MeasureStringWidth(errorText, f); int nameWidth = MeasureStringWidth(orchestration.FullName, f); int w = Math.Max(errorWidth, nameWidth) + 50; const int h = 100; var titleBrush = new SolidBrush(Color.Black); var bmp = new Bitmap(w, h); var g = Graphics.FromImage(bmp); g.FillRectangle(new SolidBrush(Color.White), 0, 0, w, h); g.DrawString(errorText, f, titleBrush, (bmp.Width / 2) - (errorWidth / 2), 10); g.DrawString(orchestration.FullName, f, titleBrush, (bmp.Width / 2) - (nameWidth / 2), 10 + fontHeight); return bmp; } }
public static Bitmap GetOrchestationImage(BtsOrchestration orchestration) { return GetOrchestationImage(orchestration); }
public OrchestrationOverviewImage(BtsOrchestration orchestration) { _orchestration = orchestration; LoadInternalData(orchestration.BtsAssembly.DisplayName); }
public static string Id(this BtsOrchestration omOrchestration) { return(omOrchestration.FullName); }
private int CheckDepenciesPrevious(BtsOrchestration invokedOrchestration) { int index = -1; foreach (BtsOrchestration orchestration in invokedOrchestration.InvokedOrchestrations) { for (int i = 0; i < _traversedOrchestrations.Count; i++) { if (_traversedOrchestrations[i].FullName == orchestration.FullName) { if ((index != -1 && index > i) || index == -1) { index = i; } } } } return index; }
public OrchestrationViewer(BtsOrchestration orchestration) { InitializeComponent(); this.BtsOrchestration = orchestration; this.OrchToView = this.GetOrchestration(); }
public static Bitmap GetOrchestationImage(BtsOrchestration orchestration) { return(GetOrchestationImage(orchestration)); }
//TODO: clean up futher public static Bitmap GetOrchestationImage(OrchestrationOverviewImage orchestrationImage, BtsOrchestration orchestration) { var ov = new OrchViewer(); string text1 = string.Empty; if (!string.IsNullOrEmpty(orchestrationImage.ViewData)) { XLANGView.XsymFile.ReadXsymFromString(ov.Root, orchestrationImage.ViewData, false, ref text1); var ps = new PageSettings(); Rectangle maxRect = GetOrchImageSize(orchestrationImage); const int maxWidth = 6000; const int maxHeight = 6000; int w = maxRect.Width, h = maxRect.Height; float scaleX = 1, scaleY = 1; if (w > maxWidth) { scaleX = maxWidth / (float)w; scaleY = scaleX; w = maxWidth; h = (int)Math.Floor(h * scaleY); } if (h > maxHeight) { scaleY *= maxWidth / (float)h; scaleX *= scaleY; h = maxHeight; w = (int)Math.Floor(w * scaleX); } var realBmp = new Bitmap(w, h); var realGraphic = Graphics.FromImage(realBmp); realGraphic.ScaleTransform(scaleX, scaleY); realGraphic.SmoothingMode = SmoothingMode.AntiAlias; realGraphic.InterpolationMode = InterpolationMode.HighQualityBicubic; var realArgs = new PrintPageEventArgs( realGraphic, maxRect, maxRect, ps); // Set background colour //realGraphic.FillRectangle(new SolidBrush(Color.White), maxRect); realGraphic.Clear(Color.White); // Draw the orch image ov.DoPrintWithSize(realArgs); //bool drawHotspots = false; //try //{ // // Decide whether we need hotspots or not // object drawHotspotsObj = new AppSettingsReader().GetValue("ShowHotSpots", typeof(int)); // if (drawHotspotsObj != null) // { // int tmp = Convert.ToInt32(drawHotspotsObj); // if (tmp == 1) drawHotspots = true; // } //} //catch(Exception ex) //{ // ErrorLogger.Log(TraceEventType.Error, ex.NestedExceptionMessage()); //} GetSelectionAreas(realGraphic, ov.Root, orchestrationImage); ps = null; realArgs = null; ov.Dispose(); realGraphic.Dispose(); return(realBmp); } else { const string errorText = "Unable to load image for orchestration"; var f = new Font("Arial", 9, FontStyle.Bold); int fontHeight = (int)f.GetHeight() + 5; int errorWidth = MeasureStringWidth(errorText, f); int nameWidth = MeasureStringWidth(orchestration.FullName, f); int w = Math.Max(errorWidth, nameWidth) + 50; const int h = 100; var titleBrush = new SolidBrush(Color.Black); var bmp = new Bitmap(w, h); var g = Graphics.FromImage(bmp); g.FillRectangle(new SolidBrush(Color.White), 0, 0, w, h); g.DrawString(errorText, f, titleBrush, (bmp.Width / 2) - (errorWidth / 2), 10); g.DrawString(orchestration.FullName, f, titleBrush, (bmp.Width / 2) - (nameWidth / 2), 10 + fontHeight); return(bmp); } }
private bool AreAllPortsBound(BtsOrchestration oInstance) { bool portBoundFlag = true; foreach(OrchestrationPort port in oInstance.Ports) { if (port.ReceivePort == null && port.SendPort == null && port.SendPortGroup == null) { portBoundFlag = false; break; } } return portBoundFlag; }
private void StartOrchestration(string name, Dictionary <string, object> metadata, BtsCatalogExplorer catalog, BtsOrchestration inst) { bool autoResumeSuspended = false; object autoResumeSuspendedStr = null; if (metadata.TryGetValue("AutoResumeInstances", out autoResumeSuspendedStr)) { bool.TryParse((string)autoResumeSuspendedStr, out autoResumeSuspended); } this.Log.LogMessage("Starting orchestration '" + name + "'..."); // No auto enable receive locations // No auto resume service instances // No auto start send ports inst.AutoResumeSuspendedInstances = autoResumeSuspended; inst.Status = OrchestrationStatus.Started; }
public Orchestration(BtsOrchestration orchestration) { BizTalkOrchestration = orchestration ?? throw new ArgumentNullException(nameof(orchestration)); }