public void Should_be_possible_to_get_an_item_value() { set setElement = SetFactory.GetSetFromDefinitionsOfRegistryObject("definitionsWithSet.xml", "oval:org.mitre.oval:obj:5000"); object itemValue = setElement.GetItemValue(set_items.set); Assert.IsNotNull(itemValue, "item value not found in set element"); }
// Start is called before the first frame update void Start() { wave.volume = 1f; bgm.volume = 0f; if (fishpoint == Vector3.zero) { fishpoint = fish.transform.position; } if (fadepoint == Vector3.zero) { fadepoint = fade.transform.position; } timer = 0; fade.color = new Color(1f, 1f, 1f, 0f); year.color = new Color(1f, 1f, 1f, 0f); fish.transform.position = fishpoint; fade.transform.position = fadepoint; //vp.enabled = false; vp.Stop(); vp.Prepare(); vppx.enabled = false; vppx.color = new Color(1f, 1f, 1f, 1f); zone = set.start; years = 2019; year.text = years.ToString(); }
void n2019() { fade.color = year.color = new Color(1f, 1f, 1f, 1f); wave.volume = 0f; timer = ptime[1] + ptime[0]; zone = set.n19; }
public void Should_be_possible_to_get_child_set_references() { set setElement = SetFactory.GetSetFromDefinitionsOfRegistryObject("definitionsWithSet.xml", "oval:org.mitre.oval:obj:5000"); IEnumerable <set> objectReferences = setElement.GetSets(); Assert.AreEqual(2, objectReferences.Count(), "the number of sets is not expected"); }
public new async Task <Guid> Save(CourseTask task) { if (task.Id == Guid.Empty) { task.Id = Guid.NewGuid(); } task.Input = null; if (task.RequirementList != null) { foreach (var requirement in task.RequirementList) { if (requirement.Id == Guid.Empty) { requirement.Id = Guid.NewGuid(); } } } await using var conn = new NpgsqlConnection(ConnectionString); await conn.ExecuteAsync( @$ "insert into {PgSchema.task} (id, data) values (@Id, @Data::jsonb) on conflict (id) do update set data = @Data::jsonb", new { task.Id, Data = task }).ConfigureAwait(false); await SaveIndex(conn, task.Id, task).ConfigureAwait(false); return(task.Id); }
private set CreateSetNode(DirectedReference reference, key keyNode, string cascade, collectionFetchMode colFetchMode, string lazyString, bool inverse) { var lazy = (collectionLazy)Enum.Parse(typeof(collectionLazy), lazyString.ToString().Replace("_", ""), true); set setNode = new set(); setNode.name = reference.FromName; setNode.key = keyNode; setNode.cascade = cascade == "none" ? null : cascade; setNode.inverse = inverse; setNode.fetchSpecified = colFetchMode != collectionFetchMode.select; setNode.fetch = colFetchMode; setNode.lazySpecified = lazy != collectionLazy.@true; setNode.lazy = (collectionLazy)Enum.Parse(typeof(collectionLazy), lazy.ToString().Replace("_", ""), true); var sqlWhereClause = NHCollections.GetSqlWhereClause(reference); if (string.IsNullOrEmpty(sqlWhereClause) == false) { setNode.where = sqlWhereClause; } return(setNode); }
public void Should_be_possible_to_evaluate_a_Set_in_the_ObjectType() { OvalDocumentLoader ovalDocument = new OvalDocumentLoader(); sc.oval_system_characteristics systemCharacteristics = ovalDocument.GetFakeOvalSystemCharacteristics("system_characteristics_with_sets.xml"); oval_definitions definitions = ovalDocument.GetFakeOvalDefinitions("definitionsWithSet.xml"); IEnumerable <StateType> states = definitions.states; set registryObjectSet = SetFactory.GetSetFromDefinitionsOfRegistryObject("definitionsWithSet.xml", "oval:org.mitre.oval:obj:6000"); SetEvaluator setEvaluator = new SetEvaluator(systemCharacteristics, states, null); SetResult result = setEvaluator.Evaluate(registryObjectSet); Assert.IsNotNull(result, "the items expected is null"); Assert.AreEqual(3, result.Result.Count(), "the quantity of items is not expected"); Assert.AreEqual(FlagEnumeration.complete, result.ObjectFlag, "the object flag is not expected"); string element = result.Result.Where <string>(item => item == "1").SingleOrDefault(); Assert.IsNotNull(element, "the element expected is not exits"); element = result.Result.Where <string>(item => item == "2").SingleOrDefault(); Assert.IsNotNull(element, "the element expected is not exits"); element = result.Result.Where <string>(item => item == "3").SingleOrDefault(); Assert.IsNotNull(element, "the element expected is not exits"); }
protected override async Task SaveIndex(NpgsqlConnection conn, Guid id, Profile data) { await conn.ExecuteAsync( @$ "insert into {PgSchema.user_index} (id, fio) values (@Id, @Fio) on conflict (id) do update set fio = @Fio", new { id, fio = data.Fio() }).ConfigureAwait(false); }
public void PushSchRowsToArchive(List <UtilSchRow> rows) { // Connect to a PostgreSQL database NpgsqlConnection conn = new NpgsqlConnection(_configuration["ConnectionStrings:WBESArchiveConnection"]); conn.Open(); int batchSize = 100; // insert in batches of 100 rows for (int batchStart = 0; batchStart < rows.Count; batchStart += batchSize) { int batchEnd = batchStart + batchSize - 1; if (batchEnd >= rows.Count) { batchEnd = rows.Count - 1; } string valuesSqlStr = rows.Skip(batchStart).Take(batchEnd - batchStart + 1) .Select(r => $"('{r.UtilName}', '{r.SchDate.ToString("yyyy-MM-dd")}', {r.Block}, '{r.SchType}', {r.SchVal})") .Aggregate((current, next) => current + "," + next); // Define a query NpgsqlCommand command = new NpgsqlCommand(@$ "INSERT INTO public.schedules( sch_utility, sch_date, sch_block, sch_type, sch_val) VALUES {valuesSqlStr} on conflict (sch_utility, sch_date, sch_block, sch_type) do update set sch_val = excluded.sch_val", conn); // Execute the query and obtain a result set int insRes = command.ExecuteNonQuery(); } conn.Close(); }
protected override async Task SaveIndex(NpgsqlConnection conn, Guid id, CourseTask data) { await conn.ExecuteAsync( @$ "insert into {PgSchema.task_index} (id, name) values (@Id, @Name) on conflict (id) do update set name = @Name", new { id, data.Name }).ConfigureAwait(false); }
public async Task <int> SetAsPayed(string order_no, string transaction_id, PayMethodEnum method) { var pay_time = DateTime.UtcNow; var sql = @$ " update {table} set Status=@payed_status, PayTime=@pay_time, ExternalPaymentNo=@transaction_id, PayMethod=@pay_method where OrderNo=@order_no and Status=@where_status "; var p = new { payed_status = (int)OrderStatusEnum.待设计, where_status = (int)OrderStatusEnum.待付款, pay_method = (int)method, order_no = order_no, pay_time = pay_time, transaction_id = transaction_id, }; using (var con = this._dbFactory.GetMetroAdDatabase()) { var count = await con.ExecuteAsync(sql, p); return(count); } }
public void Should_be_possible_to_get_a_value_of_filter_element_in_a_set() { set setElement = SetFactory.GetSetFromDefinitionsOfRegistryObject("definitionsWithSet.xml", "oval:org.mitre.oval:obj:10000"); string filterValue = setElement.GetFilterValue(); Assert.AreEqual("oval:org.mitre.oval:ste:99", filterValue); }
public static void delset(set i) { string r = webget("delset.php?id=" + i.id); if (r.IndexOf("失败")!=-1) { Debug.LogError(r); } }
//拉取用户自定义时用来加入按钮的 void addset(set s) { Transform g = (Transform)Instantiate(cardsetpre, transform.position, transform.rotation); g.parent = transform.parent; g.SendMessage("setinfo", s); playersets.Add(g); transform.Translate(new Vector3(0, 0, -0.525f)); }
void OnMouseUpAsButton() { Material classpic = transform.FindChild("cardsetdaiqi").FindChild("pic").renderer.material; transform.root.SendMessage("setclass", info.classs); transform.root.SendMessage("setclasspic", classpic); transform.root.SendMessage("setClassname", info.name); nowchoose = info; }
void setinfo(set i) { Transform clogo = transform.FindChild("classlogo"); Transform cpic = transform.FindChild("cardsetdaiqi").FindChild("pic"); UILabel namelabel = cpic.transform.parent.FindChild("name").GetComponent<UILabel>(); namelabel.text = i.name; info = i; switch (info.classs) { case CardClass.kdruid: cpic.renderer.material = dly; clogo.renderer.material = ldly; break; case CardClass.khunter: cpic.renderer.material = lr; clogo.renderer.material = llr; break; case CardClass.kmage: cpic.renderer.material = fs; clogo.renderer.material = lfs; break; case CardClass.kpaladin: cpic.renderer.material = sq; clogo.renderer.material = lsq; break; case CardClass.kpriest: cpic.renderer.material = ms; clogo.renderer.material = lms; break; case CardClass.krogue: cpic.renderer.material = dz; clogo.renderer.material = ldz; break; case CardClass.kshama: cpic.renderer.material = sm; clogo.renderer.material = lsm; break; case CardClass.kwarlock: cpic.renderer.material = zs; clogo.renderer.material = lzs; break; case CardClass.kwarrior: cpic.renderer.material = ss; clogo.renderer.material = lss; break; } }
public user_object NewObjectWithSet(user_object firstObject, user_object secondObject) { var newSetElement = new set() { Items = new object[] { firstObject, secondObject } }; return(this.CreateUserObject(newSetElement)); }
/// <summary> /// Gets the ManyToAny of the set if it exists. /// </summary> /// <param name="theSet"></param> /// <returns></returns> public static manytoany ManyToAny(this set theSet) { if (theSet.Item != null && theSet.Item is manytoany) { return((manytoany)theSet.Item); } return(null); }
/// <summary> /// Gets the CompositeElement of the set if it exists. /// </summary> /// <param name="theSet"></param> /// <returns></returns> public static compositeelement CompositeElement(this set theSet) { if (theSet.Item != null && theSet.Item is compositeelement) { return((compositeelement)theSet.Item); } return(null); }
/// <summary> /// Gets the OneToMany of the set if it exists. /// </summary> /// <param name="theSet"></param> /// <returns></returns> public static onetomany OneToMany(this set theSet) { if (theSet.Item != null && theSet.Item is onetomany) { return((onetomany)theSet.Item); } return(null); }
/// <summary> /// Gets the Element of the set if it exists. /// </summary> /// <param name="theSet"></param> /// <returns></returns> public static element Element(this set theSet) { if (theSet.Item != null && theSet.Item is element) { return((element)theSet.Item); } return(null); }
public void Should_be_possible_to_verify_if_a_set_has_another_set() { set setElement = SetFactory.GetSetFromDefinitionsOfRegistryObject("definitionsWithSet.xml", "oval:org.mitre.oval:obj:5000"); Assert.AreEqual(true, setElement.ExistsAnotherSetElement(), "the set element not has another set"); setElement = SetFactory.GetSetFromDefinitionsOfRegistryObject("definitionsWithSet.xml", "oval:org.mitre.oval:obj:6000"); Assert.AreEqual(false, setElement.ExistsAnotherSetElement(), "the set element has another set"); }
//拉取用户自定义时用来加入按钮的 void addset(set s) { Transform g = (Transform)Instantiate(cardsetpre, transform.position, transform.rotation); g.parent = transform.parent; g.SendMessage("setinfo", s); playersets.Add(g); transform.Translate(new Vector3(0, 0, -0.525f)); }
public static void delset(set i) { string r = webget("delset.php?id=" + i.id); if (r.IndexOf("失败") != -1) { Debug.LogError(r); } }
void OnMouseUpAsButton() { Material classpic = transform.FindChild("cardsetdaiqi").FindChild("pic").renderer.material; transform.root.SendMessage("setclass", info.classs); transform.root.SendMessage("setclasspic", classpic); transform.root.SendMessage("setClassname", info.name); nowchoose = info; }
void setinfo(set i) { Transform clogo = transform.FindChild("classlogo"); Transform cpic = transform.FindChild("cardsetdaiqi").FindChild("pic"); UILabel namelabel = cpic.transform.parent.FindChild("name").GetComponent <UILabel>(); namelabel.text = i.name; info = i; switch (info.classs) { case CardClass.kdruid: cpic.renderer.material = dly; clogo.renderer.material = ldly; break; case CardClass.khunter: cpic.renderer.material = lr; clogo.renderer.material = llr; break; case CardClass.kmage: cpic.renderer.material = fs; clogo.renderer.material = lfs; break; case CardClass.kpaladin: cpic.renderer.material = sq; clogo.renderer.material = lsq; break; case CardClass.kpriest: cpic.renderer.material = ms; clogo.renderer.material = lms; break; case CardClass.krogue: cpic.renderer.material = dz; clogo.renderer.material = ldz; break; case CardClass.kshama: cpic.renderer.material = sm; clogo.renderer.material = lsm; break; case CardClass.kwarlock: cpic.renderer.material = zs; clogo.renderer.material = lzs; break; case CardClass.kwarrior: cpic.renderer.material = ss; clogo.renderer.material = lss; break; } }
public static set GetSetFromDefinitionsOfRegistryObject(string definitionsName, string idRegistryObject) { OvalDocumentLoader ovalDocument = new OvalDocumentLoader(); oval_definitions definition = ovalDocument.GetFakeOvalDefinitions(definitionsName); ObjectType objectType = definition.objects.Where(x => x.id == idRegistryObject).SingleOrDefault(); set registryObjectSet = GetSetFromRegistryObject((registry_object)objectType); return(registryObjectSet); }
void newcardset(CardClass c) { Transform g = (Transform)Instantiate(cardsetpre, transform.position, transform.rotation); g.parent = transform.parent; playersets.Insert(playersets.Count-1,g);//插入到最后一位 transform.Translate(new Vector3(0, 0, -0.525f)); set s = new set(); s.id = -1; s.classs = c; g.SendMessage("Createnew", s); }
void mvst() { bgm.volume = 1f; vp.targetCameraAlpha = 1f; //vp.enabled = true; vp.Play(); timer = ptime[3] + ptime[2] + ptime[1] + ptime[0]; if (vp.enabled) { zone = set.mv; } }
public void Should_be_possible_to_get_an_object_references_from_a_set() { set setElement = SetFactory.GetSetFromDefinitionsOfRegistryObject("definitionsWithSet.xml", "oval:org.mitre.oval:obj:7000"); IEnumerable <string> objectReferences = setElement.GetObjectReferences(); Assert.AreEqual(2, objectReferences.Count(), "the number of objectReferences is not expected"); Object firstObject = objectReferences.Where(obj => obj == "oval:org.mitre.oval:obj:4000").SingleOrDefault(); Object secondObject = objectReferences.Where(obj => obj == "oval:org.mitre.oval:obj:2000").SingleOrDefault(); Assert.IsNotNull(firstObject, "the object expected is not found"); Assert.IsNotNull(secondObject, "the object expected is not found"); }
void newcardset(CardClass c) { Transform g = (Transform)Instantiate(cardsetpre, transform.position, transform.rotation); g.parent = transform.parent; playersets.Insert(playersets.Count - 1, g);//插入到最后一位 transform.Translate(new Vector3(0, 0, -0.525f)); set s = new set(); s.id = -1; s.classs = c; g.SendMessage("Createnew", s); }
private DateTime?RecordCurrentStartUtc() { // look for history record up to a millisecond before the current record if (!(View.CurrentObject is Answer ans)) { return(null); } var sql = @$ "declare @dttime datetime select @dttime = getutcdate() update answers set answertext = answertext from answers where id = {ans.Id} select @dttime as Dt "; return(HandyFunctions.RunDateQuery(sql)); }
/// <summary> /// Evaluates the specified setElement /// </summary> /// <param name="set">object that represents a Set</param> /// <returns></returns> public SetResult Evaluate(set setElement) { if (this.systemCharacteristics == null) return new SetResult( new List<String>(),FlagEnumeration.notcollected); if (setElement.ExistsAnotherSetElement()) { return EvaluateOtherSets(setElement); } else { return EvaluateSetElement(setElement); } }
protected override async Task SaveIndex(NpgsqlConnection conn, Guid id, CourseTask data) { await conn.ExecuteAsync( @$ "insert into {PgSchema.task_index} (id, name, max_score, requirements) values (@Id, @Name, @MaxScore, @RequirementList::jsonb) on conflict (id) do update set name = @Name, max_score = @MaxScore, requirements = @RequirementList::jsonb", new { id, data.Name, data.MaxScore, data.RequirementList }).ConfigureAwait(false);
public async Task <Guid> Save(Guid?id, TEntity data) { id ??= Guid.NewGuid(); await using var conn = new NpgsqlConnection(ConnectionString); await conn.ExecuteAsync( @$ "insert into {relationName} (id, data) values (@Id, @Data::jsonb) on conflict (id) do update set data = @Data::jsonb", new { id, data }).ConfigureAwait(false); await SaveIndex(conn, id.Value, data).ConfigureAwait(false); return(id.Value); }
void setinfo(set s) { info = s; if (s.id == -1) { s.name = "新建套牌"; } setname(s.name); switch (s.classs) { case CardClass.kdruid: setpic(dly); break; case CardClass.khunter: setpic(lr); break; case CardClass.kmage: setpic(fs); break; case CardClass.kpaladin: setpic(sq); break; case CardClass.kpriest: setpic(ms); break; case CardClass.krogue: setpic(dz); break; case CardClass.kshama: setpic(sm); break; case CardClass.kwarlock: setpic(ss); break; case CardClass.kwarrior: setpic(zs); break; } }
/// <summary> /// Evaluates the specified setElement /// </summary> /// <param name="set">object that represents a Set</param> /// <returns></returns> public SetResult Evaluate(set setElement) { if (this.systemCharacteristics == null) { return(new SetResult(new List <String>(), FlagEnumeration.notcollected)); } if (setElement.ExistsAnotherSetElement()) { return(EvaluateOtherSets(setElement)); } else { return(EvaluateSetElement(setElement)); } }
private SetResult EvaluateSetElement(set setElement) { List<string> results = new List<string>(); IEnumerable<string> objectReferences = setElement.GetObjectReferences(); IEnumerable<sc.ObjectType> objectTypes = this.GetSystemCharacteristicsObjectType(objectReferences); if (objectTypes.Count() > 0) { if (setElement.HasFilterElement()) { string filterValue = setElement.GetFilterValue(); objectTypes = filterEvaluator.ApplyFilter(objectTypes,filterValue); } return this.ExecuteOperationForSetElement(setElement, objectTypes); } return new SetResult(new List<String>(), FlagEnumeration.notcollected); }
/// <summary> /// Evaluates the setObjects in the tree. This method invokes the Evaluate method in the recursive form. /// The evaluation starts in the more deep level in the tree of objects. /// Then the upper levels will evaluated based on result of the deeper levels. /// </summary> /// <param name="setElement">The set element.</param> /// <returns></returns> private SetResult EvaluateOtherSets(set setElement) { IEnumerable<set> otherSetsElements = setElement.GetSets(); SetResult resultFirstSet = this.Evaluate(otherSetsElements.First()); SetResult resultSecondSet = new SetResult(new List<String>(), FlagEnumeration.notcollected); //the max number of set is 2 (reference: oval_definitions schema) if (otherSetsElements.Count() == MAX_NUMBER_OF_OBJECTS_IN_SET) { resultSecondSet = this.Evaluate(otherSetsElements.ElementAt(1)); } SetOperation operation = this.GetOperation(setElement.set_operator); IEnumerable<string> results = operation.Execute(resultFirstSet.Result, resultSecondSet.Result); FlagEnumeration objectFlag = operation.GetObjectFlag(resultFirstSet.ObjectFlag, resultSecondSet.ObjectFlag); return new SetResult(results, objectFlag); }
public override void PropertyWithOverrideModifier { set { }
protected override void OnProcess(GenerationContext context) { this.context = context; foreach (var e in context.Model.GetEntities()) { logger.Debug(string.Format("{0} working on:", GetType().Name) + e.table); if (IsManyToManyJoin(e)) { var kc = GetKeyColumns(context.GetTableMetaData(e.schema, e.name)); bool hasbag = false; if (kc.Length == 2)//bag: key spawn two columns { hasbag = true; manytoone[] refs = context.Model.GetManyToOnesOfEntity(e.name); for( int i=0;i<refs.Length;++i ) { int other = i == 0?1:0; set set = new set(); set.table = e.table; set.schema = e.schema; set.catalog = e.catalog; set.name = context.NamingStrategy.GetNameForCollection(refs[other].@class,0); set.key = new key() { column1 = refs[i].column }; set.Item = new manytomany() { @class = refs[other].@class ,Items = new column[]{ new column(){ name = refs[other].column}} }; context.Model.AddCollectionToEntity(refs[i].@class,set); logger.Warn(string.Format("Collection {0} on entity {1} is a many to many, need 'inverse' to be specified?",set.name,refs[i].@class)); } } else if( kc.Length==1 ) //idbag: a single column with the pair id. { hasbag = true; manytoone[] refs = context.Model.GetManyToOnesOfEntity(e.name); for (int i = 0; i < refs.Length; ++i) { int other = i == 0 ? 1 : 0; idbag idbag = new idbag(); idbag.collectionid = new collectionid() { column1 = kc[0].Name , type = typeConverter.GetNHType(kc[0]) , length = kc[0].ColumnSize > 0 ? kc[0].ColumnSize.ToString() : null , generator = new generator() { @class = "native" } }; logger.Warn(string.Format("IdBag collection {0} on entity {1}: collection key generator defaults to native",idbag.name,refs[i].@class)); idbag.table = e.table; idbag.schema = e.schema; idbag.catalog = e.catalog; idbag.name = context.NamingStrategy.GetNameForCollection(refs[other].@class, 0); idbag.key = new key() { column1 = refs[i].column }; idbag.Item = new manytomany() { @class = refs[other].@class , Items = new column[] { new column() { name = refs[other].column } } }; context.Model.AddCollectionToEntity(refs[i].@class, idbag); logger.Warn(string.Format("Collection {0} on entity {1} is a many to many, need 'inverse' to be specified?", idbag.name, refs[i].@class)); } } if (hasbag) { RemoveCurrentCollections(e); context.Model.RemoveEntity(e.name); } } } }
/// <summary> /// 拉取用户所有的卡组 /// </summary> /// <returns></returns> public static List<set> getSets() { List<set> ret = new List<set>(); string str = webget("getsets.php?playid=" + player.id); string[] sets = str.Replace("<br />", "@").Split('@'); for (int x = 0; x < sets.Length;x++ ) { if (sets[x]=="") { continue; } string[] setstr = sets[x].Split('&'); set a = new set(); a.id = int.Parse(setstr[0]); a.name = setstr[1]; a.classs = (CardClass)Enum.Parse(typeof(CardClass),setstr[2]); a.cards = setstr[3]; ret.Add(a); } return ret; }
void Createnew(set s) { setinfo(s); OnMouseUpAsButton(); }
private void WireSets() { foreach (string tableToWire in FkForTables.Keys) { logger.Debug(string.Format("{0} working on:", GetType().Name) + tableToWire); Dictionary<string,int> multicolls = new Dictionary<string,int>(); var kinfo = FkForTables[tableToWire]; foreach (var key in kinfo.Keys) { var kdef = kinfo[key]; ITableMetadata ptable = GetPrimaryTable(kdef); ITableMetadata ctable = GetForeignTable(kdef); if (null != ptable) { var collectingClass = context.Model.GetClassFromTableName(ptable.Name); var collectedClass = context.Model.GetClassFromTableName(ctable.Name); if (null == collectedClass) logger.Warn(string.Format("Not included table {0} could not be used in a collection", ctable.Name)); if (null == collectingClass) logger.Warn(string.Format("Target table for a collection of {0} is not included", ptable.Name)); if (null != collectedClass && null != collectingClass) { if (!multicolls.ContainsKey(collectedClass.name)) multicolls[collectedClass.name] = 0; set s = new set(); s.inverse = true; context.Model.AddCollectionToEntity(collectingClass.name, s); s.table = collectedClass.table; s.name = context.NamingStrategy.GetNameForCollection(collectedClass.name, multicolls[collectedClass.name]); s.key = GenerateCollectionKey(kdef); var pkctable = GetKeyColumns(ctable); if (pkctable.Length > 0) // collected object is an entity { s.Item = new onetomany() { @class = context.Model.GetClassFromTableName(ctable.Name).name }; } else { var notanentity = context.Model.GetClassFromTableName(ctable.Name); property[] props = context.Model.GetPropertyOfEntity(notanentity.name); if (props.Length == 1) { //use an element element e = new element(); e.column = props[0].column ?? props[0].name; e.type1 = props[0].type1; e.type = props[0].type; e.precision = props[0].precision; e.length = props[0].length; s.Item = e; } else { //use a composite element compositeelement ce = new compositeelement(); ce.@class = context.NamingStrategy.GetClassNameForCollectionComponent(ctable.Name); ce.Items = context.Model.GetPropertyOfEntity(notanentity.name); s.Item = ce; } context.Model.RemoveEntity(notanentity.name); } } } } } }
private void CheckIfCanBeMap(set set, @class entity) { if (set.Item is onetomany) { var collectedEntity = context.Model.GetClassFromEntityName((set.Item as onetomany).@class); if (collectedEntity.Item is compositeid) { var cid = collectedEntity.Item as compositeid; List<string> setColumn = new List<string>(); if (!string.IsNullOrEmpty(set.key.column1)) setColumn.Add(set.key.column1); if (null != set.key.column) setColumn.AddRange(set.key.column.Select(q => q.name)); List<string> collectedKeyColumns = new List<string>(); collectedKeyColumns.AddRange(cid.Items.OfType<keyproperty>().Select(q => q.column1 ?? q.name)); List<string> nonOverlappingColumns; if (CheckOverlapping(setColumn, collectedKeyColumns, out nonOverlappingColumns)) { setToRemove.Add(set); entitiesToRemove.Add(collectedEntity.name); map map = new map(); map.name = set.name; map.table = set.table; map.key = set.key; var meta = context.GetTableMetaData(collectedEntity.schema, collectedEntity.table ?? collectedEntity.name); if (nonOverlappingColumns.Count == 1) { map.Item = new index() { column1 = nonOverlappingColumns[0], type = typeConverter.GetNHType(meta.GetColumnMetadata(nonOverlappingColumns[0])) }; } else { compositeindex ci = new compositeindex(); ci.@class = context.NamingStrategy.GetClassNameForComponentKey(map.name??map.table); ci.Items = nonOverlappingColumns.Select(q => new keyproperty() { name = context.NamingStrategy.GetPropertyNameFromColumnName(q) ,column1 = context.NamingStrategy.GetPropertyNameFromColumnName(q) != q ? q : null ,type1=typeConverter.GetNHType(meta.GetColumnMetadata(q)) ,length = meta.GetColumnMetadata(q).ColumnSize == 0 ? null:meta.GetColumnMetadata(q).ColumnSize.ToString() }).ToArray(); map.Item = ci; } property[] props = collectedEntity.Items.OfType<property>().ToArray(); if (props.Length == 1) { //use an element element e = new element(); e.column = props[0].column ?? props[0].name; e.type1 = props[0].type1; e.type = props[0].type; e.precision = props[0].precision; e.length = props[0].length; map.Item1 = e; } else { //use a composite element compositeelement ce = new compositeelement(); ce.@class = context.NamingStrategy.GetClassNameForCollectionComponent(collectedEntity.table??collectedEntity.name); ce.Items = context.Model.GetPropertyOfEntity(collectedEntity.name); map.Item1 = ce; } context.Model.AddCollectionToEntity(entity.name, map); } } } }
/// <summary> /// 更新卡组信息,如果卡组id=-1 会插入新记录,并返回一个id.如果成功返回一个空文本 /// </summary> /// <param name="s"></param> public static int updatSet(set s) { string ret= webget("updataset.php?id=" + s.id + "&playid=" + player.id + "&name="+s.name+ "&classs="+s.classs+ "&cards="+s.cards); if (ret=="") { return 0; } else { return int.Parse(ret); } }
private SetResult ExecuteOperationForSetElement(set setElement, IEnumerable<sc.ObjectType> objectTypes) { sc.ObjectType firstObjectType = objectTypes.First(); sc.ObjectType secondObjectType = null; IEnumerable<string> firstReferenceTypes = firstObjectType.GetReferenceTypesInString(); IEnumerable<string> secondReferenceTypes = new List<string>(); FlagEnumeration firstObjectFlag = firstObjectType.flag; FlagEnumeration secondObjectFlag = FlagEnumeration.complete; if (objectTypes.Count() == MAX_NUMBER_OF_OBJECTS_IN_SET) { //the max number to the Object_Reference is 2 (reference: oval_definitions schema) secondObjectType = objectTypes.ElementAt(1); secondReferenceTypes= secondObjectType.GetReferenceTypesInString(); secondObjectFlag = secondObjectType.flag; } SetOperation operation = this.GetOperation(setElement.set_operator); IEnumerable<string> results = operation.Execute(firstReferenceTypes, secondReferenceTypes); FlagEnumeration objectFlag = operation.GetObjectFlag(firstObjectFlag, secondObjectFlag); SetResult result = new SetResult(results, objectFlag); return result; }