Exemplo n.º 1
0
 static void addAttribute(Story story, string[] attr)
 {
     foreach (var att in attr)
     {
         string[] split = att.Split('|');
         var      name  = split[0];
         var      type  = split[1];
         if (story.Attribute_FindByName(name) == null)
         {
             if (type == "Text")
             {
                 story.Attribute_Add(name, SC.API.ComInterop.Models.Attribute.AttributeType.Text);
             }
             else if (type == "Numeric")
             {
                 story.Attribute_Add(name, SC.API.ComInterop.Models.Attribute.AttributeType.Numeric);
             }
             else if (type == "List")
             {
                 story.Attribute_Add(name, SC.API.ComInterop.Models.Attribute.AttributeType.List);
             }
             else if (type == "Date")
             {
                 story.Attribute_Add(name, SC.API.ComInterop.Models.Attribute.AttributeType.Date);
             }
         }
     }
 }
Exemplo n.º 2
0
        private static void LoadPanelData(Item item, Story story, string category, string[] attributes, double[] widths)
        {
            if (attributes.Length+2 != widths.Length)
            {
                throw new Exception("attributes and widths must match");
            }

            var sortby = story.Attribute_FindByName("SortOrder");
            
            // add attributes so it won't blow up below
            foreach (var attribute in attributes)
            {
                if (story.Attribute_FindByName(attribute) == null)
                    story.Attribute_Add(attribute, Attribute.AttributeType.List);
            }

            var table1 = new HTMLTable(attributes.Length + 2);
            int col = 0;
            table1.SetValue(0, col++, "#");
            table1.SetValue(0, col++, "Name");
            foreach (var attribute in attributes)
            {
                table1.SetValue(0, col++, attribute);
            }

            int row = 1;
            foreach (var item2 in story.Items.OrderBy(i => i.GetAttributeValueAsDouble(sortby)))
            {
                if (item2.Category.Name == category)
                {
                    col = 0;
                    table1.SetValue(row, col++, item2.GetAttributeValueAsDouble(sortby).ToString());
                    table1.SetValue(row, col++, item2.Name);
                    foreach (var attribute in attributes)
                    {
                        //Debug.WriteLine($"Attrubute = '{attribute}'");
                        var att = story.Attribute_FindByName(attribute);
                        //Debug.WriteLine($"Attrubute.Name = '{att.Name}'");
                        var text = item2.GetAttributeValueAsTextWithPrefixAndSuffix(att);
                        //Debug.WriteLine($"Text = '{text}'");
                        string color = item2.GetAttributeValueAsColorText(att);
                        table1.SetValue(row, col++, text, color);
                    }
                    row++;
                }
            }

            // set the col width
            for (int c=0;c<widths.Length; c++)
            {
                table1.SetColWidth(c, widths[c]);
            }

            var panel = item.Panel_FindByTitle(category);
            if (panel == null)
                panel = item.Panel_Add(category, Panel.PanelType.RichText);
            panel.Data = table1.GetHTML;

        }
Exemplo n.º 3
0
 private static Attribute EnsureAttributeExists(Attribute attrib, Story destination)
 {
     var attDest = destination.Attribute_FindByName(attrib.Name);
     if (attDest == null)
     {
         attDest = destination.Attribute_Add(attrib.Name, attrib.Type);
         foreach (var lab in attrib.Labels)
         {
             attDest.Labels_Add(lab.Text, lab.Color);
         }
     }
     return attDest;
 }
Exemplo n.º 4
0
 public static void EnsureStoryHasRightStructure(Story story, Logger log)
 {
     // make sure all categories we need exist
     foreach (var c in _categoryNames)
     {
         if (story.Category_FindByName(c) == null) // catagory does not exist
         {
             log.Log($"Adding Category '{c}'");
             story.Category_AddNew(c);
         }
     }
     // make sure all attributes we need exist
     foreach (var a in _textFields)
     {
         if (story.Attribute_FindByName(a) == null)
         {
             log.Log($"Adding Text Attribute '{a}'");
             story.Attribute_Add(a, Attribute.AttributeType.Text);
         }
     }
     foreach (var a in _dateFields)
     {
         if (story.Attribute_FindByName(a) == null)
         {
             log.Log($"Adding Date Attribute '{a}'");
             story.Attribute_Add(a, Attribute.AttributeType.Date);
         }
     }
     foreach (var a in _numberFields)
     {
         if (story.Attribute_FindByName(a) == null)
         {
             log.Log($"Adding Number Attribute '{a}'");
             story.Attribute_Add(a, Attribute.AttributeType.Numeric);
         }
     }
     foreach (var a in _listFields)
     {
         if (story.Attribute_FindByName(a) == null)
         {
             log.Log($"Adding List Attribute '{a}'");
             story.Attribute_Add(a, Attribute.AttributeType.List);
         }
     }
     // reserved list attributes need VL,L,M,H,VH values
     foreach (var a in _listRiskFields)
     {
         if (story.Attribute_FindByName(a) == null)
         {
             log.Log($"Adding List Attribute '{a}'");
             var att = story.Attribute_Add(a, Attribute.AttributeType.List);
             foreach (var l in _riskLabels)
             {
                 log.Log($"Adding List Label '{l}'");
                 att.Labels_Add(l);
             }
         }
     }
 }
Exemplo n.º 5
0
        private void update_Click(object sender, RoutedEventArgs e)
        {
            backgroundWorker1.RunWorkerAsync();
            var progBar = sharpProgress;

            update.IsEnabled = false;
            var teamText  = Team.Text;
            var storyText = Story.Text;
            var userText  = Username.Text;

            sc = new SharpCloudApi(userText, Password.Password.ToString());
            try
            {
                Console.WriteLine(sc.Stories());
            }
            catch
            {
                MessageBox.Show("Invalid Username or Password");
                update.IsEnabled = true;
                return;
            }
            StoryLite[] teamBook = new StoryLite[30];
            try
            {
                teamBook = sc.StoriesTeam(teamText);
            }
            catch
            {
                MessageBox.Show("Invalid Team");
                update.IsEnabled = true;
                return;
            }
            Story dashStory = null;

            try
            {
                dashStory = sc.LoadStory(storyText);
            }
            catch
            {
                MessageBox.Show("Invalid Story");
                update.IsEnabled = true;
                return;
            }
            sharpProgress.Maximum = teamBook.Length - 1;
            sharpProgress.Value   = 0;
            sharpProgress.Minimum = 1;

            // Adds new attributes if story does not have it
            if (dashStory.Attribute_FindByName("Appropriated Budget") == null)
            {
                dashStory.Attribute_Add("Appropriated Budget", SC.API.ComInterop.Models.Attribute.AttributeType.Numeric);
            }
            if (dashStory.Attribute_FindByName("RAG Status") == null)
            {
                dashStory.Attribute_Add("RAG Status", SC.API.ComInterop.Models.Attribute.AttributeType.List);
            }
            if (dashStory.Attribute_FindByName("New Requested Budget") == null)
            {
                dashStory.Attribute_Add("New Requested Budget", SC.API.ComInterop.Models.Attribute.AttributeType.Numeric);
            }
            if (dashStory.Attribute_FindByName("Project Business Value") == null)
            {
                dashStory.Attribute_Add("Project Business Value", SC.API.ComInterop.Models.Attribute.AttributeType.Text);
            }
            if (dashStory.Attribute_FindByName("Project Dependencies/Assumptions/Risks") == null)
            {
                dashStory.Attribute_Add("Project Dependencies/Assumptions/Risks", SC.API.ComInterop.Models.Attribute.AttributeType.Text);
            }
            if (dashStory.Attribute_FindByName("Total Spent to Date") == null)
            {
                dashStory.Attribute_Add("Total Spent to Date", SC.API.ComInterop.Models.Attribute.AttributeType.Numeric);
            }
            Story tagStory = sc.LoadStory(teamBook[0].Id);

            // Add tags to new story
            foreach (var tag in tagStory.ItemTags)
            {
                if (dashStory.ItemTag_FindByName(tag.Name) == null)
                {
                    dashStory.ItemTag_AddNew(tag.Name, tag.Description, tag.Group);
                }
            }
            MessageBox.Show("Updating");
            sharpProgress.Value++;
            foreach (StoryLite storyTeam in teamBook)
            {
                Story story = sc.LoadStory(storyTeam.Id);
                highCost(dashStory, story);
                sharpProgress.Value++;
            }
            dashStory.Save();
            MessageBox.Show("Done");
            update.IsEnabled = true;
        }