Пример #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));
        }
Пример #2
0
        public ActionResult ViewLog()
        {
            var model = new FTPControlModel();

            try
            {
                string log = (string)Session[Constants.SESSION_OLD_LOG] + (string)Session[Constants.SESSION_LOG];
                model.OperationLog = log;
                Session[Constants.SESSION_OLD_LOG] = log;
            }
            catch (Exception e)
            {
                model.OperationLog = string.Format("[Exception] {0},\r\n{1}", e.Message, e.StackTrace) + "\r\n";
            }

            return(PartialView("_OperationLog", model));
        }
Пример #3
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));
        }
Пример #4
0
        public ActionResult ViewServerInfo(string path, string env = "", string filterPattern = "")
        {
            var result = new JsonResponse();
            var model  = new FTPControlModel();

            HostDetailModel hostDetail = (HostDetailModel)Session[Constants.SESSION_HOST_DETAIL];

            string sessionLocalPath  = (string)Session[Constants.SESSION_LOCAL_PATH];
            string sessionRemotePath = (string)Session[Constants.SESSION_REMOTE_PATH];
            string viewName          = string.Empty;

            try
            {
                string localPath  = string.Empty;
                string remotePath = string.Empty;
                List <ResourceInfoModel> localResourceList  = new List <ResourceInfoModel>();
                List <ResourceInfoModel> remoteResourceList = new List <ResourceInfoModel>();

                if (env == Constants.ENV_LOCAL)
                {
                    viewName = "_LocalServer";

                    // 一つ前のディレクトリに戻る場合
                    if (path.Equals(".."))
                    {
                        localPath = sessionLocalPath.Substring(0, sessionLocalPath.LastIndexOf("\\"));
                        // ex)c:\\などのドライブまで上がった場合は最後に\\を付ける
                        if (localPath.IndexOf("\\") == -1)
                        {
                            localPath = localPath + "\\";
                        }
                    }
                    else if (path.Equals("*"))
                    {
                        // リフレッシュ、フィルターをリセットする場合
                        localPath = sessionLocalPath;
                    }
                    else
                    {
                        localPath = path;
                    }

                    localResourceList = FTPControl.GetLocalResourceList(localPath);

                    if (filterPattern != string.Empty)
                    {
                        localResourceList        = FTPControl.GetFilteredList(localResourceList, filterPattern);
                        model.LocalFilterPattern = filterPattern;
                    }

                    remotePath         = (string)Session[Constants.SESSION_REMOTE_PATH];
                    remoteResourceList = (List <ResourceInfoModel>)Session[Constants.SESSION_REMOTE_FILE_LIST];
                }
                else if (env == Constants.ENV_REMOTE)
                {
                    viewName = "_RemoteServer";

                    // 一つ前のディレクトリに戻る場合
                    if (path.Equals(".."))
                    {
                        if (sessionRemotePath.IndexOf("/") != -1)
                        {
                            remotePath = sessionRemotePath.Substring(0, sessionRemotePath.LastIndexOf("/"));
                        }
                        else
                        {
                            remotePath = sessionRemotePath;
                        }
                    }
                    else if (path.Equals("*"))
                    {
                        // リフレッシュ、フィルターをリセットする場合
                        remotePath = sessionRemotePath;
                    }
                    else
                    {
                        remotePath = path;
                    }

                    remoteResourceList = FTPControl.GetRemoteResourceList(remotePath, hostDetail, true);

                    if (filterPattern != string.Empty)
                    {
                        remoteResourceList        = FTPControl.GetFilteredList(remoteResourceList, filterPattern);
                        model.RemoteFilterPattern = filterPattern;
                    }

                    localPath         = (string)Session[Constants.SESSION_LOCAL_PATH];
                    localResourceList = (List <ResourceInfoModel>)Session[Constants.SESSION_LOCAL_FILE_LIST];
                }
                else if (env == string.Empty && path.Equals("*"))
                {
                    // ローカル&リモート両方とも初期化状態に戻す
                    viewName = "_Server";

                    localPath  = sessionLocalPath;
                    remotePath = sessionRemotePath;

                    localResourceList  = FTPControl.GetLocalResourceList(localPath);
                    remoteResourceList = FTPControl.GetRemoteResourceList(remotePath, hostDetail, true);
                }

                model.LocalList        = localResourceList;
                model.LocalServerPath  = localPath;
                model.RemoteList       = remoteResourceList;
                model.RemoteServerPath = remotePath;
                Session[Constants.SESSION_LOCAL_PATH]       = localPath;
                Session[Constants.SESSION_LOCAL_FILE_LIST]  = localResourceList;
                Session[Constants.SESSION_REMOTE_PATH]      = remotePath;
                Session[Constants.SESSION_REMOTE_FILE_LIST] = remoteResourceList;
            }
            catch (Exception e)
            {
                Session[Constants.SESSION_LOG] = string.Format("[Exception] {0},\r\n{1}", e.Message, e.StackTrace) + "\r\n";
            }

            return(PartialView(viewName, model));
        }