예제 #1
0
        public static void GetLocation(Document document, cls_Image_Data tbdDataSet)
        {
            // Get the SiteLocation instance.
            SiteLocation site = document.SiteLocation;

            // Angles are in radians when coming from Revit API, so we
            // convert to degrees for display
            const double angleRatio = Math.PI / 180;   // angle conversion factor

            // Format the prompt information of basepoint.
            String prompt = "Current project's Site location information:";

            prompt += "\n\t" + "Latitude: " + site.Latitude / angleRatio + "XX";
            prompt += "\n\t" + "Longitude: " + site.Longitude / angleRatio + "YY";
            prompt += "\n\t" + "TimeZone: " + site.TimeZone;

            // Format the prompt information of basepoint offset
            double x = tbdDataSet.Latitude - site.Latitude / angleRatio;
            double y = tbdDataSet.Longidude - site.Longitude / angleRatio * -1;

            //define offset values
            offset = new XYZ(x, y, 0);

            //Format the prompt for the offset distance from basepoint
            prompt += "\n\t" + offset.X + "\n\t" + offset.Y;

            // Give the user some information.
            Debug.Print("Revit", prompt);
        }
예제 #2
0
        CollectEvent(object sender, CollectorEventArgs e)
        {
                // cast the sender object to the SnoopCollector we are expecting
            Collector snoopCollector = sender as Collector;
            if (snoopCollector == null) {
                Debug.Assert(false);    // why did someone else send us the message?
                return;
            }


                // see if it is a type we are responsible for
			City city = e.ObjToSnoop as City;
            if (city != null) {
                Stream(snoopCollector.Data(), city);
				return;
			}

            ProjectLocation projLoc = e.ObjToSnoop as ProjectLocation;
            if (projLoc != null) {
                Stream(snoopCollector.Data(), projLoc);
                return;
            }

            ProjectPosition projPos = e.ObjToSnoop as ProjectPosition;
            if (projPos != null) {
                Stream(snoopCollector.Data(), projPos);
                return;
            }

            SiteLocation siteLoc = e.ObjToSnoop as SiteLocation;
            if (siteLoc != null) {
                Stream(snoopCollector.Data(), siteLoc);
                return;
            }
        }
예제 #3
0
        void SetSiteLocationToCity2(Document doc)
        {
            CitySet cities = doc.Application.Cities;

            foreach (City city in cities)
            {
                string s = city.Name;

                if (s.Contains("中国") || s.Contains("China"))
                {
                    using (Transaction t = new Transaction(doc))
                    {
                        t.Start("Set Site Location to City");

                        ProjectLocation projectLocation = doc.ActiveProjectLocation;

                        //SiteLocation site = projectLocation.SiteLocation; // 2017
                        SiteLocation site = projectLocation.GetSiteLocation(); // 2018

                        // site.PlaceName = city.Name;
                        site.Latitude  = city.Latitude;  // latitude information
                        site.Longitude = city.Longitude; // longitude information
                        site.TimeZone  = city.TimeZone;  // TimeZone information

                        // SiteLocation property is read-only:
                        //projectLocation.SiteLocation = site;

                        t.Commit();
                    }
                    break;
                }
            }
        }
        void SetSiteLocationToCity1(Document doc)
        {
            Autodesk.Revit.DB.CitySet cities = doc.Application.Cities;
            int nCount = cities.Size;

            try
            {
                CitySetIterator item = cities.ForwardIterator();
                while (item != null)
                {
                    item.MoveNext();
                    City city = item.Current as City;
                    if (city.Name.Contains("中国") ||
                        city.Name.Contains("China"))
                    {
                        Transaction transaction = new Transaction(doc, "Create Wall");
                        transaction.Start();

                        ProjectLocation projectLocation = doc.ActiveProjectLocation;
                        SiteLocation    site            = projectLocation.SiteLocation;
                        // site.PlaceName = city.Name;
                        site.Latitude  = city.Latitude;  // latitude information
                        site.Longitude = city.Longitude; // longitude information
                        site.TimeZone  = city.TimeZone;  // TimeZone information
                        transaction.Commit();
                        break;
                    }
                }
            }
            catch (Exception ret)
            {
                Debug.Print(ret.Message);
            }
        }
예제 #5
0
    protected void Grid_HostList_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem DataItem = e.Item as GridDataItem;
            int          hostid   = Convert.ToInt32(DataItem["DormitoryHostId"].Text.ToString());
            int          status   = Convert.ToInt32(DataItem["HostStatus"].Text.ToString().Trim());
            DataItem["HostStatus"].Text = DormitoryHostStatus(status);
            //School and Campus
            var cHostSchool = new CDormitoryHostPreferredSchool();
            DormitoryHostPrefferedSchool hostTopSchool = cHostSchool.GetHostTopSchool(hostid);

            SiteLocation HostSchoolLocation = cHostSchool.GetHostTopShoolNameLocation(Convert.ToInt32(hostTopSchool.SiteLocationId));
            var          cSite       = new CSite();
            Site         SchoolName  = cSite.Get(Convert.ToInt32(HostSchoolLocation.SiteId));
            RadLabel     lblTopShool = (RadLabel)DataItem.FindControl("lbl_HostTopSchool");
            lblTopShool.Text = SchoolName.Abbreviation.ToString();
            RadLabel lblTopCampus = (RadLabel)DataItem.FindControl("lbl_HostTopCampus");
            lblTopCampus.Text = HostSchoolLocation.City.ToString();


            //Room Number
            RadLabel lblRoomNumber = (RadLabel)DataItem.FindControl("lbl_RoomNumber");
            var      cHostRoom     = new CDormitoryHostRoom();
            int      RoomNumber    = 0;
            RoomNumber         = cHostRoom.GetDormitoryHostRoomNumber(hostid);
            lblRoomNumber.Text = RoomNumber.ToString();
            //Bed Number
            RadLabel lblBedNumber = (RadLabel)DataItem.FindControl("lbl_BedNumber");
            var      cHostBed     = new CDormitoryHostBed();
            int      BedNumber    = 0;
            BedNumber         = cHostBed.GetDormitoryHostBedNumber(hostid);
            lblBedNumber.Text = BedNumber.ToString();
        }
    }
예제 #6
0
        Stream(ArrayList data, SiteLocation siteLoc)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(SiteLocation)));

            data.Add(new Snoop.Data.Double("Latitude", siteLoc.Latitude));
            data.Add(new Snoop.Data.Double("Longitude", siteLoc.Longitude));
            data.Add(new Snoop.Data.Double("Time zone", siteLoc.TimeZone));
        }
예제 #7
0
        public static Location Location(this SiteLocation siteLocation)
        {
            if (siteLocation == null)
            {
                return(null);
            }

            return(new Location(siteLocation.PlaceName, Units.Convert.ToDegrees(siteLocation.Longitude), Units.Convert.ToDegrees(siteLocation.Latitude), siteLocation.Elevation));
        }
예제 #8
0
        public static Location Location(this SiteLocation siteLocation)
        {
            if (siteLocation == null)
            {
                return(null);
            }

            return(new Location(siteLocation.PlaceName, siteLocation.Longitude, siteLocation.Latitude, siteLocation.Elevation));
        }
예제 #9
0
파일: IFCSite.cs 프로젝트: whztt07/RevitIFC
        /// <summary>
        /// Creates or populates Revit elements based on the information contained in this class.
        /// </summary>
        /// <param name="doc">The document.</param>
        protected override void Create(Document doc)
        {
            // Only set the project location for the site that contains the building.
            bool hasBuilding = false;

            foreach (IFCObjectDefinition objectDefinition in ComposedObjectDefinitions)
            {
                if (objectDefinition is IFCBuilding)
                {
                    hasBuilding = true;
                    break;
                }
            }

            if (hasBuilding)
            {
                ProjectLocation projectLocation = doc.ActiveProjectLocation;
                if (projectLocation != null)
                {
                    SiteLocation siteLocation = projectLocation.SiteLocation;
                    if (siteLocation != null)
                    {
                        if (RefLatitude.HasValue)
                        {
                            siteLocation.Latitude = RefLatitude.Value * Math.PI / 180.0;
                        }
                        if (RefLongitude.HasValue)
                        {
                            siteLocation.Longitude = RefLongitude.Value * Math.PI / 180.0;
                        }
                    }

                    if (ObjectLocation != null)
                    {
                        XYZ projectLoc = (ObjectLocation.RelativeTransform != null) ? ObjectLocation.RelativeTransform.Origin : XYZ.Zero;

                        // Get true north from IFCProject.
                        double         trueNorth     = 0.0;
                        IList <double> trueNorthList = IFCImportFile.TheFile.IFCProject.TrueNorthDirection;
                        if (trueNorthList != null && trueNorthList.Count >= 2)
                        {
                            trueNorth = Math.Atan2(trueNorthList[1], trueNorthList[0]);
                        }

                        ProjectPosition projectPosition = new ProjectPosition(projectLoc.X, projectLoc.Y, RefElevation, trueNorth);

                        XYZ origin = new XYZ(0, 0, 0);
                        projectLocation.set_ProjectPosition(origin, projectPosition);

                        // Now that we've set the project position, remove the site relative transform.
                        IFCLocation.RemoveRelativeTransformForSite(this);
                    }
                }
            }

            base.Create(doc);
        }
예제 #10
0
        public ActionResult DeleteConfirmed(int id)
        {
            SiteLocation siteLocation = db.SiteLocations.Find(id);
            var          HSid         = siteLocation.HospitalSiteId;

            db.SiteLocations.Remove(siteLocation);
            db.SaveChanges();

            return(RedirectToAction("../HospitalSites/Details/", new { id = HSid }));
        }
예제 #11
0
 public bool Update(SiteLocationModel siteLocationModel)
 {
     return(LogIfOperationFailed(() =>
     {
         SiteLocation siteLocation = SiteLocationMapper.ConvertModelToEntity(siteLocationModel);
         _unitOfWork.SiteLocationRepository.InsertOrUpdate(siteLocation);
         _unitOfWork.Commit();
         return true;
     }, Resources.ExceptionGetForAllProviders, "Sitelocation"));
 }
예제 #12
0
        private SiteLocation m_siteLocation; //reference to SiteLocation

        #endregion Fields

        #region Constructors

        /// <summary>
        /// override constructor
        /// </summary>
        /// <param name="data">a instance of CoordinateSystemData class</param>
        public CoordinateSystemDataForm(CoordinateSystemData data, CitySet citySet, SiteLocation siteLocation)
        {
            m_data = data;
            m_currentName = null;

            //create new members about place information
            m_placeInfo = new PlaceInfo(citySet);
            m_siteLocation = siteLocation;
            m_currentCityInfo = new CityInfo();
            InitializeComponent();
        }
예제 #13
0
        /// <summary>
        /// override constructor
        /// </summary>
        /// <param name="data">a instance of CoordinateSystemData class</param>
        public CoordinateSystemDataForm(CoordinateSystemData data, CitySet citySet, SiteLocation siteLocation)
        {
            m_data        = data;
            m_currentName = null;

            //create new members about place information
            m_placeInfo       = new PlaceInfo(citySet);
            m_siteLocation    = siteLocation;
            m_currentCityInfo = new CityInfo();
            InitializeComponent();
        }
예제 #14
0
        // GET: SiteLocations/Create
        public ActionResult Create(int?id)
        {
            // ViewBag.HospitalSiteId = new SelectList(db.HospitalSites, "Id", "Name");  // required for the HospitalSite dropdown form field
            ViewBag.HospitalSiteId = new SelectList(db.HospitalSites, "Id", "Name");

            var SL = new SiteLocation();

            SL.HospitalSiteId = id;
            //ViewBag.HSID = id;

            return(View(SL));
        }
예제 #15
0
 public ActionResult Edit([Bind(Include = "Id,Name,Descrption,Notes,HospitalSiteId")] SiteLocation siteLocation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(siteLocation).State = EntityState.Modified;
         db.SaveChanges();
         //return RedirectToAction("Index");
         return(RedirectToAction("../SiteLocations/Details/", new { id = siteLocation.Id }));
     }
     ViewBag.HospitalSiteId = new SelectList(db.HospitalSites, "Id", "Name", siteLocation.HospitalSiteId);
     return(View(siteLocation));
 }
예제 #16
0
        public static SiteLocation SiteLocation(string epwFile)
        {
            SiteLocation  siteLocation = new SiteLocation();
            string        Epwfile      = System.IO.File.ReadLines(epwFile).First();
            List <string> commaPoints  = Epwfile.Split(',').ToList();

            siteLocation.Name      = commaPoints[1] + "_" + commaPoints[2] + "_" + commaPoints[3] + "_" + commaPoints[4] + "_" + commaPoints[5]; // Expected output
            siteLocation.Latitude  = System.Convert.ToDouble(commaPoints[6]);
            siteLocation.Longitude = System.Convert.ToDouble(commaPoints[7]);
            siteLocation.TimeZone  = System.Convert.ToDouble(commaPoints[8]);
            siteLocation.Elevation = System.Convert.ToDouble(commaPoints[9]);
            return(siteLocation);
        }
예제 #17
0
        public static SiteLocationModel ConvertEntityToModel(SiteLocation site)
        {
            SiteLocationModel siteLocationModel = new SiteLocationModel();

            siteLocationModel.Address    = site.Address;
            siteLocationModel.Id         = site.Id;
            siteLocationModel.HFS        = site.HFS;
            siteLocationModel.NPI        = site.NPI;
            siteLocationModel.ProviderId = site.ProviderId;



            return(siteLocationModel);
        }
예제 #18
0
        // GET: AreasOfCare/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SiteLocation siteLocation = db.SiteLocations.Find(id);

            if (siteLocation == null)
            {
                return(HttpNotFound());
            }
            return(View(siteLocation));
        }
예제 #19
0
        public static SiteLocation ConvertModelToEntity(SiteLocationModel siteModel)
        {
            SiteLocation siteLocation = new SiteLocation();

            siteLocation.Address    = siteModel.Address;
            siteLocation.Id         = siteModel.Id;
            siteLocation.HFS        = siteModel.HFS;
            siteLocation.NPI        = siteModel.NPI;
            siteLocation.ProviderId = siteModel.ProviderId;



            return(siteLocation);
        }
예제 #20
0
        public ActionResult Create([Bind(Include = "Id,Name,Descrption,Notes,HospitalSiteId")] SiteLocation siteLocation)
        {
            if (ModelState.IsValid)
            {
                db.SiteLocations.Add(siteLocation);
                db.SaveChanges();
                //return RedirectToAction("Index");
                return(RedirectToAction("../HospitalSites/Details", new { id = siteLocation.HospitalSiteId }));
            }

            ViewBag.HospitalSiteId = new SelectList(db.HospitalSites, "Id", "Name", siteLocation.HospitalSiteId);
            return(View(siteLocation));
            //return RedirectToAction("../HospitalSites/Details", new { id = siteLocation.Id });
        }
예제 #21
0
        // GET: SiteLocations/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SiteLocation siteLocation = db.SiteLocations.Find(id);

            if (siteLocation == null)
            {
                return(HttpNotFound());
            }
            ViewBag.HospitalSiteId = new SelectList(db.HospitalSites, "Id", "Name", siteLocation.HospitalSiteId);
            return(View(siteLocation));
        }
예제 #22
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIDocument uidoc = commandData.Application.ActiveUIDocument;
            Document   doc   = uidoc.Document;


            //1 项目基点
            ProjectLocation projectLocation = doc.ActiveProjectLocation;
            ProjectPosition position        = projectLocation.GetProjectPosition(XYZ.Zero);

            // 获取 项目基点在测量点下的转换矩阵
            XYZ       translationVector    = new XYZ(position.EastWest, position.NorthSouth, position.Elevation);
            Transform translationTransform = Transform.CreateTranslation(translationVector);
            Transform rotationTransform    = Transform.CreateRotation(XYZ.BasisZ, position.Angle);
            // 转换矩阵
            Transform finalTransform = translationTransform.Multiply(rotationTransform);
            //在数值上等于 项目基点 OST_ProjectBasePoint SharedPosition 属性的值
            XYZ basePoint = finalTransform.OfPoint(XYZ.Zero);
            XYZ zore      = finalTransform.Inverse.OfPoint(basePoint);

            //2 项目位置信息
            SiteLocation siteLocation = doc.SiteLocation;


            //3 BasePoint
            FilteredElementCollector collector = new FilteredElementCollector(doc);
            var basePoints = collector.OfClass(typeof(BasePoint)).ToElements();

            // 会得到两个 basePoint

            // 第一个是 项目基点 OST_ProjectBasePoint ,position属性永远为(0,0,0)isShared属性永远为false 表示不会被移动 移动它整个图形都会动;所有元素的Location属性是和它挂钩的,也就是说,移动元素,Location属性并不会改变
            // 它有 EastWest NorthSouth Elevation 以及 Angle 参数,和上面的 ProjectPosition 中的属性是意义对应的,他们都是相对于测量点的数值
            // 我们常说的 模型坐标系 的原点就是它,证据是他和模型一起动,它相对于模型是绝对静止的

            // 第二个是 测量点 OST_SharedBasePoint ,sharedPosition属性永远为(0,0,0)isShared属性永远为true
            // 它也有 EastWest NorthSouth Elevation 以及 Angle 参数,但是都是0,说明这些属性都是相对于他自己的数字。
            // 所以所有有关Location的计算都和他没关系,(目前我只知道)他只影响标高的elevation的值


            //4 总结

            //如果链接文件中项目基点没有和Host文件中的项目基点对齐,链接文件的 revitlinkedinstance 中会有一个 transform(totaltransform) ,通过这个矩阵变换,可以把链接文件的项目基点和Host文件的项目基点对齐(revitlinkedinstance类中也有相应的方法)。然后直接获取linkdoc中的location,就可以代表host文件中的真正位置。

            //在链接文件中,如果要获取元素的位置信息,一定要看这个 revitlinkedinstance 的 totaltransform 是否为0,如果不是,都需要应用这个转换矩阵。
            //如果转化了的位置信息,在host文件中又做了一定的转换,得到新的位置信息,想要知道它应在在连接文件中在什么位置时,只需要反向应用上述得到的矩阵,即应用 totaltransform.

            return(Result.Succeeded);
        }
예제 #23
0
 public void SiteLocationTest()
 {
     using (DatabaseSetup db = new DatabaseSetup(Utili.GetCurrentMethodAndClass()))
     {
         Location loc = new Location("loc1", null, db.ConnectionString, Guid.NewGuid().ToStrGuid());
         loc.SaveToDB();
         SiteLocation sl = new SiteLocation(null, loc, -1, db.ConnectionString, "name", Guid.NewGuid().ToStrGuid());
         ObservableCollection <SiteLocation> slocs = new ObservableCollection <SiteLocation>();
         ObservableCollection <Location>     locs  = new ObservableCollection <Location>();
         sl.SaveToDB();
         locs.Add(loc);
         SiteLocation.LoadFromDatabase(slocs, db.ConnectionString, locs, false);
         db.Cleanup();
         (slocs.Count).Should().Be(1);
     }
 }
예제 #24
0
    protected void Grid_HostList_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem DataItem = e.Item as GridDataItem;
            int          hostid   = Convert.ToInt32(DataItem["HostId"].Text.ToString());
            int          status   = Convert.ToInt32(DataItem["HouseActiveStutas"].Text.ToString().Trim());
            DataItem["HouseActiveStutas"].Text = "Active";
            //School and Campus
            var cHostSchool = new CHomestayHostPreferredSchool();
            HomestayHostPrefferedSchool hostTopSchool = cHostSchool.GetHostTopSchool(hostid);

            SiteLocation HostSchoolLocation = cHostSchool.GetHostTopShoolNameLocation(Convert.ToInt32(hostTopSchool.SiteLocationId));
            var          cSite       = new CSite();
            Site         SchoolName  = cSite.Get(Convert.ToInt32(HostSchoolLocation.SiteId));
            RadLabel     lblTopShool = (RadLabel)DataItem.FindControl("lbl_HostTopSchool");
            lblTopShool.Text = SchoolName.Abbreviation.ToString();
            RadLabel lblTopCampus = (RadLabel)DataItem.FindControl("lbl_HostTopCampus");
            lblTopCampus.Text = HostSchoolLocation.City.ToString();

            //Family Member
            RadLabel lblFamilyMember = (RadLabel)DataItem.FindControl("lbl_FamilyMember");
            var      cHostFamily     = new CHomestayHostFamilyMember();
            int      MemberNumber    = 0;
            MemberNumber         = cHostFamily.GetFamilyMemberNumber(hostid);
            lblFamilyMember.Text = MemberNumber.ToString();
            //Room Number
            RadLabel lblRoomNumber = (RadLabel)DataItem.FindControl("lbl_RoomNumber");
            var      cHostRoom     = new CHomestayHostRoom();
            int      RoomNumber    = 0;
            RoomNumber         = cHostRoom.GetHomestayHostRoomNumber(hostid);
            lblRoomNumber.Text = RoomNumber.ToString();
            //Bed Number
            RadLabel lblBedNumber = (RadLabel)DataItem.FindControl("lbl_BedNumber");
            var      cHostBed     = new CHomestayHostBed();
            int      BedNumber    = 0;
            BedNumber         = cHostBed.GetHomestayHostBedNumber(hostid);
            lblBedNumber.Text = BedNumber.ToString();


            //
            if (hostid == 1) //AvalibleHost(int HostId)
            {
                DataItem.Display = false;
            }
        }
    }
예제 #25
0
        // GET: AreasOfCare/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AreaOfCare areaOfCare = db.AreasOfCare.Find(id);

            if (areaOfCare == null)
            {
                return(HttpNotFound());
            }


            SiteLocation siteLocation = db.SiteLocations.Find(areaOfCare.SiteLocationId);
            HospitalSite hospitalSite = db.HospitalSites.Find(siteLocation.Id);

            // ////////////////////////////////////////////////////

            List <NotesFieldAreaOfCare> AoCNotes = new List <NotesFieldAreaOfCare>(db.NotesFieldAreaOfCares.Where(aocn => aocn.AoCId == areaOfCare.AoCId).ToList().OrderByDescending(aocn => aocn.CreatedOn));

            ViewBag.AoCNotes = AoCNotes;
            //ViewBag.SiteLocation = siteLocation.Name;
            //ViewBag.HospitalSiteName = hospitalSite.Name;
            //ViewBag.HospitalSiteId = hospitalSite.Id;


            //List<LocationOfInterest> locationsOfInterest = new List<LocationOfInterest>;

            // find all SiteLocations where HospitalSiteId = id ////
            var locationsOfInterest = db.LocationOfInterest
                                      .Where(loi => loi.LoIAoCId == id);

            ViewBag.locationsOfInterest = locationsOfInterest;

            int count = 0;

            foreach (var loi in locationsOfInterest)
            {
                count++;
            }
            ViewBag.locationsOfInterestCount = count;
            ////////////////////////////////////////////////////////

            return(View(areaOfCare));
        }
예제 #26
0
        public void SaveItemCommand_DoSave_ManyToMany()
        {
            var fakeUnit = new EquipmentUnitType
            {
                name        = "Test Trailer",
                description = "My Description",
                unitCode    = "T"
            };

            Assert.That(fakeUnit.IsChanged, nameof(fakeUnit.IsChanged), Is.True);
            Assert.That(fakeUnit.name, Is.EqualTo("Test Trailer"));
            Assert.That(fakeUnit.displayName, Is.EqualTo(fakeUnit.name));

            var cmd = new SaveItemCommand();

            Assert.NotNull(cmd, nameof(SaveItemCommand));

            fakeUnit.unitCode = "T";
            Assert.IsTrue(cmd.CanExecute(fakeUnit));

            var fakeSite = new SiteLocation
            {
                name      = "My Site",
                locSuffix = "My"
            };

            Assert.That(fakeSite.IsChanged, nameof(fakeSite.IsChanged), Is.True);
            Assert.That(fakeSite.name, Is.EqualTo("My Site"));

            fakeSite.equipmentUnitTypesAvailable.Add(fakeUnit);
            Assert.IsTrue(cmd.CanExecute(fakeSite));

            cmd.Execute(fakeSite);
            Assert.IsFalse(cmd.CanExecute(fakeSite));
            Assert.IsFalse(cmd.CanExecute(fakeUnit));

            var db = DataRepository.GetDataRepository;
            var fakeSiteReplica = db.Load <SiteLocation>(fakeSite.PrimaryKey);

            Assert.NotNull(fakeSiteReplica, nameof(fakeSiteReplica));
            Assert.That(fakeSiteReplica.equipmentUnitTypesAvailable.Count, Is.GreaterThan(0));

            // note that must delete site first to remove mappings otherwise will fail due to mapping fk constraints
            db.Delete(fakeSite);
            db.Delete(fakeUnit);
        }
예제 #27
0
        /// <summary>
        /// Construct and initialize, e.g. when loading from DB
        /// name and email are optional and may be omitted
        /// </summary>
        public UserDetail(string userId, string hashedPassphrase, bool isActive, bool isPasswordExpired, string role, SiteLocation currentSite, List <SiteLocation> availableSites, string lastName = null, string firstName = null, string email = null)
        {
            _userId            = userId;
            _hashedPassphrase  = hashedPassphrase;
            _isActive          = isActive;
            _isPasswordExpired = isPasswordExpired;
            _role               = role;
            _lastName           = lastName;
            _firstName          = firstName;
            _email              = email;
            _currentSite        = currentSite;
            this.availableSites = availableSites;  // force IsChanged==true, note this is only field that should never be set to null thus default value of null!=initially set value and IsChanged is set to true

            // configure toString to not include password hash
            printer.Configuration.AddHandler(
                t => t == typeof(UserDetail),
                t => new List <SanitizedFieldInfo>((new HarvestHelper()).GetFieldsAndProperties(typeof(UserDetail)).Where(x => !x.SanitizedName.Contains("Passphrase")))
                );
        }
예제 #28
0
        // GET: SiteLocations/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SiteLocation siteLocation = db.SiteLocations.Find(id);
            // ////////////////////////////////////////////////
            var hospitalSiteName = db.HospitalSites
                                   .Where(HS => HS.Id == siteLocation.HospitalSiteId);

            ViewBag.HospitalSiteName = hospitalSiteName.First().Name;

            // ////////////////////////////////////////////////
            // find all SiteLocations where HospitalSiteId = id
            var AreasOfCare = db.AreasOfCare
                              .Where(AoC => AoC.SiteLocationId == id)
                              .OrderBy(g => g.AoCPlannedGoLiveDate);


            ViewBag.AreasOfCare = AreasOfCare;

            ViewBag.AreasOfCareCount = AreasOfCare.Count();
            // //////////////////////////////////////////////////


            if (siteLocation == null)
            {
                return(HttpNotFound());
            }


            // ////////////////////////////////////////////////////

            List <NotesFieldSiteLocation> LocationNotesBag = new List <NotesFieldSiteLocation>(db.LocationNotes.Where(sl => sl.SiteLocationId == siteLocation.Id).ToList().OrderByDescending(sl => sl.CreatedOn));

            ViewBag.LocationNotes = LocationNotesBag;


            return(View(siteLocation));
        }
예제 #29
0
        // Token: 0x06000001 RID: 1 RVA: 0x00002048 File Offset: 0x00000248
        public void ShowActiveProjectLocationUsage(Document document)
        {
            ProjectLocation activeProjectLocation = document.ActiveProjectLocation;
            XYZ             xyz             = new XYZ(0.0, 0.0, 0.0);
            ProjectPosition projectPosition = activeProjectLocation.GetProjectPosition(xyz);
            bool            flag            = projectPosition == null;

            if (flag)
            {
                throw new Exception("No project position in origin point.");
            }
            string text = "Current project location information:\n";

            text += "\n\tOrigin point position:";
            text  = text + "\n\t\tAngle: " + projectPosition.Angle;
            text  = text + "\n\t\tEast to West offset: " + projectPosition.EastWest;
            text  = text + "\n\t\tElevation: " + projectPosition.Elevation;
            text  = text + "\n\t\tNorth to South offset: " + projectPosition.NorthSouth;
            SiteLocation siteLocation = activeProjectLocation.GetSiteLocation();
            string       text2        = '°'.ToString();

            text += "\n\tSite location:";
            text  = string.Concat(new object[]
            {
                text,
                "\n\t\tLatitude: ",
                siteLocation.Latitude / 0.017453292519943295,
                text2
            });
            text = string.Concat(new object[]
            {
                text,
                "\n\t\tLongitude: ",
                siteLocation.Longitude / 0.017453292519943295,
                text2
            });
            text = text + "\n\t\tTimeZone: " + siteLocation.TimeZone;
            TaskDialog.Show("Revit", text);
        }
        // GET: LocationsOfInterest/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LocationOfInterest locationOfInterest = db.LocationOfInterest.Find(id);

            if (locationOfInterest == null)
            {
                return(HttpNotFound());
            }

            // ///////////////////////////////////////////////////////
            AreaOfCare   areaOfCare   = db.AreasOfCare.Find(locationOfInterest.LoIAoCId);
            SiteLocation siteLocation = db.SiteLocations.Find(areaOfCare.SiteLocationId);
            HospitalSite hospitalSite = db.HospitalSites.Find(siteLocation.HospitalSiteId);

            List <NotesFieldLocationOfInterest> notesFieldLocationOfInterest = new List <NotesFieldLocationOfInterest>(db.NotesFieldLocationOfInterest.Where(loin => loin.LoIId == locationOfInterest.LoIId).ToList().OrderByDescending(loin => loin.CreatedOn));

            ViewBag.HospitalSite     = hospitalSite;
            ViewBag.HospitalSiteID   = siteLocation.HospitalSiteId;
            ViewBag.siteLocationName = siteLocation.Name;
            ViewBag.siteLocationID   = siteLocation.Id;
            ViewBag.areaOfCareName   = areaOfCare.AoCName;

            ViewBag.notesFieldLocationOfInterest = notesFieldLocationOfInterest;

            var hardware = db.Hardwares
                           .Where(H => H.HLoIId == id);

            ViewBag.Hardware = hardware;

            ////////////////////////////////////////////////////////
            // //////////////////////////////////////////////////////

            return(View(locationOfInterest));
        }
예제 #31
0
 public long CreateUpdateSiteLoc(SiteLocationModel model)
 {
     using (var db = new PCVEntities())
     {
         if (model != null)
         {
             var myModel = new SiteLocation();
             myModel.LocationName = model.LocationName;
             myModel.SiteId       = model.SiteId;
             myModel.Description  = model.Description;
             myModel.InActive     = model.InActive;
             if (model.Id > 0)
             {
                 myModel.Id              = model.Id.To <long>();
                 myModel.UpdatedDate     = DateTime.Now;
                 myModel.UpdateBy        = MySession.Current.UserName;
                 db.Entry(myModel).State = EntityState.Modified;
             }
             else
             {
                 myModel.CreatedDate = DateTime.Now;
                 myModel.CreatedBy   = MySession.Current.UserName;
                 db.SiteLocation.Add(myModel);
             }
             db.SaveChanges();
             if (myModel.Id > 0)
             {
                 return(myModel.Id);
             }
             else
             {
                 return(0);
             }
         }
         return(0);
     }
 }
예제 #32
0
        private void Stream(ArrayList data, SiteLocation siteLoc)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(SiteLocation)));

            data.Add(new Snoop.Data.Double("Latitude", siteLoc.Latitude));
            data.Add(new Snoop.Data.Double("Longitude", siteLoc.Longitude));
            data.Add(new Snoop.Data.Double("Time zone", siteLoc.TimeZone));
        }
예제 #33
0
 /// <summary>
 /// Initializes private variables.
 /// </summary>
 /// <param name="siteLocation"></param>
 public SiteLocationWrapper(SiteLocation siteLocation)
 {
     m_siteLocation = siteLocation;
     //m_citys = RevitStartInfo.RevitApp.Cities;
 }