public object[] Take(ContractEntity input) { /*var orgType = input.GetType().GetProperties(); * var obj = new object[orgType.Length * 2]; * for (int i = 0; i < orgType.Length; i++) * { * obj[i * 2] = "@" + orgType[i].Name.Replace("Id", "ID"); * if (obj[i * 2].ToString().Equals("@ValidationErrors")) * obj[i * 2 + 1] = null; * else * obj[i * 2 + 1] = input.GetType().GetProperty(orgType[i].Name).GetValue(input, null) != null ? input.GetType().GetProperty(orgType[i].Name).GetValue(input, null) : null; * } * return obj;*/ return(new object[] { "@ContractID", input.ContractId, "@ContractNo", input.ContractNo, "@ContractName", input.ContractName, "@ContractNameEnglish", input.ContractNameEnglish, "@SignDate", input.SignDate, "@StartDate", input.StartDate, "@EndDate", input.EndDate, "@CurrencyCode", input.CurrencyCode, "@ExchangeRate", input.ExchangeRate, "@AmountOC", input.AmountOC, "@ProjectID", input.ProjectId, "@Description", input.Description, "@VendorID", input.VendorId, "@VendorBankAccountID", input.VendorBankAccountId, "@IsActive", input.IsActive, }); }
/// <summary> /// Migrate contract, save immediately /// </summary> /// <param name="contract"></param> /// <param name="migrateContract"></param> /// <param name="txId"></param> /// <param name="time"></param> public void MigrateContract(UInt160 contract, Nep5ContractInfo migrateContract, UInt256 txId, DateTime time) { var migrateContractHash = migrateContract.Hash.ToBigEndianHex(); var tx = txId.ToBigEndianHex(); var old = GetActiveContract(contract); if (old != null) { old.DeleteOrMigrateTxId = tx; old.MigrateTo = migrateContractHash; old.MigrateTime = time; var newContract = new ContractEntity() { Hash = migrateContractHash, Name = migrateContract.Name, Symbol = migrateContract.Symbol, Decimals = migrateContract.Decimals, CreateTime = migrateContract.CreateTime, CreateTxId = tx, }; _sqldb.Contracts.Add(newContract); _sqldb.SaveChanges(); _sqldb.InvokeRecords.Add(new InvokeRecordEntity() { ContractId = newContract.Id, TxId = tx, Methods = "Deployed" }); _sqldb.SaveChanges(); // migrate balance records to new contract _sqldb.AssetBalances.Where(a => a.AssetId == old.Id).BatchUpdate(new AssetBalanceEntity() { AssetId = newContract.Id }); } }
public bool Edit(ContractEntity contract) { try { var oldContract = context.Contracts.SingleOrDefault(x => x.ContractId == contract.Id && x.CustomerId == contract.CustomerId && x.SupplierId == contract.SupplierId); if (oldContract != null) { oldContract.ContractDescription = contract.Description; oldContract.ContractAddress = contract.Address; oldContract.BankAccountInFinance = contract.BankAccountInFinance; context.SaveChanges(); context.BudgetsContracts.RemoveRange(context.BudgetsContracts.Where(x => x.ContractId == contract.Id && x.CustomerId == contract.CustomerId && x.SupplierId == contract.SupplierId)); context.SaveChanges(); context.BudgetsContracts.AddRange(contract.BudgetContract.Select(x => new BudgetsContracts { BudgetId = x.BudgetId, ContractId = contract.Id, CustomerId = x.CustomerId, SupplierId = x.SupplierId, BudgetPrecent = x.Precent })); context.SaveChanges(); return(true); } else { return(false); } } catch (Exception e) { throw e; } }
/// <summary> /// Create contract, save immediately /// </summary> /// <param name="newContract"></param> public void CreateContract(Nep5ContractInfo newContract) { var contractHash = newContract.Hash.ToBigEndianHex(); var old = GetActiveContract(newContract.Hash); if (old == null) { var contract = new ContractEntity() { Hash = contractHash, Name = newContract.Name, Symbol = newContract.Symbol, Decimals = newContract.Decimals, CreateTime = newContract.CreateTime, CreateTxId = newContract.CreateTxId?.ToBigEndianHex(), }; _sqldb.Contracts.Add(contract); _sqldb.SaveChanges(); //save create contract transaction record _sqldb.InvokeRecords.Add(new InvokeRecordEntity() { ContractId = contract.Id, TxId = contract.CreateTxId, Methods = "Deployed" }); _sqldb.SaveChanges(); } }
public void AddEntity(ContractEntity newEntity) { Entities.Add(newEntity); migrator.Notify( () => Entities, () => Entities.Add(newEntity), () => Entities.Remove(newEntity), MigratorMode.EveryChange); }
public void RemoveEntity(ContractEntity removeEntity) { var position = Entities.IndexOf(removeEntity); Entities.Remove(removeEntity); migrator.Notify( () => Entities, () => Entities.Remove(removeEntity), () => Entities.Insert(position, removeEntity), MigratorMode.EveryChange); }
public async Task PostJob(JobPostModel model) { ContractEntity entity = Mapper.Map <JobPostModel, ContractEntity>(model); entity.UserId = NTContext.Context.UserId; entity.ContractStatusId = (int)ContractStatusEnum.Job; entity.PublicStatusId = (int)ContractStatusEnum.Job; this.DbContext.Contracts.Add(entity); await this.DbContext.SaveChangesAsync(); }
private AssetBalanceEntity GetOrCreateBalance(AddressEntity address, ContractEntity asset, BigInteger balance, uint height) { var old = _sqldb.AssetBalances.FirstOrDefault(a => a.AddressId == address.Id && a.AssetId == asset.Id); if (old == null) { old = new AssetBalanceEntity() { AddressId = address.Id, AssetId = asset.Id, Balance = balance.ToByteArray(), BlockHeight = height }; _sqldb.AssetBalances.Add(old); _sqldb.SaveChanges(); } return old; }
/// <summary> /// 新增合同 /// </summary> /// <param name="entity">合同主体对象</param> /// <param name="serviceEntityList">服务类型</param> public void AddForm(ContractEntity entity, List <ContractServiceEntity> serviceEntityList) { try { service.AddForm(entity, serviceEntityList); } catch (Exception) { throw; } }
/// <summary> /// 新增合同 /// </summary> /// <param name="entity">合同主体对象</param> /// <param name="serviceEntityList">服务类型</param> /// <param name="moduleId">模块ID</param> /// <param name="moduleCode">模板编码</param> public void AddForm(ContractEntity entity, List <ContractServiceEntity> serviceEntityList, string moduleId, string moduleCode) { try { service.AddForm(entity, serviceEntityList, moduleId, moduleCode); } catch (Exception) { throw; } }
public IActionResult EditContract([FromBody] ContractEntity contract) { try { return(Ok(contractsService.Edit(contract))); } catch (Exception e) { log.LogError(e.Message + "\nin:" + e.StackTrace); return(Problem(null)); } }
public async Task <ContractEntity> ContractGetContractFile(Guid contactUID) { var contract = await ContractRepository.ContractGetContractFile(contactUID); var contractToReturn = new ContractEntity() { ContractFile = contract.ContractFile, ContractFileName = contract.ContractFileName }; return(contractToReturn); }
public ActionResult SaveContractForm(string keyValue, ContractModel model) { ContractEntity entity = new ContractEntity(); entity.ContractId = model.ContractId; entity.ContractMoney = model.ContractMoney; entity.ContractType = model.ContractType; entity.CustomerId = model.CustomerId; entity.CustomerName = model.CustomerName; entity.Deadline = model.Deadline; entity.Description = model.Description; entity.EffectiveDate = model.EffectiveDate; entity.PaymentMethod = model.PaymentMethod; entity.PhoneNumber = model.PhoneNumber; entity.ProjectLeader = model.ProjectLeader; entity.ServiceType = model.ServiceType.TrimEnd(new char[] { ',', ';' }); entity.SignSubject = model.SignSubject; entity.SignSubjectId = model.SignSubjectId; entity.SignType = model.SignType; entity.ContractCode = model.ContractCode; List <ContractServiceEntity> serviceEntityList = new List <ContractServiceEntity>(); if (!string.IsNullOrWhiteSpace(model.ServiceTypeId)) { var arrIds = model.ServiceTypeId.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); var arrNames = model.ServiceType.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < arrIds.Length; i++) { ContractServiceEntity serviceEntity = new ContractServiceEntity(); serviceEntity.ServiceTypeId = arrIds[i]; serviceEntity.ServiceType = arrNames[i]; serviceEntity.ContractId = model.ContractId; serviceEntity.Create(); serviceEntityList.Add(serviceEntity); //合同编码的前置 if (string.IsNullOrWhiteSpace(entity.ContractCode)) { var dataItem = dataItemCache.GetDataItem(serviceEntity.ServiceTypeId); if (dataItem != null) { entity.ContractCode = dataItem.ItemValue; } } } } contractbll.AddForm(entity, serviceEntityList); return(Success("操作成功。")); }
public BudgetContractEntity[] GetRelationByContract(ContractEntity contract) { var result = context.BudgetsContracts.Where(x => x.CustomerId == contract.CustomerId && x.SupplierId == contract.SupplierId && x.ContractId == contract.Id).AsNoTracking().Select(x => new BudgetContractEntity { ContractId = x.ContractId, BudgetId = x.BudgetId, Precent = x.BudgetPrecent, CustomerId = x.CustomerId, SupplierId = x.SupplierId }).ToArray(); return(result); }
public void SubmitContractForm(ContractEntity contractEntity, string keyValue) { if (!string.IsNullOrEmpty(keyValue)) { contractEntity.Modify(keyValue); contractRepository.Update(contractEntity); } else { contractEntity.Create(); contractRepository.Insert(contractEntity); } }
public int EmployeeCalculateDaysOff(ContractEntity contractEntity) { if (contractEntity.ContractType == (int)ContractTypes.Temporary) { var amountOfDays = contractEntity.ContractStartDate .GetNumberOfMonths((DateTime)contractEntity.ContractEndDate) * DateTimeExtensions.GetContractExpression(); return((int)amountOfDays); } return(20); }
public void UpdateContract(ContractEntity contractEntity) { try { var _contractHumanResourceNeedsList = new List <ContractHumanResourceNeeds>(); var _contractInformation = Mapper.Map <ContractInformation>(contractEntity.ContractInformation); var _contractBilling = Mapper.Map <ContractBilling>(contractEntity.ContractBilling); var _contractPaysheet = Mapper.Map <ContractPaysheet>(contractEntity.ContractPaySheet); var _contractInvoice = Mapper.Map <ContractInvoiceHeadingText>(contractEntity.ContractInvoiceHeadingText); foreach (var humanResourceNeeds in contractEntity.ContractHumanResourceNeeds) { var _humanResourceNeeds = Mapper.Map <ContractHumanResourceNeeds>(humanResourceNeeds); _contractHumanResourceNeedsList.Add(_humanResourceNeeds); } var contractId = contractEntity.ContractInformation.ContractId; _unitOfWork.ContractInformationRepository.Update(_contractInformation); if (_contractBilling != null) { _contractBilling.ContractId = contractId; _unitOfWork.ContractBillingRepository.Update(_contractBilling); } if (_contractPaysheet != null) { _contractPaysheet.ContractId = contractId; _unitOfWork.ContractPaysheetRepository.Update(_contractPaysheet); } if (_contractInvoice != null) { _contractInvoice.ContractId = contractId; _unitOfWork.ContractInvoiceHeadingTextRepository.Update(_contractInvoice); } foreach (var _humanResourceNeeds in _contractHumanResourceNeedsList) { _humanResourceNeeds.ContractId = contractId; if (_humanResourceNeeds.Id == 0) { _unitOfWork.ContractHumanResourceNeedsRepository.Insert(_humanResourceNeeds); } else { _unitOfWork.ContractHumanResourceNeedsRepository.Update(_humanResourceNeeds); } } _unitOfWork.Save(); } catch (Exception ex) { throw ex; } }
public static void AddSafely(this EditorContract contract, ContractEntity entity) { if (contract == null) { throw new ArgumentNullException(nameof(contract)); } if (entity == null) { throw new ArgumentNullException(nameof(entity)); } contract.DataModel.AddEntity(entity); //contract.DataModel.Entities.Add(entity); }
private static async Task InsertContract(CloudTable table, AnalysisMessage message, Models.Analysis analysis, string severity) { var entry = new ContractEntity() { PartitionKey = message.Address, RowKey = "", TxHash = message.TxHash, AnalysisId = analysis.UUID, AnalysisStatus = analysis.Status, Severity = severity, Version = 1 }; TableOperation insertOperation = TableOperation.InsertOrReplace(entry); await table.ExecuteAsync(insertOperation); }
private Nep5ContractInfo ToNep5ContractInfo(ContractEntity c) { return new Nep5ContractInfo() { Hash = UInt160.Parse(c.Hash), Name = c.Name, Symbol = c.Symbol, Decimals = c.Decimals, CreateTime = c.CreateTime, CreateTxId = c.CreateTxId != null ? UInt256.Parse(c.CreateTxId) : null, DeleteOrMigrateTxId = c.DeleteOrMigrateTxId != null ? UInt256.Parse(c.DeleteOrMigrateTxId) : null, DeleteTime = c.DeleteTime, MigrateTime = c.MigrateTime, }; }
private ContractEntity CreateEntityAsync(Contracts dataContract) { var newContract = new ContractEntity() { BankAccountInFinance = dataContract.BankAccountInFinance, Description = dataContract.ContractDescription, Id = dataContract.ContractId, CustomerId = dataContract.CustomerId, Address = dataContract.ContractAddress, SupplierId = dataContract.SupplierId }; newContract.BudgetContract = new BudgetContractService(context).GetRelationByContract(newContract); return(newContract); }
public async Task ContractAddContract(ApplicationContract applicationContract) { var contractEntitty = new ContractEntity() { EmployeeUID = applicationContract.EmployeeUID, ContractType = (int)applicationContract.ContractType, ContractFile = applicationContract.ContractFile, ContractNumber = applicationContract.ContractNumber, ContractFileName = applicationContract.ContractFileName, ContractCreatedOn = DateTime.UtcNow, ContractStartDate = applicationContract.ContractStartDate, ContractEndDate = applicationContract.ContractEndDate }; await ContractWorkflow.ContractAddContract(contractEntitty); }
ContractDataModel GetExampleDataModel() { var dataModel = new ContractDataModel(); var entity2 = new ContractEntity() { Id = "entity-2", Name = "Entity 2", }; var entity1 = new ContractEntity() { Id = "entity-1", Name = "Entity 1", PrimitiveProperties = new List <PrimitiveContractProperty>() { new PrimitiveContractProperty() { Id = "property-1", Name = "Property 1", IsMandatory = true, Type = PrimitiveContractPropertyType.Number }, new PrimitiveContractProperty() { Id = "property-2", Name = "Property 2", IsMandatory = false, Type = PrimitiveContractPropertyType.NumberCollection }, }, ReferenceProperties = new List <ReferenceContractProperty>() { new ReferenceContractProperty() { Id = "property-3", Name = "Property 3", IsMandatory = true, Entity = entity2 } } }; dataModel.Entities.Add(entity1); dataModel.Entities.Add(entity2); return(dataModel); }
/// <summary> /// Updates the Contract. /// </summary> /// <param name="Contract">The Contract.</param> /// <returns></returns> public ContractResponse UpdateContract(ContractEntity Contract) { var response = new ContractResponse { Acknowledge = AcknowledgeType.Success }; try { var Contracts = ContractDao.GetContractByContractNo(Contract.ContractNo); if (Contracts != null && Contract.ContractId != Contracts.ContractId) { response.Acknowledge = AcknowledgeType.Failure; response.Message = @"Số hợp đồng " + Contract.ContractNo + @" đã tồn tại!"; return(response); } response.Message = ContractDao.UpdateContract(Contract); if (!string.IsNullOrEmpty(response.Message)) { response.Acknowledge = AcknowledgeType.Failure; return(response); } response.ContractId = Contract.ContractId; foreach (var item in Contract.ContractDetails) { if (item.ContractDetailID == null) { item.ContractDetailID = Guid.NewGuid().ToString(); item.ContractID = Contract.ContractId; item.Stt = Contract.ContractDetails.IndexOf(item); ContractDao.InsertContractDetail(item); } else { ContractDao.UpdateContractDetail(item); } } return(response); } catch (Exception ex) { response.Message = ex.Message; return(response); } }
public bool Delete(ContractEntity contract) { try { context.BudgetsContracts.RemoveRange(new BudgetsContracts { ContractId = contract.Id, CustomerId = contract.CustomerId, SupplierId = contract.SupplierId }); context.Contracts.Remove(new Contracts { CustomerId = contract.CustomerId, SupplierId = contract.SupplierId, ContractId = contract.Id }); context.SaveChanges(); return(true); } catch (Exception e) { throw e; } }
public static void RemoveSafely(this EditorContract contract, ContractEntity entity) { if (contract == null) { throw new ArgumentNullException(nameof(contract)); } if (entity == null) { throw new ArgumentNullException(nameof(entity)); } //Remove all risks contract.AnalyzeIntegrityOf(entity).ResolveDeleteRisks(); //Remove this //contract.DataModel.Entities.Remove(entity); contract.DataModel.RemoveEntity(entity); }
//-------------------------------------------------- // REFERENCE PROPERTY //-------------------------------------------------- public static void AddSafely(this EditorContract contract, ContractEntity entity, ReferenceContractProperty property) { if (contract == null) { throw new ArgumentNullException(nameof(contract)); } if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (property == null) { throw new ArgumentNullException(nameof(property)); } //entity.ReferenceProperties.Add(property); entity.AddProperty(property); }
public async Task ContractAddContract(ContractEntity contractEntity) { var employee = await EmployeeRepository.EmployeeGetEmployee(contractEntity.EmployeeUID); Contract contract = new Contract() { EmployeeID = employee.EmployeeID, ContractUID = Guid.NewGuid(), ContractType = contractEntity.ContractType, ContractStartDate = contractEntity.ContractStartDate, ContractEndDate = contractEntity.ContractEndDate, ContractCreatedOn = DateTime.UtcNow, ContractFile = contractEntity.ContractFile, ContractNumber = contractEntity.ContractNumber, ContractFileName = contractEntity.ContractFileName }; await ContractRepository.ContractInsert(contract); var result = EmployeeWorkflow.EmployeeCalculateDaysOff(contractEntity); }
public bool Add(ContractEntity contract) { try { context.Contracts.Add(new Contracts { BankAccountInFinance = contract.BankAccountInFinance, ContractAddress = contract.Address, ContractDescription = contract.Description, ContractId = contract.Id, CustomerId = contract.CustomerId, SupplierId = contract.SupplierId }); double sum = 0; for (int i = 0; i < contract.BudgetContract.Length; i++) { sum += contract.BudgetContract[i].Precent; context.BudgetsContracts.Add(new BudgetsContracts { ContractId = contract.Id, CustomerId = contract.CustomerId, SupplierId = contract.SupplierId, BudgetId = contract.BudgetContract[i].BudgetId, BudgetPrecent = contract.BudgetContract[i].Precent }); } if (sum != 100) { return(false); } context.SaveChanges(); return(true); } catch (Exception e) { throw e; } }
protected void ProceedButton_Click(object sender, EventArgs e) { string strings = jsfields.Value; StringBuilder stb = new StringBuilder(); stb.Append("employeeId="); stb.Append(strings); List <string> list = strings.Split(',').ToList(); foreach (string s in list) { if (!s.StartsWith("0")) { int i = Convert.ToInt32(s); EmployeeView employeeView = new EmployeeMapper().Get(new EmployeeEntity() { Id = Convert.ToInt32(s) }); ContractEntity lastContract = new ContractMapper().GetLastContract(new ContractEntity() { EmployeeId = employeeView.Id }); #warning change the 1 value parameter of getContentById ContractTemplateEntity cte = new ContractTemplateMapper().GetContentById(Convert.ToInt32(ContractTemplateDropDownList.SelectedValue), 1); JobDetailsSessionView jsv = new JobDetailsSessionView(); CurrentJobDetailsEntity cjde = new CurrentJobDetailsMapper().Get(new CurrentJobDetailsEntity() { EmployeeId = employeeView.Id, ContractNumber = (employeeView.Id + " / " + cte.Preffix) }); jsv.FunctionalLevel.Id = cjde.FunctionalLevelId; jsv.FunctionalLevel.Title = cjde.FunctionalLevelTitle; jsv.Grade.Id = cjde.GradeId; jsv.Grade = new GradeMapper().Get(jsv.Grade); jsv.Job.Code = cjde.JobCode; jsv.Job.Title = cjde.JobTitle; jsv.OrganisationalUnit.Id = cjde.OrganizationalUnitId; jsv.OrganisationalUnit.Title = cjde.OrganizationalUnitTitle; jsv.Step.Id = cjde.StepId; #warning changed review and edit //jsv.Step.Entry = cjde.StepEntry; if (RadioButtonList1.SelectedItem.Value != "1") { AmandamentTemplateEntity amte = new AmandamentTemplateMapper().GetContentById(Convert.ToInt32(RadioButtonList1.SelectedValue), null); AmandamentEntity am = new AmandamentEntity(cjde); am.Status = StatusEnum.Active; am.Content.Content = new GUIHelper().ReplaceTemplateContractWithConcreteContract(amte.Content, jsv, employeeView); am.ContractNumber = cjde.ContractNumber; am.Content.Content = am.Content.Content.Replace(@"{#ContractNumber}", am.ContractNumber); new AmandamentMapper().Insert(am, employeeView.Id); } else { ContractEntity ct = new ContractEntity(cjde, employeeView); ct.Content.Content = new GUIHelper().ReplaceTemplateContractWithConcreteContract(cte.Content, jsv, employeeView); string dt = DateTime.Now.ToString("dd.MM.yyyy"); dt = dt.Replace(".", ""); ct.ContractNumber = (employeeView.EmployeeNo.Replace("AKP", "") + " / " + cte.Preffix + " / " + dt); ct.Status = StatusEnum.Active; ct.ContractStatus = ContractStatus.Aproved; ct.OfficiallyApprovedDate = DateTime.Now; ct.ContractTemplateTitle = cte.Preffix; ct.Content.Content = ct.Content.Content.Replace(@"{#ContractNumber}", ct.ContractNumber); new ContractMapper().Insert(ct); new ContractMapper().UpdatePreviousContract(new ContractEntity() { ContractNumber = lastContract.ContractNumber, NextContractNumber = ct.ContractNumber, ContractStatus = Entities.ContractStatus.Changed }); } } } if (RadioButtonList1.SelectedItem.Value != "1") { Response.Redirect("Print.aspx?" + stb + "&type=newAmandament"); } else { Response.Redirect("Print.aspx?" + stb + "&type=newContract"); } }