Пример #1
0
        public ActionResult GetSettings()
        {
            var menuList   = WsFactory.GetMenu((byte)0);
            var objectList = MetaViewHelper.GetAll();

            dynamic data = new
            {
                general = new
                {
                    id    = SecurityCache.CurrentUser.Id,
                    name  = SecurityCache.CurrentUser.Name,
                    email = SecurityCache.CurrentUser.Email
                },
                menu      = menuList,
                objects   = objectList.Select(c => new { c.Id, c.Name, c.Caption }),
                security  = new { },
                subscribe = new { }
            };

            return(new ContentResult
            {
                ContentType = "text/html",
                Content = JsonSerializer.SerializeToString(data)
            });
        }
Пример #2
0
        public ActionResult EditExternalMethod(Guid?id, Guid?ViewId, MetaViewExternalMethodModel model, string button)
        {
            if (string.IsNullOrEmpty(button))
            {
                return(View(model));
            }

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            using (DBEntities context = Settings.CreateDataContext())
            {
                MetaViewExternalMethod target = null;
                if (model.Id != Guid.Empty)
                {
                    target = MetaViewHelper.GetExternalMethod(model.Id, context);
                    if (target == null)
                    {
                        ModelState.AddModelError("", Resources.Resource.RowNotFound);
                        return(View(model));
                    }
                }
                else
                {
                    target    = new MetaViewExternalMethod();
                    target.Id = model.Id = Guid.NewGuid();
                    context.AddToMetaViewExternalMethod(target);
                }

                MetaViewExternalMethodModel.CreateMap();
                target = Mapper.Map(model, target);

                try
                {
                    context.SaveChanges();
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", Resources.Resource.SaveError + ": " + ex.Message);
                }
            }

            if (button == "SaveAndExit")
            {
                return(RedirectToAction("Edit", new { id = model.MetaViewId }));
            }
            else
            {
                return(RedirectToAction("EditExternalMethod", new { id = model.Id }));
            }
        }
Пример #3
0
        public virtual ActionResult EMDeleteRows(Guid[] checkedRecords)
        {
            checkedRecords = checkedRecords ?? new Guid[] { };

            try
            {
                MetaViewHelper.EMDelete(checkedRecords);
            }
            catch (Exception ex)
            {
                return(Content(MessageHelper.FormedMessageWarning(ex), ""));
            }

            return(Content(MessageHelper.FormedMessageSuccess(Resources.Resource.RowsDeleted + "!"), ""));
        }
Пример #4
0
        public ActionResult Copy(Guid id)
        {
            Guid newId;

            try
            {
                newId = MetaViewHelper.Copy(id);
            }
            catch (Exception ex)
            {
                return(Content(MessageHelper.FormedMessageWarning(ex)));
            }

            string res = string.Format("Запись скопирована. <a href='{0}/{1}'>Перейти к новой записи</a>", Url.Action("Edit"), newId);

            return(Content(MessageHelper.FormedMessageSuccess(res), ""));
        }
Пример #5
0
        public virtual ActionResult EMUpdateRow(Guid metaviewId, byte type, Guid emId, string param)
        {
            try
            {
                MetaViewHelper.EMUpdateRow(null, metaviewId, type, emId, param);
            }
            catch (NotValidationException ex)
            {
                return(Content(MessageHelper.FormedMessageNote(ex.Message), ""));
            }
            catch (Exception ex)
            {
                return(Content(MessageHelper.FormedMessageWarning(ex), ""));
            }

            return(Content(MessageHelper.FormedMessageSuccess("Запись добавлена!"), ""));
        }
Пример #6
0
        public static List <MetaViewColumnModel> GetColumnsForView(Guid viewId, Guid masterEntityId, Guid?parentId)
        {
            MetaViewColumnModel.CreateMap();
            List <MetaViewColumn>          col;
            List <MetadataEntityAttribute> metadataEntityAttribute;

            using (DBEntities context = Settings.CreateDataContext())
            {
                col = MetaViewHelper.GetColumnsByViewId(viewId, context);
                metadataEntityAttribute = MetadataEntityHelper.GetAttributes(context);
            }

            List <MetaViewColumnModel> res = Mapper.Map <IList <MetaViewColumn>, List <MetaViewColumnModel> >(col);

            AddEntities(viewId, res, metadataEntityAttribute, masterEntityId, null);

            return(res);
        }
Пример #7
0
        public ActionResult ExternalMethodDeleteRows(Guid[] checkedRecords)
        {
            checkedRecords = checkedRecords ?? new Guid[] { };

            try
            {
                MetaViewHelper.EMDelete(checkedRecords);
            }
            catch (NotValidationException ex)
            {
                return(Content(MessageHelper.FormedMessageNote(ex.Message), ""));
            }
            catch (Exception ex)
            {
                return(Content(MessageHelper.FormedMessageWarning(ex), ""));
            }

            return(Content(MessageHelper.FormedMessageSuccess(Resources.Resource.RowsDeleted + "!"), ""));
        }
Пример #8
0
        public ActionResult Edit(Guid?id)
        {
            if (id.HasValue)
            {
                MetaView obj = MetaViewHelper.Get(id.Value);
                if (obj == null)
                {
                    return(MessageHelper.FormedContentObjectNotFound());
                }

                MetaViewModel.CreateMap();
                MetaViewModel model = Mapper.Map <MetaView, MetaViewModel>(obj);
                return(View(model));
            }
            else
            {
                return(View(new MetaViewModel()));
            }
        }
Пример #9
0
        public ActionResult EditExternalMethod(Guid?id, Guid?ViewId)
        {
            MetaViewExternalMethodModel model = null;

            if (id.HasValue)
            {
                var att = MetaViewHelper.GetExternalMethod(id.Value);
                if (att == null)
                {
                    return(MessageHelper.FormedContentObjectNotFound());
                }

                MetaViewExternalMethodModel.CreateMap();
                model = Mapper.Map <MetaViewExternalMethod, MetaViewExternalMethodModel>(att);
                return(View(model));
            }
            else if (ViewId.HasValue)
            {
                MetaView item = MetaViewHelper.Get(ViewId.Value);
                if (item != null)
                {
                    return(View(new MetaViewExternalMethodModel
                    {
                        MetaViewId = item.Id,
                        MetaViewCaption = item.Caption,
                    }));
                }
                else
                {
                    return(MessageHelper.FormedContentObjectNotFound());
                }
            }
            else
            {
                return(MessageHelper.FormedContentObjectNotFound());
            }
        }
Пример #10
0
        public ActionResult Edit(Guid id, MetaViewModel model, List <MetaViewColumnModel> columns, string button)
        {
            using (DBEntities context = Settings.CreateDataContext())
            {
                Validate(context, model);

                if (!ModelState.IsValid)
                {
                    return(View(model));
                }

                MetaView target = null;
                if (model.Id != Guid.Empty)
                {
                    target = MetaViewHelper.Get(model.Id, context);
                    if (target == null)
                    {
                        ModelState.AddModelError("", Resources.Resource.RowNotFound);
                        return(View(model));
                    }
                }
                else
                {
                    target = new MetaView {
                        Id = Guid.NewGuid()
                    };
                    context.AddToMetaView(target);
                }

                MetaViewModel.CreateMap();

                Mapper.Map(model, target);
                if (columns != null)
                {
                    SyncViewColumns(target, columns, context);
                }

                try
                {
                    context.SaveChanges();
                }
                catch (Exception ex)
                {
                    var sb = new StringBuilder(Resources.Resource.SaveError + ": " + ex.Message);
                    if (ex.InnerException != null)
                    {
                        sb.AppendLine(ex.InnerException.Message);
                    }
                    ModelState.AddModelError("", sb.ToString());
                    return(View(model));
                }

                if (button == "SaveAndExit")
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(RedirectToAction("Edit", new { target.Id }));
                }
            }
        }
Пример #11
0
 protected override void OnRestoreRows(Guid[] checkedRecords)
 {
     MetaViewHelper.Restore(checkedRecords);
 }
Пример #12
0
 protected override void OnRemoveRows(Guid[] checkedRecords)
 {
     MetaViewHelper.Delete(checkedRecords, true);
 }