Example #1
0
        private static GCsControllerModel GetControllerByACA(GCsModel model, string projectName, string url, out string action)
        {
            string area, controller;
            GetACAByUrl(url, out area, out controller, out action);

            GCsControllerModel ctr = null;
            if (area.Length == 0)
            {
                if (model.Controllers.ContainsKey(controller))
                {
                    ctr = model.Controllers[controller];
                }
                else
                {
                    ctr = new GCsControllerModel() { ProjectName = projectName, Name = controller };
                    model.Controllers.Add(controller, ctr);
                }
            }
            else
            {
                Dictionary<string, GCsControllerModel> ctrs = null;
                if (model.AreaControllers.ContainsKey(area))
                {
                    ctrs = model.AreaControllers[area];
                }
                else
                {
                    ctrs = new Dictionary<string, GCsControllerModel>(StringComparer.CurrentCultureIgnoreCase);
                    model.AreaControllers.Add(area, ctrs);
                }

                if (ctrs.ContainsKey(controller))
                {
                    ctr = ctrs[controller];
                }
                else
                {
                    ctr = new GCsControllerModel() { ProjectName = projectName, Name = controller };
                    ctrs.Add(controller, ctr);
                }
            }
            return ctr;
        }
Example #2
0
        public static GCsModel GetModelFromContent(string projectName, GContent con)
        {
            GCsModel model = new GCsModel();

            string action = string.Empty;
            GCsControllerModel ctr = null;

            foreach (var tree in con.trees)
            {
                if (tree.loadurl.Length > 0)
                {
                    ctr = GetControllerByACA(model, projectName, tree.loadurl, out action);
                    ctr.LoadTreeActions.Add(action);
                }

                if (tree.saveurl.Length > 0)
                {
                    ctr = GetControllerByACA(model, projectName, tree.saveurl, out action);
                    ctr.SaveActions.Add(action);
                }

                if (tree.delurl.Length > 0)
                {
                    ctr = GetControllerByACA(model, projectName, tree.delurl, out action);
                    ctr.DeleteActions.Add(action);
                }
            }

            foreach (var table in con.tables)
            {
                if (table.transferurl != null && table.transferurl.Length > 0)
                {
                    ctr = GetControllerByACA(model, projectName, table.transferurl, out action);
                    ctr.SaveActions.Add(action);
                }

                if (table.data.url.Length > 0)
                {
                    ctr = GetControllerByACA(model, projectName, table.data.url, out action);
                    ctr.LoadTableActions.Add(action);
                }

                foreach (var header in table.data.headers)
                {
                    if (header.actionbtns.Count > 0)
                    {
                        foreach (var btn in header.actionbtns)
                        {
                            if (btn.type.Equals("edit"))
                            {
                                if (btn.action.Length > 0)
                                {
                                    ctr = GetControllerByACA(model, projectName, btn.action, out action);
                                    ctr.SaveActions.Add(action);
                                }
                            }
                            else if (btn.type.Equals("delete"))
                            {
                                if (btn.action.Length > 0)
                                {
                                    ctr = GetControllerByACA(model, projectName, btn.action, out action);
                                    ctr.DeleteActions.Add(action);
                                }
                            }
                        }
                    }
                }
            }

            foreach (var json in con.jsons)
            {
                List<string> jFields = new List<string>();
                foreach (var d in json.data)
                {
                    if (d.c[0].fld.Length > 0)
                    {
                        jFields.Add(d.c[0].fld);
                    }
                }
                if (json.url.Length > 0)
                {
                    ctr = GetControllerByACA(model, projectName, json.url, out action);
                    ctr.LoadJsonActions.Add(action, jFields);
                }
            }

            foreach (var fm in con.forms)
            {
                if (fm.disabledurl.Length > 0)
                {
                    ctr = GetControllerByACA(model, projectName, fm.disabledurl, out action);
                    ctr.LoadIntAction.Add(action);
                }
                foreach (var btn in fm.btns)
                {
                    if (btn.action.Length > 0)
                    {
                        ctr = GetControllerByACA(model, projectName, btn.action, out action);
                        ctr.SaveActions.Add(action);
                    }
                }
            }

            return model;
        }