예제 #1
0
        private void Bind()
        {
            GetSearchItem();

            int totalRecords = 0;
            ActivityPlayerPhotoPicture bll = new ActivityPlayerPhotoPicture();

            rpData.DataSource = bll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray());
            rpData.DataBind();

            myDataAppend += "<div id=\"myDataForPage\" style=\"display:none;\">[{\"PageIndex\":\"" + pageIndex + "\",\"PageSize\":\"" + pageSize + "\",\"TotalRecord\":\"" + totalRecords + "\",\"QueryStr\":\"" + queryStr + "\"}]</div>";
        }
예제 #2
0
        private void Bind()
        {
            if (!string.IsNullOrEmpty(funName))
            {
                int totalRecords = 0;
                switch (funName)
                {
                case "CommunionPicture":
                    CommunionPicture communionpBll = new CommunionPicture();
                    rpData.DataSource = communionpBll.GetList(pageIndex, pageSize, out totalRecords, "", null);
                    rpData.DataBind();
                    break;

                case "UserHeadPicture":
                    UserHeadPicture uhpBll = new UserHeadPicture();
                    rpData.DataSource = uhpBll.GetList(pageIndex, pageSize, out totalRecords, "", null);
                    rpData.DataBind();
                    break;

                case "ActivityPhotoPicture":
                    ActivityPhotoPicture appBll = new ActivityPhotoPicture();
                    rpData.DataSource = appBll.GetList(pageIndex, pageSize, out totalRecords, "", null);
                    rpData.DataBind();
                    break;

                case "ActivityPlayerPhotoPicture":
                    ActivityPlayerPhotoPicture apppBll = new ActivityPlayerPhotoPicture();
                    rpData.DataSource = apppBll.GetList(pageIndex, pageSize, out totalRecords, "", null);
                    rpData.DataBind();
                    break;

                case "PictureScratchLotto":
                    PictureScratchLotto pslBll = new PictureScratchLotto();
                    rpData.DataSource = pslBll.GetList(pageIndex, pageSize, out totalRecords, "", null);
                    rpData.DataBind();
                    break;

                case "InformationPicture":
                    PictureInformation piBll = new PictureInformation();
                    rpData.DataSource = piBll.GetList(pageIndex, pageSize, out totalRecords, "", null);
                    rpData.DataBind();
                    break;

                default:
                    break;
                }

                myDataAppend.Replace("{TotalRecord}", totalRecords.ToString());
                myDataAppend.Replace("{PageIndex}", pageIndex.ToString());
                myDataAppend.Replace("{PageSize}", pageSize.ToString());
            }
        }
예제 #3
0
        private void OnUploadActivityPlayerPhotoPicture(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            string errorMsg = "";

            try
            {
                HttpFileCollection files = context.Request.Files;
                if (files.Count == 0)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"未找到任何可上传的文件,请检查!\"}");
                    return;
                }

                int effect            = 0;
                UploadFilesHelper ufh = new UploadFilesHelper();
                ImagesHelper      ih  = new ImagesHelper();

                using (TransactionScope scope = new TransactionScope())
                {
                    foreach (string item in files.AllKeys)
                    {
                        HttpPostedFile file = files[item];
                        if (file == null || file.ContentLength == 0)
                        {
                            continue;
                        }

                        int fileSize       = file.ContentLength;
                        int uploadFileSize = int.Parse(ConfigHelper.GetValueByKey("UploadFileSize"));
                        if (fileSize > uploadFileSize)
                        {
                            throw new ArgumentException("文件【" + file.FileName + "】大小超出字节" + uploadFileSize + ",无法上传,请正确操作!");
                        }
                        if (!UploadFilesHelper.IsFileValidated(file.InputStream, fileSize))
                        {
                            throw new ArgumentException("文件【" + file.FileName + "】为受限制的文件,请正确操作!");
                        }

                        string fileName = file.FileName;

                        ActivityPlayerPhotoPicture bll = new ActivityPlayerPhotoPicture();
                        if (bll.IsExist(file.FileName, fileSize))
                        {
                            throw new ArgumentException("文件【" + file.FileName + "】已存在,请勿重复上传!");
                        }

                        string originalUrl = UploadFilesHelper.UploadOriginalFile(file, "ActivityPhotoPicture");

                        //获取随机生成的文件名代码
                        string randomFolder = string.Format("{0}_{1}", DateTime.Now.ToString("MMdd"), UploadFilesHelper.GetRandomFolder("appp"));

                        ActivityPlayerPhotoPictureInfo model = new ActivityPlayerPhotoPictureInfo();
                        model.FileName        = VirtualPathUtility.GetFileName(originalUrl);
                        model.FileSize        = fileSize;
                        model.FileExtension   = VirtualPathUtility.GetExtension(originalUrl).ToLower();
                        model.FileDirectory   = VirtualPathUtility.GetDirectory(originalUrl.Replace("~", ""));
                        model.RandomFolder    = randomFolder;
                        model.LastUpdatedDate = DateTime.Now;

                        bll.Insert(model);

                        string rndDirFullPath = context.Server.MapPath(string.Format("~{0}{1}", model.FileDirectory, model.RandomFolder));
                        if (!Directory.Exists(rndDirFullPath))
                        {
                            Directory.CreateDirectory(rndDirFullPath);
                        }
                        File.Copy(context.Server.MapPath(originalUrl), string.Format("{0}\\{1}{2}", rndDirFullPath, randomFolder, model.FileExtension), true);

                        string[] platformNames = Enum.GetNames(typeof(EnumData.Platform));
                        foreach (string name in platformNames)
                        {
                            string platformUrl         = string.Format("{0}/{1}/{2}", model.FileDirectory, model.RandomFolder, name);
                            string platformUrlFullPath = context.Server.MapPath("~" + platformUrl);
                            if (!Directory.Exists(platformUrlFullPath))
                            {
                                Directory.CreateDirectory(platformUrlFullPath);
                            }
                            string   sizeAppend = ConfigHelper.GetValueByKey(name);
                            string[] sizeArr    = sizeAppend.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                            for (int i = 0; i < sizeArr.Length; i++)
                            {
                                string   bmsPicUrl = string.Format("{0}\\{1}_{2}{3}", platformUrlFullPath, model.RandomFolder, i, model.FileExtension);
                                string[] wh        = sizeArr[i].Split('*');

                                ih.CreateThumbnailImage(context.Server.MapPath(originalUrl), bmsPicUrl, int.Parse(wh[0]), int.Parse(wh[1]), "DB", model.FileExtension);
                            }
                        }

                        effect++;
                    }

                    scope.Complete();
                }

                if (effect == 0)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"未找到任何可上传的文件,请检查!\"}");
                    return;
                }

                context.Response.Write("{\"success\": true,\"message\": \"已成功上传文件数:" + effect + "个\"}");

                return;
            }
            catch (Exception ex)
            {
                errorMsg = ex.Message;
            }

            context.Response.Write("{\"success\": false,\"message\": \"" + errorMsg + "\"}");
        }