Ejemplo n.º 1
0
        public void dgrListImages_EditCommand(object source, DataListCommandEventArgs e)
        {
            int _ID = Convert.ToInt32(dgrListImages.DataKeys[e.Item.ItemIndex].ToString());

            UploadFileMulti.FtpClient _Ftp = new ToasoanTTXVN.UploadFileMulti.FtpClient(ftpServer, ftpuser, password, "");
            if (e.CommandArgument.ToString().ToLower() == "delete")
            {
                Label lbFileAttach = e.Item.FindControl("lbFileAttach") as Label;
                try
                {
                    if (_Ftp.IsExistFolder(lbFileAttach.Text.Trim()))
                    {
                        _Ftp.DeleteFile(lbFileAttach.Text.Trim());
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                dal.Sp_DeleteOneFromT_FileQuangCao(_ID);
                string thaotac = "Thao tác xóa ảnh đính kèm: " + lbFileAttach.Text + " tại TT QC: " + txt_tenquangcao.Text.Trim();
                UltilFunc.Log_Action(_user.UserID, _user.UserName, DateTime.Now, int.Parse(Request["Menu_ID"].ToString()), thaotac);
                LoadDataImage();
            }
        }
Ejemplo n.º 2
0
        protected void btnXoaAnh_Click(object sender, EventArgs e)
        {
            UploadFileMulti.FtpClient _Ftp = new ToasoanTTXVN.UploadFileMulti.FtpClient(ftpServer, ftpuser, password, "");
            string SqlUpdate = string.Empty;

            foreach (DataListItem m_Item in dgrListImages.Items)
            {
                int _ID = int.Parse(this.dgrListImages.DataKeys[m_Item.ItemIndex].ToString());

                CheckBox chk_Select   = (CheckBox)m_Item.FindControl("optSelect");
                Label    lbFileAttach = m_Item.FindControl("lbFileAttach") as Label;
                if (chk_Select != null && chk_Select.Checked)
                {
                    dal.Sp_DeleteOneFromT_FileQuangCao(_ID);
                    string thaotac = "Thao tác xóa ảnh đính kèm: " + lbFileAttach.Text + " tại TT QC: " + txt_tenquangcao.Text.Trim();
                    UltilFunc.Log_Action(_user.UserID, _user.UserName, DateTime.Now, int.Parse(Request["Menu_ID"].ToString()), thaotac);
                    try
                    {
                        _Ftp.DeleteFile(lbFileAttach.Text.Trim());
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
            LoadDataImage();
        }
Ejemplo n.º 3
0
        protected void btn_downloadimg_click(object sender, EventArgs e)
        {
            UploadFileMulti.FtpClient _Ftp = new ToasoanTTXVN.UploadFileMulti.FtpClient(ftpServer, ftpuser, password, "");

            LoadDataImageTinBai();
            if (DataListAnh.Items.Count != 0)
            {
                List <string> fileSave = new List <string>();
                foreach (DataListItem m_Item in DataListAnh.Items)
                {
                    Label  lbFileAttach = m_Item.FindControl("lbFileAttach") as Label;
                    string _pathfile    = Server.MapPath("/" + System.Configuration.ConfigurationManager.AppSettings["viewimg"].ToString() + lbFileAttach.Text);
                    byte[] file         = _Ftp.DownloadFile(lbFileAttach.Text);
                    File.WriteAllBytes(_pathfile, file);
                    fileSave.Add(_pathfile);
                }
                /******************* ZIP FILE ******************************/


                string _zipFile = "VietNamNews-QC.zip";
                Response.Clear();
                Response.ContentType = "application/zip";
                Response.AddHeader("content-disposition", "filename=" + _zipFile);
                using (ZipFile _zip = new ZipFile())
                {
                    foreach (string filePath in fileSave)
                    {
                        if (File.Exists(filePath))
                        {
                            _zip.AddFile(filePath, "VietNamNews-Quangcao");
                        }
                    }
                    _zip.Save(Response.OutputStream);
                }
                Response.End();

                /*************************************************/
            }
        }
Ejemplo n.º 4
0
        public void DataListAnh_EditCommand(object source, DataListCommandEventArgs e)
        {
            UploadFileMulti.FtpClient _Ftp = new ToasoanTTXVN.UploadFileMulti.FtpClient(ftpServer, ftpuser, password, "");
            if (e.CommandArgument.ToString().ToLower() == "download")
            {
                Label lbFileAttach = (Label)e.Item.FindControl("lbFileAttach");

                if (_Ftp.IsExistFolder(lbFileAttach.Text))
                {
                    byte[] file = _Ftp.DownloadFile(lbFileAttach.Text);
                    Response.Clear();
                    Response.ContentType = "application/octet-stream";
                    Response.AddHeader("Content-Disposition", "attachment;filename=" + Path.GetFileName(lbFileAttach.Text));
                    Response.Write(file);
                    Response.Flush();
                    Response.End();
                }
                else
                {
                    FuncAlert.AlertJS(this, "File không có trong Server");
                    return;
                }
            }
        }