/// <summary> /// 添加 /// </summary> /// <param name="model"></param> /// <returns></returns> public override MessageRecorder <bool> Create(DevRoom model) { var r = new MessageRecorder <bool>(); model.CreatedAt = Now; model.CreatedBy = AccountNo; using (var conn = ConnectionManager.Open()) { var trans = conn.BeginTransaction(); var query = new Criteria <DevRoom>() .Where(m => m.No, Op.Eq, model.No) .Or(m => m.Name, Op.Eq, model.Name) .Desc(m => m.No); if (conn.Exists(query)) { trans.Rollback(); return(r.Error("保存失败")); } var effectedCount = conn.Insert(model, trans); if (effectedCount == -1) { trans.Rollback(); return(r.Error("保存失败")); } trans.Commit(); } r.Append(AccessoryService.ClearExpiration(model.Pic)); return(r.SetValue(!r.HasError)); }
private void KittyAccessoryStartupProcesses() { var kittyModels = KittyService.GetAll(); var accessoryModels = AccessoryService.GetAll(); // create the kitty-accessory models if they don't yet exist var kittyAccessoriesToSave = new List <KittyAccessoryModel>(); foreach (var kittyModel in kittyModels) { foreach (var accessoryModel in accessoryModels) { var kittyAccessoryModel = KittyAccessoryService.GetModelByKittyAndAccessoryCombination( kittyModel, accessoryModel ); if (kittyAccessoryModel == null) { kittyAccessoryModel = new KittyAccessoryModel( kittyModel.id, accessoryModel.id, accessoryModel.accessoryGroup, accessoryModel.accessorySubGroup, false, false ); kittyAccessoriesToSave.Add(kittyAccessoryModel); } } } // insert kitty-accessories to be saved KittyAccessoryService.SaveMultiple(kittyAccessoriesToSave); }
private void FetchAccessoryImages() { // deactivate all accessory game objects foreach (var partDict in this.displayLookup.Values) { foreach (var image in partDict.Values) { image.gameObject.SetActive(false); } } // TODO: implementation of this method is unoptimized, utilize lookup batching in a future refactor KittyModel kittyModel = KittyService.GetSelected(); foreach (var kittyAccessoryModel in KittyAccessoryService.GetModelsByKittyId(kittyModel.id)) { if (kittyAccessoryModel.isSelected) { // lookup accessory model var accessoryModel = AccessoryService.GetModelsByIds(new List <string> { kittyAccessoryModel.accessoryId })[0]; // lookup sprite Sprite accessorySprite = AssetService.GetSprite(accessoryModel.primaryAssetAddress); // lookup display object image and assign sprite Image displayImage = this.displayLookup[kittyAccessoryModel.accessoryGroup][kittyAccessoryModel.accessorySubGroup]; displayImage.sprite = accessorySprite; displayImage.gameObject.SetActive(true); } } }
//GET public IHttpActionResult Get() { AccessoryService accessoryService = CreateAccessoryService(); var accessory = accessoryService.GetAllAccessories(); return(Ok(accessory)); }
public IHttpActionResult GetById(int id) { AccessoryService accessoryService = CreateAccessoryService(); var accessory = accessoryService.GetAccessoryById(id); return(Ok(accessory)); }
private AccessoryService CreateAccessoryService() { var accessoryId = Guid.Parse(User.Identity.GetUserId()); var accessoryService = new AccessoryService(accessoryId); return(accessoryService); }
public MessageRecorder <bool> Delete(long[] ids) { var mr = new MessageRecorder <bool>(); using (var conn = ConnectionManager.Open()) { var trans = conn.BeginTransaction(); var query = new Criteria <Account>() .Where(m => m.Id, Op.In, ids) .And("`no` NOT IN (SELECT `AccountNo` FROM `base_account_role_ref` WHERE `RoleNo` NOT IN('BranchAdmin', 'BranchStaff'))"); var models = conn.Query(query); var isOk = models.All(m => conn.Delete(m, trans)); if (isOk) { trans.Commit(); foreach (var model in models) { mr.Append(AccessoryService.DeleteObject(model.Photo)); } mr.SetValue(!mr.HasError); } else { trans.Rollback(); } return(mr); } }
// chose, at random, one item among the // locked accessories and locked kitties for unlock private void UnlockRandomKittyOrAccessory() { // chance list for calculating selection of kitty or accessory for unlock var selectBetweenList = new List <int>(); // gather objects var allKitties = KittyService.GetAll(); var selectedKitty = KittyService.GetSelected(); var accessoriesForKitty = AccessoryService.GetAccessoriesForKitty(selectedKitty); // filter for locked kitties and accessories var lockedKitties = new List <KittyModel>(); foreach (var kitty in allKitties) { if (!kitty.isUnlocked) { lockedKitties.Add(kitty); selectBetweenList.Add(1); } } var lockedAccessoriesForKitty = new List <AccessoryModel>(); foreach (var accessory in accessoriesForKitty) { var kittyAccessory = KittyAccessoryService.GetModelByKittyAndAccessoryCombination( selectedKitty, accessory ); if (!kittyAccessory.isUnlocked) { lockedAccessoriesForKitty.Add(accessory); selectBetweenList.Add(2); } } // select whether kitty or accessory will be unlocked int randomSelectionIndex = Random.Range(0, selectBetweenList.Count); int selectedType = selectBetweenList[randomSelectionIndex]; if (selectedType == 1) { // unlock random locked kitty randomSelectionIndex = Random.Range(0, lockedKitties.Count); this.unlockedKittyModel = lockedKitties[randomSelectionIndex]; this.unlockedKittyModel.isUnlocked = true; KittyService.Save(this.unlockedKittyModel); } else { // unlock random accessory for kitty randomSelectionIndex = Random.Range(0, lockedAccessoriesForKitty.Count); this.unlockedAccessoryModel = lockedAccessoriesForKitty[randomSelectionIndex]; var kittyAccessoryToUnlock = KittyAccessoryService.GetModelByKittyAndAccessoryCombination( selectedKitty, this.unlockedAccessoryModel ); kittyAccessoryToUnlock.isUnlocked = true; KittyAccessoryService.Save(kittyAccessoryToUnlock); } }
public static void Save(AccessoryModel model) { var modelsToSave = new List <AccessoryModel>() { model }; AccessoryService.SaveMultiple(modelsToSave); }
/// <summary> /// 修改 /// </summary> /// <param name="model"></param> /// <returns></returns> public override MessageRecorder <bool> Update(Project model) { var r = new MessageRecorder <bool>(); model.CreatedAt = Now; model.CreatedBy = AccountNo; string oldKey; using (var conn = ConnectionManager.Open()) { var trans = conn.BeginTransaction(); var query = new Criteria <Project>() .Where(m => m.No, Op.Eq, model.No) .Or(m => m.Name, Op.Eq, model.Name) .And(m => m.Id, Op.NotEq, model.Id); if (conn.Exists(query)) { trans.Rollback(); return(r.Error("编号或者名称重复")); } var obj = new Criteria <Project>() .Where(m => m.Id, Op.Eq, model.Id) .Select(m => m.AddrPic); oldKey = conn.ExecuteScalarEx <string>(obj.ToSelectSql()); var effectedCount = conn.Update(model, trans); if (!effectedCount) { trans.Rollback(); return(r.Error("保存失败")); } foreach (var projectInfo in model.ProjectInfos) { projectInfo.UpdatedAt = Now; projectInfo.UpdatedBy = AccountNo; projectInfo.DpNo = model.No; } var effectedCount2 = conn.Update(model.ProjectInfos, trans); if (!effectedCount2) { trans.Rollback(); return(r.Error("保存失败")); } trans.Commit(); } if (!Equals(oldKey, model.AddrPic)) { r.Append(AccessoryService.DeleteObject(oldKey)); r.Append(AccessoryService.ClearExpiration(model.AddrPic)); } return(r.SetValue(!r.HasError)); }
public override MessageRecorder <bool> Delete(params DevRoom[] models) { var r = base.Delete(models); foreach (var model in models) { r.Append(AccessoryService.DeleteObject(model.Pic)); } return(r); }
public JsonResult Upload() { var mr = AccessoryService.Upload(Request); var urls = mr.Value.Select(AccessoryService.GetUrl); var obj = new { input = Request.Params["input"], ids = string.Join(",", mr.Value), urls = string.Join(",", urls) }; return(Json(obj)); }
public static List <AccessoryModel> GetAccessoriesForKitty( KittyModel kittyModel ) { var selectedAccessoryIds = new List <string>(); foreach (var kittyAccessoryModel in KittyAccessoryService.GetAll()) { if (kittyAccessoryModel.kittyId == kittyModel.id) { selectedAccessoryIds.Add(kittyAccessoryModel.accessoryId); } } return(AccessoryService.GetModelsByIds(selectedAccessoryIds)); }
// INTERFACE METHODS // IMPLEMENTATION METHODS private void RenderAccessoryItems() { var selectedKittyModel = KittyService.GetSelected(); // clear the exising accessory items in the scroll list foreach (var accessoryItem in this.accessoryItems) { GameObject.Destroy(accessoryItem); } this.accessoryItems.Clear(); // setup kitty-accessory models for lookups var accessoryIdToKittyAccessoryModel = new Dictionary <string, KittyAccessoryModel>(); foreach (var kittyAccessoryModel in KittyAccessoryService.GetModelsByKittyId(selectedKittyModel.id)) { accessoryIdToKittyAccessoryModel.Add(kittyAccessoryModel.accessoryId, kittyAccessoryModel); } List <AccessoryModel> accessories = AccessoryService.GetAll(); bool viewAll = GameManager.instance.adminControl.showAllKittiesAndAccessories; Debug.Log("View all accessories: " + viewAll.ToString()); foreach (var accessoryModel in accessories) { var kittyAccessoryModel = accessoryIdToKittyAccessoryModel[accessoryModel.id]; // create accessory item per unlocked accessory item for currently selected kitty if (kittyAccessoryModel.isUnlocked || viewAll) { GameObject accessoryScrollContentItem = Instantiate( accessoryScrollContentItemPrefab, scrollContent.transform ); var script = accessoryScrollContentItem.GetComponent <AccessoryScrollContentItemScript>(); Sprite sprite = AssetService.GetSprite(accessoryModel.thumbAssetAddress); if (sprite != null) { script.accessoryImage.sprite = sprite; } else { Debug.Log("Sprite not found at address: " + accessoryModel.thumbAssetAddress); } script.kittyModel = selectedKittyModel; script.accessoryModel = accessoryModel; this.accessoryItems.Add(accessoryScrollContentItem); } } }
public static List <AccessoryModel> GetModelsByIds( List <string> accessoryIds ) { var idToModel = new Dictionary <string, AccessoryModel>(); foreach (var model in AccessoryService.GetAll()) { idToModel.Add(model.id, model); } var resultModels = new List <AccessoryModel>(); foreach (string id in accessoryIds) { if (idToModel.ContainsKey(id)) { resultModels.Add(idToModel[id]); } } return(resultModels); }
public override MessageRecorder <bool> Delete(params Project[] models) { using (var conn = ConnectionManager.Open()) { var trans = conn.BeginTransaction(); var r = base.Delete(models); foreach (var model in models) { var query = new Criteria <ProjectInfo>() .Where(m => m.DpNo, Op.Eq, model.No) .Asc(m => m.Id); var proInfo = conn.Query(query); var err = conn.Delete(proInfo); if (!err) { trans.Rollback(); return(r.Error("删除楼盘周边信息失败")); } trans.Commit(); r.Append(AccessoryService.DeleteObject(model.AddrPic)); } return(r); } }
public AccessoriesController(AccessoryService accessoryService, AccessoryTypeService accessoryTypeService) { _accessoryService = accessoryService; _accessoryTypeService = accessoryTypeService; }
public BillsController(BillService billService, AccessoryService accSer) { _billService = billService; _accSer = accSer; }
/// <summary> /// 附件文件分片全部上传好后保存 /// </summary> /// <param name="addFileName"></param> /// <param name="flowId"></param> /// <returns></returns> public FileUploadInfo SaveAccessoryFileOrdinaryChunk(string addFileName) { if (!addFileName.HasRealValue()) { throw new Exception("请选择文件"); } string fileName = Request["filename"]; if (string.IsNullOrEmpty(fileName)) { fileName = Server.UrlDecode(fileName); } var locationid = Request["locationid"]; var location = Request["location"]; var LocationType = Request["LocationType"]; if (!LocationType.HasRealValue()) { LocationType = location; } var basePath = HMSUtil.GetDocPath(LocationType); var filePath = basePath + DateTime.Today.ToString("yyyyMMdd"); DicCreate(filePath); int sysMaxLength = HMSUtil.GetConfig(EnuInitCode.MaxAttFileSize.ToString()).ToInt(30); int MaxFileLength = 1024 * 1024 * sysMaxLength; FileInfo file = new FileInfo(addFileName); var userToken = AMSAuthentication.GetAuthToken(); var service = new HMSServiceBase(); var db = service.Init(); long fileSize = 0; try { if (file.Length > MaxFileLength) { file.Delete(); throw new Exception($"上传的文件的大小超过限制{sysMaxLength}M"); } fileSize = file.Length; var newFileName = fileName.Split('.').FirstOrDefault() + "-" + DateTime.Now.ToString("yyyyMMddHHmmss") + Path.GetExtension(fileName); string destinationPath = Path.Combine(filePath, newFileName); if (System.IO.File.Exists(destinationPath)) { System.IO.File.Delete(destinationPath); } file.MoveTo(destinationPath); var accessoryService = new AccessoryService(); var accessory = accessoryService.GetBy(location, locationid, fileName); if (accessory == null || !accessory.AccessoryId.HasRealValue()) { accessory = new AccessoryEntity() { AccessoryLocation = location, AccessoryLocationId = locationid, AccessoryName = fileName, CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), CreateUser = AMSAuthentication.GetAuthToken().UserId, CreateUserName = AMSAuthentication.GetAuthToken().RealName, CompanyId = AMSAuthentication.GetAuthToken().CompanyId, OwnerId = "12345678" }; } else { // 如果已经存在,是修改,则删除之前的文件 var deletePath = basePath + accessory.FileName; if (System.IO.File.Exists(deletePath)) { System.IO.File.Delete(deletePath); } } // 修改和更新都需要的共用部分 accessory.FileName = DateTime.Today.ToString("yyyyMMdd") + "/" + newFileName; accessory.FileSize = fileSize; accessory.LastestAccessDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); return(accessoryService.SaveAccessory(accessory)); } catch (Exception ex) { file.Delete(); WebLogger.Log($"FileExp:{ex.Message}"); throw new Exception(ex.Message); } }
/// <summary> /// 附件文件分片全部上传好后保存 /// </summary> /// <param name="addFileName"></param> /// <param name="flowId"></param> /// <returns></returns> public FileUploadInfo SavePressDetailFileOrdinaryChunk(string addFileName) { if (!addFileName.HasRealValue()) { throw new Exception("请选择文件"); } string fileName = Request["filename"]; if (string.IsNullOrEmpty(fileName)) { fileName = Server.UrlDecode(fileName); } var locationid = Request["locationid"]; var location = Request["location"]; var LocationType = Request["LocationType"]; if (!LocationType.HasRealValue()) { LocationType = location; } var basePath = HMSUtil.GetDocPath(LocationType); var filePath = basePath + DateTime.Today.ToString("yyyyMMdd"); DicCreate(filePath); int sysMaxLength = HMSUtil.GetConfig(EnuInitCode.MaxAttFileSize.ToString()).ToInt(30); int MaxFileLength = 1024 * 1024 * sysMaxLength; FileInfo file = new FileInfo(addFileName); var userToken = AMSAuthentication.GetAuthToken(); var service = new HMSServiceBase(); var db = service.Init(); long fileSize = 0; try { if (!fileName.HasRealValue()) { throw new Exception("文件不能为空"); } if (file.Length > MaxFileLength) { file.Delete(); throw new Exception($"上传的文件的大小超过限制{sysMaxLength}M"); } var fileNameSplits = fileName.Split('.'); fileSize = file.Length; var newFileName = fileNameSplits.FirstOrDefault() + "-" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + Path.GetExtension(fileName); string destinationPath = Path.Combine(filePath, newFileName); file.MoveTo(destinationPath); //对指定格式才会对其进行缩略图的整合 if (new Regex(@"\.(?:jpg|bmp|gif|png)$", RegexOptions.IgnoreCase).IsMatch(fileName.Trim())) { var targetfilename = destinationPath.Insert(destinationPath.LastIndexOf("."), "-Thum"); if (System.IO.File.Exists(targetfilename)) { System.IO.File.Delete(targetfilename); } ImageHelper.MakeThumbnail(destinationPath, targetfilename, 100, 100, "Cut", fileNameSplits.LastOrDefault()); } var accessoryService = new AccessoryService(); var accessory = accessoryService.GetBy(location, locationid, "签收证明", fileNameSplits.FirstOrDefault(), fileNameSplits.LastOrDefault()); if (accessory == null || !accessory.AccessoryId.HasRealValue()) { accessory = new AccessoryEntity() { AccessoryLocation = location, AccessoryLocationId = locationid, AccessoryName = "签收证明", CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), CreateUser = AMSAuthentication.GetAuthToken().UserId, CreateUserName = AMSAuthentication.GetAuthToken().RealName, OwnerId = "12345678" }; } else { // 如果已经存在,是修改,则删除之前的文件 var deletePath = basePath + accessory.FileName; if (System.IO.File.Exists(deletePath)) { System.IO.File.Delete(deletePath); } } // 修改和更新都需要的共用部分 accessory.FileName = DateTime.Today.ToString("yyyyMMdd") + "/" + newFileName; accessory.FileSize = fileSize; accessory.LastestAccessDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); return(accessoryService.SavePresstbDetailAccessory(accessory)); } catch (Exception ex) { file.Delete(); WebLogger.Log($"FileExp:{ex.Message}"); // return JResult.Error("上传未成功,请联系网站管理员"); throw new Exception(ex.Message); } }
/// <summary> /// 添加 /// </summary> /// <param name="model"></param> /// <returns></returns> public override MessageRecorder <bool> Create(Account model) { var r = new MessageRecorder <bool>(); model.CreatedAt = Now; model.CreatedBy = AccountNo; if (model.ValidNos.Any() && model.ValidNos.Count != model.ValidNos.Distinct().Count()) { return(r.Error("电话或者邮件地址重复")); } var validNos = model.ValidNos; if (validNos.IsNullOrEmpty()) { return(r.Error("没有有效账户标识")); } using (var conn = ConnectionManager.Open()) { var trans = conn.BeginTransaction(); var query = new Criteria <Account>() .Or(m => m.No, Op.In, validNos) .Or(m => m.Email, Op.In, validNos) .Or(m => m.Phone, Op.In, validNos) .Or(m => m.Phone2, Op.In, validNos) .Or(m => m.Phone3, Op.In, validNos); if (conn.Exists(query)) { trans.Rollback(); return(r.Error("保存失败")); } var effectedCount = conn.Insert(model, trans); if (effectedCount == -1) { trans.Rollback(); return(r.Error("保存失败")); } var accountRoleRefQuery = new Criteria <AccountRoleRef>() .Where(m => m.AccountNo, Op.Eq, AccountNo); var accountRoleRef = conn.Get(accountRoleRefQuery); if (string.IsNullOrEmpty(accountRoleRef?.BranchNo)) { trans.Rollback(); return(r.Error("没有找到分支号,保存失败")); } var arr = new AccountRoleRef { AccountNo = model.No, BranchNo = accountRoleRef.BranchNo, RoleNo = "BranchStaff", CreatedAt = DateTime.Now, CreatedBy = AccountNo }; var effectedCount1 = conn.Insert(arr, trans); if (effectedCount1 == -1) { trans.Rollback(); return(r.Error("保存失败")); } trans.Commit(); } r.Append(AccessoryService.ClearExpiration(model.Photo)); return(r.SetValue(true)); }
// INTERFACE METHODS public void SelectAccessory() { AccessoryService.ToggleSelectedAccessoryForKitty(kittyModel, accessoryModel); GameManager.instance.unityEvents.accessorySelectEvent.Invoke(); }
public AccessoryReceiptsController(AccessoryReceiptService accReceiptService, AccessoryService accessoryService) { _accReceiptService = accReceiptService; _accessoryService = accessoryService; }
public MonthlyReportVisitor(DateTime start, DateTime end, AccessoryReceiptService accessoryReceiptService, AccessoryService accessoryService) : base(start, end) { _accessoryService = accessoryService; _accessoryReceiptService = accessoryReceiptService; }
public GqlQuery(FehContextFactory dbContextFactory) { this .Field <ListGraphType <GqlAccessory>, List <Accessory> >() .Name("accessories") .ResolveAsync( (context) => { var service = new AccessoryService(dbContextFactory.CreateDbContext()); return(service.GetAllAsync()); } ); this .Field <GqlAccessory, Accessory>() .Name("accessory") .Argument <NonNullGraphType <GuidGraphType> >("id") .ResolveAsync( (context) => { var id = context.GetArgument <Guid>("id"); var service = new AccessoryService(dbContextFactory.CreateDbContext()); return(service.GetByIdAsync(id)); } ); this .Field <ListGraphType <GqlArtist>, List <Artist> >() .Name("artists") .ResolveAsync( (context) => { var service = new ArtistService(dbContextFactory.CreateDbContext()); return(service.GetAllAsync()); } ); this .Field <GqlArtist, Artist>() .Name("artist") .Argument <NonNullGraphType <IntGraphType> >("id") .ResolveAsync( (context) => { var id = context.GetArgument <int>("id"); var service = new ArtistService(dbContextFactory.CreateDbContext()); return(service.GetByIdAsync(id)); } ); this .Field <GqlEnumerations>() .Name("enumerations") .Resolve(x => new { }); this .Field <ListGraphType <GqlHero>, List <Hero> >() .Name("heroes") .ResolveAsync( (context) => { var service = new HeroService(dbContextFactory.CreateDbContext()); return(service.GetAllAsync()); } ); this .Field <GqlHero, Hero>() .Name("hero") .Argument <NonNullGraphType <GuidGraphType> >("id") .ResolveAsync( (context) => { var id = context.GetArgument <Guid>("id"); var service = new HeroService(dbContextFactory.CreateDbContext()); return(service.GetByIdAsync(id)); } ); this .Field <ListGraphType <GqlItem>, List <Item> >() .Name("items") .ResolveAsync( (context) => { var service = new ItemService(dbContextFactory.CreateDbContext()); return(service.GetAllAsync()); } ); this .Field <GqlItem, Item>() .Name("item") .Argument <NonNullGraphType <GuidGraphType> >("id") .ResolveAsync( (context) => { var id = context.GetArgument <Guid>("id"); var service = new ItemService(dbContextFactory.CreateDbContext()); return(service.GetByIdAsync(id)); } ); this .Field <ListGraphType <GqlSkill>, List <Skill> >() .Name("skills") .ResolveAsync( (context) => { var service = new SkillService(dbContextFactory.CreateDbContext()); return(service.GetAllAsync()); } ); this .Field <GqlSkill, Skill>() .Name("skill") .Argument <NonNullGraphType <GuidGraphType> >("id") .ResolveAsync( (context) => { var id = context.GetArgument <Guid>("id"); var service = new SkillService(dbContextFactory.CreateDbContext()); return(service.GetByIdAsync(id)); } ); this .Field <ListGraphType <GqlVoiceActor>, List <VoiceActor> >() .Name("voiceActors") .ResolveAsync( (context) => { var service = new VoiceActorService(dbContextFactory.CreateDbContext()); return(service.GetAllAsync()); } ); this .Field <GqlVoiceActor, VoiceActor>() .Name("voiceActor") .Argument <NonNullGraphType <IntGraphType> >("id") .ResolveAsync( (context) => { var id = context.GetArgument <int>("id"); var service = new VoiceActorService(dbContextFactory.CreateDbContext()); return(service.GetByIdAsync(id)); } ); }
/// <summary> /// 修改 /// </summary> /// <param name="model"></param> /// <returns></returns> public override MessageRecorder <bool> Update(Account model) { var r = new MessageRecorder <bool>(); model.UpdatedAt = Now; model.UpdatedBy = AccountNo; var validNos = model.ValidNos; if (validNos.IsNullOrEmpty()) { return(r.Error("没有有效账户标识")); } string oldKey; using (var conn = ConnectionManager.Open()) { var trans = conn.BeginTransaction(); var query = new Criteria <Account>() .Or(m => m.No, Op.In, validNos) .Or(m => m.Email, Op.In, validNos) .Or(m => m.Phone, Op.In, validNos) .Or(m => m.Phone2, Op.In, validNos) .Or(m => m.Phone3, Op.In, validNos) .And(m => m.Id, Op.NotEq, model.Id); if (conn.Exists(query)) { trans.Rollback(); return(r.Error("编号或者名称重复")); } var obj = new Criteria <Account>() .Where(m => m.Id, Op.Eq, model.Id) .Select(m => m.Photo); oldKey = conn.ExecuteScalarEx <string>(obj.ToSelectSql()); // 在不修改密码的情况下,赋予原来的密码 if (string.IsNullOrEmpty(model.PasswordHash)) { query.ClearCondition().And(m => m.Id, Op.Eq, model.Id); var oriModel = conn.Query(query).FirstOrDefault(); if (oriModel == null) { return(r.Error("账户不存在")); } model.PasswordHash = oriModel.PasswordHash; model.PasswordSalt = oriModel.PasswordSalt; } var effectedCount = conn.Update(model, trans); if (!effectedCount) { trans.Rollback(); return(r.Error("保存失败")); } trans.Commit(); } if (!Equals(oldKey, model.Photo)) { r.Append(AccessoryService.DeleteObject(oldKey)); r.Append(AccessoryService.ClearExpiration(model.Photo)); } return(r.SetValue(true)); }
private void AccessoryStartupProcesses() { var accessoriesToSave = new List <AccessoryModel>(); foreach (string accessoryGroup in AccessoryService.accessoryGroups) { foreach (string accessorySubGroup in AccessoryService.accessorySubGroups) { // load accessory sprites from Resources string addressDir = AccessoryService.GetFormattedAssetDirectory( accessoryGroup, accessorySubGroup ); List <Sprite> accessorySprites = Resources.LoadAll(addressDir, typeof(Sprite)) .Cast <Sprite>() .ToList(); // Debug.Log("count accessory sprites: " + accessorySprites.Count.ToString()); foreach (Sprite accessorySprite in accessorySprites) { // create accessory models if they don't yet exist var accessoryModel = AccessoryService.GetModelByAssetName( accessorySprite.name ); if (accessoryModel == null) { accessoryModel = new AccessoryModel( System.Guid.NewGuid().ToString(), accessorySprite.name, AccessoryService.GetFormattedAssetAddress( accessoryGroup, accessorySubGroup, accessorySprite.name ), AccessoryService.GetFormattedThumbAssetAddress( accessoryGroup, accessorySubGroup, accessorySprite.name ), accessoryGroup, accessorySubGroup ); accessoriesToSave.Add(accessoryModel); } // register assets AssetService.SetSprite( AccessoryService.GetFormattedAssetAddress( accessoryGroup, accessorySubGroup, accessorySprite.name ), accessorySprite ); } // save thumb accessory sprites to Asset service string thumbAddressDir = AccessoryService.GetFormattedThumbAssetDir( accessoryGroup, accessorySubGroup ); List <Sprite> accessoryThumbSprites = Resources.LoadAll(thumbAddressDir, typeof(Sprite)) .Cast <Sprite>() .ToList(); foreach (var accessoryThumbSprite in accessoryThumbSprites) { string thumbAddress = AccessoryService.GetFormattedThumbAssetAddress( accessoryGroup, accessorySubGroup, accessoryThumbSprite.name, true ); AssetService.SetSprite( thumbAddress, accessoryThumbSprite ); } } } // insert accessories to be saved AccessoryService.SaveMultiple(accessoriesToSave); }
public AccessoryIssuesController(AccessoryIssueService accIssueService, RepairedRequestService rrService, AccessoryService accessoryService) { _accIssueService = accIssueService; _rrService = rrService; _accessoryService = accessoryService; }
public RepairedRequestsController(RepairedRequestService repReqService, AccessoryService accSer) { _repReqService = repReqService; _accSer = accSer; }
public MonthlyReportVisitor(DateTime start, DateTime end, RepairedRequestService rrService, AccessoryService accessoryService) : base(start, end) { _rrService = rrService; _accessoryService = accessoryService; }