public DebugCreatures(FFACE fface, UnitService units) { InitializeComponent(); this._fface = fface; this._units = units; _timer.Tick += new EventHandler(Timer_Tick); _timer.Interval = new TimeSpan(0, 0, 0, 1); _timer.Start(); this.Show(); }
private IDictionary <UnitType, List <object> > GetRoots() { var roots = new UnitService().GetByRootId(Constant.DEFAULT_UNIT_ROOT_ID); var hospitals = roots.Where(item => item.Type == UnitType.Hospital).Select(item => new { Id = item.Id, Name = item.Name }).ToList <object>(); var vendors = roots.Where(item => item.Type == UnitType.Vendor).Select(item => new { Id = item.Id, Name = item.Name }).ToList <object>(); var dic = new Dictionary <UnitType, List <object> >(); dic[UnitType.Hospital] = hospitals; dic[UnitType.Vendor] = vendors; return(dic); }
public ActionResult List(int length, int start, string search) { UnitService svrUnit = (new UnitService()); List <tbl_Unit> data = svrUnit.getAll(new PagingModel() { offset = start, limit = length, search = search }); int recordsTotal = (int)svrUnit.countAll(new PagingModel() { offset = start, limit = length, search = search }); int recordsFiltered = recordsTotal; int draw = 1; try { draw = int.Parse(Request.Params["draw"]); }catch { } return(Json(new { draw, recordsTotal, recordsFiltered, data }, JsonRequestBehavior.AllowGet)); }
//加载组织信息 private void LoadUnitsInfo() { try { var service = new UnitService(); var source = service.GetRootUnitsByDefaultRelationMode(loggingSessionInfo); this.drpUnit.DataBind(source.Select(obj => new controls_DropDownTree.tvNode { CheckState = false, Complete = false, ShowCheck = false, Text = obj.Name, Value = obj.Id, }).ToArray()); } catch (Exception ex) { PageLog.Current.Write(ex); this.InfoBox.ShowPopError("加载数据出错!"); } }
public void Init( GameStateUpdateService update, UnitService units, UnitFragment.Factory unitFragment, UnitsWindow.Factory unitsWindow, Canvas parent, string levelDesc, Action callback ) { _update = update; _units = units; _unitFragment = unitFragment; _unitsWindow = unitsWindow; _levelDesc = levelDesc; _callback = callback; _update.AddHandler <StartLevelCommand>(OnStartLevel); CloseButton.onClick.AddListener(() => Animation.Hide(() => Destroy(gameObject))); StartButton.onClick.AddListener(OnStart); Header.text = levelDesc; FillUnits(); UpdateInteractable(); ShowAt(parent); }
public async Task UnitService_Should_Delete_Unit_Async() { // Arrange SetUpUnitOfWork(); var service = new UnitService(_unitOfWork.Object, _mapper); var entity = new UnitDTO() { Name = "TestName", ShortName = "TestSN", }; entity = await service.CreateAsync(entity); await _unitOfWork.Object.SaveAsync(); // Act await service.DeleteAsync(entity.Id); await _unitOfWork.Object.SaveAsync(); // Assert Assert.Null(await service.GetAsync(entity.Id)); }
public async void Create_NoErrorsOccurred_ShouldReturnResponse() { var mock = new ServiceMockFacade <IUnitService, IUnitRepository>(); var model = new ApiUnitServerRequestModel(); mock.RepositoryMock.Setup(x => x.Create(It.IsAny <Unit>())).Returns(Task.FromResult(new Unit())); var service = new UnitService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.UnitModelValidatorMock.Object, mock.DALMapperMockFactory.DALUnitMapperMock, mock.DALMapperMockFactory.DALCallAssignmentMapperMock, mock.DALMapperMockFactory.DALUnitOfficerMapperMock); CreateResponse <ApiUnitServerResponseModel> response = await service.Create(model); response.Should().NotBeNull(); response.Success.Should().BeTrue(); mock.ModelValidatorMockFactory.UnitModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiUnitServerRequestModel>())); mock.RepositoryMock.Verify(x => x.Create(It.IsAny <Unit>())); mock.MediatorMock.Verify(x => x.Publish(It.IsAny <UnitCreatedNotification>(), It.IsAny <CancellationToken>())); }
protected UnitsController GetController(UnitService service) { var user = new Mock <ClaimsPrincipal>(); var claims = new Claim[] { new Claim("username", "unittestusername") }; user.Setup(u => u.Claims).Returns(claims); UnitsController controller = new UnitsController(service); controller.ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { User = user.Object } }; controller.ControllerContext.HttpContext.Request.Headers["Authorization"] = "Bearer unittesttoken"; controller.ControllerContext.HttpContext.Request.Path = new PathString("/v1/unit-test"); return(controller); }
public void Init( GameStateUpdateService update, ItemService items, UnitService units, ItemFragment.Factory itemFragment, ItemsWindow.Factory itemsWindow, Canvas parent, StateUnitModel unit ) { _update = update; _items = items; _units = units; _itemFragment = itemFragment; _itemsWindow = itemsWindow; _unit = unit; update.AddHandler <EquipItemCommand> (OnEquipItem); update.AddHandler <TakeOffItemCommand>(OnTakeOffItem); CloseButton.onClick.AddListener(Hide); CreateFragments(); Refresh(); ShowAt(parent); }
public JsonNetResult JsonQuery(string condition, PagerInfo pager) { if (!this.IsAdmin) { condition = new UnitService().Get(UserContext.RootUnitId)?.Name; } var list = new UnitService().QueryRoots(condition, UnitType.Hospital, pager); var result = new List <UnitModel>(); foreach (var item in list) { result.Add(new UnitModel { Id = item.Id, Name = item.Name, Description = item.Description, ShortCode = item.ShortCode, ContactId = item.ContactId }); } return(JsonNet(new ResponseResult(true, result, pager))); }
/// <summary> /// 获取供应商关联的医院 /// </summary> /// <param name="id">供应商ID</param> /// <returns></returns> public ActionResult JsonVendorHospitals(string id) { if (string.IsNullOrWhiteSpace(id)) { throw new Exception("The id unit is empty."); } var hospitals = new UnitService().QueryRoots(UnitType.Hospital).ToList(); var selectedHospitals = new VendorHospitalService().GetByVendor(id); var notSelectedHospitals = new List <UnitEntity>(); var selectedHospital = new List <UnitEntity>(); hospitals.ForEach(m => { if (selectedHospitals.All(j => j.HospitalId != m.Id)) { notSelectedHospitals.Add(m); } else { selectedHospital.Add(m); } }); return(JsonNet(new ResponseResult(true, new { vendorId = id, notSelectedHospitals = notSelectedHospitals, selectedHospitals = selectedHospital }))); }
static void Main(string[] args) { Unit u1 = new Unit(1, "u1", null); Unit u2 = new Unit(2, "u2", 1); Unit u3 = new Unit(3, "u3", 1); Unit u4 = new Unit(4, "u4", 2); Unit u5 = new Unit(5, "u5", 2); Unit u6 = new Unit(6, "u6", 4); Unit u7 = new Unit(7, "u7", 6); Dictionary <int, List <Unit> > result = UnitService.ToDictionnary(new List <Unit> { u1, u2, u3, u4, u5, u6, u7 }); foreach (var r in result) { Console.Write($"{r.Key} => {{"); foreach (var v in r.Value) { Console.Write(v.Id); } Console.Write("}\n"); } }
public void loadData() { btnDelete.Enabled = false; ProductTypeService productTypeService = new ProductTypeService(new CoffeShopContext()); UnitService unitService = new UnitService(new CoffeShopContext()); ProductService productService = new ProductService(new CoffeShopContext()); gridControl1.DataSource = productService.GetAllProduct(); // AreaService areaService = new AreaService(new CoffeShopContext()); RepositoryItemComboBox productType = new RepositoryItemComboBox(); productType.Items.AddRange(productTypeService.GetAllName()); gridControl1.RepositoryItems.Add(productType); gridView1.Columns[4].ColumnEdit = productType; RepositoryItemComboBox unit = new RepositoryItemComboBox(); unit.Items.AddRange(unitService.GetAllName()); gridControl1.RepositoryItems.Add(unit); gridView1.Columns[5].ColumnEdit = unit; btnDelete.Enabled = false; }
public async Task LeaveUnitMemberAsync() { using (var repo = MainRepository.WithReadAndWrite()) { var old = await repo.Unit.GetByMemberIdAsync(this.AuthData.CharacterId); if (old.Member.HasData) { var oldMember = old.Member.Data; if (oldMember.Post == UnitMemberPostType.Leader) { // 隊長は部隊から脱げられない ErrorCode.InvalidOperationError.Throw(); } } else { ErrorCode.UnitNotFoundError.Throw(); } UnitService.Leave(repo, this.AuthData.CharacterId); await repo.SaveChangesAsync(); } }
///<summary> ///Restore player from this ///</summary> public void SetBuild(Player pl) { pl.SoftReset(); lock (this) { foreach (var ent in Abilities) { pl.MineralsCurrent += UnitService.AbilityUpgradeUnit(AbilityPool.Abilities.SingleOrDefault(x => x.Ability == ent), pl); } foreach (var ent in Upgrades) { pl.MineralsCurrent += UnitService.UpgradeUnit(ent, pl); } foreach (var ent in Units) { if (ent.Value > 0) { for (int i = 0; i < ent.Value; i++) { Unit unit = UnitPool.Units.SingleOrDefault(x => x.ID == ent.Key).DeepCopy(); var positions = Position.Where(x => x.Key == unit.ID).ToList(); if (positions.Count() >= i) { Vector2Ser vec = positions.ElementAt(i).Value; unit.PlacePos = new Vector2(vec.x, vec.y); UnitService.NewUnit(pl, unit); pl.Units.Add(unit); pl.MineralsCurrent += unit.Cost; } } } } } }
public void TestRemoveUnit() { #region Arrange Controller.ControllerContext.HttpContext = new MockHttpContext(1, new[] { "" }); ControllerRecordFakes.FakeApplications(3, ApplicationRepository); ControllerRecordFakes.FakeUnits(3, UnitRepository); ControllerRecordFakes.FakeUsers(3, UserRepository); var unitAssociations = new List <UnitAssociation>(); for (int i = 0; i < 3; i++) { unitAssociations.Add(CreateValidEntities.UnitAssociation(i + 1)); unitAssociations[i].Application = ApplicationRepository.GetNullableById(2); unitAssociations[i].User = UserRepository.GetNullableById(1); unitAssociations[i].Unit = UnitRepository.GetNullableById(i + 1); } ControllerRecordFakes.FakeUnitAssociations(2, UnitAssociationRepository, unitAssociations); UserService.Expect(a => a.CanUserManageGivenLogin("Name2", "UserName", "LoginId1")).Return(true).Repeat.Any(); UnitService.Expect(a => a.GetVisibleByUser("Name2", "UserName")).Return(UnitRepository.Queryable).Repeat.Any(); #endregion Arrange #region Act Controller.RemoveUnit("Name2", "LoginId1", 2); #endregion Act #region Assert UserService.AssertWasCalled(a => a.CanUserManageGivenLogin("Name2", "UserName", "LoginId1")); UnitService.AssertWasCalled(a => a.GetVisibleByUser("Name2", "UserName")); UnitAssociationRepository.AssertWasCalled(a => a.Remove(Arg <UnitAssociation> .Is.Anything)); var args = (UnitAssociation)UnitAssociationRepository.GetArgumentsForCallsMadeOn(a => a.Remove(Arg <UnitAssociation> .Is.Anything))[0][0]; Assert.AreEqual(2, args.Id); Assert.AreEqual("ShortName2", args.Unit.ShortName); Assert.AreEqual("LoginId1", args.User.LoginId); Assert.AreEqual("Name2", args.Application.ToString()); #endregion Assert }
public IActionResult Del(Plan plan) { var planSerVice = new PlanService(); UnitService unitService = new UnitService(); CaseService caseService = new CaseService(); CasedetailService detailservice = new CasedetailService(); var units = unitService.QueryByPid(plan.Pid); foreach (Unit u in units) { unitService.Del(u.Unid); } var cases = caseService.QueryByPid(plan.Pid); foreach (Thecase c in cases) { caseService.Del(c.Cid); detailservice.Del(c.Cid); } var count = planSerVice.Del(plan.Pid); return(Redirect(Url.Action("Index", "_Plan"))); }
protected override GetDisplaynoneRD ProcessRequest(DTO.Base.APIRequest <GetDisplaynoneRP> pRequest) { GetDisplaynoneRD rd = new GetDisplaynoneRD(); var customerId = pRequest.Parameters.CustomerId; var textId = pRequest.Parameters.TextId; var currentUserInfo = Default.GetBSLoggingSession(customerId, "1"); var UnitServiceBll = new UnitService(currentUserInfo); CustomerBasicSettingBLL customerBasic = new CustomerBasicSettingBLL(currentUserInfo); bool isShowAll = customerBasic.CheckIsAllAccessoriesStores(); //判断是否显示所有门店 bool isShowSearch = customerBasic.CheckIsSearchAccessoriesStores(); //判断是否显示搜索栏 string forwardingMessageLogo = customerBasic.GetForwardingMessageLogo(); //转发消息图标 string forwardingMessageTitle = customerBasic.GetForwardingMessageTitle(); //转发消息默认标题 string forwardingMessageSummary = customerBasic.GetForwardingMessageSummary(); //转发消息默认摘要文字 rd.IsAllAccessoriesStores = isShowAll; //是否显示全部 rd.IsSearchAccessoriesStores = isShowSearch; //是否显示搜索栏 rd.ForwardingMessageLogo = forwardingMessageLogo; //转发消息图标 rd.ForwardingMessageTitle = forwardingMessageTitle; //转发消息默认标题 rd.ForwardingMessageSummary = forwardingMessageSummary; //转发消息默认摘要文字 return(rd); }
public InvoiceTollTariffsController(InvoiceNumberService invoiceNumSvc, ListReleaseInvoiceService listReleaseInvoiceSvc, TemplateInvoiceService templateInvoiceSvc, CustomerService cumtomerSvc, InvoiceService invoiceSvc, BanksService banksSvc, CurrencyService currencySvc, ProductService productSvc, UnitService unitSvc) { _unitSvc = unitSvc; _listReleaseInvoiceSvc = listReleaseInvoiceSvc; _templateInvoiceSvc = templateInvoiceSvc; _invoiceNumberSvc = invoiceNumSvc; _cumtomerSvc = cumtomerSvc; _invoiceSvc = invoiceSvc; _banksSvc = banksSvc; _currencySvc = currencySvc; _productSvc = productSvc; }
public void TestGetVisibleByUserReturnsExpectedResults4() { #region Arrange var schoolRepository = FakeRepository <School>(); Controller.Repository.Expect(a => a.OfType <School>()).Return(schoolRepository).Repeat.Any(); UnitService = new UnitService(RoleService, schoolRepository, UnitRepository, UnitAssociationRepository); var roles = new List <Role>(); roles.Add(CreateValidEntities.Role(1)); roles[0].Name = "ManageNot"; roles.Add(CreateValidEntities.Role(2)); roles[1].Name = "ManageUnit"; ControllerRecordFakes.FakeRoles(5, RoleRepository, roles); ControllerRecordFakes.FakeApplications(3, ApplicationRepository); var schools = new List <School>(); schools.Add(CreateValidEntities.School(1)); schools[0].Units = new List <Unit>(); schools[0].Units.Add(CreateValidEntities.Unit(1)); schools[0].Units[0].SetIdTo(1); schools[0].Units.Add(CreateValidEntities.Unit(2)); schools[0].Units[0].SetIdTo(2); ControllerRecordFakes.FakeSchools(3, schoolRepository, schools); var units = new List <Unit>(); units.Add(CreateValidEntities.Unit(1)); units.Add(CreateValidEntities.Unit(2)); units.Add(CreateValidEntities.Unit(3)); units[0].School = schoolRepository.Queryable.First(); units[1].School = schoolRepository.GetNullableById(2); units[2].School = schoolRepository.Queryable.First(); var unitAssociations = new List <UnitAssociation>(); unitAssociations.Add(CreateValidEntities.UnitAssociation(1)); unitAssociations.Add(CreateValidEntities.UnitAssociation(2)); unitAssociations.Add(CreateValidEntities.UnitAssociation(3)); unitAssociations[0].Application = ApplicationRepository.GetNullableById(2); unitAssociations[0].Unit = units[0]; unitAssociations[0].Unit.School = CreateValidEntities.School(1); unitAssociations[0].Unit.School.SetId("1"); unitAssociations[0].User = CreateValidEntities.User(1); unitAssociations[0].User.LoginId = "UserName"; unitAssociations[1].Application = ApplicationRepository.GetNullableById(1); unitAssociations[1].Unit = units[1]; unitAssociations[1].Unit.School = CreateValidEntities.School(1); unitAssociations[1].Unit.School.SetId("1"); unitAssociations[1].User = CreateValidEntities.User(1); unitAssociations[1].User.LoginId = "UserName"; unitAssociations[2].Application = ApplicationRepository.GetNullableById(2); unitAssociations[2].Unit = units[2]; unitAssociations[2].Unit.School = CreateValidEntities.School(1); unitAssociations[2].Unit.School.SetId("1"); unitAssociations[2].User = CreateValidEntities.User(1); unitAssociations[2].User.LoginId = "UserNameNot"; units[0].UnitAssociations = new List <UnitAssociation>(); units[1].UnitAssociations = new List <UnitAssociation>(); units[2].UnitAssociations = new List <UnitAssociation>(); units[0].UnitAssociations.Add(unitAssociations[0]); units[1].UnitAssociations.Add(unitAssociations[1]); units[1].UnitAssociations.Add(unitAssociations[2]); ControllerRecordFakes.FakeUnits(2, UnitRepository, units); ControllerRecordFakes.FakeUnitAssociations(0, UnitAssociationRepository, unitAssociations); RoleService.Expect(a => a.GetManagementRolesForUserInApplication("Name2", "UserName")).Return(RoleRepository.Queryable.Select(a => a.Name).ToList()).Repeat.Any(); #endregion Arrange #region Act var result = UnitService.GetVisibleByUser("Name2", "UserName"); #endregion Act #region Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(IQueryable <Unit>)); Assert.AreEqual(1, result.Count()); Assert.AreEqual("ShortName1", result.ElementAt(0).ShortName); #endregion Assert }
public StateMemory(IMemoryAPI eliteApi) { EliteApi = eliteApi; Executor = new Executor(eliteApi); UnitService = new UnitService(eliteApi); }
public UnitsController(UnitService units) { Units = units; }
// /// <summary> /// 处理会员的上下线关系 /// 会员状态 已经有上级关系 有新的附带上级关系 /// 从未关注的Vip 1 1 重建关系 /// 从未关注的Vip 0 1 重建关系 /// 取消关注的Vip 0 1 重建关系 /// 从未关注的Vip 0 0 /// 从未关注的Vip 1 0 /// 取消关注的Vip 1 0 /// 取消关注的Vip 0 0 /// 取消关注的Vip 1 1 /// ShareVipID 没内容的 return public void SetShareVip(string vipid, string openId) { #region 验证 if (string.IsNullOrEmpty(ShareVipID))//如果没有上级分享人员 { return; } #endregion #region Vip实体 VipBLL vipBll = new VipBLL(loggingSessionInfo); VipEntity vipInfotmp = null; if (string.IsNullOrEmpty(vipid)) { return; } else { vipInfotmp = vipBll.GetByID(vipid); } if (vipInfotmp == null) { return; } #endregion #region UnitId string UnitId = ""; //获取分享人的门店信息 //员工 或者 客服 string shareVipOpenid = ""; if (SourceId == 1 || SourceId == 2) //获取分享员工的默认门店 { UnitId = vipBll.GetUnitByUserId(ShareVipID); //获取员工的默认门店 } else { //获取分享会员的门店 VipEntity shareVip = vipBll.GetByID(ShareVipID); if (shareVip != null) { UnitId = shareVip.CouponInfo;//会员的会籍店 shareVipOpenid = shareVip.WeiXinUserId; } } #endregion #region 判断用户类型 #region 关注的 if (vipInfotmp.Status >= 1)//关注过的 { //当前没有上线,才给他建立一个上线 if (string.IsNullOrEmpty(vipInfotmp.SetoffUserId) && string.IsNullOrEmpty(vipInfotmp.HigherVipID)) { //会员 或者 客服 if (SourceId == 1 || SourceId == 2)//获取分享员工的默认门店 { vipInfotmp.SetoffUserId = ShareVipID; vipInfotmp.HigherVipID = ""; vipInfotmp.Col21 = System.DateTime.Now.ToString(); } //会员 else { vipInfotmp.HigherVipID = ShareVipID; vipInfotmp.SetoffUserId = ""; vipInfotmp.Col21 = System.DateTime.Now.ToString(); } } else if (SourceId == 4 && string.IsNullOrEmpty(vipInfotmp.Col20)) { vipInfotmp.Col20 = ShareVipID; vipInfotmp.Col21 = System.DateTime.Now.ToString(); } } #endregion #region 取消关注的 else if (vipInfotmp.Status == 0 && vipInfotmp.Col25 == "1")//取消关注的 { if (string.IsNullOrEmpty(vipInfotmp.SetoffUserId) && string.IsNullOrEmpty(vipInfotmp.HigherVipID)) { if (SourceId == 1 || SourceId == 2)//获取分享员工的默认门店 { vipInfotmp.SetoffUserId = ShareVipID; vipInfotmp.HigherVipID = null; vipInfotmp.Col21 = System.DateTime.Now.ToString(); } else { vipInfotmp.HigherVipID = ShareVipID; vipInfotmp.SetoffUserId = null; vipInfotmp.Col21 = System.DateTime.Now.ToString(); } } else if (SourceId == 4 && string.IsNullOrEmpty(vipInfotmp.Col20)) { vipInfotmp.Col20 = ShareVipID; vipInfotmp.Col21 = System.DateTime.Now.ToString(); } } #endregion #region 未关注的 else { //未关注的(oauth认证获取的) //客服 员工 if (SourceId == 1 || SourceId == 2) //获取分享员工的默认门店 { vipInfotmp.SetoffUserId = ShareVipID; vipInfotmp.HigherVipID = null; vipInfotmp.Col21 = System.DateTime.Now.ToString(); } else if (SourceId == 4) { vipInfotmp.Col20 = ShareVipID; vipInfotmp.Col21 = System.DateTime.Now.ToString(); } //会员 else { vipInfotmp.HigherVipID = ShareVipID; vipInfotmp.SetoffUserId = null; vipInfotmp.Col21 = System.DateTime.Now.ToString(); } } #endregion #endregion if (string.IsNullOrEmpty(UnitId)) { UnitService unitServer = new UnitService(loggingSessionInfo); UnitId = unitServer.GetUnitByUnitTypeForWX("总部", null).Id; //获取总部门店标识 } vipInfotmp.CouponInfo = UnitId; vipInfotmp.Col24 = ObjectID; vipInfotmp.Col23 = SourceId.ToString(); vipBll.Update(vipInfotmp, false); //分享记录 T_LEventsSharePersonLogBLL t_LEventsSharePersonLogBLL = new T_LEventsSharePersonLogBLL(loggingSessionInfo); //先查看这个会员之前是否已经打开这个图文素材 var t_LEventsSharePersonLogTemp = new T_LEventsSharePersonLogEntity(); t_LEventsSharePersonLogTemp.BusTypeCode = objectType; t_LEventsSharePersonLogTemp.ObjectId = ObjectID; ////分享的链接代表的对象,活动或者商品 t_LEventsSharePersonLogTemp.ShareVipType = SourceId; // 1员工,2客服,3会员 4超级分销商 t_LEventsSharePersonLogTemp.ShareVipID = ShareVipID; t_LEventsSharePersonLogTemp.BeShareVipID = vipid; //被分享人 var t_LEventsSharePersonLogOld = t_LEventsSharePersonLogBLL.QueryByEntity(t_LEventsSharePersonLogTemp, null); //如果已经有这样的记录,就不要再写了 if (t_LEventsSharePersonLogOld != null && t_LEventsSharePersonLogOld.Length > 0) { return; } //第一次打开的时候才创建 var t_LEventsSharePersonLog = new T_LEventsSharePersonLogEntity(); t_LEventsSharePersonLog.SharePersonLogId = Guid.NewGuid(); t_LEventsSharePersonLog.BusTypeCode = objectType; t_LEventsSharePersonLog.ObjectId = ObjectID; ////分享的链接代表的对象,活动或者商品 t_LEventsSharePersonLog.ShareVipType = SourceId; // 1员工,2客服,3会员 t_LEventsSharePersonLog.ShareVipID = ShareVipID; t_LEventsSharePersonLog.ShareOpenID = shareVipOpenid; //如果是会员,取出来 t_LEventsSharePersonLog.BeShareVipID = vipid; //新建的会员会员的vipid t_LEventsSharePersonLog.BeShareOpenID = openId; //本分享人的id t_LEventsSharePersonLog.ShareURL = goUrl; //分享的链接 t_LEventsSharePersonLog.CreateTime = System.DateTime.Now; t_LEventsSharePersonLog.CreateBy = ""; t_LEventsSharePersonLog.LastUpdateBy = ""; t_LEventsSharePersonLog.LastUpdateTime = System.DateTime.Now; t_LEventsSharePersonLog.CustomerId = loggingSessionInfo.ClientID; t_LEventsSharePersonLog.IsDelete = 0; t_LEventsSharePersonLogBLL.Create(t_LEventsSharePersonLog); }
private void Awake() { _unitService = ServiceLocator.Get <UnitService>(); _unitService.UnitDying += OnUnitDying; _unitService.UnitDisappeared += OnUnitDying; }
private void loadUser(string customer_id, string token) { //try //{ //获取登录管理平台的用户信息 var AuthWebService = new JIT.CPOS.BS.WebServices.AuthManagerWebServices.AuthServiceSoapClient(); AuthWebService.Endpoint.Address = new System.ServiceModel.EndpointAddress( ConfigurationManager.AppSettings["sso_url"].ToString() + "/AuthService.asmx"); // AuthWebService.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://localhost:42305/AuthService.asmx"); //AuthWebService.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://localhost:7335/AuthService.asmx"); if (token == null) { token = ""; } string str = AuthWebService.GetLoginUserInfo(token); if (string.IsNullOrEmpty(str)) { //this.lbErr.Text = "用户不存在,请与管理员联系"; //return; PageLog.Current.Write("SSO登录失败,AuthWebService.asmx返回空数据"); //Response.Write("登录失败,请重试!"); //Response.End(); var redirectUrl = ConfigurationManager.AppSettings["sso_url"].ToString() + "?errorinfo=" + "网络繁忙,请重新登录!"; //var redirectUrl = "http://localhost:7335/login.aspx"; Response.Redirect(redirectUrl, true); } var myLoggingManager = (JIT.CPOS.BS.Entity.LoggingManager)cXMLService.Deserialize( str, typeof(JIT.CPOS.BS.Entity.LoggingManager)); //判断登录进来的用户是否存在,并且返回用户信息 LoggingSessionInfo loggingSession = new LoggingSessionInfo(); loggingSession.CurrentLoggingManager = myLoggingManager; cUserService userService = new cUserService(loggingSession); UnitService unitService = new UnitService(loggingSession); if (!userService.IsExistUser(loggingSession)) { this.lbErr.Text = "用户不存在,请与管理员联系"; return; } var login_user = userService.GetUserById(loggingSession, myLoggingManager.User_Id); loggingSession.CurrentUser = login_user; // 获取角色 string applicationId = PageBase.JITPage.GetApplicationId(); IList <UserRoleInfo> userRoleList = userService.GetUserRoles(login_user.User_Id, applicationId); if (userRoleList != null && userRoleList.Count > 0) { loggingSession.CurrentUserRole = new UserRoleInfo(); loggingSession.CurrentUserRole.UserId = login_user.User_Id; loggingSession.CurrentUserRole.UserName = login_user.User_Name; loggingSession.CurrentUserRole.RoleId = userRoleList[0].RoleId; loggingSession.CurrentUserRole.RoleCode = userRoleList[0].RoleCode; loggingSession.CurrentUserRole.RoleName = userRoleList[0].RoleName; loggingSession.ClientID = login_user.customer_id; loggingSession.CurrentLoggingManager.Customer_Id = login_user.customer_id; loggingSession.UserID = loggingSession.CurrentUser.User_Id; try { loggingSession.CurrentUserRole.UnitId = userService.GetDefaultUnitByUserIdAndRoleId( loggingSession.CurrentUserRole.UserId, loggingSession.CurrentUserRole.RoleId); } catch (Exception ex) { PageLog.Current.Write(ex); Response.Write("找不到默认单位"); Response.End(); } try { var unitInfo = unitService.GetUnitById(loggingSession.CurrentUserRole.UnitId); loggingSession.CurrentUserRole.UnitName = unitInfo.Name; loggingSession.CurrentUserRole.UnitShortName = unitInfo.ShortName; } catch (Exception ex) { PageLog.Current.Write(ex); Response.Write("找不到单位"); Response.End(); } } else { //PageLog.Current.Write(ex); Response.Write("该用户没有权限登录管理平台"); Response.End(); } //this.Session["UserInfo"] = login_user; //this.Session["LoggingManager"] = myLoggingManager; //this.Session["loggingSessionInfo"] = loggingSession; //loggingSession.CurrentLoggingManager = myLoggingManager; new SessionManager().SetCurrentUserLoginInfo(loggingSession); //清空密码 login_user.User_Password = null; //string go_url = "~/login/SelectRoleUnit.aspx?p=0"; string go_url = "~/Default.aspx"; if (loggingSession.CurrentUserRole != null && loggingSession.CurrentUserRole.RoleId == "860E69754D3B490F8A5B401DF3F66E15") { string eventId = string.Empty; //switch (loggingSession.CurrentUserRole.UserId.Trim()) //{ // case "FA1BDA8937924D45AFA3123FE4DEE8FA": // eventId = "0326056B219340D5B234BFAD9AF02AF5"; // break; // case "4913B21CFD714C7986842B859EC1289B": // eventId = "793150439CF94190A70CF2EC229A951D"; // break; // case "BD8079F886BD492E90A335EBC1DE9676": // eventId = "F8A7E2E8807B49558F1A516F23C34473"; // break; // default: // eventId = "793150439CF94190A70CF2EC229A951D"; // break; //} LEventsBLL lEventsBLL = new LEventsBLL(loggingSession); var eventList = lEventsBLL.QueryByEntity(new LEventsEntity() { EventManagerUserId = loggingSession.CurrentUserRole.UserId }, null); if (eventList != null && eventList.Length > 0) { eventId = eventList[0].EventID; loggingSession.CurrentUserRole.RoleName = eventId; Response.Redirect("~/Module/MarketEvent/EventList/EventAnalysisList4.aspx", true); } } else { //loggingSession.CurrentUserRole.RoleName = "793150439CF94190A70CF2EC229A951D"; Response.Redirect(go_url, true); } //} //catch (Exception ex) //{ // PageLog.Current.Write(ex); // lbErr.Text = "登录失败"; //} }
/// <summary> /// 获得单位下拉列表 /// </summary> /// <returns>返回集合</returns> public IEnumerable<SelectListItem> GetUnitList() { var unitSelect = new UnitService(); IEnumerable<SelectListItem> unitSelectList = unitSelect.FindAll().Select(unitItem => new SelectListItem { Text = unitItem.Name, Value = unitItem.Id + string.Empty }).OrderBy(m => m.Text); return unitSelectList; }
//判断类型是否重复 public bool JudgeNameByType(string name, string typename) { var cureTypeService = new CureTypeService(); var medicineService = new MedicineService(); var unitService = new UnitService(); var fodderTypeService = new FodderTypeService(); var excetionTypeService = new ExceptionTypeService(); var pigTypeService = new PigTypeService(); var pigHouseTypeService = new PigHouseTypeService(); var taskStatusTypeService = new TaskStatusTypeService(); var taskTypeService = new TaskTypeService(); var roleTypeService = new RoleTypeService(); var preventionTypeService = new PreventionTypeService(); var customerService = new CustomerService(); if (typename == "治疗") { if (cureTypeService.FindByName(name) == null) return true; } if (typename == "单位") { if (unitService.FindByName(name) == null) return true; } if (typename == "药物") { if (medicineService.FindByName(name) == null) return true; } if (typename == "异常") { if (excetionTypeService.FindByName(name).Count == 0) return true; } if (typename == "饲料") { if (fodderTypeService.FindByName(name) == null) return true; } if (typename == "生猪") { if (pigTypeService.FindByName(name) == null) return true; } if (typename == "防疫") { if (preventionTypeService.FindByName(name) == null) return true; } if (typename == "猪舍") { if (pigHouseTypeService.FindByName(name) == null) return true; } if (typename == "任务状态") { if (taskStatusTypeService.FindByName(name) == null) return true; } if (typename == "任务类型") { if (taskTypeService.FindByName(name) == null) return true; } if (typename == "角色") { if (roleTypeService.FindByName(name) == null) return true; } if (typename == "客户名称") { if (customerService.FindByName(name) == null) return true; } return false; }
public void UnitTypeSaveChanges(BasicInfoModel model) { var unitTypeService = new UnitService(); List<unit> unitTypes = unitTypeService.FindAll(); foreach (unit unitType in unitTypes) { int idFlag = 0; int nameFlag = 0; string newname = ""; foreach (NameModel name in model.Names) { if (unitType.Id == name.Id) { idFlag = 1; if (unitType.Name.Equals(name.Name)) { nameFlag = 1; } else { newname = name.Name; } } } //若存在此Id,但是name变化了的,则需要修改数据库 if (idFlag == 1) { if (nameFlag == 0) { if (newname == "") { throw new Exception(); } unit modifyCure = unitTypeService.Find(unitType.Id); modifyCure.Name = newname; unitTypeService.Update(modifyCure); } } } //如果model里的Id为0,说明是新建的类型 foreach (NameModel name in model.Names) { if (name.Id == 0 && unitTypeService.FindByName(name.Name) == null) { var newUnitType = new unit {Name = name.Name}; new UnitService().Insert(newUnitType); } } }
public JsonNetResult GetFormApproveList(FormType formType) { try { if (formType == FormType.None) { throw new Exception("The audit form is not being chosen."); } var list = new FormApproveListService().Get(formType); var unitService = new UnitService(); var userService = new UserService(); var result = new List <dynamic>(); var index = 1; foreach (var item in list) { if (item.ApproverType == ApproverType.ChoosePerson) { var person = userService.Get(item.ApproverId); result.Add(new { Id = item.Id, FormType = item.FormType, Type = new { Value = item.ApproverType, Name = "指定人员" }, Approver = new { Id = item.ApproverId, Name = person == null ? string.Empty : person.Name }, Sequence = index }); } else if (item.ApproverType == ApproverType.ChooseUnitManager) { var unit = unitService.Get(item.ApproverId); result.Add(new { Id = item.Id, FormType = item.FormType, Type = new { Value = item.ApproverType, Name = "部门主管" }, Approver = new { Id = item.ApproverId, Name = unit == null ? string.Empty : unit.Name }, Sequence = index }); } else { result.Add(new { Id = item.Id, FormType = item.FormType, Type = new { Value = item.ApproverType, Name = item.ApproverType == ApproverType.Applyer ? "申请人" : "申请部门主管" }, Sequence = index }); } index++; } return(JsonNet(new ResponseResult(true, result))); } catch (Exception e) { return(JsonNet(new ResponseResult(false, e))); } }
public Player(IMemoryAPI memoryAPI) { _memoryAPI = memoryAPI; _unitService = new UnitService(memoryAPI); }
public JsonNetResult GetUnits(string parentId) { var list = new UnitService().GetByRootId(parentId); return(JsonNet(new ResponseResult(true, list))); }
public FollowState(IMemoryAPI fface) : base(fface) { this.UnitService = new UnitService(fface); }
protected override SetRechargeOrderRD ProcessRequest(APIRequest <SetRechargeOrderRP> pRequest) { SetRechargeOrderRP rp = pRequest.Parameters; SetRechargeOrderRD rd = new SetRechargeOrderRD(); var rechargeOrderBll = new RechargeOrderBLL(CurrentUserInfo); TUnitExpandBLL serviceUnitExpandBll = new TUnitExpandBLL(CurrentUserInfo); var vipBll = new VipBLL(CurrentUserInfo); var vipCardVipMappingBll = new VipCardVipMappingBLL(CurrentUserInfo); var vipCardBll = new VipCardBLL(CurrentUserInfo); var sysVipCardTypeBll = new SysVipCardTypeBLL(CurrentUserInfo); var vipCardUpgradeRuleBll = new VipCardUpgradeRuleBLL(CurrentUserInfo); //获取会员信息 VipEntity vipInfo; string userId = ""; //微信 if (pRequest.ChannelId == "2") { vipInfo = vipBll.GetByID(pRequest.UserID); UnitService unitServer = new UnitService(CurrentUserInfo); rp.UnitId = unitServer.GetUnitByUnitTypeForWX("OnlineShopping", null).Id; //获取在线商城的门店标识 } //掌柜App else { vipInfo = vipBll.GetByID(rp.VipId); userId = pRequest.UserID; } string OrderDesc = "ReRecharge"; //"升级","充值" int? VipCardTypeId = null; //会员卡类型 decimal returnAmount = 0; //赠送金额 //会员卡类型条件 List <IWhereCondition> complexConditionOne = new List <IWhereCondition> { }; //获取会员与会员卡关系表 var vipCardVipMappingEntity = vipCardVipMappingBll.QueryByEntity(new VipCardVipMappingEntity() { CustomerID = CurrentUserInfo.ClientID, VIPID = vipInfo.VIPID }, null).FirstOrDefault(); //该会员有会员卡 if (vipCardVipMappingEntity != null) { //获取该会员会员卡信息 var vipCardEntity = vipCardBll.QueryByEntity(new VipCardEntity() { CustomerID = CurrentUserInfo.ClientID, VipCardID = vipCardVipMappingEntity.VipCardID }, null).FirstOrDefault(); //获取该会员卡类型 var sysVipCardTypeEntity = sysVipCardTypeBll.GetByID(vipCardEntity.VipCardTypeID); VipCardTypeId = vipCardEntity.VipCardTypeID; //获取会员卡的会员活动 var rechargeStrategyBLL = new RechargeStrategyBLL(CurrentUserInfo); var RechargeActivityDS = rechargeStrategyBLL.GetRechargeActivityList(CurrentUserInfo.ClientID, VipCardTypeId.ToString(), 3); var RechargeStrategy = new RechargeStrategyInfo(); if (RechargeActivityDS != null && RechargeActivityDS.Tables[0].Rows.Count > 0) { var RechargeStrategyList = DataTableToObject.ConvertToList <RechargeStrategyInfo>(RechargeActivityDS.Tables[0]); //获取与充值金额最接近的活动 RechargeStrategy = RechargeStrategyList.Where(n => n.RechargeAmount <= rp.ActuallyPaid).OrderByDescending(n => n.RechargeAmount).FirstOrDefault(); if (RechargeStrategy != null) { //梯度 if (RechargeStrategy.RuleType == "Step") { //赠送金额 = 会员活动梯度设置赠送金额 returnAmount = RechargeStrategy.GiftAmount; } //叠加 if (RechargeStrategy.RuleType == "Superposition") { //赠送金额与满赠条件金额比例 decimal discount = RechargeStrategy.GiftAmount / RechargeStrategy.RechargeAmount; //赠送金额 = 充值金额 * (设置赠送金额 / 设置满赠条件金额) returnAmount = rp.ActuallyPaid * RechargeStrategy.GiftAmount / RechargeStrategy.RechargeAmount; } } } //获取等级高的会员卡类型条件 complexConditionOne.Add(new MoreThanCondition() { FieldName = "VipCardLevel", Value = sysVipCardTypeEntity.VipCardLevel, IncludeEquals = false }); complexConditionOne.Add(new EqualsCondition() { FieldName = "CustomerID", Value = CurrentUserInfo.ClientID }); } //该会员没有会员卡 else { //获取所有的会员卡类型条件 complexConditionOne.Add(new EqualsCondition() { FieldName = "CustomerID", Value = CurrentUserInfo.ClientID }); } var sysVipCardTypeList = sysVipCardTypeBll.Query(complexConditionOne.ToArray(), null).ToList(); if (sysVipCardTypeList == null) { throw new APIException("没有建立会员体系") { ErrorCode = 200 }; } //获取会员卡类型升级规则 List <IWhereCondition> complexConditionTwo = new List <IWhereCondition> { }; complexConditionTwo.Add(new EqualsCondition() { FieldName = "CustomerID", Value = CurrentUserInfo.ClientID }); complexConditionTwo.Add(new EqualsCondition() { FieldName = "IsRecharge", Value = 1 }); var vipCardUpgradeRuleList = vipCardUpgradeRuleBll.Query(complexConditionTwo.ToArray(), null); //将升级卡规则和可升级的会员卡匹配 var vipCardTypeDetailList = vipCardUpgradeRuleList.Join(sysVipCardTypeList, n => n.VipCardTypeID, m => m.VipCardTypeID, (n, m) => new { n, m }).OrderByDescending(t => t.m.VipCardLevel).ToList(); //判断是否满充值条件 bool isUpgrade = false; for (int i = 0; i < vipCardTypeDetailList.Count; i++) { //实付金额 >= 可升级金额 if (vipCardTypeDetailList[i].n.OnceRechargeAmount <= rp.ActuallyPaid) { isUpgrade = true; VipCardTypeId = vipCardTypeDetailList[i].n.VipCardTypeID ?? 0; break; } } if (isUpgrade) { OrderDesc = "Upgrade"; //升级 } //充值订单 var rechargeOrderEntity = new RechargeOrderEntity() { OrderID = Guid.NewGuid(), OrderNo = serviceUnitExpandBll.GetUnitOrderNo(), OrderDesc = OrderDesc, VipID = vipInfo.VIPID, VipCardNo = vipInfo.VipCode, UnitId = rp.UnitId, UserId = userId, TotalAmount = rp.ActuallyPaid, ActuallyPaid = rp.ActuallyPaid, PosSourceName = rp.PosSourceName, ReturnAmount = returnAmount, PayerID = vipInfo.VIPID, Status = 0, CustomerID = CurrentUserInfo.ClientID, VipCardTypeId = VipCardTypeId }; rechargeOrderBll.Create(rechargeOrderEntity); rd.orderId = rechargeOrderEntity.OrderID.ToString(); //支付完成 if (rp.PayStatus == 1) { //获取门店信息 t_unitBLL unitBLL = new t_unitBLL(CurrentUserInfo); t_unitEntity unitInfo = null; if (!string.IsNullOrEmpty(rechargeOrderEntity.UnitId)) { unitInfo = unitBLL.GetByID(rechargeOrderEntity.UnitId); } //充值 rechargeOrderBll.Recharge(rechargeOrderEntity, vipInfo, unitInfo, ""); } return(rd); }
/// <summary> /// 新建喂食信息 /// </summary> /// <param name="newFeedInfo"></param> /// y /// <returns></returns> public bool CreateFeedInfo(FeedInfo newFeedInfo) { var employeeService = new EmployeeService(); var feedService = new FeedService(); var fodderTakeService = new FodderTakeService(); var taskService = new TaskService(); var fodderTypeService = new FodderTypeService(); var unitService = new UnitService(); var taskStatusTypeService = new TaskStatusTypeService(); long taskId = long.Parse(TaskNumber); foreach (FodderTakeDetail takedetail in newFeedInfo.TakeDetail) { employee firstOrDefault = employeeService.Find(long.Parse(newFeedInfo.EmployeeName)); if (firstOrDefault != null) { var take = new fodder_take { TaskId = taskId, EmployeeId = firstOrDefault.Id, //FodderTypeId = fodderTypeService.Find(long.Parse(takedetail.FodderType)).Id, //Quantity = takedetail.Quantity, //UnitId = unitService.Find(long.Parse(takedetail.Unit)).Id, Time = takedetail.TakeTime }; fodderTakeService.Insert(take); } } foreach (FeedInfoDetail feedPigDetail in FeedPig) { var feedinfo = new feed {TaskId = taskId}; employee firstOrDefault = employeeService.Find(long.Parse(newFeedInfo.EmployeeName)); if (firstOrDefault != null) feedinfo.EmployeeId = firstOrDefault.Id; feedinfo.PigstyId = long.Parse(feedPigDetail.Pigsty); //feedinfo.FodderTypeId = long.Parse(feedPigDetail.FodderType); //feedinfo.Quality = feedPigDetail.Quantity; //feedinfo.UnitId = long.Parse(feedPigDetail.Unit); feedinfo.Memo = newFeedInfo.Meno; feedinfo.Time = feedPigDetail.DetailTime; feedService.Insert(feedinfo); } task_status_type taskStatusType = taskStatusTypeService.FindByName("正在进行"); task task = taskService.Find(long.Parse(newFeedInfo.TaskNumber)); if (taskStatusType != null && task != null) { task.TaskStatusId = taskStatusType.Id; taskService.Update(task); } return true; }
public void TestManageReturnsView2() { #region Arrange Controller.ControllerContext.HttpContext = new MockHttpContext(1, new[] { "" }); ControllerRecordFakes.FakeUnits(3, UnitRepository); UnitService.Expect(a => a.GetVisibleByUser("appName", "UserName")).Return(UnitRepository.GetAll().AsQueryable()).Repeat.Any(); ControllerRecordFakes.FakeRoles(3, RoleRepository); RoleService.Expect(a => a.GetVisibleByUser("appName", "UserName")).Return(RoleRepository.GetAll().AsQueryable()).Repeat.Any(); ControllerRecordFakes.FakeUsers(3, UserRepository); UserService.Expect(a => a.GetByApplication("appName", "UserName")).Return(UserRepository.Queryable).Repeat.Any(); var application = CreateValidEntities.Application(1); application.Name = "appName"; var permissions = new List <Permission>(); for (int i = 0; i < 4; i++) { permissions.Add(CreateValidEntities.Permission(i + 1)); permissions[i].Application = application; permissions[i].User = UserRepository.Queryable.First(); permissions[i].Role = RoleRepository.GetNullableById(i + 1); } permissions[1].User = UserRepository.GetNullableById(2); permissions[2].User = UserRepository.GetNullableById(3); permissions[3].Role = RoleRepository.GetNullableById(1); ControllerRecordFakes.FakePermissions(0, PermissionRepository, permissions); var unitAssociations = new List <UnitAssociation>(); for (int i = 0; i < 4; i++) { unitAssociations.Add(CreateValidEntities.UnitAssociation(i + 1)); unitAssociations[i].Application = application; unitAssociations[i].User = UserRepository.Queryable.First(); unitAssociations[i].Unit = UnitRepository.GetNullableById(i + 1); } unitAssociations[1].User = UserRepository.GetNullableById(2); unitAssociations[2].User = UserRepository.GetNullableById(3); unitAssociations[3].Unit = UnitRepository.GetNullableById(1); ControllerRecordFakes.FakeUnitAssociations(0, UnitAssociationRepository, unitAssociations); #endregion Arrange #region Act var result = Controller.Manage("appName") .AssertViewRendered() .WithViewData <UserManagementViewModel>(); #endregion Act #region Assert Assert.IsNotNull(result); Assert.AreEqual("appName", result.Application); Assert.AreEqual(3, result.Roles.Count); Assert.AreEqual("Name2", result.Roles[1].Value); Assert.AreEqual(3, result.Units.Count); Assert.AreEqual("ShortName2", result.Units[1].Value); Assert.AreEqual(3, result.UserShowModel.Count); Assert.AreEqual("FirstName2", result.UserShowModel[1].FirstName); Assert.AreEqual("LastName2", result.UserShowModel[1].LastName); Assert.AreEqual("*****@*****.**", result.UserShowModel[1].Email); Assert.AreEqual("LoginId2", result.UserShowModel[1].Login); Assert.AreEqual(null, result.UserShowModel[1].Phone); Assert.AreEqual(2, result.UserShowModel[0].Permissions.Count); Assert.AreEqual("Name1", result.UserShowModel[0].Permissions[1].RoleName); Assert.AreEqual("Name1", result.UserShowModel[0].Permissions[0].RoleName); Assert.AreEqual(2, result.UserShowModel[0].UnitAssociations.Count); Assert.AreEqual("ShortName1", result.UserShowModel[0].UnitAssociations[1].UnitName); Assert.AreEqual("ShortName1", result.UserShowModel[0].UnitAssociations[0].UnitName); Assert.AreEqual(1, result.UserShowModel[1].Permissions.Count); Assert.AreEqual("Name2", result.UserShowModel[1].Permissions[0].RoleName); Assert.AreEqual(1, result.UserShowModel[1].UnitAssociations.Count); Assert.AreEqual("ShortName2", result.UserShowModel[1].UnitAssociations[0].UnitName); Assert.AreEqual(1, result.UserShowModel[2].Permissions.Count); Assert.AreEqual("Name3", result.UserShowModel[2].Permissions[0].RoleName); Assert.AreEqual(1, result.UserShowModel[2].UnitAssociations.Count); Assert.AreEqual("ShortName3", result.UserShowModel[2].UnitAssociations[0].UnitName); #endregion Assert }
public BasicInfoModel ReadBasicInfo(string type) { var basicInfoModel = new BasicInfoModel {Type = type}; var names = new List<NameModel>(); basicInfoModel.Names = names; if (type == "治疗") { List<cure_type> cureTypes = new CureTypeService().FindAll(); foreach (cure_type cureType in cureTypes) { var nameModel = new NameModel {Name = cureType.Name, Id = cureType.Id}; names.Add(nameModel); } } else if (type == "药物") { List<medicine> medicineTypes = new MedicineService().FindAll(); foreach (medicine medicineType in medicineTypes) { var nameModel = new NameModel {Name = medicineType.Name, Id = medicineType.Id}; names.Add(nameModel); } } else if (type == "单位") { List<unit> unitTypes = new UnitService().FindAll(); foreach (unit unitType in unitTypes) { var nameModel = new NameModel {Name = unitType.Name, Id = unitType.Id}; names.Add(nameModel); } } else if (type == "异常") { List<exception_type> exceptionTypes = new ExceptionTypeService().FindAll(); foreach (exception_type exceptionType in exceptionTypes) { var nameModel = new NameModel {Name = exceptionType.Name, Id = exceptionType.Id}; names.Add(nameModel); } } else if (type == "饲料") { List<fodder_type> fodderTypes = new FodderTypeService().FindAll(); foreach (fodder_type fodderType in fodderTypes) { var nameModel = new NameModel {Name = fodderType.Name, Id = fodderType.Id}; names.Add(nameModel); } } else if (type == "生猪") { List<pig_type> pigTypes = new PigTypeService().FindAll(); foreach (pig_type pigType in pigTypes) { var nameModel = new NameModel {Name = pigType.Name, Id = pigType.Id}; names.Add(nameModel); } } else if (type == "防疫") { List<prevention_type> preventionTypes = new PreventionTypeService().FindAll(); foreach (prevention_type preventionType in preventionTypes) { var nameModel = new NameModel { Name = preventionType.Name, Id = preventionType.Id, MedicineId = preventionType.MedicineId, Quality = Convert.ToInt32(preventionType.Quality), UnitId = preventionType.UnitId }; names.Add(nameModel); } } else if (type == "猪舍") { List<pig_house_type> pigHouseTypes = new PigHouseTypeService().FindAll(); foreach (pig_house_type pigHouseType in pigHouseTypes) { var nameModel = new NameModel {Name = pigHouseType.Name, Id = pigHouseType.Id}; names.Add(nameModel); } } else if (type == "任务状态") { List<task_status_type> taskStatusTypes = new TaskStatusTypeService().FindAll(); foreach (task_status_type taskStatusType in taskStatusTypes) { var nameModel = new NameModel {Name = taskStatusType.Name, Id = taskStatusType.Id}; names.Add(nameModel); } } else if (type == "任务类型") { List<task_type> taskTypes = new TaskTypeService().FindAll(); foreach (task_type taskType in taskTypes) { var nameModel = new NameModel {Name = taskType.Name, Id = taskType.Id}; names.Add(nameModel); } } else if (type == "角色") { List<role_type> roleTypes = new RoleTypeService().FindAll(); foreach (role_type roleType in roleTypes) { var nameModel = new NameModel {Name = roleType.Name, Id = roleType.Id}; names.Add(nameModel); } } else if (type == "客户名称") { List<customer> customerTypes = new CustomerService().FindAll(); foreach (customer customer in customerTypes) { var nameModel = new NameModel {Name = customer.Name, Id = customer.Id}; names.Add(nameModel); } } if (names.Count == 0) { var nullNameModel = new NameModel(); names.Add(nullNameModel); } return basicInfoModel; }
public JsonResult QueryHospitalById(string id) { var hospital = new UnitService().Get(id); return(Json(hospital)); }
/// <summary> /// 根据类型id查找关联它的表是否为0 /// </summary> /// <param name="typeid">类型id</param> /// <param name="typename">类型名字</param> /// <returns></returns> public string GetRelationtById(long typeid, string typename) { var cureTypeService = new CureTypeService(); var medicineService = new MedicineService(); var unitService = new UnitService(); var fodderTypeService = new FodderTypeService(); var excetionTypeService = new ExceptionTypeService(); var pigTypeService = new PigTypeService(); var pigHouseTypeService = new PigHouseTypeService(); var taskStatusTypeService = new TaskStatusTypeService(); var taskTypeService = new TaskTypeService(); var roleTypeService = new RoleTypeService(); var preventionTypeService = new PreventionTypeService(); var roleAuthorityService = new RoleAuthorityService(); var customerService = new CustomerService(); if (typeid == 0) { return "不存在于数据库,可以删除"; } try { if (typename == "治疗") { cureTypeService.Delete(cureTypeService.Find(typeid)); } if (typename == "单位") { unitService.Delete(unitService.Find(typeid)); } if (typename == "药物") { medicineService.Delete(medicineService.Find(typeid)); } if (typename == "异常") { excetionTypeService.Delete(excetionTypeService.Find(typeid)); } if (typename == "饲料") { fodderTypeService.Delete(fodderTypeService.Find(typeid)); } if (typename == "生猪") { if (pigTypeService.Find(typeid).Name == "母猪" || pigTypeService.Find(typeid).Name == "公猪") { return "不可删除"; } pigTypeService.Delete(pigTypeService.Find(typeid)); } if (typename == "防疫") { preventionTypeService.Delete(preventionTypeService.Find(typeid)); } if (typename == "猪舍") { pigHouseTypeService.Delete(pigHouseTypeService.Find(typeid)); } if (typename == "任务状态") { if (taskStatusTypeService.Find(typeid).Name == "未完成" || taskStatusTypeService.Find(typeid).Name == "已完成" || taskStatusTypeService.Find(typeid).Name == "正在进行") { return "不可删除"; } taskStatusTypeService.Delete(taskStatusTypeService.Find(typeid)); } if (typename == "任务类型") { if (taskTypeService.Find(typeid).Name == "喂饲" || taskTypeService.Find(typeid).Name == "防疫" || taskTypeService.Find(typeid).Name == "巡查" || taskTypeService.Find(typeid).Name == "治疗" || taskTypeService.Find(typeid).Name == "销售" || taskTypeService.Find(typeid).Name == "转栏" || taskTypeService.Find(typeid).Name == "添加生猪") { return "不可删除"; } taskTypeService.Delete(taskTypeService.Find(typeid)); } if (typename == "角色") { foreach (role_authority c in roleAuthorityService.FindByRoleTypeId(typeid)) roleAuthorityService.Delete(roleAuthorityService.Find(c.Id)); roleTypeService.Delete(roleTypeService.Find(typeid)); } if (typename == "客户名称") { customerService.Delete(customerService.Find(typeid)); } } catch (Exception) { return "不可删除"; } return ""; }