示例#1
0
        public void Checked(long fileId, string comments)
        {
            var file = GetFileById(fileId);

            if (file == null)
            {
                throw new ArgumentException(string.Format("Дело с идентификатором {0} не найдено", fileId));
            }

            var status = FileStageService.GetStatusForStage(FileStages.Checked);

            if (status == null)
            {
                throw new ArgumentException(string.Format("Не определен статус для дел, переданных на проверку"));
            }

            file.CurrentStatus = status;

            var unit_of_work = UnitOfWorkProvider.GetUnitOfWork();

            unit_of_work.BeginTransaction();
            FileRepository.Update(file);
            FileStatusService.SetStatus(fileId, status.Id, DateTime.Now, comments);
            unit_of_work.Commit();
        }
示例#2
0
        public void Update(ServiceAction action)
        {
            var unit_of_work = UnitOfWorkProvider.GetUnitOfWork();

            unit_of_work.BeginTransaction();
            Repository.Update(action);

            //Обрабатываем дело
            //Если услуга не требует дела, то удаляем существующее
            //Если в результате смены типа приема требуется создание дела, тогда создаем
            var file = FileService.GetFileByActionId(action.Id);

            if (action.Type.NeedMakeFile && file == null)
            {
                FileService.Add(action);
                file = FileService.GetFileByActionId(action.Id);
            }
            else if (!action.Type.NeedMakeFile && file != null)
            {
                FileService.Delete(file.Id);
            }

            //Синхронизируем данные дела и приема
            if (action.Type.NeedMakeFile && file != null)
            {
                file.Expert = action.User;
                file.Ogv    = action.Service.Organization;
                file.Date   = action.Date;

                FileService.Update(file);
            }

            unit_of_work.Commit();
        }
示例#3
0
        public void Delete(long id)
        {
            var unit_of_work = UnitOfWorkProvider.GetUnitOfWork();

            unit_of_work.BeginTransaction();
            FileRepository.Delete(id);
            unit_of_work.Commit();
        }
示例#4
0
 public void SaveAll(List <Address> items)
 {
     using (var unitOfWork = UnitOfWorkProvider.GetUnitOfWork())
     {
         unitOfWork.DB.InsertAll(items);
         unitOfWork.Save();
     }
 }
示例#5
0
 public void SaveStreets(List <AllDbInfoViewModel> items)
 {
     using (var unitOfWork = UnitOfWorkProvider.GetUnitOfWork())
     {
         unitOfWork.DB.InsertAll(items);
         unitOfWork.Save();
     }
 }
示例#6
0
 public List <Address> GetEmptyHousesList(int limit)
 {
     using (var unitOfWork = UnitOfWorkProvider.GetUnitOfWork())
     {
         var sql = $"select * from tbltestaddress where hn is null limit {limit}";
         return(unitOfWork.DB.Select <Address>(sql));
     }
 }
示例#7
0
        public void Update(File file)
        {
            var unit_of_work = UnitOfWorkProvider.GetUnitOfWork();

            unit_of_work.BeginTransaction();
            FileRepository.Update(file);
            unit_of_work.Commit();
        }
示例#8
0
        public void Update(Package package)
        {
            var unit_of_work = UnitOfWorkProvider.GetUnitOfWork();

            unit_of_work.BeginTransaction();

            PackageRepository.Update(package);

            unit_of_work.Commit();
        }
        public void DeleteType(long typeId)
        {
            var unit_of_work = UnitOfWorkProvider.GetUnitOfWork();

            unit_of_work.BeginTransaction();
            TypeRepo.Delete(typeId);
            unit_of_work.Commit();

            _is_type_cache_valid = false;
        }
示例#10
0
        public void Update(FileStatus status)
        {
            var unit_of_work = UnitOfWorkProvider.GetUnitOfWork();

            unit_of_work.BeginTransaction();
            Repository.Update(status);
            unit_of_work.Commit();

            _is_cache_valid = false;
        }
示例#11
0
        public void UpdateOgranization(Organization organization)
        {
            var unit_of_work = UnitOfWorkProvider.GetUnitOfWork();

            unit_of_work.BeginTransaction();
            OrgRepo.Update(organization);
            unit_of_work.Commit();

            _is_org_cache_valid = false;
        }
示例#12
0
        public void DeleteOrganization(long organizationId)
        {
            var unit_of_work = UnitOfWorkProvider.GetUnitOfWork();

            unit_of_work.BeginTransaction();
            OrgRepo.Delete(organizationId);
            unit_of_work.Commit();

            _is_org_cache_valid = false;
        }
示例#13
0
        public void Delete(Int64 statusId)
        {
            var unit_of_work = UnitOfWorkProvider.GetUnitOfWork();

            unit_of_work.BeginTransaction();
            Repository.Delete(statusId);
            unit_of_work.Commit();

            _is_cache_valid = false;
        }
示例#14
0
        public void Delete(Int64 id)
        {
            var work_of_unit = UnitOfWorkProvider.GetUnitOfWork();

            work_of_unit.BeginTransaction();
            Repository.Delete(id);
            work_of_unit.Commit();

            _is_cache_valid = false;
        }
示例#15
0
        public void UpdateType(OrganizationType type)
        {
            var unit_of_work = UnitOfWorkProvider.GetUnitOfWork();

            unit_of_work.BeginTransaction();
            TypeRepo.Update(type);
            unit_of_work.Commit();

            _is_type_cache_valid = false;
        }
示例#16
0
        public void Update(Service service)
        {
            var work_of_unit = UnitOfWorkProvider.GetUnitOfWork();

            work_of_unit.BeginTransaction();
            Repository.Update(service);
            work_of_unit.Commit();

            _is_cache_valid = false;
        }
示例#17
0
        public IEnumerable <long> AcceptForControl(IEnumerable <long> file_ids)
        {
            //1. Проверяем право текущего пользователя принимать дела
            //2. Проверяем наличие статуса для дел, переданных на контроль
            //3. Формируем список дел (из переданных), которые еще не заняты другими контролерами
            //4. В одной транзакции принимает дел на контроль

            //1.
            var user = UserService.GetCurrentUser();

            if (!user.IsController)
            {
                throw new DomainException("Текущий пользователь не имеет прав для приема дел");
            }

            //2.
            var status = FileStageService.GetStatusForStage(FileStages.SendForControl);

            if (status == null)
            {
                throw new ArgumentException(string.Format("Не определен статус для дел, переданных на проверку"));
            }

            //3.
            List <File>  free_files    = new List <File>();
            List <Int64> free_file_ids = new List <Int64>();

            foreach (var id in file_ids)
            {
                var file = GetFileById(id);

                if (file.Controller == null)
                {
                    free_files.Add(file);
                    free_file_ids.Add(id);
                }
            }

            //4.
            var unit_of_work = UnitOfWorkProvider.GetUnitOfWork();

            unit_of_work.BeginTransaction();

            foreach (var file in free_files)
            {
                file.Controller    = user;
                file.CurrentStatus = status;
                FileRepository.Update(file);
                FileStatusService.SetStatus(file.Id, status.Id, DateTime.Now, string.Empty);
            }

            unit_of_work.Commit();

            return(free_file_ids);
        }
示例#18
0
        public void Delete(long id)
        {
            var files_old = new List <Int64>(GetPackageFiles(id).Select(m => m.Id));

            var unit_of_work = UnitOfWorkProvider.GetUnitOfWork();

            unit_of_work.BeginTransaction();

            PackageRepository.Delete(id);

            unit_of_work.Commit();

            ReturnStatusForFiles(files_old);
        }
示例#19
0
        public void Delete(long id)
        {
            var unit_of_work = UnitOfWorkProvider.GetUnitOfWork();

            var file = FileService.GetFileByActionId(id);

            unit_of_work.BeginTransaction();
            Repository.Delete(id);
            if (file != null)
            {
                FileService.Delete(file.Id);
            }
            unit_of_work.Commit();
        }
示例#20
0
        public void UpdateStages(IEnumerable <FileStage> stages)
        {
            lock (sync_obj_update) {
                var unit_of_work = UnitOfWorkProvider.GetUnitOfWork();

                unit_of_work.BeginTransaction();
                foreach (var stage in stages)
                {
                    Repository.Update(stage);
                }
                unit_of_work.Commit();

                _is_cache_valid = false;
            }
        }
示例#21
0
        public long CreateType(string caption)
        {
            Debug.Assert(!string.IsNullOrEmpty(caption));

            OrganizationType type = new OrganizationType {
                Caption = caption
            };
            var unit_of_work = UnitOfWorkProvider.GetUnitOfWork();

            unit_of_work.BeginTransaction();
            TypeRepo.Create(type);
            unit_of_work.Commit();

            _is_type_cache_valid = false;

            return(0);
        }
示例#22
0
        public long Create(string caption)
        {
            Debug.Assert(!string.IsNullOrEmpty(caption));

            var status = new FileStatus {
                Caption = caption,
            };

            var unit_of_work = UnitOfWorkProvider.GetUnitOfWork();

            unit_of_work.BeginTransaction();
            Repository.Create(status);
            unit_of_work.Commit();

            _is_cache_valid = false;

            return(0);
        }
示例#23
0
        public long Create(string caption, Int64 organizationId, long parentId)
        {
            Debug.Assert(!string.IsNullOrEmpty(caption));

            var service = new Service {
                Caption      = caption,
                Organization = OrgService.GetOrganizationById(organizationId),
                Parent       = GetServiceById(parentId)
            };

            var work_of_unit = UnitOfWorkProvider.GetUnitOfWork();

            work_of_unit.BeginTransaction();
            Repository.Create(service);
            work_of_unit.Commit();

            _is_cache_valid = false;

            return(0);
        }
示例#24
0
        public long CreateOrganization(string caption, string fullCaption, Int64 typeId)
        {
            Debug.Assert(!string.IsNullOrEmpty(caption));

            var org = new Organization {
                Caption     = caption,
                FullCaption = fullCaption,
                Type        = _cache_types[typeId]
            };

            var unit_of_work = UnitOfWorkProvider.GetUnitOfWork();

            unit_of_work.BeginTransaction();
            OrgRepo.Create(org);
            unit_of_work.Commit();

            _is_org_cache_valid = false;

            return(0);
        }
示例#25
0
        public long CreatePackage(User controller, DateTime date, Organization organization, IEnumerable <long> files, string comment)
        {
            Package package = new Package
            {
                Date         = date,
                Controller   = controller,
                Organization = organization,
                Comment      = comment
            };

            var unit_of_work = UnitOfWorkProvider.GetUnitOfWork();

            unit_of_work.BeginTransaction();

            PackageRepository.Create(package);

            unit_of_work.Commit();

            UpdatePackageFiles(package.Id, files);

            return(package.Id);
        }
示例#26
0
        public long Add(DateTime date, Int64 serviceId, string customer, Int64 typeId, Int64 customerTypeId, Int64 userId, Int64 serviceChildId, bool is_nonresident, bool free_visit, string comments)
        {
            var action = new ServiceAction {
                Date          = date,
                Service       = ServiceService.GetServiceById(serviceId),
                ServiceChild  = ServiceService.GetServiceById(serviceChildId),
                Customer      = customer,
                Type          = TypeService.GetTypeById(typeId),
                CustomerType  = CustomerTypeService.GetTypeById(customerTypeId),
                User          = UserService.GetUserById(userId),
                FreeVisit     = free_visit,
                IsNonresident = is_nonresident,
                Comments      = comments
            };

            if (date == DateTime.Today)
            {
                action.Date = DateTime.Now;
            }
            else
            {
                action.Date = new DateTime(date.Year, date.Month, date.Day, 23, 59, 59);
            }

            var unit_of_work = UnitOfWorkProvider.GetUnitOfWork();

            unit_of_work.BeginTransaction();

            Repository.Create(action);
            //Если тип услуги предполагает создание дела, то создаем дело
            if (action.Type.NeedMakeFile)
            {
                FileService.Add(action);
            }

            unit_of_work.Commit();

            return(0);
        }
示例#27
0
 public NHibernateDao(UnitOfWorkProvider unitOfWorkProvider, string serviceKey)
 {
     m_unitOfWork = unitOfWorkProvider.GetUnitOfWork(serviceKey);
 }