示例#1
0
        private void PublishAsNew(PageEntity item)
        {
            if (item.ID.IsNullOrWhiteSpace())
            {
                throw new Exception("Can not publish page while it is new.");
            }

            item.IsPublishedPage = true;
            item.PublishDate     = DateTime.Now;
            var zones       = _zoneService.GetByPage(item);
            var layoutHtmls = _layoutHtmlService.GetByPage(item);
            var widgets     = _widgetService.GetByPageId(item.ID);

            Add(item);
            zones.Each(m =>
            {
                m.PageId = item.ID;
                _zoneService.Add(m);
            });
            layoutHtmls.Each(m =>
            {
                m.PageId = item.ID;
                _layoutHtmlService.Add(m);
            });
            widgets.Each(m =>
            {
                using (var widgetService = _widgetActivator.Create(m))
                {
                    m        = widgetService.GetWidget(m);
                    m.PageID = item.ID;
                    widgetService.Publish(m);
                }
            });
        }
示例#2
0
        public override ServiceResult <LayoutEntity> Add(LayoutEntity item)
        {
            item.ID = Guid.NewGuid().ToString("N");
            var result = base.Add(item);

            if (result.HasViolation)
            {
                return(result);
            }
            if (item.Zones != null)
            {
                item.Zones.Each(m =>
                {
                    m.LayoutId = item.ID;
                    _zoneService.Add(m);
                });
            }
            if (item.Html != null)
            {
                item.Html.Each(m =>
                {
                    m.LayoutId = item.ID;
                    _layoutHtmlService.Add(m);
                });
            }
            return(result);
        }
示例#3
0
        public void Publish(PageEntity item)
        {
            _eventManager.Trigger(Events.OnPagePublishing, item);
            string pageId = item.ID;

            BeginTransaction(() =>
            {
                item.IsPublish   = true;
                item.PublishDate = DateTime.Now;
                base.Update(item);

                var zones       = _zoneService.GetByPage(item);
                var layoutHtmls = _layoutHtmlService.GetByPage(item);


                item.ReferencePageID = item.ID;
                item.IsPublishedPage = true;
                item.PublishDate     = DateTime.Now;

                var widgets = _widgetService.GetByPageId(item.ID);
                Add(item);
                zones.Each(m =>
                {
                    m.PageId = item.ID;
                    _zoneService.Add(m);
                });
                layoutHtmls.Each(m =>
                {
                    m.PageId = item.ID;
                    _layoutHtmlService.Add(m);
                });
                widgets.Each(m =>
                {
                    using (var widgetService = _widgetActivator.Create(m))
                    {
                        m        = widgetService.GetWidget(m);
                        m.PageID = item.ID;
                        widgetService.IsNeedNotifyChange = false;
                        widgetService.Publish(m);
                    }
                });
            });
            const int keepVersions        = 6;
            var       allPublishedVersion = Get(m => m.ReferencePageID == pageId && m.IsPublishedPage == true).OrderByDescending(m => m.PublishDate).ToList();

            if (allPublishedVersion.Count > keepVersions)
            {
                for (int i = keepVersions; i < allPublishedVersion.Count; i++)
                {
                    DeleteVersion(allPublishedVersion[i].ID);
                }
            }
            _widgetService.RemoveCache(pageId);
            _zoneService.RemoveCache(pageId);
            _layoutHtmlService.RemoveCache(pageId);
            _eventManager.Trigger(Events.OnPagePublished, item);
        }
示例#4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidateSubZone())
            {
                try
                {
                    if (ActualZone != null)
                    {
                        ActualZone.Name        = txtNombre.Text;
                        ActualZone.MaxCapacity = int.Parse(txtCapacity.Text);
                        ActualZone.SubZones    = subZone;
                        _zoneService.Update(frmLogin.token, ActualZone);
                        MessageBox.Show("Zona actualizada con exito", "Felicitaciones", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Close();
                    }
                    else
                    {
                        Zone zoneToList = new Zone();
                        zoneToList.MaxCapacity = int.Parse(txtCapacity.Text);
                        zoneToList.Name        = txtNombre.Text;
                        zoneToList.SubZones    = subZone;

                        _zoneService.Add(frmLogin.token, zoneToList);
                        MessageBox.Show("Zona ingresada con exito", "Felicitaciones", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Close();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Excepcion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
        public void ConfirmZoneRequest(string requestId, string currentPersonId)
        {
            var dbRequest = _zoneValidationRequestRepository.GetById(requestId);

            if (dbRequest == null)
            {
                throw new ArgumentOutOfRangeException(nameof(dbRequest.Id), "Invalid ZoneValidationRequestId.");
            }

            if (dbRequest.Status >= ZoneValidationStatus.Declined)
            {
                throw new ArgumentOutOfRangeException(nameof(requestId), "You cannot confirm closed request.");
            }

            if (dbRequest.ResponsiblePersonId != currentPersonId)
            {
                throw new ArgumentOutOfRangeException(nameof(requestId), "You cannot confirm someone else's request.");
            }

            var zone = new Zone
            {
                Id           = dbRequest.TargetZoneId,
                MapRectangle = new MapRectangle(),
                Settings     = new ZoneSettings(),
                OwnerId      = dbRequest.RequesterId,
                Name         = dbRequest.ZoneName
            };

            zone.MapRectangle.TopLeftLatitude      = dbRequest.TopLeftLatitude;
            zone.MapRectangle.TopLeftLongitude     = dbRequest.TopLeftLongitude;
            zone.MapRectangle.BottomRightLatitude  = dbRequest.BottomRightLatitude;
            zone.MapRectangle.BottomRightLongitude = dbRequest.BottomRightLongitude;

            if (dbRequest.RequestType == ZoneValidationType.Creation)
            {
                _zoneService.Add(zone);
            }
            else
            {
                var oldZone = _zoneService.GetZoneById(zone.Id, q => q.Include(x => x.MapRectangle));

                zone.Name            = oldZone.Name;
                zone.Settings        = oldZone.Settings;
                zone.MapRectangle.Id = oldZone.MapRectangle.Id;

                _zoneService.Update(zone);
            }

            dbRequest.Status = ZoneValidationStatus.Confirmed;
            _zoneValidationRequestRepository.Update(dbRequest);
        }
示例#6
0
        public IHttpActionResult PostZone(Zone Zone)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            string token = "";

            if (Request.Headers.Contains("oauth_token"))
            {
                token = Request.Headers.GetValues("oauth_token").First();
            }
            try
            {
                ZoneService.Add(token, Zone);
                return(Ok("lote creado con exito"));
            }
            catch (Exception e)
            {
                return(Content(HttpStatusCode.ExpectationFailed, e.Message));
            }
        }