예제 #1
0
        /// <summary>
        /// Add Kiroku log event.
        /// </summary>
        /// <param name="record"></param>
        /// <param name="instanceId"></param>
        /// <returns></returns>
        public static SQLResponseModel AddLog(LogRecordModel record, Guid instanceId)
        {
            SQLResponseModel response = new SQLResponseModel();

            try
            {
                using (var connection = new SqlConnection(Configuration.SqlConnetionString))
                {
                    var cmd = new SqlCommand("usp_Kiroku_KLogs_InsertAdd", connection);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("dt_session", record.EventTime);
                    cmd.Parameters.AddWithValue("dt_event", record.EventTime);
                    cmd.Parameters.AddWithValue("ui_blockid", record.BlockID);
                    cmd.Parameters.AddWithValue("nvc_blockname", record.BlockName);
                    cmd.Parameters.AddWithValue("nvc_logtype", record.LogType);
                    cmd.Parameters.AddWithValue("nvc_logdata", record.LogData);

                    connection.Open();

                    var reader = cmd.ExecuteReader();

                    response.Successful();

                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.Failure(ex.ToString());

                return(response);
            }
        }
예제 #2
0
        /// <summary>
        /// Update Kiroku Block, with an empty stop time.
        /// </summary>
        /// <param name="logRecord"></param>
        /// <param name="instanceId"></param>
        /// <returns></returns>
        public static SQLResponseModel UpdateBlockEmptyStop(LogRecordModel logRecord, Guid instanceId)
        {
            SQLResponseModel response = new SQLResponseModel();

            try
            {
                using (var connection = new SqlConnection(Configuration.SqlConnetionString))
                {
                    var cmd = new SqlCommand("usp_Kiroku_KBlocks_UpdateEmptyStop", connection);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("ui_instanceid", instanceId);
                    cmd.Parameters.AddWithValue("dt_blockstop", logRecord.EventTime);

                    connection.Open();

                    var reader = cmd.ExecuteReader();

                    response.Successful();

                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.Failure(ex.ToString());

                return(response);
            }
        }
        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);
        }