Example #1
0
        public void DockedPass()
        {
            if (Status == DockedStatus.Apply)
            {
                ThrowIfNoPermissions();
                using (var scope = new System.Transactions.TransactionScope())
                {
                    _LazyDockedRecord.Value.status  = DockedStatus.Pass;
                    _LazyDockedRecord.Value.updated = DateTime.Now;
                    _DockedRecordRepository.SaveChanges();

                    //推送
                    var footprint = _FootPrintServiceFactory.GetService(Fid);
                    _FootPrintDockedEventFactory.CreateEvent().OnDockedPass(this, footprint.Pid, footprint.ProjectName);
                    scope.Complete();
                }
            }
        }
        private void AddFootPrint(Models.ImportFootChatModel model, long[] tids)
        {
            var tgFid = model.TgFid;
            var now   = DateTime.Now;

            using (var scope = new TransactionScope())
            {
                if (!CheckExistFootPrint(tgFid))
                {
                    var entity = _FootPrintRepository.Add(new Data.FootPrint()
                    {
                        uid          = model.Uid,
                        pid          = model.Pid,
                        address      = model.Adddress,
                        areaNo       = model.AreaNo,
                        content      = model.Content,
                        latitude     = model.Latitude,
                        longitude    = model.Longitude,
                        created      = now,
                        isEnable     = true,
                        state        = FootPrintState.None,
                        orderUpdated = now,
                        tgFid        = tgFid,
                        updated      = now,
                    });
                    _FootPrintRepository.Add(entity);
                    _FootPrintRepository.SaveChanges();
                    var fid     = entity.fid;
                    var service = _FootPrintServiceFactory.GetService(entity.fid);
                    var imags   = (model.Imags ?? new Models.ImportFootPrintImg[0]).Where(p => !string.IsNullOrWhiteSpace(p.Imag));
                    if (imags.Count() > 0)
                    {
                        service.UpdateImages(imags.Select(p => (Model.FootImageInfo)p).ToArray());
                    }
                    service.UpdateTags(tids);
                    _ImportFootPrintRecordRepository.Add(new ImportFootPrintRecord()
                    {
                        fid             = entity.fid,
                        tgFid           = tgFid,
                        isSuccess       = true,
                        uid             = model.Uid,
                        unSuccessReason = ""
                    });
                    _ImportFootPrintRecordRepository.SaveChanges();
                }
                scope.Complete();
            }
        }
Example #3
0
        public IFootPrintService SaveFootPrint()
        {
            //Init();
            InitFootLocation();
            InitAreaNo();
            if (string.IsNullOrWhiteSpace(_AreaNo))
            {
                _AreaNo = "0001";
            }
            var now = DateTime.Now;
            IFootPrintService service = null;

            using (var scope = new TransactionScope())
            {
                Data.FootPrint entity = null;
                if (_Fid > 0)
                {
                    entity = _FootPrintRepository.Entities.FirstOrDefault(p => p.fid == _Fid);
                    ExceptionHelper.ThrowIfTrue(entity.uid != _Uid, "uid", "用户不允许修改他人的足迹");
                    ExceptionHelper.ThrowIfTrue(entity.state == FootPrintState.Pass, "", "已通过的足迹不能修改");
                }
                if (entity == null)
                {
                    entity = _FootPrintRepository.Add(new Data.FootPrint()
                    {
                        uid          = _Uid,
                        created      = now,
                        isEnable     = true,
                        state        = FootPrintState.None,
                        orderUpdated = now,
                    });
                }
                if (entity.pid != ProjectSource.pid)
                {
                    entity.pid = ProjectSource.pid;
                }
                if (!string.IsNullOrWhiteSpace(_Address) && _Address != entity.address)
                {
                    entity.address = _Address;
                }
                if (!string.IsNullOrWhiteSpace(_Content))
                {
                    entity.content = _Content;
                }
                if (_Latitude > 0 && _Longitude > 0 && (_Latitude != entity.latitude || _Longitude != entity.longitude))
                {
                    entity.latitude  = _Latitude;
                    entity.longitude = _Longitude;
                    if (!string.IsNullOrWhiteSpace(_AreaNo) && _AreaNo != "0001")
                    {
                        entity.areaNo = _AreaNo;
                    }
                }
                if (!string.IsNullOrWhiteSpace(_AreaNo) && string.IsNullOrWhiteSpace(entity.areaNo))
                {
                    entity.areaNo = _AreaNo;
                }
                entity.updated = now;
                _FootPrintRepository.SaveChanges();
                service = _FootPrintServiceFactory.GetService(entity.fid);
                service.UpdateImages(_Image);
                service.UpdateTags(_Tags);
                if (entity.state == FootPrintState.UnPass)
                {
                    entity.state = FootPrintState.None;
                }
                _FootPrintRepository.SaveChanges();


                scope.Complete();
            }
            return(service);
        }