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 }
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 }
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."); } }
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."); } }
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 }
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 void WorkWithOutlineMaskCollection() { // ExStart // ExFor: OutlineMaskCollection // ExFor: OutlineMaskCollection.Add(OutlineMask) // ExFor: OutlineMaskCollection.Clear // ExFor: OutlineMaskCollection.Contains(OutlineMask) // ExFor: OutlineMaskCollection.CopyTo(OutlineMask[],Int32) // ExFor: OutlineMaskCollection.Count // ExFor: OutlineMaskCollection.GetEnumerator // ExFor: OutlineMaskCollection.IndexOf(OutlineMask) // ExFor: OutlineMaskCollection.Insert(Int32,OutlineMask) // ExFor: OutlineMaskCollection.IsReadOnly // ExFor: OutlineMaskCollection.Item(Int32) // ExFor: OutlineMaskCollection.Remove(OutlineMask) // ExFor: OutlineMaskCollection.RemoveAt(Int32) // ExFor: MaskType // ExSummary: Shows how to work with outline mask collections. var project = new Project(DataDir + "OutlineValues2010.mpp"); var outline = project.OutlineCodes[0]; // clear outline masks if (outline.Masks.Count > 0) { if (!outline.Masks.IsReadOnly) { outline.Masks.Clear(); } } var mask = new OutlineMask(); mask.Type = MaskType.Characters; var maskWrong = new OutlineMask(); maskWrong.Type = MaskType.Null; outline.Masks.Add(mask); // insert a wrong mask outline.Masks.Insert(0, maskWrong); // edit the mask by using index access of collection var idx = outline.Masks.IndexOf(mask); outline.Masks[idx].Length = 2; // remove a wrong mask by index var idxOfWrong = outline.Masks.IndexOf(maskWrong); outline.Masks.RemoveAt(idxOfWrong); // iterate over masks foreach (var outlineMask in outline.Masks) { Console.WriteLine("Length: " + outlineMask.Length); Console.WriteLine("Level: " + outlineMask.Level); Console.WriteLine("Separator: " + outlineMask.Separator); Console.WriteLine("Type: " + outlineMask.Type); } var otherProject = new Project(DataDir + "OutlineValues2010.mpp"); var otherOutline = otherProject.OutlineCodes[0]; var masks = new OutlineMask[outline.Masks.Count]; outline.Masks.CopyTo(masks, 0); foreach (var maskToAdd in masks) { if (!otherOutline.Masks.Contains(maskToAdd)) { otherOutline.Masks.Add(maskToAdd); } } // ExEnd }