private void Entities_AddItem(EntityCollection sender, EntityCollectionEventArgs e) { if (e.Item.Type == EntityType.Leader) { Leader leader = (Leader)e.Item; if (leader.Annotation != null) { entities.Add(leader.Annotation); } } else if (e.Item.Type == EntityType.Hatch) { Hatch hatch = (Hatch)e.Item; foreach (HatchBoundaryPath path in hatch.BoundaryPaths) { foreach (EntityObject entity in path.Entities) { entities.Add(entity); } } } OnEntityAddedEvent(e.Item); e.Item.Owner = this; }
private EntityCollection <TeamEntity> GetTeamsWithSameVenueAndMatchTime(TeamEntity team, RoundEntity round) { var resultTeams = new EntityCollection <TeamEntity>(); var teamStartTime = team.MatchTime; var teamEndTime = teamStartTime?.Add(_tenantContext.TournamentContext.FixtureRuleSet.PlannedDurationOfMatch); // get a list of other teams in this round with same venue and match day-of-the-week var otherTeams = round.TeamCollectionViaTeamInRound.FindMatches((TeamFields.VenueId == team.VenueId) & (TeamFields.MatchDayOfWeek == team.MatchDayOfWeek) & (TeamFields.Id != team.Id)); foreach (var index in otherTeams) { var otherStartTime = round.TeamCollectionViaTeamInRound[index].MatchTime; var otherEndTime = otherStartTime?.Add(_tenantContext.TournamentContext.FixtureRuleSet.PlannedDurationOfMatch); if (otherStartTime <= teamStartTime && otherEndTime >= teamStartTime || otherStartTime <= teamEndTime && otherEndTime >= teamEndTime) { resultTeams.Add(round.TeamCollectionViaTeamInRound[index]); } } // list is expected to contain at least one team resultTeams.Add(team); return(resultTeams); }
public void ICVF_Remove() { EntitySet <City> entitySet; EntityCollection <City> entityCollection = this.CreateEntityCollection(out entitySet); IEditableCollectionView view = this.GetIECV(entityCollection); City city = (City)view.AddNew(); city.Name = "Des Moines"; city.CountyName = "King"; city.StateName = "WA"; view.CommitNew(); entityCollection.Add(this.CreateLocalCity("Normandy Park")); entityCollection.Add(this.CreateLocalCity("SeaTac")); // This one was added through the view and will be removed from both view.Remove(city); Assert.IsFalse(entityCollection.Contains(city), "EntityCollection should no longer contain the first entity."); Assert.IsFalse(entitySet.Contains(city), "EntitySet should no longer contain the first entity."); // This one was added directly and will only be removed for the collection city = entityCollection.ElementAt(1); view.Remove(city); Assert.IsFalse(entityCollection.Contains(city), "EntityCollection should no longer contain the entity at index 1."); Assert.IsTrue(entitySet.Contains(city), "EntitySet should still contain the entity at index 1."); }
private EntityCollection <TeamEntity> GetTeamsWithSameVenueAndMatchTime(TeamEntity team, RoundEntity round) { var resultTeams = new EntityCollection <TeamEntity>(); TimeSpan?teamStartTime = team.MatchTime; TimeSpan?teamEndTime = teamStartTime?.Add(_matchPlanner.PlannedDurationOfMatch); // first get a list of other teams with same venue and match day of the week List <int> tmpTeams = round.TeamCollectionViaTeamInRound.FindMatches(TeamFields.VenueId == team.VenueId & TeamFields.MatchDayOfWeek == (int)team.MatchDayOfWeek & TeamFields.Id != team.Id); foreach (var index in tmpTeams) { TimeSpan?otherStartTime = round.TeamCollectionViaTeamInRound[index].MatchTime; TimeSpan?otherEndTime = otherStartTime?.Add(_matchPlanner.PlannedDurationOfMatch); if ((otherStartTime <= teamStartTime && otherEndTime >= teamStartTime) || (otherStartTime <= teamEndTime && otherEndTime >= teamEndTime)) { resultTeams.Add(round.TeamCollectionViaTeamInRound[index]); } } // list is expected to contain at least one team resultTeams.Add(team); return(resultTeams); }
public virtual void Add(TInterface item) { if (item == null) { underlyingCollection.Add(null); return; } if (ctx != item.Context) { throw new WrongZetboxContextException(); } var impl = item as TImpl; if (impl == null) { throw new ArgumentOutOfRangeException("item", String.Format("item is of wrong type: [{0}] instead of [{1}]", item.GetType().AssemblyQualifiedName, typeof(TImpl).AssemblyQualifiedName)); } NotifyOwnerChanging(); NotifyItemChanging(impl); underlyingCollection.Add(impl); NotifyItemChanged(impl); NotifyOwnerChanged(); }
public void EntityCanBeAdded() { var entity = new Entity(new VariableCollection()); collection.Add(entity); Assert.NotNull(collection.Find((x) => true)); entity.Destroy(); }
private EntityCollection GetGridChildren(EntityCollection collection, PropertyCollection properties, IList fields, string unique, int index, Nullable <int> parent) { EntityCollection results = new EntityCollection(properties); IList uniques = new ArrayList(); IList values = new ArrayList(); for (int i = 0; i < collection.Count; i++) { int id = collection[i].GetValue(unique).ToInt32() + int.MaxValue / 2 + ((int.MaxValue / 2) / fields.Count) * index; object value = collection[i].GetValue(fields[index].ToString()); if (values.Contains(value) == false) { uniques.Add(id); values.Add(value); } } for (int i = 0; i < values.Count; i++) { Entity entity = new Entity(properties); entity.SetValue(unique, uniques[i].ToInt32()); entity.SetValue(fields[index].ToString(), values[i]); if (parent.HasValue == true) { entity.SetValue("_parentId", parent.Value); } results.Add(entity); EntityCollection children = collection.GetEntityCollection(fields[index].ToString(), values[i]); EntityCollection returns; if (index != fields.Count - 1) { returns = this.GetGridChildren(children, properties, fields, unique, index + 1, uniques[i].ToInt32()); } else { returns = this.GetGridChildren(children, properties, uniques[i].ToInt32()); } for (int j = 0; j < returns.Count; j++) { results.Add(returns[j]); } } return(results); }
public void TestIfPrimaryCallTypesFieldsAreBeingFilled() { // Arrange EntityCollection<CS_PrimaryCallType_CallType> primaryCallTypeReference = new EntityCollection<CS_PrimaryCallType_CallType>(); primaryCallTypeReference.Add( new CS_PrimaryCallType_CallType() { ID = 1, PrimaryCallTypeID = 1, CallTypeID = 1, CS_CallType = new CS_CallType() { ID = 1, Description = "Call Type 1", Active = true } }); primaryCallTypeReference.Add( new CS_PrimaryCallType_CallType() { ID = 2, PrimaryCallTypeID = 1, CallTypeID = 2, CS_CallType = new CS_CallType() { ID = 2, Description = "Call Type 2", Active = true } }); CS_PrimaryCallType primaryCallTypeRepeaterDataItem = new CS_PrimaryCallType() { ID = 1, Type = "Primary Call Type", Active = true, CS_PrimaryCallType_CallType = primaryCallTypeReference }; Mock<ICallCriteriaInfoView> view = new Mock<ICallCriteriaInfoView>(); view.SetupProperty(m => m.PrimaryCallTypeRepeaterDataItem, primaryCallTypeRepeaterDataItem); view.SetupProperty(m => m.PrimaryCallTypeRepeaterRowDescription, string.Empty); view.SetupProperty(m => m.PrimaryCallTypeRepeaterRowCallTypeList, new List<CS_PrimaryCallType_CallType>()); // Act CallCriteriaInfoPresenter presenter = new CallCriteriaInfoPresenter(view.Object); presenter.FillPrimaryCallTypeRow(); // Assert Assert.AreEqual("Primary Call Type", view.Object.PrimaryCallTypeRepeaterRowDescription); Assert.AreEqual(2, view.Object.PrimaryCallTypeRepeaterRowCallTypeList.Count); }
/// <summary> /// Charge la map passée en paramètre. /// </summary> /// <param name="map"></param> public void Load(MapFile map) { Passability = map.Passability; // Cherche les spawners des 2 équipes EntityCollection spawners = map.Entities.GetEntitiesByType(EntityType.HeroSpawner); EntityCollection newEntities = new EntityCollection(); // Supprime les entités non-héros foreach (var entity in Entities) { if (entity.Value.Type.HasFlag(EntityType.Player)) { newEntities.Add(entity.Key, entity.Value); // Positionne les héros sur les spawners. var spawnerCol = spawners.GetEntitiesByType(entity.Value.Type & EntityType.Teams); if (spawnerCol.Count > 0) { EntityBase spawner = spawnerCol.First().Value; entity.Value.Position = spawner.Position; } } } foreach (var entity in map.Entities) { newEntities.Add(entity.Key, entity.Value); } // Ajoute les évents. m_events.Clear(); CreateDefaultEvents(); foreach (var kvp in map.Events) { if (!m_events.ContainsKey(kvp.Key) && kvp.Value != null) { m_events.Add(kvp.Key, kvp.Value); } } Entities = newEntities; Vision.SetMap(this); m_refreshEvents = true; if (OnMapModified != null) { OnMapModified(); } }
public int Add(TViewElement item, bool isAddNew) { if (isAddNew) { // Item is added to bindingList, but pending addition to entity collection. _bindingList.Add(item); } else { _entityCollection.Add(item); // OnCollectionChanged will be fired, where the binding list will be updated. } return(_bindingList.Count - 1); }
public List<decimal> GetjournalSum(int periodId, int typeid, int entityid) { using (RecordAccessClient _Client = new RecordAccessClient(EndpointName.RecordAccess)) { if (typeid.Equals(2)) { // Entity _entity = EntityAccessClient _enClient = new EntityAccessClient(EndpointName.EntityAccess); EntityCollection _accountcollection = new EntityCollection(_enClient.QueryAllSubEntity(entityid)); List<decimal> _allandsub = new List<decimal>(); decimal _base = 0; decimal _sgd = 0; _accountcollection.Add(_enClient.Query2(entityid)[0]); foreach (Entity _entity in _accountcollection) { if (_Client.GetjournalSum(periodId, typeid, _entity.EntityID).ToList().Count > 0) { _base += _Client.GetjournalSum(periodId, typeid, _entity.EntityID).ToList()[0]; _sgd += _Client.GetjournalSum(periodId, typeid, _entity.EntityID).ToList()[1]; } } _allandsub.Add(_base); _allandsub.Add(_sgd); return _allandsub.ToList(); } else { return _Client.GetjournalSum(periodId, typeid, entityid).ToList(); } } }
public void SavePodRoomTests(IEnumerable <long> testIds, long podRoomId) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var collection = new EntityCollection <PodRoomTestEntity>(); adapter.FetchEntityCollection(collection, new RelationPredicateBucket(PodRoomTestFields.PodRoomId == podRoomId)); if (collection.Count > 0) { adapter.DeleteEntityCollection(collection); } if (testIds.IsNullOrEmpty()) { return; } collection = new EntityCollection <PodRoomTestEntity>(); foreach (long testId in testIds) { collection.Add(new PodRoomTestEntity(podRoomId, testId)); } adapter.SaveEntityCollection(collection); } }
private EntityCollection GetGridByCollectionAndParent(EntityCollection collection, string parent) { PropertyCollection properties = collection.PropertyCollection; properties.Add(new SimpleProperty("_parentId", typeof(int))); EntityCollection results = new EntityCollection(properties); results.Total = collection.Total; for (int i = 0; i < collection.Count; i++) { Entity entity = new Entity(properties); for (int j = 0; j < properties.Count; j++) { if (properties[j].Name != "_parentId") { entity.SetValue(properties[j].Name, collection[i].GetValue(properties[j].Name)); } } if (collection[i].GetValue(parent) != null) { entity.SetValue("_parentId", collection[i].GetValue(parent)); } results.Add(entity); } return(results); }
//Shows how to create an entity recognizer without loading entries. private void CreateNameParser() { Bot.CreateRecognizer("Name", request => { var requestTest = request.NormalizedText; var entities = new EntityCollection(); DatabaseUtility.Command.CommandText = "SELECT * FROM EMPLOYEES"; var reader = DatabaseUtility.Command.ExecuteReader(); while (reader.Read()) { var name = reader["Name"].ToString(); var wordIndex = requestTest.IndexOf(name, StringComparison.OrdinalIgnoreCase); if (wordIndex != -1) { var entity = new Entity("Name") { Value = name, Index = wordIndex }; entities.Add(entity); } } reader.Close(); return(entities); }); }
public Int64? InsertArea1(ForestArea forestArea, CadastralPoint[] cadastralPoints) { using (var db = new DefaultCS()) { try { if (cadastralPoints != null) { EntityCollection<CadastralPoint> cp = new EntityCollection<CadastralPoint>(); foreach (var cpp in cadastralPoints) { cp.Add(cpp); } forestArea.CadastralPoints1 = cp; } forestArea.CreatedDate = DateTime.Now; db.ForestAreas.AddObject(forestArea); db.SaveChanges(); return forestArea.Id; } catch (Exception ex) { return null; } } }
public static EntityCollection <TElement> CreateCollection <T, TElement>(this T entity, Expression <Func <T, EntityCollection <TElement> > > expr, params TElement[] items) where T : EntityObject where TElement : EntityObject { if (expr.Body.NodeType != ExpressionType.MemberAccess) { throw new ArgumentException("Expression is not correct.", "expr"); } var member = ((MemberExpression)expr.Body).Member; PropertyInfo pi = member as PropertyInfo; if (pi == null) { throw new ArgumentException("Expression is not correct.", "expr"); } EdmRelationshipNavigationPropertyAttribute attribute = (EdmRelationshipNavigationPropertyAttribute)Attribute.GetCustomAttribute(pi, typeof(EdmRelationshipNavigationPropertyAttribute)); EntityCollection <TElement> result = new EntityCollection <TElement>(); RelationshipManager rm = RelationshipManager.Create(entity); rm.InitializeRelatedCollection(attribute.RelationshipName, attribute.TargetRoleName, result); foreach (var item in items) { result.Add(item); } return(result); }
public static void createNewRequisitionList(Dictionary <string, List <RequisitionDetail> > dictionary) { UniversityStoreEntities context = new UniversityStoreEntities(); foreach (KeyValuePair <string, List <RequisitionDetail> > kvp in dictionary) { DateTime d = DateTime.Now; Employee emp = context.Employees.First <Employee>(x => x.EmployeeNumber == kvp.Key); RequisitionList rl = new RequisitionList(); rl.DepartmentCode = emp.DepartmentCode; rl.EmployeeNumber = emp.EmployeeNumber; rl.DateCreated = DateTime.Now; rl.Status = STATUS_PENDING; EntityCollection <RequisitionDetail> listDetails = new EntityCollection <RequisitionDetail>(); foreach (RequisitionDetail detail in kvp.Value) { listDetails.Add(detail); } rl.RequisitionDetails = listDetails; context.AddToRequisitionLists(rl); context.SaveChanges(); } }
public EntityCollection Parse(Request request) { string script; var entities = new EntityCollection(); string dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); using (StreamReader sr = new StreamReader(dir + @"\Helper\RuDateParser.js")) { script = sr.ReadToEnd(); } var dateParse = new Engine().Execute(script).GetValue("ParseDate"); try { dynamic obj = dateParse.Invoke(request.Text).ToObject() as ExpandoObject; if (obj != null && obj?.title != null) { string textdate = obj.title; textdate = textdate.Replace("+ ", "").Trim(); var entity = new DateEntity(obj.title, DateTime.Parse(obj.date)) { Index = request.Text.IndexOf(textdate, StringComparison.Ordinal) }; entities.Add(entity); } } catch (Exception ex) { Debugger.Log(0, nameof(RuDateRecognizer), ex.Message); } return(entities); }
/// <summary> /// Метод для создание массива шариков по концентрической сетке /// </summary> /// <param name="part">деталь</param> /// <param name="sketch">Эскиз</param> /// <param name="type">направлние</param> /// <param name="planeXOZ">плоскость XOZ</param> /// <param name="planeYOZ">плоскость YOZ</param> private static void BallsConcentricArray(ksPart part, ksEntity sketch, short type, ksEntity planeXOZ, ksEntity planeYOZ) { ksEntity rotate = part.NewEntity((short)Obj3dType.o3d_bossRotated); ksBossRotatedDefinition rotDef = rotate.GetDefinition(); rotDef.directionType = type; rotDef.SetSketch(sketch); rotDef.SetSideParam(true, 360); ksRotatedParam rotateParam = rotDef.RotatedParam(); rotate.Create(); //ОСЬ ksEntity axis = part.NewEntity((short)Obj3dType.o3d_axis2Planes); ksAxis2PlanesDefinition axisdef = axis.GetDefinition(); axisdef.SetPlane(1, planeXOZ); axisdef.SetPlane(2, planeYOZ); axis.Create(); //Массив по Кругу ksEntity circrotate = part.NewEntity((short)Obj3dType.o3d_circularCopy); ksCircularCopyDefinition cpyRotDef = circrotate.GetDefinition(); cpyRotDef.SetAxis(axis); cpyRotDef.SetCopyParamAlongDir(8, 45, false, false); EntityCollection circcoll = (cpyRotDef.GetOperationArray()); circcoll.Clear(); circcoll.Add(rotate); circrotate.Create(); }
public void SaveCurrentMedication(long customerId, List <OrderedPair <long, string> > ndcs, long createdByOrgRoleUserId) { DeactiveCurrentMedication(customerId); using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var entities = new EntityCollection <CurrentMedicationEntity>(); foreach (var ndc in ndcs) { entities.Add(new CurrentMedicationEntity { CustomerId = customerId, NdcId = ndc.FirstValue, DateCreated = DateTime.Now, CreatedByOrgRoleUserId = createdByOrgRoleUserId, IsActive = true, IsPrescribed = ndc.SecondValue == "p", IsOtc = ndc.SecondValue == "o", IsNew = true }); } if (adapter.SaveEntityCollection(entities) == 0) { throw new PersistenceFailureException(); } } }
private void UpdateTerritorypackage(long territoryId, IEnumerable <long> packageIds) { IEntityCollection2 territoryPackageEntities = new EntityCollection <TerritoryPackageEntity>(); using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var bucket = new RelationPredicateBucket(TerritoryPackageFields.TerritoryId == territoryId); bucket.PredicateExpression.AddWithAnd(TerritoryPackageFields.PackageId != packageIds.ToArray()); adapter.FetchEntityCollection(territoryPackageEntities, bucket); if (territoryPackageEntities.Count > 0) { adapter.DeleteEntityCollection(territoryPackageEntities); } territoryPackageEntities = new EntityCollection <TerritoryPackageEntity>(); foreach (var packageId in packageIds) { IEntity2 territoryPackageEntity = new TerritoryPackageEntity(territoryId, packageId); if (!adapter.FetchEntity(territoryPackageEntity)) { territoryPackageEntities.Add(territoryPackageEntity); } } if (territoryPackageEntities.Count > 0) { adapter.SaveEntityCollection(territoryPackageEntities); } } }
public static void UpdateManyToMany <TModel, TViewModel>( this EntityCollection <TModel> entityCollection, IEnumerable <TViewModel> viewModelCollection, Func <TViewModel, TModel, bool> compare, Func <TViewModel, TModel> getModel, Action <TModel> onDeleteAction) where TModel : EntityObject where TViewModel : class { var harakiriQuerue = new Queue <TModel>(); // varre todos os elementos atuais do modelo verificando quais alteraram e quais foram deletados foreach (TModel modelObject in entityCollection) { // verifico se existe view-model corresponde com este objeto var matchingViewModel = viewModelCollection.FirstOrDefault(viewModelObject => compare(viewModelObject, modelObject)); if (matchingViewModel == null) { harakiriQuerue.Enqueue(modelObject); } } // deleto os elementos do modelo que não possuem correspondência com o view-model while (harakiriQuerue.Any()) { onDeleteAction(harakiriQuerue.Dequeue()); } foreach (var notMatchingViewModel in viewModelCollection.Where(vm => !entityCollection.Any(m => compare(vm, m)))) { entityCollection.Add(getModel(notMatchingViewModel)); } }
public static EntityCollection LoadFromDatabase(string connectionString) { var entities = new EntityCollection(); var schemaInfo = DatabaseSchemaInfo.LoadFromDatabase(connectionString); foreach (var table in schemaInfo.Tables) { var entity = new Entity { Name = table.Name, Schema = table.Schema, Database = table.Database }; entities.Add(entity); foreach (var column in table.Columns) { var member = new EntityMember { Name = column.Name, DataType = DataTypeInfo.FromSqlDataTypeName(column.DataType, column.IsNullable), MaxLength = column.MaxLength, DecimalPlaces = column.DecimalPlaces, IsNullable = column.IsNullable, IsPrimaryKey = column.IsPrimaryKey, IsIdentity = column.IsIdentity, IsComputed = column.IsComputed, OrdinalPosition = column.OrdinalPosition }; entity.Members.Add(member); } } return entities; }
/// <summary>Associates current record with relatedentity, using specified intersect relationship</summary> /// <param name="container"></param> /// <param name="entity">Current entity</param> /// <param name="relatedentity">Related entity</param> /// <param name="intersect">Name of the intersect relationship/entity</param> /// <remarks>To be used with N:N-relationships.</remarks> /// <exception cref="FaultException{TDetail}"> /// <strong>TDetail</strong> may be typed as: /// <para> /// <see cref="OrganizationServiceFault" />: Thrown when association already exists. /// </para> /// </exception> public static void Associate(this IExecutionContainer container, Entity entity, Entity relatedentity, string intersect) { var collection = new EntityCollection(); collection.Add(relatedentity); container.Associate(entity, collection, intersect); }
/// <summary> /// Ensures the groups specified in this instance's <see cref="AttributeDefinitions"/> are contained in the local collection /// of groups. /// </summary> /// <remarks></remarks> private void EnsureGroupsPopulated() { using (new WriteLockDisposable(_groupLocker)) { if (_groupPopulationValid) { return; } // Get the groups from the attribute definitions. For those that have an ID (i.e. exist), ensure // our copy is distinct. var groupsFromDefs = GetGroupsFromDefsDistinctByAlias(); //<-- changed to distinct by alias not Id var groupsWithId = GetGroupsWithId(groupsFromDefs); var groupsWithoutId = GetGroupsWithoutId(groupsFromDefs); var union = UnionGroups(groupsWithoutId, groupsWithId); // Get the groups from the above selection that we don't already have var compoundAdd = GroupsNotPresent(union); // Add them to our local collection where they don't already exist in our local collection with a valid id compoundAdd.Where(x => !_attributeGroups.Any(y => !y.Id.IsNullValueOrEmpty() && y.Id == x.Id)) .ForEach(x => _attributeGroups.Add(x)); // After adding, check if we have any with matching aliases and remove those with a null ID _attributeGroups.RemoveAll(nullGroup => nullGroup.Id.IsNullValueOrEmpty() && _attributeGroups.Any(y => y.Alias == nullGroup.Alias && !y.Id.IsNullValueOrEmpty())); // Ensure we have distinct groups based on alias _attributeGroups.RemoveAll(existing => !_attributeGroups.DistinctBy(x => x.Alias).Contains(existing)); _groupPopulationValid = true; } }
public static EntityCollection GetCollection() { EntityCollection tempList = null; using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("usp_GetEntity", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.AddWithValue("@QueryId", SelectTypeEnum.GetCollection); myConnection.Open(); using (SqlDataReader myReader = myCommand.ExecuteReader()) { if (myReader.HasRows) { tempList = new EntityCollection(); while (myReader.Read()) { tempList.Add(FillDataRecord(myReader)); } } myReader.Close(); } } } return tempList; }
//private void DeleteOldOwnerMappings(long territoryId) //{ // using (var myAdapter = PersistenceLayer.GetDataAccessAdapter()) // { // IRelationPredicateBucket bucket = new RelationPredicateBucket(HospitalPartnerTerritoryFields.TerritoryId == territoryId); // myAdapter.DeleteEntitiesDirectly(typeof(HospitalPartnerTerritoryEntity), bucket); // bucket = new RelationPredicateBucket(FranchiseeTerritoryFields.TerritoryId == territoryId); // myAdapter.DeleteEntitiesDirectly(typeof(FranchiseeTerritoryEntity), bucket); // bucket = new RelationPredicateBucket(OrganizationRoleUserTerritoryFields.TerritoryId == territoryId); // myAdapter.DeleteEntitiesDirectly(typeof(OrganizationRoleUserTerritoryEntity), bucket); // } //} private void UpdateSalesRepTerritoryOwners(long territoryId, IEnumerable <SalesRepTerritoryAssignment> salesRepTerritoryAssignments) { IEntityCollection2 organizationRoleUserTerritoryEntities = new EntityCollection <OrganizationRoleUserTerritoryEntity>(); foreach (var salesRepTerritoryAssignment in salesRepTerritoryAssignments) { // TODO: Ashutosh is looking into it //OrganizationRoleUser organizationRoleUser = _organizationRoleUserRepository. // GetOrganizationRoleUser(salesRepTerritoryAssignment.SalesRep.Id, // (long)Roles.SalesRep, salesRepTerritoryAssignment.SalesRep. // SalesRepresentativeId); OrganizationRoleUser organizationRoleUser = new OrganizationRoleUser(); IEntity2 organizationRoleUserTerritoryEntity = new OrganizationRoleUserTerritoryEntity(territoryId, organizationRoleUser.Id) { EventTypeSetupPermission = (int)salesRepTerritoryAssignment. EventTypeSetupPermission }; organizationRoleUserTerritoryEntities.Add(organizationRoleUserTerritoryEntity); } using (var myAdapter = PersistenceLayer.GetDataAccessAdapter()) { myAdapter.SaveEntityCollection(organizationRoleUserTerritoryEntities); } }
public static EntityCollection GetCollection() { EntityCollection tempList = null; using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("usp_GetEntity", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.AddWithValue("@QueryId", SelectTypeEnum.GetCollection); myConnection.Open(); using (SqlDataReader myReader = myCommand.ExecuteReader()) { if (myReader.HasRows) { tempList = new EntityCollection(); while (myReader.Read()) { tempList.Add(FillDataRecord(myReader)); } } myReader.Close(); } } } return(tempList); }
//Shows how to create an entity recognizer without loading entries. private void AddEmployeeNameRecognizer() { try { Bot.CreateRecognizer("Name", request => { var requestTest = request.NormalizedText; var entities = new EntityCollection(); foreach (var emp in FullEmployeeList) { var name = emp.Name; var wordIndex = requestTest.IndexOf(name, StringComparison.OrdinalIgnoreCase); if (wordIndex != -1) { var entity = new Entity("Name") { Value = name, Reference = name, Index = wordIndex }; entities.Add(entity); } } return(entities); }); } catch (Exception e) { Console.WriteLine(e); } }
private void SaveHealthPlanResultTestDependency(long accountId, IEnumerable <long> healthPlanResultTestDependency) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { //Delete all Dependency First adapter.DeleteEntitiesDirectly(typeof(AccountHealthPlanResultTestDependencyEntity), new RelationPredicateBucket(AccountHealthPlanResultTestDependencyFields.AccountId == accountId)); if (healthPlanResultTestDependency.IsNullOrEmpty()) { return; } var entities = new EntityCollection <AccountHealthPlanResultTestDependencyEntity>(); //Insert new Test dependecy foreach (long testId in healthPlanResultTestDependency) { entities.Add(new AccountHealthPlanResultTestDependencyEntity(accountId, testId)); } if (adapter.SaveEntityCollection(entities) == 0) { throw new PersistenceFailureException(); } } }
public EntityCollection Parse(Request request) { string script; var entities = new EntityCollection(); using (StreamReader sr = new StreamReader(@"C:\Users\iShyr\documents\visual studio 2017\Projects\NureBot\NureBot\Helper\RuDateParser.js")) { script = sr.ReadToEnd(); } var dateParse = new Engine().Execute(script).GetValue("ParseDate"); try { dynamic obj = dateParse.Invoke(request.Text).ToObject() as ExpandoObject; if (obj != null && obj?.title != null) { string textdate = obj.title; textdate = textdate.Replace("+ ", "").Trim(); var entity = new DateEntity(obj.title, DateTime.Parse(obj.date)) { Index = request.Text.IndexOf(textdate, StringComparison.Ordinal) }; entities.Add(entity); } } catch (Exception ex) { Debugger.Log(0, nameof(RuDateRecognizer), ex.Message); } return(entities); }
public IEnumerable <CustomerChaseChannel> SaveCustomerChaseChannels(IEnumerable <CustomerChaseChannel> domains) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var linqMetaData = new LinqMetaData(adapter); var entities = new EntityCollection <CustomerChaseChannelEntity>(); foreach (var domain in domains) { var entity = (from ccp in linqMetaData.CustomerChaseChannel where ccp.CustomerId == domain.CustomerId && ccp.ChaseChannelLevelId == domain.ChaseChannelLevelId select ccp).SingleOrDefault(); if (entity == null) { entities.Add(Mapper.Map <CustomerChaseChannel, CustomerChaseChannelEntity>(domain)); } } if (adapter.SaveEntityCollection(entities) == 0) { throw new PersistenceFailureException(); } return(Mapper.Map <IEnumerable <CustomerChaseChannelEntity>, IEnumerable <CustomerChaseChannel> >(entities)); } }
public void SaveRequiredTests(long customerId, IEnumerable <long> testIds, long createdByOrgRoleUserId, int forYear) { DeactiveRequiredTests(customerId, forYear); using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var entities = new EntityCollection <RequiredTestEntity>(); foreach (var testId in testIds) { entities.Add(new RequiredTestEntity { CustomerId = customerId, TestId = testId, CreatedDate = DateTime.Now, CreatedBy = createdByOrgRoleUserId, IsActive = true, ForYear = forYear, IsNew = true }); } if (adapter.SaveEntityCollection(entities) == 0) { throw new PersistenceFailureException(); } } }
/// <summary> /// 获取数据通过Command /// </summary> /// <typeparam name="T"></typeparam> /// <param name="command">SQL</param> /// <returns></returns> public static EntityCollection <T> Select <T>(string queryString, DataAccessParameterCollection parameters, CommandType cmdType) where T : EntityBase, new() { EntityCollection <T> result = new EntityCollection <T>(); using (DataAccessBroker broker = DataAccessFactory.Instance()) { IDataReader reader = broker.ExecuteReader(queryString, parameters, cmdType); int fieldCount = reader.FieldCount; List <string> columns = new List <string>(); object[] values = new object[fieldCount]; for (int i = 0; i < fieldCount; i++) { columns.Add(reader.GetName(i)); } while (reader.Read()) { T t = new T(); reader.GetValues(values); for (int i = 0; i < fieldCount; i++) { if (!(values[i] == DBNull.Value)) { t.SetData(columns[i], values[i]); t.GetData(columns[i]); } } result.Add(t); } } return(result); }
public void SaveAccountAddtionalFieldDependency(long accountId, IEnumerable <AccountAdditionalFields> accountAdditionalFields) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { //Delete all additional field of this account adapter.DeleteEntitiesDirectly(typeof(AccountAdditionalFieldsEntity), new RelationPredicateBucket(AccountAdditionalFieldsFields.AccountId == accountId)); if (accountAdditionalFields.IsNullOrEmpty()) { return; } var entities = new EntityCollection <AccountAdditionalFieldsEntity>(); //Insert new Test dependecy foreach (var additionFilds in accountAdditionalFields) { additionFilds.AccountId = accountId; var entity = AutoMapper.Mapper.Map <AccountAdditionalFields, AccountAdditionalFieldsEntity>(additionFilds); entities.Add(entity); } if (adapter.SaveEntityCollection(entities) == 0) { throw new PersistenceFailureException(); } } }
public void TestConcatOperator() { EntityCollection<TestAccountEntity> entities = new EntityCollection<TestAccountEntity>(); entities.Add(new TestAccountEntity(100, 5)); entities.Add(new TestAccountEntity(102, 8)); EntityCollection<TestAccountEntity> entities0 = new EntityCollection<TestAccountEntity>(); entities0.Add(new TestAccountEntity(103, 15)); entities0.Add(new TestAccountEntity(104, 2)); IEnumerable<TestAccountEntity> result = entities.Concat(entities0); Assert.IsNotNull(result); foreach (TestAccountEntity entity in result) { Assert.IsNotNull(entity); Console.WriteLine(entity); } }
public static EntityCollection entityCollectioin(EntityCollection ec, EntityCollection entityCollection) { foreach (var entity in entityCollection) { ec.Add(entity); if (entity.SubEntities.Count() > 0) entityCollectioin(ec, entity.SubEntities); } return ec; }
public void TestAffiliateEntityCollection() { TestEntity affiliate = new TestEntity(); affiliate.Id = 1000; TestEntity affiliate0 = new TestEntity(); affiliate0.Id = 1001; TestEntity affiliate1 = new TestEntity(); affiliate1.Id = 1002; EntityCollection<TestEntity> collection = new EntityCollection<TestEntity>(); collection.Add(affiliate); collection.Add(affiliate0); collection.Add(affiliate1); foreach (TestEntity aff in collection) { Console.WriteLine("Affiliate: {0}", aff.Id); } }
public Int64? InsertArea(ForestArea forestArea, ForestCoordinate[] forestCoordinates) { using (var db = new DefaultCS()) { try { EntityCollection<ForestCoordinate> fc = new EntityCollection<ForestCoordinate>(); foreach (var fcc in forestCoordinates) { fc.Add(fcc); } forestArea.ForestCoordinates = fc; forestArea.CreatedDate = DateTime.Now; db.ForestAreas.AddObject(forestArea); db.SaveChanges(); return forestArea.Id; } catch (Exception ex) { return null; } } }
public EntityCollection GetEntities(User user) { EntityCollection collection = new EntityCollection(); using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandText = "SP_Frank_TEST"; SqlParameter ColumnParam = command.Parameters.Add("@User_ID", System.Data.SqlDbType.Int); ColumnParam.Value = user.UserID; command.CommandType = System.Data.CommandType.StoredProcedure; connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { Entity entity = new Entity(); entity.EntityID = Convert.ToInt32(reader["ID"]); entity.EntityName = reader["Name"].ToString(); entity.EntityType = (EntityType)Convert.ToInt32(reader["Type"]); entity.Currency.CurrencyID = reader["Currency"].ToString(); entity.ExchangeRate = Convert.ToDecimal(reader["Exchange_Rate"]); entity.SumType = (SumType)Convert.ToInt32(reader["SumType"]); collection.Add(entity); } } return collection; } }
public void GenerateEmailBodyForInvoicingTeamTest() { DateTime dt = new DateTime(2011, 02, 14); TimeSpan timeSpan = new TimeSpan(10, 11, 59); CS_Country country = new CS_Country() { ID = 1, Active = true, Name = "USA" }; CS_State state = new CS_State() { ID = 1, Active = true, Name = "Texas" }; CS_City city = new CS_City() { ID = 1, Active = true, Name = "Dalton" }; CS_LocationInfo locationInfo = new CS_LocationInfo() { Active = true, CountryID = 1, StateID = 1, CityID = 1, CS_Country = country, CS_State = state, CS_City = city }; CS_Frequency frequency = new CS_Frequency() { Active = true, ID = 1, Description = "D" }; CS_JobDescription csJobDescription = new CS_JobDescription() { Active = true, NumberEmpties = 1, NumberLoads = 2, NumberEngines = 1 }; CS_Division division = new CS_Division() { ID = 241, Active = true, Name = "005", Description = "White River, Ontario" }; CS_JobDivision jobdivision = new CS_JobDivision() { Active = true, JobID = 243, DivisionID = 241, CS_Division = division }; CS_Employee employee = new CS_Employee() { ID = 1, Active = true, Name = "Dcecilia", FirstName = "Test", DivisionID = 241 }; CS_Reserve reserve = new CS_Reserve() { Active = true, JobID = 243, Type = 2, CS_Employee = employee, DivisionID = 241 }; EntityCollection<CS_JobDivision> JobDivision = new EntityCollection<CS_JobDivision>(); JobDivision.Add(jobdivision); CS_ScopeOfWork csScopeOfWork = new CS_ScopeOfWork() { Active = true, ScopeOfWork = "xxcxcxc", JobId = 243 }; EntityCollection<CS_Reserve> csReserves = new EntityCollection<CS_Reserve>(); csReserves.Add(reserve); EntityCollection<CS_ScopeOfWork> scopeOfWorks = new EntityCollection<CS_ScopeOfWork>(); scopeOfWorks.Add(csScopeOfWork); //Arrange FakeObjectSet<CS_Job> fakeJobObject = new FakeObjectSet<CS_Job>(); fakeJobObject.AddObject ( new CS_Job() { ID = 243, Active = true, CreatedBy = "rbrandao", CreationDate = DateTime.Now, ModificationDate = DateTime.Now, ModifiedBy = "Load", //Internal_Tracking = "000000025INT", Number = "000243", CS_ScopeOfWork = scopeOfWorks, CS_JobDivision = JobDivision, CS_Reserve = csReserves, CS_CustomerInfo = new CS_CustomerInfo() { Active = true, CS_Customer = new CS_Customer() { Active = true, Name = "American Test" }, CS_Division = division, CS_Contact1 = new CS_Contact() { ID = 1, Active = true, Name = "danilo", LastName = "cecilia", }, CS_Contact3 = new CS_Contact() { ID = 1, Active = true, Name = "danilo", LastName = "cecilia", }, //IsCustomer = true, InitialCustomerContactId = 1, BillToContactId = 1 }, CS_JobInfo = new CS_JobInfo() { Active = true, InterimBill = true, CS_Employee = employee, EmployeeID = employee.ID, CS_Frequency = frequency, FrequencyID = 1, CS_JobAction = new CS_JobAction() { Active = true, Description = "Environmental Work, General - Undefined Scope of Work" }, CS_JobType = new CS_JobType() { Active = true, Description = "A" }, InitialCallDate = dt, InitialCallTime = timeSpan, CS_PriceType = new CS_PriceType() { Active = true, Acronym = "P", Description = "description test" }, CS_JobCategory = new CS_JobCategory() { Active = true, Description = "B" }, CS_Job_JobStatus = new EntityCollection<CS_Job_JobStatus>() { new CS_Job_JobStatus() { Active = true, JobStatusId = (int)Globals.JobRecord.JobStatus.Active, JobStartDate = new DateTime(2011,02,14), JobCloseDate = new DateTime(2011,02,14) } } }, CS_LocationInfo = locationInfo, CS_JobDescription = csJobDescription } ); //Act Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>(); mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_Job>()).Returns(fakeJobObject); JobModel jobModel = new JobModel(mockUnitOfWork.Object); string body = jobModel.GenerateEmailBodyForInvoicingTeam(243); StringBuilder sb = new StringBuilder(); sb.Append("<div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Job#:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" PA000243"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Customer:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" American Test"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Initial Customer Contact:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" danilo"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Bill to:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" cecilia, danilo"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Initial Call date:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 02/14/2011"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Initial Call time:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 10:11:59"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Price Type:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" description test"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Job Action:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" Environmental Work, General - Undefined Scope of Work"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Job Category:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" B"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Job Type:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" A"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Division:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 005"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Interim Bill:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" Yes"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Requested By:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" Dcecilia, Test"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Frequency:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" D"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Country:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" USA"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("State:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" Texas"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("City:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" Dalton"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Number Engines:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 1"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Number Loads:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 2"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Number Empties:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 1"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Scope Of Work:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append("xxcxcxc"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Job start date:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 02/14/2011 00:00:00"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Job end date:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 02/14/2011 00:00:00"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("</div>"); //Assert Assert.AreEqual(sb.ToString(), body); }
private void GrabarOpciones() { bool registroSatisfactoriamente = false; Usuario objUsuario=(Usuario)Session[Constantes.sesionUsuario]; EntityCollection<RolOpcionSistema> entRolOpciones = new EntityCollection<RolOpcionSistema>(); //recorre los nodos de las opciones del sistema for (int i = 0; i < tviewOpciones.Nodes.Count; i++) { for (int x = 0; x < tviewOpciones.Nodes[i].ChildNodes.Count; x++) { RolOpcionSistema objOpciones = new RolOpcionSistema(); objOpciones.ROS_UsuarioModificacion = objUsuario.IDUsuario.ToString(); objOpciones.ROS_UsuarioCreacion = objUsuario.IDUsuario.ToString(); objOpciones.IDOpcionSistema = Convert.ToInt32(tviewOpciones.Nodes[i].ChildNodes[x].Value); objOpciones.ROS_FechaAsignacion = DateTime.Now; objOpciones.ROS_FechaHoraModificacion = DateTime.Now; if (tviewOpciones.Nodes[i].ChildNodes[x].Checked == true) { objOpciones.ROS_Estado = Constantes.EstadoActivo; } else { objOpciones.ROS_Estado = Constantes.EstadoEliminado; } entRolOpciones.Add(objOpciones); } } if (!EsNuevoRegistro()) { //actualizar int idRol = Convert.ToInt32(Request["idRol"]); Rol objRol = RolBL.Instancia.ObtenerRolByID(idRol); objRol.ROL_Nombre = txtRol.Text; objRol.ROL_Descripcion = txtDescripcion.Text; objRol.ROL_Estado = Constantes.EstadoActivo; objRol.ROL_UsuarioModificacion = objUsuario.IDUsuario.ToString(); objRol.ROL_FechaHoraModificacion = DateTime.Now; if (objRol.RolOpcionSistema == null) { objRol.RolOpcionSistema = new EntityCollection<RolOpcionSistema>(); } try { RolBL.Instancia.Actualizar(objRol, entRolOpciones); registroSatisfactoriamente = true; } catch { registroSatisfactoriamente = false; } } else { //insertar nuevo rol Rol objRol = new Rol(); objRol.ROL_Nombre = txtRol.Text; objRol.ROL_Descripcion = txtDescripcion.Text; objRol.ROL_Estado = Constantes.EstadoActivo; objRol.ROL_UsuarioCreacion = objUsuario.IDUsuario.ToString(); objRol.ROL_FechaHoraCreacion = DateTime.Now; objRol.RolOpcionSistema = entRolOpciones; try { RolBL.Instancia.Insertar(objRol); int id = objRol.IDRol; objRol.ROL_Codigo = "ROL" + id.ToString().PadLeft(7, '0'); RolBL.Instancia.Actualizar(objRol); registroSatisfactoriamente = true; IEnumerable<RolOpcionSistema> objRolOpcionSistema = null; CargarOpciones(objRolOpcionSistema); txtDescripcion.Text = ""; txtRol.Text = ""; } catch { registroSatisfactoriamente = false; } } if (registroSatisfactoriamente) { ClientScript.RegisterStartupScript(this.GetType(), "miscriptError", "$(function(){MostrarMensaje('msjSatisfactorio');});", true); } }
public void SetCallLogViewCallEntryRowData() { //Arrange FakeObjectSet<CS_FirstAlert> fakeFirstAlert = new FakeObjectSet<CS_FirstAlert>(); CS_FirstAlertType csFirstAlertType = new CS_FirstAlertType() { Active = true, Description = "injury", CreatedBy = "dcecilia", CreationDate = new DateTime(10, 10, 10, 5, 0, 1), ModifiedBy = "dcecilia", ModificationDate = new DateTime(10, 10, 10, 5, 0, 1), }; CS_FirstAlertFirstAlertType csFirstAlertFirstAlertType = new CS_FirstAlertFirstAlertType() { Active = true, FirstAlertID = 1, FirstAlertTypeID = 1, CreatedBy = "dcecilia", CreationDate = new DateTime(10, 10, 10, 5, 0, 1), ModifiedBy = "dcecilia", ModificationDate = new DateTime(10, 10, 10, 5, 0, 1), CS_FirstAlertType = csFirstAlertType }; EntityCollection<CS_FirstAlertFirstAlertType> entityCollectionFirstAlertFirstAlertType = new EntityCollection<CS_FirstAlertFirstAlertType>(); entityCollectionFirstAlertFirstAlertType.Add(csFirstAlertFirstAlertType); DateTime currentDate = DateTime.Now; CS_Customer csCustomer = new CS_Customer() { ID = 1, Active = true, Name = "Abcd", Country = "USA", CustomerNumber = "1000" }; CS_Job csJob = new CS_Job() { ID = 1, Active = true, CreatedBy = "dcecilia", CreationDate = currentDate, ModifiedBy = "dcecilia", ModificationDate = currentDate, Number = "123" }; CS_FirstAlert csFirstAlert = new CS_FirstAlert() { ID = 1, Active = true, Number = "123", JobID = 1, CS_Job = csJob, CustomerID = 1, CS_Customer = csCustomer, Details = "aaAaA", Date = currentDate, HasPoliceReport = true, CreatedBy = "dcecilia", CreationDate = currentDate, ModifiedBy = "dcecilia", ModificationDate = new DateTime(2011, 7, 12, 5, 0, 0), CS_FirstAlertFirstAlertType = entityCollectionFirstAlertFirstAlertType, }; CS_Division csDivision = new CS_Division() { Active = true, ID = 1, Name = "001" }; CS_FirstAlertDivision csFirstAlertDivision = new CS_FirstAlertDivision() { Active = true, ID = 1, FirstAlertID = 1, DivisionID = 1, CS_Division = csDivision, CS_FirstAlert = csFirstAlert }; Mock<IFirstAlertView> mock = new Mock<IFirstAlertView>(); mock.SetupProperty(c => c.FirstAlertRowDataItem, csFirstAlert); mock.SetupProperty(c => c.FirstAlertRowAlertDateAndTime, ""); mock.SetupProperty(c => c.FirstAlertRowAlertId, ""); mock.SetupProperty(c => c.FirstAlertRowAlertNumber, ""); mock.SetupProperty(c => c.FirstAlertRowCustomer, ""); mock.SetupProperty(c => c.FirstAlertRowDivision, ""); mock.SetupProperty(c => c.FirstAlertRowFirstAlertType, ""); mock.SetupProperty(c => c.FirstAlertRowJobNumber, ""); //Act FirstAlertViewModel viewModel = new FirstAlertViewModel(mock.Object); viewModel.SetDetailedFirstAlertRowData(); // Assert Assert.AreEqual(currentDate.ToString("MM/dd/yyyy") + " " + currentDate.ToShortTimeString(), mock.Object.FirstAlertRowAlertDateAndTime, "Failed in FirstAlertRowAlertDateAndTime"); Assert.AreEqual("1", mock.Object.FirstAlertRowAlertId, "Failed in FirstAlertRowAlertId"); Assert.AreEqual("123", mock.Object.FirstAlertRowAlertNumber, "Failed in FirstAlertRowAlertNumber"); Assert.AreEqual("Abcd - USA - 1000", mock.Object.FirstAlertRowCustomer, "Failed in FirstAlertRowCustomer"); Assert.AreEqual("001", mock.Object.FirstAlertRowDivision, "Failed in FirstAlertRowDivision"); Assert.AreEqual("injury", mock.Object.FirstAlertRowFirstAlertType, "Failed in FirstAlertRowFirstAlertType"); Assert.AreEqual("123", mock.Object.FirstAlertRowJobNumber, "Failed in FirstAlertRowJobNumber"); }
public EntityCollection QueryAllSub(string entityName) { EntityCollection collection = new EntityCollection(); using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandText = "SP_SEL_Table"; SqlParameter _param = command.Parameters.Add("@value1", System.Data.SqlDbType.VarChar); _param.Value = "Entity"; SqlParameter _param2 = command.Parameters.Add("@value2", System.Data.SqlDbType.VarChar); _param2.Value = "3"; SqlParameter _param3 = command.Parameters.Add("@value3", System.Data.SqlDbType.VarChar); _param3.Value = entityName; SqlParameter _param4 = command.Parameters.Add("@order_by1", System.Data.SqlDbType.VarChar); _param4.Value = "1"; SqlParameter _param5 = command.Parameters.Add("@order_by2", System.Data.SqlDbType.TinyInt); _param5.Value = 0; command.CommandType = System.Data.CommandType.StoredProcedure; connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { Entity _entity = new Entity(); _entity.EntityID = Convert.ToInt32(reader["ID"]); _entity.ParentID = Convert.ToInt32(reader["ParentID"]); _entity.EntityName = reader["Entity_Name"].ToString(); _entity.EntityType = (EntityType)Convert.ToInt32(reader["Entity_Type"]); _entity.SumType = (SumType)Convert.ToInt32(reader["SumType"]); _entity.Currency.CurrencyID = reader["Currency"].ToString(); _entity.ExchangeRate = Convert.ToDecimal(reader["Exchange_Rate"]); _entity.IsAccount = Convert.ToInt32(reader["IsAccount"]); _entity.Enable = Convert.ToInt32(reader["Enable"]); _entity.IsLastLevel = Convert.ToInt32(reader["IsLastLevel"]); if (_entity.Enable == 1) { collection.Add(_entity); } } } reader.Close(); return collection; } }
EntityCollection<ProductInCatalogEntity> getGetListCat(ProductsEntity product) { EntityCollection<ProductInCatalogEntity> items = new EntityCollection<ProductInCatalogEntity>(); int[] cats = ucCatalogs.getListCatId(); for (int i = 0; i < cats.Length; i++) { ProductInCatalogEntity item = new ProductInCatalogEntity(); item.ProductId = product.Id; item.CatId = cats[i]; item.OrderIndex = i; items.Add(item); } return items; }
private void SetAuthorThemes(EntityCollection<Theme> themes, IEnumerable<int> themeIds) { // получаем коллекцию тем, выбранных пользователем на форме var selectedThemes = db.Theme.Where(t => themeIds.Contains(t.id)); // очищаем список старых тем themes.Clear(); // заполняем список тем теми которые выбрал пользователь if (themeIds != null) { foreach (var theme in selectedThemes) { themes.Add(theme); } } }
public EntityCollection QueryTransactionList(int entityID) { EntityCollection _transactionCollection = new EntityCollection(); EntityCollection _collection = new EntityCollection(QueryAllSub(entityID)); foreach (Entity _entity in _collection) { if(_entity.SumType==SumType.Transaction) _transactionCollection.Add(_entity); QueryTransactionList(_entity.EntityID); } return _transactionCollection; }
public void TestTakeWhileOperator() { EntityCollection<TestAccountEntity> entities = new EntityCollection<TestAccountEntity>(); entities.Add(new TestAccountEntity(100, 5)); entities.Add(new TestAccountEntity(102, 8)); entities.Add(new TestAccountEntity(101, 15)); entities.Add(new TestAccountEntity(101, 2)); IEnumerable<TestAccountEntity> result = entities.TakeWhile( delegate(TestAccountEntity entity) { return (entity.Amount < 10) ? true : false; }); Assert.IsNotNull(result); foreach (TestAccountEntity entity in result) { Assert.IsNotNull(entity); Console.WriteLine(entity); } }
public void TestOrderByOperator() { EntityCollection<TestAccountEntity> entities = new EntityCollection<TestAccountEntity>(); entities.Add(new TestAccountEntity(100, 5)); entities.Add(new TestAccountEntity(102, 8)); entities.Add(new TestAccountEntity(103, 15)); entities.Add(new TestAccountEntity(104, 2)); IEnumerable<TestAccountEntity> result = entities.OrderBy<long>( delegate(TestAccountEntity entity) { return entity.Amount; }); Assert.IsNotNull(result); foreach (TestAccountEntity entity in result) { Assert.IsNotNull(entity); Console.WriteLine(entity); } }
public void TestGetCSV() { TestEntity affiliate = new TestEntity(); affiliate.Id = 1000; affiliate.Description = "desc 1"; TestEntity affiliate0 = new TestEntity(); affiliate0.Id = 1001; affiliate0.Description = "desc 2"; TestEntity affiliate1 = new TestEntity(); affiliate1.Id = 1002; affiliate1.Description = "desc 3"; String[] stringArray = new string[] { "amin", "abel" }; affiliate1.StringArray = stringArray; EntityCollection<TestEntity> collection = new EntityCollection<TestEntity>(); collection.Add(affiliate); collection.Add(affiliate0); collection.Add(affiliate1); Console.Write(collection.GetCSV()); }
//--------------------------------------------------- //Get Service from JSON request private Service getServiceFromJsonRequest() { string json = new StreamReader(Request.InputStream).ReadLine(); int start = json.IndexOf('['); int end = json.IndexOf(']'); String test = json.Substring(start, end - start + 1); WeightRangeService[] wrs = JS.Deserialize<WeightRangeService[]>(test); EntityCollection<WeightRangeService> collection = new EntityCollection<WeightRangeService>(); foreach (WeightRangeService wr in wrs) { collection.Add(wr); } Service service = JS.Deserialize<Service>(json); service.WeightRangeService = collection; return service; }
public static EntityCollection ExtractEntities(string Text) { EntityCollection entitys = new EntityCollection(); if (Text.Contains("@") || Text.Contains("@")) { MatchCollection matchs = EXTRACT_MENTIONS.Matches(Text); foreach (Match match in matchs) { if (!SCREEN_NAME_MATCH_END.Match(match.Groups[EXTRACT_MENTIONS_GROUP_USERNAME].Value).Success) { MentionEntity uninitializedObject = (MentionEntity)FormatterServices.GetUninitializedObject(typeof(MentionEntity)); uninitializedObject.StartIndex = match.Groups[EXTRACT_MENTIONS_GROUP_USERNAME].Index - 1; uninitializedObject.EndIndex = match.Groups[EXTRACT_MENTIONS_GROUP_USERNAME].Index + match.Groups[EXTRACT_MENTIONS_GROUP_USERNAME].Length; uninitializedObject.ScreenName = match.Groups[EXTRACT_MENTIONS_GROUP_USERNAME].Value.Replace("@", "").Trim(); entitys.Add(uninitializedObject); } } } if (Text.Contains("#") || Text.Contains("#")) { MatchCollection matchs2 = AUTO_LINK_HASHTAGS.Matches(Text); foreach (Match match in matchs2) { HashTagEntity item = (HashTagEntity)FormatterServices.GetUninitializedObject(typeof(HashTagEntity)); item.StartIndex = match.Groups[AUTO_LINK_HASHTAGS_GROUP_HASH].Index; item.EndIndex = (match.Groups[AUTO_LINK_HASHTAGS_GROUP_HASH].Index + match.Groups[AUTO_LINK_HASHTAGS_GROUP_HASH].Length) + match.Groups[AUTO_LINK_HASHTAGS_GROUP_TAG].Length; item.Text = match.Groups[AUTO_LINK_HASHTAGS_GROUP_TAG].Value; entitys.Add(item); } } if (Text.Contains(":") || Text.Contains(".")) { MatchCollection matchs3 = VALID_URL.Matches(Text); foreach (Match match in matchs3) { if (!string.IsNullOrEmpty(match.Groups[VALID_URL_GROUP_PROTOCOL].Value)) { UrlEntity entity3 = (UrlEntity)FormatterServices.GetUninitializedObject(typeof(UrlEntity)); entity3.StartIndex = match.Groups[VALID_URL_GROUP_URL].Index; entity3.EndIndex = match.Groups[VALID_URL_GROUP_URL].Index + match.Groups[VALID_URL_GROUP_URL].Length; entity3.Url = match.Groups[VALID_URL_GROUP_URL].Value; entitys.Add(entity3); } } } return entitys; }
/// <summary> /// Creates a collection of entities from a collection go IFiles. /// </summary> /// <returns>The entities.</returns> /// <param name="files">Files.</param> public static EntityCollection MakeEntities(IEnumerable<IFile> files) { EntityCollection entities = new EntityCollection(); ParallelOptions parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = 8 }; switch (CheckProjectType(files)) { case ProjectType.CSharp: CsParser csParser = new CsParser(); Parallel.ForEach(files.Where(x => Path.GetExtension(x.Path) == ".cs"), parallelOptions, item => { entities.Add(csParser.Parse(item), item.Date.DateTime, item.Revisions); }); break; case ProjectType.Unicon: IcnParser icnParser = new IcnParser(); Parallel.ForEach(files.Where(x => Path.GetExtension(x.Path) == ".icn"), parallelOptions, item => { entities.Add(icnParser.Parse(item), item.Date.DateTime, item.Revisions); }); break; case ProjectType.Java: JavaParser javaParser = new JavaParser(); Parallel.ForEach(files.Where(x => Path.GetExtension(x.Path) == ".java"), parallelOptions, item => { entities.Add(javaParser.Parse(item), item.Date.DateTime, item.Revisions); }); break; } return entities; }
private void SetArticleAuthors(EntityCollection<Author> authors, IEnumerable<int> authorIds) { // получаем коллекцию авторов, выбранных пользователем на форме var selectedAuthors = db.Author.Where(t => authorIds.Contains(t.id)); // очищаем список старых авторов authors.Clear(); // заполняем список авторов теми которых выбрал пользователь if (authorIds != null) { foreach (var author in selectedAuthors) { authors.Add(author); } } }
public void GenerateEmailBodyForEstimationTeamTest() { DateTime dt = new DateTime(2011, 02, 14); CS_JobDescription csJobDescription = new CS_JobDescription() { Active = true, NumberEmpties = 1, NumberLoads = 2, NumberEngines = 1 }; CS_Division division = new CS_Division() { ID = 241, Active = true, Name = "005", Description = "White River, Ontario" }; CS_JobDivision jobdivision = new CS_JobDivision() { Active = true, JobID = 243, DivisionID = 241, CS_Division = division }; CS_Employee employee = new CS_Employee() { Active = true, Name = "Dcecilia", FirstName = "Test", DivisionID = 241 }; CS_Reserve reserve = new CS_Reserve() { Active = true, JobID = 243, Type = 2, CS_Employee = employee, DivisionID = 241 }; EntityCollection<CS_JobDivision> JobDivision = new EntityCollection<CS_JobDivision>(); JobDivision.Add(jobdivision); CS_ScopeOfWork csScopeOfWork = new CS_ScopeOfWork() { Active = true, ScopeOfWork = "xxcxcxc", JobId = 243 }; EntityCollection<CS_Reserve> csReserves = new EntityCollection<CS_Reserve>(); csReserves.Add(reserve); EntityCollection<CS_ScopeOfWork> scopeOfWorks = new EntityCollection<CS_ScopeOfWork>(); scopeOfWorks.Add(csScopeOfWork); //Arrange FakeObjectSet<CS_Job> fakeJobObject = new FakeObjectSet<CS_Job>(); fakeJobObject.AddObject ( new CS_Job() { ID = 243, Active = true, CreatedBy = "rbrandao", CreationDate = DateTime.Now, ModificationDate = DateTime.Now, ModifiedBy = "Load", Internal_Tracking = "000000025INT", CS_ScopeOfWork = scopeOfWorks, CS_JobDivision = JobDivision, CS_Reserve = csReserves, CS_CustomerInfo = new CS_CustomerInfo() { Active = true, CS_Customer = new CS_Customer() { Active = true, Name = "Test Customer" }, CS_Division = division }, CS_JobInfo = new CS_JobInfo() { Active = true, CS_JobAction = new CS_JobAction() { Active = true, Description = "Environmental Work, General - Undefined Scope of Work" }, CS_JobType = new CS_JobType() { Active = true, Description = "A" }, CS_PriceType = new CS_PriceType() { Active = true, Acronym = "P" }, CS_Job_JobStatus = new EntityCollection<CS_Job_JobStatus>() { new CS_Job_JobStatus() { JobStatusId = (int)Globals.JobRecord.JobStatus.Bid, JobStartDate = new DateTime(2011,02,14), Active = true } } }, CS_JobDescription = csJobDescription } ); Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>(); mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_Job>()).Returns(fakeJobObject); JobModel jobModel = new JobModel(mockUnitOfWork.Object); string body = jobModel.GenerateEmailBodyForEstimationTeam(243); StringBuilder sb = new StringBuilder(); sb.Append("<div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Proposal#:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" ##"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Job#:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" PA000000025INT"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Customer:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" Test Customer"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Division:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 005"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("JobType:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" A"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("JobAction:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" Environmental Work, General - Undefined Scope of Work"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Scope Of Work:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append("xxcxcxc"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Job start date:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append("02/14/2011 00:00:00"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Employee:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" Dcecilia, Test"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Number Engines:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 1"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Number Loads:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 2"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Number Empties:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 1"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("</div>"); Assert.AreEqual(sb.ToString(), body); }
public void TestDataViewEntityCollection() { TestEntity affiliate = new TestEntity(); affiliate.Id = 1000; TestEntity affiliate0 = new TestEntity(); affiliate0.Id = 1001; TestEntity affiliate1 = new TestEntity(); affiliate1.Id = 1002; EntityCollection<TestEntity> collection = new EntityCollection<TestEntity>(); collection.Add(affiliate); collection.Add(affiliate0); collection.Add(affiliate1); foreach (TestEntity aff in collection) { Console.WriteLine("Affiliate: {0}", aff.Id); } DataView view = collection.GetDataView(typeof(TestEntity)); view.ToString(); }
public void TestListFilteredFirstAlert() { //Arrange FakeObjectSet<CS_FirstAlert> fakeFirstAlert = new FakeObjectSet<CS_FirstAlert>(); CS_FirstAlertType csFirstAlertType = new CS_FirstAlertType() { Active = true, Description = "injury", CreatedBy = "dcecilia", CreationDate = new DateTime(10, 10, 10, 5, 0, 1), ModifiedBy = "dcecilia", ModificationDate = new DateTime(10, 10, 10, 5, 0, 1), }; CS_FirstAlertFirstAlertType csFirstAlertFirstAlertType = new CS_FirstAlertFirstAlertType() { Active = true, FirstAlertID = 1, FirstAlertTypeID = 1, CreatedBy = "dcecilia", CreationDate = new DateTime(10, 10, 10, 5, 0, 1), ModifiedBy = "dcecilia", ModificationDate = new DateTime(10, 10, 10, 5, 0, 1), CS_FirstAlertType = csFirstAlertType }; EntityCollection<CS_FirstAlertFirstAlertType> entityCollectionFirstAlertFirstAlertType = new EntityCollection<CS_FirstAlertFirstAlertType>(); entityCollectionFirstAlertFirstAlertType.Add(csFirstAlertFirstAlertType); fakeFirstAlert.AddObject(new CS_FirstAlert() { Active = true, Number = "123", JobID = 1, CustomerID = 1, Details = "aaAaA", Date = new DateTime(2011, 7, 12, 5, 0, 0), HasPoliceReport = true, CreatedBy = "dcecilia", CreationDate = new DateTime(2011, 7, 12, 5, 0, 0), ModifiedBy = "dcecilia", ModificationDate = new DateTime(2011, 7, 12, 5, 0, 0), CS_FirstAlertFirstAlertType = entityCollectionFirstAlertFirstAlertType, }); Mock<IUnitOfWork> mock = new Mock<IUnitOfWork>(); mock.Setup(w => w.CreateObjectSet<CS_FirstAlert>()).Returns(fakeFirstAlert); FirstAlertModel model = new FirstAlertModel(mock.Object); //Act IList<CS_FirstAlert> results = model.ListFilteredFirstAlert(Globals.FirstAlert.FirstAlertFilters.IncidentType, "injury" ); //Assert Assert.AreEqual(1, results.Count); }
public void TestEntityCollectionMerge() { EntityCollection<TestEntity> collection = new EntityCollection<TestEntity>(); TestEntity lead = new TestEntity(); lead.Id = 1000; collection.Add(lead); EntityCollection<TestEntity> otherCollection = new EntityCollection<TestEntity>(); TestEntity otherLead = new TestEntity(); otherLead.Id = 2000; otherCollection.Add(otherLead); collection.Merge(otherCollection); foreach (TestEntity tempLead in collection) { Console.WriteLine("Lead: " + tempLead.Id); } }
public void TestEntityCollectionOperatorOverloading() { EntityCollection<TestEntity> collection = new EntityCollection<TestEntity>(); TestEntity lead = new TestEntity(); lead.Id = 1000; collection.Add(lead); EntityCollection<TestEntity> otherCollection = new EntityCollection<TestEntity>(); TestEntity otherLead = new TestEntity(); otherLead.Id = 2000; otherCollection.Add(otherLead); EntityCollection<TestEntity> finalCollection = collection + otherCollection; foreach (TestEntity tempLead in finalCollection) { Console.WriteLine("Lead: " + tempLead.Id); } }
public void mock_customers_only_where_in_germany() { NorthwindEntities fake_entity_model = null; var mock_repo = new Mock<EntitiesRepository<Customer, NorthwindEntities>> (fake_entity_model); var germany_cust_spec = new Specification<Customer>(c => c.Country == "Germany"); var orders = new EntityCollection<Order>(); orders.Add(new Order{Freight = 10M}); orders.Add(new Order{Freight = 23M}); mock_repo.Expect (repo => repo.AllToIList<ICustomerMakePrefered>()) .Returns(new List<Customer>() { new Customer() { CustomerID = "ALFKI", Country = "Germany", Orders = orders }, new Customer() { CustomerID = "SIMSE", Country = "Australia" } }); var results = mock_repo.Object.AllToIList<ICustomerMakePrefered>(); var cust = results.Where(germany_cust_spec.EvalFunc).First(); cust.Makeprefered(); Assert.That(cust.Orders.Sum(o => o.Freight) == 0); Assert.AreEqual(results.Count, 2); Assert.AreEqual(results.First().Country, "Germany"); Assert.AreEqual(mock_repo.Object.AllToIList<ICustomerMakePrefered>().Count, 2); }