Beispiel #1
0
        public ImportQueue ImportQueueGet(int importQueueId)
        {
            ImportQueue retVal = new EmptyImportQueue();

            using (IDbConnection conn = DbHelper.GetDBConnection())
            {
                try
                {
                    var para = new DynamicParameters();
                    para.Add("@FdpImportQueueId", importQueueId, DbType.Int32);

                    var result = conn.Query <ImportQueueDataItem>("dbo.Fdp_ImportQueue_Get", para, commandType: CommandType.StoredProcedure).FirstOrDefault();
                    if (result != null)
                    {
                        result.ImportType   = ImportTypeDataItem.ToImportType(result);
                        result.ImportStatus = ImportStatusDataItem.ToImportStatus(result);
                        //HydrateImportErrors(result, conn);

                        retVal = ImportQueueDataItem.ToImportQueue(result);
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                    throw;
                }
            }

            return(retVal);
        }
Beispiel #2
0
        public ImportQueue ImportQueueSave(ImportQueue importQueue)
        {
            ImportQueue retVal;

            using (var conn = DbHelper.GetDBConnection())
            {
                try
                {
                    var para = new DynamicParameters();

                    para.Add("@CDSId", CurrentCDSID, DbType.String, size: 16);
                    para.Add("@OriginalFileName", importQueue.OriginalFileName, DbType.String);
                    para.Add("@FilePath", importQueue.FilePath, DbType.String);
                    para.Add("@FdpImportTypeId", (int)importQueue.ImportType.ImportTypeDefinition, DbType.Int32);
                    para.Add("@FdpImportStatusId", (int)importQueue.ImportStatus.ImportStatusCode, DbType.Int32);
                    para.Add("@ProgrammeId", importQueue.ProgrammeId, DbType.Int32);
                    para.Add("@Gateway", importQueue.Gateway, DbType.String);
                    para.Add("@DocumentId", importQueue.DocumentId, DbType.Int32);

                    var result = conn
                                 .Query <ImportQueueDataItem>("dbo.Fdp_ImportQueue_Save", para, commandType: CommandType.StoredProcedure)
                                 .FirstOrDefault();

                    result.ImportType   = ImportTypeDataItem.ToImportType(result);
                    result.ImportStatus = ImportStatusDataItem.ToImportStatus(result);
                    //HydrateImportErrors(result, conn);

                    retVal = ImportQueueDataItem.ToImportQueue(result);
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                    throw;
                }
            }

            return(retVal);
        }
Beispiel #3
0
        public PagedResults <ImportQueue> ImportQueueGetMany(ImportQueueFilter filter)
        {
            PagedResults <ImportQueue> retVal = null;

            using (IDbConnection conn = DbHelper.GetDBConnection())
            {
                try
                {
                    var para                = new DynamicParameters();
                    var totalRecords        = 0;
                    var totalDisplayRecords = 0;

                    if (filter.PageIndex.HasValue)
                    {
                        para.Add("@PageIndex", filter.PageIndex.Value, DbType.Int32);
                    }
                    if (filter.PageSize.HasValue)
                    {
                        para.Add("@PageSize", filter.PageSize.Value, DbType.Int32);
                    }
                    if (filter.ImportStatus != enums.ImportStatus.NotSet)
                    {
                        para.Add("@FdpImportStatusId", (int)filter.ImportStatus, DbType.Int32);
                    }
                    if (!string.IsNullOrEmpty(filter.FilterMessage))
                    {
                        para.Add("@FilterMessage", filter.FilterMessage, DbType.String, size: 50);
                    }
                    //if (filter.SortIndex.HasValue)
                    //{
                    //    para.Add("@SortIndex", filter.SortIndex.Value, dbType: DbType.Int32);
                    //}
                    para.Add("@SortIndex", filter.SortIndex.GetValueOrDefault(), DbType.Int32);
                    if (filter.SortDirection != enums.SortDirection.NotSet)
                    {
                        var direction = filter.SortDirection == enums.SortDirection.Descending ? "DESC" : "ASC";
                        para.Add("@SortDirection", direction, DbType.String);
                    }
                    else
                    {
                        para.Add("@SortDirection", "DESC", DbType.String);
                    }
                    para.Add("@TotalPages", dbType: DbType.Int32, direction: ParameterDirection.Output);
                    para.Add("@TotalRecords", dbType: DbType.Int32, direction: ParameterDirection.Output);
                    para.Add("@TotalDisplayRecords", dbType: DbType.Int32, direction: ParameterDirection.Output);

                    var results = conn.Query <ImportQueueDataItem>("dbo.Fdp_ImportQueue_GetMany", para, commandType: CommandType.StoredProcedure);

                    if (results.Any())
                    {
                        totalRecords        = para.Get <int>("@TotalRecords");
                        totalDisplayRecords = para.Get <int>("@TotalDisplayRecords");
                    }
                    retVal = new PagedResults <ImportQueue>
                    {
                        PageIndex           = filter.PageIndex ?? 1,
                        TotalRecords        = totalRecords,
                        TotalDisplayRecords = totalDisplayRecords,
                        PageSize            = filter.PageSize ?? totalRecords
                    };

                    var currentPage = new List <ImportQueue>();

                    foreach (var result in results)
                    {
                        result.ImportType   = ImportTypeDataItem.ToImportType(result);
                        result.ImportStatus = ImportStatusDataItem.ToImportStatus(result);
                        //HydrateImportErrors(result, conn);

                        currentPage.Add(ImportQueueDataItem.ToImportQueue(result));
                    }

                    retVal.CurrentPage = currentPage;
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                    throw;
                }
            }

            return(retVal);
        }