public ActionResult Index() { var model = new FTPControlModel(); if (Session[Constants.SESSION_LOCAL_FILE_LIST] == null || Session[Constants.SESSION_REMOTE_FILE_LIST] == null) { return(new RedirectToRouteResult(new RouteValueDictionary( new { action = "Index", controller = "Home" }))); } model.LocalServerPath = (string)Session[Constants.SESSION_LOCAL_PATH]; model.LocalList = (List <ResourceInfoModel>)Session[Constants.SESSION_LOCAL_FILE_LIST]; model.RemoteList = (List <ResourceInfoModel>)Session[Constants.SESSION_REMOTE_FILE_LIST]; model.RemoteServerPath = (string)Session[Constants.SESSION_REMOTE_PATH]; string filePath = ConfigurationManager.AppSettings["HostList"]; HostListModel hosts = HostAdmin.GetHostList(filePath); model.HostList = hosts.HostList; model.SelectedHostID = ((HostDetailModel)Session[Constants.SESSION_HOST_DETAIL]).HostID; model.OperationLog = (string)Session[Constants.SESSION_LOG]; return(View(model)); }
public JsonResult Connect(int selectHostId) { var result = new JsonResponse(); HostDetailModel hostDetail = null; try { var hosts = (HostListModel)Session[Constants.SESSION_HOST_SETTING]; if (hosts == null) { hosts = HostAdmin.GetHostList(ConfigurationManager.AppSettings["HostList"]); } if (!HostAdmin.IsExistHostID(hosts.HostList, selectHostId)) { result.AddErrorInfo("errorMessage", "接続先のホスト情報が存在しません!"); } else { foreach (HostDetailModel host in hosts.HostList) { if (host.HostID == selectHostId) { hostDetail = new HostDetailModel(host); break; } } if (hostDetail != null && FTPControl.IsRemoteConnected(hostDetail)) { Session[Constants.SESSION_LOCAL_PATH] = hostDetail.LocalServerPath != "" && hostDetail.LocalServerPath != null ? hostDetail.LocalServerPath : "C:\\forwork\\localFolder"; Session[Constants.SESSION_REMOTE_PATH] = hostDetail.HostAddress; List <ResourceInfoModel> localResourceList = FTPControl.GetLocalResourceList((string)Session[Constants.SESSION_LOCAL_PATH]); List <ResourceInfoModel> remoteResourceList = FTPControl.GetRemoteResourceList(hostDetail.HostAddress, hostDetail, true); Session[Constants.SESSION_LOCAL_FILE_LIST] = localResourceList; Session[Constants.SESSION_REMOTE_FILE_LIST] = remoteResourceList; Session[Constants.SESSION_HOST_DETAIL] = hostDetail; string log = (string)Session[Constants.SESSION_OLD_LOG] + "ホスト" + hostDetail.HostAddress + "に接続しました。\r\n"; Session[Constants.SESSION_LOG] = log; Session[Constants.SESSION_OLD_LOG] = log; result.SetResult(true); } else { result.AddErrorInfo("errorMessage", "FTP接続に失敗しました。"); } } } catch (Exception) { result.AddErrorInfo("errorMessage", "接続時にエラーが発生しました。"); } return(Json(result, "text/json", Encoding.UTF8, JsonRequestBehavior.DenyGet)); }
/// <summary> /// jsonからホスト一覧を取得 /// </summary> public HostListModel getHostList() { var hostList = (HostListModel)Session[Constants.SESSION_HOST_SETTING]; if (hostList == null) { hostList = HostAdmin.GetHostList(HostListFilePath); } return(hostList); }
private HostAdminDB MapEntityToDBEntity(HostAdmin hostAdmin) { return(new HostAdminDB() { Id = hostAdmin.Id, Name = hostAdmin.Name, VirtualName = hostAdmin.VirtualName, Age = hostAdmin.Age, EmailAddress = hostAdmin.EmailAddress, FacebookPage = hostAdmin.FacebookPage, PhoneNumber = hostAdmin.PhoneNumber }); }
public ActionResult Post([FromServices] HostAdminBR hostAdminBR, [FromBody] HostAdmin hostAdmin) { try { hostAdminBR.Update(hostAdmin); return(Ok()); } catch (Exception ex) { LogEmailHelper.LogMail(ex); LogFileSystemHelper.LogFile(string.Concat("Não foi possível realizar a atualização do HostAdmin", " - ", hostAdmin.Name, "!"), ex); return(BadRequest()); } }
public ActionResult Put([FromServices] HostAdminBR hostAdminBR, [FromBody] HostAdmin hostAdmin) { try { hostAdminBR.Add(hostAdmin); } catch (Exception ex) { LogEmailHelper.LogMail(ex); LogFileSystemHelper.LogFile("Não foi possível realizar a inserção dos dados!", ex); return(BadRequest()); } return(Ok()); }
public ActionResult Index() { Session[Constants.SESSION_LOCAL_PATH] = null; Session[Constants.SESSION_REMOTE_PATH] = null; Session[Constants.SESSION_HOST_DETAIL] = null; Session[Constants.SESSION_LOCAL_FILE_LIST] = null; Session[Constants.SESSION_REMOTE_FILE_LIST] = null; string filePath = ConfigurationManager.AppSettings["HostList"]; HostListModel hosts = HostAdmin.GetHostList(filePath); Session[Constants.SESSION_HOST_SETTING] = hosts; ViewBag.hostList = hosts.HostList; return(View()); }
public JsonResult RemoveHost(int selectHostId) { var result = new JsonResponse(); try { HostListModel hosts = getHostList(); var newHosts = new HostListModel(); var hostDetailList = new List <HostDetailModel>(); if (!HostAdmin.IsExistHostID(hosts.HostList, selectHostId)) { result.AddErrorInfo("errorMessage", "ホストは既に削除されています!"); } else { foreach (HostDetailModel hostDetail in hosts.HostList) { if (hostDetail.HostID != selectHostId) { hostDetailList.Add(hostDetail); } } newHosts.HostList = hostDetailList; newHosts.MaxHostId = hosts.MaxHostId; if (HostAdmin.SetHostList(newHosts, HostListFilePath)) { Session[Constants.SESSION_HOST_SETTING] = newHosts; result.SetResult(true); result.AddData("hostId", selectHostId.ToString()); } else { result.AddErrorInfo("errorMessage", "ホスト削除に失敗!"); } } } catch (Exception) { result.AddErrorInfo("errorMessage", "予期せぬエラー"); } return(Json(result, "text/json", Encoding.UTF8, JsonRequestBehavior.DenyGet)); }
public ActionResult ViewHostList() { var model = new FTPControlModel(); try { string filePath = ConfigurationManager.AppSettings["HostList"]; HostListModel hosts = HostAdmin.GetHostList(filePath); model.HostList = hosts.HostList; } catch (Exception e) { model.OperationLog = string.Format("[Exception] {0},\r\n{1}", e.Message, e.StackTrace) + "\r\n"; } return(PartialView("_HostMenu", model)); }
public JsonResult HostItem(int hostId) { var result = new JsonResponse(); try { HostListModel hosts = getHostList(); if (!HostAdmin.IsExistHostID(hosts.HostList, hostId)) { result.AddErrorInfo("errorMessage", "該当ホスト情報が存在しません!"); } else { var hostItemDetail = new HostDetailModel(); foreach (HostDetailModel hostDetail in hosts.HostList) { if (hostDetail.HostID == hostId) { result.SetResult(true); result.AddData("hostId", hostDetail.HostID.ToString()); result.AddData("hostName", hostDetail.HostName); result.AddData("hostAddress", hostDetail.HostAddress); result.AddData("anonymous", hostDetail.Anonymous.ToString()); result.AddData("userName", hostDetail.UserName); result.AddData("password", hostDetail.Password); result.AddData("pasvMode", hostDetail.PasvMode.ToString()); result.AddData("portNumber", hostDetail.PortNumber.ToString()); result.AddData("timeout", hostDetail.Timeout.ToString()); result.AddData("localServerPath", hostDetail.LocalServerPath); result.AddData("remoteServerPath", hostDetail.RemoteServerPath); break; } } } } catch (Exception) { result.AddErrorInfo("errorMessage", "予期せぬエラー"); } return(Json(result, "text/json", Encoding.UTF8, JsonRequestBehavior.AllowGet)); }
public JsonResult SortHost(string hostList) { var result = new JsonResponse(); try { HostListModel currentHostList = getHostList(); var newHostList = new List <HostDetailModel>(); string[] hosts = hostList.Split(':'); foreach (HostDetailModel currentHost in currentHostList.HostList) { foreach (string host in hosts) { string[] hostDetail = host.Split(','); if (Convert.ToInt32(hostDetail[0]) == currentHost.HostID) { var newHostDetail = new HostDetailModel(currentHost); newHostDetail.SortNumber = Convert.ToInt32(hostDetail[1]); newHostList.Add(newHostDetail); break; } } } currentHostList.HostList = newHostList; if (HostAdmin.SetHostList(currentHostList, HostListFilePath)) { Session[Constants.SESSION_HOST_SETTING] = currentHostList; result.SetResult(true); } else { result.AddErrorInfo("errorMessage", "ホスト一覧のソートに失敗!"); } } catch (Exception) { result.AddErrorInfo("errorMessage", "予期せぬエラー"); } return(Json(result, "text/json", Encoding.UTF8, JsonRequestBehavior.DenyGet)); }
public JsonResult AddHost(HostDetailModel newHostDetail) { var result = new JsonResponse(); try { HostListModel hostList = getHostList(); if (!HostAdmin.IsExistHostName(hostList.HostList, newHostDetail.HostName)) { int newHostId = hostList.MaxHostId + 1; newHostDetail.HostID = newHostId; newHostDetail.SortNumber = hostList.HostList.Count; hostList.HostList.Add(newHostDetail); hostList.MaxHostId = newHostId; if (HostAdmin.SetHostList(hostList, HostListFilePath)) { Session[Constants.SESSION_HOST_SETTING] = hostList; result.SetResult(true); result.AddData("hostId", newHostId.ToString()); result.AddData("hostName", newHostDetail.HostName); } else { result.AddErrorInfo("errorMessage", "新規追加に失敗!"); } } else { result.AddErrorInfo("errorMessage", "既に登録されているホスト名です!"); } } catch (Exception) { result.AddErrorInfo("errorMessage", "予期せぬエラー"); } return(Json(result, "text/json", Encoding.UTF8, JsonRequestBehavior.DenyGet)); }
public JsonResult Reconnect(int selectHostId) { var result = new JsonResponse(); try { var bgHost = new BGHostController(); HostListModel hosts = bgHost.getHostList(); if (!HostAdmin.IsExistHostID(hosts.HostList, selectHostId)) { result.AddErrorInfo("errorMessage", "接続先のホスト情報が存在しません!"); } result.SetResult(true); } catch (Exception) { result.AddErrorInfo("errorMessage", "接続時にエラーが発生しました。"); } return(Json(result, "text/json", Encoding.UTF8, JsonRequestBehavior.DenyGet)); }
public void Add(HostAdmin hostAdmin) { _adminHostRepository.Add(MapEntityToDBEntity(hostAdmin)); }
public JsonResult EditHost(HostDetailModel editHostDetail) { var result = new JsonResponse(); try { var hostList = getHostList(); var newHosts = new HostListModel(); var hostDetailList = new List <HostDetailModel>(); bool isEdit = false; if (HostAdmin.GetHostName(hostList.HostList, editHostDetail.HostID) == editHostDetail.HostName) { isEdit = true; } else if (!HostAdmin.IsExistHostName(hostList.HostList, editHostDetail.HostName)) { isEdit = true; } if (isEdit) { foreach (HostDetailModel hostDetail in hostList.HostList) { if (hostDetail.HostID.Equals(editHostDetail.HostID)) { hostDetailList.Add(editHostDetail); } else { hostDetailList.Add(hostDetail); } } newHosts.HostList = hostDetailList; newHosts.MaxHostId = hostList.MaxHostId; if (HostAdmin.SetHostList(newHosts, HostListFilePath)) { Session[Constants.SESSION_HOST_SETTING] = newHosts; result.SetResult(true); result.AddData("hostId", editHostDetail.HostID.ToString()); result.AddData("hostName", editHostDetail.HostName); } else { result.AddErrorInfo("errorMessage", "ホスト設定の修正に失敗!"); } } else { result.AddErrorInfo("errorMessage", "既に登録されているホスト名です!"); } } catch (Exception) { result.AddErrorInfo("errorMessage", "予期せぬエラー"); } return(Json(result, "text/json", Encoding.UTF8, JsonRequestBehavior.DenyGet)); }
public void Delete(HostAdmin hostAdmin) { _adminHostRepository.Delete(MapEntityToDBEntity(hostAdmin)); }
public JsonResult CopyHost(int selectHostId, string NewHostName) { var result = new JsonResponse(); try { HostListModel hosts = getHostList(); if (!HostAdmin.IsExistHostID(hosts.HostList, selectHostId)) { result.AddErrorInfo("errorMessage", "コピー元のホストが存在しません!"); } else { int newHostId = hosts.MaxHostId + 1; string newHostName = string.Empty; if (NewHostName == string.Empty || HostAdmin.IsExistHostName(hosts.HostList, NewHostName)) { newHostName = "Untitled_" + newHostId; } else { newHostName = NewHostName; } foreach (HostDetailModel hostDetail in hosts.HostList) { if (hostDetail.HostID == selectHostId) { var newHostDetail = new HostDetailModel(hostDetail); newHostDetail.HostName = newHostName; newHostDetail.HostID = newHostId; newHostDetail.SortNumber = hosts.HostList.Count; hosts.HostList.Add(newHostDetail); hosts.MaxHostId = newHostId; break; } } if (HostAdmin.SetHostList(hosts, HostListFilePath)) { Session[Constants.SESSION_HOST_SETTING] = hosts; result.SetResult(true); result.AddData("hostId", newHostId.ToString()); result.AddData("hostName", newHostName); } else { result.AddErrorInfo("errorMessage", "新規追加に失敗!"); } } } catch (Exception) { result.AddErrorInfo("errorMessage", "予期せぬエラー"); } return(Json(result, "text/json", Encoding.UTF8, JsonRequestBehavior.DenyGet)); }
public void Update(HostAdmin hostAdmin) { _adminHostRepository.Update(MapEntityToDBEntity(hostAdmin)); }