/// <summary> /// Pages the logout. /// </summary> /// <param name="args">The args.</param> private void PageLogout(string[] args) { try { WebPostRequest myPost = new WebPostRequest(new Uri("http://10.10.1.37/goform/formLogout")); string webpage = myPost.GetResponse(); } catch (Exception ex) { } finally { } }
/// <summary> /// Logins the page. /// </summary> /// <param name="args">The args.</param> /// <returns></returns> private ResultDTO LoginPage(string[] args) { Uri address; int iTotalSpace = 0; int iUsedSpace = 0; int iUnUsedSpace = 0; int iTemp = 0; ResultDTO results = new ResultDTO { UsedDiskSpace = 0, UnUsedDiskSpace = 0, PercentUsedDiskSpace = 0, Temp = 0, TotalDiskSpace = 0, Error = "" }; try { string strUrl = @"http://10.10.1.37/goform/formLogin"; WebPostRequest myPost = new WebPostRequest(new Uri(strUrl)); myPost.Add("f_LOGIN_NAME", "admin"); myPost.Add("f_LOGIN_PASSWD", ""); myPost.Add("f_login_type", "0"); myPost.Add("f_url", ""); string webpage = myPost.GetResponse(); if (webpage.ToLower().Contains("wizard")) { //-- Need to test for valid login page //-- before continuing on. //-- now goto the http://10.10.1.37/goform/adv_status WebPostRequest myPost2 = new WebPostRequest(new Uri("http://10.10.1.37/goform/adv_status")); string webpage2 = myPost2.GetResponse(); if (webpage2.ToLower().Contains("temperture")) { HtmlDocument doc = new HtmlDocument(); //-- Removes all html tags //webpage2 = Regex.Replace(webpage2, @"<(.|\n)*?>", String.Empty); //webpage2 = Regex.Replace(webpage2, @"^\n*", String.Empty, RegexOptions.Singleline | RegexOptions.IgnoreCase); //webpage2 = Regex.Replace(webpage2, @"\n*$", String.Empty, RegexOptions.Singleline | RegexOptions.IgnoreCase); //webpage2 = webpage2.Replace("\n", " "); doc.LoadHtml(webpage2); // There are various options, set as needed //doc.OptionFixNestedTags = true; //doc.OptionAutoCloseOnEnd = true; //doc.OptionCheckSyntax = true; results.Temp = GetTemp(webpage2); results.TotalDiskSpace = GetTotalSpace(webpage2); results.TotalDiskSpace = results.TotalDiskSpace / 1024; results.UsedDiskSpace = GetUsedSpace(webpage2); results.UsedDiskSpace = results.UsedDiskSpace / 1024; results.UnUsedDiskSpace = GetUnUsedSpace(webpage2); results.UnUsedDiskSpace = results.UnUsedDiskSpace / 1024; if(results.TotalDiskSpace > 0) { var percentUsed = (Convert.ToDouble(results.UsedDiskSpace) / Convert.ToDouble(results.TotalDiskSpace)) * 100; results.PercentUsedDiskSpace = Convert.ToInt32(percentUsed); } } //-- logout PageLogout(args); } else if (webpage.ToLower().Contains("another party")) { results.Error = "Web page in use."; } else { results.Error = "Unknow Error."; } } catch (Exception ex) { errorMsg = ex.Message; results.Error = ex.Message; } finally { } return results; }