Ejemplo n.º 1
0
        private List <NetworkDevices> GetNetworkDevices(ManagementScope scope)
        {
            ManagementObjectSearcher   objSearcher;
            ManagementObjectCollection objColl;
            ObjectQuery           objQuery;
            List <NetworkDevices> objListOfNetworkDevices = new List <NetworkDevices>();;

            objQuery = new ObjectQuery("SELECT * FROM Win32_NetworkAdapter WHERE AdapterTypeID <> NULL");
            scope.Connect();

            objSearcher = new ManagementObjectSearcher(scope, objQuery);
            objSearcher.Options.Timeout = new TimeSpan(0, 0, 0, 0, 7000);
            objColl = objSearcher.Get();
            NetworkDevices objNetworkDevice;

            string[] ip = null;
            foreach (ManagementObject mo in objColl)
            {
                objNetworkDevice = new NetworkDevices();

                objNetworkDevice.DeviceID     = mo["DeviceID"] == null ? "Unavailble" : mo["DeviceID"].ToString();
                objNetworkDevice.Adaptertype  = mo["AdapterType"] == null ? "Unavailble" : mo["AdapterType"].ToString();
                objNetworkDevice.Description  = mo["Description"] == null ? "Unavailble" : mo["Description"].ToString();
                objNetworkDevice.MACaddress   = mo["MACAddress"] == null ? "Unavailble" : mo["MACAddress"].ToString();
                objNetworkDevice.Manufacturer = mo["Manufacturer"] == null ? "Unavailble" : mo["Manufacturer"].ToString();

                ip = GetIPAddressByMacAddress(scope, objNetworkDevice.MACaddress);
                objNetworkDevice.IPAddresses = ip;

                objListOfNetworkDevices.Add(objNetworkDevice);
            }

            return(objListOfNetworkDevices);
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     检测网卡是否选择正确
 /// </summary>
 /// <returns></returns>
 private bool CheckAdapterState()
 {
     if (GlobleSetting.Adapter.Equals("Null"))
     {
         return(false);
     }
     try
     {
         var nd      = new NetworkDevices();
         var devices = nd.GetDevices();
         if (devices != null)
         {
             if (!devices.Any(e => e.Name.Equals(GlobleSetting.Adapter)))
             {
                 return(false);
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(false);
     }
 }
Ejemplo n.º 3
0
        private void InsertNetworkDevices()
        {
            try
            {
                NetworkDevices NDObj = new NetworkDevices();
                NDObj.Address = IPTextBox.Text;
                NDObj.Name    = NameTextBox.Text;
                //UrlObj.Name = NameTextBox.Text;
                DataTable returntable = VSWebBL.ConfiguratorBL.NetworkDevicesBL.Ins.GetIPAddress(NDObj);

                if (returntable.Rows.Count > 0)
                {
                    //3/19/2014 NS modified
                    //ErrorMessageLabel.Text = "This Name or IP Address is already being monitored. Please enter another IP Address or Name.";
                    //ErrorMessagePopupControl.ShowOnPageLoad = true;
                    //10/6/2014 NS modified for VSPLUS-990
                    errorDiv.InnerHtml = "This Name or IP Address is already being monitored. Please enter another IP Address or Name." +
                                         "<button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">&times;</span><span class=\"sr-only\">Close</span></button>";
                    errorDiv.Style.Value = "display: block";
                    flag = true;
                    //IPAddressTextBox.Focus();
                }
                else
                {
                    try
                    {
                        object ReturnValue = VSWebBL.ConfiguratorBL.NetworkDevicesBL.Ins.InsertData(CollectDataForNetworkDevices());
                        SetFocusOnError(ReturnValue);
                        if (ReturnValue.ToString() == "True")
                        {
                            //3/19/2014 NS modified

                            /*
                             * ErrorMessageLabel.Text = "Network device record created successfully.";
                             * ErrorMessagePopupControl.HeaderText = "Information";
                             * ErrorMessagePopupControl.ShowCloseButton = false;
                             * ValidationUpdatedButton.Visible = true;
                             * ValidationOkButton.Visible = false;
                             * ErrorMessagePopupControl.ShowOnPageLoad = true;
                             */
                            Session["NetworkDeviceUpdateStatus"] = NameTextBox.Text;
                            Response.Redirect("NetworkDevicesGrid.aspx", false);//Mukund, 05Aug14, VSPLUS-844:Page redirect on callback
                            Context.ApplicationInstance.CompleteRequest();
                        }
                    }
                    catch (Exception ex)
                    {
                        //6/27/2014 NS added for VSPLUS-634
                        Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex);
                        throw ex;
                    }
                    finally { }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 4
0
        private NetworkDevices CollectDataForNetworkDevices()
        {
            try
            {
                //Cluster Settings
                NetworkDevices NetworkDevicesObject = new NetworkDevices();
                NetworkDevicesObject.Name               = NameTextBox.Text;
                NetworkDevicesObject.Enabled            = EnabledCheckBox.Checked;
                NetworkDevicesObject.IncludeOnDashBoard = IncludeOnDashBoardCheckBox.Checked;
                NetworkDevicesObject.Category           = CategoryTextBox.Text;
                NetworkDevicesObject.ImageURL           = Img1.Src;
                //NetworkDevicesObject.First_Alert_Threshold = int.Parse(AlertTextBox.Text);

                NetworkDevicesObject.ScanningInterval     = int.Parse(ScanIntervalTextBox.Text);
                NetworkDevicesObject.OffHoursScanInterval = int.Parse(OffScanTextBox.Text);
                //NetworkDevicesObject.Location = LocComboBox.Text; // LocationTextBox.Text;

                NetworkDevicesObject.RetryInterval     = int.Parse(RetryIntervalTextBox.Text);
                NetworkDevicesObject.ResponseThreshold = int.Parse(ResponseThrTextBox.Text);
                NetworkDevicesObject.Address           = IPTextBox.Text;
                NetworkDevicesObject.Description       = DescriptionTextBox.Text;


                Locations LOCobject = new Locations();
                LOCobject.Location = LocComboBox.Text;
                Locations ReturnLocValue = VSWebBL.SecurityBL.LocationsBL.Ins.GetDataForLocation(LOCobject);
                NetworkDevicesObject.LocationID  = ReturnLocValue.ID;
                NetworkDevicesObject.Location    = LocComboBox.Text;
                NetworkDevicesObject.NetworkType = NetworkTypeCombobox.Text.ToString();
                if (PasswordTextBox.Text != "")
                {
                    if (PasswordTextBox.Text == "      ")
                    {
                        PasswordTextBox.Text = ViewState["PWD"].ToString();
                    }

                    TripleDES tripleDES             = new TripleDES();
                    byte[]    encryptedPass         = tripleDES.Encrypt(PasswordTextBox.Text);
                    string    encryptedPassAsString = string.Join(", ", encryptedPass.Select(s => s.ToString()).ToArray());
                    NetworkDevicesObject.Password = encryptedPassAsString;
                }

                NetworkDevicesObject.Username = UserNameTextBox.Text;

                if (Mode == "Update")
                {
                    NetworkDevicesObject.ID = ServerKey;
                }
                return(NetworkDevicesObject);
            }
            catch (Exception ex)
            {
                //6/27/2014 NS added for VSPLUS-634
                Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex);
                throw ex;
            }
            finally { }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Validation before submitting data for Server tab
        /// </summary>
        /// <param name="NetworkDevicesObject"></param>
        /// <returns></returns>
        public Object ValidateDCUpdate(NetworkDevices NetworkDevicesObject)
        {
            Object ReturnValue = "";

            try
            {
                if (NetworkDevicesObject.Name == null || NetworkDevicesObject.Name == "")
                {
                    return("ER#Please enter a name");
                }
                if (NetworkDevicesObject.Location == null || NetworkDevicesObject.Location == " ")
                {
                    return("ER#Please enter the location of the device, such as '8th floor server room");
                }
                if (NetworkDevicesObject.Description == null || NetworkDevicesObject.Description == " ")
                {
                    return("ER#Please enter a description of the device, such as 'Objectionable Content Filter'");
                }

                if (NetworkDevicesObject.Category == null || NetworkDevicesObject.Category == " ")
                {
                    return("ER#Please enter Category");
                }
                if (NetworkDevicesObject.ScanningInterval.ToString() == "")
                {
                    return("ER#Please a scan Interval");
                }

                if (NetworkDevicesObject.OffHoursScanInterval.ToString() == " ")
                {
                    return("ER#Please enter an off-hours Scan Interval");
                }

                if (NetworkDevicesObject.ResponseThreshold.ToString() == "")
                {
                    return("ER#Please enter a Response Threshold, in milliseconds, over which the device will be considered 'slow'");
                }
                if (NetworkDevicesObject.RetryInterval == null)
                {
                    return("ER#Please enter a Retry Interval, to be used when the device is down.");
                }
                if (NetworkDevicesObject.Address == null)
                {
                    return("ER#Please enter the IP Address device, such as '127.0.0.1' or host name");
                }
                //if ((NetworkDevicesObject.RetryInterval) > (NetworkDevicesObject.ScanningInterval))
                //{
                //    return "ER#Please enter a Retry Interval that is less than the Scan Interval.";

                //}
            }
            catch (Exception ex)
            { throw ex; }
            finally
            { }
            return("");
        }
Ejemplo n.º 6
0
 public DataTable GetIPAddress(NetworkDevices NDObj)
 {
     try
     {
         return(VSWebDAL.ConfiguratorDAL.NetworkDevicesDAL.Ins.GetIPAddress(NDObj));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Call to Get Data from NetworkDevices based on Primary key
 /// </summary>
 /// <param name="NetworkDevicesObject">NetworkDevicesObject object</param>
 /// <returns></returns>
 public NetworkDevices GetData(NetworkDevices NetworkDevicesObject)
 {
     try
     {
         return(VSWebDAL.ConfiguratorDAL.NetworkDevicesDAL.Ins.GetData(NetworkDevicesObject));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Call DAL Delete Data
 /// </summary>
 /// <param name="DCObject"></param>
 /// <returns></returns>
 public Object DeleteData(NetworkDevices DCObject)
 {
     try
     {
         return(VSWebDAL.ConfiguratorDAL.NetworkDevicesDAL.Ins.DeleteData(DCObject));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 9
0
        public wsSQLResult InsertNewDevice(Stream JSONdataStream)
        {
            wsSQLResult result = new wsSQLResult();

            try
            {
                //Read JSON Stream into a String..
                StreamReader reader   = new StreamReader(JSONdataStream);
                string       JSONdata = reader.ReadToEnd();

                // Convert to New User record..
                JavaScriptSerializer jss       = new JavaScriptSerializer();
                NetworkDevices       netDevice = jss.Deserialize <NetworkDevices>(JSONdata);
                if (netDevice == null)
                {
                    // Error: Couldn't deserialize JSON String
                    result.WasSuccessful = 0;
                    result.Exception     = "Unable to deserialize the JSON data.";
                    return(result);
                }
                HomeNetworkDataContext dc = new HomeNetworkDataContext();
                //if (user.UserID == Convert.ToString(dc.Users_HNUs.Where(i => i.UserID == user.UserID).FirstOrDefault()))
                //{
                //    // User Already Exists
                //    return -3;
                //}

                // Insert Record to SQL Server Table
                NetworkDevices_HNND newDevice = new NetworkDevices_HNND()
                {
                    NetworkDeviceID     = netDevice.NetworkDeviceID,
                    NetworkDeviceName   = netDevice.NetworkDeviceName,
                    MacAddress          = netDevice.MacAddress,
                    IPaddress           = netDevice.IPaddress,
                    NetworkDeviceTypeID = netDevice.NetworkDeviceTypeID,
                    NetworkPorts        = netDevice.NetworkPorts,
                    LocationID          = netDevice.LocationID
                };

                dc.NetworkDevices_HNNDs.InsertOnSubmit(newDevice);
                dc.SubmitChanges();

                result.WasSuccessful = 1;
                result.Exception     = "";
                return(result);
            }
            catch (Exception ex)
            {
                result.WasSuccessful = 0;
                result.Exception     = ex.Message;
                return(result);
            }
        }
Ejemplo n.º 10
0
        public wsSQLResult UpdateNetDevice(Stream JSONdataStream)
        {
            wsSQLResult result = new wsSQLResult();

            try
            {
                //Read JSON Stream into a String..
                StreamReader reader   = new StreamReader(JSONdataStream);
                string       JSONdata = reader.ReadToEnd();

                // Convert to New User record..
                JavaScriptSerializer jss       = new JavaScriptSerializer();
                NetworkDevices       netDevice = jss.Deserialize <NetworkDevices>(JSONdata);
                if (netDevice == null)
                {
                    // Error: Couldn't deserialize JSON String
                    result.WasSuccessful = 0;
                    result.Exception     = "Unable to deserialize the JSON data.";
                    return(result);
                }
                HomeNetworkDataContext dc            = new HomeNetworkDataContext();
                NetworkDevices_HNND    currentDevice = dc.NetworkDevices_HNNDs.Where(n => n.NetworkDeviceID == netDevice.NetworkDeviceID).FirstOrDefault();
                if (currentDevice == null)
                {
                    // Couldnt Find User to Update
                    result.WasSuccessful = -3;
                    result.Exception     = "Could not find a [NetworkDevices_HNND] record with ID: " + netDevice.NetworkDeviceID.ToString();
                    return(result);
                }

                // Update Record to SQL Server Table
                currentDevice.NetworkDeviceID     = netDevice.NetworkDeviceID;
                currentDevice.NetworkDeviceName   = netDevice.NetworkDeviceName;
                currentDevice.MacAddress          = netDevice.MacAddress;
                currentDevice.IPaddress           = netDevice.IPaddress;
                currentDevice.NetworkDeviceTypeID = netDevice.NetworkDeviceTypeID;
                currentDevice.NetworkPorts        = netDevice.NetworkPorts;
                currentDevice.LocationID          = netDevice.LocationID;
                dc.SubmitChanges();

                result.WasSuccessful = 1;
                result.Exception     = "";
                return(result);  //Success
            }
            catch (Exception ex)
            {
                result.WasSuccessful = -1;
                result.Exception     = "An exception occurred: " + ex.Message;
                return(result);  //Failed
            }
        }
Ejemplo n.º 11
0
        protected void NetworkDevicesGridView_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            NetworkDevices DCObject = new NetworkDevices();

            DCObject.ID = Convert.ToInt32(e.Keys[0]);
            //Delete row from DB
            Object ReturnValue = VSWebBL.ConfiguratorBL.NetworkDevicesBL.Ins.DeleteData(DCObject);

            //Update Grid after inserting new row, refresh grid as in page load
            ASPxGridView gridView = (ASPxGridView)sender;

            gridView.CancelEdit();
            e.Cancel = true;
            FillNetworkDevicesGrid();
        }
Ejemplo n.º 12
0
        //delete Data from NetworkDevices Table

        public Object DeleteData(NetworkDevices NDObject)
        {
            Object Update;

            try
            {
                string SqlQuery = "Delete [Network Devices] Where ID=" + NDObject.ID;

                Update = objAdaptor.ExecuteNonQuery(SqlQuery);
            }
            catch
            {
                Update = false;
            }
            finally
            {
            }
            return(Update);
        }
Ejemplo n.º 13
0
        public DataTable GetAllData()
        {
            DataTable      NetworkDevicesDataTable = new DataTable();
            NetworkDevices ReturnObject            = new NetworkDevices();

            try
            {
                string SqlQuery = "select * from [Network Devices]";

                NetworkDevicesDataTable = objAdaptor.FetchData(SqlQuery);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }
            return(NetworkDevicesDataTable);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Call to Update Data of DominoServers based on Key
        /// </summary>
        /// <param name="NetworkDevicesObject">DominoServers object</param>
        /// <returns>Object</returns>
        public Object UpdateData(NetworkDevices NetworkDevicesObject)
        {
            Object ReturnValue = ValidateDCUpdate(NetworkDevicesObject);

            try
            {
                if (ReturnValue.ToString() == "")
                {
                    return(VSWebDAL.ConfiguratorDAL.NetworkDevicesDAL.Ins.UpdateData(NetworkDevicesObject));
                }
                else
                {
                    return(ReturnValue);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Insert data into NetworkDevices table
        /// </summary>
        /// <param name="DSObject">DominoServers object</param>
        /// <returns></returns>

        public bool InsertData(NetworkDevices NDObject)
        {
            bool Insert = false;

            try
            {
                DataTable NetworkDevicesDataTable = new DataTable();
                string    SqlQuery = "select ID from servertypes where servertype='Network Device'";
                NetworkDevicesDataTable = objAdaptor.FetchData(SqlQuery);
                if (NetworkDevicesDataTable.Rows.Count > 0)
                {
                    NDObject.ServerTypeId = int.Parse(NetworkDevicesDataTable.Rows[0][0].ToString());
                }
                SqlQuery = "INSERT INTO [Network Devices] (Description,Category,Port,Username,Password,[Scanning Interval]" +
                           ",OffHoursScanInterval,Enabled,IncludeOnDashBoard,Location,Name,ResponseThreshold,RetryInterval,Address,LocationID,ImageURL,ServerTypeId,NetworkType) " +
                           "VALUES('" + NDObject.Description + "','" + NDObject.Category + "'," + NDObject.Port + ",'" + NDObject.Username + "','" + NDObject.Password +
                           "'," + NDObject.ScanningInterval + "," + NDObject.OffHoursScanInterval + ",'" + NDObject.Enabled +
                           "','" + NDObject.IncludeOnDashBoard + "', '" + NDObject.Location + "','" + NDObject.Name + "'," + NDObject.ResponseThreshold + "," + NDObject.RetryInterval + ",'" + NDObject.Address +
                           "'," + NDObject.LocationID + ",'" + NDObject.ImageURL + "'," + NDObject.ServerTypeId + ",'" + NDObject.NetworkType + "')";
                //SqlQuery = "INSERT INTO [Network Devices] (Description,Category,Port,Username,Password,[Scanning Interval]" +
                //   ",OffHoursScanInterval,Enabled,Location,ImageURL,Name,ResponseThreshold,RetryInterval,Address,LocationID,ServerTypeId) " +
                //   "VALUES('" + NDObject.Description + "','" + NDObject.Category + "'," + NDObject.Port + ",'"+NDObject.Username+"','" + NDObject.Password +
                //   "'," + NDObject.ScanningInterval + "," + NDObject.OffHoursScanInterval + ",'" + NDObject.Enabled +
                //   "','" + NDObject.Location + "','" + NDObject.ImageURL + "', '" + NDObject.Name + "'," + NDObject.ResponseThreshold + "," + NDObject.RetryInterval + ",'" + NDObject.Address +
                //   "'," + NDObject.LocationID + "," + NDObject.ServerTypeId + ")";


                Insert = objAdaptor.ExecuteNonQuery(SqlQuery);
            }
            catch
            {
                Insert = false;
            }
            finally
            {
            }
            return(Insert);
        }
Ejemplo n.º 16
0
 /// <summary>
 ///     读取可用的网卡列表
 /// </summary>
 private void ReadAdapterList()
 {
     try
     {
         var nd      = new NetworkDevices();
         var devices = nd.GetDevices();
         if (devices != null)
         {
             /*
              * foreach (DevicesData device in devices)
              * {
              *  adapterList.Items.Add(device);
              * }
              * */
             adapterList.DataSource = devices;
             if (GlobleSetting.Adapter.Equals("Null"))
             {
                 //如果为设置网卡,则默认选取第一个
                 adapterList.SelectedIndex = -1;
             }
             else
             {
                 if (devices.Any(e => e.Name.Equals(GlobleSetting.Adapter)))
                 {
                     adapterList.SelectedValue = GlobleSetting.Adapter;
                 }
                 else
                 {
                     adapterList.SelectedIndex = -1;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 17
0
        public DataTable GetIPAddress(NetworkDevices NDObj)
        {
            //SametimeServers SametimeObj = new SametimeServers();
            DataTable NDTable = new DataTable();

            try
            {
                if (NDObj.ID == 0)
                {
                    string sqlQuery = "Select * from [Network Devices] where Address='" + NDObj.Address + "' or Name='" + NDObj.Name + "' ";
                    NDTable = objAdaptor.FetchData(sqlQuery);
                }
                else
                {
                    string sqlQuery = "Select * from [Network Devices] where (Address='" + NDObj.Address + "' or Name='" + NDObj.Name + "')and ID<>" + NDObj.ID + " ";
                    NDTable = objAdaptor.FetchData(sqlQuery);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(NDTable);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Update data into NetworkDevices table
        /// </summary>
        /// <param name="DSObject">DominoServers object</param>
        /// <returns></returns>
        public Object UpdateData(NetworkDevices NDObject)
        {
            Object Update;

            try
            {
                string SqlQuery = "UPDATE [Network Devices] SET Description='" + NDObject.Description + "',Category='" + NDObject.Category +
                                  "',Port=" + NDObject.Port + ",Username='******',Password='******',[Scanning Interval]=" +
                                  NDObject.ScanningInterval + ",OffHoursScanInterval=" + NDObject.OffHoursScanInterval + ",Enabled='" + NDObject.Enabled +
                                  "', IncludeOnDashBoard='" + NDObject.IncludeOnDashBoard + "',  Location='" + NDObject.Location + "',ImageURL='" + NDObject.ImageURL + "', Name='" + NDObject.Name + "',ResponseThreshold=" + NDObject.ResponseThreshold +
                                  ",RetryInterval=" + NDObject.RetryInterval + ",Address='" + NDObject.Address + "',LocationID=" + NDObject.LocationID + ",NetworkType='" + NDObject.NetworkType + "'" +
                                  " where [ID]=" + NDObject.ID + "";

                Update = objAdaptor.ExecuteNonQuery(SqlQuery);
            }
            catch
            {
                Update = false;
            }
            finally
            {
            }
            return(Update);
        }
Ejemplo n.º 19
0
        private void FillData(int ID)
        {
            try
            {
                string         MyObjPwd;
                string[]       MyObjPwdArr;
                byte[]         MyPass;
                NetworkDevices NetworkDevicesObject = new NetworkDevices();
                NetworkDevices ReturnObject         = new NetworkDevices();
                NetworkDevicesObject.ID = ID;

                ReturnObject                       = VSWebBL.ConfiguratorBL.NetworkDevicesBL.Ins.GetData(NetworkDevicesObject);
                NameTextBox.Text                   = ReturnObject.Name;
                IPTextBox.Text                     = ReturnObject.Address;
                DescriptionTextBox.Text            = ReturnObject.Description;
                CategoryTextBox.Text               = ReturnObject.Category;
                EnabledCheckBox.Checked            = ReturnObject.Enabled;
                IncludeOnDashBoardCheckBox.Checked = ReturnObject.IncludeOnDashBoard;
                LocComboBox.Text                   = ReturnObject.Location;
                Img1.Src = ReturnObject.ImageURL;
                //if (Img1.Src != null)
                //{
                //    checkbx.Checked = true;

                //}
                //if (checkbx.Checked)
                //{
                CredentialsComboBox.Visible = true;
                //}
                CredentialsComboBox.Text = ReturnObject.imagename;

                //// LocationTextBox.Text = ReturnObject.Location;
                ScanIntervalTextBox.Text  = ReturnObject.ScanningInterval.ToString();
                OffScanTextBox.Text       = ReturnObject.OffHoursScanInterval.ToString();
                RetryIntervalTextBox.Text = ReturnObject.RetryInterval.ToString();
                ResponseThrTextBox.Text   = ReturnObject.ResponseThreshold.ToString();
                NetworkTypeCombobox.Text  = ReturnObject.NetworkType == null ? "" : ReturnObject.NetworkType.ToString();

                UserNameTextBox.Text = ReturnObject.Username == null ? "" : ReturnObject.Username;
                PasswordTextBox.Text = ReturnObject.Password == null ? "" : ReturnObject.Password;
                if (PasswordTextBox.Text != "" && PasswordTextBox.Text != null)
                {
                    PasswordTextBox.Text = "      ";
                }
                else
                {
                    PasswordTextBox.Text = "";
                }

                MyObjPwd = ReturnObject.Password == null ? "" : ReturnObject.Password;
                //if (MyObjPwd != "")
                //{
                //    MyObjPwdArr = MyObjPwd.Split(',');
                //    MyPass = new byte[MyObjPwdArr.Length];
                //    for (int j = 0; j < MyObjPwdArr.Length; j++)
                //    {
                //        MyPass[j] = Byte.Parse(MyObjPwdArr[j]);
                //    }
                //    ViewState["PWD"] = tripleDes.Decrypt(MyPass);
                //}


                if (MyObjPwd != "")
                {
                    MyObjPwdArr = MyObjPwd.Split(',');
                    MyPass      = new byte[MyObjPwdArr.Length];

                    try
                    {
                        for (int j = 0; j < MyObjPwdArr.Length; j++)
                        {
                            MyPass[j] = Byte.Parse(MyObjPwdArr[j]);
                        }
                        ViewState["PWD"] = tripleDes.Decrypt(MyPass);
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message == "Input string was not in a correct format.")
                        {
                            ViewState["PWD"] = MyObjPwd;
                        }
                    }
                }



                //TripleDES tripleDES = new TripleDES();
                //byte[] encryptedPass=  ReturnObject.Password;
                //string pwd = tripleDES.Decrypt(encryptedPass);
                //PasswordTextBox.Text = pwd;
                //PasswordTextBox.Attributes.Add("value",ReturnObject.Password.ToString());
            }
            catch (Exception ex)
            {
                //6/27/2014 NS added for VSPLUS-634
                Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex);
                throw ex;
            }
            finally { }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Get Data from NetworkDevices based on Key
        /// </summary>
        public NetworkDevices GetData(NetworkDevices DCObject)
        {
            DataTable      NetworkDevicesDataTable = new DataTable();
            NetworkDevices ReturnObject            = new NetworkDevices();

            try
            {
                string SqlQuery = "Select nd.*,t2.Location as LocationText,nm.Name as imagename from [Network Devices] nd  INNER JOIN [Locations] t2 ON nd.[LocationID] = t2.[ID] Inner join NetworkMaster nm on nd.ImageURL=nm.Image  where nd.ID=" + DCObject.ID.ToString();
                NetworkDevicesDataTable = objAdaptor.FetchData(SqlQuery);
                //populate & return data object
                if (NetworkDevicesDataTable.Rows.Count > 0)
                {
                    ReturnObject.ImageURL   = NetworkDevicesDataTable.Rows[0]["ImageURL"].ToString();
                    ReturnObject.imagename  = NetworkDevicesDataTable.Rows[0]["imagename"].ToString();
                    ReturnObject.Password   = NetworkDevicesDataTable.Rows[0]["Password"].ToString();
                    ReturnObject.Location   = NetworkDevicesDataTable.Rows[0]["Location"].ToString();
                    ReturnObject.LocationID = int.Parse(NetworkDevicesDataTable.Rows[0]["LocationID"].ToString());
                    if (NetworkDevicesDataTable.Rows[0]["Port"].ToString() != "")
                    {
                        ReturnObject.Port = int.Parse(NetworkDevicesDataTable.Rows[0]["Port"].ToString());
                    }
                    if (NetworkDevicesDataTable.Rows[0]["ResponseThreshold"].ToString() != "")
                    {
                        ReturnObject.ResponseThreshold = int.Parse(NetworkDevicesDataTable.Rows[0]["ResponseThreshold"].ToString());
                    }
                    ReturnObject.Username    = NetworkDevicesDataTable.Rows[0]["Username"].ToString();
                    ReturnObject.Description = NetworkDevicesDataTable.Rows[0]["Description"].ToString();
                    ReturnObject.Address     = NetworkDevicesDataTable.Rows[0]["Address"].ToString();
                    ReturnObject.Category    = NetworkDevicesDataTable.Rows[0]["Category"].ToString();
                    if (NetworkDevicesDataTable.Rows[0]["Enabled"].ToString() != "")
                    {
                        ReturnObject.Enabled = bool.Parse(NetworkDevicesDataTable.Rows[0]["Enabled"].ToString());
                    }
                    if (NetworkDevicesDataTable.Rows[0]["IncludeOnDashBoard"].ToString() != "")
                    {
                        ReturnObject.IncludeOnDashBoard = bool.Parse(NetworkDevicesDataTable.Rows[0]["IncludeOnDashBoard"].ToString());
                    }

                    ReturnObject.Name = NetworkDevicesDataTable.Rows[0]["Name"].ToString();
                    if (NetworkDevicesDataTable.Rows[0]["Scanning Interval"].ToString() != "")
                    {
                        ReturnObject.ScanningInterval = int.Parse(NetworkDevicesDataTable.Rows[0]["Scanning Interval"].ToString());
                    }
                    if (NetworkDevicesDataTable.Rows[0]["OffHoursScanInterval"].ToString() != "")
                    {
                        ReturnObject.OffHoursScanInterval = int.Parse(NetworkDevicesDataTable.Rows[0]["OffHoursScanInterval"].ToString());
                    }
                    if (NetworkDevicesDataTable.Rows[0]["RetryInterval"].ToString() != "")
                    {
                        ReturnObject.RetryInterval = int.Parse(NetworkDevicesDataTable.Rows[0]["RetryInterval"].ToString());
                    }

                    ReturnObject.NetworkType = NetworkDevicesDataTable.Rows[0]["NetworkType"].ToString();
                }
            }
            catch
            {
            }
            finally
            {
            }
            return(ReturnObject);
        }