コード例 #1
0
        public void ProcessData()
        {
            try
            {
                Utility.Log("PI server : " + ConfigurationSettings.PiServer);
                Utility.Log("Azure ConnectionString : " + ConfigurationSettings.AzureConnectionString);
                Utility.Log("Pi Server ConnectionString : " + ConfigurationSettings.PiServerConnectionString);

                if (!((string.IsNullOrEmpty(ConfigurationSettings.PiServer)) || (string.IsNullOrEmpty(ConfigurationSettings.AzureConnectionString)) || (string.IsNullOrEmpty(ConfigurationSettings.PiServerConnectionString))
                      ))
                {
                    Console.WriteLine("Init ProcessData");
                    Utility.Log("Init ProcessData");
                    if (utcConversionTime != GetAndTimezone())
                    {
                        utcConversionTime = GetAndTimezone();
                        PIConfigurationInfoModel piConfig = new PIConfigurationInfoModel();
                        string serverName = ConfigurationSettings.PiServer;
                        piConfig.PiServerDesc      = serverName;
                        piConfig.PiServerName      = serverName;
                        piConfig.PiServerURL       = ConfigurationSettings.PiServerConnectionString;
                        piConfig.UTCConversionTime = utcConversionTime;
                        piConfig.CreatedOn         = DateTime.UtcNow;
                        ConnectionManager.Instance().InserPIConfigurationDetailsToDB(piConfig);
                    }
                    ConnectionManager.Instance().Initialize();
                    Console.WriteLine("Done with Console manager initialization");

                    string storageConnectionString = ConfigurationSettings.GetCloudConfigDataModel().BlobStorageURL;
                    //patch for now

                    storageConnectionString = ConfigurationSettings.StorageConnectionString;

                    //
                    if (!string.IsNullOrEmpty(storageConnectionString))
                    {
                        BlobStorageManager.Instance().ConfigureBlobStorage(storageConnectionString);
                        Console.WriteLine("Done with Blob Storage configuration");
                        Utility.Log("Done with Console manager initialization");

                        string piServer = ConnectionManager.Instance().GetPIServer();


                        Thread piThread = new Thread(() => { ProcessDataByPIServer(piServer); });
                        piThread.Start();
                        //Thread sensorThread = new Thread(() => { InsertSensorData(piServer); });
                        //sensorThread.Start();
                    }
                    else
                    {
                        Utility.Log("Does not have storage connection string ");
                    }
                }
                else
                {
                    Console.WriteLine("Doesn't have sufficient data in app config for connection");
                    Console.ReadLine();
                    Utility.Log("Doesn't have sufficient data in app config for connection");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error occured in processData" + e.Message);
                Utility.Log("Error occured in processData" + e.Message);
            }
        }