public IActionResult UploadFilesAjax()
        {
            string _FilePath = CPAppContext.QueryString <string>("FilePath");

            _FilePath = CPAppContext.CPFilesPath() + _FilePath;
            if (System.IO.Directory.Exists(_FilePath) == false)
            {
                System.IO.Directory.CreateDirectory(_FilePath);
            }

            long size  = 0;
            var  files = Request.Form.Files;

            foreach (var file in files)
            {
                var filename = ContentDispositionHeaderValue
                               .Parse(file.ContentDisposition)
                               .FileName
                               .Trim('"');
                filename = _FilePath + $@"\{filename}";
                size    += file.Length;
                using (FileStream fs = System.IO.File.Create(filename))
                {
                    file.CopyTo(fs);
                    fs.Flush();
                }
            }
            string message = "{\"ReturnCode\":" + 1 + "}";

            return(Json(message));
        }
Example #2
0
        public IActionResult GridViewPreview()
        {
            base.SetGlobalViewBag();
            int    TargetGridId = CPAppContext.QueryString <int>("TargetGridId");
            string userId       = CPExpressionHelper.Instance.RunCompile("${CPUser.UserId()}");
            CPGrid grid         = CPGridEngine.Instance(int.Parse(userId)).GetGrid(TargetGridId, false, false);

            return(RedirectToAction("GridView", new { GridCode = grid.GridCode }));
        }
        public FileResult DownloadFile()
        {
            string FilePath = CPAppContext.QueryString <string>("FilePath");

            FilePath = CPAppContext.CPFilesPath() + FilePath;

            byte[] fileBytes = System.IO.File.ReadAllBytes(FilePath);
            return(File(fileBytes, "application/x-msdownload", System.IO.Path.GetFileName(FilePath)));
        }
        public FileResult ShowPicture()
        {
            string FilePath = CPAppContext.QueryString <string>("FilePath");

            FilePath = CPAppContext.CPFilesPath() + FilePath;
            int    lastIndex = FilePath.LastIndexOf(".");
            string fileEx    = FilePath.Substring(lastIndex + 1, FilePath.Length - lastIndex - 1);

            // return new FileStreamResult(new FileStream(FilePath, FileMode.Open), "image/" + fileEx);
            byte[] fileBytes = System.IO.File.ReadAllBytes(FilePath);
            return(File(fileBytes, "image/" + fileEx, System.IO.Path.GetFileName(FilePath)));
        }
Example #5
0
        // GET: /<controller>/
        public IActionResult FileUpload()
        {
            base.SetGlobalViewBag();
            string BusinessCode = CPAppContext.QueryString <string>("BusinessCode");

            BusinessCode = CPAppContext.FormatSqlPara(BusinessCode);
            string ReturnMethod   = CPAppContext.QueryString <string>("ReturnMethod");
            string AllowFileTypes = CPAppContext.QueryString <string>("AllowFileTypes");
            string AllowFileCount = CPAppContext.QueryString <string>("AllowFileCount");
            string FilePath       = BusinessCode + "/" + DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + "/" + new CPRuntimeContext().HHMMSSLongString() + "/";

            ViewBag.BusinessCode   = BusinessCode;
            ViewBag.ReturnMethod   = ReturnMethod;
            ViewBag.FilePath       = FilePath;
            ViewBag.AllowFileTypes = AllowFileTypes;
            ViewBag.AllowFileCount = AllowFileCount;
            return(View());
        }
Example #6
0
        public ActionResult SelectExp()
        {
            base.SetGlobalViewBag();
            //nType: 0通用表达式  1列表  2表单   3树 4流程
            int ToolType = CPAppContext.QueryString <int>("Type");
            List <SelectExpClass> cCol = new List <SelectExpClass>();

            for (int i = 0; i < CPExpressionHelper.Instance._vltContext.Keys.Length; i++)
            {
                Type           type      = CPExpressionHelper.Instance._vltContext.InternalGet(CPExpressionHelper.Instance._vltContext.Keys[i].ToString()).GetType();
                SelectExpClass c         = new SelectExpClass();
                var            attribute = type.GetCustomAttributes(typeof(CPNameAttribute), false).FirstOrDefault();
                c.Name   = type.Name;
                c.ExpKey = CPExpressionHelper.Instance._vltContext.Keys[i].ToString();
                if (attribute != null)
                {
                    c.Name = ((CPNameAttribute)attribute).Name + c.Name;
                    if (ToolType.Equals(0))
                    {
                        if (((CPNameAttribute)attribute).ToolType.Equals(1) ||
                            ((CPNameAttribute)attribute).ToolType.Equals(2) ||
                            ((CPNameAttribute)attribute).ToolType.Equals(3) ||
                            ((CPNameAttribute)attribute).ToolType.Equals(4)
                            )
                        {
                            continue;
                        }
                    }
                    else if (ToolType.Equals(1))
                    {
                        if (((CPNameAttribute)attribute).ToolType.Equals(2)
                            ||
                            ((CPNameAttribute)attribute).ToolType.Equals(3)
                            ||
                            ((CPNameAttribute)attribute).ToolType.Equals(4)
                            )
                        {
                            continue;
                        }
                    }
                    else if (ToolType.Equals(2))
                    {
                        if (((CPNameAttribute)attribute).ToolType.Equals(1)
                            ||
                            ((CPNameAttribute)attribute).ToolType.Equals(3)
                            ||
                            ((CPNameAttribute)attribute).ToolType.Equals(4)
                            )
                        {
                            continue;
                        }
                    }
                    else if (ToolType.Equals(3))
                    {
                        if (((CPNameAttribute)attribute).ToolType.Equals(1)
                            ||
                            ((CPNameAttribute)attribute).ToolType.Equals(2)
                            ||
                            ((CPNameAttribute)attribute).ToolType.Equals(4)
                            )
                        {
                            continue;
                        }
                    }
                    else if (ToolType.Equals(4))
                    {
                        if (((CPNameAttribute)attribute).ToolType.Equals(1)
                            ||
                            ((CPNameAttribute)attribute).ToolType.Equals(2)
                            ||
                            ((CPNameAttribute)attribute).ToolType.Equals(3)
                            )
                        {
                            continue;
                        }
                    }
                }
                c.MethodCol = new List <SelectExpMethod>();
                MethodInfo[] mCol = type.GetMethods();
                mCol.ToList().ForEach(t =>
                {
                    if (t.Attributes.ToString().ToLower().IndexOf("public") == -1)
                    {
                        return;
                    }
                    if (t.Name.Equals("ToString", StringComparison.CurrentCultureIgnoreCase) ||
                        t.Name.Equals("Equals", StringComparison.CurrentCultureIgnoreCase) ||
                        t.Name.Equals("GetHashCode", StringComparison.CurrentCultureIgnoreCase) ||
                        t.Name.Equals("GetType", StringComparison.CurrentCultureIgnoreCase)
                        )
                    {
                        return;
                    }
                    SelectExpMethod m = new SelectExpMethod();
                    m.Name            = t.Name;
                    m.MethodName      = t.Name;
                    var attribute2    = t.GetCustomAttributes(typeof(CPNameAttribute), false).FirstOrDefault();
                    if (attribute2 != null)
                    {
                        m.Name = ((CPNameAttribute)attribute2).Name + m.Name;
                    }
                    m.ParaCol      = new List <string>();
                    m.ParaTitleCol = new List <string>();
                    t.GetParameters().ToList().ForEach(p =>
                    {
                        var attribute3 = p.GetCustomAttributes(typeof(CPNameAttribute), false).FirstOrDefault();
                        if (attribute3 != null)
                        {
                            m.ParaTitleCol.Add(((CPNameAttribute)attribute3).Name);
                        }
                        else
                        {
                            m.ParaTitleCol.Add("");
                        }
                        m.ParaCol.Add(p.Name);
                    });
                    c.MethodCol.Add(m);
                });
                cCol.Add(c);
            }
            ViewBag.ExpCol = cCol;
            return(View());
        }
Example #7
0
        public GetGridDataReturn GetGridData(string GridCode, int CurUserId, string CurUserIden,
                                             int page, int pageSize, string OtherCondition)
        {
            base.SetHeader();
            GridCode    = CPAppContext.FormatSqlPara(GridCode);
            CurUserIden = CPAppContext.FormatSqlPara(CurUserIden);
            //OtherCondition = CPAppContext.FormatSqlPara(OtherCondition);
            if (OtherCondition != null)
            {
                OtherCondition = System.Web.HttpUtility.UrlDecode(OtherCondition);
                OtherCondition = OtherCondition.Replace("@", "%");
            }
            GetGridDataReturn re = new GetGridDataReturn();

            try
            {
                CPGrid Grid    = CPGridEngine.Instance(CurUserId).GetGrid(GridCode, true, true);
                string orderBy = "";
                #region 获取排序字段
                List <string> querys     = CPAppContext.GetHttpContext().Request.Query.Keys.Where(t => t.StartsWith("sort[")).ToList();
                var           queryCount = querys.Count(m => m.EndsWith("[field]"));
                for (int i = 0; i < queryCount; i++)
                {
                    //请查询字段和对应的值存储在一个字典中
                    string field = CPAppContext.QueryString <string>("sort[" + i + "][field]");
                    field = field.Replace("Column", "");
                    List <CPGridColumn> colTmp = Grid.ColumnCol.Where(c => c.Id.Equals(int.Parse(field))).ToList();
                    if (colTmp.Count > 0)
                    {
                        field = colTmp[0].FieldName;
                    }
                    string fieldValue = CPAppContext.QueryString <string>("sort[" + i + "][dir]");
                    if (string.IsNullOrEmpty(orderBy))
                    {
                        orderBy = field + " " + fieldValue;
                    }
                    else
                    {
                        orderBy += "," + field + " " + fieldValue;
                    }
                }
                #endregion


                if (this.CheckUserIden(CurUserId, CurUserIden) == false)
                {
                    re.Result   = false;
                    re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!";
                    return(re);
                }

                try
                {
                    int       recordSize = 0;
                    DataTable dt         = CPGridEngine.Instance(CurUserId).ReadDataAndFormat(Grid, page, pageSize, OtherCondition, orderBy, out recordSize);
                    re.RecordSize = recordSize;
                    re.DataJson   = CPUtils.DataTable2Json(dt);
                    re.Result     = true;
                }
                catch (Exception ex)
                {
                    re.Result   = false;
                    re.ErrorMsg = ex.Message.ToString();
                }

                return(re);
            }
            catch (Exception ex)
            {
                re.Result   = false;
                re.ErrorMsg = ex.Message.ToString();
                return(re);
            }
        }
Example #8
0
        public IActionResult FlowMonitorFrame()
        {
            base.SetGlobalViewBag();
            string         UserId      = CPExpressionHelper.Instance.RunCompile("${CPUser.UserId()}");
            string         UserRoleIds = CPExpressionHelper.Instance.RunCompile("${CPUser.UserRoleIds()}");
            CPFlowTemplate template    = CPFlowTemplate.Instance();
            List <int>     roleIdCol   = new List <int>();

            UserRoleIds.Split(',').ToList().ForEach(t => {
                if (string.IsNullOrEmpty(t) == false)
                {
                    roleIdCol.Add(int.Parse(t));
                }
            });
            List <CPFlow> col        = template.GetHasMonitorRightFlow(int.Parse(UserId), roleIdCol);
            string        flowVerIds = "";

            col.ForEach(t => {
                if (string.IsNullOrEmpty(flowVerIds))
                {
                    flowVerIds = t.FlowVerId.ToString();
                }
                else
                {
                    flowVerIds += "," + t.FlowVerId.ToString();
                }
            });
            if (string.IsNullOrEmpty(flowVerIds))
            {
                flowVerIds = "-1";
            }
            CPAppContext.GetHttpContext().Session.SetString("UserHasMonitorRightFlowVerIds", flowVerIds);
            return(Redirect(CPAppContext.CPWebRootPath() + "/Plat/Grid/GridView?GridCode=" + CPAppContext.QueryString <string>("GridCode")));
        }