public void SendMessageUDP(IBaseEntity entity, IPEndPoint endpoint) { BaseMessage msg = entity.ToMessage(); // Don't log KeepAlive messages. if (msg.Command != 3) { log.LogInformation("Send UDP: " + JsonConvert.SerializeObject(msg)); } entity.Id = LocalHubInfo.Id; byte[] data = messageSerializer.Serialize(msg); try { if (data != null) { UDPClientGateway.Send(data, data.Length, endpoint); } } catch (Exception ex) { log.LogError("Error on UDP send", ex); } }
private void OnObjectMaterialized(object sender, ObjectMaterializedEventArgs e) { using (var benchmark = Benchmark.Start()) { IBaseEntity entity = e.Entity as IBaseEntity; var entityFormatters = Container.TryGetAll <IEntityFormatter>(); if (entity != null) { foreach (var formatter in entityFormatters) { if (formatter.OnLoad(e.Entity.GetType(), entity)) { ((ObjectContext)sender).ObjectStateManager.GetObjectStateEntry(e.Entity).AcceptChanges(); } } entity.OnLoad(this); } benchmark.Stop(); if (LoggingEnabled) { Logger.Info(Logger.Completed(benchmark.TotalTime, true, "Entity Loaded: {0}".FormatString(e.Entity.GetType().Name)), RepositoryConstants.RepositoryComponent); } } }
public void SendMessageTCP(IBaseEntity entity) { BaseMessage msg = entity.ToMessage(); // Don't log KeepAlive messages. if (msg.Command != 3) { log.LogInformation("Send TCP: " + JsonConvert.SerializeObject(msg)); } if (TCPClientGateway != null && TCPClientGateway.Connected) { byte[] data = messageSerializer.Serialize(msg); try { NetworkStream NetStream = TCPClientGateway.GetStream(); NetStream.Write(data, 0, data.Length); } catch (Exception ex) { log.LogError("Error on TCP send", ex); } } }
public static string GetReferenceInternal(IBaseEntity entity) { string result = string.Empty; if (entity != null) { string particle = TypeParticle(entity); NameEntity namedEntity = entity as NameEntity; Guid fileGuid = namedEntity.Guid; if (IsSplittedType(entity)) { if (entity is IAvoidSerializedGuid avoidGuidEntity) { Guid versionId = avoidGuidEntity.ParentSerializableEntityVersionId; result = string.Format(CultureInfo.InvariantCulture, "{0}{4}{1}{4}{{{2}}}{4}{3}", avoidGuidEntity.SerializationParticle, TypeParticle(avoidGuidEntity.ParentSerializableEntity), versionId, avoidGuidEntity.ReferencedName, Separator); } else { // if (entity is IPartiallyOverridableEntity overridable) // result = overridable.OverriddenVersionId.ToString(); //else if (entity is IOverridableEntity overridableEntity) // result = overridableEntity.OverriddenVersionId.ToString(); //else result = entity.Guid.ToString(); } } else { result = string.Format(CultureInfo.InvariantCulture, "{0}{3}{1}{3}{{{2}}}.{4}", particle, NormalizeName(namedEntity?.Name), fileGuid, Separator, FilesConfig.EasyBPartialExtensionFile); } } return(result); }
public void OpenForm() { string wAssemblyInfo = String.Concat(new string[] { _FormClassName, ", ", _FormAssemblyName }); try { //Obtener la instancia del Formulario using (FrmBase f = (FrmBase)ReflectionFunctions.CreateInstance(wAssemblyInfo)) { //Busco en el archivo Configuration Manager el nombre de ensamblado, namespace y clase para crear diamicamente //FrontClientes.frmModificacion , FrontClientes" f.WindowState = _FormWindowState; f.StartPosition = _FormStartPosition; if (_EntityParam != null) { f.EntityParam = _EntityParam; } f.ShowDialog(); if (f.EntityResult != null) { _EntityResult = f.EntityResult; } } OnCloseFormEvent(); } catch (Exception ex) { throw ex; } }
public static void AgainstEntityNotFound(int id, IBaseEntity entity) { if (entity == null) { throw new EntityNotFoundException(id); } }
public static void AgainstEntityIncorrectlyIdentified(int id, IBaseEntity entity) { if (id != entity.Id) { throw new EntityIncorrectlyIdentifiedException(id, entity.Id); } }
public void AddMemberToRelationship(string relationName, IBaseEntity baseEntity) { throw new NotImplementedException(); /*var property = GetType().GetProperty(relationName, typeof(void)); * var collection = property.GetMethod.Invoke(this, null);*/ }
/// <summary> /// Generates the key for the cache. /// </summary> /// <param name="input">The input.</param> /// <returns></returns> /// <exception cref="MissingCacheKey"></exception> private string GenerateKey(IMethodInvocation input) { string values = ""; for (int i = 0; i < input.Arguments.Count; i++) { string parameterName = input.Arguments.ParameterName(i); if (ParamsToIgnore != null && ParamsToIgnore.Contains(parameterName)) { continue; } object argument = input.Arguments[i]; IBaseEntity entity = argument as IBaseEntity; if (entity == null) { values += "@@" + parameterName + "==" + argument; } else { values += "@@" + parameterName + "==" + entity.Id; } } if (string.IsNullOrEmpty(values)) { throw new MissingCacheKey(); } return(string.Format("{0}@{1}", ((MethodInfo)input.MethodBase).ReturnType.FullName, Key ?? values)); }
void TempEntCreated(IBaseEntity e) { if (e.Class.Classname == TFExplosion.CLASSNAME) { Explosion(new TFExplosion(e)); } else if (e.Class.Classname == "CTEPlayerAnimEvent") { return; } else if (e.Class.Classname == "CTEDust") { return; } else if (e.Class.Classname == "CTETFBlood") { new TFBlood(e); } else if (e.Class.Classname == "CTEEffectDispatch") { return; } else if (e.Class.Classname == "CTEWorldDecal") { return; } else if (e.Class.Classname == FireBullets.CLASSNAME) { new FireBullets(e); } else { Debug.WriteLine(string.Format("Tempent: {0}", e.Class.Classname)); } }
private void Teste (IBaseEntity entity) { if (entity is Customer) { var customer = entity as Customer; } }
public void OnSave(Type type, IBaseEntity entity) { var properties = GetProperties(type); foreach (var property in properties) { var attr = property.GetCustomAttribute <DateTimeFormatAttribute>(); object propertyValue = property.GetValue(entity, null); if (propertyValue != null) { DateTime dateTimeValue = (DateTime)propertyValue; if (dateTimeValue.Kind == DateTimeKind.Unspecified) { throw new ArgumentException( "DateTime property kind must be Local or UTC, {0}. {1}".FormatString( type.FullName, property.Name)); } if (attr.IsLocal && dateTimeValue.Kind != DateTimeKind.Local) { property.SetValue(entity, dateTimeValue.ToLocalTime(), null); } if (attr.IsUtc && dateTimeValue.Kind != DateTimeKind.Utc) { property.SetValue(entity, dateTimeValue.ToUniversalTime(), null); } } } }
public static void ToSetWriteUser(this IBaseEntity baseEntity, int writeType, string writeUser, string writeIp) { baseEntity.WriteTime = System.DateTime.Now; baseEntity.WriteType = writeType; baseEntity.WriteUser = writeUser; //HttpContext.Current.User.Identity.Name; baseEntity.WriteIp = writeIp; //HttpContext.Current.Request.UserHostAddress.ToString(); }
IEnumerable <IEntityRule> IRule.GetDomainRules(IBaseEntity baseEntity, IClientInfo clientInfo) { return(new List <IEntityRule>() { GetDomainRule(baseEntity) }); }
//İki tane functions olacak EntityConvert suan yapılacak //Convert işlemi yaparken iki adet entity ihtiyacımız bulunmaktadır. //1 tanesi kaynak Entity diğeri Hedef Entity //Kaynak entity property arasına dolaşıp hedef teki ile karşılaştırıcağız. Aynı ise //Kaynaktakini alıp hedefe atacağız. //Oluşturacağımız function ı extensions method olarak oluşturacağız. //Extensions oluşturabilmemiz için class ve function ın static olması lazım ve ilk değişken this ile başlamı //Source u IBaseEntity tanımlamamızın neden biliyoruz ki bütün entitylerimiz IBaseEntity den implemente olacak ve her halikarda bu şekilde bir kaynak gelecek public static TTarget EntityConvert <TTarget>(this IBaseEntity source) { if (source == null) { return(default(TTarget)); } //Bu şekilde hedef entitytim olan TTarget dan bir instance üretmiş olduk. var hedef = Activator.CreateInstance <TTarget>(); //Kaynak ve hedef entity property lerine reflection ile ulaşabiliriz. var kaynakProp = source.GetType().GetProperties(); var hedefProp = typeof(TTarget).GetProperties(); foreach (var kp in kaynakProp) { //Kaynak property in value sunu alıyoruz. //Kaynak property değerine ulaştık var value = kp.GetValue(source); //hedef property ulaşmaya çalışıyoruz. //Gelen kaynak prop ismini al hedef te ara buluyosan at bulamıyorsn null gelir burası var hp = hedefProp.FirstOrDefault(x => x.Name == kp.Name); if (hp != null) { //kAYNAKTAN gelen verilerde boi ise tırnak olarak geliyor tırnak ise null olarak kayıt edilmesini istiyorsak veritabanına aşağıdaki gibi yapıyoruz. hp.SetValue(hedef, ReferenceEquals(value, "") ? null : value); } } return(hedef); }
//获取所有工作流 public List <WorkflowInfo> GetAllWorkflows() { var list = SqlHelper.GetAllEntities <WorkflowInfo>(); foreach (var flow in list) { IList steps = new List <WorkflowAuditStep>(); SqlHelper.SearchByField("FlowType", flow.FlowType, ref steps, true, true); flow.AuditSteps = steps as List <WorkflowAuditStep>; if (flow.AuditSteps != null) { foreach (var step in flow.AuditSteps) { if (step.AuditType == AuditType.JointCheckup && step.JcUsers != null && step.JcUsers.Count > 0) { foreach (var jcu in step.JcUsers) { IBaseEntity entity = jcu.UserInfo ?? new SystemUser(); SqlHelper.GetSingleEntity(jcu.UserId, ref entity); jcu.UserInfo = entity as SystemUser; } } } } } return(list); }
public EntityRules(IBaseEntity Initializer) { // var c = default(int); // var c = Initializer; this.Rules = new Dictionary <string, IBaseEntity>(); }
public async Task <T> AddAsync(IBaseEntity t) { t.Id = _items.Count + 1; await Task.Run(() => _items.Add(t as T)); return((T)t); }
private static void UpdateModel <V>(this V viewModel, IBaseEntity entity) where V : DomainViewModel { if (entity == null) { return; } var props = viewModel .GetType() .GetProperties() .Where(w => w.PropertyType.IsSubclassOf(typeof(DomainEntityType))); foreach (var prop in props) { dynamic source = prop.GetValue(viewModel, null); var srcValue = ((IDomainEntityType) (entity.GetType() .GetProperty(prop.Name) .GetValue(entity, null))).Attributes; source.Attributes = srcValue; prop.SetValue(viewModel, source, null); } }
public static void NullBasket(this IGuardClause guardClause, int basketId, IBaseEntity entity) { if (entity == null) { throw new ItemNotFoundException(basketId); } }
public void AddEntity(IBaseEntity entity) { EntityObservableModel EOM = new EntityObservableModel(); EOM.BaseEntity = entity; EOM.ChangedField = new List <string>(); EOMs.Add(EOM); }
/// <summary> /// 数据库类型,目前只支持SQL Server /// </summary> /// <param name="DBType">数据库类型</param> /// <param name="connString">数据库连接信息,为null,为系统级数据库连接</param> public DBAsser(DBEnum DBType = DBEnum.SqlServer, string connString = null) { ConnectionString = connString; if (DBType == DBEnum.SqlServer)//暂时只支持SQL Server数据库 { m_DBAssesser = new SqlServerAssesser(ConnectionString); } }
public void BroadcastUDP(IBaseEntity Item) { List <HubInfo> connections = Connections.GetBroadcastConnections(false); foreach (HubInfo CI in connections) { SendUDP(Item, CI.ExternalEndpoint); } }
public async Task <User> Add(IBaseEntity obj) { var user = (User)obj; _context.Set <User>().Add(user); await _context.SaveChangesAsync(); return(user); }
public static bool IsSplittedType(IBaseEntity entity) { Type type = entity.GetType(); return(typeof(WorkflowFormalParameter).IsAssignableFrom(type) || typeof(WorkflowUICommandList).IsAssignableFrom(type) || typeof(WorkflowUICommandFormat).IsAssignableFrom(type) || typeof(EventProperty).IsAssignableFrom(type)); }
public BaseEntityWrapper(IBaseEntity e, string className) { if (e.Class.Classname != className) { throw new ArgumentException(string.Format("Invalid entity class for this {0}", nameof(BaseEntityWrapper))); } Entity = e; }
public void CreateEntityWithBaseEntity() { IBaseEntity entity = entityContext.Create("Entity"); entity.SetAttributeValue("Name", "CreateEntityWithBaseEntity"); entityContext.Set("Entity").Add(entity); entityContext.SaveChanges(); }
public void BroadcastTCP(IBaseEntity Item) { List <HubInfo> connections = Connections.GetBroadcastConnections(true); foreach (HubInfo CI in connections) { SendTCP(Item, CI.Client); } }
public bool OnLoad(Type type, IBaseEntity entity) { var properties = GetProperties(type); bool propertiesChanged = false; foreach (var property in properties) { var attr = property.GetCustomAttribute <DateTimeFormatAttribute>(); object propertyValue = property.GetValue(entity, null); if (propertyValue != null) { DateTime dateTimeValue = (DateTime)propertyValue; if (dateTimeValue.Kind != DateTimeKind.Unspecified) { //Sanity check throw new ArgumentException( "DateTime property kind must be Unspecified, {0}.{1}".FormatString( entity.GetType().FullName, property.Name)); } if (attr.IsUtc) { //All DateTimes in database is in UTC dateTimeValue = new DateTime( dateTimeValue.Year, dateTimeValue.Month, dateTimeValue.Day, dateTimeValue.Hour, dateTimeValue.Minute, dateTimeValue.Second, dateTimeValue.Millisecond, DateTimeKind.Utc); } else { //All DateTimes in database is in UTC dateTimeValue = new DateTime( dateTimeValue.Year, dateTimeValue.Month, dateTimeValue.Day, dateTimeValue.Hour, dateTimeValue.Minute, dateTimeValue.Second, dateTimeValue.Millisecond, DateTimeKind.Local); } property.SetValue(entity, dateTimeValue); propertiesChanged = true; } } return(propertiesChanged); }
protected BaseEntity(IBaseEntity <T> obj) { CreatedAt = DateTime.UtcNow; UpdatedAt = DateTime.UtcNow; Enabled = false; Published = false; MasterId = obj.MasterId; DeletedAt = obj.DeletedAt; }
public bool Equals(IBaseEntity other) { return other == this; }
public void OpenForm() { string wAssemblyInfo = String.Concat(new string[] { _FormClassName, ", ", _FormAssemblyName }); try { //Obtener la instancia del Formulario using (FrmBase f = (FrmBase)ReflectionFunctions.CreateInstance(wAssemblyInfo)) { //Busco en el archivo Configuration Manager el nombre de ensamblado, namespace y clase para crear diamicamente //FrontClientes.frmModificacion , FrontClientes" f.WindowState = _FormWindowState; f.StartPosition = _FormStartPosition; if (_EntityParam != null) f.EntityParam = _EntityParam; f.ShowDialog(); if (f.EntityResult != null) _EntityResult = f.EntityResult; } OnCloseFormEvent(); } catch (Exception ex) { throw ex; } }