//FUNCTION FOR RAILING
        public void RailingSelector(string activityDescription)
        {
            List <ElementData> TempListofSafetyIssues = new List <ElementData>();
            ElementData        eachElementData        = new ElementData();
            string             caTegory = null;

            eachElementData.EleStartDate  = new DateTime();
            eachElementData.EleEndDate    = new DateTime();
            eachElementData.ProtStartDate = new DateTime();
            eachElementData.ProtEndDate   = new DateTime();

            foreach (Nw.ModelItem modelAncestors in modelItem.AncestorsAndSelf)
            {
                Nw.PropertyCategoryCollection familypropCatCollection = modelAncestors.PropertyCategories;
                foreach (Nw.PropertyCategory familypropCat in familypropCatCollection)
                {
                    if (familypropCat.DisplayName.ToString() == "Element" &&
                        null != familypropCat.Properties.FindPropertyByDisplayName("Category"))
                    {
                        caTegory = familypropCat.Properties.FindPropertyByDisplayName("Category").Value.ToString();
                        caTegory = caTegory.Substring(caTegory.IndexOf(":") + 1);

                        //if element is stair
                        if (caTegory == "Railings")
                        {
                            foreach (Nw.PropertyCategory innerpropCat in familypropCatCollection)
                            {
                                if (innerpropCat.DisplayName.ToString() == "Element" && null != innerpropCat.Properties
                                    .FindPropertyByDisplayName("ElementInfo"))
                                {
                                    eachElementData.ActivityName = activityDescription;
                                    eachElementData.ElementType  = "Railing";
                                    eachElementData.Hazard       = "Proximity to opening/slab edge";
                                    eachElementData.Protection   = "See general guidelines working at height";

                                    //get element level and elevation
                                    foreach (Nw.PropertyCategory innermostpropCat in familypropCatCollection)
                                    {
                                        if (innermostpropCat.DisplayName.ToString() == "Base Level" &&
                                            null != innermostpropCat.Properties.FindPropertyByDisplayName("Elevation") &&
                                            null != innermostpropCat.Properties.FindPropertyByDisplayName("Name"))
                                        {
                                            //elevation is returned in feet and not as double
                                            elevation = innermostpropCat.Properties.FindPropertyByDisplayName("Elevation").Value.ToDoubleLength();
                                            elevation = elevation * (double)0.3048;
                                            eachElementData.Elevation = elevation;

                                            eachElementData.Level = innermostpropCat.Properties.FindPropertyByDisplayName("Name").Value.ToString();
                                            eachElementData.Level = eachElementData.Level.Substring(eachElementData.Level.IndexOf(":") + 1);
                                            break;
                                        }
                                    }

                                    //get element start date and end date
                                    foreach (Nw.PropertyCategory innermostpropCat in familypropCatCollection)
                                    {
                                        if (innermostpropCat.DisplayName.ToString() == "TimeLiner" &&
                                            null != innermostpropCat.Properties.FindPropertyByDisplayName("Contained in Task Start (Planned):1") &&
                                            null != innermostpropCat.Properties.FindPropertyByDisplayName("Contained in Task End (Planned):1"))
                                        {
                                            eachElementData.EleStartDate = (DateTime)innermostpropCat.Properties
                                                                           .FindPropertyByDisplayName("Contained in Task Start (Planned):1").Value.ToDateTime();
                                            eachElementData.EleEndDate = (DateTime)innermostpropCat.Properties
                                                                         .FindPropertyByDisplayName("Contained in Task End (Planned):1").Value.ToDateTime();
                                            break;
                                        }
                                    }
                                    eachElementData.ProtStartDate = eachElementData.EleStartDate;
                                    eachElementData.ProtEndDate   = eachElementData.EleEndDate;

                                    TempListofSafetyIssues.Add(eachElementData);
                                }
                            }
                        }
                    }
                }
            }

            Result.ListofSafetyIssues.AddRange(TempListofSafetyIssues);
        }
        //FUNCTION FOR STAIR
        public void StairSelector(string activityDescription)
        {
            string             caTegory;
            List <ElementData> TempListofSafetyIssues = new List <ElementData>();
            ElementData        eachElementData        = new ElementData();
            Operate            elementOperate         = new Operate();
            string             elementID;

            DateTime tempDateTime = new DateTime();

            eachElementData.EleStartDate  = new DateTime();
            eachElementData.EleEndDate    = new DateTime();
            eachElementData.ProtStartDate = new DateTime();
            eachElementData.ProtEndDate   = new DateTime();

            SlabResult stairwallResult    = new SlabResult();
            SlabResult stairrailingResult = new SlabResult();

            foreach (Nw.ModelItem modelAncestors in modelItem.AncestorsAndSelf)
            {
                Nw.PropertyCategoryCollection familypropCatCollection = modelAncestors.PropertyCategories;
                foreach (Nw.PropertyCategory familypropCat in familypropCatCollection)
                {
                    if (familypropCat.DisplayName.ToString() == "Element" &&
                        null != familypropCat.Properties.FindPropertyByDisplayName("Category"))
                    {
                        caTegory = familypropCat.Properties.FindPropertyByDisplayName("Category").Value.ToString();
                        caTegory = caTegory.Substring(caTegory.IndexOf(":") + 1);

                        //if element is stair
                        if (caTegory == "Stairs")
                        {
                            //get start date of edge walls and railings
                            foreach (Nw.PropertyCategory innerpropCat in familypropCatCollection)
                            {
                                if (innerpropCat.DisplayName.ToString() == "Element ID" &&
                                    null != innerpropCat.Properties.FindPropertyByDisplayName("Value"))
                                {
                                    elementID          = innerpropCat.Properties.FindPropertyByDisplayName("Value").Value.ToString();
                                    elementID          = elementID.Substring(elementID.IndexOf(":") + 1);
                                    stairwallResult    = elementOperate.RoofOperations(elementID);
                                    stairrailingResult = elementOperate.RailingOperations(elementID);
                                    break;
                                }
                            }

                            //get element start date and end date
                            foreach (Nw.PropertyCategory innerpropCat in familypropCatCollection)
                            {
                                if (innerpropCat.DisplayName.ToString() == "TimeLiner" &&
                                    null != innerpropCat.Properties.FindPropertyByDisplayName("Contained in Task Start (Planned):1") &&
                                    null != innerpropCat.Properties.FindPropertyByDisplayName("Contained in Task End (Planned):1"))
                                {
                                    tempDateTime = (DateTime)innerpropCat.Properties
                                                   .FindPropertyByDisplayName("Contained in Task Start (Planned):1").Value.ToDateTime();
                                    eachElementData.ProtStartDate = (DateTime)innerpropCat.Properties
                                                                    .FindPropertyByDisplayName("Contained in Task End (Planned):1").Value.ToDateTime();
                                    break;
                                }
                            }

                            //get element level and elevation
                            foreach (Nw.PropertyCategory innerpropCat in familypropCatCollection)
                            {
                                if (innerpropCat.DisplayName.ToString() == "Top Level" &&
                                    null != innerpropCat.Properties.FindPropertyByDisplayName("Elevation") &&
                                    null != innerpropCat.Properties.FindPropertyByDisplayName("Name"))
                                {
                                    //elevation is returned in feet and not as double
                                    elevation = innerpropCat.Properties.FindPropertyByDisplayName("Elevation").Value.ToDoubleLength();
                                    elevation = elevation * (double)0.3048;

                                    eachElementData.Elevation = elevation;
                                    eachElementData.Level     = innerpropCat.Properties.FindPropertyByDisplayName("Name").Value.ToString();
                                    eachElementData.Level     = eachElementData.Level.Substring(eachElementData.Level.IndexOf(":") + 1);
                                    break;
                                }
                            }

                            //in case of walls along the stair edges
                            if (stairwallResult.stairstartDate.ToShortDateString() != "01-01-0001")
                            {
                                eachElementData.ProtEndDate = stairwallResult.stairstartDate;
                                eachElementData.Hazard      = "Unprotected Stairs";
                                eachElementData.Protection  = "Provide edge protection along the stair walls are to be built";
                                TempListofSafetyIssues.Add(eachElementData);
                            }

                            //in case of railings along the stair edges
                            if (stairrailingResult.stairstartDate.ToShortDateString() != "01-01-0001")
                            {
                                eachElementData.ProtEndDate = stairrailingResult.stairstartDate;
                                eachElementData.Hazard      = "Unprotected Stairs";
                                eachElementData.Protection  = "Provide edge protection along the stair where railings are to be built";
                                TempListofSafetyIssues.Add(eachElementData);
                            }
                            eachElementData.EleStartDate  = tempDateTime;
                            eachElementData.EleEndDate    = eachElementData.ProtStartDate;
                            eachElementData.ProtStartDate = eachElementData.EleEndDate;
                            eachElementData.ProtEndDate   = eachElementData.EleEndDate;
                            eachElementData.ActivityName  = activityDescription;
                            eachElementData.ElementType   = "Stair";
                            eachElementData.Hazard        = "Working at height";
                            eachElementData.Protection    = "See general guidelines for Construction of stairs";
                            TempListofSafetyIssues.Add(eachElementData);

                            Result.ListofSafetyIssues.AddRange(TempListofSafetyIssues);
                        }
                    }
                }
            }
        }
        //FUNCTION FOR WALL
        public void WallSelector(string activityDescription)
        {
            Nw.ModelItem       modelParent    = modelItem.Parent;
            Operate            elementOperate = new Operate();
            string             elementID;
            List <ElementData> TempListofSafetyIssues = new List <ElementData>();
            ElementData        eachElementData        = new ElementData();

            DateTime tempDateTime = new DateTime();

            eachElementData.EleStartDate  = new DateTime();
            eachElementData.EleEndDate    = new DateTime();
            eachElementData.ProtStartDate = new DateTime();
            eachElementData.ProtEndDate   = new DateTime();

            Nw.PropertyCategoryCollection innerpropCatCollection = modelParent.PropertyCategories;
            foreach (Nw.PropertyCategory innerpropCat in innerpropCatCollection)
            {
                if (innerpropCat.DisplayName.ToString() == "Element ID" &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Value"))
                {
                    elementID = innerpropCat.Properties.FindPropertyByDisplayName("Value").Value.ToString();
                    elementID = elementID.Substring(elementID.IndexOf(":") + 1);
                    eachElementData.ProtEndDate = elementOperate.WallOperations(elementID);
                    break;
                }
            }

            //get element start date and end date
            foreach (Nw.PropertyCategory innerpropCat in innerpropCatCollection)
            {
                if (innerpropCat.DisplayName.ToString() == "TimeLiner" &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Attached to Task Start (Planned):1") &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Attached to Task End (Planned):1"))
                {
                    tempDateTime = (DateTime)innerpropCat.Properties
                                   .FindPropertyByDisplayName("Attached to Task Start (Planned):1").Value.ToDateTime();
                    eachElementData.ProtStartDate = (DateTime)innerpropCat
                                                    .Properties.FindPropertyByDisplayName("Attached to Task End (Planned):1").Value.ToDateTime();
                    break;
                }
            }

            //get element level
            foreach (Nw.PropertyCategory innerpropCat in innerpropCatCollection)
            {
                if (innerpropCat.DisplayName.ToString() == "Base Constraint" &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Name"))
                {
                    eachElementData.Level = innerpropCat.Properties.FindPropertyByDisplayName("Name").Value.ToString();
                    eachElementData.Level = eachElementData.Level.Substring(eachElementData.Level.IndexOf(":") + 1);
                    break;
                }
            }

            //get element top elevation
            foreach (Nw.PropertyCategory innerpropCat in innerpropCatCollection)
            {
                if (innerpropCat.DisplayName.ToString() == "Top Constraint" &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Elevation"))
                {
                    //elevation is returned in feet and not as double
                    elevation = innerpropCat.Properties.FindPropertyByDisplayName("Elevation").Value.ToDoubleLength();
                    elevation = elevation * (double)0.3048;

                    eachElementData.Elevation = elevation;
                    break;
                }
            }

            //in case of walls along the boundaries
            if (eachElementData.ProtEndDate.ToShortDateString() != "01-01-0001")
            {
                eachElementData.Hazard     = "Window Openings along slab edges";
                eachElementData.Protection = "Close openings using grills";
                TempListofSafetyIssues.Add(eachElementData);
            }

            eachElementData.EleStartDate  = tempDateTime;
            eachElementData.EleEndDate    = eachElementData.ProtStartDate;
            eachElementData.ProtStartDate = eachElementData.EleEndDate;
            eachElementData.ProtEndDate   = eachElementData.EleEndDate;
            eachElementData.ActivityName  = activityDescription;
            eachElementData.ElementType   = "Wall";
            eachElementData.Hazard        = "Working at height";
            eachElementData.Protection    = "See general guidelines for Construction of walls at height";
            TempListofSafetyIssues.Add(eachElementData);

            Result.ListofSafetyIssues.AddRange(TempListofSafetyIssues);
        }
        //FUNCTION FOR COLUMN
        public void ColumnSelector(string activityDescription)
        {
            Nw.ModelItem       modelParent            = modelItem.Parent;
            List <ElementData> TempListofSafetyIssues = new List <ElementData>();
            ElementData        eachElementData        = new ElementData();

            eachElementData.EleStartDate  = new DateTime();
            eachElementData.EleEndDate    = new DateTime();
            eachElementData.ProtStartDate = new DateTime();
            eachElementData.ProtEndDate   = new DateTime();

            Nw.PropertyCategoryCollection innerpropCatCollection = modelParent.PropertyCategories;

            eachElementData.ActivityName = activityDescription;
            eachElementData.ElementType  = "Column";
            eachElementData.Hazard       = "Working at height";
            eachElementData.Protection   = "See general guidelines for Construction of Columns at height";

            //get element level and elevation
            foreach (Nw.PropertyCategory innerpropCat in innerpropCatCollection)
            {
                if (innerpropCat.DisplayName.ToString() == "Base Level" &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Name"))
                {
                    eachElementData.Level = innerpropCat.Properties.FindPropertyByDisplayName("Name").Value.ToString();
                    eachElementData.Level = eachElementData.Level.Substring(eachElementData.Level.IndexOf(":") + 1);
                    break;
                }
            }

            //get element top elevation
            foreach (Nw.PropertyCategory innerpropCat in innerpropCatCollection)
            {
                if (innerpropCat.DisplayName.ToString() == "Top Level" &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Elevation"))
                {
                    //elevation is returned in feet and not as double
                    elevation = innerpropCat.Properties.FindPropertyByDisplayName("Elevation").Value.ToDoubleLength();
                    elevation = elevation * (double)0.3048;

                    eachElementData.Elevation = elevation;
                    break;
                }
            }

            //get element start date and end date
            foreach (Nw.PropertyCategory innerpropCat in innerpropCatCollection)
            {
                if (innerpropCat.DisplayName.ToString() == "TimeLiner" &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Contained in Task Start (Planned):1") &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Contained in Task End (Planned):1"))
                {
                    eachElementData.EleStartDate = (DateTime)innerpropCat.Properties
                                                   .FindPropertyByDisplayName("Contained in Task Start (Planned):1").Value.ToDateTime();
                    eachElementData.EleEndDate = (DateTime)innerpropCat.Properties
                                                 .FindPropertyByDisplayName("Contained in Task End (Planned):1").Value.ToDateTime();
                    break;
                }
            }
            eachElementData.ProtStartDate = eachElementData.EleStartDate;
            eachElementData.ProtEndDate   = eachElementData.EleEndDate;

            TempListofSafetyIssues.Add(eachElementData);

            Result.ListofSafetyIssues.AddRange(TempListofSafetyIssues);
        }
        //FUNCTION FOR ROOF
        public void RoofSelector(string activityDescription)
        {
            Nw.ModelItem       modelParent    = modelItem.Parent;
            Operate            elementOperate = new Operate();
            string             elementID;
            List <ElementData> TempListofSafetyIssues = new List <ElementData>();
            ElementData        eachElementData        = new ElementData();

            DateTime tempDateTime = new DateTime();

            eachElementData.EleStartDate  = new DateTime();
            eachElementData.EleEndDate    = new DateTime();
            eachElementData.ProtStartDate = new DateTime();
            eachElementData.ProtEndDate   = new DateTime();

            SlabResult slabwallResult    = new SlabResult();
            SlabResult slabrailingResult = new SlabResult();

            Nw.PropertyCategoryCollection innerpropCatCollection = modelParent.PropertyCategories;

            //get element start date and end date
            foreach (Nw.PropertyCategory innerpropCat in innerpropCatCollection)
            {
                if (innerpropCat.DisplayName.ToString() == "TimeLiner" &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Attached to Task Start (Planned):1") &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Attached to Task End (Planned):1"))
                {
                    tempDateTime = (DateTime)innerpropCat.Properties
                                   .FindPropertyByDisplayName("Attached to Task Start (Planned):1").Value.ToDateTime();
                    eachElementData.ProtStartDate = (DateTime)innerpropCat.Properties
                                                    .FindPropertyByDisplayName("Attached to Task End (Planned):1").Value.ToDateTime();
                    break;
                }
            }


            //get element level and elevation
            foreach (Nw.PropertyCategory innerpropCat in innerpropCatCollection)
            {
                if (innerpropCat.DisplayName.ToString() == "Base Level" &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Elevation") &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Name"))
                {
                    //elevation is returned in feet and not as double
                    elevation = innerpropCat.Properties.FindPropertyByDisplayName("Elevation").Value.ToDoubleLength();
                    elevation = elevation * (double)0.3048;

                    eachElementData.Elevation = elevation;
                    eachElementData.Level     = innerpropCat.Properties.FindPropertyByDisplayName("Name").Value.ToString();
                    eachElementData.Level     = eachElementData.Level.Substring(eachElementData.Level.IndexOf(":") + 1);
                    break;
                }
            }

            //get start date of edge walls and railings
            foreach (Nw.PropertyCategory innerpropCat in innerpropCatCollection)
            {
                if (innerpropCat.DisplayName.ToString() == "Element ID" &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Value"))
                {
                    elementID         = innerpropCat.Properties.FindPropertyByDisplayName("Value").Value.ToString();
                    elementID         = elementID.Substring(elementID.IndexOf(":") + 1);
                    slabwallResult    = elementOperate.RoofOperations(elementID);
                    slabrailingResult = elementOperate.RailingOperations(elementID);
                    break;
                }
            }

            //in case of walls along the boundaries
            if (slabwallResult.edgestartDate.ToShortDateString() != "01-01-0001")
            {
                eachElementData.ProtEndDate = slabwallResult.edgestartDate;
                eachElementData.Hazard      = "Unprotected Slab Edges";
                eachElementData.Protection  = "Provide edge protection along the slab edges where exterior walls are to be built";
                TempListofSafetyIssues.Add(eachElementData);
            }

            //in case of railings along the boundaries
            if (slabrailingResult.edgestartDate.ToShortDateString() != "01-01-0001")
            {
                eachElementData.ProtEndDate = slabrailingResult.edgestartDate;
                eachElementData.Hazard      = "Unprotected Edges of Slab";
                eachElementData.Protection  = "Provide edge protection along the edges of the slab where railings are to be built";
                TempListofSafetyIssues.Add(eachElementData);
            }

            //in case of walls along openings
            if (slabwallResult.openingstartDate.ToShortDateString() != "01-01-0001")
            {
                eachElementData.ProtEndDate = slabwallResult.openingstartDate;
                eachElementData.Hazard      = "Unprotected Openings in slab";
                eachElementData.Protection  = "Provide edge protection along the opening edges where walls are to be built";
                TempListofSafetyIssues.Add(eachElementData);
            }

            //in case of railings along openings
            if (slabrailingResult.openingstartDate.ToShortDateString() != "01-01-0001")
            {
                eachElementData.ProtEndDate = slabrailingResult.openingstartDate;
                eachElementData.Hazard      = "Unprotected Openings in slab";
                eachElementData.Protection  = "Provide edge protection along the edges of openings where railings are to be built";
                TempListofSafetyIssues.Add(eachElementData);
            }


            eachElementData.EleStartDate  = tempDateTime;
            eachElementData.EleEndDate    = eachElementData.ProtStartDate;
            eachElementData.ProtStartDate = eachElementData.EleEndDate;
            eachElementData.ProtEndDate   = eachElementData.EleEndDate;
            eachElementData.ActivityName  = activityDescription;
            eachElementData.ElementType   = "Roof";
            eachElementData.Hazard        = "Unprotected Edges of Slab and slab openings";
            eachElementData.Protection    = "See general guidelines for Construction of slabs at height";
            TempListofSafetyIssues.Add(eachElementData);

            Result.ListofSafetyIssues.AddRange(TempListofSafetyIssues);
        }