public JsonResult GetImageAsByte(int ad_image_id)
        {
            VImageModel   obj = new VImageModel();
            ImagePathInfo img = null;

            if (Session["Ctx"] != null)
            {
                var ctx = Session["ctx"] as Ctx;
                img = obj.GetImage(ctx, Convert.ToInt32(ad_image_id), 500, 375, ctx.GetApplicationUrl());
            }
            return(Json(JsonConvert.SerializeObject(img), JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public ActionResult UploadFileDownload()
        {
            HttpPostedFileBase myFile = Request.Files["DownloadUpload"];
            bool   isUploaded         = false;
            string message            = "上传失败!";
            //缩略图图片路径
            string fileType   = "";
            string ImgRootUrl = string.Empty;
            string sizestr    = "";

            if (myFile != null && myFile.ContentLength != 0)
            {
                string pathForSaving = string.Empty;
                fileType = FileHelper.GetDownLoadTag(myFile.FileName);
                double size = Math.Round(myFile.ContentLength * 1.0 / 1024 * 1.0, 2);
                if (size > 1024)
                {
                    size    = Math.Round(size * 1.0 / 1024 * 1.0, 2);
                    sizestr = size + "MB";
                }
                else
                {
                    sizestr = size + "KB";
                }
                pathForSaving = ImagePathInfo.ProcessBeginOfThePath("/DownLoad/Files");
                if (this.CreateFolderIfNeeded(pathForSaving))
                {
                    try
                    {
                        //图片路径处理
                        var ImgUrl = new ImagePathInfo(myFile.FileName, pathForSaving);
                        //如果路径不存在则新建
                        ImgUrl.CreateDirectory();
                        //保存图片
                        myFile.SaveAs(ImgUrl.FileAbsolutePath);
                        isUploaded = true;
                        //保存后的图片路径
                        message = ImgUrl.FileRelativePath;
                    }
                    catch (Exception ex)
                    {
                        message = string.Format("File upload failed: {0}", ex.Message);
                    }
                }
            }
            return(Json(new { isUploaded = isUploaded, message = message, form = fileType, size = sizestr }, "text/html"));
        }
Пример #3
0
        public ActionResult DecIndexImgUpload()
        {
            HttpPostedFileBase myFile = Request.Files["DecImageUpload"];
            //获取图片的种类对应图片文件夹名称(公司,工人,设计师,或案例)
            string ImageType  = "PeopleCenter";
            bool   isUploaded = false;
            string message    = "上传失败!";
            string ImgRootUrl = string.Empty;

            if (myFile != null && myFile.ContentLength != 0)
            {
                string pathForSaving = string.Empty;
                string fileType      = FileHelper.GetFileTag(myFile.FileName);
                if (fileType == "Image")
                {
                    pathForSaving = ImagePathInfo.ProcessBeginOfThePath("/UploadFiles/Images/" + ImageType);
                    //pathForSaving = Server.MapPath("~/UploadFiles/Images/"+ ImageType);
                }
                else
                {
                    pathForSaving = ImagePathInfo.ProcessBeginOfThePath
                                        ("/UploadFiles/Files");
                }

                if (this.CreateFolderIfNeeded(pathForSaving))
                {
                    try
                    {
                        //图片路径处理
                        var ImgUrl = new ImagePathInfo(myFile.FileName, pathForSaving);
                        //如果路径不存在则新建
                        ImgUrl.CreateDirectory();
                        //保存图片
                        myFile.SaveAs(ImgUrl.FileAbsolutePath);
                        isUploaded = true;
                        //保存后的图片路径
                        message = ImgUrl.FileRelativePath;
                    }
                    catch (Exception ex)
                    {
                        message = string.Format("File upload failed: {0}", ex.Message);
                    }
                }
            }
            return(Json(new { isUploaded = isUploaded, message = message }, "text/html"));
        }
Пример #4
0
        public static string GetthumImgByUrl(string url)
        {
            string ret           = "";
            string filename      = url.Substring(url.LastIndexOf('/') + 1, url.Length - url.LastIndexOf('/') - 1);
            string pathForSaving = ImagePathInfo.ProcessBeginOfThePath
                                       ("/UploadFiles/Files");
            Image img = Url2Img(url);

            byte[] bit    = ImageToByteArray(img);
            Stream stream = BytesToStream(bit);
            //缩略图处理
            var    thumbnailPathInfo = new ImagePathInfo(filename, pathForSaving);
            double hei    = 290 * (Math.Round((img.Height * 1.0 / img.Width) * 1.0, 2));
            int    height = Convert.ToInt32(Math.Round(hei, 0));

            using (var thumbNail = GetThumbnail(stream, 290, height, 100))
            {
                thumbnailPathInfo.CreateDirectory();
                thumbNail.Save(thumbnailPathInfo.FileAbsolutePath);
            }
            ret = thumbnailPathInfo.FileRelativePath;
            return(ret);
        }
        public ActionResult ComCenterPictrueUpload()
        {
            HttpPostedFileBase myFile = Request.Files["ImageUpload"];
            //获取图片的种类对应图片文件夹名称(公司,工人,设计师,或案例)
            string ImageType = "CompanyCenter";
            //缩略图宽高
            int thumwidth   = Convert.ToInt32(Request["thumwidth"]) == 0 ? 100 : Convert.ToInt32(Request["thumwidth"]);
            int thumheight  = Convert.ToInt32(Request["thumheight"]) == 0 ? 100 : Convert.ToInt32(Request["thumheight"]);
            int thumquality = Convert.ToInt32(Request["thumquality"]) == 0 ? 10 : Convert.ToInt32(Request["thumquality"]);

            bool   isUploaded = false;
            string message    = "上传失败!";
            //缩略图图片路径
            string thumbnailmessage = "";
            string ImgRootUrl       = string.Empty;

            if (myFile != null && myFile.ContentLength != 0)
            {
                string pathForSaving = string.Empty;
                string fileType      = FileHelper.GetFileTag(myFile.FileName);
                if (fileType == "Image")
                {
                    pathForSaving = ImagePathInfo.ProcessBeginOfThePath("/UploadFiles/Images/" + ImageType);
                    //pathForSaving = Server.MapPath("~/UploadFiles/Images/"+ ImageType);
                }
                else
                {
                    pathForSaving = ImagePathInfo.ProcessBeginOfThePath
                                        ("/UploadFiles/Files");
                }

                if (this.CreateFolderIfNeeded(pathForSaving))
                {
                    try
                    {
                        //图片路径处理
                        var ImgUrl = new ImagePathInfo(myFile.FileName, pathForSaving);
                        //如果路径不存在则新建
                        ImgUrl.CreateDirectory();
                        //保存图片
                        myFile.SaveAs(ImgUrl.FileAbsolutePath);
                        isUploaded = true;
                        //保存后的图片路径
                        message = ImgUrl.FileRelativePath;


                        //缩略图处理
                        var thumbnailPathInfo = new ImagePathInfo(myFile.FileName, pathForSaving);
                        using (var imgStream = myFile.InputStream)
                        {
                            var width   = 0;
                            var height  = 0;
                            var quality = 0;

                            width   = thumwidth;
                            height  = thumheight;
                            quality = thumquality;


                            using (var thumbNail = ImageHelper.GetThumbnail(imgStream, width, height, quality))
                            {
                                thumbnailPathInfo.CreateDirectory();
                                thumbNail.Save(thumbnailPathInfo.FileAbsolutePath);
                            }
                        }
                        thumbnailmessage = thumbnailPathInfo.FileRelativePath;
                    }
                    catch (Exception ex)
                    {
                        message = string.Format("File upload failed: {0}", ex.Message);
                    }
                }
            }
            return(Json(new { isUploaded = isUploaded, message = message, thumbnailmessage = thumbnailmessage }, "text/html"));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                #region Script Resource

                ScriptReference scriptReference = new ScriptReference();
                scriptReference.Path = ConfigurationManager.AppSettings["MaintJsPath"].ToString().TrimEnd('/') + "/ScriptResources/EquipmentInfoScriptResource.js";
                string[] cultures = ConfigurationManager.AppSettings["SupportLanguages"].ToString().Split(',');
                scriptReference.ResourceUICultures = CommonBLL.GetCultures(cultures, scriptReference.Path);
                scriptManager.Scripts.Add(scriptReference);

                scriptReference      = new ScriptReference();
                scriptReference.Path = ConfigurationManager.AppSettings["MaintJsPath"].ToString().TrimEnd('/') + "/ScriptResources/JQueryCalendarScriptResource.js";
                scriptReference.ResourceUICultures = CommonBLL.GetCultures(cultures, scriptReference.Path);
                scriptManager.Scripts.Add(scriptReference);
                #endregion

                int fLocationID = 0;
                int equipmentID = 0;
                int siteID      = CommonBLL.ValidateSiteID(Request);
                int userID      = this.CurrentUser.UserID;

                if (siteID == 0)
                {
                    Response.Redirect(ConfigurationManager.AppSettings["NoAccessPage"].ToString());
                }

                int accessLevelID = CommonBLL.GetAccessLevelID(this.CurrentUser.AccessLevel);

                //functional location id
                if (Request.QueryString["flid"] != null && Request.QueryString["flid"].Trim().Length > 0)
                {
                    fLocationID = Convert.ToInt32(Request.QueryString["flid"].Trim());
                }

                //equipment id
                if (Request.QueryString["eid"] != null && Request.QueryString["eid"].Trim().Length > 0)
                {
                    equipmentID = Convert.ToInt32(Request.QueryString["eid"].Trim());
                }

                AccessType access = ValidateUserPrivileges(siteID, accessLevelID);

                FilterObject filterObject = new FilterObject();
                if (Request.QueryString["filterTextValue"] != null && Request.QueryString["filterTextValue"].Trim().Length > 0)
                {
                    filterObject.FilterTextValue = Request.QueryString["filterTextValue"].Trim();
                }
                if (Request.QueryString["fids"] != null && Request.QueryString["fids"].Trim().Length > 0)
                {
                    filterObject.FilterLocationIds = Request.QueryString["fids"].Trim();
                }
                if (Request.QueryString["cids"] != null && Request.QueryString["cids"].Trim().Length > 0)
                {
                    filterObject.FilterCategoryIds = Request.QueryString["cids"].Trim();
                }

                string        basePath       = ConfigurationManager.AppSettings["MaintBasePath"].ToString().TrimEnd('/');
                string        webServicePath = ConfigurationManager.AppSettings["MaintWebServicePath"].Trim();
                ImagePathInfo imagePathInfo  = new ImagePathInfo();
                imagePathInfo.UploaderPath          = ConfigurationManager.AppSettings["uploaderPath"].ToString().Trim('/');
                imagePathInfo.ImgDefaultProfilePath = ConfigurationManager.AppSettings["MaintImagePath"].TrimEnd('/') + "/Styles/Images/Equipments.png";
                imagePathInfo.EquipmentImgPath      = ConfigurationManager.AppSettings["EquipmentImagePath"].ToString().Trim('/') + "/" + siteID + "/" + "Thumbnail";

                Vegam_MaintenanceService.SiteDateTimeFormatInfo dateTimeFormat = BLL.MaintenanceBLL.GetSiteDateTimeFormatInfo(siteID);
                hdfDatePickerFormat.Value = CommonBLL.GetDatePickerDateFormat(dateTimeFormat.DateFormat);

                BasicParam basicParam = new BasicParam();
                basicParam.SiteID        = siteID;
                basicParam.UserID        = userID;
                basicParam.AccessLevelID = accessLevelID;
                basicParam.LanguageCode  = this.CurrentUser.LanguageCode;

                UserControls.PagerData pagerData = new UserControls.PagerData();
                pagerData.PageIndex        = 0;
                pagerData.PageSize         = int.Parse(hdnEquipmentPageSize.Value.ToString());
                pagerData.SelectMethod     = "LoadAllEquipmentInfo";
                pagerData.ServicePath      = webServicePath;
                pagerData.SiteID           = siteID;
                pagerData.UserID           = userID;
                pagerData.AccessLevelID    = accessLevelID;
                pagerData.LoadControlID    = divModelInfo.ClientID;
                pagerData.PageAccessRights = access.ToString();

                # region PagerData for Equipment model and master popup
                //using pager for equipment model selection
                UserControls.PagerData modelPagerData = new UserControls.PagerData();
                modelPagerData.PageIndex        = 0;
                modelPagerData.PageSize         = int.Parse(hdnModelPageSize.Value.ToString());
                modelPagerData.SelectMethod     = "LoadEquipmentModelInfo";
                modelPagerData.ServicePath      = webServicePath;
                modelPagerData.SiteID           = siteID;
                modelPagerData.UserID           = userID;
                modelPagerData.PageAccessRights = access.ToString();


                //using pager for displaying maintenance master data in configure maintenance types modal popup
                UserControls.PagerData maintTypePagerData = new UserControls.PagerData();
                maintTypePagerData.PageIndex        = 0;
                maintTypePagerData.PageSize         = int.Parse(hdnModelPageSize.Value.ToString());
                maintTypePagerData.SelectMethod     = "LoadMaintTypesInfo";
                maintTypePagerData.ServicePath      = webServicePath;
                maintTypePagerData.SiteID           = siteID;
                maintTypePagerData.UserID           = userID;
                maintTypePagerData.AccessLevelID    = accessLevelID;
                maintTypePagerData.LoadControlID    = divModelInfo.ClientID;
                maintTypePagerData.PageAccessRights = access.ToString();
                #endregion

                if (access == AccessType.FULL_ACCESS)
                {
                    btnAddMaintType.Attributes.Add("onclick", "javascript:InsertOrUpdateMaintType(" + (new JavaScriptSerializer()).Serialize(0) + ");return false;");
                }
                else
                {
                    btnAddMaintType.Attributes.Add("disabled", "disabled");
                }

                thMaintTypes.Attributes.Add("onclick", "javascript:SortMaintTypesTabs('" + thMaintTypes.ClientID + "','MasterDataName');");
                sortEquipment.Attributes.Add("onclick", "javascript:SortByEquipmentName('" + sortEquipment.ClientID + "','EquipmentName');");

                ScriptManager.RegisterStartupScript(this, this.GetType(), "LoadEquipmentBasicInfo", "javascript:LoadEquipmentBasicInfo(" + (new JavaScriptSerializer()).Serialize(basicParam) + "," + (new JavaScriptSerializer()).Serialize(pagerData) + "," + (new JavaScriptSerializer()).Serialize(maintTypePagerData) + "," + (new JavaScriptSerializer()).Serialize(modelPagerData) + ",'" + basePath + "','" + webServicePath + "','" + equipmentID + "','" + hasEditAccess + "','" + hasDeleteAccess + "'," + (new JavaScriptSerializer()).Serialize(imagePathInfo) + ",'" + fLocationID + "','" + hdfDatePickerFormat.Value + "');", true);
            }