コード例 #1
0
        /// <summary>
        /// Creates datalog entry from record information
        /// </summary>
        /// <param name="record">The record.</param>
        private void CreateDatalogEntry(HpcrArchiveRecord record)
        {
            TraceFactory.Logger.Debug("Send datalog entry for RowIdentifier={0}, StfLogId={1} to {2}"
                                      .FormatWith(record.RowIdentifier, record.StfLogId, GlobalSettings.WcfHosts[WcfService.DataLog]));
            if (!string.IsNullOrEmpty(record.SessionId))
            {
                DigitalSendServerJobLogger log = new DigitalSendServerJobLogger(record.StfLogId);

                log.SessionId     = record.SessionId;
                log.JobType       = record.JobType;
                log.ProcessedBy   = "HPCR";
                log.DeviceModel   = record.DeviceModel;
                log.FileSizeBytes = record.FileSizeBytes;
                log.ScannedPages  = (short)record.ScannedPages;
                log.FileType      = record.FileType;

                log.DssVersion = record.DssVersion.Equals("") ? "Unknown" : record.DssVersion;

                if (record.DateDelivered.HasValue)
                {
                    log.CompletionDateTime = record.DateDelivered.Value;
                    record.StfLogStatus    = StfLogStatus.Completed;
                }
                else
                {
                    record.StfLogStatus    = StfLogStatus.Partial;
                    log.CompletionDateTime = DateTime.Parse("01/01/1800 12:00:00 AM");
                }
                record.StfDigitalSendServerJobId = log.DigitalSendServerJobId;

                log.CompletionStatus = record.FinalStatus;
                log.FileName         = record.DocumentName;
                _dataLogger.Submit(log);
            }
        }
コード例 #2
0
        private void UpdateHpcrDatabase(SqlAdapter adapter, HpcrArchiveRecord record)
        {
            string sql = string.Empty;

            if (string.IsNullOrEmpty(record.SessionId))
            {
                record.StfLogStatus = StfLogStatus.Ignore;
            }
            if ((record.JobType.Equals("HpcrScanToMe") || record.JobType.Equals("HpcrPublicDistributions")) && record.DateDelivered.HasValue)
            {
                sql = @"
                update ArchiveTable 
                set StfDigitalSendServerJobId = '{0}', StfLogId = '{1}', StfLogStatus = '{2}',  prDateDelivered = '{3}'
                where RowIdentifier = {4}
                ".FormatWith(record.StfDigitalSendServerJobId.ToString(), record.StfLogId.ToString(), record.StfLogStatus, record.DateDelivered, record.RowIdentifier);
            }
            else
            {
                sql = @"
                update ArchiveTable 
                set StfDigitalSendServerJobId = '{0}', StfLogId = '{1}', StfLogStatus = '{2}' 
                where RowIdentifier = {3}
                ".FormatWith(record.StfDigitalSendServerJobId.ToString(), record.StfLogId.ToString(), record.StfLogStatus, record.RowIdentifier);
            }
            TraceFactory.Logger.Debug(sql);
            adapter.ExecuteNonQuery(sql);
        }
コード例 #3
0
        private bool ProcessRecordForwarding(List <HpcrArchiveRecord> result, HpcrArchiveRecord hpcrRecord)
        {
            bool processed = false;

            foreach (HpcrArchiveRecord har in result)
            {
                if (har.DocumentName.Equals(hpcrRecord.DocumentName))
                {
                    har.DateDelivered = hpcrRecord.DateDelivered;

                    hpcrRecord.StfLogStatus = StfLogStatus.Completed;
                    hpcrRecord.StfLogId     = har.StfLogId;

                    processed = true;
                    break;
                }
            }
            return(processed);
        }
コード例 #4
0
        /// <summary>
        /// Updates a previously made datalog entry with updated completion time and completion status
        /// </summary>
        /// <param name="record">The record.</param>
        private void UpdateDatalogEntry(HpcrArchiveRecord record)
        {
            TraceFactory.Logger.Debug("Update datalog entry for RowIdentifier={0}, StfLogId={1}"
                                      .FormatWith(record.RowIdentifier, record.StfLogId));
            if (!string.IsNullOrEmpty(record.SessionId))
            {
                DigitalSendServerJobLogger log = new DigitalSendServerJobLogger(record.StfLogId);
                log.DigitalSendServerJobId = record.StfDigitalSendServerJobId;
                log.SessionId = record.SessionId;

                if (record.DateDelivered.HasValue)
                {
                    log.CompletionDateTime = record.DateDelivered.Value;
                    log.CompletionStatus   = record.FinalStatus;
                    _dataLogger.Update(log);

                    record.StfLogStatus = StfLogStatus.Completed;
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Retrieves the job records from the HPCR database.
        /// </summary>
        public List <HpcrArchiveRecord> RetrieveRecords()
        {
            var result = new List <HpcrArchiveRecord>();

            TraceFactory.Logger.Debug("Retrieving records from HPCR database that should be logged to STF");
            using (SqlAdapter adapter = new SqlAdapter(_connectionString))
            {
                try
                {
                    // Get records with a DocumentName that either haven't been logged (StfLogId = null)
                    // or have an updated delivery date within an expiration period
                    var sql = @"
                        select * from ArchiveTable 
                        where 
                        DATALENGTH([DocumentName]) > 0
                        and ([StfLogStatus] is null or [StfLogStatus] != 'Ignore')
                        and
                        (
                            [StfLogId] is null 
                            or (
                                [StfLogStatus] = 'Partial' 
                                and [prDateDelivered] is not null
                                and [ArchiveDate] < DATEADD(hh, -6, GETDATE())
                            )
							or(
								[StfLogStatus] = 'Partial' 
								and [prDateDelivered] is null								
								and ([prDestination] = 'scantome' or prDestination like '%-%-%-%-%')
							)
                        )
                    ";

                    using (DbDataReader reader = adapter.ExecuteReader(sql))
                    {
                        while (reader.Read())
                        {
                            Guid stfLogId = GetStfLogId(reader);
                            Guid stfDigitalSendServerJobid = GetStfDigitalSendServerJobId(reader);

                            HpcrArchiveRecord hpcrRecord = new HpcrArchiveRecord();

                            hpcrRecord.RowIdentifier             = (int)reader[HpcrDatabaseColumns.RowIdentifier];
                            hpcrRecord.DateDelivered             = GetValueAsDateTime(reader, HpcrDatabaseColumns.prDateDelivered);
                            hpcrRecord.DateSubmitted             = GetValueAsDateTime(reader, HpcrDatabaseColumns.prDateSubmitted);
                            hpcrRecord.JobType                   = TranslateJobType(GetValueAsString(reader, HpcrDatabaseColumns.prDestination));
                            hpcrRecord.DocumentName              = GetValueAsString(reader, HpcrDatabaseColumns.DocumentName);
                            hpcrRecord.FileType                  = GetValueAsString(reader, HpcrDatabaseColumns.prFinalFormCode);
                            hpcrRecord.FileSizeBytes             = GetValueAsInt(reader, HpcrDatabaseColumns.DocumentBytes);
                            hpcrRecord.ScannedPages              = GetValueAsInt(reader, HpcrDatabaseColumns.DocumentCount);
                            hpcrRecord.DssVersion                = GetValueAsString(reader, HpcrDatabaseColumns.prHPCRServerVersion);
                            hpcrRecord.FinalStatus               = GetValueAsString(reader, HpcrDatabaseColumns.prFinalStatusText);
                            hpcrRecord.StfLogStatus              = GetValueAsString(reader, HpcrDatabaseColumns.StfLogStatus);
                            hpcrRecord.DeviceModel               = GetValueAsString(reader, HpcrDatabaseColumns.DeviceModelName);
                            hpcrRecord.StfLogId                  = stfLogId;
                            hpcrRecord.StfDigitalSendServerJobId = stfDigitalSendServerJobid;


                            // public distributions and Send to Me are currently inserting two records into the archive table.
                            // ignore the one that has a Guid for the destination
                            if (!hpcrRecord.JobType.StartsWith("second"))
                            {
                                result.Add(hpcrRecord);
                            }
                            else
                            {
                                if (ProcessRecordForwarding(result, hpcrRecord))
                                {
                                    UpdateHpcrDatabase(adapter, hpcrRecord);
                                }
                            }
                        }
                        reader.Close();
                    }
                }
                catch (SqlException sqlEx)
                {
                    TraceFactory.Logger.Error("Error retrieving list of records.  Aborting.", sqlEx);
                    return(result);
                }

                TraceFactory.Logger.Debug("Found {0} records.".FormatWith(result.Count));
            }
            return(result);
        }