
MTSkull
Avatar/Signature-
Posts
153 -
Joined
-
Last visited
Personal Information
-
Occupation
Test Engineerish
-
Visual Studio .NET Version
.Net 2008
-
.NET Preferred Language
C#
MTSkull's Achievements
Newbie (1/14)
0
Reputation
-
Exact coding is difficult without knowing precisely what you are doing. This sounds like it might be an advanced project. Some hints. 1. Look up how to use Process.Start() this will allow you to run/monitor an external program. 2. When the user requests to start the new process, you are going to want to monitor/check the other running Processes, and see if it is running or not. By checking the Process.HasExited property you can see if a process has stopped. 3. I think there might be easier ways to do what you want. 4. Google is your friend 5. My post here shows one way to do something similar. Also you should have a try at doing this yourself. If you have problems come back and post specifics and the Pros here will do their best to solve it. Good Luck MTS
-
Fixed... I could not find anyone who had a similar problem, despite hours running various Google searches. I thought I might have a corrupt install or something, so I created a project to test the PreviousPage property and Source.Transfer() function, while stripping away everything else that was irrelevant to the problem. Everything worked as expected. Then I looked closer at the error message and noticed that "ASP.fieldservice_generatemr_aspx" seemed to point to the wrong location. It should have been ASP.fieldservice_SUBFOLDER_generatemr_aspx. Which lead me to suspect I had created the error, which is usually the problem. About a month ago I had moved the source page file into a sub folder in the project after I had created the page. When you create the page the project knows where it is. Then when you move it (drag and drop to new folder) something does not get updated with the new location. When you try to use <%@ PreviousPageType VirtualPath="SourcePage.aspx" %> the program freaks out because it cannot find the source form and cannot cast the page to the appropriate object. I could not find where the update to reflect the move needed to occur (didn't really look:rolleyes:) so to fix I renamed the old page and recreated a new page with the old pages original name. Then copied and pasted the code from the old to the new and presto, everything started working as expected. I should start a blog "How not to code ASPX pages." MTS
-
I realize this is old but, you might try posting some code. Some times that can let the Pros here see what is happening. Also if you fix it yourself while waiting for an answer, please come back and post your fix so others with similar problems will benefit from your experience. Have you tried using the code behind for validation, or is everything handled in Javascript. Thanks MTS
-
I have a web form that takes in user input. Then I transfer to a Processing page that tells the user to wait while some stuff is happening, and plays a simple flash animation. Source page (GenerateMR) protected void cmdGenerateMR_Click(object sender, EventArgs e) { Server.Transfer("MRProcessing.aspx",true); } Then I try to set an object on the destination page so I can read back the values entered on the source page. Destination Page (MRProcessing) private GenerateMR frmSource; protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; //Following throws InvalidCastException //Unable to cast object of type 'ASP.fieldservice_generatemr_aspx' to type 'FieldReturns.GenerateMR'. //frmSource = (GenerateMR)Context.Handler; //also generates above error.. GenerateMR frmSource = (GenerateMR)PreviousPage; } Basically I want to switch to a "Processing files, Please Wait" Page while I am doing stuff on the server. Is this method a good fit, if I can get it working or should I be doing something else. Thanks MTS
-
Just noticed that I failed to respond to this sorry. The "less then successful" was user error. I verified that the server uses local time. I just mis-adjusted the test PC's time and ran the function.
-
Figured it out. You cannot access the redirected output or error data while the process is running. once the process has stopped then you can look at the data. I think because I am actively sending data and have to explicitly send an "exit" command, the output is unavailable. The following mods to previously posted code work. public void UploadFileViaPSFTP(string ServerName, string UserName, string Password, string FileName) { // loop variables int loopThrottle = 1000; // controls how fast the loop sends commands to the process // : 1000 works // : 500 works // : 250 works, will use this for now // : 100 is too fast, transfer does not happen string[] commands = new string[]{"open " + ServerName, UserName, Password, "put \"" + FileName + "\"",// file name and path needs double quotes "ls", "exit"}; // Setup psftp process // psftp.exe download from "http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html" // select putty.zip for multiple utilities Process psftp = new Process(); psftp.StartInfo.UseShellExecute = false; // has to be false to allow stream redirection psftp.StartInfo.FileName = Server.MapPath("SSH_Tools") + "\\psftp.exe"; // allows uploading a file to a remote server psftp.StartInfo.CreateNoWindow = true; // allow console input/out stream redirection psftp.StartInfo.RedirectStandardInput = true; psftp.StartInfo.RedirectStandardOutput = true; psftp.StartInfo.RedirectStandardError = true; // Start Process, psftp.Start(); System.Threading.Thread.Sleep(loopThrottle); StreamWriter psftpIn = psftp.StandardInput; // redirect input to console //Loop to send console commands for (int x = 0; x < commands.Length; x++) { psftpIn.WriteLine(commands[x]); System.Threading.Thread.Sleep(loopThrottle); } // give things a chance to settle System.Threading.Thread.Sleep(loopThrottle * 5); psftp.WaitForExit(); LogToTextFile("UploadFileViaPSFTP", commands, psftp.StandardOutput, psftp.StandardError); // clean up... psftpIn.Close(); psftp.Close(); } private void LogToTextFile(string processName, string[] commands, StreamReader Output, StreamReader Error) { string filename = Server.MapPath("SSH_Tools") + "\\ErrorLog.txt"; string dtStamp = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + ": "; StreamWriter ftpLog = new StreamWriter(filename, true); ftpLog.WriteLine(); ftpLog.WriteLine("<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>"); ftpLog.WriteLine(); ftpLog.WriteLine(dtStamp + processName); // write commands for (int x = 0; x < commands.Length; x++) ftpLog.WriteLine(string.Format("{0}COMMAND: [{1}]: {2}",dtStamp, x, commands[x])); // write output data if (Output.EndOfStream == true) ftpLog.WriteLine(dtStamp + "OUTPUT : EOF, no output available."); else { while (Output.EndOfStream != true) ftpLog.WriteLine(dtStamp + "OUTPUT : " + Output.ReadLine()); } //write error data if (Error.EndOfStream == true) ftpLog.WriteLine(dtStamp + "ERROR : EOF, no error available"); else { while (Error.EndOfStream != true) ftpLog.WriteLine(dtStamp + "ERROR : " + Error.ReadToEnd()); } ftpLog.Close(); }
-
I am launching a process that uploads a file to a remote server. Then I will launch a second process that will run a script on the remote server to process the file. All of which works except... I would like to read the console outputs so i can tell if what I am doing is working. When I set up the process to redirect to a standard output stream, if I call any of the Read(), ReadBlock(), etc, commands, the program hangs. If I try to run the reads in an event, the event code never fires. If i call the Peek command I can see the First char that would be expected if I was running the console manually. Is there something I can do to get the read to work? Thanks MTS EDIT: This is in code behind for a aspx page, Should this be posted else where? Some code to peruse... public void UploadFileViaPSFTP(string ServerName, string UserName, string Password, string FileName) { // open log file, overwrite existing StreamWriter ftpLog = new StreamWriter("C:\\psftpLog.txt", false); // create a new log file ftpLog.WriteLine("Start Copy Process:" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString()); ftpLog.Close(); // loop variables int loopThrottle = 250; // controls how fast the loop sends commands to the process // : 1000 works // : 500 works // : 250 works, will use this for now // : 100 is too fast, transfer does not happen string[] commands = new string[]{"open " + ServerName, UserName, Password, "put \"" + FileName + "\""}; // file name and path needs double quotes // Setup psftp process // psftp.exe download from "http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html" // select putty.zip for multiple utilities Process psftp = new Process(); psftp.StartInfo.UseShellExecute = false; // has to be false to allow stream redirection psftp.StartInfo.FileName = "C:\\ssh_tools\\psftp.exe"; // allows uploading a file to a remote server psftp.StartInfo.CreateNoWindow = true; // event handler for psftp data output // Does not work, will troubleshoot as needed //psftp.OutputDataReceived += new DataReceivedEventHandler(RedirectConsoleToTextFile); // allow console input/out stream redirection psftp.StartInfo.RedirectStandardInput = true; psftp.StartInfo.RedirectStandardOutput = true; // Start Process, psftp.Start(); System.Threading.Thread.Sleep(loopThrottle); StreamWriter psftpIn = psftp.StandardInput; // redirect input to console // Hangs, never returns data //string data = psftp.StandardOutput.ReadToEnd(); //Will see the first char in the console output! Grrr, how do I read this? int data = psftp.StandardOutput.Peek(); //Loop to send console commands for (int x = 0; x < commands.Length; x++) { psftpIn.WriteLine(commands[x]); System.Threading.Thread.Sleep(loopThrottle); } // give things a chance to settle System.Threading.Thread.Sleep(loopThrottle * 5); // clean up... psftpIn.Close(); psftp.Close(); } private static void RedirectConsoleToTextFile(object sendingProcess, DataReceivedEventArgs outLine) { bool append = true; // redirect console output to text file // NOTE: never fires if (String.IsNullOrEmpty(outLine.Data) != true) { if (File.Exists("C:\\psftpLog.txt") != true) append = false; // create the file if it does not exist StreamWriter ftpLog = new StreamWriter("C:\\psftpLog.txt", append); ftpLog.Write(outLine.ToString()); ftpLog.Close(); } }
-
I have an asp application with c# code behind which will be used to collect user entered data from all over the place. I am going to stamp the data with... string.Format("{0: yyyy-MM-dd H:mm} MST", DateTime.Now); This is going to happen in the code behind at the server. So the question is, will the stamp be the local time at the server, or the local time for the end user? I tried to set up an experiment but it was less the successful. Thanks MTS
-
I think I am having a similar problem. I have an asp page that has c# elements and some javascript elements. If the code is run from the local machine in debug the code works fine in IE, Firefox and Chrome. When I publish the website to the IIS Server it still works in IE and chrome, but fails to work in Firefox. When posting to this forum adding code helps. Here is a sample of my code. I am creating a menu bar at the top with some dynamic elements. I copied the code from another website. It links to external Webpages and internal anchors. I would try searching for why Javascript does not work for aspx in firefox. If I find anything I will post results here. Also Google is a programmers best friend. <script type="text/javascript"> //SuckerTree Horizontal Menu (Sept 14th, 06) //By Dynamic Drive: http://www.dynamicdrive.com/style/ var menuids=["treemenu1"] //Enter id(s) of SuckerTree UL menus, separated by commas function buildsubmenus_horizontal() { for (var i = 0; i < menuids.length; i++) { var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul") for (var t = 0; t < ultags.length; t++) { if (ultags[t].parentNode.parentNode.id == menuids[i]) { //if this is a first level submenu ultags[t].style.top=ultags[t].parentNode.offsetHeight+"px" //dynamically position first level submenus to be height of main menu item ultags[t].parentNode.getElementsByTagName("a")[0].className="mainfoldericon" } else { //else if this is a sub level menu (ul) ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it ultags[t].parentNode.getElementsByTagName("a")[0].className="subfoldericon" } ultags[t].parentNode.onmouseover = function() { this.getElementsByTagName("ul")[0].style.visibility="visible" } ultags[t].parentNode.onmouseout = function() { this.getElementsByTagName("ul")[0].style.visibility="hidden" } } } } if (window.addEventListener) window.addEventListener("load", buildsubmenus_horizontal, false) else if (window.attachEvent) window.attachEvent("onload", buildsubmenus_horizontal) </script> <div class="suckertreemenu"> <ul id="treemenu1"> <li><a href="TyphonHome.aspx">Home</a></li> <li><a href="Search.aspx">Search</a></li> <li><a href="#Custom">Custom Data</a></li> <li><a href="#Laptop">Laptop</a></li> <li><a href="#System">System</a></li> <li><a href="#WiFi">WiFi</a></li> </ul> <br style="clear: left;" /> </div> Here is the CSS stuff /****** Sucker Tree CSS Data ******/ /*Credits: Dynamic Drive CSS Library */ /*URL: http://www.dynamicdrive.com/style/ */ .suckertreemenu ul{ margin: 0; padding: 0; list-style-type: none; } /*Top level list items*/ .suckertreemenu ul li{ position: relative; display: inline; float: left; background-color: #F3F3F3; /*overall menu background color*/ } /*Top level menu link items style*/ .suckertreemenu ul li a{ display: block; width: 90px; /*Width of top level menu link items*/ padding: 1px 8px; border: 1px solid black; border-left-width: 0; text-decoration: none; color: navy; } /*1st sub level menu*/ .suckertreemenu ul li ul{ left: 0; position: absolute; top: 1em; /* no need to change, as true value set by script */ display: block; visibility: hidden; } /*Sub level menu list items (undo style from Top level List Items)*/ .suckertreemenu ul li ul li{ display: list-item; float: none; } /*All subsequent sub menu levels offset after 1st level sub menu */ .suckertreemenu ul li ul li ul{ left: 159px; /* no need to change, as true value set by script */ top: 0; } /* Sub level menu links style */ .suckertreemenu ul li ul li a{ display: block; width: 160px; /*width of sub menu levels*/ color: navy; text-decoration: none; padding: 1px 5px; border: 1px solid #ccc; } .suckertreemenu ul li a:hover{ background-color: black; color: white; } /*Background image for top level menu list links */ .suckertreemenu .mainfoldericon{ background: #F3F3F3 url(media/arrow-down.gif) no-repeat center right; } /*Background image for subsequent level menu list links */ .suckertreemenu .subfoldericon{ background: #F3F3F3 url(media/arrow-right.gif) no-repeat center right; } * html p#iepara{ /*For a paragraph (if any) that immediately follows suckertree menu, add 1em top spacing between the two in IE*/ padding-top: 1em; } /* Holly Hack for IE \*/ * html .suckertreemenu ul li { float: left; height: 1%; } * html .suckertreemenu ul li a { height: 1%; } /* End */ EDITS: Hit post before I was ready, added css data.
-
Thanks, I found it. There was an old reference to a network resource that was unavailable to the server. When I tried to run the website on the server I got a meaningful error message that allowed me to find the problem. Thanks for the Help MTS
-
Error: 404 File or directory not found. Development Path = C:\Documents and Settings\mtskull\My Documents\Visual Studio 2008\Projects\Typhon_Tracking\Typhon_Tracking\Typh_Hx.aspx Server Path = C:\inetpub\wwwroot\TyphTrak\Typh_Hx.aspx
-
I have a web app that runs fine on the Dev Machine but, when run from a folder on the server it cannot find files in the code behind. When I run it locally I can find all files. On the server, any <a> redirects work file but I can not use Response.Redirect in the code behind. //in the aspx page the following always works... <a href="NextPage.aspx?SID=1234">Go To Next Page</a> //in the code behind the equivalent does not work on the server. // But does work on the development machine Response.Redirect("~/NextPage.aspx?SID=1234"); On the Server the pages are located in a subdirectory. Updating the redirect to include the sub dir also does not work. I.E. "/SubDir/NextPage.aspx?SID=1234" Not sure what else to try at the moment. Thanks MTS
-
How easy was that! I switched from session to Query String and passed the session variable as the value and presto it worked. Your help is greatly Appreciated.
-
I am trying to tie a sqlDatasource to a Stored Procedure. The stored procedure looks like... dbo.Select_SomeData_BySuperAssemID (@SuperAssemID as int) Select * From SomeTable Where SuperAssemID= @SuperAssemID Then the asp page is accessed via ... Response.Redirect("DataPage.aspx?SuperID=" + ID); In the code behind I can access and use Super ID no problem, but when I try to set up the SQL data source to access super ID it returns nothing. My gridview is bound to the following control. <asp:SqlDataSource ID="sqlSubAssemblies" runat="server" ConnectionString="<%$ ConnectionStrings:MyConnStr %>" SelectCommand="Select_SomeData_BySuperID" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:SessionParameter Name="SuperAssemID" SessionField="SuperID" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> Thanks in advance... Brian
-
I found this tutorial which helped get me started. http://www.dotnetspider.com/AspNet-Tutorials.aspx