private static Dictionary <string, CService> GetSCVMMServers() { // find SCVMM SPN in AD SearchResultCollection QueryResult = null; Dictionary <string, CService> ServersFound = new Dictionary <string, CService> { }; QueryResult = QueryActiveDirectory(_DomainName, "(&(cn=MSVMM)(objectClass=serviceConnectionPoint))", new List <string> { "servicednsname" }); if (QueryResult != null) { // store previous results -- to avoid duplicate service connections string lastResult = ""; string log = ""; if (QueryResult.Count > 0) { log += "SCVMM servers {"; } for (int i = 0; i < QueryResult.Count; i++) { string thisResult = QueryResult[i].Properties["servicednsname"][0].ToString(); if (thisResult != lastResult) { CService s = new CService(thisResult, CServiceType.SCVMMServer); if (s.IP != null) { ServersFound.Add(s.Name + ";" + s.Type.ToString(), s); log += s.Name + ", " + s.IP + "; "; } lastResult = thisResult; } } Log.Write(log + "}", Log.Verbosity.Verbose); } return(ServersFound); }
private static Dictionary <string, CService> GetVCenterServersUsingSCP() { Dictionary <string, CService> ServersFound = new Dictionary <string, CService> { }; SearchResultCollection QueryResult = null; QueryResult = QueryActiveDirectory(_DomainName, "(&(objectClass=serviceConnectionPoint)(keywords=instance:VMwareVCMSDS))", new List <string> { "servicednsname" }); if (QueryResult != null) { for (int i = 0; i < QueryResult.Count; i++) { string thisResult = QueryResult[i].Properties["servicednsname"][0].ToString(); if (!ServersFound.ContainsKey(thisResult + ";" + (new CServiceType(CServiceType.VCenterServer)).ToString())) { CService s = new CService(thisResult, CServiceType.VCenterServer); if (s.IP != null) { ServersFound.Add(s.Name + ";" + s.Type.ToString(), s); } } } } return(ServersFound); }
/// <summary> /// US:1951 method /// loads the checklist's service drop down list /// </summary> /// <returns></returns> protected CStatus LoadChecklistDDLs() { if (ddlCLService.Items.Count < 1) { CStatus status = CService.LoadServiceDDL( BaseMstr.BaseData, k_ACTIVE_ID.Active, ddlCLService); if (!status.Status) { return(status); } } if (ddlClinics.Items.Count < 1) { CStatus status = CClinic.LoadClinicDLL(BaseMstr.BaseData, ddlClinics); if (!status.Status) { return(status); } } return(new CStatus()); }
public Dictionary <string, CService> GetDomainServers() { SearchResultCollection QueryResult = null; Dictionary <string, CService> ServersFound = new Dictionary <string, CService> { }; QueryResult = QueryActiveDirectory("OU=Domain Controllers," + rootDSE.Properties["defaultNamingContext"].Value.ToString(), "(objectClass=Computer)", new List <string> { "dnshostname" }); if (QueryResult != null) { for (int i = 0; i < QueryResult.Count; i++) { string thisResult = QueryResult[i].Properties["dnshostname"][0].ToString(); if (!ServersFound.ContainsKey(thisResult)) { CService service = new CService(thisResult, CServiceType.DomainServer); if (service.IP != null) { ServersFound.Add(thisResult, service); } } } } return(ServersFound); }
private Dictionary <string, CService> GetVCenterAppliancesUsingLikewise() { Dictionary <string, CService> ServersFound = new Dictionary <string, CService> { }; SearchResultCollection QueryResult = null; QueryResult = QueryActiveDirectory(_DomainName, "(&(objectClass=Computer)(operatingSystemServicePack=Likewise Open unknown.unknown.unknown))", new List <string> { "dnshostname" }); if (QueryResult != null) { for (int i = 0; i < QueryResult.Count; i++) { string thisResult = QueryResult[i].Properties["dnshostname"][0].ToString(); if (!ServersFound.ContainsKey(thisResult + ";" + (new CServiceType(CServiceType.VCenterServer)).ToString())) { CService s = new CService(thisResult, CServiceType.VCenterServer); if (s.IP != null) { ServersFound.Add(s.Name + ";" + s.Type.ToString(), s); } } } } return(ServersFound); }
private Dictionary <string, CService> GetHyperVServers() { SearchResultCollection QueryResult = null; Dictionary <string, CService> ServersFound = new Dictionary <string, CService> { }; QueryResult = QueryActiveDirectory(_DomainName, "(&(objectClass=Computer)(servicePrincipalName=Hyper-V*))", new List <string> { "dnshostname" }); if (QueryResult != null) { string log = ""; if (QueryResult.Count > 0) { log += "Hyper-V servers {"; } for (int i = 0; i < QueryResult.Count; i++) { string thisResult = QueryResult[i].Properties["dnshostname"][0].ToString(); if (!ServersFound.ContainsKey(thisResult)) { CService s = new CService(thisResult, CServiceType.HYVServer); if (s.IP != null) { ServersFound.Add(s.Name + ";" + s.Type.ToString(), s); log += s.Name + ", " + s.IP + "; "; } } } Log.Write(log + "}", Log.Verbosity.Verbose); } return(ServersFound); }
private void AddGroupingInfo(CService server, CDiscoveredConfig oc) { if (server.Type == CServiceType.VCenterServer) { _AddGroupingInfo(server, server.Name, CDiscoveredTypes.VCenterServer, server.Id, server.Id); string dc = oc.Attributes.Get(CAttributeType.Datacenter).ToStringNz(); string cl = oc.Attributes.Get(CAttributeType.Cluster).ToStringNz(); string dcid = _AddGroupingInfo(server, dc, CDiscoveredTypes.VIDatacenter, server.Id); string clid = _AddGroupingInfo(server, cl, CDiscoveredTypes.VICluster, dcid); } if (server.Type == CServiceType.HYVServer) { string cl = oc.Attributes.Get(CAttributeType.Cluster).ToStringNz(); if (cl.Length > 0) { string clid = _AddGroupingInfo(server, cl, CDiscoveredTypes.HVCluster, "", ""); } else { string hostid = _AddGroupingInfo(server, server.Name, CDiscoveredTypes.HVHost, server.Id, server.Id); } } if (server.Type == CServiceType.ESXServer) { string hostid = _AddGroupingInfo(server, server.Name, CDiscoveredTypes.VIHost, server.Id, server.Id); } _AddGroupingInfo(server, oc.Site.ToStringNz(), CDiscoveredTypes.Site, server.Id); }
static void Main(string[] args) { try { Console.WriteLine("Lets create an array to work with!"); var arrayCount = CService.GetInt(); var values = CDataProvider.CreateDifferentSizedValues(arrayCount); Console.WriteLine("Original array"); foreach (var val in values) { Console.WriteLine(val); } var result = CInteractor.GetValuesLengthExceedIndex(values); Console.WriteLine("Result"); foreach (var val in result) { Console.WriteLine(val); } } catch (Exception e) { Console.WriteLine(e.Message); } Console.ReadLine(); }
public List <INamed> GetData() { var path = "./../../../LinqLabLib/Source/Countries.txt"; List <INamed> objects = CService.ReadFromTextFile(path); return(objects); }
private static List <CService> GetSCOMServers() { // find SCVMM SPN in AD SearchResultCollection QueryResult = null; List <CService> ServersFound = new List <CService> { }; QueryResult = QueryActiveDirectory(_DomainName, "(servicePrincipalName=MSOMHSvc*)", new List <string> { "dnshostname" }); if (QueryResult != null) { // store previous results -- to avoid duplicate service connections string lastResult = ""; for (int i = 0; i < QueryResult.Count; i++) { string thisResult = QueryResult[i].Properties["dnshostname"][0].ToString(); if (thisResult != lastResult) { CService service = new CService(thisResult, CServiceType.SCOMServer); if (service.IP != null) { ServersFound.Add(service); } lastResult = thisResult; } } } return(ServersFound); }
public string _AddGroupingInfo(CService server, string name, int type, string parent, string id = "") { if (!DiscoveredGroups.ContainsKey(name)) { if (id != null && id == parent) { parent = ""; } // object = parent: so parent may as well be empty DiscoveredGroups.Add(name, new CDiscoveredConfig() { Name = name, Type = type, Owner = new List <string> { parent } }); if (id != null && id != "") { DiscoveredGroups[name].Id = id; } // if id is specified specifically set this for the group if (DiscoveredGroups[name].Attributes == null) { DiscoveredGroups[name].Attributes = new CDiscoveredAttributes(); } if (DiscoveredGroups[name].Metrics == null) { DiscoveredGroups[name].Metrics = new CDiscoveredMetrics(); } if (type == CDiscoveredTypes.Site) { CSite obj = DiscoveredSites.Find(x => x.Name.Equals(name)); if (obj != null) { DiscoveredGroups[name].Attributes.Set(CAttributeType.Details, obj.Description.ToStringNz()); DiscoveredGroups[name].Attributes.Set(CAttributeType.Path, obj.Path.ToStringNz()); DiscoveredGroups[name].Attributes.Set(CAttributeType.Location, obj.Location.ToStringNz()); DiscoveredGroups[name].Attributes.Set(CAttributeType.Subnets, CFunctions.StringJoin(";", obj.Subnets)); } } else if ((type == CDiscoveredTypes.VICluster)) { if (DiscoveredGroups.ContainsKey(server.Name)) { DiscoveredGroups[server.Name].Metrics.Increment(CMetricType.ClCount, 1); } } else if ((type == CDiscoveredTypes.HVCluster)) { DiscoveredGroups[name].Metrics.Increment(CMetricType.ClCount, 1); } else if ((type == CDiscoveredTypes.VIDatacenter) || (type == CDiscoveredTypes.HVDatacenter)) { if (DiscoveredGroups.ContainsKey(server.Name)) { DiscoveredGroups[server.Name].Metrics.Increment(CMetricType.DcCount, 1); } } return(DiscoveredGroups[name].Id); } return(null); }
private void selectService_Load(object sender, EventArgs e) { Connection connection = new Connection(); connection.openConnection(); OleDbCommand getServices = new OleDbCommand(); getServices.Connection = connection.connection; getServices.CommandText = "SELECT * FROM Services"; OleDbDataReader servicesReader = getServices.ExecuteReader(); while (servicesReader.Read()) { string id = servicesReader[0].ToString(); string name = servicesReader[1].ToString(); string price = servicesReader[2].ToString(); CService tmpSerice = new CService(id, name, float.Parse(price)); servicesList.Items.Add(tmpSerice); } OleDbCommand getEmployees = new OleDbCommand(); getEmployees.Connection = connection.connection; getEmployees.CommandText = "SELECT * FROM Employees"; OleDbDataReader employeesReader = getEmployees.ExecuteReader(); while (employeesReader.Read()) { string id = employeesReader[0].ToString(); string first_name = employeesReader[1].ToString(); string last_name = employeesReader[2].ToString(); string address = employeesReader[3].ToString(); string phone = employeesReader[4].ToString(); DateTime birthday = (DateTime)employeesReader[5]; DateTime dayOfEmploymend = (DateTime)employeesReader[6]; bool fired = (bool)employeesReader[7]; CEmployee tmpEmployee = new CEmployee(id, first_name, last_name, address, phone, birthday, dayOfEmploymend, fired); if (!fired) { employeesList.Items.Add(tmpEmployee); } } connection.closeConnection(); if (servicesList.Items.Count == 0) { doneBtn.Enabled = false; employeesList.Enabled = false; } else { servicesList.SelectedIndex = 0; } }
private void btnServer_Click(object sender, EventArgs e) { try { btnServer.Enabled = false; string er = string.Empty; if (_service == null) { _service = new CService(0, "Service", CNet.HostName(), "HOST", txtSetFactory.Text); if (!_service.Connect(txtSerIP.Text, System.Convert.ToInt32(txtSerPort.Text), out er)) { ShowServiceStatus(er, true); _service = null; return; } _service.OnMessageArgs.OnEvent += new COnEvent <CService.CCMessageArgs> .OnEventHandler(OnServiceRecieve); _service.OnStatusArgs.OnEvent += new COnEvent <CService.CStatusArgs> .OnEventHandler(OnServiceStatus); _service.OnRPTCmdArgs.OnEvent += new COnEvent <CService.CCmdArgs> .OnEventHandler(OnServiceRPTCmd); _service.OnREQCmdArgs.OnEvent += new COnEvent <CService.CCmdArgs> .OnEventHandler(OnServiceREQCmd); ShowServiceStatus("连接服务端正常", false); btnServer.Text = "断开"; btnServer.ImageKey = "Connect"; btnServerCmd.Enabled = true; } else { _service.OnMessageArgs.OnEvent -= new COnEvent <CService.CCMessageArgs> .OnEventHandler(OnServiceRecieve); _service.OnStatusArgs.OnEvent -= new COnEvent <CService.CStatusArgs> .OnEventHandler(OnServiceStatus); _service.OnRPTCmdArgs.OnEvent -= new COnEvent <CService.CCmdArgs> .OnEventHandler(OnServiceRPTCmd); _service.OnREQCmdArgs.OnEvent -= new COnEvent <CService.CCmdArgs> .OnEventHandler(OnServiceREQCmd); _service.Close(); _service = null; ShowServiceStatus("断开服务端", false); btnServer.ImageKey = "DisConnect"; btnServer.Text = "连接"; btnServerCmd.Enabled = false; } } catch (Exception ex) { btnServer = null; ShowServiceStatus(ex.ToString(), false); } finally { SaveIniFile(); btnServer.Enabled = true; } }
private void packageForm_Load(object sender, EventArgs e) { connection.openConnection(); OleDbCommand getServices = new OleDbCommand(); getServices.Connection = connection.connection; getServices.CommandText = "SELECT * FROM Services"; OleDbDataReader servicesReader = getServices.ExecuteReader(); while (servicesReader.Read()) { string id = servicesReader[0].ToString(); string name = servicesReader[1].ToString(); string price = servicesReader[2].ToString(); CService tmpService = new CService(id, name, float.Parse(price)); servicesList.Items.Add(tmpService); } connection.closeConnection(); if (edit) { nameTxt.Text = package.name; priceTxt.Text = package.price.ToString(); for (int i = 0; i < package.services.Count; i++) { addedSerivesList.Items.Add(package.services[i]); for (int j = 0; j < servicesList.Items.Count; j++) { CService tmpService = servicesList.Items[j] as CService; if (package.services[i].id.Equals(tmpService.id)) { servicesList.Items.RemoveAt(j); } } } if (servicesList.Items.Count == 0) { addToPackageBtn.Enabled = false; } else { servicesList.SelectedIndex = 0; } removeFromPackageBtn.Enabled = true; } else { removeFromPackageBtn.Enabled = false; servicesList.SelectedIndex = 0; } }
private bool SaveChanges() { bool saved = false; Cursor PreviousCursor = Mouse.OverrideCursor; Mouse.OverrideCursor = Cursors.Wait; if (ObjectSelection != null && Mode == Modes.Edit) { if (ObjectSelection.Count() > 1) { foreach (CService server in ObjectSelection) { server.UserName = tbUsername.Text.Trim(); server.UserPassword = pbPassword.Password; } saved = true; } else { foreach (CService server in ObjectSelection) { // actually only runs once CService ModifiedObject = new CService(tbServiceName.Text.Trim(), (int)(new CServiceType(cbServiceType.Text)), tbUsername.Text.Trim(), pbPassword.Password); bool unique; if (server.Name == tbServiceName.Text.Trim()) { unique = true; } // object name has not changed else { unique = ObjectUnique(ModifiedObject); } // if name has changed check if it still is unique if (ObjectValidates(ModifiedObject) && unique) { server.Name = tbServiceName.Text.Trim(); //server.IP = ModifiedObject.IP; // should self-resolve server.Type = new CServiceType(cbServiceType.Text); server.UserName = ModifiedObject.UserName; server.UserPassword = ModifiedObject.UserPassword; } saved = true; } } } else { CService NewObject = new CService(tbServiceName.Text, (int)(new CServiceType(cbServiceType.Text)), tbUsername.Text, pbPassword.Password); if (ObjectValidates(NewObject) && ObjectUnique(NewObject)) { ObjectCollection.Add(NewObject); saved = true; } } Mouse.OverrideCursor = PreviousCursor; return(saved); }
public void ShouldReadFromFile() { //Arrange String _path = "./../../Countries.txt"; //Act List <INamed> returnedArray = CService.ReadFromTextFile(_path); //Assert Assert.IsTrue(returnedArray.Count == 240); }
private void servicesList_SelectedIndexChanged(object sender, EventArgs e) { if (service != null) { service.employee = null; } service = servicesList.SelectedItem as CService; employeesList.SelectedIndex = -1; }
public void ShouldConcatinate() { //Arrange String _path = "./../../Countries.txt"; List <INamed> returnedArray = CService.ReadFromTextFile(_path); //Act IEnumerable <INamed> result = CInteractor_2.GetConcatinate(returnedArray.Take(100), returnedArray.Skip(100)); //Assert Assert.IsTrue(result.Count() == 240); }
public void ShouldPerformFiltrationByName() { //Arrange String _path = "./../../Countries.txt"; List <INamed> returnedArray = CService.ReadFromTextFile(_path); //Act IEnumerable <INamed> objects = CInteractor_1.GetFilteredByName(returnedArray, "a"); //Assert Assert.IsTrue(objects.Count() == 16); }
private void removeFromPackageBtn_Click(object sender, EventArgs e) { CService tmpService = addedSerivesList.SelectedItem as CService; servicesList.Items.Add(tmpService); addedSerivesList.Items.Remove(tmpService); addToPackageBtn.Enabled = true; if (addedSerivesList.Items.Count == 0) { removeFromPackageBtn.Enabled = false; } }
public void ShouldPerformSelectionByName() { //Arrange String _path = "./../../Countries.txt"; List <INamed> returnedArray = CService.ReadFromTextFile(_path); //Act IEnumerable <String> names = CInteractor_1.SelectNames(returnedArray); //Assert Assert.AreEqual(names.First(), "AALAND ISLANDS"); Assert.AreEqual(names.Last(), "ZIMBABWE"); }
public void ShouldPerformSelectionByCodeNumber() { //Arrange String _path = "./../../Countries.txt"; List <INamed> returnedArray = CService.ReadFromTextFile(_path); //Act IEnumerable <String> codes = CInteractor_1.SelectNumerics(returnedArray); //Assert Assert.AreEqual(codes.First(), "248"); Assert.AreEqual(codes.Last(), "716"); }
public void ShouldPerformOrderingByNameLengthAndCodeNumber() { //Arrange String _path = "./../../Countries.txt"; List <INamed> returnedArray = CService.ReadFromTextFile(_path); //Act IEnumerable <INamed> objects = CInteractor_1.GetOrderedByNameLengthAndNum(returnedArray); //Assert Assert.AreEqual(objects.First().Name, "CHAD"); Assert.AreEqual(objects.Last().Name, "SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS"); }
private void servicesList_SelectedIndexChanged(object sender, EventArgs e) { CService tmpService = servicesList.SelectedItem as CService; if (tmpService.employee != null) { employeeList.SelectedItem = tmpService.employee; } else { employeeList.SelectedIndex = -1; } }
public void ShouldGroupingByLastNumOfCode() { //Arrange String _path = "./../../Countries.txt"; List <INamed> returnedArray = CService.ReadFromTextFile(_path); //Act IEnumerable <IGrouping <Char, INamed> > result = CInteractor_2.GetGroupedByLastNumberOfCode(returnedArray); //Assert Assert.IsTrue(result.First().Key == '0'); Assert.IsTrue(result.First().Count() == 47); }
public void ShouldUnion() { //Arrange String _path = "./../../Countries.txt"; List <INamed> returnedArray = CService.ReadFromTextFile(_path); IEnumerable <INamed> firstObjs = returnedArray.Take(100); IEnumerable <INamed> secondObjs = returnedArray.Skip(70); //Act var result = CInteractor_3.GetUnited(firstObjs, secondObjs); //Assert Assert.IsTrue(result.Count() == returnedArray.Count); }
/// <summary> /// method /// loads the service drop down list /// </summary> /// <returns></returns> private CStatus LoadServiceDDL() { CStatus status = CService.LoadServiceDDL( BaseMstr.BaseData, k_ACTIVE_ID.All, ddlFilterByService); if (!status.Status) { return(status); } return(new CStatus()); }
public void ShouldPerformSelectionFiltrationAndOrdering() { //Arrange String _path = "./../../Countries.txt"; List <INamed> returnedArray = CService.ReadFromTextFile(_path); //Act IEnumerable <String> names = CInteractor_1.GetSelectedSortedOrdered(returnedArray, "a"); //Assert Assert.IsTrue(names.Count() == 16); Assert.AreEqual(names.First(), "AZERBAIJAN"); Assert.AreEqual(names.Last(), "AALAND ISLANDS"); }
private void DoPortScan(CService service, int port, CNetwork.Protocols protocol = null, string stringsearch = null) { using (TcpClient client = new TcpClient()) { Log.Write(CFunctions.StringReplace("Checking " + protocol.ToString() + "://{0}:{1} for service presence ({2}).", service.IP.ToStringNz(), port.ToString(), stringsearch)); var result = client.BeginConnect(service.IP, port, null, null); var success = result.AsyncWaitHandle.WaitOne(TimeSpan.FromMilliseconds(COptions.Connection_Timeout), true); bool found = false; if (success) { if (protocol == CNetwork.Protocols.HTTP) { try { WebRequest req = HttpWebRequest.Create("http://" + service.Name); req.Method = "GET"; using (StreamReader reader = new StreamReader(req.GetResponse().GetResponseStream())) { if (stringsearch == null) { found = true; } // do not search if there is nothing to look for while (!reader.EndOfStream && !found) // otherwise search { string source = reader.ReadLine() + String.Empty; if (source.ToLower().Contains(stringsearch.ToLower())) { found = true; } } } } catch { found = false; } } else { found = true; } if (found) { lock (_ServerPortScanLock) { Log.Write("Service present (" + protocol.ToStringNz() + "): " + service.Name + " (" + service.Type + "); " + service.IP.ToStringNz()); _ServerPortScanResults.Add(service.Name + ";" + service.Type.ToString() + ";" + service.IP.ToStringNz() + ";" + port); } } } } }
internal CSession(CService server) { // initialize server session object if ((server.Type == CServiceType.ESXServer) || (server.Type == CServiceType.VCenterServer)) { Session = new VimSession(ref server); } else if ((server.Type == CServiceType.SCVMMServer) || (server.Type == CServiceType.HYVServer)) { Session = new HviSession(ref server); } else if (server.Type == CServiceType.VBRServer) { Session = new VbrSession(ref server); } }
private void SendMessageCore(CService svc) { Win32.SendMessage(_mainFrameHandle, GConst.WMG_UIMESSAGE, new IntPtr((int)svc), IntPtr.Zero); }