public FrmGroupFile(string msFolderPath, string mServerID) { InitializeComponent(); this.msFolderName = msFolderPath; this.mServerID = mServerID; IFileTypeSetService IFileTypeSetService = BLLFactory.ServiceAccess.CreateFileTypeSetService(); fileTypeSetLists = IFileTypeSetService.GetFileTypeSetByMonitorServerIdAndFolderName(mServerID, msFolderPath); this.lblTitle.Text = msFolderPath; if (fileTypeSetLists.id != null && fileTypeSetLists.id != "") { if (fileTypeSetLists.exceptAttributeFlg1 == "1") { this.chkExceptAttr1.Checked = true; } else { this.chkExceptAttr1.Checked = false; } if (fileTypeSetLists.exceptAttribute1 != null && fileTypeSetLists.exceptAttribute1 != "") { this.txtExceptAttr1.Text = fileTypeSetLists.exceptAttribute1; } if (fileTypeSetLists.exceptAttributeFlg2 == "1") { this.chkExceptAttr2.Checked = true; } else { this.chkExceptAttr2.Checked = false; } if (fileTypeSetLists.exceptAttribute2 != null && fileTypeSetLists.exceptAttribute2 != "") { this.txtExceptAttr2.Text = fileTypeSetLists.exceptAttribute2; } if (fileTypeSetLists.exceptAttributeFlg3 == "1") { this.chkExceptAttr3.Checked = true; } else { this.chkExceptAttr3.Checked = false; } if (fileTypeSetLists.exceptAttribute3 != null && fileTypeSetLists.exceptAttribute3 != "") { this.txtExceptAttr3.Text = fileTypeSetLists.exceptAttribute3; } //if (fileTypeSetLists.systemFileFlg == "1") //{ // this.chkSystemFileFlg.Checked = true; //} //if (fileTypeSetLists.hiddenFileFlg == "1") //{ // this.chkHiddenFileFlg.Checked = true; //} } }
public ActionResult Edit(string msID, string msrFolderName) { ViewData["msID"] = msID; ViewData["msrFolderName"] = msrFolderName; IFileTypeSetService setService = BLLFactory.ServiceAccess.CreateFileTypeSetService(); //ViewData["setFile"] = setService.GetFileTypeSetByMonitorServerID(msID) ; try { ViewData["setFile"] = setService.GetFileTypeSetByMonitorServerIdAndFolderName(msID, msrFolderName); } catch (Exception ex) { ViewData["setFile"] = new List <FileTypeSet>(); logger.Error(ex.Message); } return(View()); }
public ActionResult GetFileTypeSet(string msID, string folderName) { string strResult = string.Empty; IFileTypeSetService setService = BLLFactory.ServiceAccess.CreateFileTypeSetService(); try { FileTypeSet fSet = setService.GetFileTypeSetByMonitorServerIdAndFolderName(msID, folderName); strResult = JsonHelper.GetJson <FileTypeSet>(fSet); } catch (Exception ex) { logger.Error(ex.Message); } Response.Write(strResult); Response.End(); return(null); }
/// <summary> /// 获取所有父节点的除外条件 /// </summary> /// 2014-8-30 wjd add /// <param name="msID"></param> /// <param name="folderName"></param> /// <returns></returns> public ActionResult GetBranchFileTypeSet(string msID, string folderName) { string strResult = string.Empty; IFileTypeSetService setService = BLLFactory.ServiceAccess.CreateFileTypeSetService(); try { string p1 = folderName.Substring(folderName.IndexOf("\\\\") + 2); string[] ps = p1.Split(new char[] { '\\' }, System.StringSplitOptions.RemoveEmptyEntries); List <string> pss = new List <string>(); int j = 0; for (int i = 0; i < ps.Length; i++) { j = i; if (ps[i] == "") { j -= 1; continue; } if (i == 0) { pss.Add("\\\\" + ps[i]); } else { pss.Add(pss[j - 1] + "\\" + ps[i]); } } List <string> exceptedExt = new List <string>(); foreach (string path in pss) { FileTypeSet fts = setService.GetFileTypeSetByMonitorServerIdAndFolderName(msID, path); string ea1 = fts.exceptAttribute1; bool flag1 = fts.exceptAttributeFlg1 == "1"; string ea2 = fts.exceptAttribute2; bool flag2 = fts.exceptAttributeFlg2 == "1"; string ea3 = fts.exceptAttribute3; bool flag3 = fts.exceptAttributeFlg3 == "1"; if (flag1 && ea1 != "") { exceptedExt.Add(ea1); } if (flag2 && ea2 != "") { exceptedExt.Add(ea2); } if (flag3 && ea3 != "") { exceptedExt.Add(ea3); } } strResult = JsonHelper.GetJson <List <string> >(exceptedExt); } catch (Exception ex) { logger.Error(ex.Message); } Response.Write(strResult); Response.End(); return(null); }
public ActionResult GetFolderDetail(string folderPath, bool checkstate, string msID) { string strResult = string.Empty; List <budbackup.Models.FolderDetail> detailList = new List <Models.FolderDetail>(); try { if (Directory.Exists(folderPath)) { IFileTypeSetService setService = BLLFactory.ServiceAccess.CreateFileTypeSetService(); FileTypeSet fset = setService.GetFileTypeSetByMonitorServerIdAndFolderName(msID, folderPath); DirectoryInfo dirInfo = new DirectoryInfo(folderPath); foreach (DirectoryInfo folder in dirInfo.GetDirectories()) { if (fset.id != null) { if (fset.hiddenFileFlg == "1") {//隠しファイル if ((folder.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) { continue; } } if (fset.systemFileFlg == "1") {//システムファイル if ((folder.Attributes & FileAttributes.System) == FileAttributes.System) { continue; } } } budbackup.Models.FolderDetail detail = new Models.FolderDetail(); detail.checkState = checkstate; detail.fileExtensionType = "99";//99はフォルダーのフラグ detail.fileLastUpdateTime = folder.LastWriteTime.ToString("yyyy/MM/dd HH:mm:ss"); detail.fileName = folder.Name; detail.fileSize = "<DIR>"; detail.filePath = folderPath; detailList.Add(detail); } foreach (FileInfo file in dirInfo.GetFiles()) { if (fset.id != null) { //string strExceptAttribute1 = string.Empty; //string strExceptAttribute2 = string.Empty; //string strExceptAttribute3 = string.Empty; //if (fset.exceptAttributeFlg1 == "1") //{ // strExceptAttribute1 = fset.exceptAttribute1; //} //if (fset.exceptAttributeFlg2 == "1") //{ // strExceptAttribute2 = fset.exceptAttribute2; //} //if (fset.exceptAttributeFlg3 == "1") //{ // strExceptAttribute3 = fset.exceptAttribute3; //} //if (CommonWeb.CommonUtil.IsExceptFile(file.Name, strExceptAttribute1, strExceptAttribute2, strExceptAttribute3)) //{ // continue; //} if (fset.hiddenFileFlg == "1") {//隠しファイル if ((file.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) { continue; } } if (fset.systemFileFlg == "1") {//システムファイル if ((file.Attributes & FileAttributes.System) == FileAttributes.System) { continue; } } } budbackup.Models.FolderDetail detail = new Models.FolderDetail(); detail.checkState = checkstate; detail.fileExtensionType = file.Extension.ToString(); detail.fileLastUpdateTime = file.LastWriteTime.ToString("yyyy/MM/dd HH:mm:ss"); detail.fileName = file.Name; detail.fileSize = file.Length.ToString("###,###"); detail.filePath = folderPath; detailList.Add(detail); } } else if (System.IO.File.Exists(folderPath)) { FileInfo file = new FileInfo(folderPath); budbackup.Models.FolderDetail detail = new Models.FolderDetail(); detail.checkState = checkstate; detail.fileExtensionType = file.Extension.ToString(); detail.fileLastUpdateTime = file.LastWriteTime.ToString("yyyy/MM/dd HH:mm:ss"); detail.fileName = file.Name; detail.fileSize = file.Length.ToString("###,###"); detail.filePath = file.DirectoryName; detailList.Add(detail); } strResult = JsonHelper.GetJson <List <budbackup.Models.FolderDetail> >(detailList); } catch (Exception ex) { logger.Error(ex.Message); } Response.Write(strResult); Response.End(); return(null); }
public ActionResult Add(string dataJson, int intMonitorServerID) { int result = 0; if (Session["LoginId"] == null) { result = -99; } else { try { List <MonitorServerFolder> folderList = new List <MonitorServerFolder>(); folderList = JsonHelper.ParseFormJson <List <MonitorServerFolder> >(dataJson); IFileTypeSetService setService = BLLFactory.ServiceAccess.CreateFileTypeSetService(); setFileList = setService.GetFileTypeSetByMonitorServerID(intMonitorServerID.ToString()); string dt = Common.CommonUtil.DateTimeNowToString(); msFolderService.DeleteMonitorServerFolderByServerId(intMonitorServerID); //format folder list globalfolderList = folderList; tempRemoveLists.Clear(); //Not filter——2014-06-11 wjd commented //formatListsByFileTypeSet(intMonitorServerID.ToString()); foreach (MonitorServerFolder model in globalfolderList) { if (model != null) { model.id = null; model.monitorFilePath = model.monitorFilePath.TrimEnd('\\'); if (model.monitorFileType == "99") { //選択のはフォルダの場合 string strpath = string.Empty; if (model.monitorFileName == "") { strpath = model.monitorFilePath; } else { strpath = model.monitorFilePath + "\\" + model.monitorFileName; } if (Directory.Exists(strpath)) { FileTypeSet fset = setService.GetFileTypeSetByMonitorServerIdAndFolderName(intMonitorServerID.ToString(), model.monitorFilePath); DirectoryInfo dirInfo = new DirectoryInfo(strpath); if (fset != null) { if (fset.hiddenFileFlg == "1") {//隠しファイル if ((dirInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) { continue; } } if (fset.systemFileFlg == "1") {//システムファイル if ((dirInfo.Attributes & FileAttributes.System) == FileAttributes.System) { continue; } } } model.createDate = dt; model.updateDate = dt; model.creater = Session["LoginId"].ToString(); model.updater = Session["LoginId"].ToString(); model.monitorServerID = intMonitorServerID; model.monitorFlg = "0"; model.initFlg = "1"; model.deleteFlg = 0; result = msFolderService.InsertMonitorServerFolder(model); //Not save subfolder——2014-06-11 wjd commented //result = InsertFolder(strpath, dt.ToString(), intMonitorServerID); } } else {//選択のはファイルの場合 string pathName = model.monitorFilePath + "\\" + model.monitorFileName; FileTypeSet fset = setService.GetFileTypeSetByMonitorServerIdAndFolderName(intMonitorServerID.ToString(), model.monitorFilePath); FileInfo fileInfo = new FileInfo(pathName); if (fset != null) { if (fset.hiddenFileFlg == "1") {//隠しファイル if ((fileInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) { continue; } } if (fset.systemFileFlg == "1") {//システムファイル if ((fileInfo.Attributes & FileAttributes.System) == FileAttributes.System) { continue; } } } model.createDate = dt; model.updateDate = dt; model.creater = Session["LoginId"].ToString(); model.updater = Session["LoginId"].ToString(); model.monitorServerID = intMonitorServerID; model.monitorFlg = "1"; model.deleteFlg = 0; model.initFlg = "1"; result = msFolderService.InsertMonitorServerFolder(model); } } } /* --選択条件 不要 * foreach (FileTypeSet fts in setFileList) * { * if (Directory.Exists(fts.monitorServerFolderName)) * { * DirectoryInfo dirInfo = new DirectoryInfo(fts.monitorServerFolderName); * foreach (FileInfo file in dirInfo.GetFiles()) * { * * if (CommonUtil.IsExceptFile(file.Name, fts.includeAttribute1, fts.includeAttribute2, fts.includeAttribute3)) * { * bool bSaved = false; * foreach (MonitorServerFolder modelFolder in folderList) * { * * if (fts.monitorServerFolderName == modelFolder.monitorFilePath && file.Name == modelFolder.monitorFileName) * { * bSaved = true; * break; * } * } * if (bSaved) * { * continue; * } * MonitorServerFolder model = new MonitorServerFolder(); * //FileInfo file = new FileInfo(strFolderPath); * model.createDate = dt.ToString(); * model.updateDate = dt.ToString(); * model.creater = Session["LoginId"].ToString(); * model.updater = Session["LoginId"].ToString(); * model.monitorFlg = "1"; * model.deleteFlg = 0; * model.initFlg = "1"; * model.monitorServerID = intMonitorServerID; * model.monitorFileName = file.Name; * model.monitorFilePath = file.DirectoryName; * model.monitorFileType = file.Extension.ToString(); * result = msFolderService.InsertMonitorServerFolder(model); * } * } * * } * } */ } catch (Exception ex) { result = -10; logger.Error(ex.Message); } } Response.Write(result); Response.End(); return(null); }
private void btnSave_Click(object sender, EventArgs e) { IFileTypeSetService IFileTypeSetService = BLLFactory.ServiceAccess.CreateFileTypeSetService(); FileTypeSet fileTypeSet = new FileTypeSet(); if (msFolderName != "") { fileTypeSet.monitorServerFolderName = msFolderName; } fileTypeSet.monitorServerID = Convert.ToInt32(mServerID); fileTypeSet.exceptAttribute1 = ""; fileTypeSet.exceptAttribute2 = ""; fileTypeSet.exceptAttribute3 = ""; fileTypeSet.exceptAttributeFlg1 = "0"; fileTypeSet.exceptAttributeFlg2 = "0"; fileTypeSet.exceptAttributeFlg3 = "0"; fileTypeSet.systemFileFlg = "0"; fileTypeSet.hiddenFileFlg = "0"; if (this.chkExceptAttr1.Checked == true && this.txtExceptAttr1.Text.Trim() != "") { fileTypeSet.exceptAttributeFlg1 = "1"; } if (this.txtExceptAttr1.Text.Trim() != "") { fileTypeSet.exceptAttribute1 = this.txtExceptAttr1.Text.Trim(); } if (this.chkExceptAttr2.Checked == true && this.txtExceptAttr2.Text.Trim() != "") { fileTypeSet.exceptAttributeFlg2 = "1"; } if (this.txtExceptAttr2.Text.Trim() != "") { fileTypeSet.exceptAttribute2 = this.txtExceptAttr2.Text.Trim(); } if (this.chkExceptAttr3.Checked == true && this.txtExceptAttr3.Text.Trim() != "") { fileTypeSet.exceptAttributeFlg3 = "1"; } if (this.txtExceptAttr3.Text.Trim() != "") { fileTypeSet.exceptAttribute3 = this.txtExceptAttr3.Text.Trim(); } //if (this.chkSystemFileFlg.Checked == true) //{ // fileTypeSet.systemFileFlg = "1"; //} //if (this.chkHiddenFileFlg.Checked == true) //{ // fileTypeSet.hiddenFileFlg = "1"; //} fileTypeSet.deleteFlg = 0; fileTypeSet.creater = FrmMain.userinfo.loginID; fileTypeSet.createDate = CommonUtil.DateTimeNowToString(); fileTypeSet.updater = FrmMain.userinfo.loginID; fileTypeSet.updateDate = CommonUtil.DateTimeNowToString(); FileTypeSet fts = IFileTypeSetService.GetFileTypeSetByMonitorServerIdAndFolderName(mServerID, msFolderName); if (fts.id != "" && fts.id != null) { fileTypeSet.id = fts.id; int updateFlg = -1; if (MsgHelper.QuestionMsg(ValidationRegex.Q002, ValidationRegex.publicTitle)) { try { updateFlg = IFileTypeSetService.UpdateFileTypeSet(fileTypeSet); } catch (Exception ex) { logger.Error(ex.Message); } } if (updateFlg > -1) { MsgHelper.InfoMsg(ValidationRegex.U001, ValidationRegex.publicTitle); gFlag = true; this.Dispose(); } else { MsgHelper.InfoMsg(ValidationRegex.U002, ValidationRegex.publicTitle); } } else { int insertFlg = -1; if (this.txtExceptAttr1.Text.Trim() != "" || this.txtExceptAttr2.Text.Trim() != "" || this.txtExceptAttr3.Text.Trim() != "" || this.chkHiddenFileFlg.Checked == true || this.chkSystemFileFlg.Checked == true) { if (MsgHelper.QuestionMsg(ValidationRegex.Q002, ValidationRegex.publicTitle)) { try { insertFlg = IFileTypeSetService.InsertFileTypeSet(fileTypeSet); } catch (Exception ex) { logger.Error(ex.Message); } } } if (this.txtExceptAttr1.Text.Trim() == "" && this.txtExceptAttr2.Text.Trim() == "" && this.txtExceptAttr3.Text.Trim() == "" || this.chkHiddenFileFlg.Checked == true || this.chkSystemFileFlg.Checked == true) { insertFlg = 0; } if (insertFlg > -1) { MsgHelper.InfoMsg(ValidationRegex.I001, ValidationRegex.publicTitle); gFlag = true; this.Dispose(); } else { MsgHelper.InfoMsg(ValidationRegex.I002, ValidationRegex.publicTitle); } } this.DialogResult = DialogResult.OK; }