/// <summary> /// db에 파일정보를 저장한다. /// </summary> /// <param name="strConn"></param> /// <param name="strUpdateType"></param> /// <param name="strFileName"></param> public static void FileInfo_Save(Function.Db.OracleDB.strConnect strConn, enUType UType, string strUpdateType, System.IO.FileInfo fi, string strCRC, string strText, Function.Db.OracleDB.delExcuteProcedure_Progress evtP) { Function.Db.OracleDB clsDB = new Function.Db.OracleDB(strConn.strTNS, strConn.strID, strConn.strPass); OracleParameter[] param = new OracleParameter[] { new OracleParameter("ps_UpdateType", OracleDbType.Varchar2, 20), //0 new OracleParameter("ps_UType", OracleDbType.Varchar2, 20), //1 new OracleParameter("ps_FileName", OracleDbType.Varchar2, 100), //2 new OracleParameter("ps_FileName2", OracleDbType.Varchar2, 100), //3 new OracleParameter("ps_Version", OracleDbType.Varchar2, 20), //4 new OracleParameter("ps_FileDate", OracleDbType.Date, 8), //5 new OracleParameter("ps_FileImage", OracleDbType.Blob, Convert.ToInt32(fi.Length)), //6 new OracleParameter("ps_Text", OracleDbType.Varchar2, 400), //7 new OracleParameter("ps_CRC", OracleDbType.Varchar2, 100), //8 new OracleParameter("ps_FileSize", OracleDbType.Int32, 8) }; //9 param[0].Value = strUpdateType; param[1].Value = UType.ToString(); param[2].Value = fi.Name.ToUpper(); param[3].Value = fi.Name; param[4].Value = system.clsFile.FileGetVersion(fi.FullName); param[5].Value = fi.LastWriteTime; param[7].Value = Function.Db.OracleDB.Fnc.StringEmpty2DbNull(strText); param[8].Value = strCRC; param[9].Value = fi.Length; clsDB.Excute_StoredProcedure("AutoUpdater_PKG.FileInfo_Set", param, 6, fi, evtP); }
public static void Server_FileUpload(enSeverType svrType, string strUpdateType, FileInfo fi, DataRow row, Function.Db.OracleDB.delExcuteProcedure_Progress evt, Function.Db.OracleDB.strConnect strConn, AutoUpdateServer_Web.AutoUpdateServer web) { switch (svrType) { case enSeverType.ORACLE: clsDBFunc.FileInfo_Save(strConn, clsDBFunc.enUType.FILE, strUpdateType, fi, Fnc.obj2String(row["crc"]), string.Empty, evt); break; case enSeverType.WEB: FileStream fs = new FileStream(fi.FullName, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); int intBlockSize = 1024 * 256; //256kb try { byte[] bytes = new byte[intBlockSize]; int intBytes; int intTotalBytes = 0; int key = -1; DataTable dt = row.Table.Clone(); DataRow dr = dt.NewRow(); dr.ItemArray = row.ItemArray; dt.Rows.Add(dr); while ((intBytes = br.Read(bytes, 0, bytes.Length)) > 0) { key = web.FileUpload(strUpdateType, dt, bytes, intBytes, fs.Length, intTotalBytes, key); intTotalBytes += intBytes; if (evt != null) { evt(int.Parse(fi.Length.ToString()), intTotalBytes); } } dt.Dispose(); } catch { throw; } finally { br.Close(); fs.Close(); fs.Dispose(); } break; } }
private void FileUpload() { try { if (evtP == null) { evtP = new Function.Db.OracleDB.delExcuteProcedure_Progress(Upload_Progress); } int intRows = gvFileList.DataRowCount; int intCnt = 0; int intTotalCnt = 0; string msg; //체크된 row 확인.. intTotalCnt = 0; DataRow row; //정리 GC.Collect(); Application.DoEvents(); GC.WaitForPendingFinalizers(); //임시폴더 파일은 전부 삭제한다. Function.system.clsFile.FolderFileDelete(_strTempFld); //압출 파일 클래스 Function.Archive.ZipStorer zip; string zipfileName = string.Empty; FileInfo fi; FileInfo fiNew; for (int idx = 0; idx < gvFileList.RowCount; idx++) { row = gvFileList.GetDataRow(idx); if (Fnc.obj2String(row["IsUpload"]).Equals("T")) { intTotalCnt++; } } for (int idx = 0; idx < gvFileList.RowCount; idx++) { gvFileList.FocusedRowHandle = idx; row = gvFileList.GetDataRow(idx); if (!Fnc.obj2String(row["IsUpload"]).Equals("T")) { continue; } intCnt++; Application.DoEvents(); if (UseZip) { //압축 사용 Upload ProgressRow = row; msg = string.Format("[{1}/{0}] {2}을 압축 중 입니다.", intTotalCnt, intCnt, row["FileName"]); SetMessage(false, msg, false); Application.DoEvents(); //압축파일 생성 fi = new FileInfo(Fnc.obj2String(row["Source_FilePath"])); zipfileName = string.Format("{0}.zip", row["FileName"]); fiNew = new FileInfo(_strTempFld + zipfileName); Function.system.clsFile.FolderCreate(fiNew.DirectoryName); zip = Function.Archive.ZipStorer.Create(_strTempFld + zipfileName, string.Empty); zip.AddFile(Function.Archive.ZipStorer.Compression.Deflate, fi.FullName, fi.Name, string.Empty); zip.Dispose(); row["ZipFilePath"] = zipfileName; row["crc"] = system.clsFile.Get_Crc32(fiNew); msg = string.Format("[{1}/{0}] {2}을 업로드 합니다.", intTotalCnt, intCnt, row["FileName"]); SetMessage(false, msg, false); Application.DoEvents(); fncDB.Server_FileUpload(SvrType, strUpdateType, fiNew, row, evtP, strConn, web); } else { //압축 미사용 Upload msg = string.Format("[{1}/{0}] {2}을 업로드 합니다.", intTotalCnt, intCnt, row["FileName"]); SetMessage(false, msg, false); Application.DoEvents(); //Thread.Sleep(50); ProgressRow = row; row["ZipFilePath"] = string.Empty; fi = new FileInfo(Fnc.obj2String(row["Source_FilePath"])); fncDB.Server_FileUpload(SvrType, strUpdateType, fi, row, evtP, strConn, web); } } dsUpdateType_init(); ListCheckAllFile(); msg = string.Format("{0}건 업로드를 완료 했습니다.", intTotalCnt); SetMessage(false, msg, false); } catch (Exception ex) { ListCheckAllFile(); ProcExecption(ex); } finally { GC.Collect(); Application.DoEvents(); GC.WaitForPendingFinalizers(); } }