public CustomEditor(Context context, EntityProperty property) : base(context, Resource.Layout.dataform_custom_editor, Resource.Id.custom_editor_header, Resource.Id.custom_editor, Resource.Id.custom_editor_validation_view, property) { editorButton = (Button)EditorView; editorButton.Click += (object sender, EventArgs e) => this.onClick(); ((TextView)HeaderView).Text = this.Property().Header; }
public AliasedColumnsClassTests() { var type = EntityTypes.Register<AliasedColumnsClass>(tr => { tr.Alias(t => t.Name, "ADifferentName") .Alias(t => t.Description, null); }); _idProperty = type.GetProperty<AliasedColumnsClass>(t => t.Id); _nameProperty = type.GetProperty<AliasedColumnsClass>(t => t.Name); _descriptionProperty = type.GetProperty<AliasedColumnsClass>(t => t.Description); _queryGenerator = new SqlServerGenerator(); }
/// <summary> /// Generates an INSERT statement using the passed-in properties. /// </summary> /// <param name="table">The name of the table</param> /// <param name="properties">A dictionary representing the properties to be inserted; the key is the parameterized name of the property and the value is the property itself</param> /// <param name="key">The primary key of the table</param> public new string Insert(string table, IDictionary<string, EntityProperty> properties, EntityProperty key) { var fields = new List<string>(); var valueParams = new List<string>(); foreach (var kvp in properties) { fields.Add(kvp.Value.Name); valueParams.Add(kvp.Key); } var format = key.IsIdentity ? InsertWithIdentityFormat : InsertFormat; var insertOptions = (key.IsIdentity) ? "select last_insert_rowid()" : ""; return String.Format(format, table, String.Join(", ", fields), String.Join(", ", valueParams), insertOptions).Trim(); }
/// <summary> /// Insert Batch /// </summary> /// <param name="entities">Entities</param> public virtual async Task <IEnumerable <TableResult> > Insert(IEnumerable <IDictionary <string, object> > entities) { var result = new List <TableResult>(); foreach (var batch in this.Batch(entities)) { var batchOperation = new TableBatchOperation(); foreach (var entity in batch) { var properties = new Dictionary <string, EntityProperty>(); entity.Keys.Where(k => k != PartitionKey && k != RowKey && k != ETag).ToList().ForEach(key => properties.Add(key, EntityProperty.CreateEntityPropertyFromObject(entity[key]))); var partitionKey = entity.Keys.Contains(PartitionKey) ? entity[PartitionKey].ToString() : string.Empty; var rowKey = entity.Keys.Contains(RowKey) ? entity[RowKey].ToString() : string.Empty; var etag = entity.Keys.Contains(ETag) ? entity[ETag].ToString() : null; batchOperation.InsertOrMerge(new DynamicTableEntity(partitionKey, rowKey, etag, properties)); } var r = await this.reference.ExecuteBatchAsync(batchOperation).ConfigureAwait(false); result.AddRange(r); } return(result); }
private static extern void _RegisterEntityClass(EntityClassFlags flags, string name, string editorHelper, string editorIcon, string category, string fullyQualifiedName, string pathToAssembly, EntityProperty[] properties);
private void InitializeMembers(StreamingContext context) { this.queryTimeout = 60; // TODO *** this.destination = new DestinationTableParameters(); this.isDestinationTableInitialized = false; this.sourceDatabaseVersionName = String.Empty; this.statDatabaseVersionName = String.Empty; this.tableStatistics = new List<TableReference>(); this.partitions = new List<QueryPartitionBase>(); this.destinationDatabaseInstance = new EntityProperty<DatabaseInstance>(); this.partitioningTable = null; this.partitioningKey = null; }
/// <summary> /// Generates an UPDATE statement for one or more keys using the passed-in properties. /// </summary> /// <param name="table">The name of the table</param> /// <param name="properties">A dictionary representing the properties to be inserted; the key is the parameterized name of the property and the value is the property itself</param> /// <param name="key">The primary key of the table</param> /// <param name="values">The keys to be updated</param> public string UpdateMany(string table, IDictionary<string, EntityProperty> properties, EntityProperty key, string values) { var clauses = properties.Select(kvp => String.Format(UpdateParamFormat, kvp.Value.Name, kvp.Key)); return String.Format(UpdateManyFormat, table, String.Join(", ", clauses), key.Name, values); }
private void InitializeMembers(StreamingContext context) { this.protocol = String.Empty; this.authorityName = String.Empty; this.authorityUri = String.Empty; this.identifier = String.Empty; this.userProperty = new EntityProperty<User>(); }
private void CopyMembers(GraywulfDataset old) { this.context = old.context; this.databaseDefinition = new EntityProperty<DatabaseDefinition>(old.databaseDefinition); this.databaseVersion = new EntityProperty<DatabaseVersion>(old.databaseVersion); this.databaseInstance = new EntityProperty<DatabaseInstance>(old.databaseInstance); }
internal static void ReadAndUpdateTableEntityWithEdmTypeResolver(ITableEntity entity, Dictionary <string, string> entityAttributes, EntityReadFlags flags, Func <string, string, string, string, EdmType> propertyResolver, OperationContext ctx) { Dictionary <string, EntityProperty> entityProperties = (flags & EntityReadFlags.Properties) > 0 ? new Dictionary <string, EntityProperty>() : null; Dictionary <string, EdmType> propertyResolverDictionary = null; if (entity.GetType() != typeof(DynamicTableEntity)) { propertyResolverDictionary = TableOperationHttpResponseParsers.CreatePropertyResolverDictionary(entity.GetType()); } if (flags > 0) { foreach (KeyValuePair <string, string> prop in entityAttributes) { if (prop.Key == TableConstants.PartitionKey) { entity.PartitionKey = (string)prop.Value; } else if (prop.Key == TableConstants.RowKey) { entity.RowKey = (string)prop.Value; } else if (prop.Key == TableConstants.Timestamp) { if ((flags & EntityReadFlags.Timestamp) == 0) { continue; } entity.Timestamp = DateTime.Parse(prop.Value, CultureInfo.InvariantCulture); } else if ((flags & EntityReadFlags.Properties) > 0) { if (propertyResolver != null) { Logger.LogVerbose(ctx, SR.UsingUserProvidedPropertyResolver); try { EdmType type = propertyResolver(entity.PartitionKey, entity.RowKey, prop.Key, prop.Value); Logger.LogVerbose(ctx, SR.AttemptedEdmTypeForTheProperty, prop.Key, type.GetType().ToString()); try { entityProperties.Add(prop.Key, EntityProperty.CreateEntityPropertyFromObject(prop.Value, type.GetType())); } catch (FormatException ex) { throw new StorageException(string.Format(CultureInfo.InvariantCulture, SR.FailParseProperty, prop.Key, prop.Value, type.ToString()), ex) { IsRetryable = false }; } } catch (StorageException) { throw; } catch (Exception ex) { throw new StorageException(SR.PropertyResolverThrewError, ex) { IsRetryable = false }; } } else if (entity.GetType() != typeof(DynamicTableEntity)) { EdmType edmType; Logger.LogVerbose(ctx, SR.UsingDefaultPropertyResolver); if (propertyResolverDictionary != null) { propertyResolverDictionary.TryGetValue(prop.Key, out edmType); Logger.LogVerbose(ctx, SR.AttemptedEdmTypeForTheProperty, prop.Key, edmType); entityProperties.Add(prop.Key, EntityProperty.CreateEntityPropertyFromObject(prop.Value, edmType)); } } else { Logger.LogVerbose(ctx, SR.NoPropertyResolverAvailable); entityProperties.Add(prop.Key, EntityProperty.CreateEntityPropertyFromObject(prop.Value, typeof(string))); } } } if ((flags & EntityReadFlags.Properties) > 0) { entity.ReadEntity(entityProperties, ctx); } } }
private void InitializeMembers() { this.entityReference = new EntityProperty<Entity>(); this.expression = null; }
public static IEnumerable<Entity> GetEntities(XElement xml, DacpacExtractor extractor) { const string xpath = "/DataSchemaModel/Model/Element[@Type='SqlTable']"; var elements = xml.XPathSelectElements(xpath); foreach (var e in elements) { var entity = new Entity {TableName = e.GetAttributeString("Name"), IncludeForeignKey = extractor.IncludeForeignKey}; foreach (var pe in e.XPathSelectElements("Relationship[@Name='Columns']/Entry/Element[@Type='SqlSimpleColumn']")) { var nullableNode = pe.XPathSelectElement("Property[@Name='IsNullable']"); var identityNode = pe.XPathSelectElement("Property[@Name='IsIdentity']"); var p = new EntityProperty() { Nullable = nullableNode == null || nullableNode.GetAttributeBool("Value"), Identity = identityNode != null && identityNode.GetAttributeBool("Value"), Name = pe.GetAttributeString("Name"), Type = pe.XPathSelectElement("Relationship[@Name='TypeSpecifier']/Entry/Element[@Type='SqlTypeSpecifier' or @Type='SqlXmlTypeSpecifier']/Relationship[@Name='Type']/Entry/References").GetAttributeString("Name"), }; var over = extractor.ColumnOverrides.EmptyIfNull().FirstOrDefault(o => o.Name == p.Name); if (over != null) { p.Type = over.Type ?? p.Type; p.Nullable = over.Nullable ?? p.Nullable; p.Attributes = over.Attributes; over.Name = null; } if (p.Type.ToLower() != "[timestamp]" && p.Type.ToLower() != "[rowversion]" && !extractor.ObjectsToIgnore.EmptyIfNull().Contains(p.Name)) { entity.Properties.Add(p); } } foreach (var c in extractor.ColumnOverrides.EmptyIfNull()) { if (c.Name != null && c.Type != null && c.Name.StartsWith(entity.TableName)) { entity.Properties.Add(c); } } var an = extractor.EntityOverrides.EmptyIfNull().FirstOrDefault(ae => ae.TableName == entity.TableName); if (an != null) { entity.Annotations = an.Annotations; entity.Name = an.Name; entity.IncludeForeignKey = an.IncludeForeignKey; } if (!extractor.ObjectsToIgnore.EmptyIfNull().Contains(entity.TableName)) { yield return entity; } } }
public TestClassTests() { var simpleClassType = EntityTypes.Register<TestClass>(); _idProperty = simpleClassType.GetProperty<TestClass>(t => t.Id); _nameProperty = simpleClassType.GetProperty<TestClass>(t => t.Name); _queryGenerator = new SqlServerGenerator(); }
public NonIdentityKeyClassTests() { var type = EntityTypes.Register<NonIdentityKeyClass>(tr => { tr.Key(t => t.Id, false); }); _idProperty = type.GetProperty<NonIdentityKeyClass>(t => t.Id); _queryGenerator = new SqlServerGenerator(); }
protected internal abstract void SetEditorElementsArrangeMetadata(EntityPropertyControl editorElement, EntityProperty entityProperty);
public void ReadEntity(IDictionary <string, EntityProperty> properties, OperationContext operationContext) { var t = new T(); foreach (PropertyMetadata outputProperty in typeMetadata.Properties) { if (properties.ContainsKey(outputProperty.PropertyInfo.Name)) { EntityProperty inputProperty = properties[outputProperty.PropertyInfo.Name]; Type propertyType = outputProperty.PropertyInfo.PropertyType; if ((propertyType == typeof(bool)) && (inputProperty.BooleanValue.HasValue)) { outputProperty.PropertyInfo.SetValue(t, inputProperty.BooleanValue.Value); } else if ((propertyType == typeof(bool?)) && (inputProperty.BooleanValue.HasValue)) { outputProperty.PropertyInfo.SetValue(t, inputProperty.BooleanValue); } else if ((propertyType == typeof(byte)) && (inputProperty.Int32Value.HasValue)) { outputProperty.PropertyInfo.SetValue(t, ((byte)(inputProperty.Int32Value.Value))); } else if ((propertyType == typeof(byte?)) && (inputProperty.Int32Value.HasValue)) { outputProperty.PropertyInfo.SetValue(t, ((byte)(inputProperty.Int32Value.Value))); } else if ((propertyType == typeof(byte[])) && (inputProperty.BinaryValue != null)) { outputProperty.PropertyInfo.SetValue(t, inputProperty.BinaryValue); } else if ((propertyType == typeof(decimal)) && (inputProperty.DoubleValue.HasValue)) { outputProperty.PropertyInfo.SetValue(t, ((decimal)(inputProperty.DoubleValue.Value))); } else if ((propertyType == typeof(decimal?)) && (inputProperty.DoubleValue.HasValue)) { outputProperty.PropertyInfo.SetValue(t, ((decimal)(inputProperty.DoubleValue.Value))); } else if ((propertyType == typeof(DateTime)) && (inputProperty.DateTime.HasValue)) { outputProperty.PropertyInfo.SetValue(t, inputProperty.DateTime.Value); } else if ((propertyType == typeof(DateTime?)) && (inputProperty.DateTime.HasValue)) { outputProperty.PropertyInfo.SetValue(t, inputProperty.DateTime); } else if ((propertyType == typeof(double)) && (inputProperty.DoubleValue.HasValue)) { outputProperty.PropertyInfo.SetValue(t, inputProperty.DoubleValue.Value); } else if ((propertyType == typeof(double?)) && (inputProperty.DoubleValue.HasValue)) { outputProperty.PropertyInfo.SetValue(t, inputProperty.DoubleValue); } else if ((propertyType == typeof(float)) && (inputProperty.DoubleValue.HasValue)) { outputProperty.PropertyInfo.SetValue(t, ((float)(inputProperty.DoubleValue.Value))); } else if ((propertyType == typeof(float?)) && (inputProperty.DoubleValue.HasValue)) { outputProperty.PropertyInfo.SetValue(t, ((float)(inputProperty.DoubleValue.Value))); } else if ((propertyType == typeof(Guid)) && (inputProperty.GuidValue.HasValue)) { outputProperty.PropertyInfo.SetValue(t, inputProperty.GuidValue.Value); } else if ((propertyType == typeof(Guid?)) && (inputProperty.GuidValue.HasValue)) { outputProperty.PropertyInfo.SetValue(t, inputProperty.GuidValue); } else if ((propertyType == typeof(int)) && (inputProperty.Int32Value.HasValue)) { outputProperty.PropertyInfo.SetValue(t, inputProperty.Int32Value.Value); } else if ((propertyType == typeof(int?)) && (inputProperty.Int32Value.HasValue)) { outputProperty.PropertyInfo.SetValue(t, inputProperty.Int32Value); } else if ((propertyType == typeof(long)) && (inputProperty.Int64Value.HasValue)) { outputProperty.PropertyInfo.SetValue(t, inputProperty.Int64Value.Value); } else if ((propertyType == typeof(long?)) && (inputProperty.Int64Value.HasValue)) { outputProperty.PropertyInfo.SetValue(t, inputProperty.Int64Value); } else if ((propertyType == typeof(string)) && (inputProperty.StringValue != null)) { outputProperty.PropertyInfo.SetValue(t, inputProperty.StringValue); } else if (inputProperty.StringValue != null) { outputProperty.PropertyInfo.SetValue(t, JsonConvert.DeserializeObject(inputProperty.StringValue, propertyType)); } } } Data = t; }
get => GetValue(EntityProperty); set => SetValue(EntityProperty, value);
static string GetJiaFang(MyRootHtmlNode root) { var Extractor = new EntityProperty(); //这些关键字后面 Extractor.LeadingWordList = new string[] { "甲方:", "发包人:", "发包单位:", "发包方:", "发包机构:", "发包人名称:", "招标人:", "招标单位:", "招标方:", "招标机构:", "招标人名称:", "业主:", "业主单位:", "业主方:", "业主机构:", "业主名称:", "采购单位:", "采购人:", "采购人名称:", "采购方:" }; Extractor.Extract(root); foreach (var item in Extractor.CandidateWord) { var JiaFang = AfterProcessJiaFang(item.Trim()); if (EntityWordAnlayzeTool.TrimEnglish(JiaFang).Length > ContractTraning.MaxJiaFangLength) { continue; } if (JiaFang.Length < 3) { continue; //使用实际长度排除全英文的情况 } Program.Logger.WriteLine("甲方候补词(关键字):[" + JiaFang + "]"); return(JiaFang); } //招标 Extractor = new EntityProperty(); var StartArray = new string[] { "招标单位", "业主", "收到", "接到" }; var EndArray = new string[] { "发来", "发出", "的中标" }; Extractor.StartEndFeature = Utility.GetStartEndStringArray(StartArray, EndArray); Extractor.Extract(root); foreach (var item in Extractor.CandidateWord) { var JiaFang = AfterProcessJiaFang(item.Trim()); JiaFang = JiaFang.Replace("业主", "").Trim(); if (EntityWordAnlayzeTool.TrimEnglish(JiaFang).Length > ContractTraning.MaxJiaFangLength) { continue; } if (JiaFang.Length < 3) { continue; //使用实际长度排除全英文的情况 } Program.Logger.WriteLine("甲方候补词(招标):[" + JiaFang + "]"); return(JiaFang); } //合同 Extractor = new EntityProperty(); StartArray = new string[] { "与", "与业主" }; EndArray = new string[] { "签署", "签订" }; Extractor.StartEndFeature = Utility.GetStartEndStringArray(StartArray, EndArray); Extractor.Extract(root); foreach (var item in Extractor.CandidateWord) { var JiaFang = AfterProcessJiaFang(item.Trim()); JiaFang = JiaFang.Replace("业主", "").Trim(); if (EntityWordAnlayzeTool.TrimEnglish(JiaFang).Length > ContractTraning.MaxJiaFangLength) { continue; } if (JiaFang.Length < 3) { continue; //使用实际长度排除全英文的情况 } Program.Logger.WriteLine("甲方候补词(合同):[" + JiaFang + "]"); return(JiaFang); } return(""); }
private void InitializeMembers() { this.entityReference = new EntityProperty <Entity>(); this.expression = null; }
/// <summary> /// Initializes private members to their default values. /// </summary> private void InitializeMembers() { this.userGuid = Guid.Empty; this.userName = null; this.jobGuid = Guid.Empty; this.jobID = null; this.contextGuid = Guid.NewGuid(); this.isValid = true; this.showHidden = false; this.showDeleted = false; this.connectionString = null; this.connectionMode = Registry.ConnectionMode.None; this.transactionMode = Registry.TransactionMode.None; this.databaseConnection = null; this.databaseTransaction = null; this.activity = null; this.eventOrder = 0; this.clusterProperty = new EntityProperty<Cluster>(this); this.domainProperty = new EntityProperty<Domain>(this); this.federationProperty = new EntityProperty<Federation>(this); }
/// <summary> /// Adds the specified property name. /// </summary> /// <param name="propName">Name of the property.</param> /// <param name="entityProperty">The entity property.</param> public void Add(string propName, EntityProperty entityProperty) { this.Columns.Add(propName, entityProperty); }
/// <summary> /// Generates a complete SELECT statement with an ORDER BY clause that returns all rows in a SQL table, ordered by the given key property. /// </summary> /// <param name="table">The name of the table</param> /// <param name="properties">An enumerable of properties to be included in the SELECT clause</param> /// <param name="key">The property that represents the table's primary key</param> public string SelectAll(string table, IEnumerable<EntityProperty> properties, EntityProperty key) { return String.Format(SelectAllFormat, BuildColumns(properties), table, key.Name); }
private IEnumerable <DynamicTableEntity> GeneratePersistPartitionData(T entity, EntityProperty serializedField, IEnumerable <KeyValuePair <string, EntityProperty> > fields) { List <DynamicTableEntity> result = new List <DynamicTableEntity>(); foreach (var partition in EntityDefinition.GetPartitionsValues(entity)) { var entityIdValues = EntityDefinition.GetIdValues(entity); var idString = string.Join(StorageQueryBuilder.PARTITION_FIELD_SEPARATOR, entityIdValues.Select(StorageQueryBuilder.NormalizeStringValue)); var partitionKey = StorageQueryBuilder.GetPartitionKeyValue(partition.Key, partition.Value); partitionKey = string.Join(StorageQueryBuilder.PARTITION_NAME_SEPARATOR, partition.Key, partitionKey); DynamicTableEntity record = new DynamicTableEntity(partitionKey, StorageQueryBuilder.GetTableKeyNormalizedValue(idString)); record.ETag = "*"; foreach (var field in fields) { if (field.Value != null) { record.Properties.Add(field); } } record.Properties.Add("Content", serializedField); result.Add(record); } return(result); }
private EntityProperty GetAzureTableProperty(object value) { if (value == null) { return(null); } EntityProperty result = null; var valueType = value.GetType(); if (typeof(long) == valueType) { result = new EntityProperty(value == null ? (long?)null : Convert.ToInt64(value)); } else if (typeof(int) == valueType) { result = new EntityProperty(value == null ? (int?)null : Convert.ToInt32(value)); } else if (typeof(short) == valueType) { result = new EntityProperty(value == null ? (short?)null : Convert.ToInt16(value)); } else if (typeof(byte) == valueType) { result = new EntityProperty(value == null ? (byte?)null : Convert.ToByte(value)); } else if (typeof(float) == valueType) { result = new EntityProperty(value == null ? (double?)null : Convert.ToDouble(value)); } else if (typeof(decimal) == valueType) { result = new EntityProperty(value == null ? (double?)null : Convert.ToDouble(value)); } else if (typeof(double) == valueType) { result = new EntityProperty(value == null ? (double?)null : Convert.ToDouble(value)); } else if (typeof(DateTime) == valueType) { result = new EntityProperty(value == null ? (DateTime?)null : Convert.ToDateTime(value)); } else if (typeof(bool) == valueType) { result = new EntityProperty(value == null ? (bool?)null : Convert.ToBoolean(value)); } else if (typeof(string) == valueType) { result = new EntityProperty(value?.ToString()); } else if (valueType.IsEnum) { result = new EntityProperty(value?.ToString()); } else { throw new StorageArgumentException($"Type {valueType.Name} not supported"); } return(result); }
/// <summary> /// 获得合同名 /// </summary> /// <returns></returns> string GetContractName() { var e = new EntityProperty(); e.PropertyName = "合同名称"; e.PropertyType = EntityProperty.enmType.Normal; e.MaxLength = ContractTraning.MaxContractNameLength; e.MinLength = 5; /* 训练模式下 * e.LeadingColonKeyWordList = ContractTraning.ContractNameLeadingDict * .Where((x) => { return x.Value >= 40; }) //阈值40%以上 * .Select((x) => { return x.Key + ":"; }).ToArray(); */ e.LeadingColonKeyWordList = new string[] { "合同名称:" }; e.QuotationTrailingWordList = new string[] { "协议书", "合同书", "确认书", "合同", "协议" }; e.QuotationTrailingWordList_IsSkipBracket = true; //暂时只能选True var KeyList = new List <ExtractPropertyByDP.DPKeyWord>(); KeyList.Add(new ExtractPropertyByDP.DPKeyWord() { StartWord = new string[] { "签署", "签订" }, //通过SRL训练获得 StartDPValue = new string[] { LTPTrainingDP.核心关系, LTPTrainingDP.定中关系, LTPTrainingDP.并列关系 }, EndWord = new string[] { "补充协议", "合同书", "合同", "协议书", "协议", }, EndDPValue = new string[] { LTPTrainingDP.核心关系, LTPTrainingDP.定中关系, LTPTrainingDP.并列关系, LTPTrainingDP.动宾关系, LTPTrainingDP.主谓关系 } }); e.DpKeyWordList = KeyList; var StartArray = new string[] { "签署了", "签订了" }; //通过语境训练获得 var EndArray = new string[] { "合同" }; e.ExternalStartEndStringFeature = Utility.GetStartEndStringArray(StartArray, EndArray); e.ExternalStartEndStringFeatureCandidatePreprocess = (x) => { return(x + "合同"); }; e.MaxLengthCheckPreprocess = str => { return(EntityWordAnlayzeTool.TrimEnglish(str)); }; //最高级别的置信度,特殊处理器 e.LeadingColonKeyWordCandidatePreprocess = str => { var c = Normalizer.ClearTrailing(TrimJianCheng(str)); return(c); }; e.CandidatePreprocess = str => { var c = Normalizer.ClearTrailing(TrimJianCheng(str)); var RightQMarkIdx = c.IndexOf("”"); if (!(RightQMarkIdx != -1 && RightQMarkIdx != c.Length - 1)) { //对于"XXX"合同,有右边引号,但不是最后的时候,不用做 c = c.TrimStart("“".ToCharArray()); } c = c.TrimStart("《".ToCharArray()); c = c.TrimEnd("》".ToCharArray()).TrimEnd("”".ToCharArray()); return(c); }; e.ExcludeContainsWordList = new string[] { "日常经营重大合同" }; //下面这个列表的根据不足 e.ExcludeEqualsWordList = new string[] { "合同", "重大合同", "项目合同", "终止协议", "经营合同", "特别重大合同", "相关项目合同" }; e.Extract(this); //是否所有的候选词里面包括(测试集无法使用) var contractlist = TraningDataset.ContractList.Where((x) => { return(x.id == this.Id); }); if (contractlist.Count() > 0) { var contract = contractlist.First(); var contractname = contract.ContractName; if (!String.IsNullOrEmpty(contractname)) { e.CheckIsCandidateContainsTarget(contractname); } } //置信度 e.Confidence = ContractTraning.ContractES.GetStardardCI(); return(e.EvaluateCI()); }
protected void LoadSystemDatabaseInstance(EntityProperty<DatabaseInstance> databaseInstance, GraywulfDataset dataset, bool forceReinitialize) { if (!AssignedServerInstanceReference.IsEmpty && (databaseInstance.IsEmpty || forceReinitialize)) { dataset.Context = Context; var dd = dataset.DatabaseVersion.Value.DatabaseDefinition; dd.LoadDatabaseInstances(false); foreach (var di in dd.DatabaseInstances.Values) { di.Context = Context; } // Find database instance that is on the same machine try { // TODO: only server instance and database definition is checked here, maybe database version would be better databaseInstance.Value = dd.DatabaseInstances.Values.FirstOrDefault(ddi => ddi.ServerInstanceReference.Guid == AssignedServerInstance.Guid); databaseInstance.Value.GetConnectionString(); } catch (Exception ex) { throw new Exception("Cannot determine system database", ex); // TODO *** } } else if (AssignedServerInstanceReference.IsEmpty) { databaseInstance.Value = null; } }
/// <summary> /// 获得甲方 /// </summary> /// <returns></returns> public string GetJiaFang() { //最高置信度的抽取 EntityProperty e = new EntityProperty(); e.ExcludeContainsWordList = new string[] { "招标代理" }; e.LeadingColonKeyWordList = new string[] { "甲方:", "合同买方:", "发包人:", "发包单位:", "发包方:", "发包机构:", "发包人名称:", "招标人:", "招标单位:", "招标方:", "招标机构:", "招标人名称:", "业主:", "业主单位:", "业主方:", "业主机构:", "业主名称:", "采购单位:", "采购单位名称:", "采购人:", "采购人名称:", "采购方:", "采购方名称:" }; e.CandidatePreprocess = (x => { x = Normalizer.ClearTrailing(x); return(CompanyNameLogic.AfterProcessFullName(x).secFullName); }); e.MaxLength = ContractTraning.MaxJiaFangLength; e.MaxLengthCheckPreprocess = EntityWordAnlayzeTool.TrimEnglish; e.MinLength = 3; e.Extract(this); //这里不直接做Distinct,出现频次越高,则可信度越高 //多个甲方的时候,可能意味着没有甲方! if (e.LeadingColonKeyWordCandidate.Distinct().Count() > 1) { foreach (var candidate in e.LeadingColonKeyWordCandidate) { Program.Logger.WriteLine("发现多个甲方:" + candidate); } } if (e.LeadingColonKeyWordCandidate.Count > 0) { return(e.LeadingColonKeyWordCandidate[0]); } //招标 var Extractor = new ExtractPropertyByHTML(); var CandidateWord = new List <String>(); var StartArray = new string[] { "招标单位", "业主", "收到", "接到" }; var EndArray = new string[] { "发来", "发出", "的中标" }; Extractor.StartEndFeature = Utility.GetStartEndStringArray(StartArray, EndArray); Extractor.Extract(root); foreach (var item in Extractor.CandidateWord) { var JiaFang = CompanyNameLogic.AfterProcessFullName(item.Value.Trim()); if (JiaFang.secFullName.Contains("招标代理")) { continue; //特殊业务规则 } JiaFang.secFullName = JiaFang.secFullName.Replace("业主", String.Empty).Trim(); JiaFang.secFullName = JiaFang.secFullName.Replace("招标单位", String.Empty).Trim(); if (EntityWordAnlayzeTool.TrimEnglish(JiaFang.secFullName).Length > ContractTraning.MaxJiaFangLength) { continue; } if (JiaFang.secFullName.Length < 3) { continue; //使用实际长度排除全英文的情况 } if (!Program.IsMultiThreadMode) { Program.Logger.WriteLine("甲方候补词(招标):[" + JiaFang.secFullName + "]"); } CandidateWord.Add(JiaFang.secFullName); } //合同 Extractor = new ExtractPropertyByHTML(); StartArray = new string[] { "与", "与业主" }; EndArray = new string[] { "签署", "签订" }; Extractor.StartEndFeature = Utility.GetStartEndStringArray(StartArray, EndArray); Extractor.Extract(root); foreach (var item in Extractor.CandidateWord) { var JiaFang = CompanyNameLogic.AfterProcessFullName(item.Value.Trim()); JiaFang.secFullName = JiaFang.secFullName.Replace("业主", String.Empty).Trim(); if (JiaFang.secFullName.Contains("招标代理")) { continue; //特殊业务规则 } if (EntityWordAnlayzeTool.TrimEnglish(JiaFang.secFullName).Length > ContractTraning.MaxJiaFangLength) { continue; } if (JiaFang.secFullName.Length < 3) { continue; //使用实际长度排除全英文的情况 } if (!Program.IsMultiThreadMode) { Program.Logger.WriteLine("甲方候补词(合同):[" + JiaFang.secFullName + "]"); } CandidateWord.Add(JiaFang.secFullName); } return(CompanyNameLogic.MostLikeCompanyName(CandidateWord)); }
public AliasedTestClassTests() { var type = EntityTypes.Register<AliasedTestClass>(tr => { tr.AliasTable("TestClasses"); }); _table = type.Name; _idProperty = type.GetProperty<AliasedTestClass>(t => t.Id); _nameProperty = type.GetProperty<AliasedTestClass>(t => t.Name); _queryGenerator = new SqlServerGenerator(); }
internal static void ReadAndUpdateTableEntityWithEdmTypeResolver(ITableEntity entity, Dictionary <string, string> entityAttributes, EntityReadFlags flags, Func <string, string, string, string, EdmType> propertyResolver, OperationContext ctx) { Dictionary <string, EntityProperty> dictionary = ((flags & EntityReadFlags.Properties) > (EntityReadFlags)0) ? new Dictionary <string, EntityProperty>() : null; Dictionary <string, EdmType> dictionary2 = null; if (entity.GetType() != typeof(DynamicTableEntity)) { if (!TableEntity.DisablePropertyResolverCache) { dictionary2 = TableEntity.PropertyResolverCache.GetOrAdd(entity.GetType(), CreatePropertyResolverDictionary); } else { Logger.LogVerbose(ctx, "Property resolver cache is disabled."); dictionary2 = CreatePropertyResolverDictionary(entity.GetType()); } } if (flags > (EntityReadFlags)0) { foreach (KeyValuePair <string, string> entityAttribute in entityAttributes) { if (entityAttribute.Key == "PartitionKey") { entity.PartitionKey = entityAttribute.Value; } else if (entityAttribute.Key == "RowKey") { entity.RowKey = entityAttribute.Value; } else if (entityAttribute.Key == "Timestamp") { if ((flags & EntityReadFlags.Timestamp) != 0) { entity.Timestamp = DateTime.Parse(entityAttribute.Value, CultureInfo.InvariantCulture); } } else if ((flags & EntityReadFlags.Properties) > (EntityReadFlags)0) { if (propertyResolver != null) { Logger.LogVerbose(ctx, "Using the property resolver provided via TableRequestOptions to deserialize the entity."); try { EdmType edmType = propertyResolver(entity.PartitionKey, entity.RowKey, entityAttribute.Key, entityAttribute.Value); Logger.LogVerbose(ctx, "Attempting to deserialize '{0}' as type '{1}'", entityAttribute.Key, edmType.GetType().ToString()); try { dictionary.Add(entityAttribute.Key, EntityProperty.CreateEntityPropertyFromObject(entityAttribute.Value, edmType.GetType())); } catch (FormatException innerException) { throw new StorageException(string.Format(CultureInfo.InvariantCulture, "Failed to parse property '{0}' with value '{1}' as type '{2}'", entityAttribute.Key, entityAttribute.Value, edmType.ToString()), innerException) { IsRetryable = false }; } } catch (StorageException) { throw; } catch (Exception innerException2) { throw new StorageException("The custom property resolver delegate threw an exception. Check the inner exception for more details.", innerException2) { IsRetryable = false }; } } else if (entity.GetType() != typeof(DynamicTableEntity)) { Logger.LogVerbose(ctx, "Using the default property resolver to deserialize the entity."); if (dictionary2 != null) { dictionary2.TryGetValue(entityAttribute.Key, out EdmType value); Logger.LogVerbose(ctx, "Attempting to deserialize '{0}' as type '{1}'", entityAttribute.Key, value); dictionary.Add(entityAttribute.Key, EntityProperty.CreateEntityPropertyFromObject(entityAttribute.Value, value)); } } else { Logger.LogVerbose(ctx, "No property resolver available. Deserializing the entity properties as strings."); dictionary.Add(entityAttribute.Key, EntityProperty.CreateEntityPropertyFromObject(entityAttribute.Value, typeof(string))); } } } if ((flags & EntityReadFlags.Properties) > (EntityReadFlags)0) { entity.ReadEntity(dictionary, ctx); } } }
protected internal virtual void SetEditorArrangeMetadata(EntityPropertyControl editorElement, EntityProperty entityProperty, Panel parentPanel) { }
public object BuildValue(EntityProperty entityProperty, Type type) { return(unchecked ((uint)(int)entityProperty.Int32Value)); }
public IDictionary <string, EntityProperty> WriteEntity(OperationContext operationContext) { var dictionary = new Dictionary <string, EntityProperty>(); foreach (PropertyMetadata inputProperty in typeMetadata.Properties) { string propertyName = inputProperty.PropertyInfo.Name; Type propertyType = inputProperty.PropertyInfo.PropertyType; object propertyValue = inputProperty.PropertyInfo.GetValue(Data); if (propertyValue != null) { if (propertyType == typeof(bool)) { dictionary[propertyName] = new EntityProperty((bool)(propertyValue)); } else if (propertyType == typeof(bool?)) { dictionary[propertyName] = new EntityProperty((bool?)(propertyValue)); } else if (propertyType == typeof(byte)) { dictionary[propertyName] = new EntityProperty((byte)(propertyValue)); } else if (propertyType == typeof(byte?)) { dictionary[propertyName] = new EntityProperty((byte?)(propertyValue)); } else if (propertyType == typeof(byte[])) { dictionary[propertyName] = new EntityProperty((byte[])(propertyValue)); } else if (propertyType == typeof(decimal)) { dictionary[propertyName] = new EntityProperty((double)(propertyValue)); } else if (propertyType == typeof(decimal?)) { dictionary[propertyName] = new EntityProperty((double?)(propertyValue)); } else if (propertyType == typeof(DateTime)) { dictionary[propertyName] = new EntityProperty((DateTime)(propertyValue)); } else if (propertyType == typeof(DateTime?)) { dictionary[propertyName] = new EntityProperty((DateTime?)(propertyValue)); } else if (propertyType == typeof(double)) { dictionary[propertyName] = new EntityProperty((double)(propertyValue)); } else if (propertyType == typeof(double?)) { dictionary[propertyName] = new EntityProperty((double?)(propertyValue)); } else if (propertyType == typeof(float)) { dictionary[propertyName] = new EntityProperty((float)(propertyValue)); } else if (propertyType == typeof(float?)) { dictionary[propertyName] = new EntityProperty((float?)(propertyValue)); } else if (propertyType == typeof(Guid)) { dictionary[propertyName] = new EntityProperty((Guid)(propertyValue)); } else if (propertyType == typeof(Guid?)) { dictionary[propertyName] = new EntityProperty((Guid?)(propertyValue)); } else if (propertyType == typeof(int)) { dictionary[propertyName] = new EntityProperty((int)(propertyValue)); } else if (propertyType == typeof(int?)) { dictionary[propertyName] = new EntityProperty((int?)(propertyValue)); } else if (propertyType == typeof(long)) { dictionary[propertyName] = new EntityProperty((long)(propertyValue)); } else if (propertyType == typeof(long?)) { dictionary[propertyName] = new EntityProperty((long?)(propertyValue)); } else if (propertyType == typeof(string)) { dictionary[propertyName] = new EntityProperty((string)(propertyValue)); } else { dictionary[propertyName] = new EntityProperty(JsonConvert.SerializeObject(propertyValue, Formatting.Indented)); } } } return(dictionary); }
/// <summary> /// 注册特殊的实体属性,这类属性为附加自实体间关系的不可持久化的属性。 /// </summary> /// <param name="propertyInfo">属性名称。</param> /// <param name="entityType">实体类型。</param> /// <param name="referenceProperty">参数或引用的属性。</param> /// <param name="options">关联选项。</param> /// <returns>一个 <see cref="IProperty"/> 对象。</returns> private static IProperty RegisterSupposedProperty(PropertyInfo propertyInfo, Type entityType, IProperty referenceProperty = null, RelationOptions options = null) { IProperty property; if (referenceProperty != null) { if (referenceProperty.Type.IsEnum) { property = new EnumProperty { Name = propertyInfo.Name, Type = propertyInfo.PropertyType, EntityType = entityType, RelationType = referenceProperty.Type, Reference = referenceProperty, Info = InitRelatedPropertyInfo(propertyInfo), Options = options ?? RelationOptions.Default }; } else { //引用属性 property = new ReferenceProperty { Name = propertyInfo.Name, Type = propertyInfo.PropertyType, EntityType = entityType, RelationType = referenceProperty.EntityType, Reference = referenceProperty, Info = InitRelatedPropertyInfo(propertyInfo), Options = options ?? RelationOptions.Default }; } } else if (typeof(IEntity).IsAssignableFrom(propertyInfo.PropertyType)) { //实体引用属性 property = new EntityProperty { RelationType = propertyInfo.PropertyType, Name = propertyInfo.Name, Type = propertyInfo.PropertyType, EntityType = entityType, Info = InitRelatedPropertyInfo(propertyInfo), Options = options ?? RelationOptions.Default }; } else if (propertyInfo.PropertyType.IsGenericType && typeof(IEntitySet).IsAssignableFrom(propertyInfo.PropertyType)) { //实体集属性 property = new EntitySetProperty { RelationType = propertyInfo.PropertyType.GetGenericArguments()[0], Name = propertyInfo.Name, Type = propertyInfo.PropertyType, EntityType = entityType, Info = InitRelatedPropertyInfo(propertyInfo), Options = options ?? RelationOptions.Default }; } else { throw new NotImplementedException(); } return(RegisterProperty(entityType, property)); }
public void Run(string[] args) { var myEnv = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); if (args.Length == 0) { ListCommand.Run(); return; } if (args[0] == "version" || args[0] == "--version") { WriteHelpHeader($"v{typeof(ProcessCommand).Assembly.GetName().Version}"); return; } if (args[0] == "list" || args[0] == "-h" || args[0] == "--help") { ListCommand.Run(); return; } if (args.Length == 2 && (args[0] == "new:api")) { WriteHelpHeader($"This command has been depricated. If you'd like to create a new project, use the `new:domain` command. If you want to add a new bounded context to an existing project, use the `add:bc` command. Run `craftsman list` for a full list of commands."); } if (args.Length >= 2 && (args[0] == "add:bc" || args[0] == "add:boundedcontext")) { var filePath = args[1]; var verbosity = GetVerbosityFromArgs <AddBcOptions>(args); if (filePath == "-h" || filePath == "--help") { AddBoundedContextCommand.Help(); } else { var rootDir = fileSystem.Directory.GetCurrentDirectory(); if (myEnv == "Dev") { Console.WriteLine("Enter the root directory."); rootDir = Console.ReadLine(); } AddBoundedContextCommand.Run(filePath, rootDir, fileSystem, verbosity); } } if (args.Length >= 2 && (args[0] == "new:domain")) { var filePath = args[1]; var verbosity = GetVerbosityFromArgs <AddBcOptions>(args); if (filePath == "-h" || filePath == "--help") { AddBoundedContextCommand.Help(); } else { var rootDir = fileSystem.Directory.GetCurrentDirectory(); if (myEnv == "Dev") { Console.WriteLine("Enter the root directory."); rootDir = Console.ReadLine(); } NewDomainProjectCommand.Run(filePath, rootDir, fileSystem, verbosity); } } if (args.Length == 2 && (args[0] == "add:entity" || args[0] == "add:entities")) { var filePath = args[1]; var verbosity = GetVerbosityFromArgs <AddEntityOptions>(args); if (filePath == "-h" || filePath == "--help") { AddEntityCommand.Help(); } else { var solutionDir = fileSystem.Directory.GetCurrentDirectory(); if (myEnv == "Dev") { Console.WriteLine("Enter the solution directory."); solutionDir = Console.ReadLine(); } AddEntityCommand.Run(filePath, solutionDir, fileSystem, verbosity); } } if (args.Length > 1 && (args[0] == "add:property" || args[0] == "add:prop")) { if (args[1] == "-h" || args[1] == "--help") { AddEntityPropertyCommand.Help(); } else { var entityName = ""; var newProperty = new EntityProperty(); Parser.Default.ParseArguments <AddPropertyOptions>(args) .WithParsed(options => { entityName = options.Entity.UppercaseFirstLetter(); newProperty = new EntityProperty() { Name = options.Name, Type = options.Type, CanFilter = options.CanFilter, CanSort = options.CanSort, ForeignKeyPropName = options.ForeignKeyPropName }; }); var solutionDir = fileSystem.Directory.GetCurrentDirectory(); if (myEnv == "Dev") { Console.WriteLine("Enter the solution directory."); solutionDir = Console.ReadLine(); } AddEntityPropertyCommand.Run(solutionDir, entityName, newProperty); } } CheckForLatestVersion(); }
internal static async Task ProcessResults() { //CurrentBenchmarkFileId helyett: VerifierBenchmark.ToString() var filename = $"Result_{CurrentBenchmarkId}.xlsx"; var fullfilename = Path.Combine(OutputDirectory.ToString(), filename); if (Program.Offline) { Console.WriteLine($"{DateTime.Now}: Writing results to disk..."); CurrentBenchmark.Dump(fullfilename, CurrentBenchmark.Parameters); } else { //TODO: szinten excelezni json results helyett Console.WriteLine($"{DateTime.Now}: Writing results to disk..."); SerializationHelper.JsonSerializeToFile <BenchmarkResults>(CurrentResults, fullfilename); Console.WriteLine($"{DateTime.Now}: Uploading results to Azure Blob store..."); var blob = Container.GetBlockBlobReference($"Results/{filename}"); await blob.DeleteIfExistsAsync(); await blob.UploadFromFileAsync(fullfilename); Console.WriteLine($"{DateTime.Now}: Writing results to Azure Table store..."); CloudTableClient tableClient = Program.Account.CreateCloudTableClient(); CloudTable table = tableClient.GetTableReference(Program.Experiment + "FinalResults"); await table.CreateIfNotExistsAsync(); var finalResultEntity = new DynamicTableEntity(); finalResultEntity.PartitionKey = filename; finalResultEntity.RowKey = CurrentResultType; finalResultEntity.Properties.Add("Machine", EntityProperty.CreateEntityPropertyFromObject(System.Environment.MachineName)); finalResultEntity.Properties.Add("Frr", EntityProperty.CreateEntityPropertyFromObject(CurrentResults.FinalResult.Frr)); finalResultEntity.Properties.Add("Far", EntityProperty.CreateEntityPropertyFromObject(CurrentResults.FinalResult.Far)); finalResultEntity.Properties.Add("Aer", EntityProperty.CreateEntityPropertyFromObject(CurrentResults.FinalResult.Aer)); var tableOperation = TableOperation.InsertOrReplace(finalResultEntity); await table.ExecuteAsync(tableOperation); table = tableClient.GetTableReference(Program.Experiment + "SignerResults"); await table.CreateIfNotExistsAsync(); var signerResultEntity = new DynamicTableEntity(); signerResultEntity.PartitionKey = filename; foreach (var signerResult in CurrentResults.SignerResults) { signerResultEntity.RowKey = signerResult.Signer; signerResultEntity.Properties["Frr"] = EntityProperty.CreateEntityPropertyFromObject(signerResult.Frr); signerResultEntity.Properties["Far"] = EntityProperty.CreateEntityPropertyFromObject(signerResult.Far); signerResultEntity.Properties["Aer"] = EntityProperty.CreateEntityPropertyFromObject(signerResult.Aer); tableOperation = TableOperation.InsertOrReplace(signerResultEntity); await table.ExecuteAsync(tableOperation); } Console.WriteLine($"{DateTime.Now}: Writing results to MongoDB..."); var document = BsonSerializer.Deserialize <BsonDocument>(SerializationHelper.JsonSerialize <BenchmarkResults>(CurrentResults)); document.Add("Benchmark", filename); document.Add("Machine", System.Environment.MachineName); document.Add("Time", DateTime.Now); document.Add("ResultType", CurrentResultType); var client = new MongoClient("mongodb+srv://sigstat:[email protected]/test?retryWrites=true"); var database = client.GetDatabase("benchmarks"); var collection = database.GetCollection <BsonDocument>("results"); await collection.InsertOneAsync(document); } }
private static T ReadAndResolveWithEdmTypeResolver <T>(Dictionary <string, string> entityAttributes, Func <string, string, DateTimeOffset, IDictionary <string, EntityProperty>, string, T> resolver, Func <string, string, string, string, EdmType> propertyResolver, string etag, Type type, OperationContext ctx) { string pk = null; string rk = null; DateTimeOffset ts = new DateTimeOffset(); Dictionary <string, EntityProperty> properties = new Dictionary <string, EntityProperty>(); Dictionary <string, EdmType> propertyResolverDictionary = null; if (type != null) { propertyResolverDictionary = TableOperationHttpResponseParsers.CreatePropertyResolverDictionary(type); } foreach (KeyValuePair <string, string> prop in entityAttributes) { if (prop.Key == TableConstants.PartitionKey) { pk = (string)prop.Value; } else if (prop.Key == TableConstants.RowKey) { rk = (string)prop.Value; } else if (prop.Key == TableConstants.Timestamp) { ts = DateTimeOffset.Parse(prop.Value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal); if (etag == null) { etag = GetETagFromTimestamp(prop.Value); } } else { if (propertyResolver != null) { Logger.LogVerbose(ctx, SR.UsingUserProvidedPropertyResolver); try { EdmType edmType = propertyResolver(pk, rk, prop.Key, prop.Value); Logger.LogVerbose(ctx, SR.AttemptedEdmTypeForTheProperty, prop.Key, edmType); try { properties.Add(prop.Key, EntityProperty.CreateEntityPropertyFromObject(prop.Value, edmType)); } catch (FormatException ex) { throw new StorageException(string.Format(CultureInfo.InvariantCulture, SR.FailParseProperty, prop.Key, prop.Value, edmType), ex) { IsRetryable = false }; } } catch (StorageException) { throw; } catch (Exception ex) { throw new StorageException(SR.PropertyResolverThrewError, ex) { IsRetryable = false }; } } else if (type != null) { Logger.LogVerbose(ctx, SR.UsingDefaultPropertyResolver); EdmType edmType; if (propertyResolverDictionary != null) { propertyResolverDictionary.TryGetValue(prop.Key, out edmType); Logger.LogVerbose(ctx, SR.AttemptedEdmTypeForTheProperty, prop.Key, edmType); properties.Add(prop.Key, EntityProperty.CreateEntityPropertyFromObject(prop.Value, edmType)); } } else { Logger.LogVerbose(ctx, SR.NoPropertyResolverAvailable); properties.Add(prop.Key, EntityProperty.CreateEntityPropertyFromObject(prop.Value, EdmType.String)); } } } return(resolver(pk, rk, ts, properties, etag)); }
public EntityConstructorProperty(EntityProperty property, EntityProperty derivative) { Property = property; PropertyDerivative = derivative; }
static string GetContractName(MyRootHtmlNode root) { var Extractor = new EntityProperty(); var MarkFeature = new EntityProperty.struMarkFeature(); MarkFeature.MarkStartWith = "《"; MarkFeature.MarkEndWith = "》"; MarkFeature.InnerEndWith = "合同"; var MarkFeatureConfirm = new EntityProperty.struMarkFeature(); MarkFeatureConfirm.MarkStartWith = "《"; MarkFeatureConfirm.MarkEndWith = "》"; MarkFeatureConfirm.InnerEndWith = "确认书"; Extractor.MarkFeature = new EntityProperty.struMarkFeature[] { MarkFeature, MarkFeatureConfirm }; Extractor.Extract(root); foreach (var item in Extractor.CandidateWord) { var ContractName = item.Trim(); if (EntityWordAnlayzeTool.TrimEnglish(ContractName).Length > ContractTraning.MaxContractNameLength) { continue; } Program.Logger.WriteLine("合同名称候补词(《XXX》):[" + item + "]"); return(ContractName); } Extractor = new EntityProperty(); //这些关键字后面 Extractor.LeadingWordList = new string[] { "合同名称:" }; Extractor.Extract(root); foreach (var item in Extractor.CandidateWord) { var ContractName = item.Trim(); if (EntityWordAnlayzeTool.TrimEnglish(ContractName).Length > ContractTraning.MaxContractNameLength) { continue; } Program.Logger.WriteLine("合同名称候补词(关键字):[" + item + "]"); return(ContractName); } //合同 Extractor = new EntityProperty(); var StartArray = new string[] { "签署了" }; var EndArray = new string[] { "合同" }; Extractor.StartEndFeature = Utility.GetStartEndStringArray(StartArray, EndArray); Extractor.Extract(root); foreach (var item in Extractor.CandidateWord) { var ContractName = item.Trim(); if (EntityWordAnlayzeTool.TrimEnglish(ContractName).Length > ContractTraning.MaxContractNameLength) { continue; } Program.Logger.WriteLine("合同候补词(合同):[" + item + "]"); return(ContractName); } return(""); }
/// <summary> /// Is this property synchronized to the DB as a part of a write/update /// </summary> /// <param name="property"></param> /// <returns></returns> public static bool IsSynchronizedProperty(this EntityProperty property) { return(property.PropertyName != "Id" && property.PropertyName != "CreateDate" && property.PropertyName != "LastModifiedDate"); }
private void InitializeMembers(StreamingContext context) { this.context = null; this.databaseDefinition = new EntityProperty<DatabaseDefinition>(); this.databaseVersion = new EntityProperty<DatabaseVersion>(); this.databaseInstance = new EntityProperty<DatabaseInstance>(); }
public void SetGroup(EntityProperty type) { EntityProperties.SetGroup(type); }
private void CopyMembers(GraywulfIdentity old) { this.protocol = old.protocol; this.authorityName = old.authorityName; this.authorityUri = old.authorityUri; this.identifier = old.identifier; this.userProperty = new EntityProperty<User>(old.userProperty); }
public void SetProperty(string name, EntityProperty newValue) { _properties[name] = newValue; }
private EntityProperty InnerAfterCreateTypeProperty(EntityProperty entityProperty) { _properties.Add(entityProperty); InnerXElement.Add(entityProperty.ToXElement()); return entityProperty; }
// Converts a TableEntity to a MetricValue object // TODO: this needs to be made more robust to handle types properly and do conversions as needed private static MetricValue ResolveMetricEntity(DynamicTableEntity entity) { Dictionary <string, string> otherProperties = new Dictionary <string, string>(); MetricValue metricValue = new MetricValue(); EntityProperty timestamp = entity["TIMESTAMP"]; switch (timestamp.PropertyType) { case EdmType.DateTime: metricValue.Timestamp = timestamp.DateTime ?? entity.Timestamp.UtcDateTime; break; case EdmType.String: DateTime value; if (DateTime.TryParse(timestamp.StringValue, out value)) { metricValue.Timestamp = value; } break; default: metricValue.Timestamp = entity.Timestamp.UtcDateTime; break; } foreach (string key in entity.Properties.Keys) { switch (key) { case "Average": metricValue.Average = entity[key].DoubleValue; break; case "Minimum": metricValue.Minimum = entity[key].DoubleValue; break; case "Maximum": metricValue.Maximum = entity[key].DoubleValue; break; case "Total": metricValue.Total = entity[key].DoubleValue; break; case "Count": metricValue.Count = entity[key].PropertyType == EdmType.Int64 ? entity[key].Int64Value : entity[key].Int32Value; break; case "Last": metricValue.Last = entity[key].DoubleValue; break; default: // if it is a string then store it in the properties if (entity[key].PropertyType == EdmType.String) { otherProperties.Add(key, entity[key].StringValue); } break; } } metricValue.Properties = otherProperties; return(metricValue); }
/// <summary> /// Generates a SELECT statement with a WHERE IN clause which selects multiple rows based on one or more primary key values. /// </summary> /// <param name="table">The name of the table</param> /// <param name="properties">An enumerable of properties to be included in the SELECT clause</param> /// <param name="key">The property that represents the table's primary key</param> /// <param name="values">The primary key values that will be passed to the database</param> public string SelectMany(string table, IEnumerable<EntityProperty> properties, EntityProperty key, string values) { return String.Format(SelectManyFormat, BuildColumns(properties), table, key.Name, values); }
public object BuildValue(EntityProperty entityProperty, Type type) { return(entityProperty.BinaryValue); }
/// <summary> /// Generates a DELETE statement for one or more keys. /// </summary> /// <param name="table">The name of the table</param> /// <param name="key">The primary key of the table</param> /// <param name="values">The keys to be deleted</param> public string DeleteMany(string table, EntityProperty key, string values) { return String.Format(DeleteManyFormat, table, key.Name, values); }
public static bool PropertyIsIncludedForEntityRecordInterface(EntityProperty entityProperty) { return(entityProperty.PropertyName != "LastModifiedDate" && entityProperty.PropertyName != "CreateDate"); }
private void CopyMembers(QueryBase old) { this.queryTimeout = old.queryTimeout; this.destination = old.destination; this.isDestinationTableInitialized = old.isDestinationTableInitialized; this.sourceDatabaseVersionName = old.sourceDatabaseVersionName; this.statDatabaseVersionName = old.statDatabaseVersionName; this.tableStatistics = new List<TableReference>(); // *** this.partitions = new List<QueryPartitionBase>(old.partitions.Select(p => (QueryPartitionBase)p.Clone())); this.destinationDatabaseInstance = new EntityProperty<DatabaseInstance>(old.destinationDatabaseInstance); this.partitioningTable = old.partitioningTable; this.partitioningKey = old.partitioningKey; }
/// <summary> /// Helper method used to convert an EntityProperty to a ResourceProperty /// </summary> /// <param name="entityProperty">EntityProperty to convert</param> /// <param name="resourceClassBase">Resource object</param> /// <returns></returns> public static ResourceProperty ToResourceProperty( this EntityProperty entityProperty, ResourceClassBase resourceClassBase) { return(new ResourceProperty(resourceClassBase, entityProperty)); }
bool TryGetProperty(MemberInfo memberInfo, out EntityProperty property) { EditorPropertyAttribute propertyAttribute; if (memberInfo.TryGetAttribute(out propertyAttribute)) { Type memberType = null; switch (memberInfo.MemberType) { case MemberTypes.Field: memberType = (memberInfo as FieldInfo).FieldType; break; case MemberTypes.Property: memberType = (memberInfo as PropertyInfo).PropertyType; break; } var limits = new EntityPropertyLimits(propertyAttribute.Min, propertyAttribute.Max); property = new EntityProperty(memberInfo.Name, propertyAttribute.Description, Entity.GetEditorType(memberType, propertyAttribute.Type), limits, propertyAttribute.Flags); return true; } property = new EntityProperty(); return false; }
public PropertyElement(Entity e, EntityProperty prop) : base(prop.Name) { Entity = e; CellStyle = UITableViewCellStyle.Value2; Property = prop; }
public static void RegisterEntityClass(EntityClassFlags flags, string name, string editorHelper, string editorIcon, string category, string fullyQualifiedName, string pathToAssembly, EntityProperty[] properties) { _RegisterEntityClass(flags, name, editorHelper, editorIcon, category, fullyQualifiedName, pathToAssembly, properties); }
/// <summary> /// Insert Or Replace Entity (Dictionary) /// </summary> /// <remarks> /// Specify: PartitionKey, RowKey and ETag /// </remarks> /// <param name="entity">Entity</param> /// <returns>Result</returns> public virtual async Task <TableResult> InsertOrReplace(IDictionary <string, object> entity) { if (null == entity) { throw new ArgumentNullException("data"); } var properties = new Dictionary <string, EntityProperty>(); entity.Keys.Where(k => k != PartitionKey && k != RowKey && k != ETag).ToList().ForEach(key => properties.Add(key, EntityProperty.CreateEntityPropertyFromObject(entity[key]))); var partitionKey = entity.Keys.Contains(PartitionKey) ? entity[PartitionKey].ToString() : string.Empty; var rowKey = entity.Keys.Contains(RowKey) ? entity[RowKey].ToString() : string.Empty; var etag = entity.Keys.Contains(ETag) ? entity[ETag].ToString() : null; var dynamicEntity = new DynamicTableEntity(partitionKey, rowKey, etag, properties); return(await this.InsertOrReplace(dynamicEntity).ConfigureAwait(false)); }
private string GetPropertyCode(EntityProperty entityProperty) { return string.Format(@" public {0} {1} {{ get; set; }}", entityProperty.FriendlyTypeName, entityProperty.Name); }
private void InitializeMembers(StreamingContext context) { this.syncRoot = new object(); this.context = null; this.scheduler = null; this.queryFactoryTypeName = null; this.queryFactory = new Lazy<QueryFactory>(() => (QueryFactory)Activator.CreateInstance(Type.GetType(queryFactoryTypeName)), false); this.federationReference = new EntityProperty<Federation>(); this.queryString = null; this.defaultDataset = null; this.temporaryDataset = null; this.codeDataset = null; this.customDatasets = new List<DatasetBase>(); /*this.databaseVersionName = null; this.defaultDatasetName = null; this.defaultSchemaName = null;*/ this.executionMode = ExecutionMode.SingleServer; this.isCanceled = false; this.cancelableTasks = new Dictionary<string, ICancelableTask>(); this.assignedServerInstanceReference = new EntityProperty<ServerInstance>(); this.interpretedQueryString = null; this.selectStatement = null; this.temporaryDatabaseInstanceReference = new EntityProperty<DatabaseInstance>(); this.temporaryTables = new ConcurrentDictionary<string, Table>(SchemaManager.Comparer); this.temporaryViews = new ConcurrentDictionary<string, View>(SchemaManager.Comparer); this.codeDatabaseInstanceReference = new EntityProperty<DatabaseInstance>(); }