1

I am open to ways to solve this problem. I suspect the best way is to submit to the controller the path to be mounted and the controller will then pass back a python script that runs locally and mounts the path. Later we may need to verify Active Directory permissions but that's another question. We are able to configure all clients and servers as we wish, so somehow we should be able to allow the mount script to run after downloading. Only really concerned with mounting on windows but mac is optional. My main concern is how to get the server to send the script and get client to run the script, and if this is the right approach to satisfying this necessity; The second concern is how I form the path to access any arbitrary remote server share and the third concern is checking permissions first. Any help appreciated.

 public ActionResult ProjectMountSubmit(string project_path, int project_number) {
            //Send mount script to user and make him run it
            return RedirectToAction("Project", "Home", new { ProjectNumber = project_number });
        }
6
  • Definitely looking for other options, but I need input from other developers. Keep in mind this site will be on a LAN. I'm starting to think my MVC website should've been a client application, then it wouldn't be an issue I guess... the information would still come from an SQL server. I know this is a specialized application... but it's a requirement, the user must be able to mount folders when the click on a project, as read only for now but write will come latter. Maybe I have a service running on all the clients, but then how do communicate to it from the browser. Erg. Commented Dec 12, 2016 at 0:17
  • Also was considering just having javascript mount it... but I can't find anything online indicating this is possible. Commented Dec 12, 2016 at 0:39
  • 1
    "the user must be able to mount folders" ok... could you explain the flow, the intent of the application, the actual use case? You're looking too much at technical details and implementation methods for the moment. Take a step back and look at what you're trying to achieve and why. Commented Dec 12, 2016 at 10:57
  • Sure and thanks! This is a media workflow manager. Its used to make movies, commercials, cartoons, etc... Overall operation: User's work for a company that can have multiple clients; there are multiple companies. There are also multiple projects for each client. So my DB tables are linked like: company-->clients-->projects-->project files and company-->users. Active directory comes in to play as well. Also, each project relates to tons of project files in a specific folder structure. A user should be able to click my GUI to mount a project folder, so they can work on the fast server. Commented Dec 12, 2016 at 19:29
  • Michal, this seems like a good approach to me. We have control of all clients so we can install the python framework on each, then we have the client download and run a custom script formed and sent using ASP.NET. Is this the right approach and if so, what's the best way to make it as seamless as possible? Commented Dec 12, 2016 at 19:32

1 Answer 1

0

Final Answer to submit a script to the browser. User can also set the browser to open it automatically, python must also be installed and associated to .py files to allow quick double click to run. Not sure if that script/python mime is valid but it works. Improvements could include somehow using razor to modify a python script so that it isn't all inside quotes, losing color coding. Note you have to escape slashes twice recursively, one for the file stream and one for the script that gets downloaded and run.

public ActionResult ProjectMountSubmit(int project_number, string drive_letter) {
            ProjectsBAL b = new ProjectsBAL();
            Projects c = b.GetProject(project_number);
            //generate python mount script
            string script = "import ctypes\n" +
                            "import subprocess\n" +
                            "import os\n" +
                            "command = 'net use " + drive_letter + ": \\\\\\\\MSI\\\\Users\\\\gunslingor\\\\Desktop\\\\Storage\\\\" + c.CompanyName + "\\\\Clients\\\\" + c.ClientName + "\\\\" + c.ProjectNumber + "_" + c.ProjectName + "'\n" +
                            "returned = subprocess.Popen(command, shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE)\n" +
                            "cmd_err_lines = returned.stderr.readlines()";

            var stream = new MemoryStream();
            StreamWriter writer = new StreamWriter(stream);
            writer.Write(script);
            writer.Flush();
            stream.Position = 0;
            //Send mount script to user, double click to run (python must be installed and associated to the file type py)
            return File(stream, "script/python", "Automount.py");
        }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.