public IList <LocationDetail> GetInvVisualBoard(string locCode, string itemCode, string flow, DateTime?date, User user) { DetachedCriteria criteria = DetachedCriteria.For(typeof(FlowDetail)); criteria.CreateAlias("Flow", "f"); if (flow != null && flow.Trim() != string.Empty) { criteria.Add(Expression.Eq("Flow.Code", flow)); } if (itemCode != null && itemCode.Trim() != string.Empty) { criteria.Add(Expression.Eq("Item.Code", itemCode)); } if (locCode != null && locCode != string.Empty) { criteria.Add(Expression.Or(Expression.And(Expression.IsNull("LocationTo"), Expression.Eq("f.LocationTo.Code", locCode)), Expression.Eq("LocationTo.Code", locCode))); } IList <FlowDetail> flowDetailList = CriteriaMgr.FindAll <FlowDetail>(criteria); //过滤权限 if (locCode == null || locCode == string.Empty) { flowDetailList = this.FilterFlowDetail(flowDetailList, user); } IList <LocationDetail> ldList = new List <LocationDetail>(); if (flowDetailList != null && flowDetailList.Count > 0) { foreach (FlowDetail fd in flowDetailList) { LocationDetail ld = new LocationDetail(); if (fd.DefaultLocationTo == null) { continue; } ld = this.FindLocationDetail(fd.DefaultLocationTo, fd.Item, date, true); if (ld != null) { ld.FlowDetail = fd; //单位换算 if (!ld.FlowDetail.Item.Uom.Equals(ld.FlowDetail.Uom)) { ld.InTransitQty = UomConversionMgr.ConvertUomQtyInvToOrder(ld.FlowDetail, ld.InTransitQty); ld.QtyToBeIn = UomConversionMgr.ConvertUomQtyInvToOrder(ld.FlowDetail, ld.QtyToBeIn); ld.QtyToBeOut = UomConversionMgr.ConvertUomQtyInvToOrder(ld.FlowDetail, ld.QtyToBeOut); ld.InvQty = UomConversionMgr.ConvertUomQtyInvToOrder(ld.FlowDetail, ld.InvQty); ld.PAB = UomConversionMgr.ConvertUomQtyInvToOrder(ld.FlowDetail, ld.PAB); } ldList.Add(ld); } } } return(ldList); }
LocationDetail validateFileName(List <string> fileNames) { if (fileNames.Count != 2) { return(null); } LocationDetail reportYearAndMonth = null; int i = 0, reportYear = 0; var reportMonth = string.Empty; foreach (var filename in fileNames) { reportYearAndMonth = GetReportYearAndMonthFromFileNames(filename, DateTime.Now.Year); if (reportYearAndMonth == null) { return(null); } if (i == 0) { reportYear = reportYearAndMonth.ReportYear; reportMonth = reportYearAndMonth.ReportMonth; } else if (reportYearAndMonth.ReportYear != reportYear && reportYearAndMonth.ReportMonth != reportMonth) { return(null); } i++; } return(reportYearAndMonth); }
public JsonResult GetLocationDetail(String Lat, String Lng) { //dynamic dyn = jsonData; //var lat = dyn.Lat.Value as string; //var lng = dyn.Lng.Value as string; Helper helper = new Helper(); LocationDetail location = helper.GetLocation(Lat, Lng); if (location != null && location.Results != null && location.Results.Count > 0) { var loc = location.Results[0].address_components.Where(e => e.types[0] == "postal_code"); result.Formatted_Address = location.Results[0].formatted_address; if (loc != null && loc.Count() > 0) { result.PostalCode = loc.First().long_name; } } else { throw new Exception("Did you click Ocean? There is no zipcode."); } result.People = GetByZip(result.PostalCode); result.People = result.People.OrderBy(e => e.firstname).ToList(); return(Json(result, JsonRequestBehavior.AllowGet)); }
//-------------------------------------------------------------------------- public bool GetContents(LocationDetail locationDetail, GetContentsCallback callback) { return(_workerThread.PostTask(_ => { try { Tuple <long, long> surroundingOffsets = ContainsService.Instance.GetSurroundingOffsets( locationDetail.Location, _useLinesForContentRetreival, _contentRetreivalDelta); long contentsWordOffsetBegin = 0; long contentsWordOffsetEnd = 0; string contents = DocumentsService.Instance.GetContents( locationDetail, surroundingOffsets.Item1, surroundingOffsets.Item2, out contentsWordOffsetBegin, out contentsWordOffsetEnd); callback(contents, contentsWordOffsetBegin, contentsWordOffsetEnd, true, null); } catch (Exception e) { callback(null, 0, 0, false, e.Message); } })); }
public override void Start() { if (_isNew) { _locationDetail = new LocationDetail(); } else { Platform.GetService( delegate(ILocationAdminService service) { var response = service.LoadLocationForEdit(new LoadLocationForEditRequest(_locationRef)); _locationRef = response.LocationDetail.LocationRef; _locationDetail = response.LocationDetail; }); } Platform.GetService( delegate(IFacilityAdminService service) { var response = service.ListAllFacilities(new ListAllFacilitiesRequest()); _facilityChoices = response.Facilities; if (_isNew && _locationDetail.Facility == null && response.Facilities.Count > 0) { _locationDetail.Facility = response.Facilities[0]; } }); base.Start(); }
public async Task Test_GetEntriesForLocationsLongTerm_Return() { //Arrange IWeatherProvider mockWeatherProvider = new MockWeatherProvider(); IWeatherUtils mockWeatherUtils = new MockWeatherUtils(); ILocationWeatherManager locationWeatherManager = new LocationWeatherManager( mockWeatherProvider, mockWeatherUtils); var date = new DateTime(2014, 12, 01, 08, 00, 00); var location0 = new Location { Latitude = 0, Longitude = 0 }; var locDetail0 = new LocationDetail { Location = location0, Time = date }; var location1 = new Location { Latitude = 1, Longitude = 1 }; var locDetail1 = new LocationDetail { Location = location1, Time = date }; var locationDetailList = new List <LocationDetail> { locDetail0, locDetail1 }; var expectedEntry0 = (await mockWeatherProvider.GetForecastLongTerm(location0)).Entries.FirstOrDefault(); var expectedEntry1 = (await mockWeatherProvider.GetForecastLongTerm(location1)).Entries.FirstOrDefault(); var expectedDict = new Dictionary <LocationDetail, ForecastDailyEntry> { { locDetail0, expectedEntry0 }, { locDetail1, expectedEntry1 } }; //Act var result = await locationWeatherManager.GetEntriesForLocationsLongTerm(locationDetailList); var key0 = result.First().Key; var value0 = result.First().Value; var key1 = result.Last().Key; var value1 = result.Last().Value; //Assert Assert.IsInstanceOfType(result, typeof(Dictionary <LocationDetail, ForecastDailyEntry>)); Assert.AreEqual(result.Count, 2); // Assert.AreEqual(key0, locDetail0); // Assert.AreEqual(key1, locDetail1); // // Assert.AreEqual(value0, expectedEntry0); // Assert.AreEqual(value1, expectedEntry1); Assert.IsTrue(result.SequenceEqual(expectedDict)); }
private decimal GetTotalOutQty(LocationDetail locationDetail) { DetachedCriteria criteria = DetachedCriteria.For(typeof(LocationTransactionView)); //criteria.CreateAlias("Location", "l"); #region Customize //SecurityHelper.SetRegionSearchCriteria(criteria, "l.Region.Code", this.CurrentUser.Code); //区域权限 CriteriaHelper.SetStartDateCriteria(criteria, "EffDate", _criteriaParam); CriteriaHelper.SetEndDateCriteria(criteria, "EffDate", _criteriaParam); #endregion #region Select Parameters string[] regionCode = locationDetail.Region != null ? new string[] { locationDetail.Region.Code } : null; string[] locationCode = locationDetail.Location != null ? new string[] { locationDetail.Location.Code } : null; string itemCode = locationDetail.Item != null ? locationDetail.Item.Code : null; //CriteriaHelper.SetPartyCriteria(criteria, "l.Region.Code", regionCode); CriteriaHelper.SetLocationCriteria(criteria, "Loc", locationCode); CriteriaHelper.SetItemCriteria(criteria, "Item", itemCode, MatchMode.Exact); criteria.Add(Expression.In("TransType", GetTransType())); #endregion criteria.SetProjection(Projections.Sum("Qty")); IList result = CriteriaMgr.FindAll(criteria); if (result[0] != null) { return((decimal)result[0]); } else { return(0); } }
private LocationDetail GetReportYearAndMonthFromFileNames(string fileName, int thisYear) { var fileNameParts = System.IO.Path.GetFileNameWithoutExtension(fileName).Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries); if (fileNameParts.Length < 2) { return(null); } var yearStr = fileNameParts[fileNameParts.Length - 1]; int reportYear; if (!int.TryParse(yearStr, out reportYear) || !Constants.acceptableYears.Contains(reportYear) || reportYear > thisYear) { MessageBox.Show("Error determining Report year or month. Please ensure the file ends with MMM YYYY"); return(null); } var monthStr = fileNameParts[fileNameParts.Length - 2]; var reportMonth = Constants.GetStandardMonthName(monthStr); if (string.IsNullOrWhiteSpace(reportMonth)) { MessageBox.Show("Error determining Report year or month. Please ensure the file ends with MMM YYYY"); return(null); } var toReturn = new LocationDetail() { ReportYear = reportYear, ReportMonth = reportMonth }; return(toReturn); }
public async Task <bool> RecordVehiclePosition(VehiclePositionDTO vehiclePosition) { var guidDeviceId = Guid.Parse(vehiclePosition.DeviceID); try { if (vehiclePosition != null) { var vehiclePositionModel = new LocationDetail() { Latitude = vehiclePosition.Latitude, Longitude = vehiclePosition.Longitude, UpdateTime = DateTime.Now, DeviceID = guidDeviceId }; _unitOfWork.LocationDetailRepository.Add(vehiclePositionModel); var result = await _unitOfWork.CommitAsync().ConfigureAwait(false); if (result > 0) { return(true); } } return(false); } catch (System.Exception ex) { _logger.LogError(ex.Message); return(false); } }
public void Test_Location_FillIn() { //Arrange Location location = new Location(); location.Longitude = 100; location.Latitude = 100; DateTime date = new DateTime(2014, 12, 01); //Act LocationDetail locationDetail = new LocationDetail(); locationDetail.Location = location; locationDetail.Time = date; Trip trip = new Trip(); trip.StartDateTime = date; trip.Duration = 10; //Assert Assert.AreEqual(locationDetail.Location.Longitude, 100); Assert.AreEqual(trip.StartDateTime, date); }
public void Test_SelectLongTermEntry_SecondOne() { //Arrange IWeatherUtils weatherUtils = new WeatherUtils(new SystemClock()); var forecast = new ForecastLongTerm(); var entry1 = new ForecastDailyEntry(); entry1.UnixTimestamp = 1335913200; //2012/05/01 23:00 var entry2 = new ForecastDailyEntry(); entry2.UnixTimestamp = 1335927600; //2012/05/02 03:00 forecast.Entries = new List <ForecastDailyEntry>() { entry1, entry2 }; var locDetail = new LocationDetail(); locDetail.Time = new DateTime(2012, 5, 1, 0, 0, 0); //Act var entry = weatherUtils.SelectLongTermEntry(locDetail, forecast); //Assert - entry2 should be selected Assert.AreEqual(1335913200, entry.UnixTimestamp); }
public bool SetLocation(LocationDetail location) { if (ModelState.IsValid) { using (var db = new ParkNGODBEntities()) { ////LocationDetail locationData = new LocationDetail(); ////locationData.CreatedDateTime = new DateTime(); ////locationData.VehicleID = location.VehicleID; ////locationData.Location = location.Location; var locationData = db.LocationDetails.Add(location); db.SaveChanges(); if (locationData.LocationID > 0) { return(true); } return(false); } } else { return(false); } }
public void Test_SelectShortTermEntry_SecondOne() { //Arrange IWeatherUtils weatherUtils = new WeatherUtils(new SystemClock()); var forecast = new ForecastShortTerm(); var entry1 = new ForecastShortTermEntry(); entry1.UnixTimestamp = 978361200; //2001/01/01 15:00:00 var entry2 = new ForecastShortTermEntry(); entry2.UnixTimestamp = 978368400; //2001/01/01 17:00:00 forecast.Entries = new List <ForecastShortTermEntry>() { entry1, entry2 }; var locDetail = new LocationDetail(); locDetail.Time = new DateTime(2001, 01, 01, 16, 0, 1); //978364801 //Act var entry = weatherUtils.SelectShortTermEntry(locDetail, forecast); //Assert - entry2 should be selected Assert.AreEqual(978368400, entry.UnixTimestamp); }
protected static LocationDetail GetIhpReportLocationDetails(Workbook workbook, Action <string, string, string, int, int, bool> errorDialog ) { var locationDetail = new LocationDetail(); var xlRange = ((Worksheet)workbook.Sheets[GetProgramAreaIndicators.IhpVmmcProgramAreaName]).UsedRange; var facilityValue = Convert.ToString(getCellValue(xlRange, 2, 2)); //G1 if (!string.IsNullOrWhiteSpace(facilityValue)) { var split = facilityValue.Split(new[] { '>' }, StringSplitOptions.RemoveEmptyEntries); if (split.Length == 2) { locationDetail.FacilityName = split[1]; //we validate the hmiscode } else { throw new ArgumentException("Missing entry or value for 'Facility Name' in worksheet " + GetProgramAreaIndicators.IhpVmmcProgramAreaName); } } else { throw new ArgumentException("Missing entry or value for 'Facility Name' in worksheet " + GetProgramAreaIndicators.IhpVmmcProgramAreaName); } var yearValue = Convert.ToString(getCellValue(xlRange, 5, 2)); //B5 if (!string.IsNullOrWhiteSpace(yearValue)) { int year = -1; if (!int.TryParse(yearValue.Trim(), out year)) { errorDialog?.Invoke(yearValue, "Year", GetProgramAreaIndicators.IhpVmmcProgramAreaName, 5, 2, true); } locationDetail.ReportYear = Convert.ToInt32(yearValue.Trim()); } else { throw new ArgumentException("Missing entry or value for 'Year' in worksheet " + GetProgramAreaIndicators.IhpVmmcProgramAreaName); } //report month var mValue = Convert.ToString(getCellValue(xlRange, 5, 6)); //F5 var monthName = Constants.GetAlternateStandardMonthName(mValue); if (!string.IsNullOrWhiteSpace(monthName)) { locationDetail.ReportMonth = monthName; } else { throw new ArgumentException("Missing entry or value for 'Month Reported on' in worksheet " + GetProgramAreaIndicators.IhpVmmcProgramAreaName); } return(locationDetail); }
//-------------------------------------------------------------------------- public string GetContents(LocationDetail locationDetail, long fileOffsetFrom, long fileOffsetTo, out long contentsWordOffsetBegin, out long contentsWordOffsetEnd) { contentsWordOffsetBegin = 0; contentsWordOffsetEnd = 0; Document document = locationDetail.Document; string contents = DocumentParser.GetContents(document.LocalFile, fileOffsetFrom, fileOffsetTo); long binaryOffset = locationDetail.Location.FileOffset - fileOffsetFrom; contentsWordOffsetBegin = DocumentParser.IndexFromBinaryOffsetInContent(contents, binaryOffset); Word word = WordsService.Instance.GetWordById( locationDetail.Location.WordId); if (word == null) { throw new Exception("Word not found in DB?!"); } contentsWordOffsetEnd = contentsWordOffsetBegin + word.Length; return(contents); }
private static void ShowLocationDetail(DistanceAndLocationDetail distanceAndLocationDetail) { if (distanceAndLocationDetail.Distance != null) { Console.WriteLine("Distance: {0} {1}", distanceAndLocationDetail.Distance.Value, distanceAndLocationDetail.Distance.Units); } if (distanceAndLocationDetail.LocationDetail != null) { LocationDetail locationDetail = distanceAndLocationDetail.LocationDetail; ShowLocationContactAddress(locationDetail.LocationContactAndAddress); Console.WriteLine("Geographic Coordinates: {0}", locationDetail.GeographicCoordinates); if (locationDetail.LocationTypeSpecified) { Console.WriteLine("Location Type: {0}", locationDetail.LocationType); } if (locationDetail.Attributes != null) { Console.WriteLine("Location Attributes"); foreach (LocationAttributesType attribute in locationDetail.Attributes) { Console.WriteLine(" {0}", attribute); } } ShowHours(locationDetail.NormalHours, "Normal Hours"); ShowHours(locationDetail.HoursForEffectiveDate, "Hours for effective date"); ShowCarrierDetails(locationDetail.CarrierDetails); } }
public HttpResponseMessage GetLocationDetail(JObject jsonData) { dynamic dyn = jsonData; var lat = dyn.Lat.Value as string; var lng = dyn.Lng.Value as string; Helper helper = new Helper(); LocationDetail location = helper.GetLocation(lat, lng); if (location != null && location.Results != null && location.Results.Count > 0) { var loc = location.Results[0].address_components.Where(e => e.types[0] == "postal_code"); result.Formatted_Address = location.Results[0].formatted_address; if (loc != null && loc.Count() > 0) { result.PostalCode = loc.First().long_name; } } else { return(Request.CreateResponse(HttpStatusCode.UnsupportedMediaType, "Machli machli jal ki rani!")); } result.People = GetByZip(result.PostalCode); return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public void Test_SelectLongTermEntry_Argument2Null() { IWeatherUtils weatherUtils = new WeatherUtils(new SystemClock()); var loc = new LocationDetail(); weatherUtils.SelectShortTermEntry(loc, null); }
public async Task Test_GetForecastForTrip_ForShortTerm_Return() { //Arrange var trip = CreateTrip(); ILocationWeatherManager mockLocationWeatherManager = new MockLocationWeatherManager(); var mockWeatherUtils = new Mock <IWeatherUtils>(); mockWeatherUtils.Setup(t => t.AvailableForShortTermForecast(It.IsAny <Trip>())).Returns(true); var mockTripIntervalManager = new Mock <ITripIntervalManager>(); var dt = new DateTime(2012, 12, 1, 12, 0, 0); var locDetailList = new List <LocationDetail>(); for (var i = 0; i < 10; i++) { LocationDetail loc = new LocationDetail(); loc.Location = new Location() { Longitude = i, Latitude = i }; loc.Time = dt.AddSeconds(i * 60); locDetailList.Add(loc); } mockTripIntervalManager.Setup(t => t.GetLocationsInIntervalsWithTime(It.IsAny <Trip>())) .Returns(locDetailList); ITripWeatherManager tripWeatherManager = new TripWeatherManager(mockLocationWeatherManager, mockWeatherUtils.Object, mockTripIntervalManager.Object); var expectedEntry = new ForecastEntry(new MockWeatherUtils().SelectShortTermEntry(new LocationDetail(), new ForecastShortTerm())); //Act and Assert var result = await tripWeatherManager.GetForecastForTrip(trip); //Assert Assert.AreEqual(10, result.Count); Assert.AreEqual(new Location() { Latitude = 0, Longitude = 0 }, result.Keys.First().Location); Assert.AreEqual(new Location() { Latitude = 9, Longitude = 9 }, result.Keys.Last().Location); Assert.AreEqual(dt, result.Keys.First().Time); Assert.AreEqual(dt.AddSeconds(9 * 60), result.Keys.Last().Time); Assert.AreEqual(expectedEntry, result.Values.First()); Assert.AreEqual(expectedEntry, result.Values.Last()); }
public ForecastShortTermEntry SelectShortTermEntry(LocationDetail location, ForecastShortTerm forecast) { var mockWeatherProvider = new MockWeatherProvider(); var task = mockWeatherProvider.GetForecastShortTerm(new Location()); Task.WhenAll(task); return(task.Result.Entries[0]); }
public void Test_SelectShortTermEntry_NoEntries() { IWeatherUtils weatherUtils = new WeatherUtils(new SystemClock()); var loc = new LocationDetail(); var fc = new ForecastShortTerm(); fc.Entries = new List <ForecastShortTermEntry>(); weatherUtils.SelectShortTermEntry(loc, fc); }
public ActionResult Create([Bind(Include = "ID,Date,Place")] LocationDetail locationDetail) { if (ModelState.IsValid) { db.LocationDetails.Add(locationDetail); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(locationDetail)); }
public async void PreviousCities_OnItemSelectedAsync(object sender, SelectedItemChangedEventArgs e) { if (!(e.SelectedItem is SearchPageListItem item)) { return; } await LocationDetail.MasterPage_OnInputAsync(item.Name); SearchMaster.PreviousCitiesListView.SelectedItem = null; IsPresented = false; }
public void UpdateLocation(LocationDetail detail, Location location, IPersistenceContext context) { location.Name = detail.Name; location.Id = detail.Id; location.Description = detail.Description; location.Facility = context.Load <Facility>(detail.Facility.FacilityRef, EntityLoadFlags.Proxy); location.Building = detail.Building; location.Floor = detail.Floor; location.PointOfCare = detail.PointOfCare; location.Deactivated = detail.Deactivated; }
public void Test_SelectLongTermEntry_NoEntries() { IWeatherUtils weatherUtils = new WeatherUtils(new SystemClock()); LocationDetail loc = new LocationDetail(); var fc = new ForecastLongTerm(); fc.Entries = new List <ForecastDailyEntry>(); var result = weatherUtils.SelectLongTermEntry(loc, fc); Assert.AreEqual("N/A", result.WeatherDescription[0].Description); }
public ActionResult Index() { if (!Auth.Authentication((UserProfileSessionData)Session[Configuration.SESSIONNAME])) { return RedirectToAction("Index", "Login"); } LocationDetail location = new LocationDetail(); //ViewBag.Cities = location.GetAll(); var result = _sd.GetAll().ToList(); return View(result); }
protected void GV_List_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { LocationDetail ld = (LocationDetail)e.Row.DataItem; this.SetLinkButton(e.Row, "lbQtyToBeIn", new string[] { ld.Item.Code, ld.Location.Code, BusinessConstants.IO_TYPE_IN }, ld.QtyToBeIn != 0); this.SetLinkButton(e.Row, "lbQtyToBeOut", new string[] { ld.Item.Code, ld.Location.Code, BusinessConstants.IO_TYPE_OUT }, ld.QtyToBeOut != 0); this.SetLinkButton(e.Row, "lbInTransitQtyIn", new string[] { ld.Item.Code, ld.Location.Code, BusinessConstants.IO_TYPE_IN }, ld.InTransitQty != 0); this.SetLinkButton(e.Row, "lbInTransitQtyOut", new string[] { ld.Item.Code, ld.Location.Code, BusinessConstants.IO_TYPE_OUT }, ld.InTransitQtyOut != 0); this.SetLinkButton(e.Row, "lbPickedQty", new string[] { ld.Item.Code, ld.Location.Code }, ld.PickedQty != 0); e.Row.Cells[1].Attributes.Add("style", "vnd.ms-excel.numberformat:@"); } }
public async void Search_OnCompletedAsync(object sender, EventArgs e) { var cityEntry = SearchMaster.CityEntry.Text; if (string.IsNullOrEmpty(cityEntry)) { return; } SearchMaster.CityEntry.Text = string.Empty; await LocationDetail.MasterPage_OnInputAsync(cityEntry); IsPresented = false; }
public LocationDetail GetLocationById(int id) { Location location = _db.Locations.Single(l => l.LocationId == id); LocationDetail locationDetail = new LocationDetail() { LocationId = location.LocationId, Title = location.Title, StreetAddress = location.StreetAddress, Description = location.Description, Terrain = location.Terrain, Weather = location.Weather }; return(locationDetail); }
public async Task <ActionResult> LocationDetail(string location) { var date = DateTime.UtcNow; var monthlyUsage = await SQLTemplateStorageManager.GetMonthlyUsageDetailAsync(location, date); var license = await SQLTemplateStorageManager.GetLicenseAsync(location); var locationDetail = new LocationDetail { Usage = monthlyUsage, License = license }; return(View(locationDetail)); }
public async Task <IActionResult> LocationDetail(Guid id) { List <Location> locations = await SiteStatics.Context .Locations .Include(x => x.ParentLocation) .ToListAsync(); Location location = null; if (locations.Count > 0) { location = locations.First(); } LocationDetail retval = new LocationDetail(location); return(new JsonResult(retval)); }
public AddLocationRequest(LocationDetail detail) { this.LocationDetail = detail; }
public UpdateLocationRequest(LocationDetail detail) { this.LocationDetail = detail; }
public LoadLocationForEditResponse(LocationDetail locationDetail) { this.LocationDetail = locationDetail; }