/// <summary> /// Starts the discovery. /// </summary> /// <param name="mfpDiscoverer">MFP discoverer.</param> /// <remarks> /// Sequence Diagram:<br/> /// <img src="SequenceDiagrams/SD_PrintRoverWeb.Administration.DiscoverDevices.StartDiscovery.jpg"/> /// </remarks> private void StartDiscovery(object mfpDiscoverer) { MFPDiscoverer mfpDiscovery = mfpDiscoverer as MFPDiscoverer; //Initialize Session Variable Session[PROCESS_NAME] = false; try { if (RadioButtonDevicesInSubnet.Checked) { mfpDiscovery.DiscoverMfpsAsync(); } else if (RadioButtonDeviceByIP.Checked) { string deviceIP = TextBoxIPAddress.Text; string hostName = string.Empty; if (!ValidateUserInput()) { hostName = GetIpFromHost(TextBoxIPAddress.Text); if (!string.IsNullOrEmpty(hostName)) { if (!ValidateUserInput(hostName)) { mfpDiscovery.DiscoverMfpAsync(deviceIP); } else { mfpDiscovery.DiscoverMfpAsync(hostName); } } } else { mfpDiscovery.DiscoverMfpAsync(deviceIP); } } else if (RadioButtonByIPRange.Checked) { string devicestartIP = TextBoxStartIP.Text; string devicestartEndIP = TextBoxEndIP.Text; // Validate IP Addresses bool isVlaidFromIPAddress = IsValidIPAddress(devicestartIP); bool isVlaidToIPAddress = IsValidIPAddress(devicestartEndIP); mfpDiscovery.DiscoveryMode = MFPDiscoverer.DiscoveryType.SNMP; mfpDiscovery.DiscoverMfpsAsync(devicestartIP, devicestartEndIP); } } catch (Exception exceptionMessage) { } }
private void StartDeviceDiscovery() { string hostName = string.Empty; if (!ValidateUserInput()) { hostName = GetIpFromHost(TextBoxIPAddress.Text); if (!string.IsNullOrEmpty(hostName)) { if (!ValidateUserInput(hostName)) { string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "ENTER_VALID_IP"); GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Warning.ToString(), serverMessage, null); return; } } } if (RadioButtonByIPRange.Checked) { if (!CompareIP()) { string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "END_IP_GREATER"); GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Warning.ToString(), serverMessage, null); return; } } mfpDiscoverer = new MFPDiscoverer(); if (mfpDiscoverer.Initialize()) { mfpDiscoverer.MfpDiscovered += new EventHandler <MfpDiscoveredEventArgs>(OnMfpDiscovered); mfpDiscoverer.DiscoverMfpsAsyncCompleted += new EventHandler <EventArgs>(DiscoverMfpsAsyncCompleted); } //Create and initialize new thread with the address of the StartLongProcess function Thread thread = new Thread(new ParameterizedThreadStart(StartDiscovery)); //Start thread thread.Start(mfpDiscoverer); //Pass redirect page and session var name to the process wait (interum) page Response.Redirect("DiscoveryStatus.aspx?redirectPage=ManageDevice.aspx&ProcessSessionName=" + PROCESS_NAME); }