예제 #1
0
        private void ListImages()
        {
            ImageFilesDAL obj        = new ImageFilesDAL();
            DataSet       objDataset = new DataSet();

            try
            {
                //string where = " UserCreated =" + _user.UserID;
                string where = string.Empty;
                if (ddlStock.SelectedValue.Trim() != "0")
                {
                    where += " 1=1 And AuthorID =1 ";
                }
                else
                {
                    where += " 1=1 And (( AuthorID =0 ) OR (AuthorID is null ))";
                }
                if (!string.IsNullOrEmpty(fileName.Text))
                {
                    where += " AND ImageFileName like N'%" + fileName.Text + "%'";
                }
                //if (Drop_Chuyenmuc.SelectedValue.Trim() != "0")
                //    where += string.Format(" AND Categorys_ID IN (SELECT * FROM [fn_Return_Category_Tree] ({0}))", this.Drop_Chuyenmuc.SelectedValue);
                if (!String.IsNullOrEmpty(txt_FromDate.Text.Trim()))
                {
                    where += " AND " + string.Format(" (Datediff(DAY,'{0}',DateCreated)>=0) ", UltilFunc.ToDate(this.txt_FromDate.Value.ToString().Trim(), "MM/dd/yyyy"));
                }
                if (!String.IsNullOrEmpty(txt_ToDate.Text.Trim()))
                {
                    where += " AND " + string.Format(" (Datediff(DAY,'{0}',DateCreated)<=0)", UltilFunc.ToDate(this.txt_ToDate.Value.ToString().Trim(), "MM/dd/yyyy"));
                }
                else
                {
                    if (ddlStock.SelectedValue.Trim() == "0")
                    {
                        where += " AND " + string.Format(" DATEDIFF(DAY,DateCreated,'{0}')=0 ", DateTime.Now.ToString("MM/dd/yyyy"));
                    }
                }
                where     += " ORDER BY DateCreated DESC";
                objDataset = obj.ListAllImages(where);
                if (objDataset != null)
                {
                    DataView _dv = obj.BindGridListImages(objDataset.Tables[0]);
                    dlImages.DataSource = _dv;
                    dlImages.DataBind();
                }
                objDataset.Clear();
            }
            catch
            {
                dlImages.DataSource = null;
                dlImages.DataBind();
            }
        }
        private void ListImages()
        {
            ImageFilesDAL obj        = new ImageFilesDAL();
            DataSet       objDataset = new DataSet();

            string where = " UserCreated =" + user.UserID;
            //if (!String.IsNullOrEmpty(txt_FromDate.Text.Trim()))
            //    where += " AND " + string.Format(" (Datediff(DAY,'{0}',DateCreated)>=0) ", UltilFunc.ToDate(this.txt_FromDate.Value.ToString().Trim(), "MM/dd/yyyy"));
            //if (!String.IsNullOrEmpty(txt_ToDate.Text.Trim()))
            //    where += " AND " + string.Format(" (Datediff(DAY,'{0}',DateCreated)<=0) ", UltilFunc.ToDate(this.txt_ToDate.Value.ToString().Trim(), "MM/dd/yyyy"));
            //else
            where     += " AND " + string.Format(" DATEDIFF(DAY,DateCreated,'{0}')=0 ", DateTime.Now.ToString("MM/dd/yyyy"));
            where     += " ORDER BY DateCreated DESC";
            objDataset = obj.ListAllImages(where);
            if (objDataset != null)
            {
                DataView _dv = obj.BindGridListImages(objDataset.Tables[0]);
                dlImages.DataSource = _dv;
                dlImages.DataBind();
            }
        }
예제 #3
0
        protected void dlImages_EditCommand(object source, DataListCommandEventArgs e)
        {
            // xóa ảnh
            Label         lblid   = (Label)e.Item.FindControl("lbl_ID");
            Label         lblURL  = (Label)e.Item.FindControl("lbl_URL");
            int           ImageID = int.Parse(lblid.Text);
            ImageFilesDAL obj     = new ImageFilesDAL();

            try
            {
                string strRootPathVirtual = System.Configuration.ConfigurationManager.AppSettings["UploadPathBDT"] + lblURL.Text;
                string savepath           = Server.MapPath(strRootPathVirtual);
                if (File.Exists(savepath))
                {
                    File.Delete(savepath);
                }
            }
            catch {; }
            obj.Delete_Image(ImageID);
            ListImages();
        }
예제 #4
0
        protected void dlImages_EditCommand(object source, DataListCommandEventArgs e)
        {
            // xóa ảnh
            Label         lblid   = (Label)e.Item.FindControl("lbl_ID");
            Label         lblURL  = (Label)e.Item.FindControl("lbl_URL");
            int           ImageID = int.Parse(lblid.Text);
            ImageFilesDAL obj     = new ImageFilesDAL();

            try
            {
                string strRootPathVirtual = System.Configuration.ConfigurationManager.AppSettings["UploadPathBDT"] + lblURL.Text;
                string savepath           = Server.MapPath(strRootPathVirtual);
                if (File.Exists(savepath))
                {
                    File.Delete(savepath);
                    WriteLogHistory2Database.WriteHistory2Database(_user.UserID, _user.UserFullName, "[Xóa ảnh]", Convert.ToInt32(Request["Menu_ID"]).ToString(), "[Xóa ảnh] [Thao tác xóa ảnh trên server: " + lblURL.Text + "]", 0, ConstAction.BaoDT);
                }
            }
            catch {; }
            obj.Delete_Image(ImageID);
            ListImages();
        }
예제 #5
0
        private void ListImages()
        {
            ImageFilesDAL obj        = new ImageFilesDAL();
            DataSet       objDataset = new DataSet();

            //string where = " UserCreated =" + _user.UserID;
            string where = "";
            if (ddlStock.SelectedValue.Trim() != "0")
            {
                where += " 1=1 And AuthorID =1 ";
            }
            else
            {
                where += " 1=1 And (( AuthorID =0 ) OR (AuthorID is null ))";
            }
            if (!String.IsNullOrEmpty(txt_FromDate.Text.Trim()))
            {
                where += " AND " + string.Format(" (Datediff(DAY,'{0}',DateCreated)>=0) ", UltilFunc.ToDate(this.txt_FromDate.Value.ToString().Trim(), "MM/dd/yyyy"));
            }
            if (!String.IsNullOrEmpty(txt_ToDate.Text.Trim()))
            {
                where += " AND " + string.Format(" (Datediff(DAY,'{0}',DateCreated)<=0) ", UltilFunc.ToDate(this.txt_ToDate.Value.ToString().Trim(), "MM/dd/yyyy"));
            }
            else
            {
                if (ddlStock.SelectedValue.Trim() == "0")
                {
                    where += " AND " + string.Format(" DATEDIFF(DAY,DateCreated,'{0}')=0 ", DateTime.Now.ToString("MM/dd/yyyy"));
                }
            }
            where     += " ORDER BY DateCreated DESC";
            objDataset = obj.ListAllImages(where);
            if (objDataset != null)
            {
                DataView _dv = obj.BindGridListImages(objDataset.Tables[0]);
                dlImages.DataSource = _dv;
                dlImages.DataBind();
            }
        }
예제 #6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Expires     = -1;
            try
            {
                HttpPostedFile postedFile = context.Request.Files["Filedata"];
                string[]       sArrProdID = null;
                char[]         sep        = { '?' };
                string[]       sArrVkey   = null;
                string         strUserID  = string.Empty;
                char[]         sep2       = { ',' };
                sArrProdID = context.Request.QueryString["user"].ToString().Trim().Split(sep);
                sArrVkey   = sArrProdID[0].ToString().Trim().Split(sep2);
                string chuyenmuc          = sArrVkey[sArrVkey.Length - 1];
                string FolderCat          = string.Empty;
                string savepath           = string.Empty;
                string tempPath           = string.Empty;
                string strRootPathVirtual = string.Empty;
                user      = _NguoidungDAL.GetUserByUserName(sArrVkey[0].ToString());
                strUserID = user.UserID.ToString();
                string vType = sArrVkey[1].ToString();
                if (vType == "1")
                {
                    FolderCat = "/Adv/";
                }
                else if (vType == "2")
                {
                    FolderCat = "/Videos/";
                }
                else
                {
                    FolderCat = string.Empty;
                }
                tempPath           = "/" + System.Configuration.ConfigurationManager.AppSettings["UploadPathBDT"] + FolderCat;
                strRootPathVirtual = tempPath + DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Day.ToString() + "/";
                savepath           = context.Server.MapPath(strRootPathVirtual);

                string filename   = getFileNameUnique(savepath + @"\", postedFile.FileName, Path.GetFileNameWithoutExtension(postedFile.FileName), Path.GetExtension(postedFile.FileName.ToString()));
                string _extenfile = Path.GetExtension(filename.ToString());
                string strFileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(postedFile.FileName).Trim();
                if (!Directory.Exists(savepath))
                {
                    Directory.CreateDirectory(savepath);
                }
                if (_extenfile.ToLower().Contains(".mp4") ||
                    _extenfile.ToLower().Contains(".flv") ||
                    _extenfile.ToLower().Contains(".mp3") ||
                    _extenfile.ToLower().Contains(".jpg") ||
                    _extenfile.ToLower().Contains(".gif") ||
                    _extenfile.ToLower().Contains(".bmp") ||
                    _extenfile.ToLower().Contains(".png") ||
                    _extenfile.ToLower().Contains(".doc") ||
                    _extenfile.ToLower().Contains(".docx") ||
                    _extenfile.ToLower().Contains(".pdf"))
                {
                    postedFile.SaveAs(savepath + @"\" + filename);
                }

                string _urlSave = UrlPathImage_RemoveUpload(strRootPathVirtual + filename);

                //phan insert co so du lieu
                T_ImageFiles  _obj = new T_ImageFiles();
                ImageFilesDAL _DAL = new ImageFilesDAL();
                _obj = SetItem(filename, postedFile.ContentLength, _urlSave, _extenfile, Convert.ToInt16(strUserID), Convert.ToInt16(vType), 0);

                int _idReturn = _DAL.InsertT_ImageFiles(_obj);
                context.Response.StatusCode = 200;
            }
            catch (Exception ex)
            {
                context.Response.Write("Error: " + ex.Message);
            }
        }
예제 #7
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Expires     = -1;
            try
            {
                HttpPostedFile postedFile = context.Request.Files["Filedata"];

                int inStock = 0;
                try
                {
                    inStock = int.Parse(context.Request.QueryString["inStock"].ToString().Trim());
                }
                catch {; }

                string[] sArrProdID = null;
                char[]   sep        = { '?' };
                string[] sArrVkey   = null;
                string   strUserID  = string.Empty;
                char[]   sep2       = { ',' };
                sArrProdID = context.Request.QueryString["user"].ToString().Trim().Split(sep);
                sArrVkey   = sArrProdID[0].ToString().Trim().Split(sep2);
                string chuyenmuc          = sArrVkey[sArrVkey.Length - 1];
                string _urlSave           = string.Empty;
                string FolderCat          = string.Empty;
                string savepath           = string.Empty;
                string tempPath           = string.Empty;
                string strRootPathVirtual = string.Empty;
                _user     = _userDAL.GetUserByUserName(sArrVkey[0].ToString());
                strUserID = _user.UserID.ToString();
                string vType = sArrVkey[1].ToString();
                if (vType == "1")
                {
                    if (inStock != 0)
                    {
                        FolderCat = "/InStock/";
                    }
                    else
                    {
                        FolderCat = "/Article/";
                    }
                }
                else if (vType == "2")
                {
                    FolderCat = "/Ads/";
                }
                else if (vType == "3")
                {
                    FolderCat = "/Video/";
                }
                else if (vType == "4")
                {
                    FolderCat = "/Photo24/";
                }
                else
                {
                    FolderCat = string.Empty;
                }
                tempPath           = System.Configuration.ConfigurationManager.AppSettings["UploadPathBDT"] + FolderCat + sArrVkey[0].ToString() + "/";
                strRootPathVirtual = tempPath + DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Day.ToString() + "/";
                savepath           = context.Server.MapPath(strRootPathVirtual);

                string filename   = getFileNameUnique(savepath + @"\", postedFile.FileName, Path.GetFileNameWithoutExtension(postedFile.FileName), Path.GetExtension(postedFile.FileName.ToString()));
                string _extenfile = Path.GetExtension(filename.ToString());
                string strFileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(postedFile.FileName).Trim();
                if (!Directory.Exists(savepath))
                {
                    Directory.CreateDirectory(savepath);
                }
                if (_extenfile.ToLower().Contains(".jpg") ||
                    _extenfile.ToLower().Contains(".gif") ||
                    _extenfile.ToLower().Contains(".png") ||
                    _extenfile.ToLower().Contains(".bmp") ||
                    _extenfile.ToLower().Contains(".jpeg"))
                {
                    postedFile.SaveAs(savepath + @"\" + filename);
                }


                double CATID = 0;
                try { CATID = double.Parse(chuyenmuc); }
                catch {; }
                string _logo = context.Server.MapPath("../DungChung/Images/IconHPC/LoGoBaoNongNghiep.png");

                string _imagesEndWatermark = getFileNameUnique(savepath + @"\", postedFile.FileName, Path.GetFileNameWithoutExtension(filename), _extenfile);
                if (_extenfile.ToLower() != ".flv" && _extenfile.ToLower() != ".swf" && _extenfile.ToLower() != ".mp3" && _extenfile.ToLower() != ".mp4" && _extenfile.ToLower() != ".wmv" && _extenfile.ToLower() != ".doc" && _extenfile.ToLower() != ".docx" && _extenfile.ToLower() != ".xls" && _extenfile.ToLower() != ".rar" && _extenfile.ToLower() != ".txt" && _extenfile.ToLower() != ".pdf")
                {
                    if (Convert.ToBoolean(Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["WatermarkImages"])))
                    {
                        //Begin BO CT EDIT Đóng dấu ảnh
                        _imagesEndWatermark = "W_" + filename;
                        HPCImageResize.SaveImage2Server(savepath, filename, "rez_" + filename, _imagesEndWatermark, _logo, Convert.ToInt32(HPCComponents.Global.VNPResizeImages), Convert.ToInt32(HPCComponents.Global.VNPResizeImages));
                    }
                    else if (Convert.ToBoolean(Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["AutoProcessReszie"])))// Không đóng dấu ảnh //END
                    {
                        HPCImageResize.SaveImage2Server(savepath, filename, _imagesEndWatermark, Convert.ToInt32(HPCComponents.Global.VNPResizeImages), Convert.ToInt32(HPCComponents.Global.VNPResizeImages));
                    }
                }
                else
                {
                    _imagesEndWatermark = filename;
                    postedFile.SaveAs(Path.Combine(savepath, filename));
                }

                //_urlSave = UrlPathImage_RemoveUpload(strRootPathVirtual + filename);
                _urlSave = UrlPathImage_RemoveUpload(strRootPathVirtual + _imagesEndWatermark);

                //phan insert co so du lieu
                T_ImageFiles  _obj = new T_ImageFiles();
                ImageFilesDAL _DAL = new ImageFilesDAL();
                _obj = SetItem(_imagesEndWatermark, postedFile.ContentLength, _urlSave, _extenfile, Convert.ToInt16(strUserID), Convert.ToInt16(vType), CATID);

                int _idReturn = _DAL.InsertT_ImageFiles(_obj);
                if (inStock != 0)
                {
                    _DAL.UpdateStatusDataByID(" AuthorID =1 Where ID =" + _idReturn);
                }
                context.Response.Write(savepath + "/" + filename);
                context.Response.StatusCode = 200;
            }
            catch (Exception ex)
            {
                context.Response.Write("Error: " + ex.Message);
            }
        }
예제 #8
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                int    w         = Convert.ToInt32(context.Request["w"]);
                int    h         = Convert.ToInt32(context.Request["h"]);
                int    x         = Convert.ToInt32(context.Request["x"]);
                int    y         = Convert.ToInt32(context.Request["y"]);
                string _imageUrl = context.Request["img"];
                string strUserID = string.Empty;
                _user     = _userDAL.GetUserByUserName(context.Request["user"].ToString());
                strUserID = _user.UserID.ToString();
                string vType        = context.Request["vType"];
                string ImageName    = string.Empty;
                string PathUrlImage = string.Empty;
                string PathUrlDest  = string.Empty;
                string RootPath     = string.Empty; //System.Configuration.ConfigurationManager.AppSettings["UploadPath"];
                _imageUrl = _imageUrl.Replace("http://" + HttpContext.Current.Request.Url.Host, "");
                //_imageUrl = _imageUrl.Replace(System.Configuration.ConfigurationManager.AppSettings["UploadPath"], "");
                for (int i = 0; i < _imageUrl.Split('/').Length; i++)
                {
                    if (_imageUrl.Split('/')[i].ToString().Trim() != "" && i < _imageUrl.Split('/').Length - 1)
                    {
                        if (PathUrlImage == "")
                        {
                            PathUrlImage = "/" + _imageUrl.Split('/')[i].ToString();
                        }
                        else
                        {
                            PathUrlImage = PathUrlImage + "/" + _imageUrl.Split('/')[i].ToString();
                        }
                    }
                    else
                    {
                        ImageName = _imageUrl.Split('/')[i].ToString();
                    }
                }
                _imageUrl   = RootPath + _imageUrl;
                RootPath    = RootPath + PathUrlImage;
                ImageName   = w.ToString() + "x" + h.ToString() + "_" + ImageName.Trim();
                PathUrlDest = RootPath + "/" + ImageName;
                string PhysicalPathDest = context.Server.MapPath(PathUrlDest);

                PathUrlDest = "/" + PathUrlDest.Replace(System.Configuration.ConfigurationManager.AppSettings["UploadPathBDT"], "");


                _imageUrl = context.Server.MapPath(_imageUrl);

                HPCImageCrop.Crop(_imageUrl, PhysicalPathDest, w, h, x, y);


                //phan insert co so du lieu
                T_ImageFiles  _obj          = new T_ImageFiles();
                ImageFilesDAL _DAL          = new ImageFilesDAL();
                double        fileSizeTotal = new FileInfo(PhysicalPathDest).Length;
                _obj = SetItem(ImageName, fileSizeTotal, PathUrlDest, Path.GetExtension(ImageName), Convert.ToInt16(strUserID), Convert.ToInt16(vType), 0);
                _DAL.InsertT_ImageFiles(_obj);


                context.Response.Write(PathUrlDest);
                context.Response.StatusCode = 200;
            }
            catch (Exception e)
            {
                context.Response.End();
            }
        }
예제 #9
0
        private void ListImages()
        {
            try
            {
                ImageFilesDAL obj        = new ImageFilesDAL();
                DataSet       objDataset = new DataSet();

                // Populate the repeater control with the Items DataSet
                PagedDataSource objPds = new PagedDataSource();
                //string where = " UserCreated =" + _user.UserID;
                string where = "";
                if (ddlStock.SelectedValue.Trim() != "0")
                {
                    where += " 1=1 And AuthorID =1 ";
                }
                else
                {
                    where += " 1=1 And (( AuthorID =0 ) OR (AuthorID is null ))";
                }
                if (!string.IsNullOrEmpty(txtTenfile.Text))
                {
                    where += " AND ImageFileName like N'%" + txtTenfile.Text + "%'";
                }
                if (Drop_Chuyenmuc.SelectedValue.Trim() != "0")
                {
                    where += string.Format(" AND Categorys_ID IN (SELECT * FROM [fn_Return_Category_Tree] ({0}))", this.Drop_Chuyenmuc.SelectedValue);
                }
                if (!String.IsNullOrEmpty(txt_FromDate.Text.Trim()))
                {
                    where += " AND " + string.Format(" (Datediff(DAY,'{0}',DateCreated)>=0)", UltilFunc.ToDate(this.txt_FromDate.Value.ToString().Trim(), "MM/dd/yyyy"));
                }
                if (!String.IsNullOrEmpty(txt_ToDate.Text.Trim()))
                {
                    where += " AND " + string.Format(" (Datediff(DAY,'{0}',DateCreated)<=0) ", UltilFunc.ToDate(this.txt_ToDate.Value.ToString().Trim(), "MM/dd/yyyy"));
                }
                else
                {
                    if (ddlStock.SelectedValue.Trim() == "0")
                    {
                        where += " AND " + string.Format(" DATEDIFF(DAY,DateCreated,'{0}')=0 ", DateTime.Now.ToString("MM/dd/yyyy"));
                    }
                }
                where     += " ORDER BY DateCreated DESC";
                objDataset = obj.ListAllImages(where);
                if (objDataset != null && objDataset.Tables[0].Rows.Count > 0)
                {
                    DataTable _dv = obj.BindGridListImages2Table(objDataset.Tables[0]);
                    objPds.DataSource  = _dv.DefaultView;
                    objPds.AllowPaging = true;
                    if (ddlStock.SelectedValue.Trim() != "0")
                    {
                        objPds.PageSize = 30;
                    }
                    else
                    {
                        objPds.PageSize = 12;
                    }

                    objPds.CurrentPageIndex = CurrentPage;

                    lblCurrentPage.Text = "Page: " + (CurrentPage + 1).ToString() + " / " + objPds.PageCount.ToString();

                    // Disable Prev or Next buttons if necessary
                    cmdNext.Visible = true;
                    cmdPrev.Visible = true;
                    cmdPrev.Enabled = !objPds.IsFirstPage;
                    cmdNext.Enabled = !objPds.IsLastPage;

                    //dlImages.DataSource = _dv;
                    dlImages.DataSource = objPds;
                    dlImages.DataBind();
                }
                else
                {
                    lblCurrentPage.Text = "";
                    cmdNext.Visible     = false;
                    cmdPrev.Visible     = false;
                    dlImages.DataSource = null;
                    dlImages.DataBind();
                }
                objDataset.Dispose();
            }
            catch
            {
                dlImages.DataSource = null;
                dlImages.DataBind();
            }
        }
예제 #10
0
        protected void cmd_watermark_Click(object sender, EventArgs e)
        {
            string url1 = txt_UrlImage.Text.Trim();

            if (!string.IsNullOrEmpty(url1))
            {
                string url = ConfigurationManager.AppSettings["ServerPathDis"].ToString() + url1;
                if (File.Exists(url))
                {
                    int    _instock     = Convert.ToInt32(ddlStock.SelectedValue.Trim());
                    string strPhysLocal = "";
                    if (strNumberArg == "1")
                    {
                        if (_instock != 0)
                        {
                            strPhysLocal = "/" + "InStock/Thumnail/";
                        }
                        else
                        {
                            strPhysLocal = "/" + "Article/Thumnail/";
                        }
                    }
                    if (strNumberArg == "2")
                    {
                        strPhysLocal = "/" + Global.UploadPhotoAlbum + "/";
                    }
                    if (strNumberArg == "3")
                    {
                        strPhysLocal = "/" + Global.UploadPhotoEvent + "/";
                    }

                    //string width = DropSize.SelectedValue;
                    System.Drawing.Bitmap sourceImage = new System.Drawing.Bitmap(url);
                    string _extension = Path.GetExtension(url);

                    string filename    = "WaterMark_" + DateTime.Now.ToString("ddMMyyyyHHmmss") + DateTime.Now.Millisecond.ToString() + Path.GetExtension(url);
                    Bitmap imgsave     = null;
                    string newfolder   = strPhysLocal + DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Day.ToString() + "/";
                    string pathsave    = ConfigurationManager.AppSettings["ServerPathDis"].ToString() + newfolder;
                    string _logo       = Server.MapPath("../Images/IconHPC/LoGoBaoAnhDong.png");
                    Bitmap Imagemark   = new Bitmap(_logo);
                    int    spacevalues = 0;
                    try { spacevalues = int.Parse(ConfigurationManager.AppSettings["SpaceValue"].ToString()); }
                    catch {; }

                    //imgsave = HPCImages.WatermarkImages(sourceImage, Imagemark, int.Parse(DropStyle.SelectedValue), spacevalues);
                    imgsave = HPCImages.WatermarkImages(sourceImage, Imagemark, int.Parse(X11.Value), int.Parse(Y11.Value));

                    if (Directory.Exists(pathsave) == false)
                    {
                        Directory.CreateDirectory(pathsave);
                    }

                    imgsave.Save(pathsave + @"\" + filename);
                    imgsave.Dispose();
                    Imagemark.Dispose();
                    sourceImage.Dispose();

                    txt_UrlImage.Text = newfolder + "/" + filename;

                    T_ImageFiles  _obj = new T_ImageFiles();
                    ImageFilesDAL _DAL = new ImageFilesDAL();
                    _obj = SetItem(filename, 0, txt_UrlImage.Text, _extension, _user.UserID, Convert.ToInt16(strNumberArg), Convert.ToInt32(Drop_Chuyenmuc.SelectedValue));

                    int _idReturn = _DAL.InsertT_ImageFiles(_obj);
                    if (_instock != 0)
                    {
                        _DAL.UpdateStatusDataByID(" AuthorID =1 Where ID =" + _idReturn);
                    }
                    ListImages();
                    System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "Message", "PreviewImage('" + newfolder + "/" + filename + "','" + strNumberArg + "','0','" + _extension + "');", true);
                }
            }
            else
            {
                System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "Message", "alert('Hãy chọn ảnh để đóng dấu ');", true);
            }
        }
예제 #11
0
        private T_News SetItemBaoDienTu(double _id_newspaper)
        {
            T_ImageFiles _obj = new T_ImageFiles();
            ImageFilesDAL _dalimgfile = new ImageFilesDAL();
            DataTable _dt_img = new DataTable();
            T_News obj_news = new T_News();
            T_TinBai _objbaoin = new T_TinBai();
            _objbaoin = _daltinbai.load_T_news(_id_newspaper);
            double _id_newsonline = UltilFunc.GetColumnValuesOne("T_News", "News_ID", "News_CopyFrom=" + _id_newspaper);
            if (_id_newsonline == 0)
                obj_news.News_ID = 0;
            else
                obj_news.News_ID = _id_newsonline;
            obj_news.News_Tittle = _objbaoin.Tieude;
            obj_news.News_Summary = _objbaoin.Tomtat;
            obj_news.CAT_ID = _objbaoin.Ma_Chuyenmuc;
            obj_news.Lang_ID = _objbaoin.Ma_NgonNgu;

            string _sqlimg = string.Empty;
            _sqlimg = "select TenFile_Hethong,Duongdan_Anh,Chuthich from t_anh where ma_anh in (select Ma_Anh from T_Tinbai_Anh where Ma_TinBai=" + _id_newspaper + ")";
            _dt_img = ulti.ExecSqlDataSet(_sqlimg).Tables[0];
            string DesPath = string.Empty;
            string PathSource = string.Empty;
            string UrlImg = string.Empty;
            if (_dt_img != null && _dt_img.Rows.Count > 0)
            {
                for (int i = 0; i < _dt_img.Rows.Count; i++)
                {
                    if (_dt_img.Rows.Count > 1)
                    {
                        DesPath = System.Configuration.ConfigurationManager.AppSettings["UrlImageResize"].ToString() + DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Day.ToString() + "/";
                        DesPath = HttpContext.Current.Server.MapPath("/" + DesPath);
                        if (Directory.Exists(DesPath) == false)
                            Directory.CreateDirectory(DesPath);
                        PathSource = HttpContext.Current.Server.MapPath("/" + System.Configuration.ConfigurationManager.AppSettings["viewimg"].ToString() + _dt_img.Rows[i]["Duongdan_Anh"].ToString());
                        DesPath += Path.GetFileName(PathSource);
                        UrlImg = System.Configuration.ConfigurationManager.AppSettings["UrlImageResize"].ToString() + DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Day.ToString() + "/" + Path.GetFileName(PathSource);
                        ResizeImages(PathSource, Convert.ToInt32(HPCComponents.Global.VNPResizeImagesContent), DesPath);
                        if (i == 0)
                        {
                            string _strremove = "/" + UrlImg.Split('/').GetValue(1).ToString();
                            string _Images_Summary = UrlImg.Replace(_strremove, "");
                            obj_news.Images_Summary = _Images_Summary;
                            obj_news.News_Body = _objbaoin.Noidung;
                        }
                        //insert table T_ImageFiles
                        int _idImgFile = 0;

                        int startchar = UrlImg.Substring(1, UrlImg.Length - 1).IndexOf("/");
                        startchar += 1;
                        string _PathFile = UrlImg.Substring(startchar, UrlImg.Length - startchar);

                        _obj = SetItemImgFile(_dt_img.Rows[i]["TenFile_Hethong"].ToString(), 0, _PathFile, "", _user.UserID, 1, 0);
                        _idImgFile = _dalimgfile.InsertT_ImageFiles(_obj);

                        //end
                        obj_news.News_Body += "<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" style=\"width: 450px;\"><tbody><tr><td><img border=\"0\" hspace=\"3\" id=\"" + _idImgFile + "\" src=\"" + UrlImg + "\" style=\"cursor-pointer\" vspace=\"3\" /></td></tr>";
                        obj_news.News_Body += "<tr><td>" + _dt_img.Rows[i]["Chuthich"].ToString() + "</tr></td></tbody></table>";
                    }
                    else
                    {
                        DesPath = System.Configuration.ConfigurationManager.AppSettings["UrlImageResize"].ToString() + DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Day.ToString() + "/";
                        DesPath = HttpContext.Current.Server.MapPath("/" + DesPath);
                        if (Directory.Exists(DesPath) == false)
                            Directory.CreateDirectory(DesPath);
                        PathSource = HttpContext.Current.Server.MapPath("/" + System.Configuration.ConfigurationManager.AppSettings["viewimg"].ToString() + _dt_img.Rows[i]["Duongdan_Anh"].ToString());
                        DesPath += Path.GetFileName(PathSource);
                        UrlImg = System.Configuration.ConfigurationManager.AppSettings["UrlImageResize"].ToString() + DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Day.ToString() + "/" + Path.GetFileName(PathSource);
                        ResizeImages(PathSource, Convert.ToInt32(HPCComponents.Global.VNPResizeImagesContent), DesPath);
                        int _idImgFile = 0;
                        //insert table T_ImageFiles
                        int startchar = UrlImg.Substring(1, UrlImg.Length - 1).IndexOf("/");
                        startchar += 1;
                        string _PathFile = UrlImg.Substring(startchar, UrlImg.Length - startchar);

                        _obj = SetItemImgFile(_dt_img.Rows[i]["TenFile_Hethong"].ToString(), 0, _PathFile, "", _user.UserID, 1, 0);
                        _idImgFile = _dalimgfile.InsertT_ImageFiles(_obj);

                        //end
                        string _strremove = "/" + UrlImg.Split('/').GetValue(1).ToString();
                        string _Images_Summary = UrlImg.Replace(_strremove, "");
                        obj_news.Images_Summary = _Images_Summary;
                        obj_news.News_Body = "<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" style=\"width: 450px;\"><tbody><tr><td><img border=\"0\" hspace=\"3\" id=\"" + _idImgFile + "\" src=\"" + UrlImg + "\" style=\"cursor-pointer\" vspace=\"3\" /></td></tr>";
                        obj_news.News_Body += "<tr><td>" + _dt_img.Rows[i]["Chuthich"].ToString() + "</tr></td></tbody></table>";
                        obj_news.News_Body += _objbaoin.Noidung;
                    }
                }
            }
            else
                obj_news.News_Body = _objbaoin.Noidung;
            obj_news.News_PublishNumber = int.Parse(DateTime.Now.Month.ToString());
            obj_news.News_PublishYear = int.Parse(DateTime.Now.Year.ToString());
            obj_news.News_DateCreated = DateTime.Now;
            obj_news.News_DateEdit = DateTime.Now;
            obj_news.News_DatePublished = DateTime.Now;
            obj_news.News_DateApproved = DateTime.Now;
            obj_news.News_AuthorID = int.Parse(_objbaoin.Ma_Nguoitao.ToString());
            obj_news.News_AprovedID = _user.UserID;
            obj_news.News_EditorID = _user.UserID;
            obj_news.News_PublishedID = _user.UserID;
            obj_news.News_CopyFrom = 0;
            obj_news.RefID = int.Parse(_id_newspaper.ToString());
            obj_news.News_Status = int.Parse(CommonLib.ReadXML("Status_BDT"));

            return obj_news;
        }
예제 #12
0
 public void ProcessRequest(HttpContext context)
 {
     context.Response.ContentType = "text/plain";
     context.Response.Expires     = -1;
     try
     {
         HttpPostedFile postedFile = context.Request.Files["Filedata"];
         string[]       sArrProdID = null;
         char[]         sep        = { '?' };
         string[]       sArrVkey   = null;
         string         strUserID  = "";
         char[]         sep2       = { ',' };
         sArrProdID = context.Request.QueryString["user"].ToString().Trim().Split(sep);
         sArrVkey   = sArrProdID[0].ToString().Trim().Split(sep2);
         string _urlSave           = "";
         string FolderCat          = "";
         string savepath           = "";
         string tempPath           = "";
         string strRootPathVirtual = "";
         _user     = _userDAL.GetUserByUserName(sArrVkey[0].ToString());
         strUserID = _user.UserID.ToString();
         string vType   = sArrVkey[1].ToString();
         string AlbumID = sArrVkey[2].ToString();
         if (vType == "1")
         {
             FolderCat = "/Article/";
         }
         else if (vType == "2")
         {
             FolderCat = "/Ads/";
         }
         else if (vType == "3")
         {
             FolderCat = "/Video/";
         }
         else if (vType == "4")
         {
             FolderCat = "/Photo24/";
         }
         else
         {
             FolderCat = "";
         }
         tempPath           = System.Configuration.ConfigurationManager.AppSettings["UploadPathBDT"] + FolderCat + sArrVkey[0].ToString() + "/";
         strRootPathVirtual = tempPath + DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Day.ToString() + "/";
         savepath           = context.Server.MapPath(strRootPathVirtual);
         string filename   = DateTime.Now.Millisecond.ToString() + "_" + postedFile.FileName;
         string _extenfile = Path.GetExtension(filename.ToString().Trim()).Replace(".", "");
         if (!Directory.Exists(savepath))
         {
             Directory.CreateDirectory(savepath);
         }
         postedFile.SaveAs(savepath + @"\" + filename);
         string _logo = context.Server.MapPath("../Dungchung/Images/IconHPC/LoGoDongDau.png");
         string _imagesEndWatermark = DateTime.Now.ToString("yyyyMMdd").ToString() + DateTime.Now.ToString("HHmmss") + DateTime.Now.Millisecond + UltilFunc.ReplaceCharsRewrite(filename.Replace(Path.GetExtension(filename.ToString().Trim()), "")) + "." + _extenfile;
         _urlSave = UrlPathImage_RemoveUpload(strRootPathVirtual + _imagesEndWatermark);
         // Begin BO CT EDIT Đóng dấu ảnh
         if (Convert.ToBoolean(Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["WatermarkImages"])))
         {
             HPCImageResize.SaveImage2Server(savepath, filename, "rez_" + filename, _imagesEndWatermark, _logo, Convert.ToInt32(HPCComponents.Global.VNPResizeImages), Convert.ToInt32(HPCComponents.Global.VNPResizeImages));
         }
         else// Không đóng dấu ảnh //END
         {
             HPCImageResize.SaveImage2Server(savepath, filename, _imagesEndWatermark, Convert.ToInt32(HPCComponents.Global.VNPResizeImages), Convert.ToInt32(HPCComponents.Global.VNPResizeImages));
         }
         // INSERT DATABASE
         //phan insert co so du lieu
         T_ImageFiles  _objImage = new T_ImageFiles();
         ImageFilesDAL _DAL      = new ImageFilesDAL();
         _objImage = SetItemImageFiles(filename, postedFile.ContentLength, _urlSave, _extenfile, Convert.ToInt16(strUserID), Convert.ToInt16(vType), 0);
         int _idReturn = _DAL.InsertT_ImageFiles(_objImage);
         //phan insert Anh phong su
         T_Photo_EventDAL _cateDAL = new T_Photo_EventDAL();
         T_Photo_Event    _obj     = new T_Photo_Event();
         _obj = setItem(_urlSave, postedFile.FileName);
         int _return = _cateDAL.InsertT_Photo_Events(_obj);
         context.Response.Write(savepath + "/" + filename);
         context.Response.StatusCode = 200;
     }
     catch (Exception ex)
     {
         context.Response.Write("Error: " + ex.Message);
     }
 }