public void PutTicket(RelationModel model, TicketBase ticket) { using (model.For(out TicketBox ticketBox, () => new TicketBox())) { ticketBox.Put(ticket); } }
public JsonResult GetRelation(long onlineMulu) { RelationModel model = new RelationModel(); var relList = new OnlineMuluRelationService().GetByOnlineMuluId(onlineMulu); OnlineMuluRelation rel = null; if (relList != null && relList.Count > 0) { rel = relList.FirstOrDefault(); } if (rel != null) { model.ask120Relation = rel.Ask120Relation; model.fhRelation = rel.FHRelation; model.JJRelation = rel.JJRelation; model.JKRelation = rel.JKRelation; model.SJRelation = rel.SJRelation; } else { //model.ask120Relation = ""; //model.fhRelation = ""; //model.JJRelation = ""; //model.JKRelation = ""; //model.SJRelation = ""; } return(Json(model)); }
public IActionResult Index(string id) { Torrent result = _databaseService.GetTorrentByID(id); RelationModel ips = _databaseService.GetIPsOfTorrent(result.ID); TorrentDetailModel model = new TorrentDetailModel { ID = result.ID, Name = result.Name, Date = Utils.FormatDate(result.Date), Categories = Utils.FormatTags(result.Categories), Type = result.Type, MagnetLink = result.MagnetLink, Size = Utils.FormatBytes(result.Size), Files = result.Files.Select(file => new TorrentDetailModel.FileDetailModel { Name = file.Name, Size = Utils.FormatBytes(file.Size) }), NrFiles = result.Files.Count(), IPs = ips.IPs, PeerNumber = result.Peers }; return(View(model)); }
public async Task <IActionResult> AddRelationAsync([FromBody] RelationModel model) { Relation relation = _mapper.Map <Relation>(model); await _relationService.AddRelation(relation); return(Ok()); }
public RelationModel GetIPsByTorrent(String id) { var searchResponse = client.Get <RelationModel>(id, idx => idx.Index("relation").Type("doc")); RelationModel IPs = searchResponse.Source; return(IPs); }
public static void PutExpiry(this IAuthorizationService service, RelationModel model, string name, DateTime expiration) { var ticket = new ExpiryTicket(name, expiration); service.PutTicket(model, ticket); }
/// <summary> /// This method is used to load the <see cref="RelationModel"/> from cache if available or from the database. /// </summary> /// <param name="context">Contains the <see cref="IFrameworkContext{IDataRepository}"/> object used for accessing the Vasont data repository.</param> /// <param name="relationId">Contains the unique identity of the relation model to find and return.</param> /// <returns> /// Returns the <see cref="RelationModel" /> model. /// </returns> public static RelationModel LoadRelationModelCache(this IFrameworkContext <IDataRepository> context, long relationId) { string relationCacheKey = $"Tenant{context.Settings.TenantInfo.TenantId}_Relation{relationId}"; RelationModel model = null; // load relation model from the cache if it exists if (context.Cache.Contains(relationCacheKey)) { model = context.Cache[relationCacheKey] as RelationModel; } else { // build the relation model var entity = context.DataRepository.Relations.FirstOrDefault(r => r.RelationId == relationId); if (entity != null) { model = new RelationModel(entity); // add this to the cache... if (model != null && !context.Cache.Contains(relationCacheKey)) { context.Cache.Add(relationCacheKey, model); } } } return(model); }
/// <summary> /// 添加对象关系 /// </summary> /// <param name="relation"></param> /// <returns></returns> public int Insert(RelationModel relation) { int irtn = 0; bool Exist = true; StringBuilder strInsertSql = new StringBuilder(); string Sql = "select * from RELATION where RTID='" + relation.RTID + "' and BOID1='" + relation.BOId1 + "' and BOID2='" + relation.BOId2 + "'"; RelationModel model = DBUtility.OracleDBHelper.OracleHelper.ExecuteQueryText <RelationModel>(Sql).FirstOrDefault(); Exist = model == null ? false : true; if (!Exist) //去重处理,只添加不存在的对象关系 { strInsertSql.Append(" INSERT INTO RELATION( "); strInsertSql.Append(" RELATIONID,RTID,BOID1,BOID2) "); strInsertSql.Append(" VALUES (:RELATIONID,:RTID,:BOID1,:BOID2 )"); OracleParameter[] parameters = { new OracleParameter("RELATIONID", OracleDbType.Varchar2, 36), new OracleParameter("RTID", OracleDbType.Varchar2, 36), new OracleParameter("BOID1", OracleDbType.Varchar2, 36), new OracleParameter("BOID2", OracleDbType.Varchar2, 50) }; parameters[0].Value = System.Guid.NewGuid().ToString(); parameters[1].Value = relation.RTID; parameters[2].Value = relation.BOId1; parameters[3].Value = relation.BOId2; irtn = DBUtility.OracleDBHelper.OracleHelper.ExecuteSql(strInsertSql.ToString(), parameters); } return(irtn); }
public ActionResult EditRelation(long relationTypeId, long relationId, long entityId, FormCollection formCollection) { RelationModel relationModel = RemoteFacade.Instance.GetModel <RelationModel> (db); Relation relation = relationModel.GetRelation(relationId); if (relation == null) { RedirectToAction("Index"); } TryUpdateModel(relation, "Relation"); if (ModelState.IsValid) { relationModel.SaveRelation(relation); return(RedirectToAction("Relations", new { RelationTypeId = relationTypeId, EntityId = entityId })); } return(View(EditRelationView, new RelationEditViewModel() { RelationTypeId = relationTypeId, Relation = relation, EntityId = entityId })); }
public bool SendRequest(RelationModel model) { try { var userId = model.InvitingUser.Id; var userRelations = _relationRepository.GetRelationsByUserId(userId); var relationExists = userRelations.Any(x => x.InvitingUser.Id == userId && x.InvitedUser.Id == model.InvitedUser.Id || x.InvitedUser.Id == userId && x.InvitingUser.Id == model.InvitedUser.Id); var selfInvitation = model.InvitingUser.Id == model.InvitedUser.Id; if (relationExists || selfInvitation) { return false; } var relation = Mapper.Map<Relation>(model); relation.RelationStatus = RelationStatus.Pending; _relationRepository.Add(relation); _unitOfWork.Save(); return true; } catch (Exception) { return false; } }
public ActionResult PerformCreateAndAddRelation(long relationTypeId, long entityId, FormCollection formCollection) { TEntity entity = Model.GetEntity(entityId); if (entity == null || !entity.IsEditable) { return(RedirectToAction("Index")); } // TODO better check of relationTypeId validity. RelationModel relationModel = RemoteFacade.Instance.GetModel <RelationModel> (db); TypedRelations relations = relationModel.GetRelations(relationTypeId, entity); if (relations == null) { return(RedirectToAction("Index")); } Entity newEntity = relationModel.GetNewObjectiveEntity(relations.RelationType, String.Empty); TryUpdateModel(relations.RelationType.ObjectiveEntityType, newEntity, "NewEntity"); if (ModelState.IsValid) { newEntity = RemoteFacade.Instance.GetEntityModel(newEntity.GetType(), db).AddNewEntity(newEntity); relationModel.AddRelation(relationTypeId, entity, newEntity.Id); return(RedirectToAction("Relations", new { RelationTypeId = relationTypeId, EntityId = entityId })); } return(View(CreateAndAddRelationView, new CreateAndAddRelationViewModel() { Entity = entity, RelationTypeId = relationTypeId, NewEntity = (Entity)newEntity })); }
public ActionResult CreateAndAddRelation(long relationTypeId, long entityId, string relatedEntityId) { TEntity entity = Model.GetEntity(entityId); if (entity == null || !entity.IsEditable) { return(RedirectToAction("Index")); } // TODO better check of relationTypeId validity. RelationModel relationModel = RemoteFacade.Instance.GetModel <RelationModel> (db); TypedRelations relations = relationModel.GetRelations(relationTypeId, entity); if (relations == null) { return(RedirectToAction("Index")); } return(View(CreateAndAddRelationView, new CreateAndAddRelationViewModel() { Entity = entity, RelationTypeId = relationTypeId, NewEntity = relationModel.GetNewObjectiveEntity(relations.RelationType, relatedEntityId) })); }
/// <summary> /// 更新当前上报节点 /// </summary> /// <param name="relation"></param> /// <returns></returns> public static bool UpdateCurrentUploadNodeId(RelationModel relation, bool isArrived, List <string> senderCodeList) { bool result = false; string sql = string.Empty; if (!isArrived) { sql = string.Format("update huadong_tmsorder_waybillbase set currentUploadNodeId = '{0}' where id='{1}';", relation.CurrentUploadNodeId, relation.Id); } else { string innerInto = "select min(handleTHCount)-1 as c from huadong_tmsorder_waybillbase where (currentUploadDataNodeId<>0 or currentUploadDataNodeId is null) and relationId in (select relationId from huadong_tms_order where 【where】 and relationId is not null)"; string where = "SecretKey ='" + Utility._SecretKey + "'"; if (senderCodeList != null)//如果不为空,则表示查询运管平台同步过来的订单 { where = string.Format("SecretKey in ('{0}')", string.Join("','", senderCodeList)); } innerInto = innerInto.Replace("【where】", where); sql = string.Format("update huadong_tmsorder_waybillbase a INNER JOIN ({0}) b set a.currentUploadNodeId=0, a.handleTHCount=b.c where a.id = '{1}';", innerInto, relation.Id); } try { result = DbHelperMySQL.ExecuteSql(sql) > 0; UpdateHandleTime(relation.Id, result); } catch (Exception ex) { throw new Exception("更新当前上报节点出错:" + ex.Message); } return(result); }
public IActionResult EntityManagerRelation(string id) { ViewBag.Id = id; namespaceId = id; DataSet ds = DataServices.DataSetFromSQL("SELECT * FROM entitysettings.synapsenamespace WHERE synapsenamespaceid <> 'e8b78b52-641d-46eb-bb8b-16e2feb86fe7' ORDER BY synapsenamespacename"); ViewBag.SynapseNamespaceList = ToSelectList(ds.Tables[0], "SynapseNamespaceId", "SynapseNamespaceName"); ViewBag.EntityList = new SelectList(new List <SelectListItem> { }); DataSet dsAttribute = DataServices.DataSetFromSQL("SELECT entityid, attributeid, attributename FROM entitysettings.entityattribute WHERE entityid='" + id + "' AND coalesce(isrelationattribute,0) = 0 ORDER BY attributename;"); ViewBag.AttributeList = ToSelectList(dsAttribute.Tables[0], "AttributeId", "AttributeName"); ViewBag.Summary = SynapseHelpers.GetEntityNameAndNamespaceFromID(id); string sql = "SELECT * FROM entitysettings.v_relationsattributes WHERE entityid = @entityid ORDER BY entityname;"; var paramList = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("entityid", id) }; DataSet dsRelation = DataServices.DataSetFromSQL(sql, paramList); RelationModel relationModel = new RelationModel(); List <RelationDto> relationDto = dsRelation.Tables[0].ToList <RelationDto>(); relationModel.RelationDto = relationDto; return(View(relationModel)); }
public RelationModelJson(RelationModel rm) : base(rm) { Role = rm.Role; Type = rm.Type; LeftEntity = rm.Left.Name; RightEntity = rm.Right.Name; }
public T Retrieve <T>(RelationModel fromWhom) { var typeName = typeof(T).FullName; var ins = (T)_repository.Query <Attachment>() .Where(x => x.Target == fromWhom.Identifier && x.TypeName == typeName).FirstOrDefault()?.Object; return(ins); }
public ForAttachmentUpdateScope <T> For <T>(RelationModel model, out T ins, Func <T> generator = null) { T t = Retrieve <T>(model) ?? (generator ?? new Func <T>(() => default(T)))(); ForAttachmentUpdateScope <T> scope = new ForAttachmentUpdateScope <T>(this, t, model); ins = t; return(scope); }
/// <summary> /// 更新订单温湿度上报进度 /// </summary> /// <param name="relation">包含运单信息以及运单温湿度数据上报的进度</param> /// <returns></returns> public static bool UpdataUploadDataNode(RelationModel relation)//, ref List<long> _ignoreTempRelationList) { bool isArrived = false; //试图获取当前运单的下一个节点 NodeInfo nodeInfo = NodeUploadServer.GetNextUploadNodeInfo(relation.CurrentUploadDataNodeId, relation.Number); //如果存在下一个节点并且当前上报进度等于下一个节点的创建时间,则更新上报进度的节点 if (nodeInfo != null && DateTime.Parse(relation.CurrentUploadDataTime) >= DateTime.Parse(nodeInfo.OperateAt)) { relation.CurrentUploadDataNodeId = nodeInfo.Id; } //查询当前节点是否已经运抵 if (relation.CurrentUploadDataNodeId != -1) { string sql = "select arrived from waybill_node where id = " + relation.CurrentUploadDataNodeId; object arrived = DbHelperMySQL.GetSingle(sql); if (arrived == null) { throw new Exception("获取节点信息失败"); } isArrived = (arrived.ToString() == "2" && (relation.CurrentUploadNodeId == 0)); } //if (isArrived) // _ignoreTempRelationList.Remove(relation.Id); return(UpdateCurrentRelationUploadDataNode(relation, isArrived)); //} //else { //return UpdateCurrentRelationUploadDataNode(relation, false); //} //查询当前节点冷藏载体的下一条温湿度数据,如果大于下一个节点的时间,则进入下一个节点 //string sql = "select StorageId from waybill_Node where id = " + relation.CurrentUploadDataNodeId; //object storageId = DbHelperMySQL.GetSingle(sql); //if (storageId == null) // throw new Exception(string.Format("获取下一节点失败:R【{0}】 O【{1}】 N【{2}】", relation.RelationId, relation.Number, relation.CurrentUploadDataNodeId)); //sql = string.Format("select dataTime from history_data_{0} where dataTime > '{1}' limit 1", storageId, relation.CurrentUploadDataTime); //object dataTime = DbHelperMySQL.GetSingle(sql); //if (dataTime != null && Convert.ToDateTime(dataTime) > DateTime.Parse(relation.CurrentUploadDataTime)) //{ // if (nodeInfo != null) // relation.CurrentUploadDataNodeId = nodeInfo.Id; // else // { // //查询当前节点是否已经运抵 // sql = "select arrived from waybill_node where id = " + relation.CurrentUploadDataNodeId; // object arrived = DbHelperMySQL.GetSingle(sql); // if (arrived == null) // throw new Exception("获取节点信息失败"); // isArrived = arrived.ToString() == "2"; // if (isArrived) // _ignoreTempRelationList.Remove(relation.Id); // } //} //else // _ignoreTempRelationList.Add(relation.Id); //return UpdateCurrentRelationUploadDataNode(relation, isArrived); }
public void Detach <T>(RelationModel toWhom) { string typeName = typeof(T).FullName; Attachment first = _repository.Query <Attachment>().Where(x => x.Target == toWhom.Identifier && x.TypeName == typeName).FirstOrDefault(); if (first != null) { _repository.Delete <Attachment>(first.Id); } }
public IEnumerable <TicketBase> GetTickets(RelationModel model) { TicketBox ticketBox = model.Retrieve <TicketBox>(); if (ticketBox != null) { return(ticketBox.GetTickets()); } return(Enumerable.Empty <TicketBase>()); }
public void RemoveTicket(RelationModel model, string name) { using (model.For(out TicketBox ticketBox)) { if (ticketBox != null) { ticketBox.Remove(name); } } }
public T Retrieve <T>(RelationModel fromWhom) { Stopwatch watch = new Stopwatch(); watch.Start(); string typeName = typeof(T).FullName; T ins = (T)_repository.Query <Attachment>().Where(x => x.Target == fromWhom.Identifier && x.TypeName == typeName).FirstOrDefault()?.Object; watch.Stop(); _logger.LogDebug("Data query and deserilization took {} milliseconds for {}@{}", watch.ElapsedMilliseconds, typeof(T).Name, fromWhom.Identity); return(ins); }
public void CreateTable(RelationModel relation) { var a = SQL.CreateTable.CreateTb(relation.TbName); foreach (var c in relation.Columns) { a.AddColumn(c.ColumnName, c.TypeName, c.Size, c.ConstraintsStr); } SqlScript sql = a.ToSql(); DbServerProvider.ExcuteNonQuery(CommandType.Text, sql.ToString()); }
public bool Set([FromBody] RelationModel model) { var relation = new Relation() { AccountId = model.aid, EntityId = model.eid, Type = model.type }; var r = provider.AddRelation2(relation); return(true); }
/// <summary> /// 删除对象关系 /// </summary> /// <param name="relation"></param> /// <returns></returns> public int Delete(RelationModel relation) { StringBuilder strSql = new StringBuilder(); strSql.Append(" DELETE FROM RELATION "); strSql.Append(" WHERE RELATIONID=@RELATIONID "); SqlParameter[] parameters = { new SqlParameter("@RELATIONID", SqlDbType.VarChar, 36) }; parameters[0].Value = relation.RelationID; return(DBUtility.SqlServerDBHelper.ExecuteSql(strSql.ToString(), parameters)); }
/// <summary> /// 获取附加在 <see cref="RelationModel" /> 上的 <typeparamref name="T" /> 对象 /// </summary> /// <typeparam name="T">类型</typeparam> /// <param name="model">目标关系模型</param> /// <param name="generator">当对象不存在时返回该生成器创建的对象(不会附加</param> /// <returns></returns> public static T Retrieve <T>(this RelationModel model, Func <T> generator = null) { generator ??= () => default; var t = service.Retrieve <T>(model); if (t != null) { return(t); } t = generator(); if (t == null) { return(default);
/// <summary> /// 删除对象关系 /// </summary> /// <param name="relation"></param> /// <returns></returns> public int Delete(RelationModel relation) { StringBuilder strSql = new StringBuilder(); strSql.Append(" DELETE FROM RELATION "); strSql.Append(" WHERE RELATIONID=:RELATIONID "); OracleParameter[] parameters = { new OracleParameter("RELATIONID", OracleDbType.Varchar2, 36) }; parameters[0].Value = relation.RelationID; return(DBUtility.OracleDBHelper.OracleHelper.ExecuteSql(strSql.ToString(), parameters)); }
public bool SetMulti([FromBody] RelationModel model) { foreach (string item in model.aids) { var relation = new Relation() { AccountId = item, EntityId = model.eid, Type = model.type }; provider.AddRelation(relation); } return(true); }
public void TestRelationModelCreateTable() { var entity = new RelationModel { ParentNodeID = "ParentNodeID", ChildNodeID = "ChildNodeID", Type = 1, CreateDateTime = DateTime.Now, Id = Guid.NewGuid().ToString(), LastUpdateDateTime = DateTime.Now }; RelationModel result; using (var session = sessions.OpenSession()) { session.Save(entity); session.Flush(); result = session.Get <RelationModel>(entity.Id); } Assert.AreEqual(entity.ParentNodeID, result.ParentNodeID); }
public void TestRelationModelQueryAll() { var insertEntity = new RelationModel { ParentNodeID = "ParentNodeID", ChildNodeID = "ChildNodeID", Type = 1, CreateDateTime = DateTime.Now, Id = Guid.NewGuid().ToString(), LastUpdateDateTime = DateTime.Now }; using (var session = sessions.OpenSession()) { session.Save(insertEntity); session.Flush(); ICriteria crit = session.CreateCriteria(typeof(RelationModel)); var entityList = crit.List(); var resultList = session.CreateQuery("from RelationModel ").List <RelationModel>(); Assert.AreEqual(entityList.Count, resultList.Count); } }
private void CollateralForm_Load(object sender, EventArgs e) { #region Initialize Services #region OrdersService AltasoftAPI.OrdersAPI.OrdersService o = new AltasoftAPI.OrdersAPI.OrdersService(); o.RequestHeadersValue = new AltasoftAPI.OrdersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() }; #endregion #region CustomersService AltasoftAPI.CustomersAPI.CustomersService c = new AltasoftAPI.CustomersAPI.CustomersService(); c.RequestHeadersValue = new AltasoftAPI.CustomersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() }; #endregion #region AccountsService AltasoftAPI.AccountsAPI.AccountsService a = new AltasoftAPI.AccountsAPI.AccountsService(); a.RequestHeadersValue = new AltasoftAPI.AccountsAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() }; #endregion #region LoansService AltasoftAPI.LoansAPI.LoansService l = new AltasoftAPI.LoansAPI.LoansService(); l.RequestHeadersValue = new AltasoftAPI.LoansAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() }; #endregion #endregion var collateral = l.ListCollaterals(new AltasoftAPI.LoansAPI.ListCollateralsQuery() { ControlFlags = AltasoftAPI.LoansAPI.CollateralControlFlags.Basic | AltasoftAPI.LoansAPI.CollateralControlFlags.Attributes, Id = collateralID, IdSpecified = true }); var linked = l.ListLinkedCollaterals(new AltasoftAPI.LoansAPI.ListLinkedCollateralsQuery() { CollateralId = collateralID, CollateralIdSpecified = true, ControlFlags = AltasoftAPI.LoansAPI.LinkedCollateralControlFlags.Basic | AltasoftAPI.LoansAPI.LinkedCollateralControlFlags.Attributes, ApplicationIdSpecified = true }); tbxType.Text = collateral[0].CollateralType; var customer = c.GetCustomer(AltasoftAPI.CustomersAPI.CustomerControlFlags.Basic | AltasoftAPI.CustomersAPI.CustomerControlFlags.Addresses | AltasoftAPI.CustomersAPI.CustomerControlFlags.Extensions, true, collateral[0].OwnerId.Value, true); tbxOwner.Text = collateral[0].OwnerId.Value.ToString() + " | " + customer.Name.ValueGeo; tbxIdNumber.Text = (customer.Entity as AltasoftAPI.CustomersAPI.IndividualEntity).PIN; tbxBranch.Text = customer.BranchId.Value.ToString(); tbxAgreement.Text = collateral[0].AgreementNo; tbxAddressLegal.Text = customer.AddressLegal.Value.ValueGeo; tbxMobile.Text = customer.ContactInfo.MobilePhone; tbxPhone.Text = customer.ContactInfo.Phone; var relations = new List<RelationModel>(); foreach (var item in linked) { bool? n; bool n2; AltasoftAPI.LoansAPI.Application app; l.GetApplication(AltasoftAPI.LoansAPI.ApplicationControlFlags.Basic | AltasoftAPI.LoansAPI.ApplicationControlFlags.Extended | AltasoftAPI.LoansAPI.ApplicationControlFlags.ExtraFields | AltasoftAPI.LoansAPI.ApplicationControlFlags.Extensions, true, item.ApplicationId.Value, true, out n, out n2, out app); var loan = l.GetLoan(AltasoftAPI.LoansAPI.LoanControlFlags.Basic, true, app.Id.Value, true); var customer2 = c.GetCustomer(AltasoftAPI.CustomersAPI.CustomerControlFlags.Basic, true, loan.BorrowerId.Value, true); var r = new RelationModel() { AgreementNo = loan.AgreementNo, Amount = item.LinkAmount.Amount, Borrower = customer2.Name.ValueGeo, Currency = item.LinkAmount.Ccy, EndDate = loan.Term.End, StartDate = loan.Term.Start, LoanAmount = loan.Amount.Amount, LoanCurrency = loan.Amount.Ccy, LoanInterest = loan.InterestBasis.ToString() + "%", Product = l.GetLoanProduct(loan.ProductId.Value, true).Name, RelationDate = item.LinkDate.Value, Status = item.State == AltasoftAPI.LoansAPI.CollateralLinkState.Closed ? RelationStatus.დახურული : RelationStatus.მიმდინარე, }; relations.Add(r); } gridRelations.DataSource = relations; }