private void Bind()
        {
            GetSearchItem();

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

            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>";
        }
Ejemplo n.º 2
0
        private void Bind()
        {
            if (!string.IsNullOrEmpty(funName))
            {
                int totalRecords = 0;
                switch (funName)
                {
                case "AdvertisementPicture":
                    AdvertisementPicture adpBll = new AdvertisementPicture();
                    rpData.DataSource = adpBll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray());
                    rpData.DataBind();
                    break;

                case "PictureBrand":
                    PictureBrand pbBll = new PictureBrand();
                    rpData.DataSource = pbBll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray());
                    rpData.DataBind();
                    break;

                case "PictureCategory":
                    PictureCategory pcBll = new PictureCategory();
                    rpData.DataSource = pcBll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray());
                    rpData.DataBind();
                    break;

                case "PictureProduct":
                    PictureProduct ppBll = new PictureProduct();
                    rpData.DataSource = ppBll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray());
                    rpData.DataBind();
                    break;

                case "PictureProductSize":
                    PictureProductSize ppsBll = new PictureProductSize();
                    rpData.DataSource = ppsBll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray());
                    rpData.DataBind();
                    break;

                case "PictureServiceItem":
                    PictureServiceItem psiBll = new PictureServiceItem();
                    rpData.DataSource = psiBll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray());
                    rpData.DataBind();
                    break;

                case "PictureServiceVote":
                    PictureServiceVote psvBll = new PictureServiceVote();
                    rpData.DataSource = psvBll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray());
                    rpData.DataBind();
                    break;

                case "PictureServiceLink":
                    PictureServiceLink pslBll = new PictureServiceLink();
                    rpData.DataSource = pslBll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray());
                    rpData.DataBind();
                    break;

                case "PictureServiceContent":
                    PictureServiceContent pscBll = new PictureServiceContent();
                    rpData.DataSource = pscBll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray());
                    rpData.DataBind();
                    break;

                default:
                    break;
                }

                myDataAppend.Replace("{TotalRecord}", totalRecords.ToString());
                myDataAppend.Replace("{PageIndex}", pageIndex.ToString());
                myDataAppend.Replace("{PageSize}", pageSize.ToString());
            }
        }
Ejemplo n.º 3
0
        private void OnUploadAdvertisementPicture(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(TygaSoft.WebHelper.ConfigHelper.GetValueByKey("UploadFileSize"));
                        if (fileSize > uploadFileSize)
                        {
                            throw new ArgumentException("文件【" + file.FileName + "】大小超出字节" + uploadFileSize + ",无法上传,请正确操作!");
                        }
                        if (!UploadFilesHelper.IsFileValidated(file.InputStream, fileSize))
                        {
                            throw new ArgumentException("文件【" + file.FileName + "】为受限制的文件,请正确操作!");
                        }

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

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

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

                        AdvertisementPictureInfo model = new AdvertisementPictureInfo();
                        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);

                        CreateThumbnailImage(context, ih, originalUrl, model.FileDirectory, model.RandomFolder, 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 + "\"}");
        }