Exemplo n.º 1
0
        private void ImportFromMsi()
        {
            if (this.MsiPath == null)
            {
                // -Package           Required. The path and file name of the Windows Installer package.
                this.Log.LogError("MSI source is required");
                return;
            }

            this.LogTaskMessage(string.Format(CultureInfo.InvariantCulture, "Importing from {0}", this.MsiPath.ItemSpec));

            if (string.IsNullOrEmpty(this.Application))
            {
                // -ApplicationName   Optional. The name of the BizTalk application.
                this.Application = this.explorer.DefaultApplication.Name;
                this.LogTaskMessage(string.Format(CultureInfo.InvariantCulture, "Using default application {0}", this.Application));
            }

            // create application if it doesn't exist
            if (!this.CheckExists(this.Application))
            {
                OM.Application newapp = this.explorer.AddNewApplication();
                newapp.Name = this.Application;
                this.explorer.SaveChanges();
                this.LogTaskMessage(string.Format(CultureInfo.InvariantCulture, "Creating new application {0}", this.Application));
            }

            using (Group group = new Group())
            {
                group.DBName   = this.Database;
                group.DBServer = this.DatabaseServer;

                Microsoft.BizTalk.ApplicationDeployment.Application appl = group.Applications[this.Application];

                // used to specify custom properties for import, i.e. TargetEnvironment
                IDictionary <string, object> requestProperties = null;
                if (!string.IsNullOrEmpty(this.Environment))
                {
                    // -Environment       Optional. The environment to deploy.
                    requestProperties = new Dictionary <string, object> {
                        { "TargetEnvironment", this.Environment }
                    };
                    this.LogTaskMessage(string.Format(CultureInfo.InvariantCulture, "Target environment {0} specified", this.Environment));
                }

                // the overload that takes request properties also requires this
                IInstallPackage      package = DeploymentUnit.ScanPackage(this.MsiPath.ItemSpec);
                ICollection <string> applicationReferences = package.References;

                // -Overwrite         Optional. Update existing resources. If not specified and resource exists, import will fail.
                appl.Import(this.MsiPath.ItemSpec, requestProperties, applicationReferences, this.Overwrite);
                this.LogTaskMessage(string.Format(CultureInfo.InvariantCulture, "Successfully imported {0} into application {1}", this.MsiPath.ItemSpec, this.Application));
            }
        }
Exemplo n.º 2
0
        private bool CheckExists(string applicationName)
        {
            this.LogTaskMessage(MessageImportance.Low, string.Format(CultureInfo.CurrentCulture, "Checking whether Application exists: {0}", applicationName));
            this.app = this.explorer.Applications[applicationName];
            if (this.app != null)
            {
                this.LogTaskMessage(MessageImportance.Low, string.Format(CultureInfo.CurrentCulture, "Application exists: {0}", applicationName));
                this.Exists = true;
                return(true);
            }

            this.LogTaskMessage(MessageImportance.Low, string.Format(CultureInfo.CurrentCulture, "Application does not exist: {0}", applicationName));
            return(false);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Retrieve send port information for checked applications
        /// </summary>
        private void GetSendPorts()
        {
            // Clear the checkbox list
            tvSendPorts.Nodes.Clear();

            // Display for checked BizTalk applications
            foreach (var btsAppItem in chkBtsAppList.CheckedItems)
            {
                TreeNode tnRoot = tvSendPorts.Nodes.Add(btsAppItem.ToString());

                // Get a reference to the BizTalk app
                Microsoft.BizTalk.ExplorerOM.Application app = _btsExp.Applications[btsAppItem.ToString()];
                foreach (SendPort sp in app.SendPorts)
                {
                    progressBtsAppInfo.PerformStep();

                    TreeNode tn = tnRoot.Nodes.Add(sp.Name);
                    if (sp.PrimaryTransport != null)
                    {
                        tn.Nodes.Add(string.Format("{0} ({1})", sp.PrimaryTransport.TransportType.Name, sp.PrimaryTransport.Address));
                    }
                    if (sp.SendPipeline != null)
                    {
                        TreeNode tnPLC = tn.Nodes.Add(sp.SendPipeline.FullName);

                        // Add the pipeline component info
                        GetPipelineComponentInfo(tnPLC, sp.SendPipelineData);
                    }

                    if (sp.OutboundTransforms != null)
                    {
                        TreeNode tnMap = tn.Nodes.Add("Transforms");
                        foreach (Transform map in sp.OutboundTransforms)
                        {
                            tnMap.Nodes.Add(map.FullName);
                        }
                    }
                    // Filter is in XML (binding) format, convert it to readable text
                    if (!string.IsNullOrEmpty(sp.Filter))
                    {
                        TreeNode tnSub = tn.Nodes.Add("Subscriptions");
                        tnSub.Nodes.Add(ProcessSubscriptionFilter(sp.Filter, ""));
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void ConfigureReference()
        {
            if (string.IsNullOrEmpty(this.Application))
            {
                this.Log.LogError("Application is required");
                return;
            }

            if (!this.CheckExists(this.Application))
            {
                this.Log.LogError(string.Format(CultureInfo.CurrentCulture, "Application not found: {0}", this.Application));
                return;
            }

            this.app = this.explorer.Applications[this.Application];
            foreach (ITaskItem item in this.References)
            {
                OM.Application refApp = this.explorer.Applications[item.ItemSpec];
                if (refApp != null)
                {
                    switch (this.TaskAction)
                    {
                    case RemoveReferenceTaskAction:
                        this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Removing Referenced Application: {0} from: {1}", item.ItemSpec, this.Application));
                        this.app.RemoveReference(refApp);
                        break;

                    case AddReferenceTaskAction:
                        this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Adding Referenced Application: {0} from: {1}", item.ItemSpec, this.Application));
                        this.app.AddReference(refApp);
                        break;
                    }
                }
                else
                {
                    Log.LogError(string.Format(CultureInfo.CurrentCulture, "Referenced Application not found: {0}", item.ItemSpec));
                    return;
                }
            }

            this.explorer.SaveChanges();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Retrieve receive port information for checked applications
        /// </summary>
        private void GetReceivePorts()
        {
            // Clear the checkbox list
            tvReceivePorts.Nodes.Clear();

            // Display for checked BizTalk applications
            foreach (var btsAppItem in chkBtsAppList.CheckedItems)
            {
                TreeNode tnRoot = tvReceivePorts.Nodes.Add(btsAppItem.ToString());

                // Get a reference to the BizTalk app
                Microsoft.BizTalk.ExplorerOM.Application app = _btsExp.Applications[btsAppItem.ToString()];
                foreach (ReceivePort rp in app.ReceivePorts)
                {
                    progressBtsAppInfo.PerformStep();

                    TreeNode tn = tnRoot.Nodes.Add(rp.Name);
                    if (rp.InboundTransforms != null)
                    {
                        TreeNode tnMap = tn.Nodes.Add("Transforms");

                        foreach (Transform map in rp.InboundTransforms)
                        {
                            tnMap.Nodes.Add(map.FullName);
                        }
                    }
                    if (rp.ReceiveLocations != null)
                    {
                        TreeNode tnRLs = tn.Nodes.Add("Receive Locations");
                        foreach (ReceiveLocation rl in rp.ReceiveLocations)
                        {
                            TreeNode tnRL = tnRLs.Nodes.Add(rl.Name);
                            tnRL.Nodes.Add(string.Format("{0} ({1})", rl.TransportType.Name, rl.Address));
                            TreeNode tnPL = tnRL.Nodes.Add(rl.ReceivePipeline.FullName);

                            GetPipelineComponentInfo(tnPL, rl.ReceivePipelineData);
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        private void Create()
        {
            if (this.Applications == null)
            {
                this.Log.LogError("Applications is required");
                return;
            }

            foreach (ITaskItem appl in this.Applications)
            {
                this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Application: {0} - {1}", appl.ItemSpec, this.TaskAction));
                if (this.CheckExists(appl.ItemSpec))
                {
                    if (this.Force)
                    {
                        this.DeleteApplication(appl);
                        this.explorer.Refresh();
                    }
                    else
                    {
                        this.Log.LogError(string.Format(CultureInfo.CurrentCulture, "Application already exists: {0}. Set Force to true to delete the Application.", appl.ItemSpec));
                        return;
                    }
                }

                OM.Application newapp = this.explorer.AddNewApplication();
                newapp.Name        = appl.ItemSpec;
                newapp.Description = appl.GetMetadata("Description");
                if (appl.GetMetadata("Default") == "true")
                {
                    this.explorer.DefaultApplication = newapp;
                }
            }

            this.explorer.SaveChanges();
        }
        private void LoadAppTreeView()
        {
            string applicationName = comboBoxAppList.Text;

            Microsoft.BizTalk.ExplorerOM.Application application = appCollection[applicationName];
            ClearView();
            if (application != null)
            {
                TreeNode parentNode = treeView1.Nodes.Add("Application");
                parentNode.Tag                = application;
                parentNode.ImageIndex         = 0;
                parentNode.SelectedImageIndex = 0;
                if (application.Assemblies.Count > 0)
                {
                    TreeNode assembliesNode = parentNode.Nodes.Add("Assemblies");
                    assembliesNode.ImageIndex         = 1;
                    assembliesNode.SelectedImageIndex = 1;

                    var qassembly = from assembly in application.Assemblies.Cast <Microsoft.BizTalk.ExplorerOM.BtsAssembly>()
                                    orderby assembly.DisplayName
                                    select assembly;

                    foreach (Microsoft.BizTalk.ExplorerOM.BtsAssembly assembly in qassembly.ToList())
                    {
                        TreeNode assemblyNode = assembliesNode.Nodes.Add(assembly.DisplayName);
                        assemblyNode.Tag                = assembly;
                        assemblyNode.ImageIndex         = 1;
                        assemblyNode.SelectedImageIndex = 1;
                        // Load Orchestrations
                        if (assembly.Orchestrations.Count > 0)
                        {
                            TreeNode orchestrationsNode = assemblyNode.Nodes.Add("Orchestrations");
                            orchestrationsNode.ImageIndex         = 2;
                            orchestrationsNode.SelectedImageIndex = 2;
                            var q = from orchestration in assembly.Orchestrations.Cast <Microsoft.BizTalk.ExplorerOM.BtsOrchestration>()
                                    orderby orchestration.FullName
                                    select orchestration;


                            foreach (Microsoft.BizTalk.ExplorerOM.BtsOrchestration orchestration in q.ToList())
                            {
                                TreeNode node = orchestrationsNode.Nodes.Add(orchestration.FullName);

                                node.ImageIndex         = 2;
                                node.SelectedImageIndex = 2;
                                //BtsOrchestrationHelper orch = new BtsOrchestrationHelper(orchestration);
                                node.Tag = orchestration;
                            }
                        }

                        // Load Schemas
                        if (assembly.Schemas.Count > 0)
                        {
                            TreeNode schemasNode = assemblyNode.Nodes.Add("Schemas");
                            schemasNode.ImageIndex         = 6;
                            schemasNode.SelectedImageIndex = 6;
                            var q = from schema in assembly.Schemas.Cast <Microsoft.BizTalk.ExplorerOM.Schema>()
                                    orderby schema.FullName
                                    select schema;

                            foreach (Microsoft.BizTalk.ExplorerOM.Schema schema in q.ToList())
                            {
                                string   nodeName = string.IsNullOrEmpty(schema.RootName) ? schema.FullName : string.Format("{0}+{1}", schema.FullName, schema.RootName);
                                TreeNode node     = schemasNode.Nodes.Add(nodeName);
                                node.Tag                = schema;
                                node.ImageIndex         = 6;
                                node.SelectedImageIndex = 6;
                            }
                        }

                        // Load Pipelines
                        if (assembly.Pipelines.Count > 0)
                        {
                            TreeNode pipelinesNode = assemblyNode.Nodes.Add("Pipelines");
                            pipelinesNode.ImageIndex         = 5;
                            pipelinesNode.SelectedImageIndex = 5;
                            var q = from pipeline in assembly.Pipelines.Cast <Microsoft.BizTalk.ExplorerOM.Pipeline>()
                                    orderby pipeline.FullName
                                    select pipeline;

                            foreach (Microsoft.BizTalk.ExplorerOM.Pipeline pipeline in q.ToList())
                            {
                                TreeNode     node        = pipelinesNode.Nodes.Add(pipeline.FullName);
                                PipelineInfo pipelineTag = new PipelineInfo(pipeline);
                                node.Tag                = pipelineTag;
                                node.ImageIndex         = 5;
                                node.SelectedImageIndex = 5;
                            }
                        }


                        // Load transforms
                        if (assembly.Transforms.Count > 0)
                        {
                            TreeNode transformsNode = assemblyNode.Nodes.Add("Maps");
                            transformsNode.ImageIndex         = 3;
                            transformsNode.SelectedImageIndex = 3;
                            var q = from transform in assembly.Transforms.Cast <Microsoft.BizTalk.ExplorerOM.Transform>()
                                    orderby transform.FullName
                                    select transform;

                            foreach (Microsoft.BizTalk.ExplorerOM.Transform transform in q.ToList())
                            {
                                TreeNode node = transformsNode.Nodes.Add(transform.FullName);
                                node.Tag                = transform;
                                node.ImageIndex         = 3;
                                node.SelectedImageIndex = 3;
                            }
                        }
                    }
                }
                if (listPolicy.Count > 0)
                {
                    TreeNode policyNode = parentNode.Nodes.Add("Policies");
                    policyNode.Tag                = listPolicy;
                    policyNode.ImageIndex         = 4;
                    policyNode.SelectedImageIndex = 4;
                    foreach (BreRuleSetInfo item in listPolicy)
                    {
                        TreeNode ruleNode = policyNode.Nodes.Add(string.Format("{0} - Version {1}.{2}", item.Name, item.MajorRevision.ToString(), item.MinorRevision.ToString()));

                        ruleNode.Tag                = item;
                        ruleNode.ImageIndex         = 4;
                        ruleNode.SelectedImageIndex = 4;
                    }
                }
            }
            ExpandToLevel(this.treeView1.Nodes, 2);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Read the application information and export it in CSV format
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExport_Click(object sender, EventArgs e)
        {
            // Format will be:
            // <Application Name>
            // <Receive Port Name>
            //                      <Transforms>
            // <Receive Locations>, <Transport Type>, <Address>, <Pipeline Info>
            //
            // <Send Port Name>
            //                      <Transforms>
            //                      <Pipeline Info>

            // Container for the export

            if (chkBtsAppList.CheckedItems.Count == 0)
            {
                MessageBox.Show("No data to export, no BizTalk applications are selected.", "No Export", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            foreach (var btsAppItem in chkBtsAppList.CheckedItems)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append(string.Format("Export for BizTalk Application {0}", btsAppItem) + Environment.NewLine);

                // Get a reference to the BizTalk app
                Microsoft.BizTalk.ExplorerOM.Application app = _btsExp.Applications[btsAppItem.ToString()];

                // First the receive ports
                if (app.ReceivePorts.Count != 0)
                {
                    sb.Append("Receive Ports:" + Environment.NewLine);
                }
                foreach (ReceivePort rp in app.ReceivePorts)
                {
                    sb.Append(string.Format("{0},Map Name:,Source Schema:,Target Schema:", rp.Name) + Environment.NewLine);
                    if (rp.InboundTransforms != null)
                    {
                        foreach (Transform map in rp.InboundTransforms)
                        {
                            sb.Append(string.Format(",{0},{1},{2}", map.FullName, map.SourceSchema.FullName, map.TargetSchema.FullName) + Environment.NewLine);
                        }
                    }
                    if (rp.ReceiveLocations.Count != 0)
                    {
                        sb.Append(string.Format(",Receive Location:,Transport Type:,Address:") + Environment.NewLine);
                        foreach (ReceiveLocation rl in rp.ReceiveLocations)
                        {
                            sb.Append(string.Format(",{0},{1},{2},{3}", rl.Name, rl.TransportType.Name, rl.Address, rl.ReceivePipeline.FullName) + Environment.NewLine);
//                            GetPipelineComponentInfo(tnPL, rl.ReceivePipelineData);
                        }
                    }
                }

                // Now the Send ports
                if (app.SendPorts.Count != 0)
                {
                    sb.Append(Environment.NewLine + "Send Ports:" + Environment.NewLine);
                }
                foreach (SendPort sp in app.SendPorts)
                {
                    sb.Append(sp.Name + Environment.NewLine);

                    if (sp.OutboundTransforms != null)
                    {
                        foreach (Transform map in sp.OutboundTransforms)
                        {
                            sb.Append(string.Format(",{0},{1},{2}", map.FullName, map.SourceSchema.FullName, map.TargetSchema.FullName) + Environment.NewLine);
                        }
                    }
                    sb.Append(ProcessSubscriptionFilter(sp.Filter, ","));
                }
                // Write an export file per application
                // There is deliberately no Excel created to not have a dependency on the Excel library
                string filename = string.Format("BizTalk_Export_{0}_{1}_{2}_{3}.csv", tbSQLServer.Text, btsAppItem, DateTime.Now.ToString("MMddyyyy"), DateTime.Now.ToString("HHmmss"));
                File.WriteAllText(filename, sb.ToString());
            }
            MessageBox.Show("Data is exported to the folder of this executable.", "Export Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemplo n.º 9
0
        private void tvReceivePorts_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node.Parent == null)
            {
                return;
            }

            // Get the BizTalk application name
            string btsAppName = e.Node.Parent.Text;

            // Try to find the message flow of messages read from this location
            string rpName = e.Node.Text;

            // First read the transforms, the canonical output map is assumingly the format after the transform
            Microsoft.BizTalk.ExplorerOM.Application app = _btsExp.Applications[btsAppName];
            if (app == null)
            {
                return;
            }

            IList rcvMaps = app.ReceivePorts[rpName].InboundTransforms;

            if (rcvMaps != null)
            {
                foreach (Transform map in rcvMaps)
                {
                    string target = string.Format("{0}#{1}", map.TargetSchema.TargetNameSpace, map.TargetSchema.RootName);

                    // Next find the subscribers which have the BTS.ReceivePortName and/or the canonical as input map
                    foreach (var btsAppItem in chkBtsAppList.CheckedItems)
                    {
                        // Get a reference to the BizTalk app
                        Microsoft.BizTalk.ExplorerOM.Application appToSearch = _btsExp.Applications[btsAppItem.ToString()];
                        foreach (SendPort sp in appToSearch.SendPorts)
                        {
                            if (sp.OutboundTransforms != null)
                            {
                                foreach (Transform mapToCheck in sp.OutboundTransforms)
                                {
                                    string source = string.Format("{0}#{1}", mapToCheck.SourceSchema.TargetNameSpace, mapToCheck.SourceSchema.RootName);
                                    if (source == target)
                                    {
                                        // Found a send port with a mapping which has the target schema of the receive port as source schema!
                                        // Potentially this send port will output messages from the receive location!
                                        // Now check the subscription filter, which could exclude the receive location.
                                        string subscriptionFilter = ProcessSubscriptionFilter(sp.Filter, "");

                                        // Check if BTS.ReceivePortName is in there
                                        if (subscriptionFilter.Contains(string.Format("BTS.ReceivePortName == {0}", rpName)))
                                        {
                                            // Hit!
                                            MessageBox.Show("Hit on " + subscriptionFilter);
                                        }

                                        // Check if routing fields are
                                    }
                                }
                            }
                            else
                            {
                                // No outbound maps, just check the filter on the BTS.ReceivePortName
                                string subscriptionFilter = ProcessSubscriptionFilter(sp.Filter, "");
                                // Check if BTS.ReceivePortName is in there
                                if (subscriptionFilter.Contains(string.Format("BTS.ReceivePortName == {0}", rpName)))
                                {
                                    // Hit!
                                    MessageBox.Show("Hit on " + subscriptionFilter);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
        private bool CheckExists(string applicationName)
        {
            this.LogTaskMessage(MessageImportance.Low, string.Format(CultureInfo.CurrentCulture, "Checking whether Application exists: {0}", applicationName));
            this.app = this.explorer.Applications[applicationName];
            if (this.app != null)
            {
                this.LogTaskMessage(MessageImportance.Low, string.Format(CultureInfo.CurrentCulture, "Application exists: {0}", applicationName));
                this.Exists = true;
                return true;
            }

            this.LogTaskMessage(MessageImportance.Low, string.Format(CultureInfo.CurrentCulture, "Application does not exist: {0}", applicationName));
            return false;
        }
Exemplo n.º 11
0
        private void ConfigureReference()
        {
            if (string.IsNullOrEmpty(this.Application))
            {
                this.Log.LogError("Application is required");
                return;
            }

            if (!this.CheckExists(this.Application))
            {
                this.Log.LogError(string.Format(CultureInfo.CurrentCulture, "Application not found: {0}", this.Application));
                return;
            }

            this.app = this.explorer.Applications[this.Application];
            foreach (ITaskItem item in this.References)
            {
                OM.Application refApp = this.explorer.Applications[item.ItemSpec];
                if (refApp != null)
                {
                    switch (this.TaskAction)
                    {
                        case RemoveReferenceTaskAction:
                            this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Removing Referenced Application: {0} from: {1}", item.ItemSpec, this.Application));
                            this.app.RemoveReference(refApp);
                            break;
                        case AddReferenceTaskAction:
                            this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Adding Referenced Application: {0} from: {1}", item.ItemSpec, this.Application));
                            this.app.AddReference(refApp);
                            break;
                    }
                }
                else
                {
                    Log.LogError(string.Format(CultureInfo.CurrentCulture, "Referenced Application not found: {0}", item.ItemSpec));
                    return;
                }
            }

            this.explorer.SaveChanges();
        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
#if DEBUG
            System.Diagnostics.Debugger.Launch();
#endif
            if (args.Length < 3)
            {
                ShowHelp();
                Environment.ExitCode = 1;
                return;
            }
            string server    = args[0];
            string database  = args[1];
            string env       = args[2];
            string groupName = GetGroupName(env);
            if (string.IsNullOrEmpty(groupName))
            {
                ShowHelp();
                Environment.ExitCode = 1;
                return;
            }
            Group grp = new Group();
            grp.DBServer = server;
            grp.DBName   = database;
            try
            {
                Console.WriteLine("Initial upload to the DeploymentDb: '{0}'", bizilante.Helpers.LogDeployment.Utils.GetDeploymentDb());
                BtsCatalogExplorer btsExplorer = (BtsCatalogExplorer)grp.CatalogExplorer;
                Console.WriteLine(string.Format("Retrieving applications from {0}...", btsExplorer.ConnectionString));
                foreach (Microsoft.BizTalk.ApplicationDeployment.Application application in grp.Applications)
                {
                    Microsoft.BizTalk.ExplorerOM.Application app = btsExplorer.Applications[application.Name];
                    if (!app.IsSystem)
                    {
                        Console.WriteLine(string.Format("Initializing application {0}...", application.Name));
                        long id = bizilante.Helpers.LogDeployment.Utils.InsertIntoDeployment(
                            groupName,
                            env,
                            Environment.UserName,
                            DateTime.Now,
                            app.Name,
                            app.Description != null ? app.Description : "0.0.0.0",
                            "Initialisation",
                            string.Empty);
                        long id_package = bizilante.Helpers.LogDeployment.Utils.InsertIntoPackage(
                            id,
                            "Initial upload",
                            string.Empty,
                            string.Empty,
                            string.Empty,
                            string.Empty,
                            string.Empty,
                            string.Empty,
                            string.Empty,
                            application.Name);
                        string maxversion    = "0.0.0.0";
                        int    resourceCount = 0;
                        foreach (IResource resource in application.ResourceCollection)
                        {
                            if (resource.Properties.ContainsKey("IsSystem") && (bool)resource.Properties["IsSystem"])
                            {
                                break;
                            }
                            resourceCount++;
                            string str7 = GetResourceDisplayName(resource.ResourceType, resource.Luid, application.Name);
                            Console.WriteLine(string.Format("Resource: {0}", str7));
                            // We need to extract the resource CAB file
                            string        path     = Path.Combine(Path.GetTempPath(), application.Name);
                            DirectoryInfo di       = new DirectoryInfo(path);
                            string        filename = string.Empty;
                            string        version  = string.Empty;
                            if (((Resource)resource).Unpack(path))
                            {
                                // Get the corresponding file
                                if (resource.Properties.ContainsKey("DestinationLocation"))
                                {
                                    filename = (string)resource.Properties["DestinationLocation"];
                                    if (!string.IsNullOrEmpty(filename))
                                    {
                                        FileInfo fi = new FileInfo(filename);
                                        Console.WriteLine(string.Format("file: {0}", filename));
                                        FileInfo[] fis = di.GetFiles(fi.Name, SearchOption.AllDirectories);
                                        if (fis.Length > 0)
                                        {
                                            FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(fis[0].FullName);
                                            Console.WriteLine(string.Format("version: {0}", versionInfo.FileVersion));
                                            if (null != versionInfo.FileVersion)
                                            {
                                                version = versionInfo.FileVersion;
                                                if (IsVersionGreater(maxversion, version))
                                                {
                                                    maxversion = version;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            bizilante.Helpers.LogDeployment.Utils.InsertIntoFiles(
                                id_package,
                                resource.ResourceType,
                                resource.Luid,
                                filename,
                                version);
                            try
                            {
                                di.Delete(true);
                            }
                            catch { }
                        }
                        bizilante.Helpers.LogDeployment.Utils.SetEndDeployment(id, DateTime.Now, false, string.Empty);
                        bizilante.Helpers.LogDeployment.Utils.SetApplicationVersion(application.Name, maxversion);
                        Console.WriteLine(string.Format("Finished Initializing application {0}, version={1}", application.Name, maxversion));
                    }
                }
                Console.WriteLine("Finished Initializing");
                Environment.ExitCode = 0;
            }
            catch (Exception exception)
            {
                WriteError(string.Format("Error occured: {0}", exception.Message));
                Environment.ExitCode = 2;
            }
            finally
            {
                if (grp != null)
                {
                    grp.Dispose();
                }
            }
            Console.ReadLine();
        }