예제 #1
0
        /// <summary>
        /// Converts LoadOptionsPost to LoadOptions of T
        /// </summary>
        /// <param name="posted"></param>
        /// <returns></returns>
        public GetOptions <T> ToModelGetOptions(LoadOpts posted)
        {
            GetOptions <T> opts = new GetOptions <T>();

            opts.Skip       = posted.Skip;
            opts.Showing    = posted.Showing;
            opts.SearchTerm = posted.SearchTerm;
            SortDir dir;

            if (Enum.TryParse(posted.Direction, out dir))
            {
                opts.Direction = dir;
            }

            if (string.IsNullOrEmpty(posted.OrderProperty) && opts.Showing != 0)
            {
                throw new Exception("OrderProperty must be set if Showing is not 0");
            }
            opts.OrderProperty = posted.OrderProperty;

            if (posted.Filters != null)
            {
                opts.Filters = ToFilterExpressions(posted.Filters);
            }
            return(opts);
        }
예제 #2
0
        protected GetOptions <T> ReadOptionsFor <T>() where T : class
        {
            LoadOpts opts = Activator.CreateInstance <LoadOpts>();

            if (Request.RequestUri.TryReadQueryAs(out opts))
            {
                return(opts.GetOptionsFor <T>());
            }
            else
            {
                return(new GetOptions <T>());
            }
        }
예제 #3
0
        private void backgroundWorker4_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            try
            {
                if (e.Cancelled)
                {
                    MessageBox.Show("The Task Has Been Cancelled", "Cancelled", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    progressBar1.Value  = 0;
                    StatusLabel.Visible = false;
                }
                else if (e.Error != null)
                {
                    MessageBox.Show("Error. Details: " + (e.Error as Exception).ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    progressBar1.Value  = 0;
                    StatusLabel.Visible = false;
                }
                else
                {
                    RevitServices.Transactions.TransactionManager.Instance.ForceCloseTransaction();


                    var distinctItems = deleteParametersWindows.GroupBy(x => x.Id).Select(y => y.First()); //Sorts the list into only unique items

                    foreach (var item in distinctItems)
                    {
                        Document      famDoc        = localDoc.Document.EditFamily(item); //get the family property of the family
                        FamilyManager familyManager = famDoc.FamilyManager;

                        using (Transaction t = new Transaction(famDoc, "Set Parameter")) //Change Door values
                        {
                            t.Start();

                            try
                            {
                                ///delete here
                                ///

                                FamilyParameter param = familyManager.get_Parameter("Fire_Rating");

                                familyManager.RemoveParameter(param);
                            }
                            catch
                            {
                                //silent catch to continue if Fire_Rating is already on a door from a previous activation
                            }

                            t.Commit();

                            LoadOpts famLoadOptions         = new LoadOpts();
                            Autodesk.Revit.DB.Family newFam = famDoc.LoadFamily(localDoc.Document, famLoadOptions);
                        }
                    }



                    MessageBox.Show("The Task Has Been Completed.", "Completed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    progressBar1.Value = 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            DoorToWall.Enabled              = true;
            WindowToWall.Enabled            = true;
            DeleteFireRatingsDoors.Enabled  = true;
            DeleteFireRatingsWindow.Enabled = true;

            deleteParametersWindows.Clear();

            buttonCancel.Enabled = false;
            StatusLabel.Visible  = false;
        }
예제 #4
0
        private void backgroundWorker2_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            try
            {
                if (e.Cancelled)
                {
                    MessageBox.Show("The Task Has Been Cancelled", "Cancelled", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    progressBar1.Value  = 0;
                    StatusLabel.Visible = false;
                }
                else if (e.Error != null)
                {
                    MessageBox.Show("Error. Details: " + (e.Error as Exception).ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    progressBar1.Value  = 0;
                    StatusLabel.Visible = false;
                }
                else
                {
                    RevitServices.Transactions.TransactionManager.Instance.ForceCloseTransaction();

                    var distinctItems = windowFamilies.GroupBy(x => x.Id).Select(y => y.First()); //Make List Have Only Unique Families

                    Document famDoc;

                    foreach (var item in distinctItems)
                    {
                        famDoc = localDoc.Document.EditFamily(item); //get the family property of the family
                        FamilyManager familyManager = famDoc.FamilyManager;

                        using (Transaction t = new Transaction(famDoc, "Set Parameter")) //Change Door values
                        {
                            t.Start();

                            try
                            {
                                FamilyParameter newParam = familyManager.AddParameter("Fire_Rating", BuiltInParameterGroup.PG_IDENTITY_DATA, ParameterType.Text, true);
                            }
                            catch
                            {
                                //silent catch to continue if Fire_Rating is already on a door from a previous activation
                            }


                            t.Commit();

                            LoadOpts famLoadOptions         = new LoadOpts();
                            Autodesk.Revit.DB.Family newFam = famDoc.LoadFamily(localDoc.Document, famLoadOptions);
                        }
                    }


                    using (Transaction t = new Transaction(localDoc.Document, "Set Parameter")) //Change Door values
                    {
                        t.Start();

                        foreach (var item in windowElementsDictionary)
                        {
                            ParameterSet ps = item.Key.Parameters;

                            foreach (Parameter p in ps)
                            {
                                if (p.Definition.Name == "Fire_Rating")
                                {
                                    p.Set(item.Value);
                                }
                            }
                        }


                        t.Commit();
                    }


                    MessageBox.Show("The Task Has Been Completed.", "Completed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    progressBar1.Value = 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }


            DoorToWall.Enabled              = true;
            WindowToWall.Enabled            = true;
            DeleteFireRatingsDoors.Enabled  = true;
            DeleteFireRatingsWindow.Enabled = true;


            buttonCancel.Enabled = false;
            StatusLabel.Visible  = false;
        }