private void TracksCvs_Filter(object sender, FilterEventArgs e) { KeyValuePair <string, TrackViewModel> vm = (KeyValuePair <string, TrackViewModel>)e.Item; e.Accepted = EntityUtils.FilterTracks(vm.Value, this.searchService.SearchText); }
protected virtual async Task GetTracksCommonAsync(IList <TrackViewModel> tracks, TrackOrder trackOrder) { try { // Do we need to show the TrackNumber? bool showTracknumber = this.TrackOrder == TrackOrder.ByAlbum; await Task.Run(() => { foreach (TrackViewModel vm in tracks) { vm.ShowTrackNumber = showTracknumber; } }); // Order the Tracks List <TrackViewModel> orderedTrackViewModels = await EntityUtils.OrderTracksAsync(tracks, trackOrder); // Unbind to improve UI performance Application.Current.Dispatcher.Invoke(() => { if (this.TracksCvs != null) { this.TracksCvs.Filter -= new FilterEventHandler(TracksCvs_Filter); } this.TracksCvs = null; }); this.Tracks = null; // Populate ObservableCollection this.Tracks = new ObservableCollection <TrackViewModel>(orderedTrackViewModels); } catch (Exception ex) { LogClient.Error("An error occurred while getting Tracks. Exception: {0}", ex.Message); // Failed getting Tracks. Create empty ObservableCollection. this.Tracks = new ObservableCollection <TrackViewModel>(); } Application.Current.Dispatcher.Invoke(() => { // Populate CollectionViewSource this.TracksCvs = new CollectionViewSource { Source = this.Tracks }; this.TracksCvs.Filter += new FilterEventHandler(TracksCvs_Filter); // Update count this.TracksCount = this.TracksCvs.View.Cast <TrackViewModel>().Count(); // Group by Album if needed if (this.TrackOrder == TrackOrder.ByAlbum) { this.TracksCvs.GroupDescriptions.Add(new PropertyGroupDescription("GroupHeader")); } }); // Update duration and size this.CalculateSizeInformationAsync(this.TracksCvs); // Show playing Track this.ShowPlayingTrackAsync(); }
public void Run_Before_Every_Test() { SystemUnderTest = GetEntityUtils(new PostgreSQLTypeLookup(), Assembly.GetExecutingAssembly()); }
private string GetFederatedOrConsolidatedIdColName(DataStoreConfiguration c, Entity e, string idColName) { return(c.Consolidation.Get(e).None ? EntityUtils.GetFederatedFieldName(idColName) : EntityUtils.GetConsolidatedFieldName(idColName)); }
public override Vec3 Steer() { Entity self = this._behaviors.owner; float detectRadius = MIN_DETECTION_BOX_LENGTH * (1 + self.property.speed / self.maxSpeed); EntityUtils.GetEntitiesInCircle(self.battle.GetEntities(), self.property.position, detectRadius, ref this._temp); this.DebugDrawDetectRadius(detectRadius); Bio closestIntersectingObstacle = null; float distToClosestIp = float.MaxValue; Vec3 localPosOfClosestObstacle = Vec3.zero; int count = this._temp.Count; for (int i = 0; i < count; i++) { Bio bio = this._temp[i] as Bio; if (bio == null || bio == self || bio.isDead || !bio.volumetric || bio.property.dashing > 0 || bio.property.ignoreVolumetric > 0) { continue; } Vec3 localPos = self.PointToLocal(bio.property.position); if (localPos.x >= 0) { float expandedRadius = bio.size.z + self.size.z; if (MathUtils.Abs(localPos.z) < expandedRadius) { float cX = localPos.x; float cZ = localPos.z; float sqrtPart = MathUtils.Sqrt(expandedRadius * expandedRadius - cZ * cZ); float ip = cX - sqrtPart; if (ip <= 0.0f) { ip = cX + sqrtPart; } if (ip < distToClosestIp) { distToClosestIp = ip; closestIntersectingObstacle = bio; localPosOfClosestObstacle = localPos; } } } } this._temp.Clear(); if (closestIntersectingObstacle != null) { Vec3 steeringForce = Vec3.zero; const float minLocalXDistance = .3f; //限定最小的x轴距离,值越小,下面得到的x轴因子越大,侧向力就越大 float multiplier = 1.5f / MathUtils.Min(minLocalXDistance, localPosOfClosestObstacle.x); //侧向力和障碍物的x距离成反比,越近x轴的因子越大,侧向力越大 steeringForce.z = -closestIntersectingObstacle.size.z * multiplier / localPosOfClosestObstacle.z; //侧向力和障碍物的半径成正比,z轴距离成反比 const float brakingWeight = .2f; //制动力因子,值越大,速度减少越快 steeringForce.x = (closestIntersectingObstacle.size.x - localPosOfClosestObstacle.x) * brakingWeight; steeringForce = self.VectorToWorld(steeringForce); this.DebugDrawForce(steeringForce * 3); return(steeringForce); } return(Vec3.zero); }
public override void Visit(DbConstantExpression expression) { EntityUtils.CheckArgumentNull <DbConstantExpression>(expression, nameof(expression)); }
protected override void OnInit(EventArgs e) { try { base.OnInit(e); object connectionManager = SessionManager.GetSessionValueNoRedirect(ParentPage, SessionStrings.CONNECTION_MANAGER); this.Entity.SetSqlConnection(connectionManager); _EditMode = (SessionManager.GetSessionValueNoRedirect(ParentPage, SessionStrings.EDIT_PARAMETERS) != null); if (!_EditMode) { Entity.Id = ApplicationConstants.INT_NULL_VALUE; } else { Dictionary <string, object> editParameters = (Dictionary <string, object>)SessionManager.GetSessionValueNoRedirect((IndPopUpBasePage)this.Page, SessionStrings.EDIT_PARAMETERS); Entity.FillEditParameters(editParameters); } if (SessionManager.GetSessionValueNoRedirect(ParentPage, SessionStrings.ENTITY_MAPPING) == null) { SessionManager.SetSessionValue(ParentPage, SessionStrings.ENTITY_MAPPING, EntityUtils.CreateCatalogueMapping()); } //Get the properties of the entity entityProperties = GetEntityProperties(); //first create the layout CreateControlLayout(); //add custom validators LayoutAddCustomValidators(); //create the dictionary to be used in update operation if (IsPostBack) { CreateControlDictionaryForUpdate(); } //fill embedded entity from database FillEntityDataFromDB(); //populate controls with data from database only if page is not posted back if (!IsPostBack) { PopulateControlsFromEntity(); } } catch (IndException exc) { ShouldContinue = false; _ParentGenericUserControl.ReportControlError(exc); return; } catch (Exception ex) { ShouldContinue = false; _ParentGenericUserControl.ReportControlError(new IndException(ex)); return; } }
public override void Visit(DbFunctionExpression expression) { EntityUtils.CheckArgumentNull <DbFunctionExpression>(expression, nameof(expression)); this.VisitExpressionList(expression.Arguments); }
public override void Visit(DbLimitExpression expression) { EntityUtils.CheckArgumentNull <DbLimitExpression>(expression, nameof(expression)); this.VisitExpression(expression.Argument); this.VisitExpression(expression.Limit); }
public override string ToString() { return(unit ? EntityUtils.GetDisplayName(unit.Type) : position.ToString()); }
public override void Visit(DbParameterReferenceExpression expression) { EntityUtils.CheckArgumentNull <DbParameterReferenceExpression>(expression, nameof(expression)); }
private void SelectTargets(Bio mainTarget, bool detectInOut, ref List <Bio> result) { if (detectInOut) { this._tempOldTargets.AddRange(result); result.Clear(); } switch (this._buff.rangeType) { case RangeType.Single: //检查指定的目标是否符合条件 //在隐身等状态下也能选中,因此不能使用CanAttack方法 if (!mainTarget.isDead && EntityUtils.CheckCampType(this._buff.caster, this._buff.campType, mainTarget) && EntityUtils.CheckTargetFlag(this._buff.targetFlag, mainTarget)) { result.Add(mainTarget); } break; case RangeType.Circle: { bool targetAdded = false; if (mainTarget != null && EntityUtils.CanAttack(this._buff.caster, mainTarget, this._buff.campType, this._buff.targetFlag)) { targetAdded = true; result.Add(mainTarget); //如果指定的目标符合条件则优先添加到目标列表 } int maxTargetNum = mainTarget != null ? this._buff.maxTriggerTargets - 1 : this._buff.maxTriggerTargets; if (maxTargetNum > 0) { EntityUtils.GetEntitiesInCircle(this._buff.battle.GetEntities(), this._buff.property.position, this._buff.radius, ref this._temp1); if (targetAdded) { this._temp1.Remove(mainTarget); //之前已经添加目标了 } EntityUtils.FilterTarget(this._buff.caster, this._buff.campType, this._buff.targetFlag, ref this._temp1, ref this._temp2); this._temp1.Clear(); EntityUtils.FilterLimit(ref this._temp2, ref this._temp1, maxTargetNum); int count = this._temp1.Count; for (int i = 0; i < count; i++) { result.Add(( Bio )this._temp1[i]); } this._temp1.Clear(); this._temp2.Clear(); } } break; case RangeType.Sector: //todo break; } if (detectInOut) { int tc = result.Count; for (int i = 0; i < tc; i++) { Bio mTarget = result[i]; if (!this._tempOldTargets.Contains(mTarget)) { this._tempEnter.Add(mTarget); } } tc = this._tempOldTargets.Count; for (int i = 0; i < tc; i++) { Bio mTarget = this._tempOldTargets[i]; if (!result.Contains(mTarget)) { this._tempExit.Add(mTarget); } } this.HandleTargetInOut(this._tempEnter, this._tempExit); this._tempEnter.Clear(); this._tempExit.Clear(); this._tempOldTargets.Clear(); } }
public OrganizationRepository(PostgreSQLTypeLookup typeLookup, PostgreSQLConstants <Organization> sqlConstants, EntityUtils entityUtils, ExpressionUtils expressionUtils, PostgreSQLExecutor sqlExecutor, List <string> updateableFields) : base(typeLookup, sqlConstants, entityUtils, expressionUtils, sqlExecutor, updateableFields) { }
public LanguageRepository(PostgreSQLTypeLookup typeLookup, PostgreSQLConstants <Language> sqlConstants, EntityUtils entityUtils, ExpressionUtils expressionUtils, PostgreSQLExecutor sqlExecutor) : base(typeLookup, sqlConstants, entityUtils, expressionUtils, sqlExecutor, GetUpdateableFieldsList()) { }
public virtual void VisitAggregate(DbAggregate aggregate) { this.VisitExpressionList(EntityUtils.CheckArgumentNull <DbAggregate>(aggregate, nameof(aggregate)).Arguments); }
protected virtual void VisitUnaryExpression(DbUnaryExpression expression) { this.VisitExpression(EntityUtils.CheckArgumentNull <DbUnaryExpression>(expression, nameof(expression)).Argument); }
public override void Visit(DbExpression expression) { EntityUtils.CheckArgumentNull <DbExpression>(expression, nameof(expression)); throw new NotSupportedException(EFProviderSettings.Instance.GetErrorMessage(-1703, "Oracle Data Provider for .NET", expression.GetType().FullName)); }
public override void Visit(DbArithmeticExpression expression) { this.VisitExpressionList(EntityUtils.CheckArgumentNull <DbArithmeticExpression>(expression, nameof(expression)).Arguments); }
public PostgreSQLRepository(PostgreSQLTypeLookup typeLookup, PostgreSQLConstants <T> sqlConstants, EntityUtils entityUtils, ExpressionUtils expressionUtils, PostgreSQLExecutor sqlExecutor, List <string> updateableFields) : base(typeLookup, sqlConstants, entityUtils, expressionUtils, sqlExecutor, updateableFields) { var sb = new StringBuilder(); for (var i = 0; i < Fields.Length; i++) { var field = Fields[i]; sb.Append($"{PostgreSQLConstants.PARAMETER_PRESIGN}{SQLConstants.PARAMETER_PREFIX}{field.Name.GetDelimitedName()},"); } var lastComma = sb.ToString().LastIndexOf(','); sb.Remove(lastComma, 1); QueryInsert = $"{SQLConstants.SELECT} * {SQLConstants.FROM} {_sqlConstants.ProcedureNameInsert} (:{SQLConstants.UPDATED_BY_PARAMETER_NAME},:{SQLConstants.UID_PARAMETER_NAME},:{SQLConstants.NAME_PARAMETER_NAME},{sb});"; QueryUpdate = $"{PostgreSQLConstants.CALL} {_sqlConstants.ProcedureNameUpdate} (:{SQLConstants.UPDATED_BY_PARAMETER_NAME},:{_sqlConstants.IdParameterName},:{SQLConstants.NAME_PARAMETER_NAME},{sb});"; QueryDelete = $"{PostgreSQLConstants.CALL} {_sqlConstants.ProcedureNameDelete} (:{SQLConstants.UPDATED_BY_PARAMETER_NAME},:{_sqlConstants.IdParameterName});"; QueryUndoDelete = $"{PostgreSQLConstants.CALL} {_sqlConstants.ProcedureNameUndoDelete} (:{SQLConstants.UPDATED_BY_PARAMETER_NAME},:{_sqlConstants.IdParameterName});"; QueryHardDelete = $"{PostgreSQLConstants.CALL} {_sqlConstants.ProcedureNameHardDelete} (:{SQLConstants.UPDATED_BY_PARAMETER_NAME},:{_sqlConstants.IdParameterName});"; QuerySelectById = $"{SQLConstants.SELECT} * {SQLConstants.FROM} {_sqlConstants.ProcedureNameSelectById} (:{_sqlConstants.IdParameterName});"; QuerySelectRevisions = $"{SQLConstants.SELECT} * {SQLConstants.FROM} {_sqlConstants.ProcedureNameSelectRevisions} (:{_sqlConstants.IdParameterName});"; QueryRestoreRevision = $"{PostgreSQLConstants.CALL} {_sqlConstants.ProcedureNameRestoreRevision} (:{SQLConstants.UPDATED_BY_PARAMETER_NAME},:{_sqlConstants.IdParameterName},:{SQLConstants.REVISION_PARAMETER_NAME}, null);"; }
protected virtual void VisitBinaryExpression(DbBinaryExpression expression) { EntityUtils.CheckArgumentNull <DbBinaryExpression>(expression, nameof(expression)); this.VisitExpression(expression.Left); this.VisitExpression(expression.Right); }
public void AddFederatedIdMapping(string publicColName) { var m = new ColumnMappingStandard(publicColName, EntityUtils.GetFederatedFieldName(publicColName)); _mappings.Add(m); }
public override void Visit(DbRelationshipNavigationExpression expression) { this.VisitExpression(EntityUtils.CheckArgumentNull <DbRelationshipNavigationExpression>(expression, nameof(expression)).NavigationSource); }
// Set name to be displayed as the title of the EntityStats panel public void SetDisplayEntity(EntityType type) { nameText.text = EntityUtils.GetDisplayName(type); nameTooltip.SetText(EntityUtils.GetDisplayDesc(type)); }
protected virtual void VisitGroupExpressionBindingPre(DbGroupExpressionBinding binding) { EntityUtils.CheckArgumentNull <DbGroupExpressionBinding>(binding, nameof(binding)); this.VisitExpression(binding.Expression); }
protected void TracksCvs_Filter(object sender, FilterEventArgs e) { TrackViewModel track = e.Item as TrackViewModel; e.Accepted = EntityUtils.FilterTracks(track, this.searchService.SearchText); }
protected virtual void VisitLambdaFunctionPre(EdmFunction function, DbExpression body) { EntityUtils.CheckArgumentNull <EdmFunction>(function, nameof(function)); EntityUtils.CheckArgumentNull <DbExpression>(body, nameof(body)); }
private void VerifyAccountWorker(LB_VerifyAccount msg, PBChannel channel) { try { int tag = CreateTag(); string signParam = string.Format("{0}{1}{2}{3}{4}{5}", msg.OpCode, msg.Data, m_AppKey, m_AppSecret, tag, msg.ChannelId); string sign = CreateSign(signParam); HttpClient client = new HttpClient(); client.Timeout = m_HttpRequestTimeout; HttpPost postMethod = new HttpPost(new Uri(m_TestBillingServerUrl)); postMethod.Headers.Add("appkey", m_AppKey); postMethod.Headers.Add("sign", sign); postMethod.Headers.Add("tag", tag.ToString()); postMethod.Headers.Add("opcode", msg.OpCode.ToString()); postMethod.Headers.Add("channelId", msg.ChannelId.ToString()); List <NameValuePair> nameValuePairList = new List <NameValuePair>(); nameValuePairList.Add(new NameValuePair("data", msg.Data)); UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, Encoding.UTF8); postMethod.Entity = formEntity; LogSys.Log(LOG_TYPE.INFO, "Account:{0}, HttpPost headers. appkey:{1}, sign:{2}, tag:{3}, opcode:{4}, channelId:{5}", msg.Account, m_AppKey, sign, tag, msg.OpCode, msg.ChannelId); LogSys.Log(LOG_TYPE.INFO, "Account:{0}, HttpPost parameters. data:{1}", msg.Account, msg.Data); //============================================ HttpResponse response = client.Execute(postMethod); string responseStr = EntityUtils.ToString(response.Entity); DestroyTag(tag); //================================================== LogSys.Log(LOG_TYPE.INFO, "Account:{0}, Response:{1}", msg.Account, responseStr); //================================================== JsonVerifyAccountResult result = JsonConvert.DeserializeObject(responseStr, typeof(JsonVerifyAccountResult)) as JsonVerifyAccountResult; var reply = BL_VerifyAccountResult.CreateBuilder(); reply.Account = msg.Account; reply.OpCode = result.opcode; reply.ChannelId = result.channelId; reply.AccountId = ""; reply.Result = false; int repState = result.state; if (repState == (int)BillingRepState.Success && result.data != null) { int status = int.Parse(result.data.status); if (status == 1 && result.channelId == msg.ChannelId && result.opcode == msg.OpCode) { reply.AccountId = result.data.userid; reply.Result = true; } } if (reply.Result == true) { LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Green, "Account verify success. Account:{0} ID:{1}", reply.Account, reply.AccountId); } else { LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Yellow, "Account verify failed. Account:{0} Msg:{1}", reply.Account, result.error); } channel.Send(reply.Build()); } catch (Exception ex) { LogSys.Log(LOG_TYPE.ERROR, ConsoleColor.Red, "Exception Type:{0}", ex.GetType().ToString()); LogSys.Log(LOG_TYPE.ERROR, ConsoleColor.Red, "Exception:{0}\n{1}", ex.Message, ex.StackTrace); } }
public virtual void VisitExpression(DbExpression expression) { EntityUtils.CheckArgumentNull <DbExpression>(expression, nameof(expression)).Accept((DbExpressionVisitor)this); }
public EntityDecisionCrudController() { // Options should be a valid json array ex. "['option 1', 'option2']" Post("/api/v1/entity/decision/create", _ => { var rules = new List <IValidatorRule>() { new ShouldHaveParameters(new[] { "entity_guid", "entity_type", "title", "content", "deadline", "options" }), new MinLength("title", 3), new MinLength("content", 10), new ShouldBeCorrectEnumValue("entity_type", typeof(EntityType)), new EntityShouldExist() }; var errors = ValidationProcessor.Process(Request, rules, true); if (errors.Count > 0) { return(HttpResponse.Errors(errors)); } JArray options; try { options = JArray.Parse(GetRequestStr("options")); } catch (Exception e) { return(HttpResponse.Error( HttpStatusCode.UnprocessableEntity, "For options please provide a valid JSON array" )); } var entityType = (EntityType)GetRequestEnum("entity_type", typeof(EntityType)); var entityId = EntityUtils.GetEntityId(GetRequestStr("entity_guid"), entityType); if (entityType != EntityType.Project || entityType != EntityType.Board) { } var deadline = DateTime.Parse(GetRequestStr("deadline")); var minDeadline = DateTime.Now.AddDays(1); if (deadline < minDeadline) { return(HttpResponse.Error( HttpStatusCode.UnprocessableEntity, "Deadline cannot be earlier than 1 day : " + minDeadline )); } var me = UserRepository.Find(CurrentRequest.UserId); if (PermissionUtils.HasEntityPermission(me, entityId, entityType)) { return(HttpResponse.Error( HttpStatusCode.Unauthorized, "You don't have decision edit access" )); } var decision = EntityDecisionRepository.Create( me, entityId, entityType, GetRequestStr("title"), GetRequestStr("content"), deadline ); int optionOrder = 1; foreach (var option in options) { EntityDecisionOptionRepository.Create(decision, option.Value <string>(), optionOrder); optionOrder++; if (optionOrder > 10) { break; } } return(HttpResponse.Item( "decision", new DecisionTransformer().Transform(decision), HttpStatusCode.Created )); }); Patch("/api/v1/entity/decision/edit", _ => { var rules = new List <IValidatorRule>() { new ShouldHaveParameters(new[] { "decision_guid" }), new ExistsInTable("decision_guid", "entity_decisions", "guid") }; var errors = ValidationProcessor.Process(Request, rules, true); if (errors.Count > 0) { return(HttpResponse.Errors(errors)); } var me = UserRepository.Find(CurrentRequest.UserId); var decision = EntityDecisionRepository.FindByGuid(GetRequestStr("decision_guid")); if (me.id != decision.creator_id) { return(HttpResponse.Error(HttpStatusCode.Unauthorized, "Only creator can update this decision")); } if (GetRequestStr("new_status") != "") { var newStatus = (DecisionStatus)GetRequestEnum("new_status", typeof(DecisionStatus)); switch (newStatus) { case DecisionStatus.Canceled: decision.UpdateStatus(DecisionStatus.Canceled); break; case DecisionStatus.Open: case DecisionStatus.Closed: return(HttpResponse.Error(HttpStatusCode.Unauthorized, "You cannot set this status")); } } decision = decision.Refresh(); return(HttpResponse.Item("decision", new DecisionTransformer().Transform(decision))); }); Delete("/api/v1/entity/decision/delete", _ => { var rules = new List <IValidatorRule>() { new ShouldHaveParameters(new[] { "decision_guid" }), new ExistsInTable("decision_guid", "entity_decisions", "guid") }; var errors = ValidationProcessor.Process(Request, rules, true); if (errors.Count > 0) { return(HttpResponse.Errors(errors)); } var me = UserRepository.Find(CurrentRequest.UserId); var decision = EntityDecisionRepository.FindByGuid(GetRequestStr("decision_guid")); if (me.id != decision.creator_id) { return(HttpResponse.Error(HttpStatusCode.Unauthorized, "Only creator can update this decision")); } decision.Delete(); return(HttpResponse.Item("decision", new DecisionTransformer().Transform(decision))); }); }
public SQLExecutorBase(EntityUtils entityUtils) { _entityUtils = entityUtils; }