private void btnLeft_Click_Copy(object sender, EventArgs e) { //save or delete group detail data //get the selected row data from dgrdBackupServer if (null == dgrdBackupServer.CurrentCell) { return; } BackupServerGroupDetail bsgd = new BackupServerGroupDetail(); string backupServerId = dgrdBackupServer.CurrentRow.Cells[0].Value.ToString(); //get the combobox selected value string selectGroupId = this.cobBKServerGroup.SelectedValue.ToString(); bsgd.backupServerGroupId = Convert.ToInt32(selectGroupId); bsgd.backupServerId = Convert.ToInt32(backupServerId); bsgd.creater = FrmMain.userinfo.loginID; bsgd.createDate = DateTime.Now.ToString(); bsgd.updater = FrmMain.userinfo.loginID; bsgd.updateDate = DateTime.Now.ToString(); IBackupServerService bs = BLLFactory.ServiceAccess.CreateBackupServer(); IBackupServerGroupDetailService backGroupDetail = BLLFactory.ServiceAccess.CreateBackupServerGroupDetailService(); int flag = backGroupDetail.InsertBackupServerGroupDetail(bsgd); if (flag > -1) { //empty the monitor rows this.dgrdMonitorServer.Rows.Clear(); this.dgrdMonitorServer.AllowUserToAddRows = false; IList <BackupServer> gbsList = bs.GetGroupBackupServerList(selectGroupId); foreach (BackupServer gbs in gbsList) { DataGridViewRow dgvr = new DataGridViewRow(); foreach (DataGridViewColumn c in dgrdMonitorServer.Columns) { dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);//add row cells } dgvr.Cells[0].Value = gbs.id; dgvr.Cells[1].Value = gbs.backupServerName; this.dgrdMonitorServer.Rows.Add(dgvr); } //empty the monitor rows this.dgrdBackupServer.Rows.Clear(); this.dgrdBackupServer.AllowUserToAddRows = false; IList <BackupServer> gbpList = bs.GetPartBackupServerList(selectGroupId); foreach (BackupServer gbs in gbpList) { DataGridViewRow dgvr = new DataGridViewRow(); foreach (DataGridViewColumn c in dgrdBackupServer.Columns) { dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);//add row cells } dgvr.Cells[0].Value = gbs.id; dgvr.Cells[1].Value = gbs.backupServerName; this.dgrdBackupServer.Rows.Add(dgvr); } } }
private void cobBKServerGroup_SelectedIndexChanged(object sender, EventArgs e) { if (changed) { //get the combobox selected value string selectGroupId = this.cobBKServerGroup.SelectedValue.ToString(); IBackupServerService bs = BLLFactory.ServiceAccess.CreateBackupServer(); //remove the monitor current row //RowNumber = this.dgrdMonitorServer.CurrentCell.RowIndex; //dgrdMonitorServer.Rows.RemoveAt(RowNumber); //empty the monitor rows this.dgrdMonitorServer.Rows.Clear(); this.dgrdMonitorServer.AllowUserToAddRows = false; IList <BackupServer> gbsList = bs.GetGroupBackupServerList(selectGroupId); foreach (BackupServer gbs in gbsList) { DataGridViewRow dgvr = new DataGridViewRow(); foreach (DataGridViewColumn c in dgrdMonitorServer.Columns) { dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);//add row cells } dgvr.Cells[0].Value = gbs.id; dgvr.Cells[1].Value = gbs.backupServerName; this.dgrdMonitorServer.Rows.Add(dgvr); } //empty the monitor rows this.dgrdBackupServer.Rows.Clear(); this.dgrdBackupServer.AllowUserToAddRows = false; IList <BackupServer> gbpList = bs.GetPartBackupServerList(selectGroupId); foreach (BackupServer gbs in gbpList) { DataGridViewRow dgvr = new DataGridViewRow(); foreach (DataGridViewColumn c in dgrdBackupServer.Columns) { dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);//add row cells } dgvr.Cells[0].Value = gbs.id; dgvr.Cells[1].Value = gbs.backupServerName; this.dgrdBackupServer.Rows.Add(dgvr); } } }
/// <summary> /// 明細設定ページ /// </summary> /// <returns></returns> public ActionResult DetailEdit(int id) { try { ViewData["serverList"] = sService.GetBackupServerList(); ViewData["groupList"] = groupSerivce.GetBackupServerGroupList(); ViewData["selectList"] = sService.GetGroupBackupServerList(id.ToString()); ViewData["unSelectList"] = sService.GetPartBackupServerList(id.ToString()); ViewData["groupId"] = id.ToString(); } catch (Exception ex) { ViewData["serverList"] = new List <BackupServer>(); ViewData["groupList"] = new List <BackupServerGroup>(); ViewData["selectList"] = new List <BackupServer>(); ViewData["unSelectList"] = new List <BackupServer>(); ViewData["groupId"] = ""; logger.Error(ex.Message); } return(View()); }
/// <summary> /// 転送ファイルのチェック /// </summary> /// <param name="dirs"></param> private void TransferMain() { //バックアップ先list IList <BackupServer> BackupServer = BackupServerService.GetGroupBackupServerList(_backupgroupid); //バックアップ元 MonitorServer MonitorServer = MonitorServerService.GetMonitorServerById(Int32.Parse(_monitorid)); string strSenderDir = MonitorServer.monitorLocalPath + "\\"; //バックアップ元のファイル変更list IList <MonitorServerFile> monitorServerFileForDelList = MonitorServerFileService.GetMonitorServerFileDelList(_monitorid); IList <MonitorServerFile> monitorServerFileForTopDirList = MonitorServerFileService.GetMonitorServerFileTopDirList(_monitorid, strSenderDir.TrimEnd('\\')); string requestUrl = System.Configuration.ConfigurationManager.AppSettings["ssbapi"]; string account = System.Configuration.ConfigurationManager.AppSettings["ssbaccount"]; string password = System.Configuration.ConfigurationManager.AppSettings["ssbpassword"]; foreach (BackupServer backup in BackupServer) { try { SkeedFileTransfer filetransfer = new SkeedFileTransfer(requestUrl, account, password); var jsonSession = filetransfer.connect(backup.backupServerIP); if (jsonSession.ToString() != string.Empty && jsonSession.result == 0) { //批量传输 string strFileName = ""; string fileId = ""; string strDelFileName = ""; string fileDelId = ""; foreach (MonitorServerFile file in monitorServerFileForDelList) { strDelFileName = strDelFileName + "&files=./" + file.monitorFilePath.Replace(strSenderDir, ""); fileDelId = fileDelId + file.id + ","; } foreach (MonitorServerFile file in monitorServerFileForTopDirList) { strFileName = strFileName + "&files=" + file.monitorFilePath; fileId = fileId + file.id + ","; } if (strDelFileName != "") { //SSB Delete DateTime startTime = DateTime.Now; dynamic jsonResult = filetransfer.deleteFiles(jsonSession.session.sessionId, strSenderDir, backup.startFile, strDelFileName.TrimStart('&')); DateTime endTime = DateTime.Now; TimeSpan timespan = endTime - startTime; if (jsonResult.ToString() != string.Empty && jsonResult.result == 0) { foreach (MonitorServerFile file in monitorServerFileForDelList) { try { //更新传输flg MonitorServerFileService.UpdateTransferFlg(file.id, 1); //insert log and backupserverfile //InsertTransferInfo(file, backup, startTime, endTime, timespan, 1); //logger.Info("["+file.monitorFilePath + "] is deleted to [" + backup.backupServerIP + "] OK"); } catch (Exception ex) { logger.Error(ex.Message); continue; } } } else { try { foreach (MonitorServerFile file in monitorServerFileForDelList) { //更新传输flg MonitorServerFileService.UpdateTransferFlg(file.id, 2); //insert log and backupserverfile //InsertTransferInfo(file, backup, startTime, endTime, timespan, 2); //logger.Info("[" + file.monitorFilePath + "] is deleted to [" + backup.backupServerIP + "] NG"); } } catch (Exception ex) { logger.Error(ex.Message); continue; } } } if (strFileName != "") { //SSB Upload DateTime startTime = DateTime.Now; dynamic jsonResult = filetransfer.transferFiles(jsonSession.session.sessionId, strSenderDir, strFileName); DateTime endTime = DateTime.Now; TimeSpan timespan = endTime - startTime; if (jsonResult.ToString() != string.Empty && jsonResult.result == 0) { foreach (MonitorServerFile file in monitorServerFileForTopDirList) { try { //更新传输flg MonitorServerFileService.UpdateTransferFlg(file.id, 1); //insert log and backupserverfile //InsertTransferInfo(file, backup, startTime, endTime, timespan, 1); //logger.Info("[" + file.monitorFilePath + "] is uploaded to [" + backup.backupServerIP + "] OK"); } catch (Exception ex) { logger.Error(ex.Message); continue; } } } else { foreach (MonitorServerFile file in monitorServerFileForTopDirList) { try { //更新传输flg MonitorServerFileService.UpdateTransferFlg(file.id, 2); //insert log and backupserverfile //InsertTransferInfo(file, backup, startTime, endTime, timespan, 2); //logger.Info("[" + file.monitorFilePath + "] is uploaded to [" + backup.backupServerIP + "] NG"); } catch (Exception ex) { logger.Error(ex.Message); continue; } } } } var jsonSession2 = filetransfer.disconnect(jsonSession.session.sessionId); } else { logger.Error("[" + backup.backupServerIP + "]は接続できません"); continue; } } catch (Exception ex) { logger.Error(ex.Message); continue; } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnTansferFile(object sender, System.Timers.ElapsedEventArgs e) { m_timer.Enabled = false; //バックアップ先list IList <BackupServer> BackupServer = BackupServerService.GetGroupBackupServerList(backupgroupid); //バックアップ元 MonitorServer MonitorServer = MonitorServerService.GetMonitorServerById(Int32.Parse(monitorid)); string strSenderDir = MonitorServer.monitorLocalPath + "\\"; //バックアップ元のファイル変更list IList <MonitorServerFile> monitorServerFileList = MonitorServerFileService.GetMonitorServerFileSSBPutList(monitorid, strSenderDir.TrimEnd('\\')); string requestUrl = System.Configuration.ConfigurationManager.AppSettings["ssbapi"]; string account = System.Configuration.ConfigurationManager.AppSettings["ssbaccount"]; string password = System.Configuration.ConfigurationManager.AppSettings["ssbpassword"]; try { if (Directory.GetDirectories(strSenderDir).Length > 0 || Directory.GetFiles(strSenderDir).Length > 0) { foreach (BackupServer backup in BackupServer) { try { SkeedFileTransfer filetransfer = new SkeedFileTransfer(requestUrl, account, password); var jsonSession = filetransfer.connect(backup.backupServerIP); // if (monitorServerFileList.Count > 0) { // linq var dirList = monitorServerFileList.ToList().Distinct(new DirectoryNameComparer()); // 転送情報 Hashtable transferInfo = new Hashtable(); if (dirList.Count() > 0) { foreach (var dirname in dirList) { if (jsonSession.ToString() != string.Empty && jsonSession.result == 0) { dynamic jsonResult = filetransfer.doingTransferBatchesList(); if (jsonResult.ToString() != string.Empty && jsonResult.result == 0) { try { filetransfer.disconnect(jsonSession.session.sessionId); } catch (Exception ex) { } int taskeNum = Regex.Matches(jsonResult.ToString(), "taskId").Count; if (taskeNum <= SSBTaskMaxNum) { //SSB Upload DateTime startTime = DateTime.Now; // 削除の場合 bool transferresult; string remotepath = RemotePathConvert(strSenderDir, dirname.monitorFileDirectory, backup.ssbpath); transferresult = TransferDir(backup.backupServerIP, dirname.monitorFileDirectory, remotepath, minbpsset, maxbpsset, initbpsset); DateTime endTime = DateTime.Now; TimeSpan timespan = endTime - startTime; TransferResult transferResult = new TransferResult(); if (transferresult) { transferResult.OKResult = true; MonitorServerFileService.UpdateAllTransferFlg(dirname.monitorFileDirectory, 1); } else { transferResult.OKResult = false; MonitorServerFileService.UpdateAllTransferFlg(dirname.monitorFileDirectory, 2); } transferResult.StartTime = startTime; transferResult.EndTime = endTime; transferResult.TimeSpan = timespan; transferInfo.Add(dirname.monitorFileDirectory, transferResult); } } } } // ファイル更新 foreach (MonitorServerFile file in monitorServerFileList) { try { TransferResult dirResult = transferInfo[file.monitorFileDirectory] as TransferResult; if (dirResult.OKResult) { MonitorServerFileService.UpdateTransferFlg(file.id, 1); //insert log and backupserverfile //InsertTransferInfo(file, backup, dirResult.StartTime, dirResult.EndTime, dirResult.TimeSpan, 1); } else { MonitorServerFileService.UpdateTransferFlg(file.id, 2); //insert log and backupserverfile //InsertTransferInfo(file, backup, dirResult.StartTime, dirResult.EndTime, dirResult.TimeSpan, 2); } } catch (Exception ex) { logger.Error(ex.Message); continue; } } } } } catch (Exception ex) { logger.Error(ex.Message); continue; } } } } catch (Exception ex) { logger.Error(ex.Message); } m_timer.Enabled = true; }
private void FrmGroupDetail_Load(object sender, EventArgs e) { //init the backup group select tab IBackupServerGroupService backGroupList = BLLFactory.ServiceAccess.CreateBackupServerGroupService(); IBackupServerService bs = BLLFactory.ServiceAccess.CreateBackupServer(); IList <BackupServerGroup> bsgList = backGroupList.GetBackupServerGroupList(); List <ComboBoxItem> cbiList = new List <ComboBoxItem>(); int index = 0; int i = 0; foreach (BackupServerGroup bgs in bsgList) { if (bgs.id == id) { index = i; } cbiList.Add(new ComboBoxItem(bgs.id.ToString(), bgs.backupServerGroupName)); i++; } this.cobBKServerGroup.DisplayMember = "Text"; this.cobBKServerGroup.ValueMember = "Value"; this.cobBKServerGroup.DataSource = cbiList; //set the combobox default value; this.cobBKServerGroup.SelectedIndex = index; //not allowed user add new row to datagridview this.dgrdMonitorServer.AllowUserToAddRows = false; IList <BackupServer> gbsList = bs.GetGroupBackupServerList(this.cobBKServerGroup.SelectedValue.ToString()); foreach (BackupServer gbs in gbsList) { DataGridViewRow dgvr = new DataGridViewRow(); foreach (DataGridViewColumn c in dgrdMonitorServer.Columns) { dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);//add row cells } dgvr.Cells[0].Value = gbs.id; dgvr.Cells[1].Value = gbs.backupServerName; this.dgrdMonitorServer.Rows.Add(dgvr); } //not allowed user add new row to datagridview this.dgrdBackupServer.AllowUserToAddRows = false; IList <BackupServer> bsList = bs.GetPartBackupServerList(this.cobBKServerGroup.SelectedValue.ToString()); foreach (BackupServer bserver in bsList) { DataGridViewRow dgvr = new DataGridViewRow(); foreach (DataGridViewColumn c in dgrdBackupServer.Columns) { dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);//add row cells } dgvr.Cells[0].Value = bserver.id; dgvr.Cells[1].Value = bserver.backupServerName; this.dgrdBackupServer.Rows.Add(dgvr); } changed = true; }