当前位置: 首页>>代码示例>>C#>>正文


C# Project.Save方法代码示例

本文整理汇总了C#中Project.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Project.Save方法的具体用法?C# Project.Save怎么用?C# Project.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Project的用法示例。


在下文中一共展示了Project.Save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        public static void Run()
        {
            // ExStart:UpdateProjectAndRescheduleUncompletedWork
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            
            // Create a new project and set start date
            Project project = new Project();
            project.Set(Prj.StartDate, new DateTime(2014, 1, 27, 8, 0, 0));

            // Add new tasks
            Task task1 = project.RootTask.Children.Add("Task 1");
            Task task2 = project.RootTask.Children.Add("Task 2");
            task2.Set(Tsk.Duration, task2.ParentProject.GetDuration(16, TimeUnitType.Hour));
            Task task3 = project.RootTask.Children.Add("Task 3");
            task3.Set(Tsk.Duration, task2.ParentProject.GetDuration(24, TimeUnitType.Hour));
            Task task4 = project.RootTask.Children.Add("Task 4");
            task4.Set(Tsk.Duration, task2.ParentProject.GetDuration(16, TimeUnitType.Hour));
            Task task5 = project.RootTask.Children.Add("Task 5");
            task5.Set(Tsk.Duration, task2.ParentProject.GetDuration(16, TimeUnitType.Hour));

            // Add links between tasks
            TaskLink link12 = project.TaskLinks.Add(task1, task2, TaskLinkType.FinishToStart);
            TaskLink link23 = project.TaskLinks.Add(task2, task3, TaskLinkType.FinishToStart);
            // One day lag
            link23.LinkLag = 4800; 
            TaskLink link34 = project.TaskLinks.Add(task3, task4, TaskLinkType.FinishToStart);
            TaskLink link45 = project.TaskLinks.Add(task4, task5, TaskLinkType.FinishToStart);
            
            // Add new tasks
            Task task6 = project.RootTask.Children.Add("Task 6");
            Task task7 = project.RootTask.Children.Add("Task 7");
            task7.Set(Tsk.Duration, task7.ParentProject.GetDuration(24, TimeUnitType.Hour));
            Task task8 = project.RootTask.Children.Add("Task 8");
            task8.Set(Tsk.Duration, task2.ParentProject.GetDuration(16, TimeUnitType.Hour));
            Task task9 = project.RootTask.Children.Add("Task 9");
            task9.Set(Tsk.Duration, task2.ParentProject.GetDuration(16, TimeUnitType.Hour));
            Task task10 = project.RootTask.Children.Add("Task 10");
            
            // Add links between tasks
            TaskLink link67 = project.TaskLinks.Add(task6, task7, TaskLinkType.FinishToStart);
            TaskLink link78 = project.TaskLinks.Add(task7, task8, TaskLinkType.FinishToStart);
            TaskLink link89 = project.TaskLinks.Add(task8, task9, TaskLinkType.FinishToStart);
            TaskLink link910 = project.TaskLinks.Add(task9, task10, TaskLinkType.FinishToStart);
            task6.Set(Tsk.IsManual, true);
            task7.Set(Tsk.IsManual, true);
            task8.Set(Tsk.IsManual, true);
            task9.Set(Tsk.IsManual, true);
            task10.Set(Tsk.IsManual, true);
            
            // Save project before and after updating work as completed 
            project.Save(dataDir + "RescheduleUncompletedWork_not updated_out.xml", SaveFileFormat.XML);
            project.UpdateProjectWorkAsComplete(new DateTime(2014, 1, 28, 17, 0, 0), false);
            project.Save(dataDir + "RescheduleUncompletedWork_updated_out.xml", SaveFileFormat.XML);

            // Save project after rescheduling uncompleted work
            project.RescheduleUncompletedWorkToStartAfter(new DateTime(2014, 2, 7, 8, 0, 0));
            project.Save(dataDir + "RescheduleUncompletedWork_rescheduled_out.xml", SaveFileFormat.XML);
            // ExEnd:UpdateProjectAndRescheduleUncompletedWork
        }
开发者ID:aspose-tasks,项目名称:Aspose.Tasks-for-.NET,代码行数:60,代码来源:UpdateProjectAndRescheduleUncompletedWork.cs

示例2: Run

        public static void Run()
        {
            // ExStart:RenderTaskUsageViewWithDetails
            // Create project instance
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            Project project1 = new Project(dataDir + "TaskUsageViewWithDetails.mpp");

            // Get Default view
            UsageView view = project1.DefaultView as TaskUsageView;

            // Details header column will not be displayed
            view.DisplayDetailsHeaderColumn = false;
            view.RepeatDetailsHeaderOnAllRows = false;
            view.AlignDetailsData = StringAlignment.Near;
            project1.Save(dataDir + "task usage1_out.pdf", SaveFileFormat.PDF);

            // Display details header column
            view.DisplayDetailsHeaderColumn = true;

            // Repeat details header on all assignments rows
            view.RepeatDetailsHeaderOnAllRows = true;
            view.AlignDetailsData = StringAlignment.Far;
            project1.Save(dataDir + "task usage2_out.pdf", SaveFileFormat.PDF);
            // ExEnd:RenderTaskUsageViewWithDetails
        }
开发者ID:aspose-tasks,项目名称:Aspose.Tasks-for-.NET,代码行数:25,代码来源:RenderTaskUsageViewWithDetails.cs

示例3: Run

        public static void Run()
        {  
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

            // ExStart:AlignCellContents
            Project project = new Project(dataDir + "Project2.mpp");
            SaveOptions options = new PdfSaveOptions();
            options.Timescale = Timescale.Months;
            options.View = ProjectView.GetDefaultGanttChartView();

            GanttChartColumn column1 = options.View.Columns[2] as GanttChartColumn;
            column1.StringAlignment = StringAlignment.Center;
            column1 = options.View.Columns[3] as GanttChartColumn;
            column1.StringAlignment = StringAlignment.Far;
            column1 = options.View.Columns[4] as GanttChartColumn;
            column1.StringAlignment = StringAlignment.Far;

            project.Save(dataDir + "AlignCellContents_GanttChart_out.pdf", options);

            options.PresentationFormat = PresentationFormat.ResourceSheet;
            options.View = ProjectView.GetDefaultResourceSheetView();

            ResourceViewColumn column2 = options.View.Columns[2] as ResourceViewColumn;
            column2.StringAlignment = StringAlignment.Center;
            column2 = options.View.Columns[3] as ResourceViewColumn;
            column2.StringAlignment = StringAlignment.Far;
            column2 = options.View.Columns[4] as ResourceViewColumn;
            column2.StringAlignment = StringAlignment.Far;

            project.Save(dataDir + "AlignCellContents_ResourceSheet_out.pdf", options);
            // ExEnd:AlignCellContents
        }
开发者ID:aspose-tasks,项目名称:Aspose.Tasks-for-.NET,代码行数:33,代码来源:AlignCellContents.cs

示例4: Run

        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

            // ExStart:PrintProjectPagesToSeparateFiles
            Project project = new Project(dataDir + "CreateProject2.mpp");
            ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFileFormat.PNG);
            saveOptions.StartDate = project.Get(Prj.StartDate).AddDays(-3);
            saveOptions.EndDate = project.Get(Prj.FinishDate);
            
            saveOptions.MarkCriticalTasks = true;
            saveOptions.LegendOnEachPage = false;
            
            saveOptions.Gridlines = new List<Gridline>();
            
            Gridline gridline = new Gridline();
            gridline.GridlineType = GridlineType.GanttRow;
            gridline.Color = Color.CornflowerBlue;
            gridline.Pattern = LinePattern.Dashed;
            saveOptions.Gridlines.Add(gridline);
 
            // Save the whole project layout to one file
            project.Save(dataDir + "PrintProjectPagesToSeparateFiles1_out.png", saveOptions);
            
            // Save project layout to separate files
            saveOptions.SaveToSeparateFiles = true;
            project.Save(dataDir + "PrintProjectPagesToSeparateFiles2_out.png", saveOptions);
            // ExEnd:PrintProjectPagesToSeparateFiles
        }
开发者ID:aspose-tasks,项目名称:Aspose.Tasks-for-.NET,代码行数:30,代码来源:PrintProjectPagesToSeparateFiles.cs

示例5: Run

        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

            // ExStart:RenderResourceUsageView
            // Create project instance
            Project project1 = new Project(dataDir + "ResourceUsageView.mpp");
                        
            // Define the SaveOptions with required TimeScale settings as Days
            SaveOptions options = new PdfSaveOptions();
            options.Timescale = Timescale.Days;

            // Set the Presentation format to ResourceUsage
            options.PresentationFormat = PresentationFormat.ResourceUsage;

            // Save the Project
            string outputFile = "result_ResourceUsageView_days_out.pdf";
            project1.Save(dataDir + outputFile, options);

            // Set the Tiemscale settings to ThirdsOfMonths and save the Project
            options.Timescale = Timescale.ThirdsOfMonths;
            outputFile = "result_ResourceUsageView_thirdsOfMonths_out.pdf";
            project1.Save(dataDir + outputFile, options);

            // Set the Timescale settings to Months and save the Project
            options.Timescale = Timescale.Months;
            outputFile = "result_ResourceUsageView_months_out.pdf";
            project1.Save(dataDir + outputFile, options);
            // ExEnd:RenderResourceUsageView
        }
开发者ID:aspose-tasks,项目名称:Aspose.Tasks-for-.NET,代码行数:31,代码来源:RenderResourceUsageView.cs

示例6: Run

        public static void Run()
        {
            // ExStart:ReadTaskWBS
            // Read project
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            Project project1 = new Project(dataDir + "TaskWBS.mpp");

            // Create a ChildTasksCollector instance
            ChildTasksCollector collector = new ChildTasksCollector();

            // Collect all the tasks from RootTask using TaskUtils
            TaskUtils.Apply(project1.RootTask, collector, 0);

            // Parse through all the collected tasks
            foreach (Task tsk in collector.Tasks)
            {
                Console.WriteLine(tsk.Get(Tsk.WBS));
                Console.WriteLine(tsk.Get(Tsk.WBSLevel));
                
                // Set custom WBS
                tsk.Set(Tsk.WBS, "custom wbs" + tsk.Get(Tsk.WBS));
            }
            // ExEnd:ReadTaskWBS

            // Save project as PDF
            project1.Save(dataDir + "TaskWBS_out.pdf", SaveFileFormat.PDF);
        }
开发者ID:aspose-tasks,项目名称:Aspose.Tasks-for-.NET,代码行数:27,代码来源:ReadTaskWBS.cs

示例7: Run

        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

            // ExStart:SetTimeScaleCount
            Project project = new Project();

            // Init Gantt Chart View
            GanttChartView view = new GanttChartView();

            // Set Time Scale count
            view.BottomTimescaleTier.Count = 2;
            view.BottomTimescaleTier.ShowTicks = false; 
            view.MiddleTimescaleTier.Count = 2;
            view.MiddleTimescaleTier.ShowTicks = false;
            
            // Add Gantt Chart View to project
            project.Views.Add(view);

            // Add some test data to project
            Task task1 = project.RootTask.Children.Add("Task 1");
            Task task2 = project.RootTask.Children.Add("Task 2");
            task1.Set(Tsk.Duration, task1.ParentProject.GetDuration(24, TimeUnitType.Hour));
            task2.Set(Tsk.Duration, task1.ParentProject.GetDuration(40, TimeUnitType.Hour));
            project.Save(dataDir + "SetTimeScaleCount_out.pdf", SaveFileFormat.PDF); 
            // ExEnd:SetTimeScaleCount
        }
开发者ID:aspose-tasks,项目名称:Aspose.Tasks-for-.NET,代码行数:28,代码来源:SetTimeScaleCount.cs

示例8: Run

        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

            // ExStart:ChangeGanttBarsColorGradient
            Project project = new Project(dataDir + "Project2.mpp");
            
            SaveOptions options = new XamlOptions();
            options.UseGradientBrush = false;
            project.Save(dataDir + "ChangeGanttBarsColorGradient_Solid_out.xaml", options);

            options.UseGradientBrush = true;
            project.Save(dataDir + "ChangeGanttBarsColorGradient_Gradient_out.xaml", options);
            // ExEnd:ChangeGanttBarsColorGradient
        }
开发者ID:aspose-tasks,项目名称:Aspose.Tasks-for-.NET,代码行数:16,代码来源:ChangeGanttBarsColorGradient.cs

示例9: Run

        public static void Run()
        {
            // ExStart:CreateSplitTasks
            // Create new project
            Project splitTaskProject = new Project();

            // Get a standard calendar
            Calendar calendar = splitTaskProject.Get(Prj.Calendar);

            // Set project's calendar settings
            splitTaskProject.Set(Prj.StartDate, new DateTime(2000, 3, 15, 8, 0, 0));
            splitTaskProject.Set(Prj.FinishDate, new DateTime(2000, 4, 21, 17, 0, 0));

            // Add a new task to root task
            Task rootTask = splitTaskProject.RootTask;
            rootTask.Set(Tsk.Name, "Root");
            Task taskToSplit = rootTask.Children.Add("Task1");
            taskToSplit.Set(Tsk.Duration, splitTaskProject.GetDuration(3));

            // Create a new resource assignment and generate timephased data
            ResourceAssignment splitResourceAssignment = splitTaskProject.ResourceAssignments.Add(taskToSplit, null);
            splitResourceAssignment.TimephasedDataFromTaskDuration(calendar);

            // Split the task into 3 parts.
            // Provide start date and finish date arguments to SplitTask method which will be used for split
            splitResourceAssignment.SplitTask(new DateTime(2000, 3, 16, 8, 0, 0), new DateTime(2000, 3, 16, 17, 0, 0), calendar);
            splitResourceAssignment.SplitTask(new DateTime(2000, 3, 18, 8, 0, 0), new DateTime(2000, 3, 18, 17, 0, 0), calendar);
            splitResourceAssignment.Set(Asn.WorkContour, WorkContourType.Contoured);

            // Save the Project
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            splitTaskProject.Save(dataDir + "CreateSplitTasks_out.xml", SaveFileFormat.XML);
            // ExEnd:CreateSplitTasks
        }
开发者ID:aspose-tasks,项目名称:Aspose.Tasks-for-.NET,代码行数:34,代码来源:CreateSplitTasks.cs

示例10: Run

        public static void Run()
        {
            try
            {
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

                // ExStart:AddImageToPageHeaderFooter
                Project project = new Project(dataDir + "AddImageToPageHeaderFooter.mpp");

                project.RootTask.Children.Add("Task1");
                PageInfo pageInfo = project.DefaultView.PageInfo;
                
                using (Image image = Image.FromFile(dataDir + "Image1.png"))
                {
                    pageInfo.Header.CenteredImage = image;
                    pageInfo.Legend.LeftImage = image;
                    pageInfo.Legend.LeftText = string.Empty;
                    MPPSaveOptions saveOptions = new MPPSaveOptions();
                    saveOptions.WriteViewData = true;
                    project.Save(dataDir + "AddImageToPageHeaderFooter_out.mpp", saveOptions);
                }
                // ExEnd:AddImageToPageHeaderFooter
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http://www.aspose.com/purchase/default.aspx.");
            }
        }
开发者ID:aspose-tasks,项目名称:Aspose.Tasks-for-.NET,代码行数:29,代码来源:AddImageToPageHeaderFooter.cs

示例11: Main

        static void Main(string[] args)
        {
            string FileName = @"E:\Aspose\Aspose Vs VSTO\Aspose.Tasks VS VSTO Projects\Sample Files\NewProject.xml";
            Project MyProject = new Project();

            MyProject.Save(FileName, Saving.SaveFileFormat.XML);
        }
开发者ID:arboledaCarlos,项目名称:Aspose_Tasks_NET,代码行数:7,代码来源:Program.cs

示例12: Run

        public static void Run()
        {
            try
            {
                // ExStart:WriteMPPProjectSummary
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

                // Instantiate Project class
                Project project = new Project(dataDir + "WriteMPPProjectSummary.mpp");

                // Set project summary
                project.Set(Prj.Author, "Author");
                project.Set(Prj.LastAuthor, "Last Author");
                project.Set(Prj.Revision, 15);
                project.Set(Prj.Keywords, "MSP Aspose");
                project.Set(Prj.Comments, "Comments");
                project.Save(dataDir + "WriteMPPProjectSummary_out.mpp", SaveFileFormat.MPP);
                // ExEnd:WriteMPPProjectSummary
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http://www.aspose.com/purchase/default.aspx.");
            }          
        }
开发者ID:aspose-tasks,项目名称:Aspose.Tasks-for-.NET,代码行数:25,代码来源:WriteMPPProjectSummary.cs

示例13: Run

        public static void Run()
        {
            try
            {				
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

                // ExStart:ReplaceCalendarWithNewCalendar
                // Create project
                Project project = new Project(dataDir + "Project5.mpp");

                // Access project calendars
                CalendarCollection calColl = project.Calendars;
                foreach (Calendar myCalendar in calColl)
                {
                    if (myCalendar.Name == "TestCalendar")
                    {
                        // Remove calendar
                        calColl.Remove(myCalendar);
                    }
                }

                // Add new calendar
                Calendar newCalendar = calColl.Add("TestCalendar");
                project.Save(dataDir + "ReplaceCalendar_out.mpp", SaveFileFormat.MPP);
                // ExEnd:ReplaceCalendarWithNewCalendar
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http://www.aspose.com/purchase/default.aspx.");
            }
        }
开发者ID:aspose-tasks,项目名称:Aspose.Tasks-for-.NET,代码行数:32,代码来源:ReplaceCalendarWithNewCalendar.cs

示例14: Run

        public static void Run()
        {
            try
            {
                // ExStart:ConfigureGantChart
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); 
                Project project = new Project(dataDir + "Project5.mpp"); // Create a new project task
                Task task = project.RootTask.Children.Add("New Activity");

                // Add custom text attribute to created task.
                ExtendedAttribute attr = new ExtendedAttribute();
                attr.FieldId = ((int)ExtendedAttributeTask.Text1).ToString();
                attr.Value = "Activity attribute";
                task.ExtendedAttributes.Add(attr);

                // Customize table by adding text attribute field
                TableField attrField = new TableField();
                attrField.Field = Field.TaskText1;
                attrField.Width = 20;
                attrField.Title = "Custom attribute";
                attrField.AlignTitle = StringAlignment.Center;
                attrField.AlignData = StringAlignment.Center;

                Table table = project.Tables.ToList()[0];
                table.TableFields.Insert(3, attrField);
                         
                project.Save(dataDir + "ConfigureGantChart_out.mpp", SaveFileFormat.MPP);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx.");
            }
            // ExEnd:ConfigureGantChart
        }
开发者ID:aspose-tasks,项目名称:Aspose.Tasks-for-.NET,代码行数:35,代码来源:ConfigureGantChart.cs

示例15: ImplementCustomBarSytle

        // ExStart:ImplementCustomBarStyleWriting
        static void ImplementCustomBarSytle()
        {
            try
            {
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

                Project project = new Project(dataDir + "Blank2010.mpp");
                project.RootTask.Children.Add("Task");

                GanttChartView view = project.DefaultView as GanttChartView;
                GanttBarStyle custom = GetCustomBarStyle();

                // Add the custom bar style to the custom bar collection of the project view
                view.CustomBarStyles.Add(custom);

                string file = "ImplementCustomBarStyleWriting_out.mpp";

                MPPSaveOptions options = new MPPSaveOptions();
                options.WriteViewData = true;

                project.Save(dataDir + file, options);
            }
            catch (NotSupportedException ex)
            {
                Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http://www.aspose.com/purchase/default.aspx.");
            }
        }
开发者ID:aspose-tasks,项目名称:Aspose.Tasks-for-.NET,代码行数:29,代码来源:ImplementCustomBarStyleWriting.cs


注:本文中的Project.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。