Esempio n. 1
0
 static void Main(string[] args)
 {
     using (var logBuffer = new LogBuffer(4, 10, "test.log"))
     {
         logBuffer.Add("Test string 1");
         logBuffer.Add("Test string 2");
         logBuffer.Add("Test string 3");
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Adds a new LogEntry to the LogBuffer.
 /// </summary>
 /// <param name="entry">The LogEntry to add</param>
 public void Log(LogEntry entry)
 {
     if (GlobalSettings.General.EnableBotLog || IsDebug)
     {
         LogBuffer.Add(entry);
     }
 }
Esempio n. 3
0
 public void Log(string s, LogLevel level)
 {
     if ((int)Program.LogLevel >= (int)level)
     {
         LogBuffer.Add(s);
         if (LogBuffer.Count > Chip8Emu.DisplayRows)
         {
             LogBuffer.RemoveAt(0);
         }
     }
 }
Esempio n. 4
0
        public void TestMaxBufferSize()
        {
            var logBuffer = new LogBuffer(2, 10000, _fileMock.Object);

            var list = new List <string> {
                "Test Str1", "Test Str2", "Test Str3"
            };

            logBuffer.Add(list[0]);
            VerifyThatThereWasNoWriteCall();
            logBuffer.Add(list[1]);
            VerifyThatThereWasNoWriteCall();
            logBuffer.Add(list[2]);

            var data = new UTF8Encoding(true).GetBytes(string.Join("\n", list) + "\n");

            _fileMock.Verify(stream => stream.Write(
                                 data, 0, data.Length),
                             Times.Once);
        }
 /// <summary>
 ///     Logs the appropriate level of message.
 /// </summary>
 /// <param name="level">The level.</param>
 /// <param name="context">The context - if <see cref="Logger.UseContext" /> is false, this will be empty.</param>
 /// <param name="threadId">The thread identifier - if <see cref="Logger.UseThreadId"/> is false, this will be empty.</param>
 /// <param name="logTag">The log tag.</param>
 /// <param name="msg">The message.</param>
 public void LogThis(LoggingLevel level, string context, string threadId, LogTag logTag, string msg)
 {
     LogBuffer.Add(new LogEntry
     {
         Context  = context,
         LogTag   = logTag,
         Level    = level,
         Message  = msg,
         ThreadId = threadId
     });
 }
Esempio n. 6
0
        /// <summary>
        /// Log lỗi
        /// </summary>
        /// <param name="Error">Chi tiết lỗi cần log</param>
        protected void WriteError(string Error)
        {
            var match = Regex.Match(Error, "<MES>([^<]+)</MES>");

            if (match.Success)
            {
                Error     = match.Groups[1].Value;
                LastError = string.Format("\r\n*** [Lỗi] {0:HH:mm:ss} - {1} ***\r\n", DateTime.Now, Error);
            }
            else
            {
                LastError = string.Format("[Lỗi] {0:HH:mm:ss} - {1}", DateTime.Now, Error);
            }
            TotalError++;
            LogBuffer.Add(LastError);
            SetProcessState(ProcessState.Error);
        }
Esempio n. 7
0
        private void Awake()
        {
            Application.logMessageReceived +=
                (string condition, string stackTrace, LogType type) =>
            {
                ScrollPosition = new Vector2(0, System.Single.MaxValue - 1);

                SealedLog sealedLog = new SealedLog()
                {
                    time       = System.DateTime.Now,
                    type       = type,
                    condition  = condition,
                    stackTrace = stackTrace
                };

                logBuffer.Add(sealedLog);
            };
        }
Esempio n. 8
0
        public void TestInterval()
        {
            var logBuffer = new LogBuffer(10, 1, _fileMock.Object);

            const string str = "Some string";

            logBuffer.Add(str);

            VerifyThatThereWasNoWriteCall();

            Thread.Sleep(1100);

            var data = new UTF8Encoding(true).GetBytes(str + "\n");


            _fileMock.Verify(stream => stream.Write(
                                 data, 0, data.Length),
                             Times.Once);
        }
Esempio n. 9
0
 /// <summary>
 /// Logs an empty line to the LogBuffer.
 /// </summary>
 public void LogNewLine()
 {
     LogBuffer.Add(new LogEntry("", Colors.White));
 }
Esempio n. 10
0
        bool Run( )
        {
            CloudWebDeployInputs inputs = null;

            if (!GetInputs(out inputs))
            {
                return(false);
            }

            Console.WriteLine("Retrieving namespace metadata...");
            // Create Namespace
            ServiceBusManagementClient sbMgmt = new ServiceBusManagementClient(inputs.Credentials);

            var    nsDescription      = sbMgmt.Namespaces.GetNamespaceDescription(inputs.SBNamespace);
            string nsConnectionString = nsDescription.NamespaceDescriptions.First(
                (d) => String.Equals(d.AuthorizationType, "SharedAccessAuthorization")
                ).ConnectionString;

            NamespaceManager nsManager = NamespaceManager.CreateFromConnectionString(nsConnectionString);

            EventHubDescription ehDevices = AzureConsoleHelper.SelectEventHub(nsManager, inputs.Credentials);

            var serviceNamespace = inputs.SBNamespace;
            var hubName          = ehDevices.Path;

            var sharedAccessAuthorizationRule = ehDevices.Authorization.FirstOrDefault((d)
                                                                                       => d.Rights.Contains(AccessRights.Listen)) as SharedAccessAuthorizationRule;

            if (sharedAccessAuthorizationRule == null)
            {
                Console.WriteLine("Cannot locate Authorization rule for WebSite key.");
                return(false);
            }

            var receiverKeyName = sharedAccessAuthorizationRule.KeyName;
            var receiverKey     = sharedAccessAuthorizationRule.PrimaryKey;
            //Console.WriteLine("Starting temperature processor with {0} partitions.", partitionCount);

            CancellationTokenSource cts = new CancellationTokenSource( );

            int            closedReceivers  = 0;
            AutoResetEvent receiversStopped = new AutoResetEvent(false);

            MessagingFactory factory = MessagingFactory.Create(ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespace, ""),
                                                               new MessagingFactorySettings
            {
                TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider(receiverKeyName, receiverKey),
                TransportType = TransportType.Amqp
            });

            EventHubClient        eventHubClient        = factory.CreateEventHubClient(hubName);
            EventHubConsumerGroup eventHubConsumerGroup = eventHubClient.GetDefaultConsumerGroup( );

            int partitionCount = ehDevices.PartitionCount;

            for (int i = 0; i < partitionCount; i++)
            {
                Task.Factory.StartNew((state) =>
                {
                    try
                    {
                        _ConsoleBuffer.Add(string.Format("Starting worker to process partition: {0}", state));

                        var receiver = eventHubConsumerGroup.CreateReceiver(state.ToString( ), DateTime.UtcNow);

                        _ConsoleBuffer.Add(string.Format("Waiting for start receiving messages: {0} ...", state));

                        while (true)
                        {
                            // Receive could fail, I would need a retry policy etc...
                            var messages = receiver.Receive(10);
                            foreach (var message in messages)
                            {
                                //var eventBody = Newtonsoft.Json.JsonConvert.DeserializeObject<TemperatureEvent>(Encoding.Default.GetString(message.GetBytes()));
                                //Console.WriteLine("{0} [{1}] Temperature: {2}", DateTime.Now, message.PartitionKey, eventBody.Temperature);
                                _ConsoleBuffer.Add(message.PartitionKey + " sent message:" + Encoding.Default.GetString(message.GetBytes( )));
                            }

                            if (cts.IsCancellationRequested)
                            {
                                Console.WriteLine("Stopping: {0}", state);
                                receiver.Close( );
                                if (Interlocked.Increment(ref closedReceivers) >= partitionCount)
                                {
                                    receiversStopped.Set();
                                }
                                break;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        _ConsoleBuffer.Add(ex.Message);
                    }
                }, i);
            }

            Console.ReadLine( );
            cts.Cancel( );

            //waiting for all receivers to stop
            receiversStopped.WaitOne( );

            bool saveToFile;

            for ( ;;)
            {
                Console.WriteLine("Do you want to save received data to file? (y/n)");

                string answer  = Console.ReadLine( );
                string request = "do not";

                saveToFile = false;
                if (!string.IsNullOrEmpty(answer) && answer.ToLower( ).StartsWith("y"))
                {
                    saveToFile = true;
                    request    = "";
                }
                if (ConsoleHelper.Confirm("Are you sure you " + request + " want to save received data?"))
                {
                    break;
                }
            }
            if (saveToFile)
            {
                string fileName     = inputs.SBNamespace + DateTime.UtcNow.ToString("_d_MMM_h_mm") + ".log";
                string filePath     = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                string fileFullName = filePath + @"\" + fileName;
                if (_ConsoleBuffer.FlushToFile(fileFullName))
                {
                    Console.WriteLine("Output was saved to your desktop, at " + fileFullName + " file.");
                }
            }


            Console.WriteLine("Wait for all receivers to close and then press ENTER.");
            Console.ReadLine( );

            return(true);
        }
Esempio n. 11
0
        public bool Run( )
        {
            AzurePrepInputs inputs;

            if (!GetInputs(out inputs))
            {
                Console.WriteLine("Error while getting inputs.");
                Console.WriteLine("Press Enter to continue...");
                Console.ReadLine( );
                return(false);
            }

            AzurePrepOutputs createResults = CreateEventHub(inputs);

            if (createResults == null)
            {
                Console.WriteLine("Error while creating Event Hubs.");
                Console.WriteLine("Press Enter to continue...");
                Console.ReadLine( );
                return(false);
            }

            for ( ;;)
            {
                Console.WriteLine("Do you want to create Stream Analytics jobs? (y/n)");

                string answer = Console.ReadLine( );
                bool   create;
                string request;
                if (!string.IsNullOrEmpty(answer) && answer.ToLower( ).StartsWith("y"))
                {
                    create  = true;
                    request = "";
                }
                else
                {
                    create  = false;
                    request = "do not ";
                }
                if (ConsoleHelper.Confirm("Are you sure you " + request + "want to create Stream Analytics jobs?"))
                {
                    if (create)
                    {
                        CreateStreamAnalyticsJobs(inputs, createResults);
                    }
                    break;
                }
            }

            #region print results

            _ConsoleBuffer.Add("");
            _ConsoleBuffer.Add("Service Bus management connection string (i.e. for use in Service Bus Explorer):");
            _ConsoleBuffer.Add(createResults.nsConnectionString);
            _ConsoleBuffer.Add("");
            _ConsoleBuffer.Add("Device AMQP address strings (for Raspberry PI/devices):");

            for (int i = 1; i <= 4; i++)
            {
                var deviceKeyName = String.Format("D{0}", i);
                var deviceKey     = (createResults.ehDevices.Authorization.First((d)
                                                                                 => String.Equals(d.KeyName, deviceKeyName, StringComparison.InvariantCultureIgnoreCase)) as SharedAccessAuthorizationRule).PrimaryKey;

                _ConsoleBuffer.Add(string.Format("amqps://{0}:{1}@{2}.servicebus.windows.net",
                                                 deviceKeyName, Uri.EscapeDataString(deviceKey), createResults.SBNamespace));
            }

            Console.WriteLine("");
            Console.WriteLine("");

            string fileName     = createResults.SBNamespace + DateTime.UtcNow.ToString("_d_MMM_h_mm") + ".log";
            string filePath     = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            string fileFullName = filePath + @"\" + fileName;
            if (_ConsoleBuffer.FlushToFile(fileFullName))
            {
                Console.WriteLine("Output was saved to your desktop, at " + fileFullName + " file.");
            }

            Console.WriteLine("Please hit enter to close.");
            Console.ReadLine( );

            #endregion
            return(true);
        }
Esempio n. 12
0
 /// <summary>
 /// Log thông tin
 /// </summary>
 /// <param name="Info">Thông tin cần log</param>
 protected void WriteInfo(string Info)
 {
     LogBuffer.Add(string.Format("[Thông báo] {0:HH:mm:ss} - {1}", DateTime.Now, Info));
 }
Esempio n. 13
0
        private void DeleteResources(ClearResourcesInputs inputs)
        {
            if (inputs.NamespaceExists)
            {
                _ConsoleBuffer.Add("Connecting to Service Bus...");
                ServiceBusManagementClient sbMgmt = new ServiceBusManagementClient(inputs.Credentials);

                bool deleteNamespace = ConsoleHelper.AskAndPerformAction(
                    "Do you want to delete whole namespace " + inputs.SBNamespace + " including all entities under it?",
                    "Are you sure you want to delete namespace " + inputs.SBNamespace + "?",
                    "Are you sure you do not want to delete namespace " + inputs.SBNamespace + "?",
                    () =>
                {
                    _ConsoleBuffer.Add("Sending request to delete " + inputs.SBNamespace + " namespace...");
                    AzureOperationResponse nsResponse = sbMgmt.Namespaces.Delete(inputs.SBNamespace);
                    if (nsResponse.StatusCode == HttpStatusCode.OK)
                    {
                        _ConsoleBuffer.Add(inputs.SBNamespace + " namespace was deleted.");
                    }
                },
                    _ConsoleBuffer);

                //if we did not delete whole Namespace, maybe we want to delete some of its Event Hubs?
                if (!deleteNamespace)
                {
                    _ConsoleBuffer.Add("Reading list of Event Hubs from " + inputs.SBNamespace + " namespace...");

                    var nsDescription      = sbMgmt.Namespaces.GetNamespaceDescription(inputs.SBNamespace);
                    var nsConnectionString = nsDescription.NamespaceDescriptions.First(
                        (d) => String.Equals(d.AuthorizationType, "SharedAccessAuthorization")
                        ).ConnectionString;
                    var nsManager = NamespaceManager.CreateFromConnectionString(nsConnectionString);

                    var eventHubs = nsManager.GetEventHubs( );

                    foreach (var eventHubDescription in eventHubs)
                    {
                        EventHubDescription description = eventHubDescription;
                        ConsoleHelper.AskAndPerformAction(
                            "Do you want to delete Event Hub " + eventHubDescription.Path +
                            " including all messages under it?",
                            "Are you sure you want to delete Event Hub " + eventHubDescription.Path + "?",
                            "Are you sure you do not want to delete Event Hub " + eventHubDescription.Path + "?",
                            () =>
                        {
                            _ConsoleBuffer.Add("Sending request to delete " + description.Path + " Event Hub...");
                            nsManager.DeleteEventHub(description.Path);
                            _ConsoleBuffer.Add("Request to delete " + description.Path + " Event Hub was accepted.");
                        },
                            _ConsoleBuffer);
                    }
                }
            }

            //Deleting Storage
            _ConsoleBuffer.Add("Reading list of Storage Accounts...");
            StorageManagementClient stgMgmt         = new StorageManagementClient(inputs.Credentials);
            HashSet <string>        storageAccounts = new HashSet <string>( );

            foreach (var storageAccount in stgMgmt.StorageAccounts.List( ))
            {
                storageAccounts.Add(storageAccount.Name);
            }

            int deletedCount = 0;

            if (storageAccounts.Contains(inputs.StorageAccountName))
            {
                ConsoleHelper.AskAndPerformAction(
                    "Do you want to delete " + inputs.StorageAccountName + " storage account?",
                    "Are you sure you want to delete " + inputs.StorageAccountName + " storage account?",
                    "Are you sure you do not want to delete " + inputs.StorageAccountName + " storage account?",
                    () =>
                {
                    _ConsoleBuffer.Add("Sending request to delete " + inputs.StorageAccountName + " Storage account...");
                    AzureOperationResponse resultStg = stgMgmt.StorageAccounts.Delete(inputs.StorageAccountName);
                    deletedCount += 1;
                    if (resultStg.StatusCode == System.Net.HttpStatusCode.OK)
                    {
                        _ConsoleBuffer.Add("Storage account " + inputs.StorageAccountName + " was deleted.");
                    }
                },
                    _ConsoleBuffer);
            }
            if (deletedCount == 0)
            {
                _ConsoleBuffer.Add("No related Storage account was detected.");
            }

            //Deleting Stream Analytics jobs
            _ConsoleBuffer.Add("Reading list of Stream Analytics jobs...");
            StreamAnalyticsManagementClient saMgmt = new StreamAnalyticsManagementClient(inputs.Credentials);
            JobListResponse jobListResponse        = saMgmt.StreamingJobs.ListJobsInSubscription(new JobListParameters {
                PropertiesToExpand = string.Empty
            });

            deletedCount = 0;
            foreach (var job in jobListResponse.Value)
            {
                if (job.Name.StartsWith(inputs.NamePrefix))
                {
                    Job jobToAsk = job;
                    ConsoleHelper.AskAndPerformAction(
                        "Do you want to delete Stream Analytics job " + job.Name + "?",
                        "Are you sure you want to delete Stream Analytics job  " + job.Name + "?",
                        "Are you sure you do not want to delete namespace " + job.Name + "?",
                        () =>
                    {
                        //we need to figure out wat resourceGroup this job belongs to
                        //--//
                        const string resourceGroupPath = "/resourceGroups/";
                        const string providersPath     = "/providers/";

                        int resourceGroupPathIndex    = jobToAsk.Id.IndexOf(resourceGroupPath, System.StringComparison.Ordinal);
                        int providersPathIndex        = jobToAsk.Id.IndexOf(providersPath, System.StringComparison.Ordinal);
                        int resourceGroupIdStartIndex = resourceGroupPathIndex + resourceGroupPath.Length;

                        string resourceGroup = jobToAsk.Id.Substring(resourceGroupIdStartIndex, providersPathIndex - resourceGroupIdStartIndex);
                        //--//

                        deletedCount += 1;
                        _ConsoleBuffer.Add("Sending request to delete " + jobToAsk.Name + " Stream Analytics job...");
                        LongRunningOperationResponse response = saMgmt.StreamingJobs.Delete(resourceGroup, jobToAsk.Name);
                        if (response.Status == OperationStatus.Succeeded)
                        {
                            _ConsoleBuffer.Add("Stream Analytics job " + jobToAsk.Name + " was deleted.");
                        }
                    },
                        _ConsoleBuffer);
                }
            }
            if (deletedCount == 0)
            {
                _ConsoleBuffer.Add("No Stream Analytics job was deleted.");
            }
        }
Esempio n. 14
0
        public bool Run( )
        {
            AzurePrepInputs inputs;

            if (!GetInputs(out inputs))
            {
                Console.WriteLine("Error while getting inputs.");
                Console.WriteLine("Press Enter to continue...");
                Console.ReadLine( );
                return(false);
            }

            AzurePrepOutputs createResults = CreateEventHub(inputs);

            if (createResults == null)
            {
                Console.WriteLine("Error while creating Event Hubs.");
                Console.WriteLine("Press Enter to continue...");
                Console.ReadLine();
                return(false);
            }

            #region print results

            _ConsoleBuffer.Add("");
            _ConsoleBuffer.Add("Service Bus management connection string (i.e. for use in Service Bus Explorer):");
            _ConsoleBuffer.Add(createResults.nsConnectionString);
            _ConsoleBuffer.Add("");
            _ConsoleBuffer.Add("Device AMQP address strings (for Raspberry PI/devices):");

            for (int i = 1; i <= 4; i++)
            {
                var deviceKeyName = String.Format("D{0}", i);
                var deviceKey     = (createResults.ehDevices.Authorization.First((d)
                                                                                 => String.Equals(d.KeyName, deviceKeyName, StringComparison.InvariantCultureIgnoreCase)) as SharedAccessAuthorizationRule).PrimaryKey;

                _ConsoleBuffer.Add(string.Format("amqps://{0}:{1}@{2}.servicebus.windows.net",
                                                 deviceKeyName, Uri.EscapeDataString(deviceKey), createResults.SBNamespace));
            }

            Console.WriteLine("");
            Console.WriteLine("");

            string fileName     = createResults.SBNamespace + DateTime.UtcNow.ToString("_d_MMM_h_mm") + ".log";
            string filePath     = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            string fileFullName = filePath + @"\" + fileName;
            if (_ConsoleBuffer.FlushToFile(fileFullName))
            {
                Console.WriteLine("Output was saved to your desktop, at " + fileFullName + " file.");
            }

            Console.WriteLine("Please hit enter to close.");
            Console.ReadLine( );

            #endregion

#if AZURESTREAMANALYTICS
            // Create StreamAnalyticsJobs + inputs + outputs + enter keys

            // Untested code. May require AAD authentication, no support for management cert?

            // Create Resource Group for the Stream Analytics jobs
            var groupCreateRequest = WebRequest.Create(String.Format("https://management.azure.com/subscriptions/{0}/resourcegroups/{1}?api-version=2014-04-01-preview",
                                                                     SubscriptionId, StreamAnalyticsGroup)) as HttpWebRequest;

            groupCreateRequest.ClientCertificates.Add(creds.ManagementCertificate);
            groupCreateRequest.ContentType = "application/json";
            groupCreateRequest.Method      = "PUT";
            groupCreateRequest.KeepAlive   = true;

            var bytesGroup = Encoding.UTF8.GetBytes("{\"location\":\"Central US\"}");
            groupCreateRequest.ContentLength = bytesGroup.Length;
            groupCreateRequest.GetRequestStream().Write(bytesGroup, 0, bytesGroup.Length);

            var groupCreateResponse = groupCreateRequest.GetResponse();

            //var streamMgmt = new ManagementClient(creds); //, new Uri("https://management.azure.com"));
            //HttpClient client = streamMgmt.HttpClient;

            var createJob = new StreamAnalyticsJob()
            {
                location = Location,
                inputs   = new List <StreamAnalyticsEntity>
                {
                    new StreamAnalyticsEntity
                    {
                        name       = "devicesInput",
                        properties = new Dictionary <string, object>
                        {
                            { "type", "stream" },
                            { "serialization", new Dictionary <string, object>
                              {
                                  { "type", "JSON" },
                                  { "properties", new Dictionary <string, object>
                                    {
                                        { "encoding", "UTF8" },
                                    } }
                              } },
                            { "datasource", new Dictionary <string, object>
                              {
                                  { "type", "Microsoft.ServiceBus/EventHub" },
                                  { "properties", new Dictionary <string, object>
                                    {
                                        { "eventHubNamespace", Namespace },
                                        { "eventHubName", EventHubDevices },
                                        { "sharedAccessPolicyName", "StreamingAnalytics" },
                                        { "sharedAccessPolicyKey",
                                            (ehDevices.Authorization.First((d)
                                                                           => String.Equals(d.KeyName, "StreamingAnalytics", StringComparison.InvariantCultureIgnoreCase)) as SharedAccessAuthorizationRule).PrimaryKey },
                                    } }
                              } }
                        },
                    },
                },
                transformation = new StreamAnalyticsEntity()
                {
                    name       = "Aggregates",
                    properties = new Dictionary <string, object>
                    {
                        { "streamingUnits", 1 },
                        { "query", "select * from devicesInput" },
                    }
                },
                outputs = new List <StreamAnalyticsEntity>
                {
                    new StreamAnalyticsEntity
                    {
                        name       = "output",
                        properties = new Dictionary <string, object>
                        {
                            { "datasource", new Dictionary <string, object>
                              {
                                  { "type", "Microsoft.ServiceBus/EventHub" },
                                  { "properties", new Dictionary <string, object>
                                    {
                                        { "eventHubNamespace", Namespace },
                                        { "eventHubName", EventHubAlerts },
                                        { "sharedAccessPolicyName", "StreamingAnalytics" },
                                        { "sharedAccessPolicyKey",
                                            (ehAlerts.Authorization.First((d) => String.Equals(d.KeyName, "StreamingAnalytics", StringComparison.InvariantCultureIgnoreCase)) as SharedAccessAuthorizationRule).PrimaryKey },
                                    } }
                              } },
                            { "serialization", new Dictionary <string, object>
                              {
                                  { "type", "JSON" },
                                  { "properties", new Dictionary <string, object>
                                    {
                                        { "encoding", "UTF8" },
                                    } }
                              } },
                        },
                    },
                }
            };



            var jobCreateRequest = WebRequest.Create(String.Format("https://management.azure.com/subscriptions/{0}/resourcegroups/{1}/Microsoft.StreamAnalytics/streamingjobs/{2}?api-version=2014-10-01",
                                                                   SubscriptionId, StreamAnalyticsGroup, JobAggregates)) as HttpWebRequest;

            jobCreateRequest.ClientCertificates.Add(creds.ManagementCertificate);
            jobCreateRequest.ContentType = "application/json";
            jobCreateRequest.Method      = "PUT";
            jobCreateRequest.KeepAlive   = true;

            var bytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(createJob));
            jobCreateRequest.ContentLength = bytes.Length;
            jobCreateRequest.GetRequestStream().Write(bytes, 0, bytes.Length);

            var jobCreateResponse = jobCreateRequest.GetResponse();

            //var jobCreateTask = streamMgmt.HttpClient.PutAsync(
            //    String.Format("https://management.azure.com/subscriptions/{0}/resourcegroups/{1}/Microsoft.StreamAnalytics/streamingjobs/{2}?api-version=2014-10-01",
            //    SubscriptionId, StreamAnalyticsGroup, JobAggregates),
            //    new StringContent(JsonConvert.SerializeObject(createJob)));
            //jobCreateTask.Wait();
            //var jobCreateResponse = jobCreateTask.Result;
#endif
            return(true);
        }