private void GetRemovalListProxy(SpecLabEntities _entities,
                                         DatabaseCommand <GetRemovalListParams, List <RemovalNoteShortData> > paramCommand)
        {
            var removalQuery = (from import in _entities.Removals
                                select import);

            if (!string.IsNullOrEmpty(paramCommand.CallingInfo.RemovalId))
            {
                removalQuery = removalQuery.Where(e => e.RemovalId.StartsWith(paramCommand.CallingInfo.RemovalId));
            }

            if (paramCommand.CallingInfo.StartDate != null)
            {
                removalQuery = removalQuery.Where(e => e.RemovalDate >= paramCommand.CallingInfo.StartDate);
            }

            if (paramCommand.CallingInfo.EndDate != null)
            {
                var limitDate = paramCommand.CallingInfo.EndDate.GetValueOrDefault().AddDays(1);
                removalQuery = removalQuery.Where(e => e.RemovalDate < limitDate);
            }

            removalQuery = removalQuery.OrderByDescending(t => t.RemovalDate);

            var listResult = removalQuery.Select(t => new RemovalNoteShortData()
            {
                RemovalId     = t.RemovalId,
                RemovalUserId = t.RemovalUserId,
                RemovalDate   = t.RemovalDate,
                RemovalReason = t.RemovalReason,
                NumberRemoval = t.SampleNumber
            });

            paramCommand.ReturnValue.AddRange(listResult);
        }
        private void GetImportListProxy(SpecLabEntities _entities,
                                        DatabaseCommand <GetImportListParams, List <ImportNoteShortData> > paramCommand)
        {
            var importQuery = (from import in _entities.Imports
                               select import);

            if (!string.IsNullOrEmpty(paramCommand.CallingInfo.ImportId))
            {
                importQuery = importQuery.Where(e => e.ImportId.StartsWith(paramCommand.CallingInfo.ImportId));
            }

            if (paramCommand.CallingInfo.StartDate != null)
            {
                importQuery = importQuery.Where(e => e.ImportDate >= paramCommand.CallingInfo.StartDate);
            }

            if (paramCommand.CallingInfo.EndDate != null)
            {
                var limitDate = paramCommand.CallingInfo.EndDate.GetValueOrDefault().AddDays(1);
                importQuery = importQuery.Where(e => e.ImportDate < limitDate);
            }

            var listResult = importQuery.Select(t => new ImportNoteShortData()
            {
                ImportId     = t.ImportId,
                ImportUserId = t.ImportUserId,
                ImportDate   = t.ImportDate,
                NumberImport = t.SampleNumber
            });

            listResult = listResult.OrderByDescending(t => t.ImportDate);

            paramCommand.ReturnValue.AddRange(listResult);
        }
Esempio n. 3
0
        private void GetLoginUserInfoProxy(SpecLabEntities _entities,
                                           DatabaseCommand <string, LoginUserInfo> paramCommand)
        {
            if (paramCommand.CallingInfo != null)
            {
                if (CommonConstant.SystemAdmin.ToLower().Equals(paramCommand.CallingInfo.ToLower()))
                {
                    paramCommand.ReturnValue = GetSystemAdminLoginInfo();
                }
                else
                {
                    var dbItem = _entities.UserInfoes
                                 .FirstOrDefault(u => u.UserId.ToLower().Equals(paramCommand.CallingInfo.ToLower()));

                    if (dbItem != null)
                    {
                        var existsUser = new LoginUserInfo()
                        {
                            FullName = dbItem.FullName,
                            UserId   = dbItem.UserId,
                            Status   = CommonUtils.GetEnumFromValue <UserStatus>(dbItem.Status)
                        };

                        var rights = dbItem.UserRights.ToList();

                        existsUser.Rights.AddRange(dbItem.UserRights.ToList().ConvertAll(ConvertUserRightCode));

                        paramCommand.ReturnValue = existsUser;
                    }
                }
            }
        }
Esempio n. 4
0
        private void UpdateUserRightsProxy(SpecLabEntities _entities,
                                           DatabaseCommand <UpdateRightParams, bool> paramCommand)
        {
            var listRights = (from u in _entities.UserRights
                              where u.UserInfo.UserId.ToLower().Equals(paramCommand.CallingInfo.UserId.ToLower())
                              select u);

            foreach (var right in listRights)
            {
                _entities.UserRights.Remove(right);
            }
            _entities.SaveChanges();

            foreach (var rightCode in paramCommand.CallingInfo.UpdateRights)
            {
                _entities.UserRights.Add(new UserRight()
                {
                    CreateDate = DateTime.Now,
                    UpdateDate = DateTime.Now,
                    UserId     = paramCommand.CallingInfo.UserId,
                    RightCode  = rightCode.ToString()
                });
            }
            _entities.SaveChanges();

            paramCommand.ReturnValue = true;
        }
Esempio n. 5
0
        private void ChangePasswordProxy(SpecLabEntities _entities,
                                         DatabaseCommand <ChangePassParams, bool> paramCommand)
        {
            paramCommand.ReturnValue = false;

            var selectedUser = (from u in _entities.UserInfoes
                                where u.UserId.ToLower().Equals(paramCommand.CallingInfo.UserId.ToLower())
                                select u).FirstOrDefault();

            if (selectedUser == null)
            {
                throw new BusinessException(ErrorCode.UserIdNotExists);
            }
            else
            {
                string passwordHash = GeneratePasswordHash(
                    paramCommand.CallingInfo.OldPass, selectedUser.PasswordSalt);
                if (!passwordHash.Equals(selectedUser.Password))
                {
                    throw new BusinessException(ErrorCode.PasswordNotMatch);
                }
                else
                {
                    string passwordSalt = Guid.NewGuid().ToString();
                    passwordHash = GeneratePasswordHash(paramCommand.CallingInfo.NewPass, passwordSalt);

                    selectedUser.Password     = passwordHash;
                    selectedUser.PasswordSalt = passwordSalt;

                    _entities.SaveChanges();

                    paramCommand.ReturnValue = true;
                }
            }
        }
        private void GetExportHistoryProxy(SpecLabEntities _entities,
                                           DatabaseCommand <GetExportHistoryParam, List <ReportExportHistoryInfo> > paramCommand)
        {
            var historyQuery = (from history in _entities.viewExportHistories
                                select history);

            if (paramCommand.CallingInfo.StartDate != null)
            {
                historyQuery = historyQuery.Where(history => history.ExportDate >= paramCommand.CallingInfo.StartDate);
            }

            if (paramCommand.CallingInfo.EndDate != null)
            {
                var limitDate = paramCommand.CallingInfo.EndDate.GetValueOrDefault().AddDays(1);
                historyQuery = historyQuery.Where(history => history.ExportDate < limitDate);
            }

            historyQuery = historyQuery.OrderByDescending(history => history.ExportDate);

            var listResult = historyQuery.Select(history => new ReportExportHistoryInfo()
            {
                TubeId         = history.TubeId,
                ExportDate     = history.ExportDate,
                ExportUserId   = history.ExportUserId,
                ExportReason   = history.ExportReason,
                SampleType     = (SampleType)history.SampleType,
                UpdateDate     = history.UpdateDate,
                UpdateUserId   = history.UpdateUserId,
                StorageId      = history.StorageId,
                MaximumStorage = history.NumberStorage,
                LocationNum    = history.LocationNum
            });

            paramCommand.ReturnValue.AddRange(listResult);
        }
Esempio n. 7
0
        private void AddStorageInfoProxy(SpecLabEntities _entities,
                                         DatabaseCommand <ShortStorageInfo, object> paramCommand)
        {
            var existStorage = (from storage in _entities.Storages
                                where storage.StorageId.Equals(paramCommand.CallingInfo.StorageId, StringComparison.OrdinalIgnoreCase)
                                select storage).FirstOrDefault();

            if (existStorage != null)
            {
                throw new BusinessException(ErrorCode.StorageIdExists);
            }
            else
            {
                _entities.Storages.Add(new Storage()
                {
                    UpdateDate    = DateTime.Now,
                    CreateDate    = DateTime.Now,
                    NumberStorage = paramCommand.CallingInfo.NumberStorage,
                    NumColumn     = paramCommand.CallingInfo.NumColumn,
                    NumRows       = paramCommand.CallingInfo.NumRows,
                    StorageId     = paramCommand.CallingInfo.StorageId
                });

                _entities.SaveChanges();
            }
        }
Esempio n. 8
0
        public List <ShortStorageInfo> GetListStorage()
        {
            var command = new DatabaseCommand <object, List <ShortStorageInfo> >();

            this.ProxyCalling(GetListStorageIdProxy, command);
            return(command.ReturnValue);
        }
Esempio n. 9
0
        public List <string> GetListStorageId()
        {
            var command = new DatabaseCommand <object, List <ShortStorageInfo> >();

            this.ProxyCalling(GetListStorageIdProxy, command);
            return(command.ReturnValue.ConvertAll(ConvertShortStorageInfoToString));
        }
Esempio n. 10
0
        private void SaveContentProxy(SpecLabEntities _entities,
                                      DatabaseCommand <ContentInfo, object> paramCommand)
        {
            var existContent = (from content in _entities.Contents
                                where content.ContentId == paramCommand.CallingInfo.ContentId
                                select content).FirstOrDefault();

            var loginInfo = SessionUtils.LoginUserInfo;

            if (existContent == null)
            {
                //throw new BusinessException(ErrorCode.ContentIdNotExists, paramCommand.CallingInfo);
                _entities.Contents.Add(new Content()
                {
                    CreateUser  = loginInfo == null ? null : loginInfo.UserId,
                    UpdateUser  = loginInfo == null ? null : loginInfo.UserId,
                    UpdateDate  = DateTime.Now,
                    CreateDate  = DateTime.Now,
                    ContentId   = paramCommand.CallingInfo.ContentId,
                    ContentText = paramCommand.CallingInfo.ContentText
                });
                _entities.SaveChanges();
            }
            else
            {
                existContent.UpdateDate  = DateTime.Now;
                existContent.UpdateUser  = loginInfo == null ? null : loginInfo.UserId;
                existContent.ContentText = paramCommand.CallingInfo.ContentText;
                _entities.SaveChanges();
            }
        }
Esempio n. 11
0
        private void DeleteStorageInfoProxy(SpecLabEntities _entities,
                                            DatabaseCommand <string, object> paramCommand)
        {
            var existStorage = (from storage in _entities.Storages
                                where storage.StorageId.Equals(paramCommand.CallingInfo, StringComparison.OrdinalIgnoreCase)
                                select storage).FirstOrDefault();

            if (existStorage == null)
            {
                throw new BusinessException(ErrorCode.StorageIdNotExists, paramCommand.CallingInfo);
            }
            else
            {
                var checkStorageInUse = (from exists in _entities.TubeSamples
                                         where exists.StorageId == paramCommand.CallingInfo
                                         select exists.StorageId);
                if (checkStorageInUse.Any())
                {
                    throw new BusinessException(ErrorCode.StorageIdAlreadyInUse);
                }

                checkStorageInUse = (from exists in _entities.SampleHistories
                                     where exists.StorageId == paramCommand.CallingInfo
                                     select exists.StorageId);
                if (checkStorageInUse.Any())
                {
                    throw new BusinessException(ErrorCode.StorageIdAlreadyInUse);
                }

                _entities.Storages.Remove(existStorage);
                _entities.SaveChanges();
            }
        }
Esempio n. 12
0
        private void GetSampleStatisticsProxy(SpecLabEntities _entities,
                                              DatabaseCommand <string, List <ReportSampleStatisticInfo> > paramCommand)
        {
            var query = _entities.viewSampleStatistics
                        .Where(statistic => statistic.Status != (int)TubeSampleStatus.Remove);

            paramCommand.ReturnValue = query.ToList().ConvertAll(ConvertReportSampleStatisticInfo);
        }
Esempio n. 13
0
        public List <ShortStorageInfo> GetStorageInfoByID(string _storageid)
        {
            ShortStorageInfo _ShortStorageInfo = new ShortStorageInfo();
            var command = new DatabaseCommand <object, List <ShortStorageInfo> >();

            this.ProxyCalling(GetListStorageIdProxy, command);
            return(command.ReturnValue.Where(s => s.StorageId.Contains(_storageid)).ToList());
        }
Esempio n. 14
0
        public void DeleteStorageInfo(string storageId)
        {
            var command = new DatabaseCommand <string, object>()
            {
                CallingInfo = storageId
            };

            this.ProxyCalling(DeleteStorageInfoProxy, command);
        }
        public void UpdateTube(UpdateTubeParams updateTube)
        {
            var command = new DatabaseCommand <UpdateTubeParams, bool>()
            {
                CallingInfo = updateTube,
            };

            this.ProxyCalling(UpdateTubeProxy, command);
        }
Esempio n. 16
0
        public void AddStorageInfo(ShortStorageInfo storageInfo)
        {
            var command = new DatabaseCommand <ShortStorageInfo, object>()
            {
                CallingInfo = storageInfo
            };

            this.ProxyCalling(AddStorageInfoProxy, command);
        }
Esempio n. 17
0
        public void SaveContentInfo(ContentInfo contentInfo)
        {
            var command = new DatabaseCommand <ContentInfo, object>()
            {
                CallingInfo = contentInfo
            };

            this.ProxyCalling(SaveContentProxy, command);
        }
        public void ImportSample(SampleSpecInfo sampleSpec)
        {
            var command = new DatabaseCommand <SampleSpecInfo, bool>()
            {
                CallingInfo = sampleSpec,
                ReturnValue = false
            };

            this.ProxyCalling(ImportSampleProxy, command);
        }
        public void ExportSamples(ExportSampleParam exportNote)
        {
            var command = new DatabaseCommand <ExportSampleParam, bool>()
            {
                CallingInfo = exportNote,
                ReturnValue = false
            };

            this.ProxyCalling(ExportSamplesProxy, command);
        }
        public void RemovalSamples(RemovalSampleParam removalNote)
        {
            var command = new DatabaseCommand <RemovalSampleParam, bool>()
            {
                CallingInfo = removalNote,
                ReturnValue = false
            };

            this.ProxyCalling(RemovalSamplesProxy, command);
        }
Esempio n. 21
0
        public bool ResetPassword(ResetPassParams passParams)
        {
            var command = new DatabaseCommand <ResetPassParams, bool>()
            {
                CallingInfo = passParams
            };

            this.ProxyCalling(ResetPasswordProxy, command);
            return(command.ReturnValue);
        }
Esempio n. 22
0
        private void GetAllShortUserInfoProxy(SpecLabEntities _entities,
                                              DatabaseCommand <object, List <ShortUserInfo> > paramCommand)
        {
            var userStatusEnable = UserStatus.Enable.ToString();
            var listUsers        = (from u in _entities.UserInfoes
                                    where u.Status.Equals(userStatusEnable)
                                    select u).ToList();

            paramCommand.ReturnValue = listUsers.ConvertAll(ConvertToShortUserInfo);
        }
        public SampleSpecInfo GetSampleSpec(string sampleSpecId)
        {
            var command = new DatabaseCommand <string, SampleSpecInfo>()
            {
                CallingInfo = sampleSpecId,
            };

            this.ProxyCalling(GetSampleSpecProxy, command);
            return(command.ReturnValue);
        }
Esempio n. 24
0
        public LoginUserInfo UpdateUser(LoginUserInfo loginUserInfo)
        {
            var command = new DatabaseCommand <LoginUserInfo, LoginUserInfo>()
            {
                CallingInfo = loginUserInfo
            };

            this.ProxyCalling(UpdateUserProxy, command);
            return(command.ReturnValue);
        }
Esempio n. 25
0
        public bool DeleteUser(string userId)
        {
            var command = new DatabaseCommand <string, bool>()
            {
                CallingInfo = userId
            };

            this.ProxyCalling(DeleteUserProxy, command);
            return(command.ReturnValue);
        }
Esempio n. 26
0
        public LoginUserInfo GetLoginUserInfo(string userId)
        {
            var command = new DatabaseCommand <string, LoginUserInfo>()
            {
                CallingInfo = userId
            };

            this.ProxyCalling(GetLoginUserInfoProxy, command);
            return(command.ReturnValue);
        }
        public List <SampleHistoryInfo> GetImportHistory(string sampleSpecId)
        {
            var command = new DatabaseCommand <string, List <SampleHistoryInfo> >()
            {
                CallingInfo = sampleSpecId,
            };

            this.ProxyCalling(GetImportHistoryProxy, command);
            return(command.ReturnValue);
        }
Esempio n. 28
0
        public int GetNumberRemoval(GetNumberRemovalParams rightParams)
        {
            var command = new DatabaseCommand <GetNumberRemovalParams, int>()
            {
                CallingInfo = rightParams,
                ReturnValue = 0
            };

            this.ProxyCalling(GetNumberRemovalProxy, command);
            return(command.ReturnValue);
        }
Esempio n. 29
0
        public List <TubeExportCount> GetTubeExportCount(GetTubeExportCountParams rightParams)
        {
            var command = new DatabaseCommand <GetTubeExportCountParams, List <TubeExportCount> >()
            {
                CallingInfo = rightParams,
                ReturnValue = new List <TubeExportCount>()
            };

            this.ProxyCalling(GetTubeExportCountProxy, command);
            return(command.ReturnValue);
        }
Esempio n. 30
0
        public List <ReportExportHistoryInfo> GetExportHistory(GetExportHistoryParam param)
        {
            var command = new DatabaseCommand <GetExportHistoryParam, List <ReportExportHistoryInfo> >()
            {
                CallingInfo = param,
                ReturnValue = new List <ReportExportHistoryInfo>()
            };

            this.ProxyCalling(GetExportHistoryProxy, command);
            return(command.ReturnValue);
        }