示例#1
0
        private void Team_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Border grid = sender as Border;

            if (grid == null)
            {
                return;
            }
            var item = grid.DataContext as SC.API.ComInterop.Models.Team;

            try
            {
                _viewModel.AllStories.Clear();
                var tStories = _client.StoriesTeam(item.Id);

                this.userStoriesContainer.Visibility = Visibility.Visible;
                foreach (SC.API.ComInterop.Models.StoryLite a in tStories)
                {
                    _viewModel.AllStories.Add(a);
                }

                //this.userStories.ItemsSource = tStories;
                //this.userStories.Items.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
            }
            catch (Exception e1)
            { }
        }
示例#2
0
        private void Team_MouseUp(object sender, MouseButtonEventArgs e)
        {
            Border grid = sender as Border;

            if (grid == null)
            {
                return;
            }
            var item = grid.DataContext as Team;

            try
            {
                _viewModel.AllStories.Clear();
                var tStories = _client.StoriesTeam(item.Id);

                this.userStoriesContainer.Visibility = Visibility.Visible;
                foreach (StoryLite a in tStories)
                {
                    _viewModel.AllStories.Add(a);
                }
            }
            catch (Exception)
            {
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            // Get info from config file
            var team   = ConfigurationManager.AppSettings["team"];
            var userid = ConfigurationManager.AppSettings["user"];
            var passwd = ConfigurationManager.AppSettings["pass"];
            var sheet  = ConfigurationManager.AppSettings["sheet"];
            // Login and get story data from Sharpcloud
            var    sc       = new SharpCloudApi(userid, passwd);
            var    teamBook = sc.StoriesTeam(team);
            string fileName = System.IO.Directory.GetParent
                                  (System.IO.Directory.GetParent(Environment.CurrentDirectory).ToString()).ToString() + "\\" + sheet + ".xlsx";

            // Load data from excel
            using (ExcelPackage xlPackage = new ExcelPackage(new FileInfo(fileName)))
            {
                // Generate data from worksheets
                var itemSheet   = xlPackage.Workbook.Worksheets.First();
                var itemRows    = itemSheet.Dimension.End.Row;
                var itemColumns = itemSheet.Dimension.End.Column;
                // Creating the objects to be used in the threads
                // add attribute to story

                foreach (var book in teamBook)
                {
                    var story = sc.LoadStory(book.Id);
                    Console.WriteLine("Adding tags to " + story.Name);
                    for (var k = 2; k < itemRows; k++)
                    {
                        if (story.ItemTag_FindByName(itemSheet.Cells[k, 1].Value.ToString()) == null)
                        {
                            story.ItemTag_AddNew(itemSheet.Cells[k, 1].Value.ToString(), " ", itemSheet.Cells[k, 3].Value.ToString());
                        }
                    }
                    story.Save();
                }
            }
        }
示例#4
0
        public static async void ProcessBowTies(SharpCloudApi sc, string teamId, string portfolioId, string controlId, string temaplateId, Logger log)
        {
            // combine all bowtie stories 
            log.Log($"Reading Portfolio Story");
            await Task.Delay(100);
            var portfolioStory = sc.LoadStory(portfolioId);
            var attSubCat = portfolioStory.Attribute_FindByName("Risk Sub Category") ??
                               portfolioStory.Attribute_Add("Risk Sub Category", Attribute.AttributeType.List);


            log.Log($"Reading Control Story");
            await Task.Delay(100);
            var controlsStory = sc.LoadStory(controlId);

            // make sure risk count exists
            var _riskCount = "RiskCount";
            var attRiskCountControlStory = controlsStory.Attribute_FindByName(_riskCount) ??
                               controlsStory.Attribute_Add(_riskCount, Attribute.AttributeType.Numeric);
            var attOverallControlRatingControlStory = controlsStory.Attribute_FindByName(_attrControlRating) ??
                   controlsStory.Attribute_Add(_attrControlRating, Attribute.AttributeType.List);
            var attManagedControlStory = controlsStory.Attribute_FindByName(_attrControlOpinion) ??
                   controlsStory.Attribute_Add(_attrControlOpinion, Attribute.AttributeType.List);
            var attRiskLevelControlStory = controlsStory.Attribute_FindByName(_attrRiskLevel) ??
                   controlsStory.Attribute_Add(_attrRiskLevel, Attribute.AttributeType.List);
            var attBasisOfOpinionControlStory = controlsStory.Attribute_FindByName(_attrBasisOfOpinion) ??
                   controlsStory.Attribute_Add(_attrBasisOfOpinion, Attribute.AttributeType.List);
            var attKeyScorecardAreaControlStory = controlsStory.Attribute_FindByName(_attrImpactedArea) ??
                               controlsStory.Attribute_Add(_attrImpactedArea, Attribute.AttributeType.List);
            var attDirectorateControlStory = controlsStory.Attribute_FindByName(_attrDirectorate) ??
                               controlsStory.Attribute_Add(_attrDirectorate, Attribute.AttributeType.List);
            var attControlOwnerControlStory = controlsStory.Attribute_FindByName(_attrControlOwner) ??
                               controlsStory.Attribute_Add(_attrControlOwner, Attribute.AttributeType.List);


            /* Don't remove
            attOverallControlRating.Labels_Delete(_multipleValues); // always removed
            attManaged.Labels_Delete(_multipleValues); // always removed
            */

            // remove control ratings for existing controls

            foreach (var itm in controlsStory.Items)
            {
                itm.RemoveAttributeValue(attManagedControlStory);
                itm.RemoveAttributeValue(attOverallControlRatingControlStory);
                itm.RemoveAttributeValue(attRiskLevelControlStory);
                itm.RemoveAttributeValue(attBasisOfOpinionControlStory);
                itm.RemoveAttributeValue(attKeyScorecardAreaControlStory);
                itm.RemoveAttributeValue(attDirectorateControlStory);
                itm.RemoveAttributeValue(attControlOwnerControlStory);

                itm.SetAttributeValue(attRiskCountControlStory, 0);

                // delete all resources - we will add new ones back in later
                var list = new List<string>();
                foreach (var res in itm.Resources)
                {
                    if (res.Description == _strRiskControlInstance || res.Description == _strRiskRelatedStory)
                        list.Add(res.Id);
                }
                foreach(var id in list)
                    itm.Resource_DeleteById(id);
            }



            foreach (var teamStory in sc.StoriesTeam(teamId))
            {
                if (teamStory.Id != portfolioId && teamStory.Id != temaplateId && teamStory.Id != controlId)// && teamStory.Id == "aad81010-af26-4ba2-954a-420383fb6d1f")
                {
                    log.Log($"Reading from '{teamStory.Name}'");
                    await Task.Delay(100);

                    
                    try
                    {
                        var story = sc.LoadStory(teamStory.Id);
                        var riskItemSource = story.Item_FindByExternalId("RISK");

                        if (riskItemSource != null)
                        {
                            var riskItem = portfolioStory.Item_FindByExternalId(story.Id) ??
                               portfolioStory.Item_AddNew(riskItemSource.Name, false);

                            riskItem.Name = riskItemSource.Name;
                            riskItem.Description = riskItemSource.Description;
                            riskItem.ExternalId = story.Id;

                            var attDirectorate = story.Attribute_FindByName(_attrDirectorate);
                            var riskCategoryName = riskItemSource.GetAttributeValueAsText(attDirectorate);

                            string catName, subCatName;
                            var split = riskCategoryName.Split('.');
                            if (split.Count() == 1)
                            {
                                catName = split[0];
                                subCatName = "";
                            }
                            else // maybe multiple sub cats
                            {
                                catName = split[0];
                                subCatName = riskCategoryName.Substring(catName.Length+1);
                            }

                            var riskCategory = portfolioStory.Category_FindByName(catName) ??
                                               portfolioStory.Category_AddNew(catName);
                            riskItem.Category = riskCategory;

                            riskItem.SetAttributeValue(attSubCat, subCatName); // set the sub category attribute
                            // TODO Set the real sub category when the SDK supports this.

                            // copy and assigned risk tags
                            foreach (var t in riskItemSource.Tags)
                                riskItem.Tag_AddNew(t.Text);


                            var res = riskItem.Resource_FindByName(teamStory.Name) ?? riskItem.Resource_AddName(teamStory.Name);
                            res.Description = story.Description;
                            res.Url = new Uri(story.Url);

                            LoadPanelData(riskItem, story, _cause, _listCauses, _widthCauses);
                            LoadPanelData(riskItem, story, _causeControls, _listCausesControls, _widthCausesControls);
                            LoadPanelData(riskItem, story, _causeControlActions, _listCausesActions, _widthCausesActions);
                            LoadPanelData(riskItem, story, _consequence, _listConsequenses, _widthConsequenses);
                            LoadPanelData(riskItem, story, _consequenceControls, _listConsequensesControls, _widthConsequensesControls);
                            LoadPanelData(riskItem, story, _consequenceActions, _listConsequensesActions, _widthConsequensesActions);
                            LoadPanelData(riskItem, story, _ewi, _listEWI, _widthEWI);

                            if (riskItemSource != null)
                                CopyAllAttributeValues(riskItemSource, riskItem);
                            else
                                log.LogError($"Could not find a risk item in {teamStory.Name}");


                            // do the controls
                            var attManagedControlsRiskStory = story.Attribute_FindByName(_attrControlOpinion) ??
                                                       story.Attribute_Add(_attrControlOpinion, Attribute.AttributeType.List);

                            var attRiskLevelControlsRiskStory = story.Attribute_FindByName(_attrRiskLevel) ??
                                                       story.Attribute_Add(_attrRiskLevel, Attribute.AttributeType.List);

                            var attOverallControlRatingControlsRiskStory = story.Attribute_FindByName(_attrControlRating) ??
                                                       story.Attribute_Add(_attrControlRating, Attribute.AttributeType.List);

                            var attBasisOfOpinionRiskStory = story.Attribute_FindByName(_attrBasisOfOpinion) ??
                                                       story.Attribute_Add(_attrBasisOfOpinion, Attribute.AttributeType.List);

                            var attScorecardAreaRiskStory = story.Attribute_FindByName(_attrImpactedArea) ??
                                                       story.Attribute_Add(_attrImpactedArea, Attribute.AttributeType.List);

                            var attControlOwnerRiskStory = story.Attribute_FindByName(_attrControlOwner) ??
                                                       story.Attribute_Add(_attrControlOwner, Attribute.AttributeType.List);


                            foreach (var itemControlSource in story.Items.Where( i =>
                                            (i.Category.Name == _causeControls ||
                                             i.Category.Name == _consequenceControls)))
                            {
                                var itemControlDestination = controlsStory.Item_FindByName(itemControlSource.Name) ??
                                            controlsStory.Item_AddNew(itemControlSource.Name);

                                itemControlDestination.Description = itemControlSource.Description;

                                itemControlDestination.Tag_AddNew(itemControlSource.Category.Name);
                                // add any tags
                                foreach (var t in itemControlSource.Tags)
                                {
                                    itemControlDestination.Tag_AddNew(t.Text);
                                }

                                var resC = itemControlDestination.Resource_FindByUrl(itemControlSource.Url);
                                if (resC == null)
                                    resC = itemControlDestination.Resource_AddName(itemControlSource.Id); // need to be unique
                                resC.Name = "Usage of this control";
                                resC.Description = $"Control used in '{story.Name}'";//"Instance of This Control";
                                resC.Url = new Uri(itemControlSource.Url);

                                var resCC = itemControlSource.Resource_FindByUrl(itemControlDestination.Url);
                                if (resCC == null)
                                    resCC = itemControlSource.Resource_AddName(itemControlDestination.Id); // need to be unique
                                resCC.Name = "Control Library";
                                resCC.Description = "View this control in Control library";
                                resCC.Url = new Uri(itemControlDestination.Url);


                                // risk control
                                AddAttributeButCheckForDiffernce(itemControlSource, attManagedControlsRiskStory, itemControlDestination, attManagedControlStory);
                                // overall risk rating
                                AddAttributeButCheckForDiffernce(riskItemSource, attOverallControlRatingControlsRiskStory, itemControlDestination, attOverallControlRatingControlStory);
                                // overall risk Level
                                AddAttributeButCheckForDiffernce(riskItemSource, attRiskLevelControlsRiskStory, itemControlDestination, attRiskLevelControlStory);
                                // add risk basis of opinion
                                AddAttributeButCheckForDiffernce(itemControlSource, attBasisOfOpinionRiskStory, itemControlDestination, attBasisOfOpinionControlStory);
                                // add risk group (category)
                                AddAttributeButCheckForDiffernce(riskItemSource, attScorecardAreaRiskStory, itemControlDestination, attKeyScorecardAreaControlStory);
                                // add risk directorate
                                AddAttributeButCheckForDiffernce(riskItemSource, attDirectorate, itemControlDestination, attDirectorateControlStory);
                                // add risk directorate
                                AddAttributeButCheckForDiffernce(itemControlSource, attControlOwnerRiskStory, itemControlDestination, attControlOwnerControlStory);

                            }
                            story.Save();// save resourc links
                        }
                        else
                        {
                            log.LogError($"Could not find a risk item in {teamStory.Name}");
                        }

                    }
                    catch (Exception e)
                    {
                        log.LogError(e.Message);
                    }
                }
            }

            // process control item resource panels
            foreach (var itm in controlsStory.Items)
            {
                // delete all resources - we will add new ones back in later
                var listR = new List<string>();
                var listC = new List<string>();
                foreach (var res in itm.Resources)
                {
                    if (res.Description == _strRiskControlInstance)
                        listC.Add(res.Id);
                    if (res.Description == _strRiskRelatedStory)
                        listR.Add(res.Id);
                }
            }
 
            log.Log($"Saving {portfolioStory.Name}");
            portfolioStory.Save();
            log.Log($"Saving {controlsStory.Name}");
            controlsStory.Save();
            await Task.Delay(1000);

            log.HideProgress();
        }
        private async void DoIt()
        {
            try
            {
                button.IsEnabled = false;

                var teamId     = team.Text;     // "amrcrustydemo";
                var templateID = template.Text; // "f17c88ef-409a-4a2e-ab01-65b0ac93b371";

                _sc = new SharpCloudApi(username.Text, password.Password, url.Text);

                Status.Text = "";

                await SetText("Reading template...");

                var templateStory = _sc.LoadStory(templateID);

                await SetText($"Template '{templateStory.Name}' Loaded.");

                _tags = new Dictionary <string, ItemTag>();
                // check the story tags exist in the template
                StoryLite[] teamstories;
                if (cbDirectory.IsChecked == false)
                {
                    teamstories = _sc.StoriesTeam(teamId);
                }
                else
                {
                    teamstories = _sc.StoriesDirectory(teamId);
                }

                if (teamstories == null)
                {
                    if (cbDirectory.IsChecked == false)
                    {
                        await SetText($"Oops... Looks like your team does not exist");
                    }
                    else
                    {
                        await SetText($"Oops... Looks like your directory does not exist");
                    }

                    await SetText($"Aborting process");

                    goto End;
                }

                foreach (var ts in teamstories)
                {
                    if (ts.Id.ToLower() != templateID.ToLower())
                    {
                        var tag = templateStory.ItemTag_FindByName(ts.Name);
                        if (tag == null)
                        {
                            await SetText($"Tag '{ts.Name}' created.");

                            tag = templateStory.ItemTag_AddNew(ts.Name, "Created automatically", _tagGroup);
                        }
                        _tags.Add(ts.Id, tag);
                    }
                }
                templateStory.Save();
                await SetText($"'{templateStory.Name}' saved.");


                Story story;

                // remove any existing tags
                if (chkRemoveOldtags.IsChecked == true)
                {
                    await SetText($"Deleting tags");

                    _stories = new Dictionary <string, Story>();
                    _stories.Add(templateStory.Id, templateStory);

                    foreach (var ts in teamstories)
                    {
                        if (ts.Id.ToLower() != templateID.ToLower())
                        {
                            if (!_stories.ContainsKey(ts.Id))
                            {
                                LoadStoryAndCheckPerms(ts.Id, ts.Name);
                            }
                            story = _stories[ts.Id];

                            if (story != null)
                            {
                                foreach (var i in story.Items)
                                {
                                    await RemoveTags(i, _tags);
                                }
                            }
                        }
                    }

                    // save
                    foreach (var s in _stories)
                    {
                        await SetText($"Saving '{s.Value.Name}'");

                        s.Value.Save();
                    }
                    await SetText($"Tags Deletion Complete.");
                }


                _stories = new Dictionary <string, Story>();
                _stories.Add(templateStory.Id, templateStory);

                // asign new tags
                foreach (var ts in teamstories)
                {
                    if (ts.Id.ToLower() != templateID.ToLower())
                    {
                        if (!_stories.ContainsKey(ts.Id))
                        {
                            LoadStoryAndCheckPerms(ts.Id, ts.Name);
                        }
                        story = _stories[ts.Id];

                        foreach (var i in story.Items)
                        {
                            await UpdateItem(i, _tags[story.Id]);
                        }
                    }
                }

                foreach (var s in _stories)
                {
                    if (s.Value != null)
                    {
                        await SetText($"Saving '{s.Value.Name}'");

                        s.Value.Save();
                    }
                }
                await SetText($"Complete.");
            }
            catch (Exception ex)
            {
                await SetText($"There was an error.");
                await SetText($"'{ex.Message}'.");
                await SetText($"'{ex.StackTrace}'.");
            }

End:
            button.IsEnabled = true;
        }
示例#6
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;
        }