예제 #1
0
        public override WidgetResult Configuration()
        {
            var model = new SlackConfigModel();

            try
            {
                var data = GeminiContext.GlobalConfigurationWidgetStore.Get <SlackConfigData>(AppConstants.AppId);
                if (data != null && data.Value != null)
                {
                    model.SlackUrl = data.Value.SlackAPIEndpoint;
                    if (data.Value.ProjectChannels != null && data.Value.ProjectChannels.ContainsKey(0))
                    {
                        model.Channel = data.Value.ProjectChannels[0];
                    }
                    model.SecondsToQueueChanges = data.Value.SecondsToQueueChanges == 0 ? 60 : data.Value.SecondsToQueueChanges;
                }
            } catch
            { }

            var projects = GeminiContext.Projects.GetAll();

            projects.Insert(0, new Project()
            {
                Id = 0, Name = GetResource(Countersoft.Gemini.ResourceKeys.AllProjects)
            });

            model.Projects = new SelectList(projects, "Id", "Name", 0);

            var result = new WidgetResult();

            result.Success = true;
            result.Markup  = new WidgetMarkup("views/Settings.cshtml", model);
            return(result);
        }
예제 #2
0
        public override WidgetResult Show(IssueDto issue = null)
        {
            WidgetResult result = new WidgetResult();

            List <int>    selectedProjects = new List <int>();
            ReportOptions options          = new ReportOptions();

            SummaryModel     model = new SummaryModel();
            IssuesGridFilter tmp   = new IssuesGridFilter();

            try
            {
                if (CurrentCard.IsNew || !CurrentCard.Options.ContainsKey(AppGuid))
                {
                    tmp = new IssuesGridFilter(HttpSessionManager.GetFilter(CurrentCard.Id, CurrentCard.Filter));

                    if (tmp == null)
                    {
                        tmp = CurrentCard.Options[AppGuid].FromJson <IssuesGridFilter>();
                    }

                    if (tmp.Projects == Constants.AllProjectsId.ToString())
                    {
                        selectedProjects.Add(Constants.AllProjectsId);
                    }
                    else
                    {
                        selectedProjects = tmp.GetProjects();
                    }
                }
                else
                {
                    options = CurrentCard.Options[AppGuid].FromJson <ReportOptions>();

                    if (options.AllProjectsSelected)
                    {
                        selectedProjects.Add(Constants.AllProjectsId);
                    }
                    else if (options.ProjectIds.Count > 0)
                    {
                        selectedProjects.AddRange(options.ProjectIds);
                    }
                }
            }
            catch (Exception ex)
            {
                tmp = new IssuesGridFilter(HttpSessionManager.GetFilter(CurrentCard.Id, IssuesFilter.CreateProjectFilter(UserContext.User.Entity.Id, UserContext.Project.Entity.Id)));

                selectedProjects = tmp.GetProjects();
            }

            model.ProjectList = GetProjectFilter(selectedProjects);
            model.Options     = options;

            result.Markup = new WidgetMarkup("views\\Summary.cshtml", model);

            result.Success = true;

            return(result);
        }
예제 #3
0
        public override WidgetResult Show(IssueDto args)
        {
            var result = new WidgetResult();

            result.Success     = true;
            result.Markup.Html = "Slack Integration";
            return(result);
        }
예제 #4
0
        public override WidgetResult Caption(IssueDto issue)
        {
            WidgetResult result = new WidgetResult();

            result.Success     = true;
            result.Markup.Html = "Slack Integration";
            return(result);
        }
예제 #5
0
        public override WidgetResult GetCaption(ItemWidgetArguments args)
        {
            WidgetResult result = new WidgetResult();

            result.Success     = true;
            result.Markup.Html = "Checklist";

            return(result);
        }
예제 #6
0
        public override WidgetResult Caption(Countersoft.Gemini.Commons.Dto.IssueDto issue = null)
        {
            WidgetResult result = new WidgetResult();

            result.Success     = true;
            result.Markup.Html = "Webhooks";

            return(result);
        }
예제 #7
0
        public override WidgetResult GetCaption(ItemWidgetArguments args)
        {
            WidgetResult result = new WidgetResult();

            result.Success = true;
            result.Markup.Html = "Checklist";

            return result;
        }
예제 #8
0
        public override WidgetResult Show(IssueDto args)
        {
            var result = new WidgetResult();

            result.Success = true;

            result.Markup.Html = "Item Created Notifier";

            return(result);
        }
예제 #9
0
        public override WidgetResult Caption(IssueDto issue)
        {
            WidgetResult result = new WidgetResult();

            result.Success = true;

            result.Markup.Html = "Item Created Notifier";

            return(result);
        }
예제 #10
0
        //bool isTfs2012 = true;

        public override WidgetResult Caption(IssueDto issue)
        {
            WidgetResult result = new WidgetResult();

            result.Success = true;

            result.Markup.Html = "TFS Picker";

            return(result);
        }
예제 #11
0
        public override WidgetResult Caption(IssueDto issue = null)
        {
            WidgetResult result = new WidgetResult();

            result.Success = true;

            result.Markup.Html = AppName;

            return(result);
        }
예제 #12
0
        public override WidgetResult Configuration()
        {
            var          data   = GetData();
            WidgetResult result = new WidgetResult();

            result.Markup  = new WidgetMarkup("views/webhooks.cshtml", data.Value);
            result.Success = true;

            return(result);
        }
예제 #13
0
        public override WidgetResult Caption(IssueDto item)
        {
            WidgetResult result = new WidgetResult();

            result.Success = true;

            result.Markup.Html = "Code Review";

            //DebugConstant.DebugModeState = DebugMode;
            return(result);
        }
예제 #14
0
        public override WidgetResult Show(IssueDto issue = null)
        {
            var data = GetData(issue);

            WidgetResult result = new WidgetResult();

            result.Markup = new WidgetMarkup("views\\checklist.cshtml", data);

            result.Success = true;

            return(result);
        }
예제 #15
0
        public override WidgetResult Show(IssueDto issue = null)
        {
            WidgetResult result = new WidgetResult();

            RepeaterModel model = GetRepeatingModel();

            result.Markup = new WidgetMarkup("views\\Repeater.cshtml", model);

            result.Success = true;

            return(result);
        }
예제 #16
0
        public override WidgetResult Configuration()
        {
            var result = new WidgetResult()
            {
                Success = true
            };

            ProjectAdminConfigModel model = GetConfigModel();

            result.Markup = new WidgetMarkup("views/settings.cshtml", model);

            return(result);
        }
        public override WidgetResult Caption(IssueDto item)
        {
            WidgetResult result = new WidgetResult();

            result.Success = true;

            result.Markup.Html = "Lucidchart";

            if (item != null)
            {
                result.Buttons.Add(new AppButton("Add", "add", AppButtonStyle.Default, string.Format("window.location='{0}apps/lucidchart/newdocument/{1}/{2}/{3}'", UserContext.Url, item.Project.Code, item.Project.Id, item.Id)));
            }

            return(result);
        }
예제 #18
0
        public WidgetResult GetCommits(IssueDto args)
        {
            var commits = GeminiContext.CodeCommits.GetAll(args.Id);

            var data = new IssueWidgetData <List <SourceControlContainer> >();

            data.Value = new List <SourceControlContainer>();

            if (commits != null)
            {
                foreach (var commit in commits)
                {
                    var dataHolder = new SourceControlContainer();

                    dataHolder.commits = commit.Data.FromJson <SourceControlCommit>();

                    if (commit.Provider == SourceControlProvider.GitHub)
                    {
                        dataHolder.commits.ExtraData = dataHolder.commits.RepositoryUrl.ReplaceIgnoreCase("https://api.github.com", "https://github.com");
                    }

                    dataHolder.Provider = commit.Provider;

                    dataHolder.Fullname = commit.Fullname;

                    dataHolder.Created = commit.Created.ToLocal(UserContext.User.TimeZone);

                    dataHolder.Comment = commit.Comment;

                    dataHolder.CommitBlock = ParseCommentBlock(commit.Comment, args, dataHolder.commits.RevisionId);

                    data.Value.Add(dataHolder);
                }
            }

            data.IssueId = args.Id;

            WidgetResult result = new WidgetResult();

            result.Markup = new WidgetMarkup("views//index.cshtml", data);

            result.Success = true;

            return(result);
        }
예제 #19
0
        public override WidgetResult Show(IssueDto item)
        {
            WidgetResult result = GetCommits(item);

            if (!_validLicense)
            {
                _validLicense = new Countersoft.Gemini.Infrastructure.LicenseManager().HasValidLicense("F473D13E-19B7-45F3-98ED-6ED77B6BAB0A", true);

                if (!_validLicense)
                {
                    result.Markup = new WidgetMarkup(UnlicensedMessage);

                    result.Success = true;
                }
            }

            return(result);
        }
        public override WidgetResult Configuration()
        {
            var result = new WidgetResult();

            var data = GeminiContext.GlobalConfigurationWidgetStore.Get <string>(AppConstants.AppId);

            if (data == null)
            {
                data = new GlobalConfigurationWidgetData <string>();

                data.Value = string.Empty;
            }

            result.Success = true;

            result.Markup = new WidgetMarkup("views/settings.cshtml", data.Value);

            return(result);
        }
예제 #21
0
        public override WidgetResult Show(IssueDto issue = null)
        {
            WidgetResult result = new WidgetResult();

            IssueWidgetData <string> data = GeminiContext.IssueWidgetStore.Get <string>(issue.Id, AppGuid, AppControlGuid);

            if (data == null || data.Value == null)
            {
                data         = new IssueWidgetData <string>();
                data.Value   = "Default!";
                data.IssueId = issue.Id;

                GeminiContext.IssueWidgetStore.Save(issue.Id, AppGuid, AppControlGuid, data.Value);
            }

            result.Markup  = new WidgetMarkup("views\\my-view.cshtml", data);
            result.Success = true;

            return(result);
        }
예제 #22
0
        public override WidgetResult OnShow(ItemWidgetArguments args)
        {
            WidgetResult result = new WidgetResult();

            IssueWidgetData<string> data = args.GeminiContext.IssueWidgetStore.Get<string>(args.Item.Id, AppId, ControlId);

            if (data == null || data.Value == null)
            {
                data = new IssueWidgetData<string>();
                data.Value = "Default!";
                data.IssueId = args.Item.Id;

                args.GeminiContext.IssueWidgetStore.Save(args.Item.Id, AppId, ControlId, data.Value);
            }

            result.Markup = new WidgetMarkup("views\\my-view.cshtml", data);
            result.Success = true;

            return result;
        }
예제 #23
0
        public override WidgetResult Show(IssueDto issue = null)
        {
            WidgetResult result = new WidgetResult();

            IssueWidgetData<string> data = GeminiContext.IssueWidgetStore.Get<string>(issue.Id, AppGuid, AppControlGuid);

            if (data == null || data.Value == null)
            {
                data = new IssueWidgetData<string>();
                data.Value = "Default!";
                data.IssueId = issue.Id;

                GeminiContext.IssueWidgetStore.Save(issue.Id, AppGuid, AppControlGuid, data.Value);
            }

            result.Markup = new WidgetMarkup("views\\my-view.cshtml", data);
            result.Success = true;

            return result;
        }
예제 #24
0
        public override WidgetResult OnShow(ItemWidgetArguments args)
        {
            WidgetResult result = new WidgetResult();

            IssueWidgetData <string> data = args.GeminiContext.IssueWidgetStore.Get <string>(args.Item.Id, AppId, ControlId);

            if (data == null || data.Value == null)
            {
                data         = new IssueWidgetData <string>();
                data.Value   = "Default!";
                data.IssueId = args.Item.Id;

                args.GeminiContext.IssueWidgetStore.Save(args.Item.Id, AppId, ControlId, data.Value);
            }

            result.Markup  = new WidgetMarkup("views\\my-view.cshtml", data);
            result.Success = true;

            return(result);
        }
예제 #25
0
        public override WidgetResult Configuration()
        {
            var result = new WidgetResult();

            var data = GeminiContext.GlobalConfigurationWidgetStore.Get <List <CreateItemNotifierData> >(AppConstants.AppId);

            var allData = data == null || data.Value == null || data.Value.Count == 0 ? null : data.Value.Find(d => d.ProjectId.GetValueOrDefault() == 0);

            var model = new IssueAlertModel();

            var projects = GeminiContext.Projects.GetAll();

            projects.Insert(0, new Project()
            {
                Id = 0, Name = "All"
            });

            model.Projects = new SelectList(projects, "Id", "Name", 0);

            model.Users = new MultiSelectList(GeminiContext.Users.GetActive(), "Id", "Fullname", allData == null ? null : allData.UserIds);

            var alerts = GeminiApp.Container.Resolve <IAlertTemplates>();

            var templates = alerts.GetAll();

            templates = templates.FindAll(t => t.AlertType == AlertTemplateType.Generic);

            templates.Insert(0, new AlertTemplate()
            {
                AlertType = AlertTemplateType.Generic, Id = 0, Label = "None"
            });

            model.Templates = new SelectList(templates, "Id", "Label", allData == null ? 0 : allData.TemplateId);

            result.Success = true;

            result.Markup = new WidgetMarkup("views/settings.cshtml", model);

            return(result);
        }
        public DataTable GetDrawDownData()
        {
            WidgetResult wr = GetWidgetResult();
            DataTable    dt = new DataTable();

            for (int c = 0; c < wr.names.Length; c++)
            {
                Type t = wr.types[c] == "integer" ? typeof(int) : wr.types[c] == "date" ? typeof(DateTime) : typeof(string);
                dt.Columns.Add(wr.names[c], t);
            }
            for (int r = 0; r < wr.data.Length; r++)
            {
                object[] convertedData = wr.types.Zip(wr.data[r],
                                                      (type, value) => type == "integer" && value == string.Empty ? null : value).ToArray();
                dt.Rows.Add(convertedData);
            }
            DataView dv = dt.DefaultView;

            dv.Sort = "Depth desc";
            DataTable sortedDT = dv.ToTable();

            return(sortedDT);
        }
        public override WidgetResult Show(IssueDto item)
        {
            WidgetResult result = new WidgetResult();

            bool hasData = false;

            IssueWidgetData <List <LucidChartData> > data = GeminiContext.IssueWidgetStore.Get <List <LucidChartData> >(item.Id, Constants.AppId, Constants.ControlId);

            if (data != null && data.Value.Count > 0)
            {
                hasData = true;
            }

            LucidChartModel model = new LucidChartModel {
                IssueId = item.Id.ToString(), AppId = Constants.AppId, ControlId = Constants.ControlId, ProjectId = item.Project.Id.ToString(), ProjectCode = item.Project.Code, HasData = hasData, LucidChartData = data, IsGeminiLicenseFree = GeminiApp.GeminiLicense.IsFree, IsGeminiTrial = GeminiApp.LicenseSummary.IsGeminiTrial(), Url = UserContext.Url.Substring(0, UserContext.Url.Length - 1)
            };

            result.Success = true;

            result.Markup = new WidgetMarkup("views\\LucidChart.cshtml", model);

            return(result);
        }
예제 #28
0
        private void MainTabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (mainMenu.SelectedIndex == 1) // if user switched to router tab
            {
                List <Widget> widgets = Json.ReadJson();
                if (LoginDetailsChanged == true)
                {
                    MainTableLayoutPanel.Controls.Clear();
                    Log.Info("Loading all router information...");
                    routerIPText.Text = ManualIPAddress.Text;

                    List <WidgetResult> listToRun = new List <WidgetResult>(); // list contains all widgets and other elements

                    WidgetResult pid = new WidgetResult
                    {
                        WidgetCommand = "show inventory",
                        UselongTime   = false,
                        WidgetTag     = "PID"
                    };
                    listToRun.Add(pid);

                    WidgetResult showRun = new WidgetResult
                    {
                        WidgetCommand = "show run",
                        UselongTime   = true,
                        WidgetTag     = "showRun"
                    };
                    listToRun.Add(showRun);
                    Log.Info("Loading all widgets / if available");
                    if (widgets == null || widgets.Count == 0)
                    {
                        Log.Info("No widgets were found - adding plus sign");
                        PictureBox addButton = new PictureBox
                        {
                            Size      = new Size(100, 100),
                            BackColor = Color.Transparent,
                            Image     = Properties.Resources.add_1,
                            SizeMode  = PictureBoxSizeMode.Zoom,
                            Anchor    = AnchorStyles.None
                        };
                        addButton.Click += new EventHandler(AddButtonClick);
                        MainTableLayoutPanel.Controls.Add(addButton);
                    }
                    else if (MainTableLayoutPanel.Controls.Count != widgets.Count + 1)
                    {
                        MainTableLayoutPanel.Enabled = true;
                        int count = 0;
                        foreach (Widget widget in widgets)
                        {
                            WidgetResult item = new WidgetResult
                            {
                                WidgetCommand = widget.WidgetCommand,
                                UselongTime   = widget.WidgetUseLongProcessTime,
                                WidgetTag     = count.ToString()
                            };
                            listToRun.Add(item);
                            count++;
                        }
                    }
                    BackgroundWorker widgetPageBackgroundWorker = new BackgroundWorker();
                    widgetPageBackgroundWorker.DoWork             += getWidgetPageInfo_Work;
                    widgetPageBackgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(getWidgetPageInfo_runCompleted);
                    widgetPageBackgroundWorker.RunWorkerAsync(listToRun);
                    LoginDetailsChanged = false; // this will prevent reloading if user switches tabs
                }
            }
        }
예제 #29
0
        public ActionResult Authenticate(int issueId)
        {
            //Authentication
            string username = Request["username"] ?? string.Empty;

            string password = Request["password"] ?? string.Empty;

            string repositoryUrl = Request["repositoryurl"] ?? string.Empty;

            string message = string.Empty;

            bool success = true;

            string dataView = string.Empty;

            if (username.IsEmpty() || password.IsEmpty() || repositoryUrl.IsEmpty())
            {
                message = "Please make sure Username, Password and Url are not empty";
                success = false;
            }

            if (success)
            {
                UserWidgetDataDetails userData = new UserWidgetDataDetails();

                userData.Username = username.Trim();

                userData.Password = SecretsHelper.Encrypt(password.Trim(), SecretsHelper.EncryptionKey);

                userData.RepositoryUrl = repositoryUrl.Trim();

                SaveLoginDetails(CurrentUser, userData, GeminiContext);

                TFSPicker tfsPicker = new TFSPicker();

                try
                {
                    ItemWidgetArguments args = new ItemWidgetArguments(UserContext, GeminiContext, Cache, System.Web.HttpContext.Current.Request, CurrentIssue);

                    tfsPicker.AuthenticateUser(args);

                    UserWidgetDataDetails loginDetails = tfsPicker.getLoginDetails();

                    TFSPicker.ConnectByImplementingCredentialsProvider connect = new TFSPicker.ConnectByImplementingCredentialsProvider();

                    ICredentials iCred = new NetworkCredential(loginDetails.Username, loginDetails.Password);

                    connect.setLoginDetails(loginDetails.Username, loginDetails.Password, loginDetails.RepositoryUrl);

                    connect.GetCredentials(new Uri(loginDetails.RepositoryUrl), iCred);

                    TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(new Uri(loginDetails.RepositoryUrl));


                    configurationServer.Credentials = iCred;

                    if (TFSPicker.IsBasicAuth)
                    {
                        configurationServer.ClientCredentials = new TfsClientCredentials(new BasicAuthCredential(iCred));
                    }
                    else
                    {
                        configurationServer.ClientCredentials = new TfsClientCredentials(new WindowsCredential(iCred));
                    }

                    try
                    {
                        configurationServer.EnsureAuthenticated();
                    }
                    catch
                    {
                        System.Threading.Thread.Sleep(1000);
                        configurationServer             = TfsConfigurationServerFactory.GetConfigurationServer(new Uri(loginDetails.RepositoryUrl));
                        configurationServer.Credentials = iCred;

                        if (TFSPicker.IsBasicAuth)
                        {
                            configurationServer.ClientCredentials = new TfsClientCredentials(new BasicAuthCredential(iCred));
                        }
                        else
                        {
                            configurationServer.ClientCredentials = new TfsClientCredentials(new WindowsCredential(iCred));
                        }
                        configurationServer.EnsureAuthenticated();
                    }
                }
                catch (Exception ex)
                {
                    var logindetails = GeminiContext.UserWidgetStore.Get <UserWidgetDataDetails>(CurrentUser.Entity.Id, Constants.AppId, Constants.ControlId);

                    if (logindetails != null)
                    {
                        GeminiContext.UserWidgetStore.Delete(logindetails.Id);
                    }

                    success = false;

                    message = ex.Message;

                    GeminiApp.LogException(new Exception(ex.Message)
                    {
                        Source = "TFS Picker"
                    }, false);

                    return(JsonSuccess(new { success = success, message = message }));
                }

                tfsPicker.setLoginDetails(userData.Username, password.Trim(), userData.RepositoryUrl);

                WidgetResult result = new WidgetResult();

                List <string> tfsDetails = new List <string>();

                IssueWidgetData <List <string> > data = GeminiContext.IssueWidgetStore.Get <List <string> >(issueId, Constants.AppId, Constants.ControlId);

                if (data != null && data.Value != null && data.Value.Count > 0)
                {
                    tfsDetails = data.Value;
                }

                List <WorkItem> details = new List <WorkItem>();

                foreach (var tfs in tfsDetails)
                {
                    try
                    {
                        string url;

                        UserWidgetDataDetails loginDetails = tfsPicker.getLoginDetails();

                        if (Username.IsEmpty())
                        {
                            Username = loginDetails.Username;
                        }

                        if (Password.IsEmpty())
                        {
                            Password = loginDetails.Password;
                        }

                        if (RepositoryUrl.IsEmpty())
                        {
                            RepositoryUrl = loginDetails.RepositoryUrl;
                        }

                        var item = GetItem(tfs, out url);

                        if (item != null)
                        {
                            details.Add(item);
                        }
                    }
                    catch (Exception ex)
                    {
                        success = false;

                        message = ex.Message;

                        GeminiApp.LogException(new Exception(ex.Message)
                        {
                            Source = "TFS Picker"
                        }, false);
                    }
                }
            }

            return(JsonSuccess(new { success = success, message = message }));
        }
예제 #30
0
        public override WidgetResult Show(IssueDto args)
        {
            _projectManager = new ProjectManager(Cache, UserContext, GeminiContext);

            _projectDocumentManager = new ProjectDocumentManager(Cache, UserContext, GeminiContext);

            IssuesGridFilter tmp = new IssuesGridFilter();

            HttpSessionManager HttpSessionManager = new HttpSessionManager();

            var projects = new List <int>();

            int selectedFolderKey = 0;

            // Safety check required because of http://gemini.countersoft.com/project/DEV/21/item/5088
            try
            {
                if (CurrentCard.IsNew)
                {
                    tmp = new IssuesGridFilter(HttpSessionManager.GetFilter(CurrentCard.Id, CurrentCard.Filter));

                    if (tmp == null)
                    {
                        tmp = CurrentCard.Options[AppGuid].FromJson <IssuesGridFilter>();
                    }

                    projects = tmp.GetProjects();
                }
                else
                {
                    var cardOptions = CurrentCard.Options[AppGuid].FromJson <DocumentAppNavCard>();

                    projects.Add(cardOptions.projectId);

                    selectedFolderKey = cardOptions.folderKey;
                }
            }
            catch (Exception ex)
            {
                tmp = new IssuesGridFilter(HttpSessionManager.GetFilter(CurrentCard.Id, IssuesFilter.CreateProjectFilter(UserContext.User.Entity.Id, UserContext.Project.Entity.Id)));

                projects = tmp.GetProjects();
            }

            var activeProjects = _projectManager.GetActive();

            var viewableProjects = new List <ProjectDto>();

            int?currentProjectId = projects.Count > 0 ? projects.First() : 0;

            if (activeProjects == null || activeProjects.Count == 0)
            {
                activeProjects = new List <ProjectDto>();
            }
            else
            {
                viewableProjects = ProjectManager.GetAppViewableProjects(this);
            }

            if (!viewableProjects.Any(s => s.Entity.Id == currentProjectId.Value))
            {
                currentProjectId = viewableProjects.Count > 0 ? viewableProjects.First().Entity.Id : 0;
            }


            var model = new DocumentsModel
            {
                Projects      = viewableProjects,
                FolderList    = _projectDocumentManager.GetFolders(currentProjectId),
                MaxFileUpload = GeminiApp.Config.MaxFileUploadSizeBytes
            };

            model.ProjectList = new SelectList(model.Projects, "Entity.Id", "Entity.Name", currentProjectId);

            model.Projects = viewableProjects;

            model.SelectedFolder = selectedFolderKey;

            model.HeaderText.Add(new HeaderTextItem(ResourceKeys.Documents));

            if (!model.FolderList.Any() && currentProjectId > 0)
            {
                var entity = new ProjectDocument
                {
                    Name      = ResourceKeys.Documents,
                    IsFolder  = true,
                    ProjectId = currentProjectId
                };

                model.FolderList.Add(_projectDocumentManager.Create(entity));
            }

            if (ProjectManager.GetAppEditableProjects(this).Count > 0)
            {
                ViewBag.EditPermission = true;
            }
            else
            {
                ViewBag.EditPermission = false;
            }

            WidgetResult result = new WidgetResult();

            result.Markup = new WidgetMarkup("views\\Documents.cshtml", model);

            result.Success = true;

            return(result);
        }
예제 #31
0
        public override WidgetResult Show(IssueDto issueItem)
        {
            WidgetResult result = new WidgetResult();

            if (!_validLicense)
            {
                _validLicense = !GeminiApp.LicenseSummary.IsFree || GeminiApp.LicenseSummary.IsGeminiTrial();

                if (!_validLicense)
                {
                    result.Markup  = new WidgetMarkup(UnlicensedMessage);
                    result.Success = true;
                    return(result);
                }
            }

            List <string> tfsDetails = new List <string>();

            IssueWidgetData <List <string> > data = GeminiContext.IssueWidgetStore.Get <List <string> >(issueItem.Entity.Id, Constants.AppId, Constants.ControlId);

            if (data != null && data.Value != null && data.Value.Count > 0)
            {
                tfsDetails = data.Value;
            }

            Dictionary <string, WorkItem> details = new Dictionary <string, WorkItem>();

            Pair <int, string> authenticationModel = new Pair <int, string>(issueItem.Entity.Id, string.Concat("apps/tfspicker/authenticate/", issueItem.Entity.Id));

            if (tfsDetails.Count > 0)
            {
                if (AuthenticateUser(issueItem))
                {
                    //IsTfs2012();
                    foreach (var tfs in tfsDetails)
                    {
                        try
                        {
                            string url;

                            var item = GetItem(tfs, out url);

                            if (item != null)
                            {
                                if (url == null)
                                {
                                    url = string.Format("{0}/web/UI/Pages/WorkItems/WorkItemEdit.aspx?id={1}&pguid={2}", RepositoryUrl, item.Id, item.Project.Guid);
                                }

                                /*if (isTfs2012)
                                 * {
                                 * url = string.Format("{0}/DefaultCollection/Countersoft/_workitems#_a=edit&id={1}", RepositoryUrl, item.Id);
                                 * }
                                 * else
                                 * {
                                 *  url = string.Format("{0}/web/UI/Pages/WorkItems/WorkItemEdit.aspx?id={1}&pguid={2}", RepositoryUrl, item.Id, item.Project.Guid);
                                 * }*/
                                if (!details.ContainsKey(url))
                                {
                                    details.Add(url, item);
                                }
                            }

                            Dictionary <string, TfsPickerItem> tfsPickerModel = ConvertWorkItemsToTfsPickerItems(details);

                            result.Markup = new WidgetMarkup("views\\items.cshtml", tfsPickerModel);
                        }
                        catch (Exception ex)
                        {
                            result.Markup = new WidgetMarkup("views\\authenticationForm.cshtml", authenticationModel);

                            GeminiApp.LogException(new Exception(ex.Message)
                            {
                                Source = "TFS Picker"
                            }, false);
                        }
                    }
                }
                else
                {
                    result.Markup = new WidgetMarkup("views\\authenticationForm.cshtml", authenticationModel);
                }
            }
            else
            {
                try
                {
                    if (AuthenticateUser(issueItem))
                    {
                        string url;

                        var item = GetItem("", out url);

                        Dictionary <string, TfsPickerItem> tfsPickerModel = ConvertWorkItemsToTfsPickerItems(details);

                        result.Markup = new WidgetMarkup("views\\items.cshtml", tfsPickerModel);
                    }
                    else
                    {
                        result.Markup = new WidgetMarkup("views\\authenticationForm.cshtml", authenticationModel);
                    }
                }
                catch (Exception ex)
                {
                    result.Markup = new WidgetMarkup("views\\authenticationForm.cshtml", authenticationModel);

                    GeminiApp.LogException(new Exception(ex.Message)
                    {
                        Source = "TFS Picker"
                    }, false);
                }
            }

            result.Success = true;

            return(result);
        }