예제 #1
0
        public static JsonSerializerSettings GetSettings(MEDM model)
        {
            JsonSerializerSettings _Settings = new JsonSerializerSettings();

            _Settings.Converters.Add(GetConverter(model));
            return(_Settings);
        }
예제 #2
0
        public static JsonSerializerSettings GetSettings(MEDM model, string path = "macro")
        {
            JsonSerializerSettings _Settings = null;

            _Settings = new JsonSerializerSettings();
            _Settings.Converters.Add(GetConverter(model));
            return(_Settings);
        }
예제 #3
0
 public MAppController(MEDM model) : base(model)
 {
 }
예제 #4
0
 public static MJsonAppConverter GetConverter(MEDM model)
 {
     return(new MJsonAppConverter(model));
 }
예제 #5
0
 public MJsonAppConverter(MEDM model) : base(model)
 {
     ConverterId = AutoIncrementId;
 }
예제 #6
0
        public virtual object Save(MEDM model, string path, string parms)
        {
            IFormCollection f    = Context.Request.Form;
            string          n    = f["_name"];
            string          t    = f["_type"];
            Type            type = model.GetClassTypeByClassName(t);

            if (type == null)
            {
                type = model.GetClassTypeByClassName(n);
            }
            if (type == null)
            {
                throw (new Exception($"Запись изменений. Тип данных не найден ({t}/{n}) ..."));
            }
            string id = f["_id"];

            if (string.IsNullOrEmpty(id))
            {
                id = f["id"];
            }

            switch (f["webix_operation"])
            {
            case "insert":
            {
                MEDMObj o = model.CreateObject(type);        //   MainDic.NewObj(type, null);
                if (o == null)
                {
                    throw (new Exception($"Запись изменений. Операция insert. Объект не создан (id={id})..."));
                }
                foreach (KeyValuePair <string, StringValues> kv in f)
                {
                    if (!kv.Key.StartsWith("_") && !kv.Key.StartsWith("webix_"))
                    {
                        o.SetStringValue(kv.Key, kv.Value, true);
                    }
                }
                model.Save(Context.Session);
                return(o);
            }

            case "update":
            {
                if (string.IsNullOrEmpty(id))
                {
                    throw (new Exception($"Запись изменений. Id не задан ..."));
                }
                model.LockUpdates++;
                MEDMObj o = null;
                try
                {
                    o = model.MainDic.GetObj(type, id);
                }
                finally
                {
                    model.LockUpdates--;
                }
                //Старый вариант с общим кешем
                //MEDMObj o = model.MainDic.FindObj(type, id);
                //if (o==null) throw (new Exception($"Запись изменений. Операция update. Объект не найден (id={id})..."));
                foreach (KeyValuePair <string, StringValues> kv in  f)
                {
                    if (kv.Key != "id" && !kv.Key.StartsWith("_") && !kv.Key.StartsWith("webix_"))
                    {
                        o.SetStringValue(kv.Key, kv.Value[0], true);
                    }
                }
                model.Save(Context.Session);
                return(o);
            }

            case "delete":
            {
                if (string.IsNullOrEmpty(id))
                {
                    throw (new Exception($"Запись изменений. Id не задан ..."));
                }
                MEDMObj o = model.MainDic.GetObj(type, id);
                if (o == null)
                {
                    throw (new Exception($"Запись изменений. Операция delete. Объект не найден (id={id})..."));
                }
                model.DeleteObject(o);
                model.Save(Context.Session);
                return(o);
            }

            case "move":
                break;

            default:
            {
                throw (new Exception($"Запись изменений. Операция \"{f["webix_operation"]}\" не определена..."));
            }
            break;
            }
            return(null);
        }
예제 #7
0
 public virtual object Run(MEDM model, string path, string parms)
 {
     throw new NotImplementedException();
 }
예제 #8
0
 public virtual IEnumerable <string> GetCommands(MEDM model)
 {
     return("refresh".Split(';'));
 }
예제 #9
0
 public override object Run(MEDM model, string path, string parms)
 {
     return(Run(model as MBuilderModel, path, parms));
 }
예제 #10
0
        public MUser CurrentUser(MEDM model)
        {
            MUser currentUser = model.GetCurrentUser(Context.User) as MUser;

            return(currentUser);
        }
예제 #11
0
 public MTemplateController(MEDM model)
 {
     Model = model;
 }
예제 #12
0
 public MJsonDataConverter(MEDM model) : base(model)
 {
     ObjDic  = new Dictionary <TypeInfo, HashSet <MEDMObj> >();
     ObjList = new HashSet <MEDMObj>();
     TypeDic = new HashSet <TypeInfo>();
 }
예제 #13
0
 public MSysController(MEDM model)
 {
     Model = model;
 }
예제 #14
0
 public MDataController(MEDM model)
 {
     Model = model;
 }
예제 #15
0
 public override object Run(MEDM model, string path, string parms)
 {
     return(Run(model as RZDMonitoringModel, path, parms));
 }
예제 #16
0
 public MJsonConverter(MEDM model)
 {
     Model = model;
 }