예제 #1
0
        private static void CheckOutlineCodeIdUniqueness(string dataDir)
        {
            //ExStart:CheckOutlineCodeIdUniqueness
            Project project = new Project(dataDir + "OutlineValues2010.mpp");

            OutlineCodeDefinition textOutline = new OutlineCodeDefinition();

            textOutline.FieldId = ExtendedAttributeTask.OutlineCode7.ToString("D");
            textOutline.Alias   = "My Outline Code";

            project.OutlineCodes.Add(textOutline);

            OutlineMask mask = new OutlineMask();

            mask.Type = MaskType.Characters;
            textOutline.Masks.Add(mask);

            OutlineValue textValue = new OutlineValue();

            textValue.Value       = "Text value 1";
            textValue.ValueId     = 1;
            textValue.Type        = OutlineValueType.Text;
            textValue.Description = "Text value descr 1";
            textOutline.Values.Add(textValue);

            project.Save(dataDir + "MultipleOutlineValues.mpp", SaveFileFormat.MPP);
            //ExEnd:CheckOutlineCodeIdUniqueness
        }
예제 #2
0
        public void WorkWithOutlineMask()
        {
            // ExStart:WorkWithOutlineMask
            // ExFor: OutlineMask
            // ExFor: OutlineMask.#ctor
            // ExFor: OutlineMask.Type
            // ExFor: OutlineMask.Separator
            // ExFor: OutlineMask.Level
            // ExFor: OutlineMask.Length
            // ExSummary: Shows how to work with outline masks.
            var project = new Project(DataDir + "OutlineValues2010.mpp");

            var outline = new OutlineCodeDefinition();

            outline.FieldId = ExtendedAttributeTask.OutlineCode7.ToString("D");
            outline.Alias   = "My Outline Code";

            project.OutlineCodes.Add(outline);

            var mask = new OutlineMask();

            // set the type of a mask
            mask.Type = MaskType.Characters;

            // set the separator of code values
            mask.Separator = "/";

            // set the level of a mask
            mask.Level = 1;

            // set the maximum length (in characters) of the outline code values. 0 if length is not defined.
            mask.Length = 2;

            // add the mask to the definition
            outline.Masks.Add(mask);

            var value = new OutlineValue();

            value.Value       = "Text value 1";
            value.ValueId     = 1;
            value.Type        = OutlineValueType.Text;
            value.Description = "Text value descr 1";
            outline.Values.Add(value);

            // ...
            // ExEnd:WorkWithOutlineMask
        }
예제 #3
0
        public void WorkWithOutlineCodeCollection()
        {
            // ExStart
            // ExFor: OutlineCodeCollection
            // ExFor: OutlineCodeCollection.Add(OutlineCode)
            // ExFor: OutlineCodeCollection.Clear
            // ExFor: OutlineCodeCollection.Contains(OutlineCode)
            // ExFor: OutlineCodeCollection.CopyTo(OutlineCode[],Int32)
            // ExFor: OutlineCodeCollection.Count
            // ExFor: OutlineCodeCollection.GetEnumerator
            // ExFor: OutlineCodeCollection.IndexOf(OutlineCode)
            // ExFor: OutlineCodeCollection.Insert(Int32,OutlineCode)
            // ExFor: OutlineCodeCollection.IsReadOnly
            // ExFor: OutlineCodeCollection.Item(Int32)
            // ExFor: OutlineCodeCollection.Remove(OutlineCode)
            // ExFor: OutlineCodeCollection.RemoveAt(Int32)
            // ExSummary: Shows how to work with outline code collections.
            var project = new Project(DataDir + "OutlineCodes2003.mpp");

            var collector = new ChildTasksCollector();

            TaskUtils.Apply(project.RootTask, collector, 0);

            for (var i = 0; i < collector.Tasks.Count; i++)
            {
                var current = collector.Tasks[i];
                if (current.Get(Tsk.Id) == 0)
                {
                    continue;
                }

                Console.WriteLine("Print outline codes for the " + current.Get(Tsk.Name) + " task.");
                Console.WriteLine("Count of outline codes: " + current.OutlineCodes.Count);
                foreach (var outlineCode in current.OutlineCodes)
                {
                    Console.WriteLine("Field Id: " + outlineCode.FieldId);
                    Console.WriteLine("Value Id: " + outlineCode.ValueId);
                    Console.WriteLine("Value Guid: " + outlineCode.ValueGuid);
                    Console.WriteLine();
                }
            }

            // add a custom outline code definition
            var outlineCodeDefinition = new OutlineCodeDefinition {
                FieldId = ((int)ExtendedAttributeTask.OutlineCode3).ToString("D"), Alias = "My Outline Code"
            };

            project.OutlineCodes.Add(outlineCodeDefinition);

            // create outline code
            var value = new OutlineValue {
                Type = OutlineValueType.Text, Value = "Val1", Description = "Descr1", ValueId = 1
            };

            outlineCodeDefinition.Values.Add(value);

            var codeOne = new OutlineCode {
                FieldId = outlineCodeDefinition.FieldId, ValueId = 1, ValueGuid = value.ValueGuid.ToString("D").ToUpperInvariant()
            };

            var task = project.RootTask.Children.GetByUid(2);

            // one can check that collection is not read only
            if (!task.OutlineCodes.IsReadOnly)
            {
                task.OutlineCodes.Add(codeOne);
            }

            var codeZero = new OutlineCode {
                FieldId = outlineCodeDefinition.FieldId, ValueId = 0, ValueGuid = value.ValueGuid.ToString("D").ToUpperInvariant()
            };

            task.OutlineCodes.Insert(0, codeZero);

            var code2 = new OutlineCode {
                FieldId = outlineCodeDefinition.FieldId, ValueId = 2, ValueGuid = value.ValueGuid.ToString("D").ToUpperInvariant()
            };

            // insert code with 2 in a wrong position
            task.OutlineCodes.Insert(0, code2);

            // fix it
            var indexOf = task.OutlineCodes.IndexOf(code2);

            task.OutlineCodes.RemoveAt(indexOf);

            // insert code with 2 in a right position
            task.OutlineCodes.Insert(2, code2);

            // check that the code was inserted
            Console.WriteLine("Is outline codes contains the inserted value: " + task.OutlineCodes.Contains(code2));

            // ...
            // work with outline codes
            // ...
            var otherProject = new Project(DataDir + "OutlineCodes2003.mpp");
            var otherTask    = otherProject.RootTask.Children.GetById(2);

            // add a custom outline code definition
            outlineCodeDefinition = new OutlineCodeDefinition {
                FieldId = ((int)ExtendedAttributeTask.OutlineCode3).ToString("D"), Alias = "My Outline Code"
            };
            otherProject.OutlineCodes.Add(outlineCodeDefinition);

            // create outline code
            var otherValue = new OutlineValue {
                Type = OutlineValueType.Text, Value = "Val1", Description = "Descr1", ValueId = 1
            };

            outlineCodeDefinition.Values.Add(otherValue);

            var outlineCodes = new OutlineCode[task.OutlineCodes.Count];

            task.OutlineCodes.CopyTo(outlineCodes, 0);

            foreach (var code in outlineCodes)
            {
                otherTask.OutlineCodes.Add(code);
            }

            // ...
            // work with outline codes
            // ...

            // remove outline code
            otherTask.OutlineCodes.RemoveAt(0);

            while (otherTask.OutlineCodes.Count > 0)
            {
                otherTask.OutlineCodes.Remove(otherTask.OutlineCodes[0]);
            }

            // clear all values at once
            task.OutlineCodes.Clear();

            // ExEnd
        }
        public static void Run()
        {
            try
            {
                // ExStart:UpdateOutlineCodes
                string  dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
                Project project = new Project(dataDir + "project.mpp");

                // Define outline code and its outline mask
                OutlineCodeDefinition code1 = new OutlineCodeDefinition();
                code1.Alias     = "New task outline code1";
                code1.FieldId   = ((int)ExtendedAttributeTask.OutlineCode1).ToString();
                code1.FieldName = "Outline Code1";
                OutlineMask mask = new OutlineMask();
                mask.Separator = "+";
                mask.Level     = 1;
                mask.Type      = MaskType.Numbers;
                code1.Masks.Add(mask);

                // Add outline value
                OutlineValue value = new OutlineValue();
                value.Description = "Value description";
                value.ValueId     = 1;
                value.Value       = "123456";
                value.Type        = OutlineValueType.Number;
                code1.Values.Add(value);

                // Add outline code to project
                project.OutlineCodes.Add(code1);

                // Define outline code and its outline mask
                OutlineCodeDefinition code2 = new OutlineCodeDefinition();
                code2.Alias     = "New rsc outline code2";
                code2.FieldId   = ((int)ExtendedAttributeResource.OutlineCode2).ToString();
                code2.FieldName = "Outline Code2";
                OutlineMask mask2 = new OutlineMask();
                mask2.Separator = "/";
                mask2.Level     = 1;
                mask2.Type      = MaskType.Numbers;
                code2.Masks.Add(mask2);

                // Add outline value
                OutlineValue value2 = new OutlineValue();
                value2.Description = "Value2 description";
                value2.ValueId     = 2;
                value2.Value       = "987654";
                value2.Type        = OutlineValueType.Number;
                code2.Values.Add(value2);

                // Add outline code to project
                project.OutlineCodes.Add(code2);

                // Save project as MPP
                project.Save(dataDir + "Updated_project_out.mpp", SaveFileFormat.MPP);
                // ExEnd:UpdateOutlineCodes
            }
            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.");
            }
        }
예제 #5
0
        public void UpdateOutlineCodes()
        {
            try
            {
                // ExStart:UpdateOutlineCodes
                // ExFor: OutlineCodeDefinition.Values
                // ExSummary: Shows how to create new outline codes.
                var project = new Project(DataDir + "project.mpp");

                // Define outline code and its outline mask
                var code1 = new OutlineCodeDefinition();
                code1.Alias     = "New task outline code1";
                code1.FieldId   = ((int)ExtendedAttributeTask.OutlineCode1).ToString();
                code1.FieldName = "Outline Code1";
                var mask = new OutlineMask();
                mask.Separator = "+";
                mask.Level     = 1;
                mask.Type      = MaskType.Numbers;
                code1.Masks.Add(mask);

                // Add outline value
                var value = new OutlineValue();
                value.Description = "Value description";
                value.ValueId     = 1;
                value.Value       = "123456";
                value.Type        = OutlineValueType.Number;
                code1.Values.Add(value);

                // Add outline code to project
                project.OutlineCodes.Add(code1);

                // Define outline code and its outline mask
                var code2 = new OutlineCodeDefinition();
                code2.Alias     = "New rsc outline code2";
                code2.FieldId   = ((int)ExtendedAttributeResource.OutlineCode2).ToString();
                code2.FieldName = "Outline Code2";
                var mask2 = new OutlineMask();
                mask2.Separator = "/";
                mask2.Level     = 1;
                mask2.Type      = MaskType.Numbers;
                code2.Masks.Add(mask2);

                // Add outline value
                var value2 = new OutlineValue();
                value2.Description = "Value2 description";
                value2.ValueId     = 2;
                value2.Value       = "987654";
                value2.Type        = OutlineValueType.Number;
                code2.Values.Add(value2);

                // Add outline code to project
                project.OutlineCodes.Add(code2);

                project.Save(OutDir + "Updated_project_out.mpp", SaveFileFormat.MPP);

                // ExEnd:UpdateOutlineCodes
            }
            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.");
            }
        }
예제 #6
0
        public void CheckOutlineCodeIdUniqueness()
        {
            // ExStart:CheckOutlineCodeIdUniqueness
            // ExFor: OutlineCodeDefinition
            // ExFor: OutlineCodeDefinition.#ctor
            // ExFor: OutlineCodeDefinition.FieldId
            // ExFor: OutlineCodeDefinition.Alias
            // ExFor: OutlineCodeDefinition.AllLevelsRequired
            // ExFor: OutlineCodeDefinition.Enterprise
            // ExFor: OutlineCodeDefinition.EnterpriseOutlineCodeAlias
            // ExFor: OutlineCodeDefinition.FieldName
            // ExFor: OutlineCodeDefinition.Guid
            // ExFor: OutlineCodeDefinition.LeafOnly
            // ExFor: OutlineCodeDefinition.Masks
            // ExFor: OutlineCodeDefinition.OnlyTableValuesAllowed
            // ExFor: OutlineCodeDefinition.PhoneticAlias
            // ExFor: OutlineCodeDefinition.ResourceSubstitutionEnabled
            // ExFor: OutlineCodeDefinition.ShowIndent
            // ExSummary: Shows how to work with outline code definitions.
            var project = new Project(DataDir + "OutlineValues2010.mpp");

            // create a new outline code definition
            var outline = new OutlineCodeDefinition();

            // set the field number of an outline code
            outline.FieldId = ExtendedAttributeTask.OutlineCode7.ToString("D");

            // set the name of a custom outline code
            outline.FieldName = "Outline Code1";

            // set the Guid of an outline code
            outline.Guid = "e6afac06-0d86-4359-a96c-db705e3d2ca8";

            // set a value indicating whether the values specified in this outline code field must be leaf values
            outline.LeafOnly = false;

            // set the alias of a custom outline code
            outline.Alias = "My Outline Code";

            // set the phonetic pronunciation of the alias of the custom outline code
            outline.PhoneticAlias = "Outline Code";

            // set a value indicating whether the new codes must have all levels. Not available for Enterprise Codes.
            outline.AllLevelsRequired = true;

            // set a value indicating whether a custom outline code is an enterprise custom outline code
            outline.Enterprise = false;

            // set a reference to another custom field for which this outline code definition is an alias
            outline.EnterpriseOutlineCodeAlias = 0;

            // add an outline mask
            var mask = new OutlineMask();

            mask.Type = MaskType.Characters;
            outline.Masks.Add(mask);

            // set a value indicating whether the values specified must come from values table
            outline.OnlyTableValuesAllowed = false;

            // set a value indicating whether the custom outline code can be used
            // by the Resource Substitution Wizard in Microsoft Project
            outline.ResourceSubstitutionEnabled = false;

            // set a value indicating whether the indents of this outline code must be shown.
            outline.ShowIndent = false;

            project.OutlineCodes.Add(outline);

            var value = new OutlineValue();

            value.Value       = "Text value 1";
            value.ValueId     = 1;
            value.Type        = OutlineValueType.Text;
            value.Description = "Text value descr 1";
            outline.Values.Add(value);

            // ...
            // ExEnd:CheckOutlineCodeIdUniqueness
        }
예제 #7
0
        public void WorkWithOutlineValue()
        {
            // ExStart:WorkWithOutlineValue
            // ExFor: OutlineValue
            // ExFor: OutlineValue.Type
            // ExFor: OutlineValue.Value
            // ExFor: OutlineValue.ValueGuid
            // ExFor: OutlineValue.ValueId
            // ExFor: OutlineValue.Description
            // ExFor: OutlineValue.DurationValue
            // ExFor: OutlineValue.IsCollapsed
            // ExFor: OutlineValue.ParentValueId
            // ExFor: OutlineValueType
            // ExSummary: Shows how to work with outline values.
            var project = new Project(DataDir + "OutlineValues2010.mpp");

            var outline = new OutlineCodeDefinition();

            outline.FieldId = ExtendedAttributeTask.OutlineCode7.ToString("D");
            outline.Alias   = "My Outline Code";
            var outline2 = new OutlineCodeDefinition();

            outline2.FieldId = ExtendedAttributeTask.OutlineCode7.ToString("D");
            outline2.Alias   = "My Outline Code 2";

            project.OutlineCodes.Add(outline);

            var mask = new OutlineMask();

            mask.Type = MaskType.Characters;
            outline.Masks.Add(mask);

            // create an outline value
            var value = new OutlineValue();

            // set the actual value
            value.Value = "Text value 1";

            // set the unique Id of an outline code value within a project
            value.ValueId = 1;

            // get a GUID which identifies this value among others in the entire project
            Console.WriteLine("Check value GUID: " + value.ValueGuid);

            // set the outline code type
            value.Type = OutlineValueType.Text;

            // set the description of an outline value
            value.Description = "Text value descr 1";

            // set a value indicating whether outline value is collapsed or not
            value.IsCollapsed = false;

            // check parent value id
            Console.WriteLine("Check parent value id: " + value.ParentValueId);
            outline.Values.Add(value);

            // create an outline value with duration
            var value2 = new OutlineValue();

            // set the duration value
            value2.DurationValue = project.GetDuration(1, TimeUnitType.Hour);

            // set the unique Id of an outline code value within a project
            value2.ValueId = 2;
            outline2.Values.Add(value2);

            // ...
            // ExEnd:WorkWithOutlineValue
        }
        public static void Run()
        {
            try
            {
                // ExStart:UpdateOutlineCodes
                string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
                Project project = new Project(dataDir + "project.mpp");
                 
                // Define outline code and its outline mask
                OutlineCodeDefinition code1 = new OutlineCodeDefinition();
                code1.Alias = "New task outline code1";
                code1.FieldId = ((int)ExtendedAttributeTask.OutlineCode1).ToString();
                code1.FieldName = "Outline Code1";
                OutlineMask mask = new OutlineMask();
                mask.Separator = "+";
                mask.Level = 1;
                mask.Type = MaskType.Numbers;
                code1.Masks.Add(mask);

                // Add outline value
                OutlineValue value = new OutlineValue();
                value.Description = "Value description";
                value.ValueId = 1;
                value.Value = "123456";
                value.Type = OutlineValueType.Number;
                code1.Values.Add(value);

                // Add outline code to project
                project.OutlineCodes.Add(code1);

                // Define outline code and its outline mask
                OutlineCodeDefinition code2 = new OutlineCodeDefinition();
                code2.Alias = "New rsc outline code2";
                code2.FieldId = ((int)ExtendedAttributeResource.OutlineCode2).ToString();
                code2.FieldName = "Outline Code2";
                OutlineMask mask2 = new OutlineMask();
                mask2.Separator = "/";
                mask2.Level = 1;
                mask2.Type = MaskType.Numbers;
                code2.Masks.Add(mask2);

                // Add outline value
                OutlineValue value2 = new OutlineValue();
                value2.Description = "Value2 description";
                value2.ValueId = 2;
                value2.Value = "987654";
                value2.Type = OutlineValueType.Number;
                code2.Values.Add(value2);

                // Add outline code to project
                project.OutlineCodes.Add(code2);

                // Save project as MPP
                project.Save(dataDir + "Updated_project_out.mpp", SaveFileFormat.MPP);
                // ExEnd:UpdateOutlineCodes
            }
            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.");
            }         
        }
예제 #9
0
        public void WorkWithOutlineValueCollection()
        {
            // ExStart
            // ExFor: OutlineValueCollection
            // ExFor: OutlineValueCollection.Add(OutlineValue)
            // ExFor: OutlineValueCollection.Clear
            // ExFor: OutlineValueCollection.Contains(OutlineValue)
            // ExFor: OutlineValueCollection.CopyTo(OutlineValue[],Int32)
            // ExFor: OutlineValueCollection.Count
            // ExFor: OutlineValueCollection.GetEnumerator
            // ExFor: OutlineValueCollection.IndexOf(OutlineValue)
            // ExFor: OutlineValueCollection.Insert(Int32,OutlineValue)
            // ExFor: OutlineValueCollection.IsReadOnly
            // ExFor: OutlineValueCollection.Item(Int32)
            // ExFor: OutlineValueCollection.Remove(OutlineValue)
            // ExFor: OutlineValueCollection.RemoveAt(Int32)
            // ExSummary: Shows how to work with outline value collections.
            var project = new Project(DataDir + "OutlineValues2010.mpp");

            // clear value collections
            foreach (var outlineCode in project.OutlineCodes)
            {
                // clear outline masks
                if (outlineCode.Values.Count <= 0)
                {
                    continue;
                }

                if (!outlineCode.Values.IsReadOnly)
                {
                    outlineCode.Values.Clear();
                }
            }

            var codeDefinition = new OutlineCodeDefinition
            {
                Alias = "New task outline code1", FieldId = ((int)ExtendedAttributeTask.OutlineCode1).ToString(), FieldName = "Outline Code1"
            };
            var value = new OutlineValue {
                Description = "Value description", ValueId = 1, Value = "123456", Type = OutlineValueType.Number
            };

            codeDefinition.Values.Add(value);
            project.OutlineCodes.Add(codeDefinition);

            // update value by index access
            codeDefinition.Values[0].Value = "654321";

            // iterate over outline values
            foreach (var definitionValue in codeDefinition.Values)
            {
                Console.WriteLine("Value: " + definitionValue.Value);
                Console.WriteLine("Value Id: " + definitionValue.ValueId);
                Console.WriteLine("Value Guid: " + definitionValue.ValueGuid);
                Console.WriteLine();
            }

            // ...
            // work with outline values
            // ...

            // remove a value when needed
            if (codeDefinition.Values.Contains(value))
            {
                codeDefinition.Values.Remove(value);
            }

            // insert a value in the start position
            codeDefinition.Values.Insert(0, value);

            // check the position of inserted value
            Console.WriteLine("Index of inserted value: " + codeDefinition.Values.IndexOf(value));

            // ...
            // work with outline values
            // ...

            // remove the last value from the collection
            codeDefinition.Values.RemoveAt(codeDefinition.Values.Count - 1);

            // one can create the another outline code definition
            var codeDefinition2 = new OutlineCodeDefinition
            {
                Alias = "New outline code 2", FieldId = ((int)ExtendedAttributeTask.OutlineCode2).ToString(), FieldName = "Outline Code2"
            };

            // and then copy outline values
            var outlineValues = new OutlineValue[codeDefinition.Values.Count];

            codeDefinition.Values.CopyTo(outlineValues, 0);

            foreach (var outlineValue in outlineValues)
            {
                codeDefinition2.Values.Add(outlineValue);
            }

            // ExEnd
        }