public void Test() { Family family = new Family(); Child child1 = new Child(1); Child child2 = new Child(2); Parent parent = new Parent(new List<Child>() {child1, child2}); family.Add(parent); string file = "sandbox.txt"; try { File.Delete(file); } catch { } using (var fs = File.OpenWrite(file)) { Serializer.Serialize(fs, family); } using (var fs = File.OpenRead(file)) { family = Serializer.Deserialize<Family>(fs); } System.Diagnostics.Debug.Assert(family != null, "1. Expect family not null, but not the case."); }
/// <summary> /// construct function. /// </summary> /// <param name="doorFamily"> one door family</param> /// <param name="app">Revit application</param> public DoorFamily(Family doorFamily, UIApplication app) { m_app = app; m_family = doorFamily; // one door instance which belongs to this family and neither flipped nor mirrored. m_oneInstance = CreateOneInstanceWithThisFamily(); }
public Panos_1(String SVGPanos1String) { int tempInt; String[] valuesString = SVGPanos1String.Split(' '); if (int.TryParse(valuesString[0], out tempInt)) family = (Family)tempInt; if (int.TryParse(valuesString[1], out tempInt)) serifStyle = (Serif_Style)tempInt; if (int.TryParse(valuesString[2], out tempInt)) weight = (Weight)tempInt; if (int.TryParse(valuesString[3], out tempInt)) proportion = (Proportion)tempInt; if (int.TryParse(valuesString[4], out tempInt)) contrast = (Contrast)tempInt; if (int.TryParse(valuesString[5], out tempInt)) strokeVariation = (Stroke_Variation)tempInt; if (int.TryParse(valuesString[6], out tempInt)) armStyle = (Arm_Style)tempInt; if (int.TryParse(valuesString[7], out tempInt)) letterform = (Letterform)tempInt; if (int.TryParse(valuesString[8], out tempInt)) midline = (Midline)tempInt; if (int.TryParse(valuesString[0], out tempInt)) xHeight = (XHeight)tempInt; }
public bool OnSharedFamilyFound(Family sharedFamily, bool familyInUse, out FamilySource source, out bool overwriteParameterValues) { source = FamilySource.Family; overwriteParameterValues = true; return true; }
internal void FamilyDestroyed() { Family = null; if (Hp > 0) { Village.AddEmptyHouse(this); } }
public void init() { allFamilies.Clear(); Family zeroFamily = new Family(0, 0, 0, ""); addToAllFamilies(zeroFamily); // This will serve as the root of the tree and Generation 0, Adam and Eve can be Generation 1 myPeople.init(); }
public Mission(string nm, Family fam, int rep) { name = nm; steps = new List<MissionStep>(); progress = 0; maxProgress = 0; targetFamily = fam; repReward = rep; currentStep = 0; }
/// <summary> /// Método para registrar familia. /// </summary> /// <param name="family"></param> /// <returns></returns> public FamilyDto RegisterFamily(FamilyDto family) { using(DutiesFamilyEntities dataContext = new DutiesFamilyEntities()) { var familyCreated = new Family(); familyCreated.FamilyName = family.FamilyName; familyCreated.Image = family.Image; familyCreated.Password = family.Password; dataContext.Family.Add(familyCreated); dataContext.SaveChanges(); family.IdFamily = familyCreated.IdFamily; } return family; }
static void Main(string[] args) { Family familyDB = new Family(); if(familyDB.son("jack", "tom")) System.Console.WriteLine("Yeah!"); System.Console.WriteLine("Who is the father of john? "); AbstractTerm f = new AbstractTerm(); familyDB.father(f, "john"); System.Console.WriteLine(f); }
internal override void JustCollapsed() { if (Hp == 0 && Family != null) { foreach (Villager v in Family.FamilyMembers) { v.HouseCollapsed(); } Family = null; } //Debug.Assert(Village.EmptyHouseList.Contains(this), "JustCollapsed - emptyHouseList"); //if (Hp == 0 && Family == null) //{ // Village.RemoveEmptyHouse(this); //} }
public bool CreateFamily(string orgName, string currUser, string famUserName = "") { var creator = _repo.Query<ApplicationUser>().Where(m => m.UserName == currUser).Include(m => m.Familys).FirstOrDefault(); if (_repo.Query<Family>().Where(m => m.OrgName == orgName).FirstOrDefault() == null) { var newFam = new Family { OrgName = orgName, FamilyUserName = orgName, CreatedBy = creator, MemberList = new List<FamilyUser> { new FamilyUser { UserId = creator.Id } } }; _repo.Add<Family>(newFam); _repo.SaveChanges(); return true; } return false; }
// get a family from the pool public Family getFamily() { Family family = null; if (_families.Count > 0) { family = _families.First(); _families.Remove(family); } else { // if the pool is empty, make a new family and refill the pool family = new Family(); refillFamilyPool(); } // return the reference to the family return family; }
public static Family CreateFamily(Family family) { var f = new Family() { EnterpriseId = CurrentUser.Principal.EnterpriseID, BusinessUnitId = CurrentUser.Principal.BusinessUnitID, CreatedBy = CurrentUser.Principal.MemberID, Image = family.Image ?? String.Empty, Name = family.Name ?? String.Empty, IsActive = true, ModifiedDate = DateTime.Now.ToString(), CreatedDate = DateTime.Now.ToString(), }; Entity<Family>.Save(f); AddFamilyMember(f.Id, CurrentUser.Principal.MemberID); return f; }
private void radioBaseDrop_CheckChanged(object sender, EventArgs e) { if (rdoYellow.Checked) { droppingBaseFor = Family.Yellow; } else if (rdoRed.Checked) { droppingBaseFor = Family.Red; } else if (rdoBlue.Checked) { droppingBaseFor = Family.Blue; } else if (rdoOrange.Checked) { droppingBaseFor = Family.Orange; } }
public int StartFamily(int treePersonIndex, int treePersonSpouceIndex, string year) { Family myFamily = null; int familyIndex = -1; FamilyEvent marriageevent = MakeMarriageEvent(treePersonIndex, treePersonSpouceIndex, year ?? ""); if (marriageevent != null) { myFamily = new Family(marriageevent.Generation, marriageevent.BridePersonIndex, marriageevent.GroompersonIndex, marriageevent.Date); familyIndex = addToAllFamilies(myFamily); marriageevent.FamilyIndex = familyIndex; myPeople.allPeople[marriageevent.BridePersonIndex].MarriedFamilyIndex = familyIndex; myPeople.allPeople[marriageevent.GroompersonIndex].MarriedFamilyIndex = familyIndex; myPeople.allPeople[marriageevent.BridePersonIndex].AddEvent(marriageevent); myPeople.allPeople[marriageevent.GroompersonIndex].AddEvent(marriageevent); } return familyIndex; }
public Mission Create(Mission.Type type, Family targetFamily) { switch (type) { case Mission.Type.Assassination: return generateAssassinationMission(); case Mission.Type.Retrievement: return generateRetrievementMission(); case Mission.Type.DrugTrafficking: break; case Mission.Type.DrugDealing: return generateDrugDealMission(); case Mission.Type.HumanTrafficking: break; case Mission.Type.Delivery: break; case Mission.Type.Recruitment: break; } return null; }
/// <summary> /// /// </summary> /// <param name="location"></param> /// <param name="sizeOfWorld"></param> /// <param name="name"></param> /// <param name="family"></param> /// <param name="rndObject">A random object created outside of the class so that each number will be truely random.</param> public Ant(Point location, Size sizeOfWorld, string name, Family family, Random rndObject, List<Nest> availableNests, List<Food> availableFoods, List<Ant> antsInWorld) { randomObject = rndObject; Location = location; Age = 0; Name = name; ViewRange = Settings.AntVisionRange; Facing = Direction.Up; SizeOfWorld = sizeOfWorld; HasFood = false; ViewingRectangle = new Rectangle(); LifeHistory = new List<string>(); Family = family; this.availableFoods = availableFoods; this.availableNests = availableNests; this.antsInWorld = antsInWorld; RememberedFoodLocation = new Point(); LifeHistory.Add("[" + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + "] " +"I was born at x:" + Location.X + " y:" + Location.Y + " as a " + family.ToString() + " ant"); UpdateViewingRectangle(); }
public FamilyTree GetFamilies() { FamilyTree christmasPickList = new FamilyTree(); PersonCollection milwaukeeGehredParents = new PersonCollection(new Person("Bob", "Gehred", new DateTime(1972, 7, 27), "21111111-2222-3333-4444-555555555555"), new Person("Angie", "Gehred", new DateTime(1971, 9, 26), "11111111-2222-3333-4444-555555555555")); PersonCollection milwaukeeGehredKids = new PersonCollection(); milwaukeeGehredKids.Add(new Person("Maxwell", "Gehred", new DateTime(2001, 9, 30), "31111111-2222-3333-4444-555555555555")); milwaukeeGehredKids.Add(new Person("Charlotte", "Gehred", new DateTime(2005, 4, 21), "41111111-2222-3333-4444-555555555555")); Family milwaukeeGehreds = new Family("milwaukeeGehreds", milwaukeeGehredParents, milwaukeeGehredKids); PersonCollection tosaGehredParents = new PersonCollection(new Person("John", "Gehred", new DateTime(1961, 2, 16), "13111111-2222-3333-4444-555555555555"), new Person("Ann", "Gehred", new DateTime(1961, 5, 17), "12111111-2222-3333-4444-555555555555")); PersonCollection tosaGehredKids = new PersonCollection(); tosaGehredKids.Add(new Person("Madeline", "Gehred", new DateTime(1994, 4, 12), "14111111-2222-3333-4444-555555555555")); tosaGehredKids.Add(new Person("Cecila", "Gehred", new DateTime(1997, 10, 12), "15111111-2222-3333-4444-555555555555")); Family tosaGehreds = new Family("tosaGehreds", tosaGehredParents, tosaGehredKids); christmasPickList.Add(milwaukeeGehreds); christmasPickList.Add(tosaGehreds); return christmasPickList; }
public void FamilyService_Add_Calls_Repository_Add_Method_With_The_Same_Family_Object_It_Recieved() { // Create test data var newFamily = new Family { WifeId = TestConstants.ID_WifeId, HusbandId = TestConstants.ID_HusbandId }; //Create Mock var mockRepository = new Mock<IRepository<Family>>(); _mockUnitOfWork.Setup(d => d.GetRepository<Family>()).Returns(mockRepository.Object); //Arrange _service = new FamilyService(_mockUnitOfWork.Object); //Act _service.Add(newFamily); //Assert mockRepository.Verify(r => r.Add(newFamily)); }
public void FamilyService_Add_Calls_UnitOfWork_Commit_Method() { // Create test data var newFamily = new Family { WifeId = TestConstants.ID_WifeId, HusbandId = TestConstants.ID_HusbandId }; //Create Mock var mockRepository = new Mock<IRepository<Family>>(); _mockUnitOfWork.Setup(d => d.GetRepository<Family>()).Returns(mockRepository.Object); //Arrange _service = new FamilyService(_mockUnitOfWork.Object); //Act _service.Add(newFamily); //Assert _mockUnitOfWork.Verify(db => db.Commit()); }
private FamilyViewModel GetFamilyViewModel(Family family, Sex sex) { var fam = family.Clone(); var familyViewModel = new FamilyViewModel(fam); var spouseId = (sex == Sex.Male) ? fam.WifeId.GetValueOrDefault(0) : fam.HusbandId.GetValueOrDefault(0); if (spouseId > 0) { familyViewModel.Spouse = GetIndividualViewModel(_individualService.Get(spouseId, fam.TreeId)); } var children = _individualService.Get(fam.TreeId, (ind) => ind.FatherId == fam.HusbandId && ind.MotherId == fam.WifeId); foreach (var child in children) { familyViewModel.Children.Add(GetIndividualViewModel(child)); } return familyViewModel; }
public void DeepCopyTest() { Person person = new Person() { Name = "A", Age = 20 }; Family family = new Family() { FamilyName = "Big A", Population = 10 }; person.Family = family; Person person2 = SerializationUtils.DeepCopy<Person>(person); family.Population = 8; Assert.AreEqual("A", person2.Name); Assert.AreEqual(20, person2.Age); Assert.AreEqual("Big A", person2.Family.FamilyName); Assert.AreEqual(10, person2.Family.Population); Assert.AreEqual(8, person.Family.Population); }
internal void UploadPeople(UploadPeopleRun rt, ExcelWorksheet ws) { Extravaluenames = (from name in Names where !Standardnames.Contains(name.Key, StringComparer.OrdinalIgnoreCase) where !Standardrecregnames.Contains(name.Key) select name.Key).ToList(); Recregnames = (from name in Names where Standardrecregnames.Contains(name.Key) select name.Key).ToList(); if (Names.ContainsKey("Campus")) { var campuslist = (from li in Datalist group li by(string) li.Campus into campus where campus.Key.HasValue() select campus.Key).ToList(); var dbc = from c in campuslist join cp in JobDbContext.Campus on c equals cp.Description into j from cp in j.DefaultIfEmpty() select new { cp, c }; var clist = dbc.ToList(); if (clist.Count > 0) { var maxcampusid = 0; if (JobDbContext.Campus.Any()) { maxcampusid = JobDbContext.Campus.Max(c => c.Id); } foreach (var i in clist) { if (i.cp != null) { continue; } var cp = new Campu { Description = i.c, Id = ++maxcampusid }; if (!Testing) { JobDbContext.Campus.InsertOnSubmit(cp); } } } } if (!Testing) { JobDbContext.SubmitChanges(); } Campuses = JobDbContext.Campus.ToDictionary(cp => cp.Description, cp => cp.Id); var q = (from li in Datalist group li by li.FamilyId into fam select fam).ToList(); rt.Count = q.Sum(ff => ff.Count()); rt.Description = $"Uploading People {(Testing ? "in testing mode" : "for real")}"; ProgressDbContext.SubmitChanges(); foreach (var fam in q) { var prevpid = 0; foreach (var a in fam) { if (!Testing) { JobDbContext.SubmitChanges(); } Family f = null; var potentialdup = false; int? pid = FindRecord(JobDbContext, a, ref potentialdup); if (pid == -1) // no data: no first or last name { continue; } var p = pid.HasValue ? UpdateRecord(JobDbContext, pid.Value, a) : NewRecord(JobDbContext, ref f, a, prevpid, potentialdup); prevpid = p.PeopleId; if (Recregnames.Any()) { SetRecRegs(p, a); } if (Extravaluenames.Any()) { ProcessExtraValues(JobDbContext, p, a); } rt.Processed++; ProgressDbContext.SubmitChanges(); } if (!Testing) { JobDbContext.SubmitChanges(); } } }
//Mass >> Room/Area/Floor private bool TransferToRoom(Dictionary <Element, FamilyInstance> mapDictionary) { try { foreach (Element mainElement in mapDictionary.Keys) { FamilyInstance massInstance = mapDictionary[mainElement]; foreach (string paramName in defDictionary.Keys) { ExternalDefinition extDefinition = defDictionary[paramName] as ExternalDefinition; #if RELEASE2013 || RELEASE2014 Parameter mainParameter = mainElement.get_Parameter(paramName); Parameter massParameter = massInstance.get_Parameter("Mass_" + paramName); #elif RELEASE2015 || RELEASE2016 Parameter mainParameter = mainElement.LookupParameter(paramName); Parameter massParameter = massInstance.LookupParameter("Mass_" + paramName); #endif if (null != mainParameter && null != massParameter && !mainParameter.IsReadOnly) { using (Transaction trans = new Transaction(m_doc)) { trans.Start("Set Parameter"); switch (mainParameter.StorageType) { case StorageType.Double: mainParameter.Set(massParameter.AsDouble()); break; case StorageType.Integer: mainParameter.Set(massParameter.AsInteger()); break; case StorageType.String: mainParameter.Set(massParameter.AsString()); break; } trans.Commit(); } } else if (null != mainParameter && null == massParameter) //create Mass Parameter { Family family = massInstance.Symbol.Family; Document familyDoc = m_doc.EditFamily(family); if (null != familyDoc && familyDoc.IsFamilyDocument) { using (Transaction fTrans = new Transaction(familyDoc)) { fTrans.Start("Add Parameter"); FamilyParameter fParam = familyDoc.FamilyManager.AddParameter(extDefinition, BuiltInParameterGroup.INVALID, true); switch (fParam.StorageType) { case StorageType.Double: familyDoc.FamilyManager.Set(fParam, mainParameter.AsDouble()); break; case StorageType.Integer: familyDoc.FamilyManager.Set(fParam, mainParameter.AsInteger()); break; case StorageType.String: familyDoc.FamilyManager.Set(fParam, mainParameter.AsString()); break; } familyDoc.LoadFamily(m_doc, new FamilyOption()); fTrans.Commit(); } familyDoc.Close(true); } } } } return(true); } catch (Exception ex) { MessageBox.Show("Failed to transfer data from Mass to " + massCategory.ToString() + "\n" + ex.Message, "Form_DataTrnasfer:TransferToRoom", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } }
internal Person NewRecord(CMSDataContext db, ref Family f, dynamic a, int prevpid, bool potentialdup) { if (!Testing) { if (prevpid > 0) { f = db.LoadFamilyByPersonId(prevpid); } } if (f == null) { f = new Family { AddressLineOne = GetString(a.Address), AddressLineTwo = GetString(a.Address2), CityName = GetString(a.City), StateCode = GetString(a.State), ZipCode = GetString(a.Zip), HomePhone = GetDigits(a.HomePhone) }; db.Families.InsertOnSubmit(f); if (!Testing) { db.SubmitChanges(); } } DateTime?dob = GetDate(a.Birthday); var dobstr = dob.FormatDate(); var p = Person.Add(db, false, f, 10, null, (string)a.First, (string)a.GoesBy, (string)a.Last, dobstr, 0, 0, 0, null, Testing); p.FixTitle(); p.AltName = GetString(a.AltName); p.SuffixCode = GetString(a.Suffix); p.MiddleName = GetString(a.Middle); p.MaidenName = GetString(a.MaidenName); p.EmployerOther = GetString(a.Employer); p.OccupationOther = GetString(a.Occupation); p.EmailAddress = GetStringTrimmed(a.Email); p.EmailAddress2 = GetStringTrimmed(a.Email2); p.CellPhone = GetDigits(a.CellPhone); p.WorkPhone = GetDigits(a.WorkPhone); p.TitleCode = Title(a.Title); p.GenderId = Gender(a.Gender); p.MaritalStatusId = Marital(a.Marital); p.PositionInFamilyId = Position(a.Position); SetMemberStatus(db, p, a.MemberStatus); p.WeddingDate = GetDate(a.WeddingDate); p.JoinDate = GetDate(a.JoinDate); p.DropDate = GetDate(a.DropDate); p.BaptismDate = GetDate(a.BaptismDate); StoreIds(p, a); if (Testing) { return(p); } p.CampusId = Campus(a.Campus); p.AddEditExtraBool("InsertPeopleAdded", true); if (potentialdup) { p.AddEditExtraBool("FoundDup", true); } db.SubmitChanges(); return(p); }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication app = commandData.Application; UIDocument uidoc = app.ActiveUIDocument; Document doc = uidoc.Document; Result rc = Result.Failed; using (Transaction t = new Transaction(doc)) { t.Start("Place a New Sprinkler Instance"); // retrieve the sprinkler family symbol: #if _2010 Filter filter = app.Create.Filter.NewFamilyFilter( _name); List <Element> families = new List <Element>(); doc.get_Elements(filter, families); Family family = null; foreach (Element e in families) { family = e as Family; if (null != family) { break; } } #endif // _2010 Family family = Util.GetFirstElementOfTypeNamed( doc, typeof(Family), _name) as Family; if (null == family) { if (!doc.LoadFamily(_filename, out family)) { message = "Unable to load '" + _filename + "'."; return(rc); } } FamilySymbol sprinklerSymbol = null; //foreach( FamilySymbol fs in family.Symbols ) // 2014 foreach (ElementId id in family.GetFamilySymbolIds()) // 2015 { sprinklerSymbol = doc.GetElement(id) as FamilySymbol; break; } Debug.Assert(null != sprinklerSymbol, "expected at least one sprinkler symbol" + " to be defined in family"); // pick the host ceiling: Element ceiling = Util.SelectSingleElement( uidoc, "ceiling to host sprinkler"); if (null == ceiling || !ceiling.Category.Id.IntegerValue.Equals( (int)BuiltInCategory.OST_Ceilings)) { message = "No ceiling selected."; return(rc); } //Level level = ceiling.Level; //XYZ p = new XYZ( 40.1432351841559, 30.09700395984548, 8.0000 ); // these two methods cannot create the sprinkler on the ceiling: //FamilyInstance fi = doc.Create.NewFamilyInstance( p, sprinklerSymbol, ceiling, level, StructuralType.NonStructural ); //FamilyInstance fi = doc.Create.NewFamilyInstance( p, sprinklerSymbol, ceiling, StructuralType.NonStructural ); // use this overload so get the bottom face of the ceiling instead: // FamilyInstance NewFamilyInstance( Face face, XYZ location, XYZ referenceDirection, FamilySymbol symbol ) // retrieve the bottom face of the ceiling: Options opt = app.Application.Create.NewGeometryOptions(); opt.ComputeReferences = true; GeometryElement geo = ceiling.get_Geometry(opt); PlanarFace ceilingBottom = null; foreach (GeometryObject obj in geo) { Solid solid = obj as Solid; if (null != solid) { foreach (Face face in solid.Faces) { PlanarFace pf = face as PlanarFace; if (null != pf) { XYZ normal = pf.FaceNormal.Normalize(); if (Util.IsVertical(normal) && 0.0 > normal.Z) { ceilingBottom = pf; break; } } } } } if (null != ceilingBottom) { XYZ p = PointOnFace(ceilingBottom); // Create the sprinkler family instance: FamilyInstance fi = doc.Create.NewFamilyInstance( ceilingBottom, p, XYZ.BasisX, sprinklerSymbol); rc = Result.Succeeded; } t.Commit(); } return(rc); }
protected void Page_Load(object sender, System.EventArgs e) { if (_family == null) { FamilyMember you = null; FamilyMember spouse = null; if (CurrentPerson != null) { _family = CurrentPerson.Family(); you = _family.FamilyMembers.FindByGuid(CurrentPerson.PersonGUID); spouse = _family.Spouse(CurrentPerson); } else { _family = new Family(); you = new FamilyMember(); you.PersonGUID = Guid.NewGuid(); you.FamilyRole = new Lookup(SystemLookup.FamilyRole_Adult); you.Gender = Arena.Enums.Gender.Unknown; _family.FamilyMembers.Add(you); } // Save Spouse if (spouse == null) { spouse = new FamilyMember(); spouse.PersonGUID = Guid.NewGuid(); spouse.FamilyRole = new Lookup(SystemLookup.FamilyRole_Adult); if (CurrentPerson != null && CurrentPerson.Gender == Arena.Enums.Gender.Male) { you.Gender = Arena.Enums.Gender.Female; } else if (CurrentPerson != null && CurrentPerson.Gender == Arena.Enums.Gender.Female) { you.Gender = Arena.Enums.Gender.Male; } else { you.Gender = Arena.Enums.Gender.Unknown; } _family.FamilyMembers.Add(spouse); } // Save Guids hfYouGuid.Value = you.PersonGUID.ToString(); hfSpouseGuid.Value = spouse.PersonGUID.ToString(); } if (Page.IsPostBack) { UpdateChanges(); } else { ShowYou(); } }
public void NewBirth() { List <long> getListOfRooms = new List <long>(); getListOfRooms = GetNumberOfRooms(); //birth = 0, maternity = 1 og restRoom = 2 Console.WriteLine($"Vælg en start dato for din fødsel."); Birth newBirth = new Birth(); newBirth.PlannedStartDate = ReservationDate(); Console.WriteLine($"Vælg en s**t dato for din fødsel."); newBirth.PlannedEndDate = ReservationDate(); Console.WriteLine( $"Vælg et fødselserum mellem {getListOfRooms.ElementAt(1) + getListOfRooms.ElementAt(2) + 1} og {getListOfRooms.ElementAt(0) + getListOfRooms.ElementAt(1) + getListOfRooms.ElementAt(2)}: "); int choice3 = int.Parse(Console.ReadLine()); newBirth.RoomNumber = choice3; bool notDone = true; while (notDone) { Console.WriteLine("Tryk enter for at vælge personale eller 'e' for at afslutte"); if (Console.ReadKey().Key != ConsoleKey.E) { Console.WriteLine($"Vælg et ledig personale: "); //dbSearch.ShowAvaliableClinciansAndRoomsForNextFiveDays(); List <Employee> eml = _birthClinicPlanningService.Employees.Find(Builders <Employee> .Filter.Empty).ToList(); foreach (var employee in eml) { Console.WriteLine($"id: {employee.EmployeeNumber} navn: {employee.FullName}"); } Console.WriteLine("Indtast et Id på et ledig personale"); int choice4 = int.Parse(Console.ReadLine()); var filterEmployee = Builders <Employee> .Filter.Where(e => e.EmployeeNumber == choice4); Employee em = _birthClinicPlanningService.Employees.Find(filterEmployee).Single(); newBirth.EmployeeList.Add(ObjectId.Parse(em.EmployeeId)); } else { notDone = false; } } List <Relatives> relativesList = new List <Relatives>(); bool notdone1 = true; while (notdone1) { Console.WriteLine("\nTryk enter for at tilføje familiemedlemmer til fødslen eller 'e' for at afslutte"); if (Console.ReadKey().Key != ConsoleKey.E) { Relatives r1; Console.WriteLine("\nIndtast m for mor, f for far eller a for familie"); string choice = Console.ReadLine(); Console.WriteLine("Indtast navn:"); string name = Console.ReadLine(); switch (choice) { case "m": r1 = new Mother(name); break; case "f": r1 = new Father(name); break; case "a": r1 = new Family(name); break; default: r1 = new Family(name); break; } relativesList.Add(r1); } else { notdone1 = false; } } foreach (var relatives in relativesList) { newBirth.RelativesList.Add(relatives); } _birthClinicPlanningService.Births.InsertOne(newBirth); }
public bool DoUpload(string text) { var rt = Db2.UploadPeopleRuns.OrderByDescending(mm => mm.Id).First(); var sep = text.First(vv => new char[] { '\t', ',' }.Contains(vv)); var csv = new CsvReader(new StringReader(text), false, sep); csv.SupportsMultiline = true; var list = csv.ToList(); var list0 = list.First().Select(kk => kk).ToList(); names = list0.ToDictionary(i => i.TrimEnd(), i => list0.FindIndex(s => s == i), StringComparer.OrdinalIgnoreCase); extravaluenames = (from name in names.Keys where !standardnames.Contains(name, StringComparer.OrdinalIgnoreCase) where !standardrecregnames.Contains(name) select name).ToList(); recregnames = (from name in names.Keys where standardrecregnames.Contains(name) select name).ToList(); var db = DbUtil.Create(host); if (names.ContainsKey("campus")) { var campuslist = (from li in list.Skip(1) where li.Length == names.Count group li by li[names["campus"]] into campus where campus.Key.HasValue() select campus.Key).ToList(); var dbc = from c in campuslist join cp in db.Campus on c equals cp.Description into j from cp in j.DefaultIfEmpty() select new { cp, c }; var clist = dbc.ToList(); if (clist.Count > 0) { var maxcampusid = 0; if (db.Campus.Any()) { maxcampusid = db.Campus.Max(c => c.Id); } foreach (var i in clist) { if (i.cp == null) { var cp = new Campu { Description = i.c, Id = ++maxcampusid }; if (!testing) { db.Campus.InsertOnSubmit(cp); } } } } } var now = DateTime.Now; if (!testing) { db.SubmitChanges(); } Campuses = db.Campus.ToDictionary(cp => cp.Description, cp => cp.Id); var q = (from li in list.Skip(1) where li.Length == names.Count group li by li[names["familyid"]] into fam select fam).ToList(); rt.Count = q.Sum(ff => ff.Count()); Db2.SubmitChanges(); foreach (var fam in q) { Family f = null; var prevpid = 0; FindPerson3 pid; Person p = null; foreach (var a in fam) { if (!testing) { db.SubmitChanges(); db.Dispose(); db = DbUtil.Create(host); } var potentialdup = false; var first = a[names["first"]]; var last = a[names["last"]]; DateTime dt; DateTime?dob = null; if (names.ContainsKey("birthday")) { if (DateTime.TryParse(a[names["birthday"]], out dt)) { dob = dt; if (dob.Value < SqlDateTime.MinValue) { dob = null; } } } string email = null; string cell = null; string homephone = null; if (names.ContainsKey("email")) { email = a[names["email"]].Trim(); } if (names.ContainsKey("cellphone")) { cell = a[names["cellphone"]].GetDigits(); } if (names.ContainsKey("homephone")) { homephone = a[names["homephone"]].GetDigits(); } pid = db.FindPerson3(first, last, dob, email, cell, homephone, null).FirstOrDefault(); if (noupdate && pid != null) { if (!testing) { var pd = db.LoadPersonById(pid.PeopleId.Value); pd.AddEditExtraBool("FoundDup", true); } potentialdup = true; pid = null; } if (pid != null) // found { p = db.LoadPersonById(pid.PeopleId.Value); prevpid = p.PeopleId; psb = new List <ChangeDetail>(); fsb = new List <ChangeDetail>(); UpdateField(p, a, "TitleCode", "title"); UpdateField(p, a, "FirstName", "first"); UpdateField(p, a, "NickName", "goesby"); UpdateField(p, a, "LastName", "last"); UpdateField(p, a, "EmailAddress", "email"); UpdateField(p, a, "EmailAddress2", "email2"); UpdateField(p, a, "DOB", "birthday"); UpdateField(p, a, "AltName", "altname"); UpdateField(p, a, "SuffixCode", "suffix"); UpdateField(p, a, "MiddleName", "middle"); UpdateField(p, a, "CellPhone", "cellphone", GetDigits(a, "cellphone")); UpdateField(p, a, "WorkPhone", "workphone", GetDigits(a, "workphone")); UpdateField(p, a, "GenderId", "gender", Gender(a)); UpdateField(p, a, "MaritalStatusId", "marital", Marital(a)); UpdateField(p, a, "PositionInFamilyId", "position", Position(a)); if (!testing) { UpdateField(p, a, "CampusId", "campus", Campus(a)); } UpdateField(p.Family, a, "AddressLineOne", "address"); UpdateField(p.Family, a, "AddressLineTwo", "address2"); UpdateField(p.Family, a, "CityName", "city"); UpdateField(p.Family, a, "StateCode", "state"); UpdateField(p.Family, a, "ZipCode", "zip"); if (names.ContainsKey("memberstatus")) { UpdateMemberStatus(db, p, a); } if (!testing) { p.LogChanges(db, psb, PeopleId); p.Family.LogChanges(db, fsb, p.PeopleId, PeopleId); db.SubmitChanges(); p.AddEditExtraBool("InsertPeopleUpdated", true); } } else // new person { if (!testing) { if (prevpid > 0) { f = db.LoadFamilyByPersonId(prevpid); } } if (f == null || !a[names["familyid"]].HasValue()) { f = new Family(); SetField(f, a, "AddressLineOne", "address"); SetField(f, a, "AddressLineTwo", "address2"); SetField(f, a, "CityName", "city"); SetField(f, a, "StateCode", "state"); SetField(f, a, "ZipCode", "zip"); SetField(f, a, "HomePhone", "homephone", GetDigits(a, "homephone")); db.Families.InsertOnSubmit(f); if (!testing) { db.SubmitChanges(); } } string goesby = null; if (names.ContainsKey("goesby")) { goesby = a[names["goesby"]]; } p = Person.Add(db, false, f, 10, null, a[names["first"]], goesby, a[names["last"]], dob.FormatDate(), 0, 0, 0, null, testing); prevpid = p.PeopleId; p.FixTitle(); SetField(p, a, "AltName", "altname"); SetField(p, a, "SuffixCode", "suffix"); SetField(p, a, "MiddleName", "middle"); SetField(p, a, "MaidenName", "maidenname"); SetField(p, a, "EmployerOther", "employer"); SetField(p, a, "OccupationOther", "occupation"); SetField(p, a, "CellPhone", "cellphone", GetDigits(a, "cellphone")); SetField(p, a, "WorkPhone", "workphone", GetDigits(a, "workphone")); SetField(p, a, "EmailAddress", "email"); SetField(p, a, "EmailAddress2", "email2"); SetField(p, a, "GenderId", "gender", Gender(a)); SetField(p, a, "MaritalStatusId", "marital", Marital(a)); SetField(p, a, "WeddingDate", "weddingdate", GetDate(p, a, "weddingdate")); SetField(p, a, "JoinDate", "joindate", GetDate(p, a, "joindate")); SetField(p, a, "DropDate", "dropdate", GetDate(p, a, "dropdate")); SetField(p, a, "BaptismDate", "baptismdate", GetDate(p, a, "baptismdate")); SetField(p, a, "PositionInFamilyId", "position", Position(a)); SetField(p, a, "TitleCode", "title", Title(a)); if (names.ContainsKey("memberstatus")) { SetMemberStatus(db, p, a); } if (!testing) { SetField(p, a, "CampusId", "campus", Campus(a)); p.AddEditExtraBool("InsertPeopleAdded", true); if (potentialdup) { p.AddEditExtraBool("FoundDup", true); } db.SubmitChanges(); } } if (names.ContainsKey("createddate")) { SetCreatedDate(p, a); } if (names.ContainsKey("backgroundcheck")) { SetBackgroundCheckDate(db, p, a); } if (recregnames.Any()) { SetRecRegs(p, a); } if (extravaluenames.Any()) { ProcessExtraValues(db, p, a); } rt.Processed++; Db2.SubmitChanges(); } if (!testing) { db.SubmitChanges(); } } rt.Completed = DateTime.Now; Db2.SubmitChanges(); return(true); }
public Family Add(Family family) { _familyRepository.Add(family); return(family); }
public static void Initialize(CSCDbContext dbContext) { dbContext.Database.EnsureCreated(); if (dbContext.Users.Any()) { return; } var users = new User[] { new User { Name = "Michael", Surname = "Jackson", Email = "*****@*****.**", Address = "Indiana", Password = "******" }, new User { Name = "Arnold", Surname = "Schwarzenegger", Email = "*****@*****.**", Address = "Los Angeles", Password = "******" } }; foreach (var user in users) { dbContext.Users.Add(user); } dbContext.SaveChanges(); var organizations = new Organization[] { new Organization { Name = "Samsung", Code = "S7", Type = OrganizationType.GeneralPartnership, User = users[0] }, new Organization { Name = "Vodafone", Code = "V8", Type = OrganizationType.IncorporatedCompany, User = users[0] }, new Organization { Name = "T-Mobile", Code = "TMB", Type = OrganizationType.LimitedLiabilityCompany, User = users[1] }, new Organization { Name = "AT&T branded", Code = "ATT", Type = OrganizationType.LimitedPartnership, User = users[1] }, new Organization { Name = "XAS", Code = "XAS", Type = OrganizationType.SocialEnterprise, User = users[1] } }; foreach (var organization in organizations) { dbContext.Organizations.Add(organization); } dbContext.SaveChanges(); var countries = new Country[] { new Country { Name = "Afghanistan", Code = "AFG", Organization = organizations[0] }, new Country { Name = "Austria", Code = "TRG", Organization = organizations[0] }, new Country { Name = "Bulgaria", Code = "BGL", Organization = organizations[0] }, new Country { Name = "Croatia", Code = "CRO", Organization = organizations[0] }, new Country { Name = "Cyprus", Code = "CYY", Organization = organizations[4] }, new Country { Name = "Czech Republic", Code = "ETL", Organization = organizations[2] }, new Country { Name = "Greece", Code = "EUR", Organization = organizations[1] }, new Country { Name = "Hungary", Code = "XEH", Organization = organizations[3] }, new Country { Name = "Indonesia", Code = "XSE", Organization = organizations[4] }, new Country { Name = "Israel", Code = "ILO", Organization = organizations[2] }, new Country { Name = "Italy", Code = "ITV", Organization = organizations[1] }, new Country { Name = "Libya", Code = "BTC", Organization = organizations[3] }, new Country { Name = "Luxembourg", Code = "LUX", Organization = organizations[2] }, new Country { Name = "Montenegro", Code = "TMT", Organization = organizations[3] } }; foreach (var country in countries) { dbContext.Countries.Add(country); } dbContext.SaveChanges(); var businessTypes = new Business[] { new Business { Name = "GIS" }, new Business { Name = "CEO" }, new Business { Name = "Telecommunication" }, new Business { Name = "Managed Services" } }; foreach (var businessType in businessTypes) { dbContext.Businesses.Add(businessType); } dbContext.SaveChanges(); var familyTypes = new Family[] { new Family { Name = "Data Center", Business = businessTypes[0] }, new Family { Name = "Cloud", Business = businessTypes[0] }, new Family { Name = "Cyber", Business = businessTypes[1] }, new Family { Name = "Computer Networks", Business = businessTypes[2] }, new Family { Name = "Television Networks", Business = businessTypes[2] }, new Family { Name = "Business-to-business", Business = businessTypes[3] }, new Family { Name = "Marketing", Business = businessTypes[3] } }; foreach (var familyType in familyTypes) { dbContext.Families.Add(familyType); } dbContext.SaveChanges(); var offeringTypes = new Offering[] { new Offering { Name = "Data Storage", Family = familyTypes[0] }, new Offering { Name = "Data management", Family = familyTypes[0] }, new Offering { Name = "Biz cloud", Family = familyTypes[1] }, new Offering { Name = "Cloud compute", Family = familyTypes[1] }, new Offering { Name = "Consulting services", Family = familyTypes[2] }, new Offering { Name = "Ethernet", Family = familyTypes[3] }, new Offering { Name = "Wireless networks", Family = familyTypes[3] }, new Offering { Name = "Cable television", Family = familyTypes[4] }, new Offering { Name = "Satellite television", Family = familyTypes[4] }, new Offering { Name = "Supply chain management", Family = familyTypes[5] }, new Offering { Name = "Videoconferencing", Family = familyTypes[5] }, new Offering { Name = "Marketing strategy", Family = familyTypes[6] }, new Offering { Name = "Integrated advertising agency services", Family = familyTypes[6] } }; foreach (var offeringType in offeringTypes) { dbContext.Offerings.Add(offeringType); } dbContext.SaveChanges(); var countryBusinesses = new CountryBusiness[] { new CountryBusiness { Country = countries[0], Business = businessTypes[0] }, new CountryBusiness { Country = countries[1], Business = businessTypes[0] }, new CountryBusiness { Country = countries[1], Business = businessTypes[1] }, new CountryBusiness { Country = countries[2], Business = businessTypes[2] }, new CountryBusiness { Country = countries[3], Business = businessTypes[3] }, new CountryBusiness { Country = countries[3], Business = businessTypes[1] }, new CountryBusiness { Country = countries[4], Business = businessTypes[2] }, new CountryBusiness { Country = countries[5], Business = businessTypes[3] }, new CountryBusiness { Country = countries[6], Business = businessTypes[0] }, new CountryBusiness { Country = countries[6], Business = businessTypes[2] }, new CountryBusiness { Country = countries[6], Business = businessTypes[1] }, new CountryBusiness { Country = countries[8], Business = businessTypes[3] }, new CountryBusiness { Country = countries[9], Business = businessTypes[0] }, new CountryBusiness { Country = countries[9], Business = businessTypes[3] }, new CountryBusiness { Country = countries[10], Business = businessTypes[2] }, new CountryBusiness { Country = countries[12], Business = businessTypes[1] }, new CountryBusiness { Country = countries[12], Business = businessTypes[0] }, new CountryBusiness { Country = countries[12], Business = businessTypes[2] }, new CountryBusiness { Country = countries[13], Business = businessTypes[3] } }; foreach (var countryBusiness in countryBusinesses) { dbContext.CountryBusinesses.Add(countryBusiness); } dbContext.SaveChanges(); var businessFamilies = new BusinessFamily[] { new BusinessFamily { CountryBusiness = countryBusinesses[0], Family = familyTypes[0] }, new BusinessFamily { CountryBusiness = countryBusinesses[0], Family = familyTypes[1] }, new BusinessFamily { CountryBusiness = countryBusinesses[1], Family = familyTypes[1] }, new BusinessFamily { CountryBusiness = countryBusinesses[2], Family = familyTypes[2] }, new BusinessFamily { CountryBusiness = countryBusinesses[3], Family = familyTypes[3] }, new BusinessFamily { CountryBusiness = countryBusinesses[4], Family = familyTypes[5] }, new BusinessFamily { CountryBusiness = countryBusinesses[4], Family = familyTypes[6] }, new BusinessFamily { CountryBusiness = countryBusinesses[6], Family = familyTypes[3] }, new BusinessFamily { CountryBusiness = countryBusinesses[7], Family = familyTypes[6] }, new BusinessFamily { CountryBusiness = countryBusinesses[8], Family = familyTypes[0] }, new BusinessFamily { CountryBusiness = countryBusinesses[9], Family = familyTypes[3] }, new BusinessFamily { CountryBusiness = countryBusinesses[9], Family = familyTypes[4] }, new BusinessFamily { CountryBusiness = countryBusinesses[11], Family = familyTypes[5] }, new BusinessFamily { CountryBusiness = countryBusinesses[12], Family = familyTypes[1] }, new BusinessFamily { CountryBusiness = countryBusinesses[13], Family = familyTypes[6] }, new BusinessFamily { CountryBusiness = countryBusinesses[14], Family = familyTypes[3] }, new BusinessFamily { CountryBusiness = countryBusinesses[14], Family = familyTypes[4] }, new BusinessFamily { CountryBusiness = countryBusinesses[16], Family = familyTypes[0] }, new BusinessFamily { CountryBusiness = countryBusinesses[17], Family = familyTypes[4] }, new BusinessFamily { CountryBusiness = countryBusinesses[18], Family = familyTypes[5] } }; foreach (var businessFamily in businessFamilies) { dbContext.BusinessFamilies.Add(businessFamily); } dbContext.SaveChanges(); var familyOfferings = new FamilyOffering[] { new FamilyOffering { BusinessFamily = businessFamilies[0], Offering = offeringTypes[0] }, new FamilyOffering { BusinessFamily = businessFamilies[1], Offering = offeringTypes[2] }, new FamilyOffering { BusinessFamily = businessFamilies[2], Offering = offeringTypes[3] }, new FamilyOffering { BusinessFamily = businessFamilies[3], Offering = offeringTypes[4] }, new FamilyOffering { BusinessFamily = businessFamilies[5], Offering = offeringTypes[9] }, new FamilyOffering { BusinessFamily = businessFamilies[5], Offering = offeringTypes[10] }, new FamilyOffering { BusinessFamily = businessFamilies[6], Offering = offeringTypes[11] }, new FamilyOffering { BusinessFamily = businessFamilies[7], Offering = offeringTypes[5] }, new FamilyOffering { BusinessFamily = businessFamilies[8], Offering = offeringTypes[11] }, new FamilyOffering { BusinessFamily = businessFamilies[8], Offering = offeringTypes[12] }, new FamilyOffering { BusinessFamily = businessFamilies[10], Offering = offeringTypes[6] }, new FamilyOffering { BusinessFamily = businessFamilies[11], Offering = offeringTypes[7] }, new FamilyOffering { BusinessFamily = businessFamilies[12], Offering = offeringTypes[9] }, new FamilyOffering { BusinessFamily = businessFamilies[13], Offering = offeringTypes[2] }, new FamilyOffering { BusinessFamily = businessFamilies[13], Offering = offeringTypes[3] }, new FamilyOffering { BusinessFamily = businessFamilies[15], Offering = offeringTypes[5] }, new FamilyOffering { BusinessFamily = businessFamilies[16], Offering = offeringTypes[8] }, new FamilyOffering { BusinessFamily = businessFamilies[17], Offering = offeringTypes[1] }, new FamilyOffering { BusinessFamily = businessFamilies[18], Offering = offeringTypes[7] }, new FamilyOffering { BusinessFamily = businessFamilies[18], Offering = offeringTypes[8] }, new FamilyOffering { BusinessFamily = businessFamilies[19], Offering = offeringTypes[10] } }; foreach (var familyOffering in familyOfferings) { dbContext.FamilyOfferings.Add(familyOffering); } dbContext.SaveChanges(); var departments = new Department[] { new Department { Name = "Departmetnt 1", FamilyOffering = familyOfferings[0] }, new Department { Name = "Departmetnt 2", FamilyOffering = familyOfferings[1] }, new Department { Name = "Departmetnt 3", FamilyOffering = familyOfferings[1] }, new Department { Name = "Departmetnt 4", FamilyOffering = familyOfferings[2] }, new Department { Name = "Departmetnt 5", FamilyOffering = familyOfferings[2] }, new Department { Name = "Departmetnt 6", FamilyOffering = familyOfferings[2] }, new Department { Name = "Departmetnt 7", FamilyOffering = familyOfferings[4] }, new Department { Name = "Departmetnt 8", FamilyOffering = familyOfferings[5] }, new Department { Name = "Departmetnt 9", FamilyOffering = familyOfferings[6] }, new Department { Name = "Departmetnt 10", FamilyOffering = familyOfferings[7] }, new Department { Name = "Departmetnt 11", FamilyOffering = familyOfferings[7] }, new Department { Name = "Departmetnt 12", FamilyOffering = familyOfferings[7] }, new Department { Name = "Departmetnt 13", FamilyOffering = familyOfferings[9] }, new Department { Name = "Departmetnt 14", FamilyOffering = familyOfferings[10] }, new Department { Name = "Departmetnt 15", FamilyOffering = familyOfferings[11] }, new Department { Name = "Departmetnt 16", FamilyOffering = familyOfferings[11] }, new Department { Name = "Departmetnt 17", FamilyOffering = familyOfferings[13] }, new Department { Name = "Departmetnt 18", FamilyOffering = familyOfferings[14] }, new Department { Name = "Departmetnt 19", FamilyOffering = familyOfferings[15] }, new Department { Name = "Departmetnt 20", FamilyOffering = familyOfferings[17] }, new Department { Name = "Departmetnt 21", FamilyOffering = familyOfferings[17] }, new Department { Name = "Departmetnt 22", FamilyOffering = familyOfferings[17] }, new Department { Name = "Departmetnt 23", FamilyOffering = familyOfferings[19] }, new Department { Name = "Departmetnt 24", FamilyOffering = familyOfferings[20] }, new Department { Name = "Departmetnt 25", FamilyOffering = familyOfferings[20] } }; foreach (var department in departments) { dbContext.Departments.Add(department); } dbContext.SaveChanges(); }
private string CalculateDoorOperationStyle(FamilyInstance currElem, Transform trf) { int leftPosYArcCount = 0; int leftNegYArcCount = 0; int rightPosYArcCount = 0; int rightNegYArcCount = 0; int fullCircleCount = 0; int leftHalfCircleCount = 0; int rightHalfCircleCount = 0; double allowance = 0.0001; if (currElem == null) { return("NOTDEFINED"); } FamilySymbol famSymbol = currElem.Symbol; if (famSymbol == null) { return("NOTDEFINED"); } Family fam = famSymbol.Family; if (fam == null) { return("NOTDEFINED"); } Transform doorWindowTrf = ExporterIFCUtils.GetTransformForDoorOrWindow(currElem, famSymbol, FlippedX, FlippedY); IList <Curve> origArcs = GeometryUtil.get2DArcOrLineFromSymbol(currElem, allCurveType: false, inclArc: true); if (origArcs == null || (origArcs.Count == 0)) { return("NOTDEFINED"); } BoundingBoxXYZ doorBB = GetBoundingBoxFromSolids(currElem); XYZ bbMin = doorWindowTrf.OfPoint(doorBB.Min); XYZ bbMax = doorWindowTrf.OfPoint(doorBB.Max); // Reorganize the bbox min and max after transform double xmin = bbMin.X, xmax = bbMax.X, ymin = bbMin.Y, ymax = bbMax.Y, zmin = bbMin.Z, zmax = bbMax.Z; if (bbMin.X > bbMax.X) { xmin = bbMax.X; xmax = bbMin.X; } if (bbMin.Y > bbMax.Y) { ymin = bbMax.Y; ymax = bbMin.Y; } if (bbMin.Z > bbMax.Z) { zmin = bbMax.Z; zmax = bbMin.Z; } bbMin = new XYZ(xmin - tolForArcCenter, ymin - tolForArcCenter, zmin - tolForArcCenter); bbMax = new XYZ(xmax + tolForArcCenter, ymax + tolForArcCenter, zmax + tolForArcCenter); IList <XYZ> arcCenterLocations = new List <XYZ>(); SortedSet <double> arcRadii = new SortedSet <double>(); foreach (Arc arc in origArcs) { Arc trfArc = arc.CreateTransformed(doorWindowTrf) as Arc; // Filter only Arcs that is on XY plane and at the Z=0 of the Door/Window transform if (!(MathUtil.IsAlmostEqual(Math.Abs(trfArc.Normal.Z), 1.0) /*&& MathUtil.IsAlmostEqual(Math.Abs(trfArc.Center.Z), Math.Abs(doorWindowTrf.Origin.Z))*/)) { continue; } // Filter only Arcs that have center within the bounding box if (trfArc.Center.X > bbMax.X || trfArc.Center.X < bbMin.X || trfArc.Center.Y > bbMax.Y || trfArc.Center.Y < bbMin.Y) { continue; } if (!trfArc.IsBound) { fullCircleCount++; } else { double angleOffOfXY = 0; XYZ v1 = CorrectNearlyZeroValueToZero((trfArc.GetEndPoint(0) - trfArc.Center).Normalize()); XYZ v2 = CorrectNearlyZeroValueToZero((trfArc.GetEndPoint(1) - trfArc.Center).Normalize()); angleOffOfXY = Math.Acos(v1.DotProduct(v2)); if ((Math.Abs(angleOffOfXY) > (60.0 / 180.0) * Math.PI && Math.Abs(angleOffOfXY) < (240.0 / 180.0) * Math.PI) && ((v1.Y > 0.0 && v2.Y < 0.0) || (v1.Y < 0.0 && v2.Y > 0.0))) // Consider the opening swing between -30 to +30 up to -120 to +120 degree, where Y axes must be at the opposite sides { if (trfArc.Center.X >= -tolForArcCenter && trfArc.Center.X <= tolForArcCenter) { leftHalfCircleCount++; } else { rightHalfCircleCount++; } } else if ((Math.Abs(angleOffOfXY) > (30.0 / 180.0) * Math.PI && Math.Abs(angleOffOfXY) < (170.0 / 180.0) * Math.PI) && (MathUtil.IsAlmostEqual(Math.Abs(v1.X), 1.0, allowance) || MathUtil.IsAlmostEqual(Math.Abs(v2.X), 1.0, allowance))) // Consider the opening swing between 30 to 170 degree, beginning at X axis { XYZ yDir; if (MathUtil.IsAlmostEqual(Math.Abs(v1.Y), Math.Abs(Math.Sin(angleOffOfXY)), 0.01)) { yDir = v1; } else { yDir = v2; } // if the Normal is pointing to -Z, it is flipped. Flip the Y if it is if (MathUtil.IsAlmostEqual(trfArc.Normal.Z, -1.0)) { yDir = yDir.Negate(); } // Check the center location in the X-direction to determine LEFT/RIGHT if (trfArc.Center.X >= -tolForArcCenter && trfArc.Center.X <= tolForArcCenter) { // on the LEFT if ((yDir.Y > 0.0 && trfArc.YDirection.Y > 0.0) || (yDir.Y < 0.0 && trfArc.YDirection.Y < 0.0)) { leftPosYArcCount++; } else if ((yDir.Y > 0.0 && trfArc.YDirection.Y < 0.0) || (yDir.Y < 0.0 && trfArc.YDirection.Y > 0.0)) { leftNegYArcCount++; } else { continue; } } else { // on the RIGHT if ((yDir.Y > 0.0 && trfArc.YDirection.Y > 0.0) || (yDir.Y < 0.0 && trfArc.YDirection.Y < 0.0)) { rightPosYArcCount++; } else if ((yDir.Y > 0.0 && trfArc.YDirection.Y < 0.0) || (yDir.Y < 0.0 && trfArc.YDirection.Y > 0.0)) { rightNegYArcCount++; } else { continue; } } } else { continue; } // Collect all distinct Arc Center if it is counted as the door opening, to ensure that for cases that there are more than 2 leafs, it is not worngly labelled bool foundExisting = false; foreach (XYZ existingCenter in arcCenterLocations) { if ((trfArc.Center.X > existingCenter.X - tolForArcCenter) && (trfArc.Center.X <= existingCenter.X + tolForArcCenter) && (trfArc.Center.Y > existingCenter.Y - tolForArcCenter) && (trfArc.Center.Y <= existingCenter.Y + tolForArcCenter)) { foundExisting = true; break; } } if (!foundExisting) { arcCenterLocations.Add(trfArc.Center); arcRadii.Add(trfArc.Radius); } } } // When only full circle(s) exists if (fullCircleCount > 0 && rightHalfCircleCount == 0 && leftHalfCircleCount == 0 && leftPosYArcCount == 0 && leftNegYArcCount == 0 && rightPosYArcCount == 0 && rightNegYArcCount == 0) { return("REVOLVING"); } // There are more than 2 arc centers, no IFC Door operation type fits this, return NOTDEFINED if (arcCenterLocations.Count > 2) { return("NOTDEFINED"); } // When half circle arc(s) exists if (leftHalfCircleCount > 0 && fullCircleCount == 0) { if (rightHalfCircleCount == 0 && leftPosYArcCount == 0 && leftNegYArcCount == 0 && rightPosYArcCount == 0 && rightNegYArcCount == 0) { return("DOUBLE_SWING_LEFT"); } if ((rightHalfCircleCount > 0 || (rightPosYArcCount > 0 && rightNegYArcCount > 0)) && leftPosYArcCount == 0 && leftNegYArcCount == 0) { return("DOUBLE_DOOR_DOUBLE_SWING"); } } if (rightHalfCircleCount > 0 && fullCircleCount == 0) { if (leftHalfCircleCount == 0 && leftPosYArcCount == 0 && leftNegYArcCount == 0 && rightPosYArcCount == 0 && rightNegYArcCount == 0) { return("DOUBLE_SWING_RIGHT"); } if ((leftHalfCircleCount > 0 || (leftPosYArcCount > 0 && leftNegYArcCount > 0)) && rightPosYArcCount == 0 && rightNegYArcCount == 0) { return("DOUBLE_DOOR_DOUBLE_SWING"); } } // When only 90-degree arc(s) exists if (leftPosYArcCount > 0 && fullCircleCount == 0 && rightHalfCircleCount == 0 && leftHalfCircleCount == 0 && leftNegYArcCount == 0 && rightPosYArcCount == 0 && rightNegYArcCount == 0) { // if the arc is less than 50%of the boundingbox, treat this to be a door with partially fixed panel if (arcRadii.Max < (bbMax.X - bbMin.X) * 0.5) { if (ExporterCacheManager.ExportOptionsCache.ExportAsOlderThanIFC4) { return("NOTDEFINED"); } else { return("SWING_FIXED_LEFT"); } } else { return("SINGLE_SWING_LEFT"); } } if (rightPosYArcCount > 0 && fullCircleCount == 0 && rightHalfCircleCount == 0 && leftHalfCircleCount == 0 && leftNegYArcCount == 0 && leftPosYArcCount == 0 && rightNegYArcCount == 0) { // if the arc is less than 50%of the boundingbox, treat this to be a door with partially fixed panel if (arcRadii.Max < (bbMax.X - bbMin.X) * 0.5) { if (ExporterCacheManager.ExportOptionsCache.ExportAsOlderThanIFC4) { return("NOTDEFINED"); } else { return("SWING_FIXED_RIGHT"); } } else { return("SINGLE_SWING_RIGHT"); } } if (leftPosYArcCount > 0 && leftNegYArcCount > 0 && fullCircleCount == 0 && rightHalfCircleCount == 0 && leftHalfCircleCount == 0 && rightPosYArcCount == 0 && rightNegYArcCount == 0) { return("DOUBLE_SWING_LEFT"); } if (rightPosYArcCount > 0 && rightNegYArcCount > 0 && fullCircleCount == 0 && rightHalfCircleCount == 0 && leftHalfCircleCount == 0 && leftNegYArcCount == 0 && leftPosYArcCount == 0) { return("DOUBLE_SWING_RIGHT"); } if (leftPosYArcCount > 0 && rightPosYArcCount > 0 && fullCircleCount == 0 && rightHalfCircleCount == 0 && leftHalfCircleCount == 0 && leftNegYArcCount == 0 && rightNegYArcCount == 0) { return("DOUBLE_DOOR_SINGLE_SWING"); } if (leftPosYArcCount > 0 && rightPosYArcCount > 0 && leftNegYArcCount > 0 && rightNegYArcCount > 0 && fullCircleCount == 0 && rightHalfCircleCount == 0 && leftHalfCircleCount == 0) { return("DOUBLE_DOOR_DOUBLE_SWING"); } if (leftPosYArcCount > 0 && rightNegYArcCount > 0 && fullCircleCount == 0 && rightHalfCircleCount == 0 && leftHalfCircleCount == 0 && leftNegYArcCount == 0 && rightPosYArcCount == 0) { return("DOUBLE_DOOR_SINGLE_SWING_OPPOSITE_RIGHT"); } if (leftNegYArcCount > 0 && rightPosYArcCount > 0 && fullCircleCount == 0 && rightHalfCircleCount == 0 && leftHalfCircleCount == 0 && leftPosYArcCount == 0 && rightNegYArcCount == 0) { return("DOUBLE_DOOR_SINGLE_SWING_OPPOSITE_LEFT"); } return("NOTDEFINED"); }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication app = commandData.Application; UIDocument uidoc = app.ActiveUIDocument; Document doc = uidoc.Document; // retrieve all FamilySymbol objects of "Windows" category: BuiltInCategory bic = BuiltInCategory.OST_Windows; FilteredElementCollector symbols = LabUtils.GetFamilySymbols(doc, bic); List <string> a = new List <string>(); foreach (FamilySymbol s in symbols) { Family fam = s.Family; a.Add(s.Name + ", Id=" + s.Id.IntegerValue.ToString() + "; Family name=" + fam.Name + ", Family Id=" + fam.Id.IntegerValue.ToString()); } LabUtils.InfoMsg("{0} windows family symbol{1} loaded in the model{1}", a); // loop through the selection set and check for // standard family instances of "Windows" category: int iBic = (int)bic; string msg, content; ICollection <ElementId> ids = uidoc.Selection.GetElementIds(); foreach (ElementId id in ids) { Element e = doc.GetElement(id); if (e is FamilyInstance && null != e.Category && e.Category.Id.IntegerValue.Equals(iBic)) { msg = "Selected window Id=" + e.Id.IntegerValue.ToString(); FamilyInstance inst = e as FamilyInstance; #region 3.3 Retrieve the type of the family instance, and the family of the type: FamilySymbol fs = inst.Symbol; Family f = fs.Family; #endregion // 3.3 content = "FamilySymbol = " + fs.Name + "; Id=" + fs.Id.IntegerValue.ToString(); content += "\r\n Family = " + f.Name + "; Id=" + f.Id.IntegerValue.ToString(); LabUtils.InfoMsg(msg, content); } } return(Result.Succeeded); }
///<summary>Adds the xml for one statement.</summary> public static void GenerateOneStatement(XmlWriter writer, Statement stmt, Patient pat, Family fam, DataSet dataSet) { writer.WriteStartElement("Statement"); writer.WriteStartElement("RecipientAddress"); Patient guar = fam.ListPats[0]; writer.WriteElementString("Name", guar.GetNameFLFormal()); if (PrefC.GetBool(PrefName.StatementAccountsUseChartNumber)) { writer.WriteElementString("Account", guar.ChartNumber); } else { writer.WriteElementString("Account", POut.Long(guar.PatNum)); } writer.WriteElementString("Address1", guar.Address); writer.WriteElementString("Address2", guar.Address2); writer.WriteElementString("City", guar.City); writer.WriteElementString("State", guar.State); writer.WriteElementString("Zip", guar.Zip); string email = ""; Def billingDef = Defs.GetDef(DefCat.BillingTypes, guar.BillingType); if (billingDef.ItemValue == "E") { email = guar.Email; } writer.WriteElementString("EMail", email); writer.WriteEndElement(); //RecipientAddress //Account summary----------------------------------------------------------------------- if (stmt.DateRangeFrom.Year < 1880) //make up a statement date. { writer.WriteElementString("PriorStatementDate", DateTime.Today.AddMonths(-1).ToString("MM/dd/yyyy")); } else { writer.WriteElementString("PriorStatementDate", stmt.DateRangeFrom.AddDays(-1).ToString("MM/dd/yyyy")); } DateTime dueDate; if (PrefC.GetLong(PrefName.StatementsCalcDueDate) == -1) { dueDate = DateTime.Today.AddDays(10); } else { dueDate = DateTime.Today.AddDays(PrefC.GetLong(PrefName.StatementsCalcDueDate)); } writer.WriteElementString("DueDate", dueDate.ToString("MM/dd/yyyy")); writer.WriteElementString("StatementDate", stmt.DateSent.ToString("MM/dd/yyyy")); double balanceForward = 0; for (int r = 0; r < dataSet.Tables["misc"].Rows.Count; r++) { if (dataSet.Tables["misc"].Rows[r]["descript"].ToString() == "balanceForward") { balanceForward = PIn.Double(dataSet.Tables["misc"].Rows[r]["value"].ToString()); } } writer.WriteElementString("PriorBalance", balanceForward.ToString("F2")); DataTable tableAccount = null; for (int i = 0; i < dataSet.Tables.Count; i++) { if (dataSet.Tables[i].TableName.StartsWith("account")) { tableAccount = dataSet.Tables[i]; } } double credits = 0; for (int i = 0; i < tableAccount.Rows.Count; i++) { credits += PIn.Double(tableAccount.Rows[i]["creditsDouble"].ToString()); } writer.WriteElementString("Credits", credits.ToString("F2")); decimal payPlanDue = 0; double amountDue = guar.BalTotal; for (int m = 0; m < dataSet.Tables["misc"].Rows.Count; m++) { if (dataSet.Tables["misc"].Rows[m]["descript"].ToString() == "payPlanDue") { payPlanDue += PIn.Decimal(dataSet.Tables["misc"].Rows[m]["value"].ToString()); //This will be an option once more users are using it. } } writer.WriteElementString("PayPlanDue", payPlanDue.ToString("F2")); if (PrefC.GetBool(PrefName.BalancesDontSubtractIns)) { writer.WriteElementString("EstInsPayments", ""); //optional. } else //this is typical { writer.WriteElementString("EstInsPayments", guar.InsEst.ToString("F2")); //optional. amountDue -= guar.InsEst; } InstallmentPlan installPlan = InstallmentPlans.GetOneForFam(guar.PatNum); if (installPlan != null) { //show lesser of normal total balance or the monthly payment amount. if (installPlan.MonthlyPayment < amountDue) { amountDue = installPlan.MonthlyPayment; } } writer.WriteElementString("AmountDue", amountDue.ToString("F2")); writer.WriteElementString("PastDue30", guar.Bal_31_60.ToString("F2")); //optional writer.WriteElementString("PastDue60", guar.Bal_61_90.ToString("F2")); //optional writer.WriteElementString("PastDue90", guar.BalOver90.ToString("F2")); //optional //Notes----------------------------------------------------------------------------------- writer.WriteStartElement("Notes"); if (stmt.NoteBold != "") { writer.WriteStartElement("Note"); writer.WriteAttributeString("FgColor", "Red"); writer.WriteCData(stmt.NoteBold); writer.WriteEndElement(); //Note } if (stmt.Note != "") { writer.WriteStartElement("Note"); writer.WriteCData(stmt.Note); writer.WriteEndElement(); //Note } writer.WriteEndElement(); //Notes //Detail items------------------------------------------------------------------------------ writer.WriteStartElement("DetailItems"); //string note; string descript; string fulldesc; string procCode; string tth; //string linedesc; string[] lineArray; List <string> lines; DateTime date; int seq = 0; for (int i = 0; i < tableAccount.Rows.Count; i++) { procCode = tableAccount.Rows[i]["ProcCode"].ToString(); tth = tableAccount.Rows[i]["tth"].ToString(); descript = tableAccount.Rows[i]["description"].ToString(); fulldesc = procCode + " " + tth + " " + descript; lineArray = fulldesc.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); lines = new List <string>(lineArray); //The specs say that the line limit is 30 char. But in testing, it will take 50 char. //We will use 40 char to be safe. if (lines[0].Length > 40) { string newline = lines[0].Substring(40); lines[0] = lines[0].Substring(0, 40); //first half lines.Insert(1, newline); //second half } for (int li = 0; li < lines.Count; li++) { writer.WriteStartElement("DetailItem"); //has a child item. We won't add optional child note writer.WriteAttributeString("sequence", seq.ToString()); writer.WriteStartElement("Item"); if (li == 0) { date = (DateTime)tableAccount.Rows[i]["DateTime"]; writer.WriteElementString("Date", date.ToString("MM/dd/yyyy")); writer.WriteElementString("PatientName", tableAccount.Rows[i]["patient"].ToString()); } else { writer.WriteElementString("Date", ""); writer.WriteElementString("PatientName", ""); } writer.WriteElementString("Description", lines[li]); if (li == 0) { writer.WriteElementString("Charges", tableAccount.Rows[i]["charges"].ToString()); writer.WriteElementString("Credits", tableAccount.Rows[i]["credits"].ToString()); writer.WriteElementString("Balance", tableAccount.Rows[i]["balance"].ToString()); } else { writer.WriteElementString("Charges", ""); writer.WriteElementString("Credits", ""); writer.WriteElementString("Balance", ""); } writer.WriteEndElement(); //Item writer.WriteEndElement(); //DetailItem seq++; } } writer.WriteEndElement(); //DetailItems writer.WriteEndElement(); //Statement }
public static void RefreshModuleData_end(object sender, Family famCur, Patient patCur) { contrAccountP.FamCur = famCur; contrAccountP.PatCur = patCur; }
public void ShouldWorkLoadingComplexEntities() { const string crocodileFather = "Crocodile father"; const string crocodileMother = "Crocodile mother"; using (ISession s = sessions.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { var rf = new Reptile { Description = crocodileFather }; var rm = new Reptile { Description = crocodileMother }; var rc1 = new Reptile { Description = "Crocodile" }; var rc2 = new Reptile { Description = "Crocodile" }; var rfamily = new Family <Reptile> { Father = rf, Mother = rm, Childs = new HashedSet <Reptile> { rc1, rc2 } }; s.Save("ReptileFamily", rfamily); tx.Commit(); } const string humanFather = "Fred"; const string humanMother = "Wilma"; using (ISession s = sessions.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { var hf = new Human { Description = "Flinstone", Name = humanFather }; var hm = new Human { Description = "Flinstone", Name = humanMother }; var hc1 = new Human { Description = "Flinstone", Name = "Pebbles" }; var hfamily = new Family <Human> { Father = hf, Mother = hm, Childs = new HashedSet <Human> { hc1 } }; s.Save("HumanFamily", hfamily); tx.Commit(); } using (IStatelessSession s = sessions.OpenStatelessSession()) using (ITransaction tx = s.BeginTransaction()) { IList <Family <Human> > hf = s.CreateQuery("from HumanFamily").List <Family <Human> >(); Assert.That(hf.Count, Is.EqualTo(1)); Assert.That(hf[0].Father.Name, Is.EqualTo(humanFather)); Assert.That(hf[0].Mother.Name, Is.EqualTo(humanMother)); NHibernateUtil.IsInitialized(hf[0].Childs).Should("Lazy collection should NOT be initialized").Be.False(); IList <Family <Reptile> > rf = s.CreateQuery("from ReptileFamily").List <Family <Reptile> >(); Assert.That(rf.Count, Is.EqualTo(1)); Assert.That(rf[0].Father.Description, Is.EqualTo(crocodileFather)); Assert.That(rf[0].Mother.Description, Is.EqualTo(crocodileMother)); NHibernateUtil.IsInitialized(hf[0].Childs).Should("Lazy collection should NOT be initialized").Be.False(); tx.Commit(); } using (ISession s = sessions.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { s.Delete("from HumanFamily"); s.Delete("from ReptileFamily"); tx.Commit(); } }
static void Main(string[] args) { Engine engine = new Engine(); Family family1 = Family.All(typeof(ComponentA), typeof(ComponentB)).Get(); engine.GetEntitiesFor(family1); Family family2 = Family.All(typeof(ComponentA), typeof(ComponentC)).Get(); engine.GetEntitiesFor(family2); Family family3 = Family.All(typeof(ComponentA), typeof(ComponentE)).Get(); engine.GetEntitiesFor(family3); Family family4 = Family.All(typeof(ComponentA), typeof(ComponentF)).Get(); engine.GetEntitiesFor(family4); Family family5 = Family.All(typeof(ComponentF)).Exclude(typeof(ComponentD)).Get(); engine.GetEntitiesFor(family5); Family family6 = Family.All(typeof(ComponentF)).Exclude(typeof(ComponentE)).Get(); engine.GetEntitiesFor(family6); Family family7 = Family.All(typeof(ComponentD)).Exclude(typeof(ComponentC)).Get(); engine.GetEntitiesFor(family7); Family family8 = Family.All(typeof(ComponentD)).Exclude(typeof(ComponentA)).Get(); engine.GetEntitiesFor(family8); Stopwatch stopwatch = new Stopwatch(); // Add entities stopwatch.Start(); int count = 10000; for (int i = 0; i < count; i++) { Entity entity = engine.CreateEntity(); entity.AddComponent(new ComponentA()); entity.AddComponent(new ComponentB()); entity.AddComponent(new ComponentD()); entity.AddComponent(new ComponentG()); entity.AddComponent(new ComponentE()); entity.RemoveComponent <ComponentF>(); } stopwatch.Stop(); Console.WriteLine($"Added and removed components from {count} entities using sparse arrays, which took:"); Console.WriteLine(stopwatch.ElapsedMilliseconds); //Engine engine = new Engine(); //Family family1 = Family.All(typeof(ComponentA), typeof(ComponentB)).Get(); //engine.GetEntitiesFor(family1); //Family family2 = Family.All(typeof(ComponentA), typeof(ComponentC)).Get(); //engine.GetEntitiesFor(family2); //Family family3 = Family.All(typeof(ComponentA), typeof(ComponentE)).Get(); //engine.GetEntitiesFor(family3); //Family family4 = Family.All(typeof(ComponentA), typeof(ComponentF)).Get(); //engine.GetEntitiesFor(family4); //Family family5 = Family.All(typeof(ComponentF)).Exclude(typeof(ComponentD)).Get(); //engine.GetEntitiesFor(family5); //Family family6 = Family.All(typeof(ComponentF)).Exclude(typeof(ComponentE)).Get(); //engine.GetEntitiesFor(family6); //Family family7 = Family.All(typeof(ComponentD)).Exclude(typeof(ComponentC)).Get(); //engine.GetEntitiesFor(family7); //Family family8 = Family.All(typeof(ComponentD)).Exclude(typeof(ComponentA)).Get(); //engine.GetEntitiesFor(family8); //Stopwatch stopwatch = new Stopwatch(); //// Add entities //stopwatch.Start(); //int count = 10000; //for(int i = 0; i < count; i++) //{ // Entity entity = engine.CreateEntity(); // entity.AddComponent(new ComponentA()); // entity.AddComponent(new ComponentF()); // entity.AddComponent(new ComponentD()); // entity.AddComponent(new ComponentG()); // entity.AddComponent(new ComponentE()); // entity.RemoveComponent<ComponentF>(); //} //stopwatch.Stop(); //Console.WriteLine($"Added and removed components from {count} entities using cached lists, which took:"); //Console.WriteLine(stopwatch.ElapsedMilliseconds); }
public FamilyWriter(Family family, TextWriter writer) { _writer = writer; _flattener = new Flattener(family); }
public Family Update(Family family) { var Family = _familyRepository.Update(family); return(Family); }
public override string ToString() { return(Family.ToString()); }
GetFilteredNestedFamilyInstances( string familyFileNameFilter, string typeNameFilter, Document familyDocument, bool caseSensitiveFiltering) { // Following good SOA practices, verify the // incoming data can be worked with. ValidateFamilyDocument(familyDocument); // Throws an exception if not a family doc // The filters can be null List <FamilyInstance> oResult = new List <FamilyInstance>(); FamilyInstance oFamilyInstanceCandidate; FamilySymbol oFamilySymbolCandidate; List <Family> oMatchingNestedFamilies = new List <Family>(); List <FamilyInstance> oAllFamilyInstances = new List <FamilyInstance>(); bool bFamilyFileNameFilterExists = true; bool bTypeNameFilterExists = true; // Set up some fast-to-test boolean values, which will be // used for short-circuit Boolean evaluation later. if (string.IsNullOrEmpty(familyFileNameFilter)) { bFamilyFileNameFilterExists = false; } if (string.IsNullOrEmpty(typeNameFilter)) { bTypeNameFilterExists = false; } // Unfortunately detecting nested families in a family document requires iterating // over all the elements in the document, because the built-in filtering mechanism // doesn't work for this case. However, families typically don't have nearly as many // elements as a whole project, so the performance hit shouldn't be too bad. // Still, the fastest performance should come by iterating over all elements in the given // family document exactly once, keeping subsets of the family instances found for // later testing against the nested family file matches found. ElementClassFilter fFamilyClass = new ElementClassFilter(typeof(Family)); ElementClassFilter fFamInstClass = new ElementClassFilter(typeof(FamilyInstance)); LogicalOrFilter f = new LogicalOrFilter(fFamilyClass, fFamInstClass); FilteredElementCollector collector = new FilteredElementCollector(familyDocument); collector.WherePasses(f); foreach (Element e in collector) { // See if this is a family file nested into the current family document. Family oNestedFamilyFileCandidate = e as Family; if (oNestedFamilyFileCandidate != null) { // Must ask the "Element" version for it's name, because the Family object's // name is always the empty string. if (!bFamilyFileNameFilterExists || FilterMatches(oNestedFamilyFileCandidate.Name, familyFileNameFilter, caseSensitiveFiltering)) { // This is a nested family file, and either no valid family file name filter was // given, or the name of this family file matches the filter. oMatchingNestedFamilies.Add(oNestedFamilyFileCandidate); } } else { // This element is not a nested family file definition, see if it's a // nested family instance. oFamilyInstanceCandidate = e as FamilyInstance; if (oFamilyInstanceCandidate != null) { // Just add the family instance to our "all" collection for later testing // because we may not have yet found all the matching nested family file // definitions. oAllFamilyInstances.Add(oFamilyInstanceCandidate); } } } // End iterating over all the elements in the family document exactly once // See if any matching nested family file definitions were found. Only do any // more work if at least one was found. foreach (Family oMatchingNestedFamilyFile in oMatchingNestedFamilies) { // Count backwards through the all family instances list. As we find // matches on this iteration through the matching nested families, we can // delete them from the candidates list to reduce the number of family // instance candidates to test for later matching nested family files to be tested for (int iCounter = oAllFamilyInstances.Count - 1; iCounter >= 0; iCounter--) { oFamilyInstanceCandidate = oAllFamilyInstances[iCounter]; #if _2010 oFamilySymbolCandidate = oFamilyInstanceCandidate.ObjectType as FamilySymbol; #endif // _2010 ElementId id = oFamilyInstanceCandidate.GetTypeId(); oFamilySymbolCandidate = familyDocument.GetElement(id) as FamilySymbol; if (oFamilySymbolCandidate.Family.UniqueId == oMatchingNestedFamilyFile.UniqueId) { // Only add this family instance to the results if there was no type name // filter, or this family instance's type matches the given filter. if (!bTypeNameFilterExists || FilterMatches(oFamilyInstanceCandidate.Name, typeNameFilter, caseSensitiveFiltering)) { oResult.Add(oFamilyInstanceCandidate); } // No point in testing this one again, // since we know its family definition // has already been processed. oAllFamilyInstances.RemoveAt(iCounter); } } // Next family instance candidate } // End of for each matching nested family file definition found return(oResult); }
/// <summary> /// Replace the Family document in the collection. /// </summary> /// <param name="databaseName">The name/ID of the database.</param> /// <param name="collectionName">The name/ID of the collection.</param> /// <param name="familyName">The name/ID of the document</param> /// <param name="updatedFamily">The family document to be replaced.</param> /// <returns>The Task for asynchronous execution.</returns> private async Task ReplaceFamilyDocument(string databaseName, string collectionName, string familyName, Family updatedFamily) { try { await this.client.ReplaceDocumentAsync(UriFactory.CreateDocumentUri(databaseName, collectionName, familyName), updatedFamily); this.WriteToConsoleAndPromptToContinue("Replaced Family {0}", familyName); } catch (DocumentClientException de) { throw de; } }
public static void PrintFamily(Family family) { Console.WriteLine(family); }
private void Stream( ArrayList data, Family fam ) { data.Add( new Snoop.Data.ClassSeparator( typeof( Family ) ) ); Category category = fam.FamilyCategory; data.Add( new Snoop.Data.Object( "Family category", category ) ); //List<FamilySymbol> symbols = new List<FamilySymbol>(); //foreach (ElementId id in fam.GetFamilySymbolIds()) //{ // symbols.Add( fam.Document.GetElement( id ) as FamilySymbol ); //} //data.Add( new Snoop.Data.Enumerable( "Symbols", fam.Symbols ) ); // 2015, jeremy: 'Autodesk.Revit.DB.Family.Symbols' is obsolete: 'This property is obsolete in Revit 2015. Use Family.GetFamilySymbolIds() instead.' data.Add( new Snoop.Data.Enumerable( "Symbols", fam.GetFamilySymbolIds() ) ); // 2016, jeremy data.Add( new Snoop.Data.Bool( "Is InPlace", fam.IsInPlace ) ); data.Add( new Snoop.Data.Bool( "Is CurtainPanelFamily", fam.IsCurtainPanelFamily ) ); if( fam.IsInPlace == false ) { try { data.Add( new Snoop.Data.Object( "Family Document", fam.Document.EditFamily( fam ) ) ); } catch( Exception ex ) { data.Add( new Snoop.Data.Exception( "FamilyDocument", new Exception( ex.Message, ex ) ) ); } } if( fam.IsCurtainPanelFamily ) { data.Add( new Snoop.Data.Double( "Curtain Panel Horiz Spacing", fam.CurtainPanelHorizontalSpacing ) ); data.Add( new Snoop.Data.Double( "Curtain Panel Vert Spacing", fam.CurtainPanelVerticalSpacing ) ); data.Add( new Snoop.Data.String( "Curtain Panel Tile Spacing", fam.CurtainPanelTilePattern.ToString() ) ); } // data.Add(new Snoop.Data.Enumerable("Components", fam.Components)); // data.Add(new Snoop.Data.Enumerable("Loaded symbols", fam.LoadedSymbols)); }
private readonly Document _fd; // Passed in Family Document #endregion Fields #region Constructors /// <summary> /// Constructor /// </summary> /// <param name="fd">Family Document</param> /// <param name="f">Family Element</param> public clsFamData(Document fd, Family f) { // Widen Scope _f = f; _fd = fd; }
/// <summary> /// Creates the documents used in this Sample /// </summary> /// <param name="collectionUri">The selfLink property for the DocumentCollection where documents will be created.</param> /// <returns>None</returns> private static async Task CreateDocuments(Uri collectionUri) { Family AndersonFamily = new Family { Id = "AndersenFamily", LastName = "Andersen", Parents = new Parent[] { new Parent { FirstName = "Thomas" }, new Parent { FirstName = "Mary Kay" } }, Children = new Child[] { new Child { FirstName = "Henriette Thaulow", Gender = "female", Grade = 5, Pets = new [] { new Pet { GivenName = "Fluffy" } } } }, Address = new Address { State = "WA", County = "King", City = "Seattle" }, IsRegistered = true }; await client.CreateDocumentAsync(collectionUri, AndersonFamily); Family WakefieldFamily = new Family { Id = "WakefieldFamily", LastName = "Wakefield", Parents = new[] { new Parent { FamilyName = "Wakefield", FirstName = "Robin" }, new Parent { FamilyName = "Miller", FirstName = "Ben" } }, Children = new Child[] { new Child { FamilyName = "Merriam", FirstName = "Jesse", Gender = "female", Grade = 8, Pets = new Pet[] { new Pet { GivenName = "Goofy" }, new Pet { GivenName = "Shadow" } } }, new Child { FirstName = "Lisa", Gender = "female", Grade = 1 } }, Address = new Address { State = "NY", County = "Manhattan", City = "NY" }, IsRegistered = false }; await client.CreateDocumentAsync(collectionUri, WakefieldFamily); }
public FamilyJsonWarpper(FamilyAdapter familyAdapter) { Family = familyAdapter; }
public bool Equals([AllowNull] Font other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return((Family == other.Family && Family != null && other.Family != null && Family.Equals(other.Family)) && (Size == other.Size && Size != null && other.Size != null && Size.Equals(other.Size)) && (Color == other.Color && Color != null && other.Color != null && Color.Equals(other.Color))); }
public static PetStruct GetPetStruct(RealmManager manager, Family? petFamily, Rarity rarity) { Random rand = new Random((int)DateTime.Now.Ticks); List<PetStruct> structs = new List<PetStruct>(); Rarity petRarity = rarity; if (rarity == Rarity.Uncommon) petRarity = Rarity.Common; else if (rarity == Rarity.Legendary) petRarity = Rarity.Rare; foreach (var x in manager.GameData.TypeToPet) { if (petFamily == null && x.Value.PetRarity == petRarity) { structs.Add(x.Value); continue; } if (x.Value.PetFamily == petFamily && x.Value.PetRarity == petRarity) structs.Add(x.Value); } PetStruct petStruct = structs[rand.Next(structs.Count)]; return petStruct; }
public void OnGet() { Family = FamilyService.GetFamily(); }
/// <summary> /// Create the Family document in the collection if another by the same ID doesn't already exist. /// </summary> /// <param name="databaseName">The name/ID of the database.</param> /// <param name="collectionName">The name/ID of the collection.</param> /// <param name="family">The family document to be created.</param> /// <returns>The Task for asynchronous execution.</returns> private async Task CreateFamilyDocumentIfNotExists(string databaseName, string collectionName, Family family) { try { await this.client.ReadDocumentAsync(UriFactory.CreateDocumentUri(databaseName, collectionName, family.Id)); this.WriteToConsoleAndPromptToContinue("Found {0}", family.Id); } catch (DocumentClientException de) { if (de.StatusCode == HttpStatusCode.NotFound) { await this.client.CreateDocumentAsync(UriFactory.CreateDocumentCollectionUri(databaseName, collectionName), family); this.WriteToConsoleAndPromptToContinue("Created Family {0}", family.Id); } else { throw; } } }
public bool Equals([AllowNull] Font other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return((Family == other.Family && Family != null && other.Family != null && Family.Equals(other.Family)) && (Equals(FamilyArray, other.FamilyArray) || FamilyArray != null && other.FamilyArray != null && FamilyArray.SequenceEqual(other.FamilyArray)) && (Size == other.Size && Size != null && other.Size != null && Size.Equals(other.Size)) && (Equals(SizeArray, other.SizeArray) || SizeArray != null && other.SizeArray != null && SizeArray.SequenceEqual(other.SizeArray)) && (Color == other.Color && Color != null && other.Color != null && Color.Equals(other.Color)) && (Equals(ColorArray, other.ColorArray) || ColorArray != null && other.ColorArray != null && ColorArray.SequenceEqual(other.ColorArray)) && (FamilySrc == other.FamilySrc && FamilySrc != null && other.FamilySrc != null && FamilySrc.Equals(other.FamilySrc)) && (SizeSrc == other.SizeSrc && SizeSrc != null && other.SizeSrc != null && SizeSrc.Equals(other.SizeSrc)) && (ColorSrc == other.ColorSrc && ColorSrc != null && other.ColorSrc != null && ColorSrc.Equals(other.ColorSrc))); }
/// <summary> /// Run the get started demo for Azure DocumentDB. This creates a database, collection, two documents, executes a simple query /// and cleans up. /// </summary> /// <returns>The Task for asynchronous completion.</returns> private async Task GetStartedDemo() { // Create a new instance of the DocumentClient this.client = new DocumentClient(new Uri(EndpointUri), PrimaryKey); await this.CreateDatabaseIfNotExists("FamilyDB_og"); await this.CreateDocumentCollectionIfNotExists("FamilyDB_og", "FamilyCollection_og"); // Insert a document, here we create a Family object Family andersenFamily = new Family { Id = "Andersen.1", LastName = "Andersen", Parents = new Parent[] { new Parent { FirstName = "Thomas" }, new Parent { FirstName = "Mary Kay" } }, Children = new Child[] { new Child { FirstName = "Henriette Thaulow", Gender = "female", Grade = 5, Pets = new Pet[] { new Pet { GivenName = "Fluffy" } } } }, Address = new Address { State = "WA", County = "King", City = "Seattle" }, IsRegistered = true }; await this.CreateFamilyDocumentIfNotExists("FamilyDB_og", "FamilyCollection_og", andersenFamily); Family wakefieldFamily = new Family { Id = "Wakefield.7", LastName = "Wakefield", Parents = new Parent[] { new Parent { FamilyName = "Wakefield", FirstName = "Robin" }, new Parent { FamilyName = "Miller", FirstName = "Ben" } }, Children = new Child[] { new Child { FamilyName = "Merriam", FirstName = "Jesse", Gender = "female", Grade = 8, Pets = new Pet[] { new Pet { GivenName = "Goofy" }, new Pet { GivenName = "Shadow" } } }, new Child { FamilyName = "Miller", FirstName = "Lisa", Gender = "female", Grade = 1 } }, Address = new Address { State = "NY", County = "Manhattan", City = "NY" }, IsRegistered = false }; await this.CreateFamilyDocumentIfNotExists("FamilyDB_og", "FamilyCollection_og", wakefieldFamily); this.ExecuteSimpleQuery("FamilyDB_og", "FamilyCollection_og"); // Update the Grade of the Andersen Family child andersenFamily.Children[0].Grade = 6; await this.ReplaceFamilyDocument("FamilyDB_og", "FamilyCollection_og", "Andersen.1", andersenFamily); this.ExecuteSimpleQuery("FamilyDB_og", "FamilyCollection_og"); // Delete the document await this.DeleteFamilyDocument("FamilyDB_og", "FamilyCollection_og", "Andersen.1"); // Clean up/delete the database and client await this.client.DeleteDatabaseAsync(UriFactory.CreateDatabaseUri("FamilyDB_og")); }
/// <summary> /// List all import instances in all the given families. /// Retrieve nested families and recursively search in these as well. /// </summary> void ListImportsAndSearchForMore( int recursionLevel, Document doc, Dictionary <string, Family> families) { string indent = new string( ' ', 2 * recursionLevel ); List <string> keys = new List <string>( families.Keys); keys.Sort(); foreach (string key in keys) { Family family = families[key]; if (family.IsInPlace) { Debug.Print(indent + "Family '{0}' is in-place.", key); } else { Document fdoc = doc.EditFamily(family); FilteredElementCollector c = new FilteredElementCollector(doc); c.OfClass(typeof(ImportInstance)); IList <Element> imports = c.ToElements(); int n = imports.Count; Debug.Print(indent + "Family '{0}' contains {1} import instance{2}{3}", key, n, Util.PluralSuffix(n), Util.DotOrColon(n)); if (0 < n) { foreach (ImportInstance i in imports) { string s = i.Pinned ? "" : "not "; //string name = i.ObjectType.Name; // 2011 string name = doc.GetElement(i.GetTypeId()).Name; // 2012 Debug.Print(indent + " '{0}' {1}pinned", name, s); i.Pinned = !i.Pinned; } } Dictionary <string, Family> nestedFamilies = GetFamilies(fdoc); ListImportsAndSearchForMore( recursionLevel + 1, fdoc, nestedFamilies); } } }
public static async Task AddFamily(DocumentClient client,DocumentCollection collection, string name) { var family = new Family { Address = new Dictionary<string, string> {{"state", "fl"}}, Childrend = new List<FamilyMemeber> { new FamilyMemeber {Age = 10, Gender = "female", Name = "susy"}, new FamilyMemeber {Age = 8, Gender = "male", Name = "jimmy"} }, IsHome = true, Parents = new List<FamilyMemeber> { new FamilyMemeber {Age = 45, Gender = "female", Name = "Linda"}, new FamilyMemeber {Age = 40, Gender = "male", Name = "Bob"} }, Name = name }; await client.CreateDocumentAsync(collection.DocumentsLink, family); }
/// <summary> /// Non-recursively list all import instances /// in all families used in the current project document. /// </summary> public Result ExecuteWithoutRecursion( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication app = commandData.Application; Document doc = app.ActiveUIDocument.Document; FilteredElementCollector instances = new FilteredElementCollector(doc); instances.OfClass(typeof(FamilyInstance)); Dictionary <string, Family> families = new Dictionary <string, Family>(); foreach (FamilyInstance i in instances) { Family family = i.Symbol.Family; if (!families.ContainsKey(family.Name)) { families[family.Name] = family; } } List <string> keys = new List <string>( families.Keys); keys.Sort(); foreach (string key in keys) { Family family = families[key]; if (family.IsInPlace) { Debug.Print("Family '{0}' is in-place.", key); } else { Document fdoc = doc.EditFamily(family); FilteredElementCollector c = new FilteredElementCollector(doc); c.OfClass(typeof(ImportInstance)); IList <Element> imports = c.ToElements(); int n = imports.Count; Debug.Print( "Family '{0}' contains {1} import instance{2}{3}", key, n, Util.PluralSuffix(n), Util.DotOrColon(n)); if (0 < n) { foreach (ImportInstance i in imports) { //string name = i.ObjectType.Name; // 2011 string name = doc.GetElement(i.GetTypeId()).Name; // 2012 Debug.Print(" '{0}'", name); } } } } return(Result.Failed); }
/// <summary> /// Find a specific family type for a door. /// another approach will be to look up from Family, then from Family.Symbols property. /// This gets more complicated although it is logical approach. /// </summary> public Element FindFamilyType_Door_v2(string doorFamilyName, string doorTypeName) { // (1) find the family with the given name. var familyCollector = new FilteredElementCollector(_doc); familyCollector.OfClass(typeof(Family)); // Use the iterator Family doorFamily = null; FilteredElementIterator familyItr = familyCollector.GetElementIterator(); //familyItr.Reset(); while ((familyItr.MoveNext())) { Family fam = (Family)familyItr.Current; // Check name and categoty if ((fam.Name == doorFamilyName) & (fam.FamilyCategory.Id.IntegerValue == (int)BuiltInCategory.OST_Doors)) { // We found the family. doorFamily = fam; break; } } // (2) Find the type with the given name. Element doorType2 = null; // Id of door type we are looking for. if (doorFamily != null) { // If we have a family, then proceed with finding a type under Symbols property. //FamilySymbolSet doorFamilySymbolSet = doorFamily.Symbols; // 'Autodesk.Revit.DB.Family.Symbols' is obsolete: // 'This property is obsolete in Revit 2015. Use Family.GetFamilySymbolIds() instead.' // Iterate through the set of family symbols. //FamilySymbolSetIterator doorTypeItr = doorFamilySymbolSet.ForwardIterator(); //while (doorTypeItr.MoveNext()) //{ // FamilySymbol dType = (FamilySymbol)doorTypeItr.Current; // if ((dType.Name == doorTypeName)) // { // doorType2 = dType; // Found it. // break; // } //} /// Following part is modified code for Revit 2015 ISet <ElementId> familySymbolIds = doorFamily.GetFamilySymbolIds(); if (familySymbolIds.Count > 0) { // Get family symbols which is contained in this family foreach (ElementId id in familySymbolIds) { FamilySymbol dType = doorFamily.Document.GetElement(id) as FamilySymbol; if ((dType.Name == doorTypeName)) { doorType2 = dType; // Found it. break; } } } /// End of modified code for Revit 2015 } return(doorType2); }
public async Task RemoveFamilyAsync(Family family) { await client.DeleteAsync($"{uri}/families/{family.HouseNumber}/{family.StreetName}"); }
/// <summary> /// Creates the documents used in this Sample /// </summary> /// <param name="collectionUri">The selfLink property for the DocumentCollection where documents will be created.</param> /// <returns>None</returns> private static async Task CreateDocuments(Uri collectionUri) { Family AndersonFamily = new Family { Id = "AndersenFamily", LastName = "Andersen", Parents = new Parent[] { new Parent { FirstName = "Thomas" }, new Parent { FirstName = "Mary Kay"} }, Children = new Child[] { new Child { FirstName = "Henriette Thaulow", Gender = "female", Grade = 5, Pets = new [] { new Pet { GivenName = "Fluffy" } } } }, Address = new Address { State = "WA", County = "King", City = "Seattle" }, IsRegistered = true }; await client.CreateDocumentAsync(collectionUri, AndersonFamily); Family WakefieldFamily = new Family { Id = "WakefieldFamily", LastName = "Wakefield", Parents = new[] { new Parent { FamilyName= "Wakefield", FirstName= "Robin" }, new Parent { FamilyName= "Miller", FirstName= "Ben" } }, Children = new Child[] { new Child { FamilyName= "Merriam", FirstName= "Jesse", Gender= "female", Grade= 8, Pets= new Pet[] { new Pet { GivenName= "Goofy" }, new Pet { GivenName= "Shadow" } } }, new Child { FirstName= "Lisa", Gender= "female", Grade= 1 } }, Address = new Address { State = "NY", County = "Manhattan", City = "NY" }, IsRegistered = false }; await client.CreateDocumentAsync(collectionUri, WakefieldFamily); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIDocument uidoc = commandData.Application.ActiveUIDocument; doc = uidoc.Document; Selection sel = uidoc.Selection; try { IList <FamilyWithImage> allBeamsInfo = Utils.GetInformation.GetAllBeamFamilies(doc); if (allBeamsInfo.Count < 1) { message = Properties.Messages.BeamsForBuilding_NoBeamFamilyLoaded; return(Result.Failed); } BeamsFromEntireBuildingUI currentUI = new BeamsFromEntireBuildingUI(this, allBeamsInfo); currentUI.ShowDialog(); if (currentUI.DialogResult == false) { return(Result.Cancelled); } FamilyWithImage currentFamilyWithImage = currentUI.CurrentFamilyWithImage; Family currentFamily = doc.GetElement(new ElementId(currentFamilyWithImage.FamilyID)) as Family; //for now we will set the symbol for the first beam of that family //later on we will duplicate it and check if it exist or not ElementId fsID = currentFamily.GetFamilySymbolIds().First(); FamilySymbol fs = doc.GetElement(fsID) as FamilySymbol; double beamHeight = Utils.ConvertM.cmToFeet(currentUI.BeamHeight); double beamWidth = Utils.ConvertM.cmToFeet(currentUI.BeamWidth); bool createBeamsInIntermediateLevels = currentUI.CreateBeamsInIntermediateLevels; bool ignoreStandardLevels = currentUI.GroupAndDuplicateLevels; bool isLinked = currentUI.IsLinked; double minWallWidth = Utils.ConvertM.cmToFeet(currentUI.MinWallWidth); IList <LevelInfo> allLevelInfo = currentUI.LevelInfoList; string standardLevelName = currentUI.StandardLevelName; bool pickStandardLevelsByName = currentUI.PickStandardLevelsByName; bool isCaseSensitive = currentUI.IsCaseSensitive; bool isJoinBeams = (bool)currentUI.checkJoinBeams.IsChecked; //Will be set if needed int linkedInstanceID = -1; Transform linkedInstanceTransf = null; IList <string> listOfNames = new List <string>(); listOfNames.Add(standardLevelName); if (isLinked == false) { currentDoc = doc; } else { RevitLinkInstance rvtInstance = doc.GetElement(new ElementId(currentUI.SelectedRevitLinkInfo.Id)) as RevitLinkInstance; currentDoc = rvtInstance.GetLinkDocument(); linkedInstanceTransf = rvtInstance.GetTotalTransform(); linkedInstanceID = currentUI.SelectedRevitLinkInfo.Id; } if (pickStandardLevelsByName) { foreach (LevelInfo currentLevelInfo in allLevelInfo) { if (LevelNameContainsString(currentLevelInfo.levelName, listOfNames, isCaseSensitive)) { currentLevelInfo.isStandardLevel = true; } } } string beamWidthInCm = Math.Round(Utils.ConvertM.feetToCm(beamWidth)).ToString(); string beamHeigthInCm = Math.Round(Utils.ConvertM.feetToCm(beamHeight)).ToString(); string newTypeName = beamWidthInCm + " x " + beamHeigthInCm + "cm"; FamilySymbol currentFamilySymbol = null; using (Transaction t = new Transaction(doc, Properties.Messages.BeamsForBuilding_Transaction)) { t.Start(); if (!Utils.FindElements.thisTypeExist(newTypeName, currentFamily.Name, BuiltInCategory.OST_StructuralFraming, doc)) { currentFamilySymbol = fs.Duplicate(newTypeName) as FamilySymbol; Parameter parameterB = currentFamilySymbol.LookupParameter("b"); Parameter parameterH = currentFamilySymbol.LookupParameter("h"); //TODO check for code like this that can throw exceptions parameterB.Set(beamWidth); parameterH.Set(beamHeight); } else { currentFamilySymbol = Utils.FindElements.findElement(newTypeName, currentFamily.Name, BuiltInCategory.OST_StructuralFraming, doc) as FamilySymbol; } currentFamilySymbol.Activate(); bool isThisTheFirstStandardLevel = true; foreach (LevelInfo currentLevelInfo in allLevelInfo) { if (currentLevelInfo == null) { continue; } if (!currentLevelInfo.willBeNumbered) { continue; } Level currentLevel = currentDoc.GetElement(new ElementId(currentLevelInfo.levelId)) as Level; XYZ minPoint = new XYZ(-9999, -9999, currentLevel.ProjectElevation - 0.1); XYZ maxPoint = new XYZ(9999, 9999, currentLevel.ProjectElevation + 0.1); Outline levelOutLine = new Outline(minPoint, maxPoint); BoundingBoxIntersectsFilter levelBBIntersect = new BoundingBoxIntersectsFilter(levelOutLine, 0.05); BoundingBoxIsInsideFilter levelBBInside = new BoundingBoxIsInsideFilter(levelOutLine, 0.05); LogicalOrFilter levelInsideOrIntersectFilter = new LogicalOrFilter(levelBBInside, levelBBIntersect); IList <Element> wallsThatIntersectsCurrentLevel = new FilteredElementCollector(currentDoc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType() .WherePasses(levelInsideOrIntersectFilter).ToList(); if (currentLevelInfo.isStandardLevel && ignoreStandardLevels) { if (isThisTheFirstStandardLevel) { isThisTheFirstStandardLevel = false; } else { continue; } } foreach (Element currentWallElment in wallsThatIntersectsCurrentLevel) { Wall currentWall = currentWallElment as Wall; //wall is valid? if (currentWall == null) { continue; } if (currentWall.Width < minWallWidth) { continue; } if (!createBeamsInIntermediateLevels) { if (currentWallElment.get_Parameter(BuiltInParameter.WALL_BASE_CONSTRAINT).AsElementId() != currentLevel.Id && currentWallElment.get_Parameter(BuiltInParameter.WALL_HEIGHT_TYPE).AsElementId() != currentLevel.Id) { continue; } } LocationCurve wallLocationCurve = currentWall.Location as LocationCurve; //we need to verify if this wall has locationCurve if (wallLocationCurve == null) { continue; } Curve wallCurve = ((currentWall.Location) as LocationCurve).Curve; if (isLinked) { wallCurve = wallCurve.CreateTransformed(linkedInstanceTransf); } double wallBaseOffset = currentWall.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET).AsDouble(); Level wallBaseLevel = currentDoc.GetElement(currentWall.get_Parameter(BuiltInParameter.WALL_BASE_CONSTRAINT).AsElementId()) as Level; double wallBaseTotalHeight = wallBaseLevel.ProjectElevation + wallBaseOffset; double wallTotalHeight = currentWall.get_Parameter(BuiltInParameter.WALL_USER_HEIGHT_PARAM).AsDouble(); if (wallTotalHeight < beamHeight) { continue; } double levelHeight = currentLevel.ProjectElevation; Level currentLevelInProject = null; if (isLinked) { levelHeight += linkedInstanceTransf.Origin.Z; IList <Level> allLevelsInProject = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Levels).OfClass(typeof(Level)).Cast <Level>().ToList(); foreach (Level levelCanditate in allLevelsInProject) { if (Math.Abs(levelHeight - levelCanditate.ProjectElevation) <= 0.1) { currentLevelInProject = levelCanditate; break; } } if (currentLevelInProject == null) { currentLevelInProject = Level.Create(doc, levelHeight); } } else { currentLevelInProject = currentLevel; } FamilyInstance currentBeamInstance = doc.Create.NewFamilyInstance(wallCurve, currentFamilySymbol, currentLevelInProject, Autodesk.Revit.DB.Structure.StructuralType.Beam); AdjustBeamParameters(currentBeamInstance, currentLevelInProject); doc.Regenerate(); Utils.CheckFamilyInstanceForIntersection.CheckForDuplicatesAndIntersectingBeams(currentBeamInstance, doc); } } if (isJoinBeams) { IList <FamilyInstance> allBeamsInstances = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_StructuralFraming) .OfClass(typeof(FamilyInstance)).WhereElementIsNotElementType().Cast <FamilyInstance>().ToList(); foreach (FamilyInstance currentBeam in allBeamsInstances) { Utils.CheckFamilyInstanceForIntersection.JoinBeamToWalls(currentBeam, doc); } } t.Commit(); } } catch (Exception excep) { ExceptionManager eManager = new ExceptionManager(excep); } return(Result.Succeeded); }