コード例 #1
0
        public static RoutingFileViewModel GetRoutingFileView(RoutingFileFilterModel filter)
        {
            ACTION = "GetRoutingFileView(RoutingFileFilterModel)";
            try
            {
                ResponseModel response    = new ResponseModel();
                int           totalRecord = 0;
                decimal       lastVersion = 0;

                var model = RoutingFileDAL.GetRoutingFileList(filter, ref totalRecord, ref response, ref lastVersion);
                filter.Pagination.TotalRecord = totalRecord;

                PaginationModel pagination = new PaginationModel(totalRecord, filter.Pagination.Page, filter.Pagination.Take);
                filter.Pagination             = pagination;
                filter.LastRoutingFileVersion = lastVersion;

                return(new RoutingFileViewModel()
                {
                    Action = ACTION,
                    Source = SOURCE,
                    Status = response.Status,
                    Message = response.Message,
                    List = model,
                    Filter = filter
                });
            }
            catch (Exception ex)
            {
                return(new RoutingFileViewModel()
                {
                    Action = ACTION,
                    Source = SOURCE,
                    Status = false,
                    Message = ex.Message,
                    List = null,
                    Filter = filter
                });
            }
        }
コード例 #2
0
        public static List <RoutingFileModel> GetRoutingFileList(RoutingFileFilterModel filter, ref int totalRecord, ref ResponseModel response, ref decimal lastVersion)
        {
            ACTION = "GetRoutingFileList(RoutingFileFilterModel)";
            try
            {
                using (UTMMABCDBEntities context = new UTMMABCDBEntities())
                {
                    filter.RoutingFileIDs = filter.RoutingFileIDs != null ? filter.RoutingFileIDs : new int[] { };
                    var IQuery = context.USR_TMMA_ROUTING_FILE
                                 .Where(o =>
                                        (!string.IsNullOrEmpty(filter.Keywords) ?
                                         (o.RecObjectName.Contains(filter.Keywords)) ||
                                         (o.CreatedBy.Contains(filter.Keywords))
                        : true) &&
                                        (filter.RoutingFileID.HasValue ? o.RoutingFileID == filter.RoutingFileID.Value : true) &&
                                        (filter.RoutingFileIDs.Count() > 0 ? filter.RoutingFileIDs.Contains(o.RoutingFileID) : true) &&
                                        (!string.IsNullOrEmpty(filter.RecObjectName) ? filter.RecObjectName.Contains(o.RecObjectName) : true) &&
                                        (filter.ProductsTypeID.HasValue ? o.ProductsTypeID == filter.ProductsTypeID.Value : true) &&
                                        (filter.IsActive.HasValue ? o.IsActive == 1 : true)
                                        );

                    totalRecord = IQuery.Count();

                    var lists = filter.Sort == "asc"
                        ? filter.Order == "RecObjectName" ? IQuery.OrderBy(o => o.RecObjectName)
                        : filter.Order == "UserSAP" ? IQuery.OrderBy(o => o.UserSAP)
                        : filter.Order == "Version" ? IQuery.OrderBy(o => o.RoutingFileVersion)
                        : filter.Order == "Status" ? IQuery.OrderBy(o => o.RoutingFileStatus)
                        : filter.Order == "ValidDate" ? IQuery.OrderBy(o => o.ValidDate)
                        : filter.Order == "CreatedBy" ? IQuery.OrderBy(o => o.CreatedBy)
                        : filter.Order == "CreatedDate" ? IQuery.OrderBy(o => o.CreatedDate)
                        : IQuery.OrderBy(o => o.CreatedDate)
                        : filter.Order == "RecObjectName" ? IQuery.OrderByDescending(o => o.RecObjectName)
                        : filter.Order == "UserSAP" ? IQuery.OrderByDescending(o => o.UserSAP)
                        : filter.Order == "Version" ? IQuery.OrderByDescending(o => o.RoutingFileVersion)
                        : filter.Order == "Status" ? IQuery.OrderByDescending(o => o.RoutingFileStatus)
                        : filter.Order == "ValidDate" ? IQuery.OrderByDescending(o => o.ValidDate)
                        : filter.Order == "CreatedBy" ? IQuery.OrderByDescending(o => o.CreatedBy)
                        : filter.Order == "CreatedDate" ? IQuery.OrderByDescending(o => o.CreatedDate)
                        : IQuery.OrderByDescending(o => o.CreatedDate);

                    lastVersion = IQuery.OrderByDescending(o => o.RoutingFileVersion).FirstOrDefault().RoutingFileVersion.GetValueOrDefault();

                    List <USR_TMMA_ROUTING_FILE> list = filter.Pagination.IsPaging ? lists.Skip(filter.Pagination.Skip).Take(filter.Pagination.Take).ToList() : lists.ToList();

                    List <RoutingFileModel> mList = Mapping(list);

                    response = new ResponseModel()
                    {
                        Source  = SOURCE,
                        Action  = ACTION,
                        Status  = true,
                        Message = "Success"
                    };

                    return(mList);
                }
            }
            catch (Exception ex)
            {
                totalRecord = 0;

                response = new ResponseModel()
                {
                    Source  = SOURCE,
                    Action  = ACTION,
                    Status  = false,
                    Message = ex.Message
                };

                return(null);
            }
        }
コード例 #3
0
ファイル: Core.cs プロジェクト: champ6803/TMMAConversion
 /// <summary>
 /// Monomer Routing
 /// </summary>
 /// <param name="filter"></param>
 /// <returns></returns>
 public RoutingFileViewModel GetRoutingFileView(RoutingFileFilterModel filter)
 {
     return(RoutingFileBLL.GetRoutingFileView(filter));
 }