public async Task TestAddEntry() { var currentPath = Path.Combine(Path.GetTempPath(), "SavedDatabase.kdbx"); var newEntry = new EntryEntity { Name = "New Entry Test" }; var originalFile = await _fileProxy.OpenBinaryFile(Path.Combine(Directory.GetCurrentDirectory(), "Data", "TestDatabase.kdbx")); var currentFile = await _fileProxy.OpenBinaryFile(currentPath); await _database.Open(originalFile, _credentials); await _database.AddEntry(_database.RootGroupId, newEntry.Id); var result = await _database.SaveDatabase(currentFile); await _fileProxy.WriteBinaryContentsToFile(currentPath, result); _database.CloseDatabase(); await _database.Open(currentFile, _credentials); var rootGroup = _database.GetGroup(_database.RootGroupId); Assert.That(newEntry.Id, Is.Not.Empty); Assert.That(rootGroup.Entries.Count, Is.EqualTo(3)); Assert.That(rootGroup.Entries.Last().Name, Is.EqualTo("New Entry Test")); }
public void GetLastEntryByVehicleBadId_ShouldReturnNull() { // Arrange (preparación, organizar) var entryEntity = new EntryEntity { CC = null, EntryTime = DateTime.Now, Id = Guid.NewGuid().ToString(), IdVehicle = "SFL55D", IdVehicleType = VehicleTypeEnum.car }; var entryList = new List <EntryEntity> { entryEntity }; var id = entryEntity.IdVehicle; entryRepository.Setup(er => er.List(er => er.IdVehicle == id)).Returns(entryList); var entryServiceClass = new EntryService(entryRepository.Object, _cellService.Object, _departureService.Object, _placaService.Object); // Act var result = entryServiceClass.GetLastEntryByVehicleId("ZFL55D"); // Assert Assert.IsNull(result); }
public TrainDTO[] GetByUserId(string mobile) { using (MyDbContext dbc = new MyDbContext()) { CommonService <TrainEntity> cs = new CommonService <TrainEntity>(dbc); foreach (var train in cs.GetAll()) { if (train.StartTime > DateTime.Now) { train.StatusId = 34; } else if (train.StartTime <= DateTime.Now && train.EndTime >= DateTime.Now) { train.StatusId = 35; } else if (train.EndTime < DateTime.Now) { train.StatusId = 36; } } dbc.SaveChanges(); CommonService <EntryEntity> ecs = new CommonService <EntryEntity>(dbc); var entry = ecs.GetAll().SingleOrDefault(u => u.Mobile == mobile); if (entry == null) { entry = new EntryEntity(); } //return dbc.Database.SqlQuery<ActivityDTO>("select top(10) a.ID,a.Num,a.Name,a.Description,a.ImgUrl,a.StatusId,i.Name as StatusName,a.PaperId,t.TestTitle as PaperTitle,a.PrizeName,a.PrizeImgUrl,a.WeChatUrl,a.VisitCount,a.ForwardCount,a.AnswerCount,a.HavePrizeCount,a.PrizeCount,a.StartTime,a.ExamEndTime,a.RewardTime from T_Activities as a left join t_idnames i on i.id=a.statusid left join T_TestPapers t on t.Id=a.PaperId, (select ActivityId from T_UserActivities where UserId=@id) as u where a.Id=u.ActivityId and a.IsDeleted=0", new SqlParameter("@id",id)).ToArray(); return(entry.Trains.Where(a => a.IsDeleted == false).OrderByDescending(a => a.CreateDateTime).Take(20).ToList().Select(a => ToDTO(a)).ToArray()); } }
/// <summary> /// Validate if a state update requested by a user via a patch update is valid. /// </summary> /// <param name="entry"></param> /// <param name="targetEventId"></param> /// <returns></returns> private bool ValidateStateMove(EntryEntity entry, int targetEventId) { // check to ensure the state they want to move to is possible. // get the current event state they are in.. var chainCheck = entry.Game.Chain.SingleOrDefault(x => x.Id == entry.State); var failEventId = chainCheck.FailEvent ?? 0; var successEventId = chainCheck.SuccessEvent ?? 0; // if the target event state equals one of the success or fail id's... then validate move and update. if (failEventId == targetEventId || successEventId == targetEventId) { var destEventEntity = entry.Game.Events.SingleOrDefault(x => x.Id == targetEventId); var destruleset = _mapper.Map <Event>(destEventEntity); var destState = Validate(entry, destEventEntity); if (destState == "ok") { return(true); } } else { AddErrorToCollection(new Error { Key = "EntryUpdate", Message = "Update to entry state failed, cannot move to proposed state from current state." }); } return(false); }
public void FromModelToDto_Should_Map_Entry_To_PwEntry() { var entry = new EntryEntity { Id = "VGhlIHF1aWNrIGJyb3duIA==", Name = "Test", UserName = "******", Password = "******", Url = new Uri("http://google.com"), Notes = "blabla", ExpirationDate = DateTimeOffset.Now, //BackgroundColor = Color.White, //ForegroundColor = Color.Black, AdditionalFields = new Dictionary <string, string> { { "additional", "custom" } } }; var pwEntry = new PwEntry(false, false); _mapper.Map(entry, pwEntry); Assert.That(pwEntry.ExpiryTime, Is.Not.EqualTo(default(DateTime))); //Assert.That(pwEntry.BackgroundColor, Is.EqualTo(Color.White)); //Assert.That(pwEntry.ForegroundColor, Is.EqualTo(Color.Black)); Assert.That(pwEntry.Strings.GetSafe(PwDefs.TitleField).ReadString(), Is.EqualTo("Test")); Assert.That(pwEntry.Strings.GetSafe(PwDefs.UserNameField).ReadString(), Is.EqualTo("toto")); Assert.That(pwEntry.Strings.GetSafe(PwDefs.PasswordField).ReadString(), Is.EqualTo("password")); Assert.That(pwEntry.Strings.GetSafe(PwDefs.UrlField).ReadString(), Is.EqualTo(new Uri("http://google.com"))); Assert.That(pwEntry.Strings.GetSafe(PwDefs.NotesField).ReadString(), Is.EqualTo("blabla")); Assert.That(pwEntry.Strings.GetSafe("additional").ReadString(), Is.EqualTo("custom")); }
public DtoDeparture RegistryDeparture(DtoDeparture departure) { double totalCharge; var departureTime = DateTime.Now; EntryEntity lastEntry = GetInfoEntryByVehicleId(departure.IdVehicle); if (lastEntry == null) { throw new DepartureException("No existe un registro de entrada para el vehículo"); } RateEntity rateEntity = _rateService.GetRateByVehicleType(lastEntry.IdVehicleType); if (rateEntity == null) { throw new DepartureException("No existe una tarifa configurada para el tipo de vehículo"); } var difference = departureTime - lastEntry.EntryTime;//Math.Ceiling((departureTime - lastEntry.EntryTime).TotalHours); int days = difference.Days; double hours = Math.Ceiling(difference.TotalHours); if (days < 1) { if (hours >= rateEntity.DayChargeFrom) { totalCharge = rateEntity.DayValue; } else { totalCharge = rateEntity.HourValue * hours; } } else { var additionalHours = hours % 24; totalCharge = days * rateEntity.DayValue; totalCharge += additionalHours * rateEntity.HourValue; } if (lastEntry.IdVehicleType == VehicleTypeEnum.motorcycle) { bool isParsed = short.TryParse(lastEntry.CC, out short cc); if (!isParsed) { throw new DepartureException("No fue posible determinar el cilindraje del vehículo"); } if (cc >= rateEntity.SpecialChargeFromCC) { totalCharge += rateEntity.SpecialChargeValue; } } var entryEntity = _departureRepository.Add(DepartureMapper.ConvertDTOToEntity(departure, lastEntry, totalCharge)); _cellService.IncreaseCell(lastEntry.IdVehicleType, 1); return(DepartureMapper.ConvertEntityToDTO(entryEntity)); }
private async Task Edit(EntryEntity entity) { selected = entity; var parameters = new NavigationParameters() .SetValue(EditParameter.Value, entity.Qty) .SetValue(EditParameter.ResetValue, entity.Qty); await navigator.PushModelAsync("/Edit/QtyEditPage", parameters); }
public async Task <bool> DeleteChainAsync(int gameId) { var success = true; var gameEntity = _context.Find(typeof(GameEntity), gameId) as GameEntity; if (gameEntity != null) { var randomDrawEvents = from Chain in gameEntity.Chain join evnt in gameEntity.Events on Chain.Id equals evnt.Id where evnt.Type == EventType.RandomDraw select evnt; // clear any random draw jobs foreach (var randomDraw in randomDrawEvents) { await _randomDrawEventService.ClearDrawExecutionJobs(randomDraw.Id); } gameEntity.Chain = null; foreach (var id in _context.Entries.Where(x => x.GameId == gameId).Select(e => e.Id)) { var entity = new EntryEntity { Id = id }; _context.Entries.Attach(entity); _context.Entries.Remove(entity); } foreach (var id in _context.Players.Where(x => x.GameId == gameId).Select(e => e.Id)) { var entity = new PlayerEntity { Id = id }; _context.Players.Attach(entity); _context.Players.Remove(entity); } //gameEntity.Entries.Clear(); // clear all entries for this game. //gameEntity.Players.Clear(); // clear all players for this game. } else { success = false; } await _context.SaveChangesAsync(); return(success); }
public static EntryEntity ConvertDTOToEntity(DtoEntry entry) { EntryEntity entryEntity = new EntryEntity(); if (entry != null) { entryEntity.CC = entry.CC; entryEntity.EntryTime = DateTime.Now; entryEntity.IdVehicle = entry.IdVehicle; entryEntity.IdVehicleType = entry.IdVehicleType; entryEntity.Id = Guid.NewGuid().ToString(); } return(entryEntity); }
public static DtoEntry ConvertEntityToDTO(EntryEntity entry) { DtoEntry entryEntity = new DtoEntry(); if (entry != null) { entryEntity.CC = entry.CC; entryEntity.IdVehicle = entry.IdVehicle; entryEntity.IdVehicleType = entry.IdVehicleType; entryEntity.Id = entry.Id; entryEntity.EntryTime = entry.EntryTime; } return(entryEntity); }
public static DepartureEntity ConvertDTOToEntity(DtoDeparture dtoDeparture, EntryEntity entryEntity, double rateTotal) { DepartureEntity departureEntity = new DepartureEntity(); if (dtoDeparture != null) { departureEntity.DepartureTime = DateTime.Now; departureEntity.IdVehicle = dtoDeparture.IdVehicle; departureEntity.Id = Guid.NewGuid().ToString(); departureEntity.IdEntry = entryEntity.Id; departureEntity.RateTotalValue = rateTotal; } return(departureEntity); }
/// <summary> /// Given an entry it validate the destination event is ok to move to. /// </summary> /// <param name="entry">the entry to move</param> /// <param name="destEventId">the destination event id</param> /// <returns>true if the move is valid</returns> private async Task <bool> ValidateMove(EntryEntity entry, int destEventId) { var isSuccess = false; if (destEventId != 0) { var destEvent = await _context.Events.FirstAsync(x => x.Id == destEventId); if (Validate(entry, destEvent) == "ok") { isSuccess = true; } } return(isSuccess); }
private void FillReferDetail(ExtendedDataEntity[] entityDataes, DynamicObject billTypePara) { FormMetadata metadata = (FormMetadata)Kingdee.K3.MFG.App.AppServiceContext.MetadataService.Load(base.Context, "QM_InspectBill", true); EntryEntity entryEntity = metadata.BusinessInfo.GetEntryEntity("FReferDetail"); List <long> srcEntryIds = (from s in entityDataes from ss in s.DataEntity["FEntity_Link"] as DynamicObjectCollection select ss.GetDynamicObjectItemValue <long>("SId", 0L)).Distinct <long>().ToList <long>(); string businessType = billTypePara.GetDynamicObjectItemValue <string>("FInspectType", null); DynamicObjectCollection col = this.GetSrcInfo(base.Context, srcEntryIds, businessType); if (!col.IsEmpty <DynamicObject>()) { foreach (ExtendedDataEntity entity2 in entityDataes) { DynamicObject dataEntity = entity2.DataEntity; DynamicObjectCollection objects2 = entity2.DataEntity.GetDynamicObjectItemValue <DynamicObjectCollection>("ReferDetail", null); objects2.Clear(); DynamicObjectCollection objects3 = entity2.DataEntity.GetDynamicObjectItemValue <DynamicObjectCollection>("FEntity_Link", null); int num = 1; foreach (DynamicObject obj2 in objects3) { InspectBillView.FEntity_Link link = obj2; foreach (DynamicObject obj3 in (from w in col where w.GetDynamicObjectItemValue <string>("FTEID", null) == link.SId select w).ToList <DynamicObject>()) { InspectBillView.ReferDetail detail = new Kingdee.K3.MFG.Common.BusinessEntity.QM.InspectBillView.ReferDetail(new DynamicObject(entryEntity.DynamicObjectType)) { Seq = num++, SrcBillType = obj3.GetDynamicObjectItemValue <string>("FSRCBILLTYPE", null), SrcBillNo = obj3.GetDynamicObjectItemValue <string>("FSRCBILLNO", null), SrcInterId = Convert.ToInt64(link.SBillId), SrcEntryId = Convert.ToInt64(link.SId), SrcEntrySeq = (long)obj3.GetDynamicObjectItemValue <int>("FSRCENTRYSEQ", 0), OrderType_Id = obj3.GetDynamicObjectItemValue <string>("FORDERBILLTYPE", null), OrderBillNo = obj3.GetDynamicObjectItemValue <string>("FORDERBILLNO", null), OrderId = obj3.GetDynamicObjectItemValue <long>("FORDERID", 0L), OrderEntryId = obj3.GetDynamicObjectItemValue <long>("FORDERENTRYID", 0L), OrderEntrySeq = (long)obj3.GetDynamicObjectItemValue <int>("FORDERENTRYSEQ", 0) }; objects2.Add((DynamicObject)detail); } } } } }
public void OnNavigatingTo(NavigationContext context) { if (context.IsPopBack) { var value = context.Parameters.GetValueOrDefault <long?>(EditParameter.Value); if (value.HasValue) { selected.Qty = value.Value; updated = true; UpdateSummary(); selected = null; } } }
public override void BeforeSave(BOS.Core.Bill.PlugIn.Args.BeforeSaveEventArgs e) { base.BeforeSave(e); //销售订单的“当前组织”、“己审核”的销售订单的当前物料的数量 和 该单据物料之和大于最大销量 不允许提交当前销售订单 EntryEntity entryEntity = this.View.BusinessInfo.GetEntryEntity("FSaleOrderEntry"); DynamicObjectCollection rows = this.View.Model.GetEntityDataObject(entryEntity); IOperationResult operaRst = new OperationResult(); operaRst.IsSuccess = false; operaRst.CustomMessageModel = K3DisplayerModel.Create(this.Context, "行号~|~校验信息"); operaRst.CustomMessageModel.FieldAppearances[0].Width = new LocaleValue("100", this.Context.UserLocale.LCID); operaRst.CustomMessageModel.FieldAppearances[1].Width = new LocaleValue("100", this.Context.UserLocale.LCID); operaRst.CustomMessageModel.FieldAppearances[2].Width = new LocaleValue("300", this.Context.UserLocale.LCID); foreach (var row in rows) { DynamicObject material = row["MaterialID"] as DynamicObject; decimal qty = Convert.ToDecimal(row["Qty"]); decimal maxQty = Convert.ToDecimal(material["F_PAEZ_maxSaleQty"]); int seq = Convert.ToInt32(row["Seq"]); if (null == material) { return; } string sql = string.Format(@"SELECT sum(b.FQTY) qty FROM T_SAL_ORDER a inner join T_SAL_ORDERENTRY b on a.fid =b.fid WHERE b.FMATERIALID ='{0}' AND a.FDOCUMENTSTATUS in ('B','C') ", material["Id"]); DynamicObjectCollection saleOrderCol = DBUtils.ExecuteDynamicObject(this.Context, sql); if (saleOrderCol.Count > 0) { qty = qty + Convert.ToDecimal(saleOrderCol[0]["qty"]); } if (qty > maxQty) { operaRst.CustomMessageModel.AddMessage(string.Format("{0}~|~{1}", seq, "大于此物料的最大销量,不允许提交当前销售订单")); } } if (operaRst.CustomMessageModel.Messages.Count() > 0) { e.Cancel = true; this.View.ShowK3Displayer(operaRst.CustomMessageModel); } }
/// <summary> /// Given an entry it will check to see if the entry needs to be automatically moved onto the next state. /// </summary> /// <param name="entry">The entry to check</param> /// <param name="chain">The chain instance the entry belongs too.</param> /// <param name="saveChanges">If true any entry entity changes to state will be saved to the database. /// Set this to false if you are going to call SaveChanges on the db context yourself.</param> /// <returns>Returns true if the entryEntity state has changed.</returns> private async Task <bool> ProcessEntryStateAsync(EntryEntity entry, ChainEntity chain, bool saveChanges) { // get entry // get the event its in // is the event a timed event? if so does the entry need to move on? var currentEvent = await _context.Events.FirstAsync(x => x.Id == entry.State); if (currentEvent.TransitionType == TransitionType.Timed && currentEvent.ManualAdvance == false) // if manual advance is false then we can try and move it. { var datetimeNow = DateTime.UtcNow; if (currentEvent.EndDate < datetimeNow) // the event it sits in now has expired... { // then if valid this entry should move on to the next event state. // first check the pass round var successeventId = chain.SuccessEvent ?? 0; var faileventId = chain.FailEvent ?? 0; // CHECK IF ITS A MODERATE EVENT TYPE THE ENTRY IS CURRENTLY IN THEN IT NEEDS TO EITHER STAY WHERE IT IS // OR MOVE TO THE FALSE EVENT. // CUSTOM EVENTS CAN ONLY BE MOVED MANUALLY BY CALLING ADVANCE OR UPDATING ENTRIES MANUALLY. // CURRENTLY ALL OTHER EVENTS ARE ACTION ONLY SO ARE NOT AFFECTED BY THIS. if (currentEvent.Type == EventType.Moderate) { // then move to false event.. or keep where it is var ok = await ValidateMove(entry, faileventId); if (ok) { entry.State = faileventId; if (saveChanges) { await _context.SaveChangesAsync(); } return(true); } } } } return(false); }
public async Task <StatusEntityPair <EntryStatusEntity, EntryEntity> > QueryEntryAsync(int storageNo) { var path = Path.Combine(Definition.EntryDirectory, Definition.EntryFileFormatter(storageNo)); if (!fileService.IsFileExists(path)) { return(new StatusEntityPair <EntryStatusEntity, EntryEntity>( new EntryStatusEntity { StorageNo = storageNo }, Enumerable.Empty <EntryEntity>())); } using (var stream = await fileService.OpenReadAsync(path).ConfigureAwait(false)) { // Status var buffer = new byte[EntryStatusEntity.Size]; stream.Read(buffer, 0, buffer.Length); var status = new EntryStatusEntity(); status.FromBytes(buffer); // Entity var count = (int)((stream.Length - EntryStatusEntity.Size) / EntryEntity.Size); var list = new List <EntryEntity>(count); buffer = new byte[EntryEntity.Size]; for (var i = 0; i < count; i++) { stream.Position = (EntryEntity.Size * i) + EntryStatusEntity.Size; stream.Read(buffer, 0, buffer.Length); var entity = new EntryEntity { DetailNo = i + 1 }; entity.FromBytes(buffer); list.Add(entity); } return(new StatusEntityPair <EntryStatusEntity, EntryEntity>(status, list)); } }
private async Task Scan() { var code = await barcodeService.ScanAsync(); if (String.IsNullOrEmpty(code)) { return; } var item = await itemService.FindItemAsync(code); if (item == null) { return; } // TODO if ((Entities.Count > 0) && (Entities[0].ItemCode == code)) { Entities[0].Qty++; } else { var entry = new EntryEntity { DetailNo = Entities.Count + 1, ItemCode = item.ItemCode, ItemName = item.ItemName, SalesPrice = item.SalesPrice, Qty = 1 }; Entities.Insert(0, entry); } updated = true; UpdateSummary(); }
public void GetEntryById_ShouldReturnADTOEntry() { // Arrange var entryEntity = new EntryEntity { CC = null, EntryTime = DateTime.Now, Id = Guid.NewGuid().ToString(), IdVehicle = "SFL55D", IdVehicleType = VehicleTypeEnum.car }; var id = entryEntity.Id; entryRepository.Setup(er => er.GetById(id)).Returns(entryEntity); var entryServiceClass = new EntryService(entryRepository.Object, _cellService.Object, _departureService.Object, _placaService.Object); // Act var result = entryServiceClass.GetEntryById(id); // Assert Assert.IsTrue(result.GetType() == typeof(DtoEntry)); }
public override void BarItemClick(BOS.Core.DynamicForm.PlugIn.Args.BarItemClickEventArgs e) { base.BarItemClick(e); switch (e.BarItemKey) { case "tbAmountAllocation": //点击“金额分摊”功能后,重新计算销售增值税专用发票的单据体分录“含税单价”,含税单价=原价*折扣率; EntryEntity entryEntity = this.View.BusinessInfo.GetEntryEntity("FSALESICENTRY"); DynamicObjectCollection rows = this.View.Model.GetEntityDataObject(entryEntity); decimal disaccount = Convert.ToDecimal(this.View.Model.GetValue("F_PAEZ_disaccount")); //折扣率 int rowCount = rows.Count; for (int i = 0; i < rowCount; i++) { decimal origPrice = Convert.ToDecimal(this.View.Model.GetValue("F_PAEZ_origPrice", i)); //原价 //5、 金额分摊时,要把折扣率和折扣额清零,否则会造成折上折 this.View.Model.SetValue("FENTRYDISCOUNTRATE", 0, i); //折扣率% this.View.Model.SetValue("FDISCOUNTAMOUNTFOR", 0, i); //折扣额 this.View.Model.SetValue("FAUXTAXPRICE", origPrice * disaccount, i); //含税单价=原价*折扣率 } return; } }
public void GetEntryByBadId_ShouldReturnAnEntityWithValuesInNull() { // Arrange var entryEntity = new EntryEntity { CC = null, EntryTime = DateTime.Now, Id = Guid.NewGuid().ToString(), IdVehicle = "SFL55D", IdVehicleType = VehicleTypeEnum.car }; var id = "aa"; entryRepository.Setup(er => er.GetById(entryEntity.Id)).Returns(entryEntity); var entryServiceClass = new EntryService(entryRepository.Object, _cellService.Object, _departureService.Object, _placaService.Object); // Act var result = entryServiceClass.GetEntryById(id); // Assert Assert.IsNull(result.Id); }
private EntryDTO ToDTO(EntryEntity entity) { EntryDTO dto = new EntryDTO(); dto.Address = entity.Address; dto.BankAccount = entity.BankAccount; dto.CityId = entity.CityId; dto.Contact = entity.Contact; dto.CreateDateTime = entity.CreateDateTime; dto.Duty = entity.Duty; dto.Ein = entity.Ein; dto.EntryChannelId = entity.EntryChannelId; dto.Gender = entity.Gender; dto.Id = entity.Id; dto.InvoiceUp = entity.InvoiceUp; dto.Mobile = entity.Mobile; dto.Name = entity.Name; dto.OpenBank = entity.OpenBank; dto.PayId = entity.PayId; dto.StayId = entity.StayId; dto.WorkUnits = entity.WorkUnits; return(dto); }
/// <summary> /// 移动表格分录 /// </summary> /// <param name="view"></param> /// <param name="entityKey"></param> /// <param name="iSrcRowIndex"></param> /// <param name="iDstRowIndex"></param> /// <param name="callback"></param> public static void MoveEntryRow(this IDynamicFormView view, string entityKey, int iSrcRowIndex, int iDstRowIndex, Action <int, int> callback = null) { EntryEntity entryEntity = view.BillBusinessInfo.GetEntryEntity(entityKey); DynamicObjectCollection dataEntities = view.Model.GetEntityDataObject(entryEntity); if (iSrcRowIndex < 0 || iSrcRowIndex >= dataEntities.Count) { return; } if (iDstRowIndex < 0 || iDstRowIndex >= dataEntities.Count) { return; } var srcRow = dataEntities[iSrcRowIndex]; var dstRow = dataEntities[iDstRowIndex]; if (iSrcRowIndex > iDstRowIndex) { dataEntities.RemoveAt(iSrcRowIndex); dataEntities.Insert(iDstRowIndex, srcRow); } else { dataEntities.RemoveAt(iDstRowIndex); dataEntities.Insert(iSrcRowIndex, dstRow); } EntryGrid grid = view.GetControl <EntryGrid>(entityKey); grid.ExchangeRowIndex(iSrcRowIndex, iDstRowIndex); grid.SetFocusRowIndex(iDstRowIndex); if (callback != null) { callback(iSrcRowIndex, iDstRowIndex); } }
public override void CreateNewData(BizDataEventArgs e) { base.CreateNewData(e); DynamicObjectCollection logs = GetObjects(this.Context, initSql); DynamicObjectType dtType = this.View.BusinessInfo.GetDynamicObjectType(); EntryEntity entity = (EntryEntity)this.View.BusinessInfo.GetEntity("F_HS_Entity"); DynamicObject objData = new DynamicObject(dtType); DynamicObject entityObj = null; if (logs != null && logs.Count > 0) { int seq = 1; foreach (var log in logs) { if (log != null) { entityObj = new DynamicObject(entity.DynamicObjectType); entity.DynamicProperty.GetValue <DynamicObjectCollection>(objData).Add(entityObj); entityObj["seq"] = seq; entityObj["F_HS_DataSourceType"] = log["FDataSourceType"]; entityObj["F_HS_DataSourceId"] = log["FDataSourceId"]; entityObj["F_HS_BILLNO"] = log["FBILLNO"]; entityObj["F_HS_SynchroTime"] = log["FSynchroTime"]; entityObj["F_HS_IsSuccess"] = log["FIsSuccess"]; entityObj["F_HS_ErrInfor"] = log["FErrInfor"]; entityObj["F_HS_DataSourceTypeDesc"] = log["FDataSourceTypeDesc"]; entityObj["F_HS_OperateId"] = log["FHSOperateId"]; seq++; } } e.BizDataObject = objData; } }
private async Task <object> SubmitEntry(string phoneNumber) { phoneNumber = phoneNumber.ToLower(); if (PhoneExists(phoneNumber)) { throw new Exception("This phone number has already been entered"); } //naive collision detection string entryCode; do { entryCode = RandomString(5); } while (EntryExists(entryCode)); var newEntry = new EntryEntity { PhoneNumber = phoneNumber.ToLower(), EntryCode = entryCode }; _ctx.Entries.Add(newEntry); await SMSClient.SendSms(phoneNumber, newEntry.EntryCode); await _ctx.SaveChangesAsync(); return(new { newEntry.EntryCode, PhoneNumber = phoneNumber }); }
public void UpdateEntry(EntryEntity entry) { throw new NotImplementedException(); }
public async Task AddEntry(AddEntryModel model) { EntryEntity entryEntity = _mappingHelper.Map <EntryEntity, AddEntryModel>(model); await _entryRepository.AddEntry(entryEntity); }
public Entry MapEntry(EntryEntity src, Entry dest) { return(mapper.Map(src, dest)); }
public void AddEntry(EntryEntity entry) { _context.Entries.Add(entry); }
private EntryEntity CreateNewEntryEntity() { EntryEntity relatedEntity = new EntryEntity(); return relatedEntity; }
/// <summary> /// 处理Excel块粘贴功能 /// </summary> /// <param name="view"></param> /// <param name="e"></param> /// <param name="bAllowAutoNewRows">允许自动新增行</param> /// <param name="bCanPaste">是否允许填充某字段</param> public static void PasteBlockData(this IDynamicFormView view, EntityBlockPastingEventArgs e, bool bAllowAutoNewRows = false, Func <FieldAppearance, int, bool> bCanPaste = null) { if (e.BlockValue.IsNullOrEmptyOrWhiteSpace()) { return; } FieldAppearance startFieldAp = view.LayoutInfo.GetFieldAppearance(e.StartKey); if (startFieldAp == null || (startFieldAp.Field.Entity is EntryEntity) == false) { return; } EntryEntity entryEntity = (EntryEntity)startFieldAp.Field.Entity; int iTotalRows = view.Model.GetEntryRowCount(entryEntity.Key); var copyOperation = view.BillBusinessInfo.GetForm().FormOperations .FirstOrDefault(o => o.OperationId == 31 && string.Equals(o.Parmeter.OperationObjectKey, entryEntity.Key, StringComparison.InvariantCultureIgnoreCase)); bool isCopyLinkEntry = false; //如果表格未配置复制行操作,则不允许自动新增行 if (copyOperation == null) { bAllowAutoNewRows = false; } else { isCopyLinkEntry = GetIsCopyLinkEntryParam(copyOperation.Parmeter); } string[] strBlockDataRows = e.BlockValue.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); int iRow = e.StartRow; foreach (var rowData in strBlockDataRows) { if (iRow >= iTotalRows) { if (bAllowAutoNewRows) { view.Model.CopyEntryRow(entryEntity.Key, iRow - 1, iRow, isCopyLinkEntry); } else { break; } } string[] strItemValues = rowData.Split(new char[] { '\t' }); FieldAppearance fieldAp = startFieldAp; foreach (var value in strItemValues) { if (fieldAp == null) { continue; } object objValue = value; if (typeof(ValueType).IsAssignableFrom(fieldAp.Field.GetPropertyType())) { if (value.IsNullOrEmptyOrWhiteSpace()) { objValue = 0; } else { ValueTypeConverter converter = new ValueTypeConverter(); if (value != null && converter.CanConvertTo(value.GetType())) { objValue = converter.ConvertTo(value, fieldAp.Field.GetPropertyType()); } } } if (bCanPaste == null || bCanPaste(fieldAp, iRow)) { (view as IDynamicFormViewService).UpdateValue(fieldAp.Key, iRow, objValue); } fieldAp = GetNextEditFieldAp(view, fieldAp, iRow); } iRow++; } }