Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            StringBuilder    stringBuilder   = new StringBuilder();
            List <FuncModel> modelByFatherId = FuncModelUtils.GetModelByFatherId(0);

            for (int i = 0; i < modelByFatherId.Count; i++)
            {
                FuncModel funcModel = modelByFatherId[i];
                stringBuilder.Append("{");
                stringBuilder.Append("icon: '../images/DeskTop/system.gif',");
                stringBuilder.Append("title: '" + funcModel.Name + "',");
                stringBuilder.Append("url: 'WorkSpace.aspx?FMDID=" + funcModel.Id + "',");
                stringBuilder.Append("height: '500',");
                stringBuilder.Append("width: '600',");
                stringBuilder.Append("wsstate: 'WSMAX',");
                stringBuilder.Append("showDialogId: ''}\n\r,");
            }
            stringBuilder.Append("{");
            stringBuilder.Append("icon: '../images/DeskTop/password.gif',");
            stringBuilder.Append("title: '修改密码',");
            stringBuilder.Append("url: 'PassMe.aspx',");
            stringBuilder.Append("height: '200',");
            stringBuilder.Append("width: '400',");
            stringBuilder.Append("wsstate: 'WSNORMAL',");
            stringBuilder.Append("showDialogId: ''}\n\r,");
            stringBuilder.Append("{");
            stringBuilder.Append("icon: '../images/DeskTop/close.gif',");
            stringBuilder.Append("title: '关闭',");
            stringBuilder.Append("url: 'Logout.aspx',");
            stringBuilder.Append("height: '200',");
            stringBuilder.Append("width: '400',");
            stringBuilder.Append("wsstate: 'WSNORMAL',");
            stringBuilder.Append("showDialogId: ''}\n\r");
            this.objIcons = stringBuilder.ToString();
        }
        public string Add(EditFuncModel model)
        {
            if (ModelState.IsValid)
            {
                FuncModel func = new FuncModel();
                func.Name = model.Name;                         //英文名称
                func.Title = model.Title;                       //中文名称
                func.DisplayFlag = model.DisplayFlag;           //是否显示
                func.Sortno = model.Sortno;                     //序号
                func.Url = model.Url;                           //链接url
                func.Pid = model.Pid;                           //上级模块
                func.FullPid = model.FullPid == null ? "0" : model.FullPid;     //所有上级模块
                func.FuncLevel = model.FuncLevel;               //模块层级
                func.CreateMan = SysConfig.CurrentUser.Id;      //创建人
                func.CreateTime = DateTime.Now;                 //创建时间

                int result = (int)func.Insert();

                if (result > 0)
                {
                    //记录操作日志
                    CommonMethod.Log(SysConfig.CurrentUser.Id, "Insert", "Sys_Func",
                                  string.Format("添加【{0}】模块", func.Title));

                    return "1";
                }
            }

            return "0";
        }
        public string AddSub(EditFuncModel model)
        {
            if (ModelState.IsValid)
            {
                FuncModel func = new FuncModel();
                func.Name = model.Name;                         //英文名称
                func.Title = model.Title;                       //中文名称
                func.DisplayFlag = model.DisplayFlag;           //是否显示
                func.Sortno = model.Sortno;                     //序号
                func.Url = model.Url;                           //链接url
                func.Pid = model.Id.ToInt();                    //上级模块
                func.FullPid = model.FullPid + "-" + model.Id;  //所有上级模块
                func.FuncLevel = model.FuncLevel + 1;           //模块层级
                func.CreateMan = SysConfig.CurrentUser.Id;      //创建人
                func.CreateTime = DateTime.Now;                 //创建时间

                int result = (int)func.Insert();

                if (result > 0)
                {
                    //记录操作日志
                    FuncModel parent = FuncModel.SingleOrDefault(model.Id);
                    CommonMethod.Log(SysConfig.CurrentUser.Id, "Insert", "Sys_Func",
                                  string.Format("给[{0}]模块添加【{1}】子模块",
                                  parent == null ? "" : parent.Title, func.Title));

                    return "1";
                }
            }

            return "0";
        }
Example #4
0
        private FuncModel Query(string name)
        {
            var client      = new RestClient("http://" + baseUrl);
            var restRequest = new RestRequest("api/setting/func/name?name=" + name);

            restRequest.Method = Method.GET;

            var       resetEvent = new ManualResetEvent(false);
            FuncModel funcModel  = null;

            var handle = client.ExecuteAsync(restRequest, (restResponse) =>
            {
                funcModel = JsonConvert.DeserializeObject <FuncModel>(restResponse.Content);

                resetEvent.Set();
            });

            resetEvent.WaitOne();

            if (funcModel != null)
            {
                functions.Add(funcModel.Name, funcModel);
            }

            return(funcModel);
        }
        public object FuncTest(FuncModel func)
        {
            var code = "{# " + func.Sample + " #}";
            var test = new ComplieFuncTest(func.Code);

            return(test.GetResult(code));
        }
        public virtual string Add(Func <TInput, TOutput> func)
        {
            var funcModel = new FuncModel <TInput, TOutput>(func);

            Funcs.Add(funcModel);

            return(funcModel.Id);
        }
Example #7
0
        public object UpdateFunc(FuncModel func)
        {
            //if (func.Name == "now" || func.Name == "ticks")
            //    return false;

            var f = FuncLiteDb.Get(func.Name);

            if (f != null && f.Id == 0)
            {
                return(false);
            }

            FuncLiteDb.AddOrUpdate(func);
            return(true);
        }
Example #8
0
        public void TestSample()
        {
            var m = new FuncModel();

            m.Code   = @"for (int i = 0; i < 10; i++)
            {
                result += i.ToString();
            }
            ";
            m.Sample = "timeOfDay()";

            var func   = new ComplieFuncTest("result = DateTime.Now.TimeOfDay;");
            var result = func.GetResult("{# " + m.Sample + " #}");

            Assert.IsTrue(result.Length > 0);
        }
        public FuncListModel GetFuncMenu(string email, string passw)
        {
            FuncListModel resp = new FuncListModel();

            try
            {
                resp.func = new List <FuncModel>();

                string query = string.Format(
                    @"select C.seq,D.code, D.name_thai AS func_name, 
                        D.route_path, D.icon_name, D.func_type, D.func_ref_sub
                        from [dbo].[SYS_ACCOUNT] A
                        INNER JOIN [dbo].[SYS_PERMISSION_GROUP] B
                        ON A.account_id = B.account_id
                        INNER JOIN [dbo].[SYS_PERMISSION_FUNCTION] C
                        ON B.group_code = C.group_code
                        INNER JOIN [dbo].[SYS_FUNCTION] D
                        ON C.func_code = D.code
                        WHERE A.email='{0}'AND A.password='******'
                        ORDER BY b.group_code,c.seq ASC", email, passw);

                using (MSSql mssql = new MSSql(DBConnectionType.RBAC, _EnvironmentModel))
                {
                    var dt = mssql.GetDataTableFromQueryStr(query);

                    if (dt.Rows.Count > 0)
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            string func_type = dr["func_type"].ToString();

                            if (func_type == "Main" || func_type == "MainSub")
                            {
                                FuncModel func_model = new FuncModel()
                                {
                                    seq      = Convert.ToInt32(dr["seq"]),
                                    key      = dr["code"].ToString(),
                                    icon     = dr["icon_name"].ToString(),
                                    path     = func_type == "MainSub" ? null : dr["route_path"].ToString(),
                                    sub_item = new List <SubFuncModel>(),
                                };
                                resp.func.Add(func_model);
                            }
                            if (func_type == "Divider")
                            {
                                FuncModel func_model = new FuncModel()
                                {
                                    seq     = Convert.ToInt32(dr["seq"]),
                                    divider = true,
                                };
                                resp.func.Add(func_model);
                            }
                        }
                        foreach (DataRow dr in dt.Rows)
                        {
                            string func_type = dr["func_type"].ToString();

                            if (func_type == "SubMenu")
                            {
                                SubFuncModel sub_item = new SubFuncModel()
                                {
                                    seq  = Convert.ToInt32(dr["seq"]),
                                    key  = dr["code"].ToString(),
                                    icon = dr["icon_name"].ToString(),
                                    path = dr["route_path"].ToString(),
                                };
                                int indexFunc = resp.func.FindIndex(e => e.key != null && e.key == dr["func_ref_sub"].ToString());
                                resp.func[indexFunc].sub_item.Add(sub_item);
                            }
                        }
                        return(resp);
                    }
                }
            }
            catch (Exception ex)
            {
                _ILogs.LogError("Function Application: ", ex.Message.ToString(), ex.StackTrace);
            }
            return(null);
        }
Example #10
0
        public object FuncTest([FromBody] FuncModel func)
        {
            var type = (func.Type == FuncType.URLFUNCTION) ? "url" : "proc";

            return(CodeCompilerManager.Test(type, func.Sample, func.Code));
        }
Example #11
0
        public PluginPageReducer()
        {
            Process <LoadEngins>((state, action) =>
            {
                state.Engins = new List <Engin>();
                state.Engins.Add(new Engin()
                {
                    Id = "UE4", Name = "UE4"
                });
                state.Engins.Add(new Engin()
                {
                    Id = "Unity", Name = "Unity"
                });

                return(state);
            }).
            Process <LoadProjects>((state, action) =>
            {
                state.Projects       = new List <Project>();
                var projectApiServer = HttpApi.Resolve <IProjectApi>();
                var result           = projectApiServer.GetAllProjectAsync().InvokeAsync().Result;
                if (result != null)
                {
                    foreach (var item in result)
                    {
                        state.Projects.Add(new Project()
                        {
                            Id           = item.Id,
                            Des          = item.Description,
                            Name         = item.ProjectName,
                            RelativePath = item.RelativePath,
                            Version      = item.Version,
                            Versions     = GetVersions(item.Versions),
                            Engine       = item.Engine
                        });
                    }
                }

                return(state);
            }).
            Process <LoadEnginVersions>((state, action) =>
            {
                state.UE4Versions   = new List <Models.Version>();
                state.UnityVersions = new List <Models.Version>();
                var httpUE4Result   = HttpApi.Resolve <IPluginApi>().GetPluginVersionAsync(true).InvokeAsync().Result;
                var httpUnityResult = HttpApi.Resolve <IPluginApi>().GetPluginVersionAsync(false).InvokeAsync().Result;

                if (httpUE4Result != null)
                {
                    foreach (var item in httpUE4Result)
                    {
                        state.UE4Versions.Add(new Models.Version()
                        {
                            Id = item, Name = item
                        });
                    }
                }

                if (httpUnityResult != null)
                {
                    foreach (var item in httpUnityResult)
                    {
                        state.UnityVersions.Add(new Models.Version()
                        {
                            Id = item, Name = item
                        });
                    }
                }

                return(state);
            }).
            Process <LoadFuncs>((state, action) => {
                state.FuncModels = new List <FuncModel>();

                var httpResult = HttpApi.Resolve <IPluginApi>().GetAllPluginAsync().InvokeAsync().Result;

                if (httpResult != null)
                {
                    foreach (var item in httpResult)
                    {
                        var curFuncModel = new FuncModel()
                        {
                            Id           = item.Id,
                            Des          = item.Description,
                            Name         = item.FuncName,
                            RelativePath = item.RelativePath,
                            Version      = item.Version,
                            Versions     = GetVersions(item.Versions),
                            Engine       = item.Engine,
                        };
                        state.FuncModels.Add(curFuncModel);
                    }
                }

                return(state);
            }).
            Process <CreateProjectJson>((state, action) => {
                var dir = @"./ProjectCreateJson";
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
                var fileFullName = dir + "/" + action.ProjectCreateMoudle.ProjectName + ".json";
                if (!File.Exists(fileFullName))
                {
                    File.WriteAllText(fileFullName, JsonConvert.SerializeObject(action.ProjectCreateMoudle));
                }

                state.Message.Msg      = "创建json文件成功";
                state.Message.MsgType  = MessageType.Success;
                state.Message.Showtype = Showtype.Notification;

                return(state);
            });
        }