Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        /// <summary>
        /// jsonからホスト一覧を取得
        /// </summary>
        public HostListModel getHostList()
        {
            var hostList = (HostListModel)Session[Constants.SESSION_HOST_SETTING];

            if (hostList == null)
            {
                hostList = HostAdmin.GetHostList(HostListFilePath);
            }

            return(hostList);
        }
Exemplo n.º 4
0
        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());
        }
Exemplo n.º 5
0
        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));
        }