public void ThreadMonitorServiceBus(object data)
        {
            tc.InstrumentationKey = "7972aa41-5375-4134-8a9a-4ddf53a78f80";// "a22ec41f -0ffa-4bd8-a745-d982cf9c1268";

            tc.Context.User.Id                = Environment.UserName;
            tc.Context.Session.Id             = Guid.NewGuid().ToString();
            tc.Context.Device.OperatingSystem = Environment.OSVersion.ToString();

            tc.TrackEvent("ServiceBusWatcher");

            namespaceManager = Microsoft.ServiceBus.NamespaceManager.CreateFromConnectionString(connectionString);

            serviceBusHelper           = new ServiceBusHelper();
            serviceBusHelper.OnCreate += serviceBusHelper_OnCreate;
            serviceBusHelper.OnDelete += serviceBusHelper_OnDelete;

            var  serviceBusNamespace = GetServiceBusNamespace("Manual", connectionString);
            bool bFlag = serviceBusHelper.Connect(serviceBusNamespace);

            for (int iIndex = 0; iIndex < 6000; iIndex++)
            {
                tc.TrackEvent("GetEntities: " + (iIndex + 1));
                GetEntities(EntityType.All);

                System.Threading.Thread.Sleep(500);
            }

            Console.WriteLine("*******************");
            Console.WriteLine("* Report Complete *");
            Console.WriteLine("*******************");
        }
        public void ThreadMonitorServiceBus(/*object data*/)
        {
            tc.InstrumentationKey = "448255fe-beb0-44d9-a019-7a7353a3f39f";// "7972aa41-5375-4134-8a9a-4ddf53a78f80";// Ap6R7CCAr9qz7nQP6G0DqWUclkDMGI6oA/m+eSKTJqw=";

            tc.Context.User.Id                = Environment.UserName;
            tc.Context.Session.Id             = Guid.NewGuid().ToString();
            tc.Context.Device.OperatingSystem = Environment.OSVersion.ToString();

            tc.TrackEvent("ServiceBusWatcher");

            namespaceManager = Microsoft.ServiceBus.NamespaceManager.CreateFromConnectionString(connectionString);

            serviceBusHelper = new ServiceBusHelper();
            //serviceBusHelper.OnCreate += serviceBusHelper_OnCreate;
            //serviceBusHelper.OnDelete += serviceBusHelper_OnDelete;

            var  serviceBusNamespace = serviceBusHelper.GetServiceBusNamespace("Manual", connectionString);
            bool bFlag = serviceBusHelper.Connect(serviceBusNamespace);

            tc.TrackEvent("GetEntities");
            iGlobalVMRes = GetEntities();

            Console.WriteLine("*******************");
            Console.WriteLine("* Report Complete *");
            Console.WriteLine("*******************");
        }
 private static void CreateSubsciption()
 {
     Microsoft.ServiceBus.NamespaceManager namespaceManager = Microsoft.ServiceBus.NamespaceManager.Create();
     TopicDescription myTopic = namespaceManager.GetTopic("tempdata");
     //SubscriptionDescription myAgentSubscription = namespaceManager.CreateSubscription(myTopic.Path, "AgentSubscription");
 }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            ConnectionString    = string.Empty;
            EventHubName        = string.Empty;
            QueueName           = string.Empty;
            NotificationHubName = string.Empty;

            if (args.Length < 4)
            {
                Usage();
                return;
            }

            // parse command line arguments
            for (var i = 0; i < args.Length; i++)
            {
                switch (args[i])
                {
                case "-connstr":
                    i++;
                    ConnectionString = args[i];
                    break;

                case "-eventhub":
                    i++;
                    EventHubName = args[i];
                    break;

                case "-queue":
                    i++;
                    QueueName = args[i];
                    break;

                case "-notificationhub":
                    i++;
                    NotificationHubName = args[i];
                    break;

                case "?":     // help
                    Usage();
                    break;

                default:     // default
                    Usage();
                    break;
                }
            }

            if (ConnectionString == string.Empty)
            {
                Console.WriteLine("ERROR: missing connection string.");
                Usage();
                return;
            }

            if ((EventHubName == string.Empty) && (QueueName == string.Empty) && (NotificationHubName == string.Empty))
            {
                Console.WriteLine("ERROR: missing event hub, queue name or notification hub.");
                Usage();
                return;
            }

            try
            {
                if (NotificationHubName != string.Empty)
                {
                    var nsclient = Microsoft.Azure.NotificationHubs.NamespaceManager.CreateFromConnectionString(ConnectionString);

                    if (!nsclient.NotificationHubExists(NotificationHubName))
                    {
                        var desc = new NotificationHubDescription(NotificationHubName);
                        nsclient.CreateNotificationHub(desc);
                    }
                }
                else
                {
                    var sbclient = NamespaceManager.CreateFromConnectionString(ConnectionString);

                    if (EventHubName != string.Empty)
                    {
                        if (!sbclient.EventHubExists(EventHubName))
                        {
                            sbclient.CreateEventHub(EventHubName);
                        }
                    }

                    if (QueueName != string.Empty)
                    {
                        if (!sbclient.QueueExists(QueueName))
                        {
                            sbclient.CreateQueue(QueueName);
                        }
                    }
                }
            }
            catch (Exception err)
            {
                Console.WriteLine("Error: {0}", err.Message);
            }
        }
 public ManagementClient(Microsoft.ServiceBus.NamespaceManager manager)
 {
     this.manager = manager;
 }
 public ManagementClient(string connectionString)
 {
     this.manager = Microsoft.ServiceBus.NamespaceManager.CreateFromConnectionString(connectionString);
 }