示例#1
0
        public SelectStory(SharpCloudApi client, bool allowMultiSelect = true, string username = "")
        {
            InitializeComponent();

            _viewModel = DataContext as SelectedStoryViewModel;
            _client = client;

            storiesCvs = this.FindResource("storiesCvs") as CollectionViewSource;
            storiesCvs.Source = _viewModel.AllStories;
            teamsCvs = this.FindResource("teamsCvs") as CollectionViewSource;
            teamsCvs.Source = _viewModel.AllTeams;

            if (_client == null)
                loginGrid.Visibility = Visibility.Visible;
            else
            {
                loginGrid.Visibility = Visibility.Collapsed;
            }

            Loaded += new RoutedEventHandler(SelectRoadmap_Loaded);

            SelectedIDs = new List<string>();
            SelectedStoryLites = new List<StoryLite>();
            _allowMultiSelect = allowMultiSelect;
            _userName = username.ToLower();
        }
示例#2
0
        public SelectTeam(SharpCloudApi client)
        {
            InitializeComponent();

            _viewModel = DataContext as SelectedStoryViewModel;
            _client = client;

            teamsCvs = this.FindResource("teamsCvs") as CollectionViewSource;
            teamsCvs.Source = _viewModel.AllTeams;

            Loaded += new RoutedEventHandler(SelectRoadmap_Loaded);

            SelectedTeam = null;
        }
示例#3
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();
        }
示例#4
0
        private void logIn_Click(object sender, RoutedEventArgs e)
        {
            var username = this.username.Text;
            var password = this.password.Password;
            string baseUri = this.loginUrl.Text;
            // create a connection with valid creds
            if (username != "" || password != "")
            {
                try
                {
                    _client = new SC.API.ComInterop.SharpCloudApi(username, password, baseUri);

                    LoadTeams();
                }
                catch (Exception e1)
                { }

            }
        }
示例#5
0
        public bool ConnectAndProcessCube()
        {
            try
            {

            using (AdomdConnection cubeConnection = new AdomdConnection(_configDetails.ConnectionString))
            {
                cubeConnection.Open();

                using (AdomdCommand cmd = new AdomdCommand(_configDetails.MDXQuery, cubeConnection))
                {
                    Console.WriteLine("Connected to the cube");

                    DataSet ds = new DataSet();
                    ds.EnforceConstraints = false;
                    ds.Tables.Add();
                    DataTable dt = ds.Tables[0];
                    dt.Load(cmd.ExecuteReader());

                    Console.WriteLine(string.Format("Data loaded from cube: {0} rows", dt.Rows.Count));

                    //we have the data table, now find the index of the fields we want
                    _configDetails.FindDataTableIndexesForAllColumns(dt.Columns);

                    int rowCount = dt.Rows.Count;
                    int colCount = _configDetails.SharpCloudAttributes.Count;

                    //arrayValues is the array that we pass to the SharpCloud Lib dll in order to update the story
                    string[,] arrayValues = new string[rowCount + 1, colCount];

                    //the first row must be the column headings, eg:
                    //arrayValues[0, 0] = "ExternalID";
                    //arrayValues[0, 1] = "Name";

                    for (int i = 0; i < _configDetails.SharpCloudAttributes.Count; i++)
                    {
                        if (_configDetails.SharpCloudAttributes[i].SharpCloudAttributeName.ToUpper() == "NAME" ||
                            _configDetails.SharpCloudAttributes[i].SharpCloudAttributeName.ToUpper() == "CATEGORY" ||
                            _configDetails.SharpCloudAttributes[i].SharpCloudAttributeName.ToUpper() == "EXTERNALID" ||
                            _configDetails.SharpCloudAttributes[i].SharpCloudAttributeName.ToUpper() == "EXTERNAL ID")
                        {
                            //built in column, don't change
                            arrayValues[0, i] = _configDetails.SharpCloudAttributes[i].SharpCloudAttributeName;
                        }
                        else if (_configDetails.SharpCloudAttributes[i].AttributeDataType.ToUpper() == "LIST")
                        {
                            arrayValues[0, i] = string.Format("L__{0}", _configDetails.SharpCloudAttributes[i].SharpCloudAttributeName);
                        }
                        else if (_configDetails.SharpCloudAttributes[i].AttributeDataType.ToUpper() == "NUMERIC")
                        {
                            arrayValues[0, i] = string.Format("N__{0}", _configDetails.SharpCloudAttributes[i].SharpCloudAttributeName);
                        }
                        else if (_configDetails.SharpCloudAttributes[i].AttributeDataType.ToUpper() == "DATE")
                        {
                            arrayValues[0, i] = string.Format("D__{0}", _configDetails.SharpCloudAttributes[i].SharpCloudAttributeName);
                        }
                        else if (_configDetails.SharpCloudAttributes[i].AttributeDataType.ToUpper() == "TEXT")
                        {
                            arrayValues[0, i] = string.Format("T__{0}",_configDetails.SharpCloudAttributes[i].SharpCloudAttributeName);
                        }
                        else
                        {
                            arrayValues[0, i] = _configDetails.SharpCloudAttributes[i].SharpCloudAttributeName;
                        }
                        _configDetails.SharpCloudAttributes[i].ArrayColumnIndex = i;
                    }

                    for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
                    {
                        DataRow dataRow = dt.Rows[rowIndex];

                        for (int attIndex = 0; attIndex < _configDetails.SharpCloudAttributes.Count; attIndex++)
                        {
                            SharpCloudAttribute sharpCloudAttribute = _configDetails.SharpCloudAttributes[attIndex];
                            string cubeValueString = dataRow.ItemArray[sharpCloudAttribute.CubeTableMappingIndex].ToString();
                            if (sharpCloudAttribute.AttributeDataType == "NUMERIC")
                            {
                                double numericValue;
                                if (double.TryParse(cubeValueString, out numericValue))
                                {
                                    arrayValues[rowIndex + 1, sharpCloudAttribute.ArrayColumnIndex] = numericValue.ToString();
                                }
                                else
                                {
                                    arrayValues[rowIndex + 1, sharpCloudAttribute.ArrayColumnIndex] = "(null)";
                                }
                            }
                            else
                            {
                                //must be a string
                                arrayValues[rowIndex + 1, sharpCloudAttribute.ArrayColumnIndex] = cubeValueString;
                            }
                        }

                    }

                    string errorMessage;

                    Console.WriteLine(string.Format("Connecting to SharpCloud"));

                    var client = new SharpCloudApi(_configDetails.SharpCloudUserName, _configDetails.SharpCloudPassword, _configDetails.SharpCloudURL);
                    Story rm = client.LoadStory(_configDetails.SharpCloudStoryID);
                    Console.WriteLine(string.Format("Loaded story from SharpCloud, now updating"));
                    if (rm.UpdateStoryWithArray(arrayValues, _configDetails.DeleteMissingItems, out errorMessage))
                    {
                        rm.Save();
                        Console.WriteLine("***Update Complete***");
                        Console.WriteLine("");
                        Console.WriteLine("Press any key to close this window");
                        Console.ReadLine();
                    }
                    else
                    {
                        Console.WriteLine("Error updating story: " + errorMessage);
                        Console.WriteLine("");
                        Console.WriteLine("Press any key to close this window");
                        Console.ReadLine();
                    }

                }

            };
            return true;

            }
            catch (Exception ex)
            {

                Console.WriteLine("Error: " + ex.Message);
                Console.WriteLine("");
                Console.WriteLine("Press any key to close this window");
                Console.ReadLine();
                return false;
            }
        }