コード例 #1
0
        public static bool Execute(string line, Guid fileGuid, KLog uploaderLog)
        {
            uploaderLog.Warning($"Uploader => Footer Check Failed - Guid: {fileGuid.ToString()}");

            BlobFileCollection.GetFiles().First(d => d.FileGuid == fileGuid).FooterStatus = false;

            LogRecordModel record = null;

            try
            {
                record = JsonConvert.DeserializeObject <LogRecordModel>(line);
            }
            catch (Exception ex)
            {
                uploaderLog.Error($" [UploadInstanceStop] Log Record Deserialize Exception: {ex.ToString()}");
                return(false);
            }

            var newEndTime = record.EventTime;

            InstanceModel newInstanceCloser = new InstanceModel();

            newInstanceCloser.InstanceID = fileGuid;
            newInstanceCloser.EventTime  = newEndTime;

            var checkUpdateInstaceClose = DataAccessor.UpdateInstanceStop(newInstanceCloser);

            if (!checkUpdateInstaceClose.Success)
            {
                uploaderLog.Error($"SQL Expection on [UploadInstanceStop].[UpdateInstaceClose] - Message: {checkUpdateInstaceClose.Message}");
                return(false);
            }

            var checkUpdateBlockStop = DataAccessor.UpdateBlockEmptyStop(record, fileGuid);

            if (!checkUpdateBlockStop.Success)
            {
                uploaderLog.Error($"SQL Expection on [UploadInstanceStop].[UpdateBlockStop] - Message: {checkUpdateBlockStop.Message}");
                return(false);
            }

            return(true);
        }
コード例 #2
0
        public static void Execute()
        {
            using (KLog checkLog = new KLog("ClassBlobFileCheck-MethodExecute"))
            {
                try
                {
                    foreach (var file in BlobFileCollection.GetFiles())
                    {
                        if (file.FileGuid != Guid.Empty)
                        {
                            var resultResponse = DataAccessor.CheckInstanceId(file.FileGuid);

                            if (!resultResponse.Success)
                            {
                                checkLog.Error($"SQL Expection on [BlobFileCheck].[CheckInstance] - Message: {resultResponse.Message}");
                                break;
                            }

                            if (resultResponse.Id != Guid.Empty)
                            {
                                BlobFileCollection.GetFiles().First(d => d.FileGuid == file.FileGuid).Exist = true;
                                checkLog.Info($"Instance Check => Guid: {file.FileGuid.ToString()} Result: true");
                            }
                            else
                            {
                                BlobFileCollection.GetFiles().First(d => d.FileGuid == file.FileGuid).Exist = false;
                                checkLog.Info($"Instance Check => Guid: {file.FileGuid.ToString()} Result: false");
                            }
                        }
                        else
                        {
                            BlobFileCollection.GetFiles().First(d => d.FileGuid == file.FileGuid).Exist = true;
                            checkLog.Info($"Instance Check => Guid: {file.FileGuid.ToString()} Result: true (empty guid)");
                        }
                    }
                }
                catch (Exception ex)
                {
                    checkLog.Error($"BlobfileCheck Expection: {ex.ToString()}");
                }
            }
        }
コード例 #3
0
        public static bool Execute(List <LogRecordModel> recordModelList, Guid fileGuid, KLog uploaderLog)
        {
            Dictionary <Guid, LogRecordModel> blockCache = new Dictionary <Guid, LogRecordModel>();

            foreach (var record in recordModelList)
            {
                if (record.LogData.Contains("KLOG_BLOCK"))
                {
                    if (record.LogData.Contains("KLOG_BLOCK_START"))
                    {
                        blockCache.Add(record.BlockID, record);
                    }
                    else if (record.LogData.Contains("KLOG_BLOCK_STOP"))
                    {
                        var startBlock = blockCache[record.BlockID];

                        if (startBlock != null)
                        {
                            var checkAddBlockResponse = DataAccessor.AddBlock(record, startBlock, instanceId: fileGuid);

                            if (!checkAddBlockResponse.Success)
                            {
                                uploaderLog.Error($"SQL Expection on [UploadAllLogs].[AddBlock] - Message: {checkAddBlockResponse.Message}");
                                return(false);
                            }
                        }
                        else
                        {
                            uploaderLog.Error($"Starting Block not found, is missing from Block pair.");
                        }

                        blockCache.Remove(record.BlockID);
                    }
                    else
                    {
                        uploaderLog.Error($"Malformed Block");
                    }
                }
                else
                {
                    if (record.LogType == "Metric")
                    {
                        var jsonString = record.LogData.Replace("#", "\"");
                        var metric     = JsonConvert.DeserializeObject <MetricRecordModel>(jsonString);

                        var checkMetricResponse = DataAccessor.AddMetric(record, metric, instanceId: fileGuid);

                        if (!checkMetricResponse.Success)
                        {
                            uploaderLog.Error($"SQL Expection on [UploadAllLogs].[AddMetric] - Message: {checkMetricResponse.Message}");
                            return(false);
                        }
                    }
                    else if (record.LogType == "Result")
                    {
                        var jsonString = record.LogData.Replace("#", "\"");
                        var result     = JsonConvert.DeserializeObject <ResultRecordModel>(jsonString);

                        var checkResultResponse = DataAccessor.AddResult(record, result, instanceId: fileGuid);

                        if (!checkResultResponse.Success)
                        {
                            uploaderLog.Error($"SQL Expection on [UploadAllLogs].[AddResult] - Message: {checkResultResponse.Message}");
                            return(false);
                        }
                    }
                    else
                    {
                        if (record.LogData.Length > Configuration.MessageLength)
                        {
                            var messageCap   = Configuration.MessageLength - 20;
                            var cleanLogData = "[ERROR-MAX-" + Configuration.MessageLength + "]";
                            cleanLogData  += record.LogData.Substring(1, messageCap);
                            record.LogData = cleanLogData;
                        }

                        var checkAddInstanceStop = DataAccessor.AddLog(record, instanceId: fileGuid);

                        if (!checkAddInstanceStop.Success)
                        {
                            uploaderLog.Error($"SQL Expection on [UploadAllLogs].[AddLog] - Message: {checkAddInstanceStop.Message}");
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }