platform/upload/.svn/text-base/fileUpload.aspx.cs.svn-base

102 lines
3.4 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.IO;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ZhangPu.Gov.Logical;
public partial class upload_fileUpload : PagePublic
{
private string fileType ="";
private string fileCode = "";
private string fileInfo = "";
private string empid="";
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
getParameters();
try
{
if (fileUpload1.FileName.Length == 0) return;
lbuploadmessage.Text = "";
string fileName = fileUpload1.FileName;
System.Random rand = new Random();
int len = rand.Next();
fileName = empid + "T" + fileType + len +
fileName.Substring(fileName.LastIndexOf("."));
DirectoryInfo dir = new DirectoryInfo(Server.MapPath("~/upload/"+fileType ));
if (!dir.Exists)
dir.Create();
string fileSavePath = Server.MapPath("~/upload/" + fileType+"/" + fileName);
fileUpload1.SaveAs(fileSavePath);
lbuploadmessage.Text = "上传成功!";
LFile _logic = new LFile();
_logic.Initialize();
_logic.GetFilesmgrExt.File_type = Convert.ToInt32(fileType);
_logic.GetFilesmgrExt.file_dest = fileName;
_logic.GetFilesmgrExt.File_Desc = txtFileDesc.Text;
_logic.GetFilesmgrExt.File_Emp = Convert.ToInt32(empid);  
if (fileType.Equals(((int)Tracen.Utils.FileType.Project).ToString()))
_logic.GetFilesmgrExt.File_Project = Convert.ToInt32(fileInfo);
if (fileType.Equals(((int)Tracen.Utils.FileType.ProjectDetail).ToString()))
_logic.GetFilesmgrExt.File_ProjectDetail = Convert.ToInt32(fileInfo);
_logic.GetFilesmgrExt.Add();
closewindow();
}
catch (Exception er)
{
lbuploadmessage.Text = "上传失败!";
}
}
void closewindow()
{
StringBuilder strResponse = new StringBuilder();
strResponse.Append("<script language=JavaScript>");
// strResponse.Append("alert('aaa');");
strResponse.Append("this.close();");
strResponse.Append(" </");
strResponse.Append("script>");
Response.Write(strResponse);
}
void getParameters()
{
// if (Session["uploadCode"] != null && Session["fileType"] != null && Session["fileInfo"] != null)
// if (Session["uploadCode"] != null && Session["fileType"] != null && Session["fileInfo"] != null)
// {
// string preCode = Session["uploadCode"].ToString();
fileCode = Request.QueryString["fileCode"];
fileType = Request.QueryString["fileType"];
fileInfo = Request.QueryString["fileInfo"];
empid = Request.QueryString["id"];
// fileType = Session["fileType"].ToString();
// fileInfo = Session["fileInfo"].ToString();
// if (!fileCode.Equals(preCode))
// {
// closewindow();
// }
// }
// else
// {
// closewindow();
// }
}
}