public static void Main(String[] args) { string GeoipDbPath = "/usr/local/share/GeoIP/"; string GeoipDb = GeoipDbPath + "GeoIPCity.dat"; //open the database try { LookupService ls = new LookupService(GeoipDb, LookupService.GEOIP_STANDARD); //get city location of the ip address if (args.Length > 0) { Location l = ls.getLocationV6(args[0]); if (l != null) { Console.Write("country code " + l.countryCode + "\n"); Console.Write("country name " + l.countryName + "\n"); Console.Write("region " + l.region + "\n"); Console.Write("city " + l.city + "\n"); Console.Write("postal code " + l.postalCode + "\n"); Console.Write("latitude " + l.latitude + "\n"); Console.Write("longitude " + l.longitude + "\n"); Console.Write("metro code " + l.metro_code + "\n"); Console.Write("area code " + l.area_code + "\n"); Console.Write("region name " + l.regionName + "\n"); } else { Console.Write("IP Address Not Found\n"); } } else { Console.Write("Usage: cityExample IPAddress\n"); } } catch (System.Exception e) { Console.Write("Error" + e.Message + "\n"); } }
public void Find_Detailed_Location_For_IP() { var lookupService = new LookupService ("GeoLiteCity.dat", LookupService.MemoryMode.Standard); var location = lookupService.GetLocation ("98.26.2.102"); Assert.AreEqual (location.CountryCode, "US"); Assert.AreEqual (location.CountryName, "United States"); Assert.AreEqual (location.City, "Raleigh"); Assert.AreEqual (location.Region, "NC"); Assert.AreEqual (location.RegionName, "North Carolina"); Assert.AreEqual (location.PostalCode, "27613"); Assert.AreEqual (location.Latitude, 35.9341); Assert.AreEqual (location.Longitude, -78.7166); Assert.AreEqual (location.MetroCode, 560); Assert.AreEqual (location.AreaCode, 919); Console.WriteLine (location.CountryCode); Console.WriteLine (location.CountryName); Console.WriteLine (location.City); Console.WriteLine (location.Region); Console.WriteLine (location.RegionName); Console.WriteLine (location.PostalCode); Console.WriteLine (location.Latitude); Console.WriteLine (location.Longitude); Console.WriteLine (location.MetroCode); Console.WriteLine (location.AreaCode); }
public static Location GetLocation(string ipAddress) { if (System.Web.HttpContext.Current.Session["Long"] == null) { try { LookupService ls = new LookupService(System.Web.HttpContext.Current.Server.MapPath("~/App_Data/GeoLiteCity.dat"), LookupService.GEOIP_STANDARD); Location l = ls.getLocation(ipAddress); if (l.latitude == null) throw new Exception("No Location"); System.Web.HttpContext.Current.Session["Location"] = l; return l; } catch (Exception) { ipAddress = "80.193.180.102"; LookupService ls = new LookupService(System.Web.HttpContext.Current.Server.MapPath("~/App_Data/GeoLiteCity.dat"), LookupService.GEOIP_STANDARD); Location l = ls.getLocation(ipAddress); System.Web.HttpContext.Current.Session["Location"] = l; return l; } } else { return (Location)System.Web.HttpContext.Current.Session["Location"]; } }
static void Main(string[] args) { var path = Directory.GetCurrentDirectory(); string GeoipDb = path + @"\db\GeoIP.dat"; //open the database LookupService ls = new LookupService(GeoipDb, LookupService.GEOIP_MEMORY_CACHE); //get country of the ip address Country c = ls.getCountry("24.24.24.24"); Console.Write(" code: " + c.getCode() + "\n"); Console.Write(" name: " + c.getName() + "\n"); GeoipDb = path + @"\db\GeoLiteCity.dat"; ls = new LookupService(GeoipDb, LookupService.GEOIP_STANDARD); Location l = ls.getLocation("24.24.24.24"); if (l != null) { Console.Write("country code " + l.countryCode + "\n"); Console.Write("country name " + l.countryName + "\n"); Console.Write("region " + l.region + "\n"); Console.Write("city " + l.city + "\n"); Console.Write("postal code " + l.postalCode + "\n"); Console.Write("latitude " + l.latitude + "\n"); Console.Write("longitude " + l.longitude + "\n"); Console.Write("metro code " + l.metro_code + "\n"); Console.Write("area code " + l.area_code + "\n"); Console.Write("region name " + l.regionName + "\n"); } else { Console.Write("IP Address Not Found\n"); } Console.WriteLine(); }
public static void Run(String[] args) { string GeoipDbPath = "/usr/local/share/GeoIP/"; string GeoipDb = GeoipDbPath + "GeoIPNetSpeed.dat"; //open the database LookupService ls = new LookupService(GeoipDb, LookupService.GEOIP_STANDARD); int id = ls.getID(args[0]); int speed = id; if (speed == LookupService.GEOIP_UNKNOWN_SPEED) { Console.Write("Unknown \n"); } else if (speed == LookupService.GEOIP_DIALUP_SPEED) { Console.Write("Dialup \n"); } else if (speed == LookupService.GEOIP_CABLEDSL_SPEED) { Console.Write("Cable/DSL \n"); } else if (speed == LookupService.GEOIP_CORPORATE_SPEED) { Console.Write("Corporate \n"); } }
/// <summary> /// Initializes a new instance of the <see cref="HomeController" /> class. /// </summary> /// <param name="leaveService">The leave service.</param> /// <param name="timesheetService">The timesheet service.</param> /// <param name="lookupService">The lookup service.</param> /// <param name="releaseService">The release service.</param> public HomeController(LeaveService leaveService, TimesheetService timesheetService, LookupService lookupService, ReleaseService releaseService) { this.leaveService = leaveService; this.timesheetService = timesheetService; this.lookupService = lookupService; this.releaseService = releaseService; }
public static void Run(String[] args) { //open the database LookupService ls = new LookupService("/usr/local/share/GeoIP/GeoIPNetSpeedCell.dat", LookupService.GEOIP_STANDARD); //get org of the ip address String orgorisp = ls.getOrg("24.24.24.24"); Console.Write(" NetspeedCell: " + orgorisp + "\n"); }
public static void Main(String[] args) { //open the database LookupService ls = new LookupService("/usr/local/share/GeoIP/GeoIPDomain.dat", LookupService.GEOIP_STANDARD); //get org of the ip address String domain = ls.getOrg("24.24.24.24"); Console.Write(" domain: " + domain + "\n"); }
public static void Main(String[] args) { //open the database LookupService ls = new LookupService("/usr/local/share/GeoIP/GeoIPASNumv6.dat", LookupService.GEOIP_STANDARD); //get org of the ip address String orgorisp = ls.getOrgV6("2001:4860:0:1001::68"); Console.Write("asn: " + orgorisp + "\n"); }
public void Find_Org_For_IP() { var lookupService = new LookupService ("GeoIPOrg.dat", LookupService.MemoryMode.Standard); var org = lookupService.GetOrganization ("98.26.2.102"); Console.WriteLine (org); }
public static void Main(String[] args) { //open the database LookupService ls = new LookupService("/usr/local/share/GeoIP/GeoIPv6.dat", LookupService.GEOIP_MEMORY_CACHE); //get country of the ip address Country c = ls.getCountryV6("2001:4860:0:1001::68"); Console.Write(" code: " + c.getCode()+"\n"); Console.Write(" name: " + c.getName()+"\n"); }
public static void Main(String[] args){ string GeoipDb = "./GeoIP.dat"; //open the database LookupService ls = new LookupService(GeoipDb, LookupService.GEOIP_MEMORY_CACHE); //get country of the ip address Country c = ls.getCountry("24.24.24.24"); Console.Write(" code: " + c.getCode()+"\n"); Console.Write(" name: " + c.getName()+"\n"); }
private static string GetCountryCode() { string ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; //open the database const string maxmindDb = @"D:\inetpub\MarketingSite\maxmind\GeoIPRegion-115.dat"; var ls = new LookupService(maxmindDb, LookupService.GEOIP_STANDARD); Region c = ls.getRegion(ip); return c.getcountryCode(); }
public void Find_Region_For_IP() { var lookupService = new LookupService ("GeoIPRegion.dat", LookupService.MemoryMode.Standard); var region = lookupService.GetRegion ("98.26.2.102"); Console.WriteLine (region.CountryCode); Console.WriteLine (region.CountryName); Console.WriteLine (region.RegionName); }
/// <summary> /// /// </summary> public Parser(int threads) { this.Threads = threads; _ls = new LookupService("GeoIP.dat", LookupService.GEOIP_MEMORY_CACHE); sessionParser = new SessionParser(this.Threads); sessionParser.MessageEvent += SessionParser_MessageEvent; sessionParser.CompleteEvent += SessionParser_CompleteEvent; }
public static void Main(String[] args) { //open the database LookupService ls = new LookupService("/usr/local/share/GeoIP/GeoIPRegion.dat", LookupService.GEOIP_STANDARD); //get region of the ip address Region c = ls.getRegion("24.24.24.24"); Console.Write(" code: " + c.getcountryCode()+"\n"); Console.Write(" name: " + c.getcountryName()+"\n"); Console.Write(" region: " + c.getregion() + "\n"); }
public static void Main(String[] args) { string GeoipDbPath = "/usr/local/share/GeoIP/"; string GeoipDb = GeoipDbPath + "GeoIPOrg.dat"; //open the database LookupService ls = new LookupService(GeoipDb, LookupService.GEOIP_STANDARD); //get org of the ip address String orgorisp = ls.getOrg("24.24.24.24"); Console.Write(" org: " + orgorisp + "\n"); }
public void UnknownCityReturnsNullNotFailing() { string geoipDb = Path.Combine(GeoipDbPath, GeoLiteCityDb); using (var ls = new LookupService(geoipDb)) { Location l = ls.getLocation("0.2.3.4"); l.ShouldBeNull(); } }
public void KnownRegionReturnsRegionName() { string geoipDb = Path.Combine(GeoipDbPath, GeoLiteCityDb); using (var ls = new LookupService(geoipDb)) { Location l = ls.getLocation("64.17.254.223"); //Region r = ls.getRegion("186.33.234.28"); l.regionName.ShouldEqual("California"); } }
public void Find_Country_For_IP() { var lookupService = new LookupService ("GeoIP.dat", LookupService.MemoryMode.Standard); var country = lookupService.GetCountry ("98.26.2.102"); Assert.AreEqual (country.Code, "US"); Assert.AreEqual (country.Name, "United States"); Console.WriteLine (country.Code); Console.WriteLine (country.Name); }
ViewModelBase createModel() { var model = new AllocationsViewModel(); PrepareViewModel(model, EvolutionResources.bnrAllocations, 0, MenuOptionFlag.RequiresNoSale); model.BrandCategoryId = CurrentUser.DefaultBrandCategoryId.Value; model.BrandCategoryList = ProductService.FindBrandCategoryListItemModel(CurrentCompany); model.LocationId = CurrentCompany.DefaultLocationID.Value; model.LocationList = LookupService.FindLocationListItemModel(CurrentCompany); return(model); }
public JsonResult GetSiteName(int themeId) { var lookupService = new LookupService(); var item = lookupService.FetchThemes().FirstOrDefault(t => t.Id == themeId); if (item != null) { return(Json(new { SiteName = item.SiteName }, JsonRequestBehavior.AllowGet)); } return(Json(new { SiteName = string.Empty }, JsonRequestBehavior.AllowGet)); }
void prepareViewModel(SalePrintOptionsViewModel model) { var soht = SalesService.FindSalesOrderHeaderTempModel(model.SalesOrderHeaderTempId, CurrentCompany, true); PrepareViewModel(model, EvolutionResources.bnrPrintSale, model.SalesOrderHeaderTempId, MakeMenuOptionFlags(0, 0, 0, soht.OriginalRowId)); model.TemplateList = LookupService.FindDocumentTemplatesListItemModel(DocumentTemplateCategory.SalesOrders); model.AvailableRecipientsList = CustomerService.FindCustomerRecipients(soht, CurrentCompany, CurrentUser); model.AvailableRecipientsList.Add(new ListItemModel("Other Recipient", "OTH")); model.SalutationList = LookupService.FindLOVItemsListItemModel(CurrentCompany, LOVName.Salutation); }
public ActionResult Edit(int id, int lovId) { var model = new EditLOVItemViewModel(); PrepareViewModel(model, EvolutionResources.bnrAddEditLOVItem); model.LovItem = LookupService.FindLOVItemModel(id, lovId); model.LovItem.CompanyId = null; model.ColourList = LookupService.FindColourListItemModel(); model.LGS = LookupService.LockLOVItem(model.LovItem); return(View(model)); }
private bool GeoipLoadDatabase(string GeoipPath) { try { lookupService = new LookupService(GeoipPath, LookupService.GEOIP_STANDARD); lookupService.getCountry("255.255.255.255"); // GeoIP reads the db only when asked to do something geoipDbLoaded = true; } catch (Exception) { MessageBox.Show("Could not load Geoip database. Traceroute mapping will not be possible.", "Failed loading database", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(true); }
public ActionResult Delete(int index, int id, int lovId) { var model = new ListsOfValuesViewModel { GridIndex = index }; try { LookupService.DeleteLOVItem(id); } catch (Exception e1) { model.Error.SetError(e1); } return(Json(model, JsonRequestBehavior.AllowGet)); }
public void Test2() { //Arrange var mockServiceProvider = new Mock <IServiceProvider>(); var mockMapper = new Mock <IMapper>(); //Act var lookupSvc = new LookupService(mockServiceProvider.Object, mockMapper.Object); //Assert mockServiceProvider.Verify(x => x.GetService(It.IsAny <Type>()), Times.Once); }
public void Test1() { //Arrange var mockServiceProvider = new Mock <IServiceProvider>(); var mockMapper = new Mock <IMapper>(); //Act var lookupSvc = new LookupService(mockServiceProvider.Object, mockMapper.Object); //Assert Assert.IsNotNull(lookupSvc); }
public static void Main(String[] args) { const string GeoipDbPath = "/usr/local/share/GeoIP/"; const string GeoipDb = GeoipDbPath + "GeoIPRegion.dat"; //open the database LookupService ls = new LookupService(GeoipDb, LookupService.GEOIP_STANDARD); //get region of the ip address Region c = ls.getRegion("24.24.24.24"); Console.Write(" code: " + c.getcountryCode() + "\n"); Console.Write(" name: " + c.getcountryName() + "\n"); Console.Write(" region: " + c.getregion() + "\n"); }
protected override void MatchValueToSelectedItems() { Lookup newValue = null; if (SelectedItem != null && SelectedItem.Record != null) { newValue = LookupService.ToLookup(SelectedItem.Record); } if (newValue != Value) { Value = newValue; } }
public IEnumerable <Lookup> Get(string name = "[NAMESPACE]", int parentId = 0, int id = 0) { var lookupService = new LookupService(); if (id > 0) { return(lookupService.LookupByName(name, parentId, id)); } else { return(lookupService.LookupByName(name, parentId)); } }
private void LoadRooms() { LookupService service = new LookupService(); List <RoomDTO> rooms = service.GetRooms(); rooms.Insert(0, new RoomDTO { RoomId = 0, RoomName = "" }); cmbAvailableRooms.DataSource = rooms; cmbAvailableRooms.DisplayMember = "RoomName"; cmbAvailableRooms.ValueMember = "RoomId"; cmbAvailableRooms.SelectedIndex = -1; }
public void FindCountryModelTest() { var user = GetTestUser(); var model = createCountry(); var error = LookupService.InsertOrUpdateCountry(model, user, ""); Assert.IsTrue(!error.IsError, $"Error: {error.Message}"); var test = LookupService.FindCountryModel(model.Id, false); AreEqual(model, test); }
public void Find_Speed_For_IP() { var lookupService = new LookupService("GeoIPNetSpeed.dat", LookupService.MemoryMode.Standard); int id = lookupService.GetID("98.26.2.102"); Assert.IsTrue(id == (int)LookupService.NetSpeeds.CableDSL || id == (int)LookupService.NetSpeeds.Corporate || id == (int)LookupService.NetSpeeds.Dialup || id == (int)LookupService.NetSpeeds.Unknown); Console.WriteLine(id); }
public void Find_Speed_For_IP() { var lookupService = new LookupService ("GeoIPNetSpeed.dat", LookupService.MemoryMode.Standard); int id = lookupService.GetID ("98.26.2.102"); Assert.IsTrue (id == (int) LookupService.NetSpeeds.CableDSL || id == (int) LookupService.NetSpeeds.Corporate || id == (int) LookupService.NetSpeeds.Dialup || id == (int) LookupService.NetSpeeds.Unknown); Console.WriteLine (id); }
public void UnknownCityReturnsUknownNotFailing() { string geoipDb = Path.Combine(GeoipDbPath, GeoipDb); using (var ls = new LookupService(geoipDb)) { Country c = ls.getCountry("0.0.0.0"); c.ShouldNotBeNull(); c.getCode().ShouldEqual("--"); c.getName().ShouldEqual("N/A"); } }
public void InsertOrUpdateDocumentTemplateTest() { // Tested in DeleteDocumentTemplateTest, but additional tests here var testUser = GetTestUser(); var testCompany = GetTestCompany(testUser); var testCurrency = db.FindCurrency("AUD"); var testDocumentTemplate1 = createDocumentTemplate(testCompany, DocumentTemplateCategory.Invoice, DocumentTemplateType.None); var error = LookupService.InsertOrUpdateDocumentTemplate(testDocumentTemplate1, testUser, ""); Assert.IsTrue(!error.IsError, error.Message); var test = db.FindDocumentTemplate(testDocumentTemplate1.Id); var testModel = LookupService.MapToModel(test); AreEqual(testDocumentTemplate1, testModel); var testDocumentTemplate2 = createDocumentTemplate(testCompany, DocumentTemplateCategory.Pickslip, DocumentTemplateType.None); error = LookupService.InsertOrUpdateDocumentTemplate(testDocumentTemplate2, testUser, ""); Assert.IsTrue(!error.IsError, error.Message); test = db.FindDocumentTemplate(testDocumentTemplate2.Id); testModel = LookupService.MapToModel(test); AreEqual(testDocumentTemplate2, testModel); // Try to create a DocumentTemplate with the same name var dupItem = LookupService.Clone(testDocumentTemplate1); dupItem.Id = 0; error = LookupService.InsertOrUpdateDocumentTemplate(dupItem, testUser, ""); Assert.IsTrue(error.IsError, "Error: Creating a duplicate DocumentTemplate returned no error when it should have returned a 'duplicate' error"); // Try to rename the item to a non-existing name (should work) string lgs = LookupService.LockDocumentTemplate(testDocumentTemplate1); testDocumentTemplate1.Name = RandomString(); error = LookupService.InsertOrUpdateDocumentTemplate(testDocumentTemplate1, testUser, lgs); Assert.IsTrue(!error.IsError, error.Message); // Try to rename to an existing item (should fail) lgs = LookupService.LockDocumentTemplate(testDocumentTemplate1); testDocumentTemplate1.Name = testDocumentTemplate2.Name; error = LookupService.InsertOrUpdateDocumentTemplate(testDocumentTemplate1, testUser, lgs); Assert.IsTrue(error.IsError, "Error: Renaming a DocumentTemplate to the same name as an existing DocumentTemplate returned no error when it should have returned a 'duplicate' error"); }
public void InsertOrUpdateSalesOrderHeaderStatusTest() { // Tested in DeleteSalesOrderStatuTest, but additional tests here var testUser = GetTestUser(); var testSalesOrderStatu1 = createSalesOrderHeaderStatus(); var error = LookupService.InsertOrUpdateSalesOrderHeaderStatus(testSalesOrderStatu1, testUser, ""); Assert.IsTrue(!error.IsError, error.Message); var test = db.FindSalesOrderHeaderStatus(testSalesOrderStatu1.Id); var testModel = LookupService.MapToModel(test); AreEqual(testSalesOrderStatu1, testModel); var testSalesOrderStatu2 = createSalesOrderHeaderStatus(); error = LookupService.InsertOrUpdateSalesOrderHeaderStatus(testSalesOrderStatu2, testUser, ""); Assert.IsTrue(!error.IsError, error.Message); test = db.FindSalesOrderHeaderStatus(testSalesOrderStatu2.Id); testModel = LookupService.MapToModel(test); AreEqual(testSalesOrderStatu2, testModel); // Try to create a SalesOrderStatus with the same name var dupItem = LookupService.Clone(testSalesOrderStatu1); dupItem.Id = 0; error = LookupService.InsertOrUpdateSalesOrderHeaderStatus(dupItem, testUser, ""); Assert.IsTrue(error.IsError, "Error: Creating a duplicate SalesOrderStatus returned no error when it should have returned a 'duplicate' error"); // Try to rename the item to a non-existing name (should work) string lgs = LookupService.LockSalesOrderHeaderStatus(testSalesOrderStatu1); testSalesOrderStatu1.StatusName = RandomString(); testSalesOrderStatu1.StatusValue++; error = LookupService.InsertOrUpdateSalesOrderHeaderStatus(testSalesOrderStatu1, testUser, lgs); Assert.IsTrue(!error.IsError, error.Message); // Try to rename to an existing item (should fail) lgs = LookupService.LockSalesOrderHeaderStatus(testSalesOrderStatu1); testSalesOrderStatu1.StatusName = testSalesOrderStatu2.StatusName; testSalesOrderStatu1.StatusValue = testSalesOrderStatu2.StatusValue; error = LookupService.InsertOrUpdateSalesOrderHeaderStatus(testSalesOrderStatu1, testUser, lgs); Assert.IsTrue(error.IsError, "Error: Renaming a SalesOrderStatus to the same name as an existing SalesOrderStatus returned no error when it should have returned a 'duplicate' error"); }
/// <summary> /// Gets the OrderHistory ViewModel, containing a list of Orders. /// </summary> /// <param name="param"></param> /// <returns></returns> public virtual async Task <OrderHistoryViewModel> GetOrderHistoryViewModelAsync(GetCustomerOrdersParam param) { if (param == null) { throw new ArgumentNullException("param"); } if (param.CultureInfo == null) { throw new ArgumentException("param.CultureInfo"); } if (param.CustomerId == null) { throw new ArgumentException("param.CustomerId"); } if (string.IsNullOrWhiteSpace(param.Scope)) { throw new ArgumentException("param.Scope"); } var orderDetailBaseUrl = OrderUrlProvider.GetOrderDetailsBaseUrl(param.CultureInfo); var orderStatuses = await LookupService.GetLookupDisplayNamesAsync(new GetLookupDisplayNamesParam { CultureInfo = param.CultureInfo, LookupType = LookupType.Order, LookupName = "OrderStatus", }).ConfigureAwait(false); var orderQueryResult = await OrderRepository.GetCustomerOrdersAsync(param).ConfigureAwait(false); var shipmentsTrackingInfos = new Dictionary <Guid, TrackingInfoViewModel>(); if (orderQueryResult != null && orderQueryResult.Results != null && param.OrderTense == OrderTense.CurrentOrders) { shipmentsTrackingInfos = await GetShipmentsTrackingInfoViewModels(orderQueryResult, param).ConfigureAwait(false); } var getOrderHistoryViewModelParam = new GetOrderHistoryViewModelParam { CultureInfo = param.CultureInfo, OrderResult = orderQueryResult, OrderStatuses = orderStatuses, Page = param.Page, OrderDetailBaseUrl = orderDetailBaseUrl, ShipmentsTrackingInfos = shipmentsTrackingInfos }; var viewModel = OrderHistoryViewModelFactory.CreateViewModel(getOrderHistoryViewModelParam); return(viewModel); }
public void FindProductIPListModelTest() { var testUser = GetTestUser(); var testCompany = GetTestCompany(testUser); var product = createProduct(testCompany, testUser); ProductService.InsertOrUpdateProduct(product, testUser, ""); // Test Model.Items against Marketing\Llocation - count var model = ProductService.FindProductIPListModel(product.Id); var marketingLocation = LookupService.FindLOVItemsModel(testCompany, LOVName.MarketingLocation); int expected = marketingLocation.Count(); int actual = model.Items.Count(); Assert.IsTrue(actual == expected, $"Error: {actual} items were found when {expected} were expected"); // check all items in model are Selected = false foreach (var item in model.Items) { Assert.IsTrue(item.Selected == false, "Error: 'False' was expected when 'True' was returned"); } // Add a new item and make sure it is found foreach (var item in model.Items) { item.Selected = true; } var error = ProductService.InsertOrUpdateProductIP(product, model, ""); Assert.IsTrue(!error.IsError, $"Error: {error.Message}"); // check all items in model are Selected = true model = ProductService.FindProductIPListModel(product.Id); foreach (var item in model.Items) { Assert.IsTrue(item.Selected == true, "Error: 'True' was expected when 'False' was returned"); } // Delete it and make sure it dissapears foreach (var item in model.Items) { ProductService.DeleteProductIP(item.Id); } // check all items in model are Selected = false model = ProductService.FindProductIPListModel(product.Id); foreach (var item in model.Items) { Assert.IsTrue(item.Selected == false, "Error: 'False' was expected when 'True' was returned"); } }
public void InsertOrUpdatePriceLevelTest() { // Tested in DeletePriceLevelTest, but additional tests here var testUser = GetTestUser(); var testCompany = GetTestCompany(testUser); var testPriceLevel1 = createPriceLevel(testCompany); var error = LookupService.InsertOrUpdatePriceLevel(testPriceLevel1, testUser, ""); Assert.IsTrue(!error.IsError, error.Message); var test = db.FindPriceLevel(testPriceLevel1.Id); var testModel = LookupService.MapToModel(test); AreEqual(testPriceLevel1, testModel); var testPriceLevel2 = createPriceLevel(testCompany); error = LookupService.InsertOrUpdatePriceLevel(testPriceLevel2, testUser, ""); Assert.IsTrue(!error.IsError, error.Message); test = db.FindPriceLevel(testPriceLevel2.Id); testModel = LookupService.MapToModel(test); AreEqual(testPriceLevel2, testModel); // Try to create a PriceLevel with the same name var dupItem = LookupService.Clone(testPriceLevel1); dupItem.Id = 0; error = LookupService.InsertOrUpdatePriceLevel(dupItem, testUser, ""); Assert.IsTrue(error.IsError, "Error: Creating a duplicate PriceLevel returned no error when it should have returned a 'duplicate' error"); // Try to rename the item to a non-existing name (should work) string lgs = LookupService.LockPriceLevel(testPriceLevel1); testPriceLevel1.Mneumonic = RandomString().Left(3); error = LookupService.InsertOrUpdatePriceLevel(testPriceLevel1, testUser, lgs); Assert.IsTrue(!error.IsError, error.Message); // Try to rename to an existing item (should fail) lgs = LookupService.LockPriceLevel(testPriceLevel1); testPriceLevel1.Mneumonic = testPriceLevel2.Mneumonic; error = LookupService.InsertOrUpdatePriceLevel(testPriceLevel1, testUser, lgs); Assert.IsTrue(error.IsError, "Error: Renaming a PriceLevel to the same name as an existing PriceLevel returned no error when it should have returned a 'duplicate' error"); }
protected virtual async Task <CompleteCheckoutViewModel> MapOrderToCompleteCheckoutViewModel(Overture.ServiceModel.Orders.Order order, CompleteCheckoutParam param) { if (order == null) { return(null); } var orderStatuses = await LookupService.GetLookupDisplayNamesAsync(new GetLookupDisplayNamesParam { CultureInfo = param.CultureInfo, LookupType = LookupType.Order, LookupName = "OrderStatus", }).ConfigureAwait(false); var productImageInfo = new ProductImageInfo { ImageUrls = await ImageService.GetImageUrlsAsync(order.Cart.GetLineItems()).ConfigureAwait(false) }; var getVmOrderParam = new CreateOrderDetailViewModelParam { Order = order, CultureInfo = param.CultureInfo, OrderStatuses = orderStatuses, OrderDetailBaseUrl = OrderUrlProvider.GetOrderDetailsBaseUrl(param.CultureInfo), BaseUrl = param.BaseUrl, ProductImageInfo = productImageInfo, }; var orderViewModel = OrderDetailsViewModelFactory.CreateLightViewModel(getVmOrderParam); var completeCheckoutViewModel = new CompleteCheckoutViewModel { OrderNumber = order.OrderNumber, Order = orderViewModel, CustomerEmail = order.Cart.Customer.Email, CustomerFirstName = order.Cart.Customer.FirstName, CustomerLastName = order.Cart.Customer.LastName, Affiliation = order.Cart.OrderLocation?.Name, Revenu = order.Cart.Total, Tax = order.Cart.TaxTotal, Shipping = order.Cart.FulfillmentCost, ShippingOptions = order.Cart.Shipments?.FirstOrDefault()?.FulfillmentMethod.FulfillmentMethodType.ToString().ToLowerInvariant(), BillingCurrency = order.Cart.BillingCurrency, Coupons = MapCoupons(order, param.CultureInfo), LineItems = orderViewModel?.Shipments.FirstOrDefault()?.LineItems }; return(completeCheckoutViewModel); }
public void InsertOrUpdateFreightCarrierTest() { // Tested in DeleteFreightCarrierTest, but additional tests here var testUser = GetTestUser(); var testCompany = GetTestCompany(testUser); var testFreightCarrier1 = createFreightCarrier(testCompany); var error = LookupService.InsertOrUpdateFreightCarrier(testFreightCarrier1, testUser, ""); Assert.IsTrue(!error.IsError, error.Message); var test = db.FindFreightCarrier(testFreightCarrier1.Id); var testModel = LookupService.MapToModel(test); AreEqual(testFreightCarrier1, testModel); var testFreightCarrier2 = createFreightCarrier(testCompany); error = LookupService.InsertOrUpdateFreightCarrier(testFreightCarrier2, testUser, ""); Assert.IsTrue(!error.IsError, error.Message); test = db.FindFreightCarrier(testFreightCarrier2.Id); testModel = LookupService.MapToModel(test); AreEqual(testFreightCarrier2, testModel); // Try to create a FreightCarrier with the same name var dupItem = LookupService.Clone(testFreightCarrier1); dupItem.Id = 0; error = LookupService.InsertOrUpdateFreightCarrier(dupItem, testUser, ""); Assert.IsTrue(error.IsError, "Error: Creating a duplicate Freight Carrier returned no error when it should have returned a 'duplicate' error"); // Try to rename the item to a non-existing name (should work) string lgs = LookupService.LockFreightCarrier(testFreightCarrier1); testFreightCarrier1.FreightCarrier = RandomString(); error = LookupService.InsertOrUpdateFreightCarrier(testFreightCarrier1, testUser, lgs); Assert.IsTrue(!error.IsError, error.Message); // Try to rename to an existing item (should fail) lgs = LookupService.LockFreightCarrier(testFreightCarrier1); testFreightCarrier1.FreightCarrier = testFreightCarrier2.FreightCarrier; error = LookupService.InsertOrUpdateFreightCarrier(testFreightCarrier1, testUser, lgs); Assert.IsTrue(error.IsError, "Error: Renaming a Freight Carrier to the same name as an existing Freight Carrier returned no error when it should have returned a 'duplicate' error"); }
public void InsertOrUpdateMarketingGroupTest() { // Tested in DeleteMarketingGroupTest, but additional tests here var testUser = GetTestUser(); var testCompany = GetTestCompany(testUser); var testMarketingGroup1 = createMarketingGroup(testCompany); var error = LookupService.InsertOrUpdateMarketingGroup(testMarketingGroup1, testUser, ""); Assert.IsTrue(!error.IsError, error.Message); var test = db.FindMarketingGroup(testMarketingGroup1.Id); var testModel = LookupService.MapToModel(test); AreEqual(testMarketingGroup1, testModel); var testMarketingGroup2 = createMarketingGroup(testCompany); error = LookupService.InsertOrUpdateMarketingGroup(testMarketingGroup2, testUser, ""); Assert.IsTrue(!error.IsError, error.Message); test = db.FindMarketingGroup(testMarketingGroup2.Id); testModel = LookupService.MapToModel(test); AreEqual(testMarketingGroup2, testModel); // Try to create a MarketingGroup with the same name var dupItem = LookupService.Clone(testMarketingGroup1); dupItem.Id = 0; error = LookupService.InsertOrUpdateMarketingGroup(dupItem, testUser, ""); Assert.IsTrue(error.IsError, "Error: Creating a duplicate MarketingGroup returned no error when it should have returned a 'duplicate' error"); // Try to rename the item to a non-existing name (should work) string lgs = LookupService.LockMarketingGroup(testMarketingGroup1); testMarketingGroup1.MarketingGroupName = RandomString().Left(30); error = LookupService.InsertOrUpdateMarketingGroup(testMarketingGroup1, testUser, lgs); Assert.IsTrue(!error.IsError, error.Message); // Try to rename to an existing item (should fail) lgs = LookupService.LockMarketingGroup(testMarketingGroup1); testMarketingGroup1.MarketingGroupName = testMarketingGroup2.MarketingGroupName; error = LookupService.InsertOrUpdateMarketingGroup(testMarketingGroup1, testUser, lgs); Assert.IsTrue(error.IsError, "Error: Renaming a MarketingGroup Id to the same name as an existing MarketingGroup returned no error when it should have returned a 'duplicate' error"); }
public CivilFilesService(IConfiguration configuration, FileServicesClient filesClient, IMapper mapper, LookupService lookupService, LocationService locationService, IAppCache cache) { _filesClient = filesClient; _filesClient.JsonSerializerSettings.ContractResolver = new SafeContractResolver { NamingStrategy = new CamelCaseNamingStrategy() }; _lookupService = lookupService; _locationService = locationService; _mapper = mapper; _requestApplicationCode = configuration.GetNonEmptyValue("Request:ApplicationCd"); _requestAgencyIdentifierId = configuration.GetNonEmptyValue("Request:AgencyIdentifierId"); _requestPartId = configuration.GetNonEmptyValue("Request:PartId"); _cache = cache; }
public void FindCityDbAccessIp() { // 186.33.234.28 Should give country code "AR", country "Argentina", latitude -34 and longitude -64 string geoipDb = Path.Combine(GeoipDbPath, GeoipDb); using (var ls = new LookupService(geoipDb)) { Country c = ls.getCountry("186.33.234.28"); c.ShouldNotBeNull(); c.getCode().ShouldEqual("AR"); c.getName().ShouldEqual("Argentina"); } }
private ProductComplianceModel createProductCompliance(CompanyModel testCompany, ProductModel product) { var cc = LookupService.FindLOVItemsModel(testCompany, LOVName.ComplianceCategory).FirstOrDefault(); var market = LookupService.FindLOVItemsModel(testCompany, LOVName.MarketingLocation).FirstOrDefault(); var model = new ProductComplianceModel(); model.ProductId = product.Id; model.ComplianceCategoryId = cc.Id; model.ComplianceCategoryText = cc.ItemText; model.MarketId = market.Id; model.MarketNameText = market.ItemText; return(model); }
/* # # Visit # */ public static void visit(int visitTimes) { int UserId = checkUserExists(); if (visitTimes < 50) { if ((Utils._POST("gid").Length == 32) && UserId > 0) { string OnlineUserKey = Utils.SERVER_NAME + Utils.ONLINE_USERS + Utils.md5(Utils._POST("sid") + Utils._SERVER("REMOTE_ADDR") + Utils._POST("gid")); Dictionary <string, string> OnlineUserValue = new Dictionary <string, string>(); OnlineUserValue["UserId"] = UserId.ToString(); OnlineUserValue["GameId"] = Utils._POST("gid"); OnlineUserValue["Action"] = Utils._POST("act"); OnlineUserValue["APIVer"] = "v1"; OnlineUserValue["WebRefer"] = Utils._POST("ref"); OnlineUserValue["Refer"] = Utils._SERVER("HTTP_REFERER"); OnlineUserValue["ClientIP"] = Utils._SERVER("REMOTE_ADDR"); OnlineUserValue["Visit"] = visitTimes.ToString(); OnlineUserValue["WebAgent"] = Utils._SERVER("HTTP_USER_AGENT"); OnlineUserValue["CallBack"] = "visit"; LookupService ls = new LookupService("C:/VStudioC#/Fgs/geo/GeoIPCity.dat", LookupService.GEOIP_STANDARD); Location geo = ls.getLocation("88.247.103.59"); OnlineUserValue["City"] = geo.city; OnlineUserValue["Country"] = geo.countryName; /* * OnlineUserValue["City"] = ""; * OnlineUserValue["Country"] = ""; */ OnlineUserValue["Id"] = InsertRefererTable(OnlineUserValue).ToString(); SessionObjects.wincache_ucache_set(OnlineUserKey, OnlineUserValue, TimeToLive); /* # # Send Response # */ Responser("visit", Utils._POST("sid")); } else { RequestVisit(); } } else { Responser("ping", "pong"); } }
public void InsertOrUpdateSupplierTermTest() { // Tested in SupplierTermTest, but additional tests here var testUser = GetTestUser(); var testCompany = GetTestCompany(testUser); var testSupplierTerm1 = createSupplierTerm(testCompany); var error = LookupService.InsertOrUpdateSupplierTerm(testSupplierTerm1, testUser, ""); Assert.IsTrue(!error.IsError, error.Message); var test = db.FindSupplierTerm(testSupplierTerm1.Id); var testModel = LookupService.MapToModel(test); AreEqual(testSupplierTerm1, testModel); var testSupplierTerm2 = createSupplierTerm(testCompany); error = LookupService.InsertOrUpdateSupplierTerm(testSupplierTerm2, testUser, ""); Assert.IsTrue(!error.IsError, error.Message); test = db.FindSupplierTerm(testSupplierTerm2.Id); testModel = LookupService.MapToModel(test); AreEqual(testSupplierTerm2, testModel); // Try to create a SupplierTerm with the same name var dupItem = LookupService.Clone(testSupplierTerm1); dupItem.Id = 0; error = LookupService.InsertOrUpdateSupplierTerm(dupItem, testUser, ""); Assert.IsTrue(error.IsError, "Error: Creating a duplicate SupplierTerm returned no error when it should have returned a 'duplicate' error"); // Try to rename the item to a non-existing name (should work) string lgs = LookupService.LockSupplierTerm(testSupplierTerm1); testSupplierTerm1.SupplierTermName = RandomString(); error = LookupService.InsertOrUpdateSupplierTerm(testSupplierTerm1, testUser, lgs); Assert.IsTrue(!error.IsError, error.Message); // Try to rename to an existing item (should fail) lgs = LookupService.LockSupplierTerm(testSupplierTerm1); testSupplierTerm1.SupplierTermName = testSupplierTerm2.SupplierTermName; error = LookupService.InsertOrUpdateSupplierTerm(testSupplierTerm1, testUser, lgs); Assert.IsTrue(error.IsError, "Error: Renaming a SupplierTerm to the same name as an existing SupplierTerm returned no error when it should have returned a 'duplicate' error"); }
public void FindPaymentTermModelTest() { var user = GetTestUser(); var testCompany = GetTestCompany(user); var model = createPaymentTerm(testCompany); var error = LookupService.InsertOrUpdatePaymentTerm(model, user, ""); Assert.IsTrue(!error.IsError, $"Error: {error.Message}"); var test = LookupService.FindPaymentTermModel(model.Id, false); AreEqual(model, test); }
public SalesOrderSummaryModel CreateOrderSummary(SalesOrderHeaderTempModel soht) { var model = new SalesOrderSummaryModel(); model.SubTotal = 0; model.TaxName = ""; model.TaxTotal = 0; model.Total = 0; model.Total = model.SubTotal + model.TaxTotal; model.TotalCbms = 0; // The tax code and currency comes from the customer double taxRate = 0; if (soht.CustomerId != null) { var customer = db.FindCustomer(soht.CustomerId.Value); if (customer != null) { var taxCode = db.FindTaxCode(customer.TaxCodeId); if (taxCode != null) { model.TaxName = taxCode.TaxCode1; if (taxCode.TaxPercentageRate != null) { taxRate = (double)taxCode.TaxPercentageRate.Value; } } model.CurrencySymbol = LookupService.FindCurrencySymbol(customer.CurrencyId); } } // Now traverse all the items on the order foreach (var orderLine in FindSalesOrderDetailTempsListModel(soht.CompanyId, soht.Id, 0, 1, 9999, "").Items) { double linePrice = (double)(orderLine.LinePrice == null ? 0 : orderLine.LinePrice.Value); model.SubTotal += linePrice; double gstAmount = linePrice / 100 * taxRate; model.TaxTotal += gstAmount; if (orderLine.UnitCBM != null) { model.TotalCbms += orderLine.UnitCBM.Value * (double)orderLine.OrderQty; } } model.Total = model.SubTotal + model.TaxTotal; return(model); }
public static ILookupService <LookupDto> GetLookupService(string collectionName) { ILookupService <LookupDto> serviceObj = null; switch (sectionHandler.ConnectionStringName) { case DataBaseType.SKILLSMART_MONGO_DB: serviceObj = new LookupService(DatabaseFactory.CreateMongoDatabase(), collectionName); break; default: serviceObj = new LookupService(DatabaseFactory.CreateMongoDatabase(), collectionName); break; } return(serviceObj); }
public void FindCountryTest() { var user = GetTestUser(); var model = createCountry(); var error = LookupService.InsertOrUpdateCountry(model, user, ""); Assert.IsTrue(!error.IsError, $"Error: {error.Message}"); var test = db.FindCountry(model.Id); var result = LookupService.MapToModel(test); AreEqual(model, result); }
public static void Main(String[] args) { LookupService ls = new LookupService("/usr/local/share/GeoIP/GeoIPNetSpeed.dat", LookupService.GEOIP_STANDARD); int id = ls.getID(args[0]); int speed = id; if (speed == LookupService.GEOIP_UNKNOWN_SPEED){ Console.Write("Unknown \n"); } else if (speed == LookupService.GEOIP_DIALUP_SPEED){ Console.Write("Dialup \n"); } else if (speed == LookupService.GEOIP_CABLEDSL_SPEED){ Console.Write("Cable/DSL \n"); } else if (speed == LookupService.GEOIP_CORPORATE_SPEED){ Console.Write("Corporate \n"); } }
public static void Main(String[] args) { string GeoipDbPath = "/usr/local/share/GeoIP/"; string GeoipDb = GeoipDbPath + "GeoIPCity.dat"; if (args.Length > 0) { GeoipDb = args[0]; } //open the database LookupService ls = new LookupService(GeoipDb, LookupService.GEOIP_STANDARD); //get the database info DatabaseInfo dbinfo = ls.getDatabaseInfo(); Console.Write(" dbinfo string: " + dbinfo.toString() + "\n"); Console.Write(" dbinfo type: " + dbinfo.getType() + "\n"); Console.Write(" dbinfo date: " + dbinfo.getDate() + "\n"); }
public void FindCityCacheDbIp() { // 186.33.234.28 Should give country code "AR", country "Argentina", latitude -34 and longitude -64 string geoipDb = Path.Combine(GeoipDbPath, GeoipDb); using (var ls = new LookupService(geoipDb, LookupService.GEOIP_MEMORY_CACHE)) // Set cached in memory database { Location l = ls.getLocationV6("0:0:0:0:0:ffff:ba21:ea1c"); l.ShouldNotBeNull(); l.countryCode.ShouldEqual("AR"); l.countryName.ShouldEqual("Argentina"); l.latitude.ShouldEqual(-34); l.longitude.ShouldEqual(-64); } }
public void FindRegionCacheDbIp() { // 186.33.234.28 Should give country code "AR", country "Argentina", latitude -34 and longitude -64 string geoipDb = Path.Combine(GeoipDbPath, GeoipDb); using (var ls = new LookupService(geoipDb, LookupService.GEOIP_MEMORY_CACHE)) // Set cached in memory database { Country c = ls.getCountry("186.33.234.28"); c.ShouldNotBeNull(); c.getCode().ShouldEqual("AR"); c.getName().ShouldEqual("Argentina"); } }
public void FindRegionCacheDbIp() { // 186.33.234.28 Should give country code "AR", country "Argentina", latitude -34 and longitude -64 string geoipDb = Path.Combine(GeoipDbPath, GeoLiteCityDb); using (var ls = new LookupService(geoipDb)) // Set cached in memory database { Region r = ls.getRegion("186.33.234.28"); r.ShouldNotBeNull(); //r.getcountryCode().ShouldEqual("AR"); //r.getcountryName().ShouldEqual("Argentina"); } }
public void FindCityDbAccessIp() { // 186.33.234.28 Should give country code "AR", country "Argentina", latitude -34 and longitude -64 string geoipDb = Path.Combine(GeoipDbPath, GeoipDb); using (var ls = new LookupService(geoipDb)) { Location l = ls.getLocation("186.33.234.28"); l.ShouldNotBeNull(); l.countryCode.ShouldEqual("AR"); l.countryName.ShouldEqual("Argentina"); l.latitude.ShouldEqual(-34); l.longitude.ShouldEqual(-64); } }
public void FindCityDbAccessIp() { // Get location 186.33.234.28 Should give country code "AR", country "Argentina", latitude -34 and longitude -64 string geoipDb = Path.Combine(GeoipDbPath, GeoIpRegionDb); using (var ls = new LookupService(geoipDb)) { Region r = ls.getRegion("64.17.254.223"); //Region r = ls.getRegion("186.33.234.28"); //24.24.24.24 //r.ShouldNotBeNull(); r.getregion().ShouldEqual("CA"); //r.countryCode.ShouldEqual("AR"); //r.countryName.ShouldEqual("Argentina"); } }