Esempio n. 1
0
        public ActionResult PSD(Guid id)
        {
            QRCode_Template_BLL bll  = new QRCode_Template_BLL();
            QRCode_Template     temp = bll.Get(a => a.TemplateID == id);

            return(View(temp));
        }
Esempio n. 2
0
        public ActionResult Add(QRCode_Template model)
        {
            model.TemplateID = Guid.NewGuid();
            QRCode_Template_BLL bll = new QRCode_Template_BLL();

            bll.Add(model);
            return(RedirectToAction("Add"));
        }
Esempio n. 3
0
        public ActionResult UploadPSD(Guid TemplateID, HttpPostedFileBase fileData)
        {
            if (fileData != null)
            {
                try
                {
                    QRCode_Template_BLL bll  = new QRCode_Template_BLL();
                    QRCode_Template     temp = bll.Get(a => a.TemplateID == TemplateID);



                    byte[] buffer = new byte[fileData.ContentLength];
                    fileData.InputStream.Read(buffer, 0, fileData.ContentLength);

                    Stream stream = new MemoryStream(buffer);

                    string key = "qrcodetemplatepsd/" + Guid.NewGuid().ToString() + Path.GetExtension(fileData.FileName);
                    if (QiNiuHelper.PutFile(ConfigurationManager.AppSettings["QiNiuBucket"].ToString().Trim(), key, stream))
                    {
                        if (temp.TemplatePSDUrl != null)
                        {
                            QiNiuHelper.Delete(ConfigurationManager.AppSettings["QiNiuBucket"].ToString().Trim(), temp.TemplatePSDUrl);
                        }



                        temp.TemplatePSDUrl = key;

                        bll.Update(temp);

                        string filename = Path.GetFileName(fileData.FileName);
                        string fileurl  = ConfigurationManager.AppSettings["QiNiuDomain"] + key;
                        return(Json(new { Success = true, FileName = filename, SaveName = fileurl }));
                    }
                    else
                    {
                        return(Json(new { Success = false, Message = "上传失败,请稍后再试!" }));
                    }
                }
                catch (Exception ex)
                {
                    return(Json(new { Success = false, Message = ex.Message }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json(new { Success = false, Message = "请选择要上传的文件!" }, JsonRequestBehavior.AllowGet));
            }
        }