Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (null != Request.Params["id"])
        {
            int fileId = Convert.ToInt32(Request.Params["id"]);
            SFileBB fileBB = new SFileBB();
            SFileData fileData = new SFileData();
            try
            {
                fileData = fileBB.GetModel(fileId);
                if (fileData == null)
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "close", "alert('文件不存在,可能已被删除!');window.close();", true);
                    return;
                }
                string pathName = fileData.absolutPath + fileData.sysFileNm;

                FileInfo file = new FileInfo(pathName);
                if (file.Exists)
                {
                    this.OutPutFile(pathName, fileData.preFileNm);
                    this.ClientScript.RegisterStartupScript(this.GetType(), "close", "window.close();", true);
                }
                else
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "close", "alert('文件不存在,可能已被删除!');window.close();", true);
                }
            }
            catch (Exception ex)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",1);", true);
                return;
            }
            finally
            {
                fileBB.Dispose();
            }
        }
    }
Ejemplo n.º 2
0
 /// <summary>
 /// ����һ������
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(SFileData model)
 {
     return this.fileDB.ModifyRecord(model);
 }
Ejemplo n.º 3
0
        ///// <summary>
        ///// ��ȡ����ļ�����
        ///// </summary>
        ///// <param name="��·��">applicationPath</param>
        ///// <param name="batchEmpId">�ļ�Id</param>
        ///// <returns>�ļ����ƣ��ԡ��������</returns>
        //public string GetDownBatchFileNm(string applicationPath, string batchFileId)
        //{
        //    string batchFileNm = "";
        //    string strWhere = "fileId in(" + batchFileId + ")";
        //    if (batchFileId == "" || batchFileId == null)
        //    {
        //        return "";
        //    }
        //    //�����·�������û������Ŀ¼����Ϊ��ֵ
        //    if (applicationPath == "/")
        //    {
        //        applicationPath = "";
        //    }
        //    DataSet ds = new DataSet();
        //    ds = this.GetList(strWhere);
        //    if (ds.Tables[0].Rows.Count > 0)
        //    {
        //        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        //        {
        //            DataRow row = ds.Tables[0].Rows[i];
        //            int fid = Convert.ToInt32(row["fileId"]);
        //            string virtualPath = ConfigHelper.GetConfigString("VirtualPath");
        //            string href = string.Empty;
        //            if (string.Empty != virtualPath.Trim())
        //            {
        //                href = applicationPath + "/" + virtualPath + "/Common/OutPutFile.aspx?id=" + fid.ToString();
        //            }
        //            else
        //            {
        //                href = applicationPath + "/Common/OutPutFile.aspx?id=" + fid.ToString();
        //            }
        //            //href = System.Web.HttpUtility.UrlEncode(href);
        //            if (batchFileNm == "")
        //            {
        //                batchFileNm = "<a href=\"javascript:OpenWindow('" + href + "',300,200)\" style=\"color:Blue\">" + row["preFileNm"].ToString() + "</a>";
        //            }
        //            else
        //            {
        //                batchFileNm += " | " + "<a href=\"javascript:OpenWindow('" + href + "',300,200)\" style=\"color:Blue\">" + row["preFileNm"].ToString() + "</a>";
        //            }
        //        }
        //    }
        //    return batchFileNm;
        //}
        public string GetFileFullUrl(int fileId)
        {
            SFileData fileData = new SFileData();
            fileData = this.GetModel(fileId);
            string fullPath = "";
            fullPath += fileData.urlPath + "/" + fileData.sysFileNm;

            return fullPath;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// ����һ������
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(SFileData model)
 {
     return this.fileDB.AddRecord(model);
 }
Ejemplo n.º 5
0
    protected void btnUp_Click(object sender, EventArgs e)
    {
        this.lblMsg.Text = "";
        this.isUpSucess = false;
        if (this.SingleLimit == "1" && this.selectedFiles.Items.Count > 0)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"本次文件上传只允许选择单个文件!\");", true);
            return;
        }

        int userId = this.currentUser.empId;
        int fileID = 0;
        string preFileNm = "";
        SFileData model = new SFileData();
        SSpaceBC spaceBC = new SSpaceBC();

        try
        {
            //判断文件格式(0无限制、1图片)
            switch (this.FileType)
            {
                case "0":
                    break;
                case "1":
                    FileInfo file = new FileInfo(this.File1.PostedFile.FileName);
                    string extension = file.Extension;
                    //查看文件格式是否存在与系统表“图片文件格式”中
                    SCommBB commBB = new SCommBB();
                    try
                    {
                        if (commBB.Query("select 1 from SImageFileType where fileExtension='" + extension + "'").Tables[0].Rows.Count == 0)
                        {
                            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"本次附件上传要求为图片格式文件,请重新选择!\");", true);
                            return;
                        }
                    }
                    finally
                    {
                        commBB.Dispose();
                    }
                    break;
                default:
                    break;
            }

            fileID = spaceBC.UploadFile(model, this.File1.PostedFile, userId, this.FileType == "1");

            if (fileID != 0)
            {
                preFileNm = model.preFileNm;
            }

            ListItem item = new ListItem();
            item.Text = preFileNm;
            item.Value = fileID.ToString();
            this.selectedFiles.Items.Add(item);

            this.isUpSucess = true;
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",1);", true);
            return;
        }
        finally
        {
            spaceBC.Dispose();
        }
    }
Ejemplo n.º 6
0
    private SFileData UpImg(HttpPostedFile postedFile)
    {
        //判断上传控件是否为空
        if (postedFile.FileName == "")
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请首先选择一个图片文件!\");", true);
            return null;
        }
        SFileData model = new SFileData();
        SSpaceBC spaceBC = new SSpaceBC();
        try
        {
            //判断文件格式(0无限制、1图片)
            FileInfo file = new FileInfo(postedFile.FileName);
            string extension = file.Extension;
            SCommBB commBB = new SCommBB();
            try
            {
                //查看文件格式是否存在与系统表“图片文件格式”中
                if (commBB.Query("select 1 from SImageFileType where fileExtension='" + extension + "'").Tables[0].Rows.Count == 0)
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"本次附件上传要求为图片格式文件,请重新选择!\");", true);
                    return null;
                }
            }
            finally
            {
                commBB.Dispose();
            }

            int fileId = spaceBC.UploadFile(model, postedFile, "upFile", this.currentUser.empId, false);
            model.fileId = fileId;

            return model;
        }
        finally
        {
            spaceBC.Dispose();
        }
    }
Ejemplo n.º 7
0
        /// <summary>
        /// ����һ������
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(SFileData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into SFile(");
            strSql.Append("typeNo,sysFileNm,preFileNm,fileSize,urlPath,absolutPath,isImage,imageWidth,imageHeight,usingNum,useEmpId,isPerson,mark,isrtEmpId,isrtDt,updtEmpId,updtDt)");
            strSql.Append(" values (");
            strSql.Append("@typeNo,@sysFileNm,@preFileNm,@fileSize,@urlPath,@absolutPath,@isImage,@imageWidth,@imageHeight,@usingNum,@useEmpId,@isPerson,@mark,@isrtEmpId,@isrtDt,@updtEmpId,@updtDt)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@typeNo", SqlDbType.NVarChar,20),
                    new SqlParameter("@sysFileNm", SqlDbType.NVarChar,50),
                    new SqlParameter("@preFileNm", SqlDbType.NVarChar,50),
                    new SqlParameter("@fileSize", SqlDbType.Int),
                    new SqlParameter("@urlPath", SqlDbType.NVarChar,200),
                    new SqlParameter("@absolutPath", SqlDbType.NVarChar,200),
                    new SqlParameter("@isImage", SqlDbType.Bit),
                    new SqlParameter("@imageWidth", SqlDbType.Int),
                    new SqlParameter("@imageHeight", SqlDbType.Int),
                    new SqlParameter("@usingNum", SqlDbType.Int),
                    new SqlParameter("@useEmpId", SqlDbType.Int),
                    new SqlParameter("@isPerson", SqlDbType.Bit),
                    new SqlParameter("@mark", SqlDbType.NVarChar,500),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@updtEmpId", SqlDbType.Int),
                    new SqlParameter("@updtDt", SqlDbType.DateTime)
                };
            parameters[0].Value = model.typeNo;
            parameters[1].Value = model.sysFileNm;
            parameters[2].Value = model.preFileNm;
            parameters[3].Value = model.fileSize;
            parameters[4].Value = model.urlPath;
            parameters[5].Value = model.absolutPath;
            parameters[6].Value = model.isImage;
            parameters[7].Value = model.imageWidth;
            parameters[8].Value = model.imageHeight;
            parameters[9].Value = model.usingNum;
            parameters[10].Value = model.useEmpId;
            parameters[11].Value = model.isPerson;
            parameters[12].Value = model.mark;
            parameters[13].Value = model.isrtEmpId;
            parameters[14].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[15].Value = model.updtEmpId;
            parameters[16].Value = model.updtDt == string.Empty ? null : model.updtDt;

            int id = 0;
            try
            {
                object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

                if (ret != null && ret != DBNull.Value)
                {
                    id = Convert.ToInt32(ret);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return id;
        }
Ejemplo n.º 8
0
    /// <summary>
    /// 上传文件
    /// </summary>
    /// <returns>上传后的文件名称</returns>
    public string SaveFile(HttpPostedFile file)
    {
        if (file.FileName == "")
            return "";

        SFileData model = new SFileData();
        SSpaceBC spaceBC = new SSpaceBC();

        try
        {
            spaceBC.UploadFile(model, file, "upFile", this.currentUser.empId, false);
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
        }
        finally
        {
            spaceBC.Dispose();
        }

        if (model != null)
        {
            return model.absolutPath + model.preFileNm;
        }
        else
        {
            return "";
        }
    }
Ejemplo n.º 9
0
        /// <summary>
        /// ����һ������
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(SFileData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update SFile set ");
            strSql.Append("typeNo=@typeNo,");
            strSql.Append("sysFileNm=@sysFileNm,");
            strSql.Append("preFileNm=@preFileNm,");
            strSql.Append("fileSize=@fileSize,");
            strSql.Append("urlPath=@urlPath,");
            strSql.Append("absolutPath=@absolutPath,");
            strSql.Append("isImage=@isImage,");
            strSql.Append("imageWidth=@imageWidth,");
            strSql.Append("imageHeight=@imageHeight,");
            strSql.Append("usingNum=@usingNum,");
            strSql.Append("useEmpId=@useEmpId,");
            strSql.Append("isPerson=@isPerson,");
            strSql.Append("mark=@mark,");
            strSql.Append("isrtEmpId=@isrtEmpId,");
            strSql.Append("isrtDt=@isrtDt,");
            strSql.Append("updtEmpId=@updtEmpId,");
            strSql.Append("updtDt=@updtDt");
            strSql.Append(" where fileId = @fileId ");
            SqlParameter[] parameters = {
                    new SqlParameter("@fileId", SqlDbType.Int),
                    new SqlParameter("@typeNo", SqlDbType.NVarChar,20),
                    new SqlParameter("@sysFileNm", SqlDbType.NVarChar,50),
                    new SqlParameter("@preFileNm", SqlDbType.NVarChar,50),
                    new SqlParameter("@fileSize", SqlDbType.Int),
                    new SqlParameter("@urlPath", SqlDbType.NVarChar,200),
                    new SqlParameter("@absolutPath", SqlDbType.NVarChar,200),
                    new SqlParameter("@isImage", SqlDbType.Bit),
                    new SqlParameter("@imageWidth", SqlDbType.Int),
                    new SqlParameter("@imageHeight", SqlDbType.Int),
                    new SqlParameter("@usingNum", SqlDbType.Int),
                    new SqlParameter("@useEmpId", SqlDbType.Int),
                    new SqlParameter("@isPerson", SqlDbType.Bit),
                    new SqlParameter("@mark", SqlDbType.NVarChar,500),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@updtEmpId", SqlDbType.Int),
                    new SqlParameter("@updtDt", SqlDbType.DateTime)
                };
            parameters[0].Value = model.fileId;
            parameters[1].Value = model.typeNo;
            parameters[2].Value = model.sysFileNm;
            parameters[3].Value = model.preFileNm;
            parameters[4].Value = model.fileSize;
            parameters[5].Value = model.urlPath;
            parameters[6].Value = model.absolutPath;
            parameters[7].Value = model.isImage;
            parameters[8].Value = model.imageWidth;
            parameters[9].Value = model.imageHeight;
            parameters[10].Value = model.usingNum;
            parameters[11].Value = model.useEmpId;
            parameters[12].Value = model.isPerson;
            parameters[13].Value = model.mark;
            parameters[14].Value = model.isrtEmpId;
            parameters[15].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[16].Value = model.updtEmpId;
            parameters[17].Value = model.updtDt == string.Empty ? null : model.updtDt;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// �õ�һ��model
        /// </summary>
        /// <param name="fileId">����ֵ</param>
        /// <returns>model</returns>
        public SFileData GetModel(int fileId)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * from SFile");
            strSql.Append(" where fileId = @fileId ");
            SqlParameter[] parameters = {
                    new SqlParameter("@fileId", SqlDbType.Int)
                };
            parameters[0].Value = fileId;

            SFileData model = new SFileData();
            DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                if (row["fileId"] != DBNull.Value)
                {
                    model.fileId = Convert.ToInt32(row["fileId"]);
                }
                if (row["typeNo"] != DBNull.Value)
                {
                    model.typeNo = Convert.ToString(row["typeNo"]);
                }
                if (row["sysFileNm"] != DBNull.Value)
                {
                    model.sysFileNm = Convert.ToString(row["sysFileNm"]);
                }
                if (row["preFileNm"] != DBNull.Value)
                {
                    model.preFileNm = Convert.ToString(row["preFileNm"]);
                }
                if (row["fileSize"] != DBNull.Value)
                {
                    model.fileSize = Convert.ToInt32(row["fileSize"]);
                }
                if (row["urlPath"] != DBNull.Value)
                {
                    model.urlPath = Convert.ToString(row["urlPath"]);
                }
                if (row["absolutPath"] != DBNull.Value)
                {
                    model.absolutPath = Convert.ToString(row["absolutPath"]);
                }
                if (row["isImage"] != DBNull.Value)
                {
                    model.isImage = Convert.ToBoolean(row["isImage"]);
                }
                if (row["imageWidth"] != DBNull.Value)
                {
                    model.imageWidth = Convert.ToInt32(row["imageWidth"]);
                }
                if (row["imageHeight"] != DBNull.Value)
                {
                    model.imageHeight = Convert.ToInt32(row["imageHeight"]);
                }
                if (row["usingNum"] != DBNull.Value)
                {
                    model.usingNum = Convert.ToInt32(row["usingNum"]);
                }
                if (row["useEmpId"] != DBNull.Value)
                {
                    model.useEmpId = Convert.ToInt32(row["useEmpId"]);
                }
                if (row["isPerson"] != DBNull.Value)
                {
                    model.isPerson = Convert.ToBoolean(row["isPerson"]);
                }
                if (row["mark"] != DBNull.Value)
                {
                    model.mark = Convert.ToString(row["mark"]);
                }
                if (row["isrtEmpId"] != DBNull.Value)
                {
                    model.isrtEmpId = Convert.ToInt32(row["isrtEmpId"]);
                }
                if (row["isrtDt"] != DBNull.Value)
                {
                    model.isrtDt = Convert.ToString(row["isrtDt"]);
                }
                if (row["updtEmpId"] != DBNull.Value)
                {
                    model.updtEmpId = Convert.ToInt32(row["updtEmpId"]);
                }
                if (row["updtDt"] != DBNull.Value)
                {
                    model.updtDt = Convert.ToString(row["updtDt"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// �����ļ��ϴ�
        /// </summary>
        /// <param name="model">sFile��model</param>
        /// <param name="postedFile">�ļ�</param>
        /// <param name="empId">��ԱId</param>
        /// <param name="isImg">�Ƿ�ͼƬ</param>
        /// <returns>��û�����򷵻�true�����򷵻�false</returns>
        public int UploadFile(SFileData model, HttpPostedFile postedFile, int empId, bool isImg)
        {
            int ret;
            string saveFilePathNm = "";
            string saveFilePath = "";
            string saveUrlPath = "";
            string nowDt = "";
            nowDt = DateTime.Now.ToString("yyyy-MM-dd");

            SSystemConfigBB systemConfigBB = new SSystemConfigBB();
            DataSet systemConfigDs = new DataSet();
            SFileSaveTypeBB fileSaveTypeBB = new SFileSaveTypeBB();
            DataSet fileSaveTypeDs = new DataSet();

            try
            {
                //��ȡϵͳ���������ϴ��������ߴ磨KB)
                systemConfigDs = systemConfigBB.GetList("");
                if (systemConfigDs.Tables[0].Rows.Count == 0)
                {
                    throw new Exception("�����Ƚ���ϵͳ���ã�");
                }
                DataRow systemConfigRow = systemConfigDs.Tables[0].Rows[0];

                int maxSizeK = Convert.ToInt32(systemConfigRow["maxUpFileSize"]);
                int maxSize = maxSizeK * 1024;
                model.fileSize = postedFile.ContentLength;
                if (model.fileSize > maxSize)
                {
                    throw new Exception("��ǰ�ϴ��ļ��ijߴ����׼������ߴ�,��ѹ����" + maxSizeK + "KB���ڽ����ϴ�!");
                }

                //��ȡupFile���ļ�����·��������
                fileSaveTypeDs = fileSaveTypeBB.GetList("typeNo='upFile'");
                if (fileSaveTypeDs.Tables[0].Rows.Count == 0)
                {
                    throw new Exception("�����������ļ�����·����");
                }
                DataRow fileSaveTypeRow = fileSaveTypeDs.Tables[0].Rows[0];

                saveFilePath = fileSaveTypeRow["absolutePath"].ToString();
                saveFilePath = AddAbsoluteLastSeparator(saveFilePath);
                saveUrlPath = fileSaveTypeRow["urlPath"].ToString();
                saveUrlPath = AddRelativeLastSeparator(saveUrlPath);

                FileInfo preFileInfo = new FileInfo(postedFile.FileName);

                //��ȡ�ļ����
                //2015-06-30 �޸� �����浽��̨�����Ƹ�Ϊԭ��������
                //string fileName = this.fileBB.GetNewFileName("upFile", nowDt, empId);
                //��ȡԭ�ļ���չ��
               // fileName += preFileInfo.Extension;

                saveFilePath += Convert.ToString(empId) + Path.DirectorySeparatorChar;
                saveFilePath += nowDt + Path.DirectorySeparatorChar;

                saveUrlPath += empId + "/";
                saveUrlPath += nowDt + "/";
                DirectoryInfo dir = new DirectoryInfo(saveFilePath);
                if (!dir.Exists)
                {
                    dir.Create();
                }

                //�����ļ����ļ��б��¼
                saveFilePathNm = saveFilePath + preFileInfo.Name;

                model.typeNo = "upFile";
                model.preFileNm = preFileInfo.Name;
               // model.sysFileNm = fileName;
                model.sysFileNm = preFileInfo.Name;//2015-06-26�޸� ����������������Ϊһ��
                model.urlPath = saveUrlPath;
                model.absolutPath = saveFilePath;
                model.usingNum = 1;
                model.useEmpId = empId;
                model.isrtEmpId = empId;
                model.isrtDt = nowDt;

                postedFile.SaveAs(saveFilePathNm);

                ret = this.fileBB.AddRecord(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                systemConfigBB.Dispose();
                fileSaveTypeBB.Dispose();
            }
            return ret;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// �����ļ��ϴ�
        /// </summary>
        /// <param name="model">sFile��model</param>
        /// <param name="postedFile">�ļ�</param>
        /// <param name="saveType">�ļ���������</param>
        /// <param name="empId">��ԱId</param>
        /// <param name="isImg">�Ƿ�ͼƬ</param>
        /// <returns>��û�����򷵻�true�����򷵻�false</returns>
        public int UploadCustFile(SFileData model, HttpPostedFile postedFile, string saveType, int empId, bool isImg,string filenm)
        {
            int ret;
            string saveFilePath = "";
            string saveUrlPath = "";
            string nowDt = "";
            nowDt = DateTime.Now.ToString("yyyy-MM-dd");

            SSystemConfigBB systemConfigBB = new SSystemConfigBB();
            DataSet systemConfigDs = new DataSet();
            SFileSaveTypeBB fileSaveTypeBB = new SFileSaveTypeBB();
            DataSet fileSaveTypeDs = new DataSet();

            try
            {
                //��ȡϵͳ���������ϴ��������ߴ磨KB)
                systemConfigDs = systemConfigBB.GetList("");
                if (systemConfigDs.Tables[0].Rows.Count == 0)
                {
                    throw new Exception("�����Ƚ���ϵͳ���ã�");
                }
                DataRow systemConfigRow = systemConfigDs.Tables[0].Rows[0];

                int maxSizeK = Convert.ToInt32(systemConfigRow["maxUpFileSize"]);
                int maxSize = maxSizeK * 1024;
                model.fileSize = postedFile.ContentLength;
                if (model.fileSize > maxSize)
                {
                    throw new Exception("��ǰ�ϴ��ļ��ijߴ����׼������ߴ�,��ѹ����" + maxSizeK + "KB���ڽ����ϴ�!");
                }

                //��ȡupFile���ļ�����·��������
                fileSaveTypeDs = fileSaveTypeBB.GetList("typeNo='" + saveType + "'");
                if (fileSaveTypeDs.Tables[0].Rows.Count == 0)
                {
                    throw new Exception("�����������ļ�����·����");
                }
                DataRow fileSaveTypeRow = fileSaveTypeDs.Tables[0].Rows[0];

                saveFilePath = fileSaveTypeRow["absolutePath"].ToString()+"/";

                saveUrlPath = fileSaveTypeRow["urlPath"].ToString() + "/";

                ;
                DirectoryInfo dir = new DirectoryInfo(saveFilePath);
                if (!dir.Exists)
                {
                    dir.Create();
                }

                //�����ļ����ļ��б��¼

                model.typeNo = saveType;
                model.preFileNm = filenm;
                model.sysFileNm = filenm;
                model.urlPath = saveUrlPath;
                model.absolutPath = saveFilePath;
                model.usingNum = 1;
                model.useEmpId = empId;
                model.isrtEmpId = empId;
                model.isrtDt = nowDt;

                postedFile.SaveAs(saveFilePath+filenm);

                ret = this.fileBB.AddRecord(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                systemConfigBB.Dispose();
                fileSaveTypeBB.Dispose();
            }
            return ret;
        }
Ejemplo n.º 13
0
 /// <summary>
 /// ɾ���ļ�
 /// </summary>
 /// <param name="fileId">�ļ�Id</param>
 public void DeleteFile(int fileId)
 {
     SFileData fileData = new SFileData();
     SFileBB fileBB = new SFileBB();
     try
     {
         fileData = fileBB.GetModel(fileId);
         //ɾ���ļ����ļ���¼
         fileBB.DeleteRecord(fileId);
         FileInfo preFileInfo = new FileInfo(fileData.absolutPath + fileData.sysFileNm);
         preFileInfo.Delete();
     }
     catch
     {
     }
     finally
     {
         fileBB.Dispose();
     }
 }