コード例 #1
0
ファイル: mPurge.cs プロジェクト: ChaBoiNick/SharpPaul
        public static int DeleteAllSchedules(Document curDoc)
        {
            int counter = 0;

            //get all schedules
            List <ViewSchedule> viewList = CollectorsAll.getAllSchedules(curDoc);

            //create transaction
            using (Transaction curTrans = new Transaction(curDoc, "Delete All Schedules"))
            {
                if (curTrans.Start() == TransactionStatus.Started)
                {
                    //loop through sheets - if view is not current then delete
                    foreach (View curView in viewList)
                    {
                        if (curDoc.ActiveView.Id.Compare(curView.Id) != 0)
                        {
                            try
                            {
                                //delete view
                                curDoc.Delete(curView.Id);

                                //incremenet counter
                                counter = counter + 1;
                            }
                            catch (Exception)
                            {
                                System.Diagnostics.Debug.Print("Could not delete schedule");
                            }
                        }
                    }
                }

                //commit changes
                curTrans.Commit();
                curTrans.Dispose();
            }

            //return counter
            return(counter);
        }