示例#1
0
        public FileResult DownloadTabConfig(string TabIds, int CurUserId, string CurUserIden)
        {
            base.SetHeader();
            CurUserIden = CPAppContext.FormatSqlPara(CurUserIden);
            CPWebApiBaseReturnEntity re = new CPWebApiBaseReturnEntity();

            if (this.CheckUserIden(CurUserId, CurUserIden) == false)
            {
                throw new Exception("系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!");
            }
            TabIds = TabIds.Replace("@", ",");
            TabIds = CPAppContext.FormatSqlPara(TabIds);
            List <int> col = new List <int>();

            TabIds.Split(',').ToList().ForEach(t => {
                if (string.IsNullOrEmpty(t) == false)
                {
                    col.Add(int.Parse(t));
                }
            });
            string sXml = CPTabEngine.Instance().GetTabConfigXml(col);

            byte[] byteArray = System.Text.Encoding.Default.GetBytes(sXml);
            return(File(byteArray, "application/x-msdownload", "标签页配置.CPXml"));
        }
示例#2
0
        public CPWebApiBaseReturnEntity SynTabConfig(int TargetSysId, bool IsCreateNew, int CurUserId, string CurUserIden)
        {
            base.SetHeader();
            CurUserIden = CPAppContext.FormatSqlPara(CurUserIden);
            CPWebApiBaseReturnEntity re = new CPWebApiBaseReturnEntity();

            if (this.CheckUserIden(CurUserId, CurUserIden) == false)
            {
                re.Result   = false;
                re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!";
                return(re);
            }
            try
            {
                var files = Request.Form.Files;
                foreach (var file in files)
                {
                    //  var filename = ContentDispositionHeaderValue
                    //                   .Parse(file.ContentDisposition)
                    //                .FileName
                    //                .Trim('"');
                    ////  filename = _FilePath + $@"\{filename}";
                    //  size += file.Length;
                    byte[] bData = null;
                    using (var fileStream = file.OpenReadStream())
                        using (var ms = new MemoryStream())
                        {
                            fileStream.CopyTo(ms);
                            bData = ms.ToArray();
                            //var fileBytes = ms.ToArray();
                            //string s = Convert.ToBase64String(fileBytes);
                            //// act on the Base64 data
                        }
                    if (bData != null)
                    {
                        if (IsCreateNew)
                        {
                            re.Result = CPTabEngine.Instance().InitTabFromConfigXml(TargetSysId, bData);
                        }
                        else
                        {
                            re.Result = CPTabEngine.Instance().SyncTabFromConfigXml(TargetSysId, bData);
                        }
                    }
                }
                re.Result = true;
                return(re);
            }
            catch (Exception ex)
            {
                re.Result   = false;
                re.ErrorMsg = ex.Message.ToString();
                return(re);
            }
        }
示例#3
0
文件: Startup.cs 项目: vebin/qMISPlat
        // This method gets called by the runtime. Use this method to add services to the container.
        //注册服务
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            //不加这句的话,发布到IIS里会运行不起来
            services.AddApplicationInsightsTelemetry(Configuration);
            //注册编辑器
            services.AddUEditorService();
            services.AddMvc(o => o.Conventions.Add(new FeatureConvention()))
            .AddJsonOptions(t => t.SerializerSettings.ContractResolver = new DefaultContractResolver())
            .AddRazorOptions(options =>
            {
                // {0} - Action Name
                // {1} - Controller Name
                // {2} - Area Name
                // {3} - Feature Name
                // replace normal view location entirely
                //    options.ViewLocationFormats.Clear();
                options.ViewLocationFormats.Add("/Plat/{3}/{1}/{0}.cshtml");
                options.ViewLocationFormats.Add("/Plat/{3}/{0}.cshtml");
                options.ViewLocationFormats.Add("/Plat/Shared/{0}.cshtml");


                options.ViewLocationExpanders.Add(new FeatureViewLocationExpander());
            }).AddSessionStateTempDataProvider();

            //.AddApplicationPart(typeof(GridEngineController).Assembly).AddControllersAsServices(); ;
            //services.AddMvc()
            // .AddApplicationPart(typeof(GridEngineController).Assembly).AddControllersAsServices();
            //services.AddMvc().AddApplicationPart(Assembly.Load(new AssemblyName("CPFrameWork.UIInterface")));
            //使用session
            services.AddSession();
            Services = services;
            //设置文件大小
            services.Configure <FormOptions>(options =>
            {
                //1个G
                options.MultipartBodyLengthLimit = 1024 * 1024 * 1024;
            });
            //自己加的
            CPLogHelper.StartupInit(services, Configuration);
            CPSystemHelper.StartupInit(services, Configuration);
            CPAutoNumHelper.StartupInit(services, Configuration);
            COOrgans.StartupInit(services, Configuration);
            CPFormEngine.StartupInit(services, Configuration);
            CPFormTemplate.StartupInit(services, Configuration);
            CPGridEngine.StartupInit(services, Configuration);
            CPTabEngine.StartupInit(services, Configuration);
            CPTreeEngine.StartupInit(services, Configuration);
            CPModuleEngine.StartupInit(services, Configuration);
            CPFlowTemplate.StartupInit(services, Configuration);
            CPFlowEngine.StartupInit(services, Configuration);
            CPMsgs.StartupInit(services, Configuration);
        }
示例#4
0
        public GetTabInfoReturn GetTabInfo(string TabCode, int CurUserId, string CurUserIden)
        {
            base.SetHeader();
            TabCode     = CPAppContext.FormatSqlPara(TabCode);
            CurUserIden = CPAppContext.FormatSqlPara(CurUserIden);

            GetTabInfoReturn re = new GetTabInfoReturn();

            if (this.CheckUserIden(CurUserId, CurUserIden) == false)
            {
                re.Result   = false;
                re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!";
                return(re);
            }
            try
            {
                re.Tab = CPTabEngine.Instance().GetTab(TabCode, true);
                #region 处理
                List <CPTabItem> cCol = new List <CPTabItem>();
                re.Tab.ItemCol.ForEach(t =>
                {
                    bool isShow = true;
                    if (t.IsUseExpressionShow.Value)
                    {
                        string leftValue  = CPExpressionHelper.Instance.RunCompile(t.LeftExpression);
                        string rightValue = CPExpressionHelper.Instance.RunCompile(t.RightExpression);

                        if (t.ShowMethod == CPTabEnum.ShowMethodEnum.EqualTo)
                        {
                            if (leftValue.Equals(rightValue, StringComparison.CurrentCultureIgnoreCase))
                            {
                                isShow = t.IsShowByExpression.Value;
                            }
                            else
                            {
                                if (t.IsShowByExpression.Value)
                                {
                                    isShow = false;
                                }
                                else
                                {
                                    isShow = true;
                                }
                            }
                        }
                        else if (t.ShowMethod == CPTabEnum.ShowMethodEnum.NotEqualTo)
                        {
                            if (leftValue.Equals(rightValue, StringComparison.CurrentCultureIgnoreCase) == false)
                            {
                                isShow = t.IsShowByExpression.Value;
                            }
                            else
                            {
                                if (t.IsShowByExpression.Value)
                                {
                                    isShow = false;
                                }
                                else
                                {
                                    isShow = true;
                                }
                            }
                        }
                        else if (t.ShowMethod == CPTabEnum.ShowMethodEnum.GreaterThanOrEqualTo)
                        {
                            double dLeft  = 0;
                            double dRight = 0;
                            try
                            {
                                dLeft = Convert.ToDouble(leftValue);
                            }
                            catch (Exception ex) { }
                            try
                            {
                                dRight = Convert.ToDouble(rightValue);
                            }
                            catch (Exception ex) { }
                            if (dLeft >= dRight)
                            {
                                isShow = t.IsShowByExpression.Value;
                            }
                            else
                            {
                                if (t.IsShowByExpression.Value)
                                {
                                    isShow = false;
                                }
                                else
                                {
                                    isShow = true;
                                }
                            }
                        }
                        else if (t.ShowMethod == CPTabEnum.ShowMethodEnum.GreaterThan)
                        {
                            double dLeft  = 0;
                            double dRight = 0;
                            try
                            {
                                dLeft = Convert.ToDouble(leftValue);
                            }
                            catch (Exception ex) { }
                            try
                            {
                                dRight = Convert.ToDouble(rightValue);
                            }
                            catch (Exception ex) { }
                            if (dLeft > dRight)
                            {
                                isShow = t.IsShowByExpression.Value;
                            }
                            else
                            {
                                if (t.IsShowByExpression.Value)
                                {
                                    isShow = false;
                                }
                                else
                                {
                                    isShow = true;
                                }
                            }
                        }
                        else if (t.ShowMethod == CPTabEnum.ShowMethodEnum.LessThanOrEqualTo)
                        {
                            double dLeft  = 0;
                            double dRight = 0;
                            try
                            {
                                dLeft = Convert.ToDouble(leftValue);
                            }
                            catch (Exception ex) { }
                            try
                            {
                                dRight = Convert.ToDouble(rightValue);
                            }
                            catch (Exception ex) { }
                            if (dLeft <= dRight)
                            {
                                isShow = t.IsShowByExpression.Value;
                            }
                            else
                            {
                                if (t.IsShowByExpression.Value)
                                {
                                    isShow = false;
                                }
                                else
                                {
                                    isShow = true;
                                }
                            }
                        }
                        else if (t.ShowMethod == CPTabEnum.ShowMethodEnum.LessThan)
                        {
                            double dLeft  = 0;
                            double dRight = 0;
                            try
                            {
                                dLeft = Convert.ToDouble(leftValue);
                            }
                            catch (Exception ex) { }
                            try
                            {
                                dRight = Convert.ToDouble(rightValue);
                            }
                            catch (Exception ex) { }
                            if (dLeft < dRight)
                            {
                                isShow = t.IsShowByExpression.Value;
                            }
                            else
                            {
                                if (t.IsShowByExpression.Value)
                                {
                                    isShow = false;
                                }
                                else
                                {
                                    isShow = true;
                                }
                            }
                        }
                        else if (t.ShowMethod == CPTabEnum.ShowMethodEnum.Contains)
                        {
                            if (leftValue.IndexOf(rightValue, StringComparison.CurrentCultureIgnoreCase) != -1)
                            {
                                isShow = t.IsShowByExpression.Value;
                            }
                            else
                            {
                                if (t.IsShowByExpression.Value)
                                {
                                    isShow = false;
                                }
                                else
                                {
                                    isShow = true;
                                }
                            }
                        }
                        else if (t.ShowMethod == CPTabEnum.ShowMethodEnum.DoesNotContain)
                        {
                            if (leftValue.IndexOf(rightValue, StringComparison.CurrentCultureIgnoreCase) == -1)
                            {
                                isShow = t.IsShowByExpression.Value;
                            }
                            else
                            {
                                if (t.IsShowByExpression.Value)
                                {
                                    isShow = false;
                                }
                                else
                                {
                                    isShow = true;
                                }
                            }
                        }
                    }
                    else
                    {
                        isShow = true;
                    }
                    if (isShow)
                    {
                        t.TargetUrl = CPExpressionHelper.Instance.RunCompile(t.TargetUrl);
                        cCol.Add(t);
                    }
                });
                #region 添加修改配置按钮
                if (re.Tab.SysId.HasValue && re.Tab.SysId.Value.Equals(CPAppContext.InnerSysId) == false)
                {
                    string UserAdminSysIds = CPExpressionHelper.Instance.RunCompile("${CPUser.UserAdminSysIds()}");
                    if (UserAdminSysIds.Split(',').ToList().Contains(re.Tab.SysId.ToString()))
                    {
                        CPTabItem func1 = new CPTabItem();
                        func1.EleTitle            = "修改配置";
                        func1.IsUseExpressionShow = false;
                        func1.ShowOrder           = 99999;
                        func1.TabId     = re.Tab.Id;
                        func1.TargetUrl = "/Plat/Form/FormView?FormCode=Form201709231502250010&SceneCode=Scene201709231514430010&ViewCode=View201709231514390010&DeviceType=1&InitGroupCode=Group201709231514470010&SysId=1&PKValues=" + re.Tab.Id;
                        cCol.Add(func1);
                    }
                }
                #endregion
                re.Tab.ItemCol = cCol;
                #endregion
                re.Result = true;
                return(re);
            }
            catch (Exception ex)
            {
                re.Result   = false;
                re.ErrorMsg = ex.Message.ToString();
                return(re);
            }
        }