public void TestValidQty(int qty) { OrderDAL Repo; LocationDAL LocDal; var conn = new SqliteConnection("DataSource=:memory:"); conn.Open(); try { var options = new DbContextOptionsBuilder <WheyMenContext>() .UseSqlite(conn) .Options; using (var context = new WheyMenContext(options)) { context.Database.EnsureCreated(); } using (var context = new WheyMenContext(options)) { TestSetup(context); Repo = new OrderDAL(context); LocDal = new LocationDAL(context); var orderItem = new OrderItem { Oid = 1, Qty = qty, Pid = 5, }; Assert.IsTrue(orderItem.ValidateQuantity(LocDal.GetQty(5))); } } finally { conn.Close(); } }
public static DTO.DriveDTO convertToDriveDTO(DAL.Drive drive) { if (drive == null) { return(null); } Loction fromL = LocationDAL.GetLocationById(drive.fromLocation); Loction toL = LocationDAL.GetLocationById(drive.toLocation); DTO.DriveDTO newdrive = new DTO.DriveDTO() { //driveCode = drive.driveCode, driverCode = drive.driverCode, customerCode = drive.customerCode, drivingTime = drive.drivingTime, travelDate = drive.travelDate, fromLocationFormat = fromL.locationFormat, fromLocationLat = fromL.locationLat, fromLocationLng = fromL.locationLng, toLocationFormat = toL.locationFormat, toLocationLat = toL.locationLat, toLocationLng = toL.locationLng, //fromLocation = drive.fromLocation, //toLocation = drive.toLocation, packageSizeCode = drive.packageSizeCode, howLongBeforeReminder = drive.howLongBeforeReminder, transportation = drive.transportation, describeDrive = drive.describeDrive, confirmationCustomer = drive.confirmationCustomer }; return(newdrive); }
public LocationMgr(IConfiguration config) { _iconfiguration = config; var specific_DAL = new LocationDAL(config); DAL = specific_DAL; }
public LocationModel GetById(int locationId) { locationDAL = new LocationDAL(); var locationDto = locationDAL.GetById(locationId); return(Mapper.Map <LocationModel>(locationDto)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { TypeContent.InnerHtml = ActivityTypeDAL.GetTypeHtml(); ObjectContent.InnerHtml = LObjectDAL.GetLObjectsHtml(); LocationContent.InnerHtml = LocationDAL.GetLoctionHtml(); ddlParentType.DataSource = DAL.ActivityTypeDAL.GetTypesByparentId(0); ddlParentType.DataTextField = "Action"; ddlParentType.DataValueField = "ActivityTypeID"; ddlParentType.DataBind(); ddlPLocation.DataSource = DAL.LocationDAL.GetLoctionsByParentId(0); ddlPLocation.DataTextField = "Address"; ddlPLocation.DataValueField = "LocationID"; ddlPLocation.DataBind(); if (DAL.ActivityTypeDAL.GetTypes().Count > 0) { ddlType.DataSource = DAL.ActivityTypeDAL.GetTypes(); ddlType.DataTextField = "Action"; ddlType.DataValueField = "ActivityTypeID"; ddlType.DataBind(); } else { ddlType.Items.Add("系统中尚未存在活动类别"); } } //addTypeBtn.Click += AddTypes; //addObjBtn.Click += addObjects; //addLocatonBtn.Click += addLocation; }
public Location Get(int locationId) { SERVDataContract.DbLinq.Location lret = new LocationDAL().Get(locationId); Location ret = new Location(lret); return(ret); }
public void AfterDateSelectForLocation(DateTime startDate, DateTime endDate) { locationListForSelect = new List <LocationDTO>(); EventDAL locationObject = new EventDAL(); LocationDTO locationDtoObject = new LocationDTO(); LocationDAL locationDALObject = new LocationDAL(); List <Location> locationList = locationDALObject.SelectLocation(); int[] collidingLocationID = locationObject.SelectForEventLocation(startDate, endDate); int collidingLocationIDLength = collidingLocationID.Length; for (int i = 0; i < collidingLocationIDLength; i++) { locationList = locationList.Where(w => w.LocationID != collidingLocationID[i]).ToList <Location>(); } foreach (var item in locationList) { locationDtoObject = new LocationDTO(); locationDtoObject.LocationID = item.LocationID; locationDtoObject.LocationName = item.LocationName; locationListForSelect.Add(locationDtoObject); } }
/// <summary> /// 获取设备缓存信息 /// </summary> /// <param name="p"></param> public static void GetCacheMacAllList(bool isReset) { if (HttpContext.Current.Cache["CacheMacAll"] == null || isReset) { List <Loc_DevInfo> list = new LocationDAL().GetDevList(); HttpContext.Current.Cache.Insert("CacheMacAll", list, null, DateTime.Now.AddHours(6), TimeSpan.Zero); } }
public List <bookstoreLocation> getLocation() { LocationDAL locationDAL = new LocationDAL(); List <bookstoreLocation> locationList = new List <bookstoreLocation>(); locationList = locationDAL.getLocation(); return(locationList); }
/// <summary> /// 重新获取缓存的场所信息 /// </summary> /// <param name="isReset"></param> public static void GetCacheLoca(bool isReset) { if (HttpContext.Current.Cache["ShowCacheLoca"] == null || isReset) { List <Loc_NetBarInfo> list = new LocationDAL().GetLocationList(); HttpContext.Current.Cache.Insert("ShowCacheLoca", list, null, DateTime.Now.AddHours(6), TimeSpan.Zero); } }
public string getLocationByAjax() { LocationDAL locationDAL = new LocationDAL(); List <bookstoreLocation> locationList = new List <bookstoreLocation>(); locationList = locationDAL.getLocation(); return(ObjectToJson(locationList)); }
public async Task <ILocationModel> IndexAsync(HttpContext context, string orgId, CancellationToken cancellationToken) { _dal = new LocationDAL(); ILocationModel model = await _dal.SelectByIDAsync(Convert.ToInt64(orgId), userId, cancellationToken); await PoulateDropDownListAsync(model, cancellationToken); return(model); }
public int Save(Location location, User user) { using (LocationDAL dal = new LocationDAL()) { SERVDataContract.DbLinq.Location l = dal.Get(location.LocationID); UpdatePolicyAttribute.MapPropertiesWithUpdatePolicy(location, l, user, false); return(dal.Update(l)); } }
private LocationDAL GetLocationDalInstance() { if (locationDal == null) { locationDal = new LocationDAL(); } return(locationDal); }
public LocationModel Update(LocationModel location) { locationDAL = new LocationDAL(); var locationDto = Mapper.Map <Location>(location); locationDto.Timestamp = DateTimeOffset.Now; locationDAL.Update(locationDto); return(location); }
public List <Location> ListLocations(string search) { List <Location> ret = new List <Location>(); List <SERVDataContract.DbLinq.Location> locs = new LocationDAL().ListLocations(search); foreach (SERVDataContract.DbLinq.Location l in locs) { ret.Add(new Location(l)); } return(ret); }
/// <summary> /// 获取缓存中场所对象信息 /// </summary> /// <param name="keyword"></param> /// <returns></returns> public static Loc_NetBarInfo GetLocaInfoByNetBar_ID_Two(int NETBAR_ID, string Lname) { List <Loc_NetBarInfo> list = null; if (HttpContext.Current.Cache["ShowCacheLoca"] == null) { GetCacheLoca(); } else { list = (List <Loc_NetBarInfo>)HttpContext.Current.Cache["ShowCacheLoca"]; } if (NETBAR_ID > 0 || !string.IsNullOrEmpty(Lname)) { IEnumerable <Loc_NetBarInfo> IEList = list; try { if (NETBAR_ID > 0) { IEList = IEList.Where(m => m.ID == NETBAR_ID); } else { IEList = IEList.Where(m => m.PLACE_NAME == Lname); } } catch (Exception) { return(null); } list = IEList.ToList(); if (list != null && list.Count != 0) { return(list.First()); } else { Loc_NetBarInfo loca = new LocationDAL().GetLocaByIdOrName(NETBAR_ID, Lname); if (loca != null) { list.Add(loca); HttpContext.Current.Cache.Insert("ShowCacheLoca", list, null, DateTime.Now.AddHours(6), TimeSpan.Zero); return(loca); } return(null); } } else { return(null); } }
public static bool Delete(int locationToSave) { if (locationToSave > 0) { return(LocationDAL.Delete(locationToSave)); } else { throw new BLLException("Delete failed. Location ID is Invalid: " + locationToSave.ToString()); } }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="loginUser"></param> /// <returns></returns> public bool LogicDeleteInfo(long id, string loginUser) { ///校验对应是否已经维护了工位TM_BAS_LOCATION,已逻辑删除的生产线不在校验范围内 int cnt = new LocationDAL().GetCounts("[WORKSHOP_SECTION] in (select [WORKSHOP_SECTION] from [LES].[TM_BAS_WORKSHOP_SECTION] with(nolock) where [ID] = " + id + " and [VALID_FLAG] = 1)"); if (cnt > 0) { throw new Exception("MC:0x00000103");///该工段下还有工位,无法删除 } return(dal.LogicDelete(id, loginUser) > 0 ? true : false); }
/// <summary> /// 获取缓存中设备对象信息 /// </summary> /// <param name="keyword"></param> /// <returns></returns> public static Loc_DevInfo GetMacInfoByDevAP_ID_Two(int DevAP_ID, string AP_MAC) { List <Loc_DevInfo> list = null; if (HttpContext.Current.Cache["CacheMacAll"] == null) { GetCacheMacAllList(); } else { list = (List <Loc_DevInfo>)HttpContext.Current.Cache["CacheMacAll"]; } if (DevAP_ID > 0 || !string.IsNullOrEmpty(AP_MAC)) { IEnumerable <Loc_DevInfo> IEList = list; try { if (DevAP_ID > 0) { IEList = IEList.Where(m => m.ID == DevAP_ID); } else if (!string.IsNullOrEmpty(AP_MAC)) { IEList = IEList.Where(m => m.AP_MAC == AP_MAC); } } catch (Exception ex) { return(null); } list = IEList.ToList(); if (list != null && list.Count != 0) { return(list.First()); } else { Loc_DevInfo mac = new LocationDAL().GetMacInfoByIdOrMac(DevAP_ID, AP_MAC); if (mac != null) { list.Add(mac); HttpContext.Current.Cache.Insert("CacheMacAll", list, null, DateTime.Now.AddHours(6), TimeSpan.Zero); return(mac); } return(null); } } else { return(null); } }
public string getDemoRTInfo() { DoorDAL doorDAL = new DoorDAL(); List <doorRecord> doorRecordList = doorDAL.getDemoDoorInfo(); RfidDAL rfidDAL = new RfidDAL(); List <RFIDRecord> RFIDRecordList = rfidDAL.getDemoRFIDInfo(); bookDAL bookDAL = new bookDAL(); ReaderDAL readerDAL = new ReaderDAL(); LocationDAL locationDAL = new LocationDAL(); string demoInfoInJson = "["; bool flag = true; //Door_RT_info foreach (doorRecord doorRecord in doorRecordList) { if (!flag) { demoInfoInJson += ","; } string locationName = locationDAL.getLocationByDoorIp(doorRecord.Door_ip); string readerName = readerDAL.getReaderNameBySC(doorRecord.Signal_code); string each = "{\"action\":\"" + doorRecord.Action + "\","; each += "\"reader_name\":\"" + readerName + "\","; each += "\"generate_date\":\"" + doorRecord.Generate_date + "\","; each += "\"location_door\":\"" + locationName + "\","; each += "\"door_ip\":\"" + doorRecord.Door_ip + "\"}"; demoInfoInJson += each; flag = false; } //RFID_RT_info foreach (RFIDRecord RFIDRecord in RFIDRecordList) { if (!flag) { demoInfoInJson += ","; } string locationName = locationDAL.getLocationByRFIDIp(RFIDRecord.Ip); string bookName = bookDAL.getbookNameBySC(RFIDRecord.Signal_code); string each = "{\"signal_code\":\"" + RFIDRecord.Signal_code + "\","; each += "\"book_name\":\"" + bookName + "\","; each += "\"action_date\":\"" + RFIDRecord.Action_date + "\","; each += "\"location_rfid\":\"" + locationName + "\","; each += "\"ip\":\"" + RFIDRecord.Ip + "\"}"; demoInfoInJson += each; flag = false; } demoInfoInJson += "]"; return(demoInfoInJson); }
private void btnSubmit_Click(object sender, EventArgs e) { splashScreenManager1.ShowWaitForm(); splashScreenManager1.SetWaitFormCaption("正在处理数据"); splashScreenManager1.SetWaitFormDescription("请稍后..."); LocationDAL.GetAllLocation(@"F:\研究生\油工数据\data\1020.data.bak"); ReadFilesDAL.ReadFiles(txtFAPath.Text); DatabaseWellDAL dwd = new DatabaseWellDAL(); dwd.GetLTJInf(MainForm.strEndDate); splashScreenManager1.CloseWaitForm(); }
public DataTable GetById(int id) { try { LocationDAL locationDAL = new LocationDAL(); return(locationDAL.GetById(id)); } catch (Exception) { throw; } }
public async Task TestOrdDeleteEmpty() { OrderDAL Repo; LocationDAL LocDal; var conn = new SqliteConnection("DataSource=:memory:"); conn.Open(); try { var options = new DbContextOptionsBuilder <WheyMenContext>() .UseSqlite(conn) .Options; using (var context = new WheyMenContext(options)) { context.Database.EnsureCreated(); } using (var context = new WheyMenContext(options)) { TestSetup(context); Repo = new OrderDAL(context); LocDal = new LocationDAL(context); var newCust = new Order { CustId = 1, Total = 0, LocId = 1, Timestamp = DateTime.Now }; Repo.Add(newCust); var custs = await Repo.GetOrds(); int initialCount = custs.ToList().Count; var newCust1 = new Order { CustId = 1, Total = 0, LocId = 1, Timestamp = DateTime.Now }; int rem = Repo.Add(newCust1); custs = await Repo.GetOrds(); int current = custs.ToList().Count; Assert.AreEqual(initialCount, initialCount); Repo.Remove(rem); } } finally { conn.Close(); } }
public bool Delete(Locations location) { try { LocationDAL locationDAL = new LocationDAL(); return(locationDAL.Delete(location)); } catch (Exception) { throw; } }
public DataTable GetAll() { try { LocationDAL locationDAL = new LocationDAL(); return(locationDAL.GetAll()); } catch (Exception) { throw; } }
public async Task TestOrdtAdd() { OrderDAL Repo; LocationDAL LocDal; var conn = new SqliteConnection("DataSource=:memory:"); conn.Open(); try { var options = new DbContextOptionsBuilder <WheyMenContext>() .UseSqlite(conn) .Options; using (var context = new WheyMenContext(options)) { context.Database.EnsureCreated(); } using (var context = new WheyMenContext(options)) { TestSetup(context); Debug.WriteLine(context.Customer.ToList().Count); Repo = new OrderDAL(context); LocDal = new LocationDAL(context); var custs = await Repo.GetOrds(); int initial_count = custs.ToList().Count; Order cust1 = new Order { CustId = 1, LocId = 1, Total = 0, Timestamp = DateTime.Now }; int x = Repo.Add(cust1); custs = await Repo.GetOrds(); int final_count = custs.ToList().Count; Assert.AreEqual(final_count, initial_count + 1); Repo.Remove(x); } } finally { conn.Close(); } }
public void TestOrdTotalUpdate() { OrderDAL Repo; LocationDAL LocDal; var conn = new SqliteConnection("DataSource=:memory:"); conn.Open(); try { var options = new DbContextOptionsBuilder <WheyMenContext>() .UseSqlite(conn) .Options; using (var context = new WheyMenContext(options)) { context.Database.EnsureCreated(); } using (var context = new WheyMenContext(options)) { TestSetup(context); Repo = new OrderDAL(context); LocDal = new LocationDAL(context); var newCust = new Order { CustId = 1, Total = 0, LocId = 1, Timestamp = DateTime.Now }; int addedID = Repo.Add(newCust); var orderItem = new OrderItem { Oid = addedID, Qty = 2, Pid = 5, }; Repo.AddOrderItem(orderItem); var order = Repo.FindByID(addedID); Assert.AreEqual(0, order.Total); Repo.RemoveOrderItem(orderItem); Repo.Remove(addedID); } } finally { conn.Close(); } }
public static int Save(Location locationToSave) { BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection(); if (string.IsNullOrEmpty(locationToSave.Name)) { saveBrokenRules.Add("Location Name", "Name is required."); } if (saveBrokenRules.Count() > 0) { throw new BLLException("There was an error saving Gym", saveBrokenRules); } else { return(LocationDAL.Save(locationToSave)); } }
public void TestSetup(WheyMenContext context) { OrderDAL Repo; LocationDAL LocDal; CustomerDAL CustDal; Repo = new OrderDAL(context); LocDal = new LocationDAL(context); CustDal = new CustomerDAL(context); var cust = new Customer { Id = 1, Name = "jon", LastName = "asd", Email = "*****@*****.**", Username = "******", Pwd = "asd" }; var loc = new Loc { Id = 1, Name = "gnc", }; var prod = new Products { Id = 1, Price = 12, Name = "wpi", }; var inventory = new Inventory { Id = 5, Qty = 10000, Pid = 1, StoreId = 1 }; CustDal.Add(cust); LocDal.Add(loc); context.Products.Add(prod); context.Inventory.Add(inventory); context.SaveChanges(); }