Exemplo n.º 1
0
        public static void CheckForFilesToBeProcessed(string productVersion, ILogger log)
        {
            FoundFile foundFile = null;

            while (true)
            {
                foundFile = null;
                try {
                    foundFile = AzureFileHelper.ScanForANewFile();
                } catch (Exception ex) { LogHelper.LogSystemError(log, productVersion, ex); }

                if (foundFile == null)
                {
                    break;
                }

                try {
                    string msg = "Processing the file " + foundFile.PlantName + "," + foundFile.AzureFileName;
                    log.LogInformation("*** " + msg + $" at: {DateTime.Now}" + ":" + productVersion);
                    LogHelper.LogMessage(foundFile.PlantName, productVersion, msg);
                    foundFile.ProcessFile(log, productVersion);
                    foundFile.DisposeOfFile();
                    foundFile.RecordSuccess();
                } catch (Exception ex) {
                    LogHelper.LogMessage(foundFile.PlantName, productVersion, "Fatal error with file " + foundFile.AzureFullPathName + " : " + ex.Message + ex.StackTrace);
                    AzureModel.RecordFailure(foundFile.PlantName, foundFile.AzureFullPathName, foundFile.SuccessfulRecords, foundFile.FailedRecords, ex.Message);
                    try {
                        foundFile.DisposeOfFile(true);
                    } catch (Exception ex2) { LogHelper.LogSystemError(log, productVersion, ex2); }
                }
            }
        }
Exemplo n.º 2
0
        public static void Run([TimerTrigger("0 */1 * * * *")] TimerInfo myTimer, ExecutionContext context, ILogger log)    // triggering every minute
        {
            var productVersion = typeof(R2PLoader).Assembly.GetName().Version.ToString();

            try {
                FoundFile.SetConnection(context, log);
                AzureFileHelper.ProcessModifiedTagMappings(productVersion);
            } catch (Exception ex) { LogHelper.LogSystemError(log, productVersion, ex); }

            AzureFileHelper.CheckForFilesToBeProcessed(productVersion, log);
        }
Exemplo n.º 3
0
        internal static void ProcessModifiedTagMapping(string plant, string version)
        {
            // add/modify/delete tags mappings
            string suffix = "." + plant + ".csv";
            string tags   = AzureFileHelper.ReadFile(tagMappingFile + suffix);

            if (tags != null)
            {
                DataTable tm     = Utilities.ConvertCSVTexttoDataTable(tags);
                string    output = AzureModel.UpdateTagMappings(plant, tm);
                LogHelper.LogMessage(plant, version, "Updated the following tag mappings:\r\n" + output);
                AzureFileHelper.WriteFile(tagMappingFileProcessed + suffix, tags, false);
                AzureFileHelper.DeleteFile(tagMappingFile + suffix);
            }
        }