Пример #1
0
        public ActionResult Edit(Guid id, ExternalMethodModel model, string button)
        {
            using (DBEntities context = Settings.CreateDataContext())
            {
                Validate(context, model);

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

                ExternalMethod target = null;
                if (model.Id != Guid.Empty)
                {
                    target = ExternalMethodHelper.Get(model.Id, context);
                    if (target == null)
                    {
                        ModelState.AddModelError("", Resources.Resource.RowNotFound);
                        return(View(model));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Запись не найдена!");
                    target    = new ExternalMethod();
                    target.Id = Guid.NewGuid();
                    context.AddToExternalMethod(target);
                }

                target.Name       = model.Name;
                target.MethodName = model.MethodName;
                target.ClassName  = model.ClassName;
                target.UsingText  = model.UsingText;
                target.CodeText   = model.CodeText;

                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 }));
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Prepares the default callbacks provided by this type
 /// </summary>
 /// <param name="scope">the script scope that is used for expression or script execution</param>
 /// <param name="scriptingContext">the scripting context that is used for expression or script execution</param>
 public static void PrepareDefaultCallbacks(IScope scope, IDisposable scriptingContext)
 {
     ExternalMethodHelper.PrepareExpressionVariables(scope,
                                                     new Dictionary <string, object>
     {
         { "session", scriptingContext },
         { "scope", scope },
         { "variables", scope }
     });
 }
Пример #3
0
        public ActionResult CreateExternalMethod(Guid[] ids)
        {
            string res = string.Empty;

            try
            {
                res = ExternalMethodHelper.CreateExternalMethod(ids);
            }
            catch (Exception ex)
            {
                return(Content(MessageHelper.FormedMessageWarning(ex), ""));
            }

            return(Content(MessageHelper.FormedMessageSuccess(res), ""));
        }
Пример #4
0
        public ActionResult Edit(Guid?id)
        {
            if (id.HasValue)
            {
                ExternalMethod obj = ExternalMethodHelper.Get(id.Value);
                if (obj == null)
                {
                    return(MessageHelper.FormedContentObjectNotFound());
                }

                Mapper.CreateMap <ExternalMethod, ExternalMethodModel>();
                ExternalMethodModel model = Mapper.Map <ExternalMethod, ExternalMethodModel>(obj);
                return(View(model));
            }
            else
            {
                return(View(new ExternalMethodModel()
                {
                    ClassName = "Project",
                    MethodName = "Method1"
                }));
            }
        }
Пример #5
0
 static ScriptExtensionHelper()
 {
     ExternalMethodHelper.RegisterClass(typeof(ScriptExtensionHelper));
 }
Пример #6
0
 protected override void OnDeleteRows(Guid[] checkedRecords)
 {
     ExternalMethodHelper.Delete(checkedRecords);
 }
Пример #7
0
 public ActionResult GetEmParam(Guid id)
 {
     return(Json(ExternalMethodHelper.GetParams(id)));
 }
Пример #8
0
 /// <summary>
 /// Initializes static members of the DefaultCallbacks class
 /// </summary>
 static DefaultCallbacks()
 {
     ExternalMethodHelper.RegisterClass(typeof(DefaultCallbacks));
 }