public static DomainEntity GetDomainEntity(string domain) { var d = DomainExtension.DePunycodeDomain(domain.ToLower()); lock (_domainLocker) { var domainEntity = DomainEntity.DataSource .WhereEquals(DomainEntity.Fields.Domain, d) .WhereEquals(DomainEntity.Fields.CollectionIdentity, (short) CollectionIdentity) .First(); if (domainEntity == null) { domainEntity = new DomainEntity { Datecreated = DateTime.UtcNow, Domain = d, Status = DomainStatus.Default, CollectionIdentity = CollectionIdentity }; domainEntity.Save(); } return domainEntity; } }
private string GetPropertyValue(object propertyState, string propertyName,DomainEntity entity) { if (propertyState != null) { //Type entityType = entity.GetType(); Type propertyType = propertyState.GetType(); if (propertyType == typeof(IList<>) || propertyType == typeof(IList) || propertyType == typeof(IEnumerable<>) || propertyType == typeof(IEnumerable)) { } else if(propertyType.IsAssignableFrom(typeof(Entity))) { } return propertyState.ToString(); } return null; }
/// <summary> /// Sets the table level audit items. /// </summary> /// <param name="actor">The actor.</param> private void SetTableLevelAuditItems(DomainEntity entity, IIdentity actor) { ITitanIdentity currentIdentity = null; if (actor is ITitanIdentity) currentIdentity = (ITitanIdentity) actor; DateTime auditDate = DateTime.Now; string currentUser = (currentIdentity == null || string.IsNullOrEmpty(currentIdentity.Guid) || currentIdentity.Guid == TitanIdentity.AnonymousIdentifier) ? "00076173-2367-1488-58A1-8E9C848DCA26" : currentIdentity.Guid; if (entity.IsNew) { entity.CreatedBy = currentUser; entity.CreatedByDate = auditDate; } entity.LastModifiedBy = currentUser; entity.LastModifiedByDate = auditDate; }
public static async Task Main(string[] args) { const string host = "http://localhost:9999"; const string token = "my-token"; const string bucket = "my-bucket"; const string organization = "my-org"; var options = new InfluxDBClientOptions.Builder() .Url(host) .AuthenticateToken(token.ToCharArray()) .Org(organization) .Bucket(bucket) .Build(); var converter = new DomainEntityConverter(); var client = InfluxDBClientFactory.Create(options); // // Prepare data to write // var time = new DateTimeOffset(2020, 11, 15, 8, 20, 15, new TimeSpan(3, 0, 0)); var entity1 = new DomainEntity { Timestamp = time, SeriesId = Guid.Parse("0f8fad5b-d9cb-469f-a165-70867728950e"), Value = 15, Properties = new List <DomainEntityAttribute> { new DomainEntityAttribute { Name = "height", Value = 4 }, new DomainEntityAttribute { Name = "width", Value = 110 } } }; var entity2 = new DomainEntity { Timestamp = time.AddHours(1), SeriesId = Guid.Parse("0f8fad5b-d9cb-469f-a165-70867728950e"), Value = 15, Properties = new List <DomainEntityAttribute> { new DomainEntityAttribute { Name = "height", Value = 5 }, new DomainEntityAttribute { Name = "width", Value = 160 } } }; var entity3 = new DomainEntity { Timestamp = time.AddHours(2), SeriesId = Guid.Parse("7c9e6679-7425-40de-944b-e07fc1f90ae7"), Value = 15, Properties = new List <DomainEntityAttribute> { new DomainEntityAttribute { Name = "height", Value = 5 }, new DomainEntityAttribute { Name = "width", Value = 110 } } }; var entity4 = new DomainEntity { Timestamp = time.AddHours(3), SeriesId = Guid.Parse("7c9e6679-7425-40de-944b-e07fc1f90ae7"), Value = 15, Properties = new List <DomainEntityAttribute> { new DomainEntityAttribute { Name = "height", Value = 6 }, new DomainEntityAttribute { Name = "width", Value = 160 } } }; // // Write data // await client.GetWriteApiAsync(converter) .WriteMeasurementsAsync(WritePrecision.S, entity1, entity2, entity3, entity4); // // Query Data to Domain object // var queryApi = client.GetQueryApiSync(converter); // // Select ALL // var query = from s in InfluxDBQueryable <DomainEntity> .Queryable("my-bucket", "my-org", queryApi, converter) select s; Console.WriteLine("==== Select ALL ===="); query.ToList().ForEach(it => Console.WriteLine(it.ToString())); // // Filter By Tag // query = from s in InfluxDBQueryable <DomainEntity> .Queryable("my-bucket", "my-org", queryApi, converter) where s.SeriesId == Guid.Parse("7c9e6679-7425-40de-944b-e07fc1f90ae7") select s; Console.WriteLine("==== Filter by Tag ===="); query.ToList().ForEach(it => Console.WriteLine(it.ToString())); // // Use Take + Skip // query = (from s in InfluxDBQueryable <DomainEntity> .Queryable("my-bucket", "my-org", queryApi, converter) select s) .Take(1) .Skip(1); Console.WriteLine("==== Use Take + Skip ===="); query.ToList().ForEach(it => Console.WriteLine(it.ToString())); // // Use Time Range // query = from s in InfluxDBQueryable <DomainEntity> .Queryable("my-bucket", "my-org", queryApi, converter) where s.Timestamp > time.AddMinutes(30) && s.Timestamp < time.AddHours(3) select s; Console.WriteLine("==== Use Time Range ===="); query.ToList().ForEach(it => Console.WriteLine(it.ToString())); // // Use Any // query = from s in InfluxDBQueryable <DomainEntity> .Queryable("my-bucket", "my-org", queryApi, converter) where s.Properties.Any(a => a.Name == "width" && a.Value == 160) select s; Console.WriteLine("==== Use Any ===="); query.ToList().ForEach(it => Console.WriteLine(it.ToString())); // // Debug Query // Console.WriteLine("==== Debug LINQ Queryable Flux output ===="); var influxQuery = ((InfluxDBQueryable <DomainEntity>)query).ToDebugQuery(); foreach (var statement in influxQuery.Extern.Body) { var os = statement as OptionStatement; var va = os?.Assignment as VariableAssignment; var name = va?.Id.Name; var value = va?.Init.GetType().GetProperty("Value")?.GetValue(va.Init, null); Console.WriteLine($"{name}={value}"); } Console.WriteLine(); Console.WriteLine(influxQuery._Query); client.Dispose(); }
public async Task <List <DomainEntity> > GetDomainEntities(int page, int countPerPage, string accountId = "", DomainEntity delta = null) { //todo:增加筛选 try { using (var context = new DjLiveCpContext()) { var sql = $@"SELECT * FROM sys_domain limit {(page - 1) * countPerPage},{countPerPage}"; var paraObjects = new object[] { }; if (!string.IsNullOrEmpty(accountId)) { sql = $@"SELECT * FROM sys_domain where AccountId = {"{0}"} limit {(page - 1) * countPerPage},{countPerPage}"; paraObjects = new object[] { accountId }; } var objs = context.Database.SqlQuery <DomainEntity>(sql, paraObjects); return(await objs.ToListAsync()); } } catch (Exception e) { LogHelper.Error(e.Message, e); return(null); } }
public virtual void Add(DomainEntity de) { NodeUriToEntityMap[de.Location] = de; }
public static DomainEntity AddMetaData(DomainEntity domainEntity) { domainEntity.CreatedAt = DateTime.Now; domainEntity.ChangedAt = DateTime.Now; return(domainEntity); }
///////////////// public DomainContext(DomainEntity domain) { Domain = domain; Refresh(); }
private static void GeDomainData(DomainEntity domainEntity) { domainEntity.Status |= DomainStatus.Loaded; domainEntity.Datecollected = DateTime.UtcNow; var domainInfo = GetDomainInfo(domainEntity.Domain); if (domainInfo != null) { domainEntity.Content = domainInfo.Content; if (domainInfo.Emails != null) { domainInfo.Emails.Select(e => new Domainemail { DomainID = domainEntity.ID, Datecreated = DateTime.UtcNow, Email = e, CollectionIdentity = CollectionIdentity }) .ToList() .Save<Domainemail, int>(); domainEntity.Status |= DomainStatus.EmailPhoneCollected; } if (domainInfo.Phones != null) { domainInfo.Phones.Select(ph => new Domainphone { DomainID = domainEntity.ID, Datecreated = DateTime.UtcNow, Phone = ph, CollectionIdentity = CollectionIdentity }) .ToList() .Save<Domainphone, int>(); domainEntity.Status |= DomainStatus.EmailPhoneCollected; } } else { domainEntity.Status |= DomainStatus.LoadedError; } domainEntity.Save(); }
private bool DomainEntityCheck(DomainEntity domainEntity, PropertyInfo property) { var value = (DomainEntity)property.GetValue(domainEntity); return(value.Id == Guid.Empty); }
public static IServiceProvider WireUpDomainEventHandlers(this IServiceProvider serviceProvider) { DomainEntity.WireUpDispatcher(serviceProvider.GetRequiredService <IDomainEventDispatcher>()); return(serviceProvider); }
public EntityRemoved(DomainEntity entity) { Entity = entity; }
private bool StringCheck(DomainEntity domainEntity, PropertyInfo property) { var value = (string)property.GetValue(domainEntity); return(string.IsNullOrWhiteSpace(value)); }
public EditEntityModel(DomainEntity target) { SaveButtonText = FastPackKeys.SAVE_KEY; Target = target; _notification = new Notification(); }
protected bool Equals(DomainEntity other) { return(Id == other.Id && string.Equals(Name, other.Name)); }
public bool HasSimilar(DomainEntity domainEntity) { var genus = (Genus)domainEntity; return(_context.tblGenus.Any(x => x.Id != genus.Id && x.Name == genus.Title)); }
public async Task <DaoResultMessage> Add2Account(string accountId, string serverId, DomainEntity entity) { DaoResultMessage message = new DaoResultMessage(); try { using (var context = new DjLiveCpContext()) { if (await context.Domain.CountAsync(item => item.SourceDomain == entity.SourceDomain) >= 1) { message.Code = DaoResultCode.ItemAlreadyExist; message.Message = "修改失败,对象已经存在!"; } else { var dbentity = context.Account.FirstOrDefault(obj => obj.Id == accountId); var serverEntity = context.Server.FirstOrDefault(obj => obj.Id == serverId); if (dbentity != null && serverEntity != null) { entity.Account = dbentity; entity.Server = serverEntity; context.Domain.Add(entity); await context.SaveChangesAsync(); } else { message.Code = DaoResultCode.ItemNotExist; message.Message = "修改失败,对象不存在!"; } } } } catch (Exception e) { LogHelper.Error(e.Message, e); message.Code = DaoResultCode.UnExpectError; message.Message = e.Message; } return(message); }
public DatabaseRecord(DomainEntity entity) { this.EntityId = entity.Key; }
public BlankEditModel(DomainEntity target) : base(target) { }
protected static void CreateOrUpdateDomainPhrase(DomainEntity domainEntity, Phrase phrase, SearchEngine seType, SourceType sourceType) { var firstDomainPhrase = Domainphrase.DataSource .WhereEquals(Domainphrase.Fields.DomainID, domainEntity.ID) .WhereEquals(Domainphrase.Fields.PhraseID, phrase.ID) .WhereEquals(Domainphrase.Fields.CollectionIdentity, (short) CollectionIdentity) .First(); if (firstDomainPhrase == null) { var domainphrase = new Domainphrase { DomainID = domainEntity.ID, PhraseID = phrase.ID, SourceType = sourceType, SE = seType, CollectionIdentity = CollectionIdentity }; domainphrase.Save(); } else { firstDomainPhrase.SourceType |= sourceType; firstDomainPhrase.SE |= seType; firstDomainPhrase.Save(); } }
public void ApplyDefaultsToNewEntity(DomainEntity entity) { // nothing }
public async Task <DomainEntity> Put(DomainEntity value) { throw new NotImplementedException(); }
public async Task UpdateDomainDetailsAsync(DomainEntity entity) { _dbContext.DomainEntity.Update(entity); await _dbContext.SaveChangesAsync(); }
public static async void ProcessRedirectsSync( [QueueTrigger(QueueNames.SynchroniseRedirects)] string node, [Table(TableNames.Redirects)] CloudTable redirectTable, [Table(TableNames.Domains)] CloudTable domainTable, [Queue(QueueNames.ProcessClicksGeo), StorageAccount("AzureWebJobsStorage")] ICollector <HttpRequestEntity> processClicksGeoQueue, ILogger log, ExecutionContext context) { var config = new ConfigurationBuilder() .SetBasePath(context.FunctionAppDirectory) .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true) .AddEnvironmentVariables() .Build(); string connectionString = config[$"NODE_SYNC_CONNECTION_{node}"]; if (connectionString == null) { throw new Exception($"No connection string found for node [{node}]. Aborting."); } CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString); CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); CloudTable destinationRedirectTable = tableClient.GetTableReference(TableNames.Redirects); CloudTable destinationDomainTable = tableClient.GetTableReference(TableNames.Domains); await destinationRedirectTable.CreateIfNotExistsAsync(); await destinationDomainTable.CreateIfNotExistsAsync(); List <DomainEntity> domains = await DomainEntity.get(domainTable, null); List <string> uniqueAccounts = new List <string>(); foreach (DomainEntity domain in domains) { await DomainEntity.put(destinationDomainTable, domain); if (uniqueAccounts.FindIndex(checkAccount => checkAccount == domain.Account) == -1) { uniqueAccounts.Add(domain.Account); } } List <DomainEntity> destinationDomains = await DomainEntity.get(destinationDomainTable, null); foreach (DomainEntity destinationDomain in destinationDomains) { if (domains.FindIndex(checkDomain => checkDomain.RowKey == destinationDomain.RowKey) == -1) { await DomainEntity.delete(destinationRedirectTable, destinationDomain); } } foreach (string account in uniqueAccounts) { List <RedirectEntity> redirects = await RedirectEntity.get(redirectTable, account); foreach (RedirectEntity redirect in redirects) { await RedirectEntity.put(destinationRedirectTable, redirect); } List <RedirectEntity> destinationRedirects = await RedirectEntity.get(destinationRedirectTable, account); foreach (RedirectEntity destinationRedirect in destinationRedirects) { if (redirects.FindIndex(checkRedirect => checkRedirect.RowKey == destinationRedirect.RowKey) == -1) { await RedirectEntity.delete(destinationRedirectTable, destinationRedirect); } } } }