public void MakeContextMenu(IListProcessor list, List <ToolStripItem> menuItemList, object selectedListItem, object selectedObject, string aspectName) { JCountry item = selectedObject as JCountry; if (item != null) { ToolStripMenuItem menuItem = null; menuItem = new ToolStripMenuItem(); menuItem.Text = "Demo menu item from DemoPluginForJCountry"; menuItem.Click += (s, em) => { try { MessageBox.Show("Country: " + item.Name); } catch (Exception ex) { Log.ShowError(ex); } }; menuItemList.Add(menuItem); } }
static public void ConfirmIPAddress(BaseProxyServer item, string homeIP, JobLog jobLog) { string externalIP = NetConnUtils.GetMyExternalIP(); if (externalIP == null) { throw new Exception("Ip of vpn connection is null"); } jobLog.Info("ExternalIP: " + externalIP); if (homeIP != null) { if (homeIP.Equals(externalIP)) { throw new Exception("Ip address of vpn connection not changed. It equals home ip address."); } } JIPAddressInfo extIPAddressInfo = NetConnUtils.GetIPAddressInfo(externalIP); if (extIPAddressInfo == null) { throw new Exception("IPAddressInfo of vpn connection is null"); } jobLog.Info("New IP address Info: " + Log.PropertyList(extIPAddressInfo)); if (item != null) { if (item.JCountry != null) { if (!string.IsNullOrEmpty(extIPAddressInfo.CountryCode)) { if (extIPAddressInfo.CountryCode.ToLower().Equals(item.JCountry.JCountryId) == false) { //throw new Exception jobLog.Warn("Country code of vpn connection ip address (" + extIPAddressInfo.CountryCode.ToLower() + ") not equals to contry code of VPN server (" + item.JCountry.JCountryId + ")"); JCountry newContry = Dm.Instance.Find <JCountry>(extIPAddressInfo.CountryCode.ToLower()); if (newContry != null) { if (item.JCountryDeclared == null) { item.JCountryDeclared = item.JCountry; } item.JCountry = newContry; Dm.Instance.SaveObject(item); } else { throw new Exception("Country code of vpn connection ip address (" + extIPAddressInfo.CountryCode.ToLower() + ") not a valid country code"); } } } else { throw new Exception("Country code of vpn connection is empty"); } if (!string.IsNullOrEmpty(extIPAddressInfo.City)) { if (item.Town != null) { if (extIPAddressInfo.City.ToLower().Equals(item.Town.ToLower()) == false) { jobLog.Warn("City vpn connection ip address (" + extIPAddressInfo.City + ") not equals to town of VPN server (" + item.Town + "). New City value was set"); if (item.TownDeclared == null) { item.TownDeclared = item.Town; } item.Town = extIPAddressInfo.City; Dm.Instance.SaveObject(item); } } else { item.Town = extIPAddressInfo.City; Dm.Instance.SaveObject(item); } } } else { //todo } jobLog.Info("Test OK for item " + item.JProxyServerId); } //ok //todo NetConnUtils.MyExternalIP = externalIP; NetConnUtils.MyExtIPAddressInfo = extIPAddressInfo; }