Esempio n. 1
0
        public ActionResult SoftwareUploadClick(string version, string type, string plistUrl)
        {
            var result          = new DirectResult();
            var fileUploadField = this.GetCmp <FileUploadField>("fileUploadField");

            if (fileUploadField.HasFile)
            {
                try
                {
                    string postedFileName = GetPostedFileName(fileUploadField.PostedFile.FileName);
                    postedFileName = ChinesePinYin.GetPinYin(postedFileName);
                    var    documentAttachment = new DocumentAttachment(GetFilePath(type, GetSoftwareBaseFolder()));
                    string filePath           = documentAttachment.GetFileName(postedFileName);
                    string url = GetUrl(type, GetSoftwareMuLu(), postedFileName);
                    fileUploadField.PostedFile.SaveAs(filePath);
                    SaveSoftwareFilePathToDbstring(version, type, url, plistUrl);
                    X.Msg.Show(MessageBoxConfig(Success, TiShi, MessageBox.Icon.INFO));
                }
                catch (Exception ex)
                {
                    X.Msg.Show(MessageBoxConfig(ex.ToString(), Fail, MessageBox.Icon.INFO));
                }
                finally
                {
                    PushMessageToTag(type.ToLower(), version, "all", 1, -1, string.Empty, string.Empty, 0);
                }
            }
            else
            {
                result.IsUpload = true;
                X.Msg.Show(MessageBoxConfig(NoFile, TiShi, MessageBox.Icon.ERROR));
            }
            return(result);
        }
Esempio n. 2
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                var areaPath       = HttpContext.Current.Request.Params["areaPath"].ToString(CultureInfo.InvariantCulture);
                var wuYeYongTu     = HttpContext.Current.Request.Params["wuYeYongTu"].ToString(CultureInfo.InvariantCulture);
                var wuYeBianHao    = HttpContext.Current.Request.Params["wuYeBianHao"].ToString(CultureInfo.InvariantCulture);
                var wuYeMingCheng  = HttpContext.Current.Request.Params["wuYeMingCheng"].ToString(CultureInfo.InvariantCulture);
                var zhaoPianLeiXin = HttpContext.Current.Request.Params["zhaoPianLeiXin"].ToString(CultureInfo.InvariantCulture);
                //var importDataType = HttpContext.Current.Request.Params["importDataType"].ToString(CultureInfo.InvariantCulture);

                string shi = GetCity(areaPath);
                for (int i = 0; i < context.Request.Files.Count; ++i)
                {
                    HttpPostedFile file = context.Request.Files[i];
                    if (file.ContentLength == 0 || string.IsNullOrEmpty(file.FileName))
                    {
                        continue;
                    }
                    string fileName = Guid.NewGuid() + Path.GetExtension(file.FileName);
                    //string fileFullName = HttpContext.Current.Server.MapPath(filePath + "/" + fileName);
                    //file.SaveAs(fileFullName);
                    var imageAttachment =
                        new ImageAttachment(GetFilePath(ChinesePinYin.GetPinYin(shi),
                                                        ChinesePinYin.GetPinYin(wuYeYongTu), GetZhaoPianBaseFolder(), wuYeBianHao));


                    string url = GetUrl(ChinesePinYin.GetPinYin(shi), ChinesePinYin.GetPinYin(wuYeYongTu), wuYeBianHao,
                                        GetZhaoPianMuLu(), fileName);

                    string imageFileFullPath = imageAttachment.GetFileName(fileName);

                    var img = new WebImage(file.InputStream);
                    SetImageDirection(img);
                    img.Save(imageFileFullPath);
                    SaveImageFilePathToDb(wuYeYongTu, shi, wuYeBianHao, wuYeMingCheng, zhaoPianLeiXin, imageFileFullPath,
                                          url, fileName, areaPath, img.GetBytes());

                    HttpContext.Current.Response.ContentType = "application/json";

                    var json = new JObject {
                        { "fileName", fileName }
                    };
                    HttpContext.Current.Response.Write(json.ToString());

                    context.Response.Flush();
                }
            }
            catch (Exception ex)
            {
                context.Response.StatusCode = 500;
                context.Response.Write(ex.Message);
                context.Response.End();
            }
            finally
            {
                context.Response.End();
            }
        }
Esempio n. 3
0
        public ActionResult ImageUploadClick(string areaPath, string wuYeYongTu, string wuYeBianHao,
                                             string wuYeMingCheng, string zhaoPianLeiXin, string importDataType)
        {
            var result          = new DirectResult();
            var fileUploadField = this.GetCmp <FileUploadField>("fileUploadField");

            if (fileUploadField.HasFile)
            {
                //string strFileName = Path.GetExtension(fileUploadField.PostedFile.FileName).ToUpper();//获取文件后缀
                //if (!(strFileName == ".BMP" || strFileName == ".GIF" || strFileName == ".JPG"))
                //{
                //    result.IsUpload = true;
                //    X.Msg.Show(MessageBoxErrorFormatConfig());
                //}
                try
                {
                    string shi            = GetCity(areaPath).Description;
                    string postedFileName = GetPostedFileName(fileUploadField.PostedFile.FileName);
                    postedFileName = ChinesePinYin.GetPinYin(postedFileName);
                    //wuYeYongTu = ChinesePinYin.GetPinYin(wuYeYongTu);
                    var imageAttachment =
                        new ImageAttachment(GetFilePath(ChinesePinYin.GetPinYin(shi),
                                                        ChinesePinYin.GetPinYin(wuYeYongTu), GetZhaoPianBaseFolder(), wuYeBianHao));
                    string imageFileFullPath = imageAttachment.GetFileName(postedFileName);
                    var    img = new WebImage(fileUploadField.PostedFile.InputStream);
                    SetImageDirection(img);
                    img.Save(imageFileFullPath);

                    //string url = GetUrl(areaPath, wuYeYongTu, wuYeMingCheng, zhaoPianLeiXin, postedFileName);
                    string url = GetUrl(ChinesePinYin.GetPinYin(shi), ChinesePinYin.GetPinYin(wuYeYongTu), wuYeBianHao,
                                        GetZhaoPianMuLu(), postedFileName);
                    SaveImageFilePathToDb(wuYeYongTu, shi, wuYeBianHao, wuYeMingCheng, zhaoPianLeiXin, imageFileFullPath,
                                          url, postedFileName, areaPath, img.GetBytes());

                    X.Msg.Show(MessageBoxConfig(Success, TiShi, MessageBox.Icon.INFO));
                }
                catch (Exception ex)
                {
                    X.Msg.Show(MessageBoxConfig(ex.ToString(), Fail, MessageBox.Icon.INFO));
                }
            }
            else
            {
                result.IsUpload = true;
                X.Msg.Show(MessageBoxConfig(NoFile, TiShi, MessageBox.Icon.ERROR));
            }
            return(result);
        }
Esempio n. 4
0
        public ActionResult ZhuanYeRenShiUploadClick(string areaPath)
        {
            var result = new DirectResult();

            var fileUploadField = this.GetCmp <FileUploadField>("fileUploadField");

            if (fileUploadField.HasFile)
            {
                try
                {
                    var    shi            = GetCity(areaPath).Description;
                    string postedFileName = GetPostedFileName(fileUploadField.PostedFile.FileName);
                    postedFileName = ChinesePinYin.GetPinYin(postedFileName);
                    const string type     = "zhuanyerenshi";
                    var          folder   = Path.Combine(GetZhaoPianMuLu(), ChinesePinYin.GetPinYin(shi), type);
                    var          fileName = Path.GetFileNameWithoutExtension(postedFileName) + DateTime.Now.ToString("yyyyMMddHHmmss") + Path.GetExtension(postedFileName);

                    var    imageAttachment   = new ImageAttachment(Server.MapPath("~/" + folder));
                    string imageFileFullPath = imageAttachment.GetFileName(fileName);
                    var    img = new WebImage(fileUploadField.PostedFile.InputStream);
                    img.Save(imageFileFullPath);
                    X.Msg.Show(MessageBoxConfig(Success, TiShi, MessageBox.Icon.INFO));
                    X.GetCmp <TextField>("ZhaoPian").Value = imageFileFullPath;

                    var url = WebPathUtility.Path.ToURI(imageFileFullPath);// "/" + Path.Combine(folder, fileName).Replace("\\", "/");
                    X.GetCmp <Image>("ZhaoPianImage").ImageUrl = url;
                    X.GetCmp <Hidden>("ZhaoPianUrl").Value     = url;
                }
                catch (Exception ex)
                {
                    X.Msg.Show(MessageBoxConfig(ex.ToString(), Fail, MessageBox.Icon.INFO));
                }
            }
            else
            {
                result.IsUpload = true;
                X.Msg.Show(MessageBoxConfig(NoFile, TiShi, MessageBox.Icon.ERROR));
            }
            return(result);
        }
Esempio n. 5
0
        public ActionResult XiTongImageUploadClick(string areaPath, string zhaoPianLeiXin, string importDataType)
        {
            var result = new DirectResult();

            var fileUploadField = this.GetCmp <FileUploadField>("fileUploadField");

            if (fileUploadField.HasFile)
            {
                try
                {
                    var    shi            = GetCity(areaPath).Description;
                    string postedFileName = GetPostedFileName(fileUploadField.PostedFile.FileName);
                    postedFileName = ChinesePinYin.GetPinYin(postedFileName);
                    const string type            = "system";
                    var          imageAttachment =
                        new ImageAttachment(GetFilePath(ChinesePinYin.GetPinYin(shi), type, GetZhaoPianBaseFolder()));
                    string imageFileFullPath = imageAttachment.GetFileName(postedFileName);
                    var    img = new WebImage(fileUploadField.PostedFile.InputStream);
                    SetImageDirection(img);
                    img.Save(imageFileFullPath);
                    string url = GetUrl(ChinesePinYin.GetPinYin(shi), type, GetZhaoPianMuLu(), postedFileName);
                    SaveXiTongImageFilePathToDb(shi, zhaoPianLeiXin, imageFileFullPath,
                                                url, postedFileName, areaPath);

                    X.Msg.Show(MessageBoxConfig(Success, TiShi, MessageBox.Icon.INFO));
                }
                catch (Exception ex)
                {
                    X.Msg.Show(MessageBoxConfig(ex.ToString(), Fail, MessageBox.Icon.INFO));
                }
            }
            else
            {
                result.IsUpload = true;
                X.Msg.Show(MessageBoxConfig(NoFile, TiShi, MessageBox.Icon.ERROR));
            }
            return(result);
        }
Esempio n. 6
0
        public ActionResult DocumentUploadClick(string title, string areaPath, string documentType, string releaseDate)
        {
            log4net.LogManager.GetLogger("DocumentUploadClick").InfoFormat("推送周刊数据【{0}】-【{1}】-【{2}】-【{3}】", title, areaPath, documentType, releaseDate);
            var limitClick = Session["DocumentUploadClick"] as DateTime?;

            if (limitClick.HasValue)
            {
                if ((DateTime.Now - limitClick.Value).TotalMinutes < 1)
                {
                    X.Msg.Show(MessageBoxConfig("不允许一分钟内重复发布周刊", TiShi, MessageBox.Icon.ERROR));
                    return(this.Direct());
                }
            }
            var result = new DirectResult();

            var    fileUploadField = this.GetCmp <FileUploadField>("fileUploadField");
            var    xingZhengQuYu   = GetCity(areaPath);
            string shi             = xingZhengQuYu.Description;

            if (fileUploadField.HasFile)
            {
                try
                {
                    string postedFileName = GetPostedFileName(fileUploadField.PostedFile.FileName);
                    postedFileName = ChinesePinYin.GetPinYin(postedFileName);
                    string type = ChinesePinYin.GetPinYin(documentType);
                    var    documentAttachment = new DocumentAttachment(GetFilePath(ChinesePinYin.GetPinYin(shi), type, GetDocumentBaseFolder()));
                    string filePath           = documentAttachment.GetFileName(postedFileName);
                    string url = GetUrl(ChinesePinYin.GetPinYin(shi), type, GetDocumentMuLu(), postedFileName);
                    fileUploadField.PostedFile.SaveAs(filePath);
                    SaveDocumentFilePathToDbstring(title, shi, postedFileName, fileUploadField.PostedFile.ContentType, documentType, releaseDate, filePath, url, areaPath);

                    switch (documentType)
                    {
                    case MsgInfo.ZhouKan:
                    case MsgInfo.ZhiDiFenXi:
                        //PushMessageToTag2(title, shi, 2, shi, documentType, xingZhengQuYu.Id);
                        PushMessageToTag2(title, shi, 2, shi, MsgInfo.ZhiDiFenXi, xingZhengQuYu.Id);
                        break;

                    case MsgInfo.TuDiGuaPai:
                    case MsgInfo.DiChanShaLong:
                    case MsgInfo.ZiChanChuZhi:
                        PushMessageToTag2(title, "all", 2, shi, documentType, xingZhengQuYu.Id);
                        break;
                    }
                    X.Msg.Show(MessageBoxConfig(Success, TiShi, MessageBox.Icon.INFO));
                }
                catch
                (Exception ex)
                {
                    X.Msg.Show(MessageBoxConfig(ex.ToString(), Fail, MessageBox.Icon.INFO));
                }
            }
            else
            {
                result.IsUpload = true;
                X.Msg.Show(MessageBoxConfig(NoFile, TiShi, MessageBox.Icon.ERROR));
            }
            return(result);
        }
Esempio n. 7
0
 public ActionResult GetPingYin(string wuYeMingCheng)
 {
     this.GetCmp <TextField>("PinYing").Value         = ChinesePinYin.GetPinYin(wuYeMingCheng);
     this.GetCmp <TextField>("PinYingShouZiMu").Value = ChinesePinYin.GetFirstPinyin(wuYeMingCheng);
     return(this.Direct());
 }