public int OnItemAdded(uint itemidParent, uint itemidSiblingPrev, uint itemidAdded) { ThreadHelper.ThrowIfNotOnUIThread(); string r; object var; if (VSErr.Succeeded(ProjectHierarchy.GetProperty(itemidAdded, (int)__VSHPROPID.VSHPROPID_IsNonMemberItem, out var)) && (bool)var) { return VSErr.S_OK; // Extra item for show all files } if (_loaded) { if (VSErr.Succeeded(VsProject.GetMkDocument(itemidAdded, out r)) && SvnItem.IsValidPath(r)) { // Check out VSHPROPID_IsNewUnsavedItem if (!SvnItem.PathExists(r)) { SetPreCreatedItem(itemidAdded); } else { SetPreCreatedItem(VSItemId.Nil); SetDirty(); } } } return VSErr.S_OK; }
private void SelectHierarchy(HttpContext context) { // Get the full path to the hierarchy // file from the http request's parameters. string fileNameTemplate = context.Request.Params["FileName"]; // Build the path to the study's hierarchy file. string fileName = Path.Combine( context.Request.PhysicalApplicationPath, "Fileadmin", "StudyTaxonomyStructures", Global.Core.ClientName, this.IdSelectedStudy + ".xml" ); // Copy the template file to the study hierarchy file. File.Copy( fileNameTemplate, fileName ); ProjectHierarchy hierarchy = new ProjectHierarchy(fileName); hierarchy.Origin = Guid.Parse( (new FileInfo(fileNameTemplate)).Name.Replace(".xml", "") ); hierarchy.Save(); }
private void AddField(HttpContext context) { if (this.SelectedTaxonomyStrucure == null) { return; } ProjectHierarchy taxonomyStructure = new ProjectHierarchy(this.SelectedTaxonomyStrucure); string xPath = context.Request.Params["XPath"]; XmlNode xmlNode = taxonomyStructure.XmlDocument.SelectSingleNode(xPath); if (xmlNode == null) { return; } xmlNode.InnerXml += string.Format( "<Field Id=\"{0}\" Type=\"Single\"><Label IdLanguage=\"{1}\"></Label></Field>", Guid.NewGuid(), this.IdLanguage ); taxonomyStructure.Save(); }
private void SetFieldType(HttpContext context) { if (this.SelectedTaxonomyStrucure == null) { return; } ProjectHierarchy taxonomyStructure = new ProjectHierarchy(this.SelectedTaxonomyStrucure); // Get the xPath of the field's xml node // from the http request's parameters. string xPath = context.Request.Params["XPath"]; // Get the new type for the field // from the http request's parameters. ProjectHierarchyFieldType type = (ProjectHierarchyFieldType)Enum.Parse( typeof(ProjectHierarchyFieldType), context.Request.Params["Value"] ); // Select the field's xml node. XmlNode xmlNode = taxonomyStructure.XmlDocument.SelectSingleNode(xPath); // Check if the field exists. if (xmlNode == null) { return; } // Set new type of the field. xmlNode.Attributes["Type"].Value = type.ToString(); // Save the taxonomy structure. taxonomyStructure.Save(); }
private void AddFieldValue(HttpContext context) { if (this.SelectedTaxonomyStrucure == null) { return; } ProjectHierarchy taxonomyStructure = new ProjectHierarchy(this.SelectedTaxonomyStrucure); // Get the xPath of the field's xml node // from the http request's parameters. string xPath = context.Request.Params["XPath"]; // Select the field's xml node. XmlNode xmlNode = taxonomyStructure.XmlDocument.SelectSingleNode(xPath); // Check if the field exists. if (xmlNode == null) { return; } // Add a new value xml node to the field's xml node. xmlNode.InnerXml += string.Format( "<Value Id=\"{0}\"><Label IdLanguage=\"{1}\">{2}</Label></Value>", Guid.NewGuid(), this.IdLanguage, Global.LanguageManager.GetText("NewTaxonomyFieldValue") ); // Save the taxonomy structure. taxonomyStructure.Save(); }
private void DeleteFieldValue(HttpContext context) { if (this.SelectedTaxonomyStrucure == null) { return; } ProjectHierarchy taxonomyStructure = new ProjectHierarchy(this.SelectedTaxonomyStrucure); // Get the xPath of the field value's xml node // from the http request's parameters. string xPath = context.Request.Params["XPath"]; // Select the field value's xml node. XmlNode xmlNode = taxonomyStructure.XmlDocument.SelectSingleNode(xPath); // Check if the field value exists. if (xmlNode == null) { return; } // Delete the field value. xmlNode.ParentNode.RemoveChild(xmlNode); // Save the taxonomy structure. taxonomyStructure.Save(); }
private void UpdateField(HttpContext context) { if (this.SelectedTaxonomyStrucure == null) { return; } ProjectHierarchy taxonomyStructure = new ProjectHierarchy(this.SelectedTaxonomyStrucure); // Parse the xPath of the field's xml node to // get from the http request's parameters. string xPath = context.Request.Params["XPath"]; // Select the field's xml node. XmlNode xmlNode = taxonomyStructure.XmlDocument.SelectSingleNode(xPath); // Check if the field exists. if (xmlNode == null) { return; } ProjectHierarchyField field = new ProjectHierarchyField(taxonomyStructure, xmlNode); Panel pnlField = field.Render(this.IdLanguage); // Write the field's panel as html to the http response. context.Response.Write(pnlField.ToHtml()); // Set the http response's content type to plain text. context.Response.ContentType = "text/plain"; }
private void SetStudyValue(HttpContext context) { // Build the path to the study's taxonomy structure file. string fileName = Path.Combine( context.Request.PhysicalApplicationPath, "Fileadmin", "StudyTaxonomyStructures", Global.Core.ClientName, this.IdSelectedStudy + ".xml" ); ProjectHierarchy structure = new ProjectHierarchy(fileName); // Get the xPath to the value xml node // from the http request's parameters. string xPath = context.Request.Params["XPath"]; // Select the value xml node. XmlNode xmlNode = structure.XmlDocument.SelectSingleNode(xPath); // Check if the field value exists. if (xmlNode == null) { return; } // Get the index of the study value from // the http request's parameters. int index = int.Parse(context.Request.Params["Index"]); // Get the value for the study value // from the http request's parameters. string value = context.Request.Params["Value"]; // Select the study value xml node. XmlNode xmlNodeStudyValue = xmlNode.SelectSingleNode(string.Format( "StudyValue[@Index=\"{0}\"]", index )); // Check if a study value with that index exists. if (xmlNodeStudyValue == null) { xmlNode.InnerXml += string.Format( "<StudyValue Index=\"{0}\">{1}</StudyValue>", index, value ); } else { xmlNodeStudyValue.InnerXml = value; } // Save the taxonomy structure. structure.Save(); }
private void SetFieldValueLabel(HttpContext context) { if (this.SelectedTaxonomyStrucure == null) { return; } ProjectHierarchy taxonomyStructure = new ProjectHierarchy(this.SelectedTaxonomyStrucure); // Get the xPath of the field value's xml node // from the http request's parameters. string xPath = context.Request.Params["XPath"]; // Get the new label for the field value // from the http request's parameters. string label = context.Request.Params["Value"]; // Select the field value's xml node. XmlNode xmlNode = taxonomyStructure.XmlDocument.SelectSingleNode(xPath); // Check if the field value exists. if (xmlNode == null) { return; } // Select the label xml node. XmlNode xmlNodeLabel = xmlNode.SelectSingleNode(string.Format( "Label[@IdLanguage=\"{0}\"]", this.IdLanguage )); // Check if a label in that language exists. if (xmlNodeLabel == null) { // Add a new label in that language. xmlNode.InnerXml += string.Format( "<Label IdLanguage=\"{0}\">{1}</Label>", this.IdLanguage, label ); } else { // Set the new label. xmlNodeLabel.InnerXml = label; } // Save the taxonomy structure. taxonomyStructure.Save(); }
public int OnItemDeleted(uint itemid) { SetPreCreatedItem(VSItemId.Nil); object var; if (VSErr.Succeeded(ProjectHierarchy.GetProperty(itemid, (int)__VSHPROPID.VSHPROPID_IsNonMemberItem, out var)) && (bool)var) { return(VSErr.S_OK); // Extra item for show all files } SetDirty(); return(VSErr.S_OK); }
internal void Hook(bool hook) { uint cookie; if (_hierarchyEventsCookie == 0 && hook) { if (VSErr.Succeeded(ProjectHierarchy.AdviseHierarchyEvents(this, out cookie))) { _hierarchyEventsCookie = cookie; } } else if (!hook && (_hierarchyEventsCookie != 0)) { cookie = _hierarchyEventsCookie; _hierarchyEventsCookie = 0; ProjectHierarchy.UnadviseHierarchyEvents(cookie); } }
public void SetCommandLine(string NewCommandLine) { System.Windows.Threading.Dispatcher.CurrentDispatcher.VerifyAccess(); // Update out MRU combo list SetCommandLineMRU(NewCommandLine); // Set on the project IVsHierarchy ProjectHierarchy; if (SolutionBuildManager.get_StartupProject(out ProjectHierarchy) == VSConstants.S_OK && ProjectHierarchy != null) { object ProjectObject; ProjectHierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out ProjectObject); var SelectedStartupProject = (EnvDTE.Project)ProjectObject; if (SelectedStartupProject != null) { var ActiveConfiguration = SelectedStartupProject.ConfigurationManager.ActiveConfiguration; if (ActiveConfiguration != null) { var PropertyStorage = ProjectHierarchy as IVsBuildPropertyStorage; if (PropertyStorage != null) { string ConfigurationName = MakeConfigurationName(ActiveConfiguration); // Remove property if (string.IsNullOrEmpty(NewCommandLine)) { PropertyStorage.RemoveProperty("LocalDebuggerCommandArguments", ConfigurationName, (uint)_PersistStorageType.PST_USER_FILE); PropertyStorage.RemoveProperty("RemoteDebuggerCommandArguments", ConfigurationName, (uint)_PersistStorageType.PST_USER_FILE); } // Set property else { PropertyStorage.SetPropertyValue("LocalDebuggerCommandArguments", ConfigurationName, (uint)_PersistStorageType.PST_USER_FILE, NewCommandLine); PropertyStorage.SetPropertyValue("RemoteDebuggerCommandArguments", ConfigurationName, (uint)_PersistStorageType.PST_USER_FILE, NewCommandLine); } } } } } }
public static string GetStartupProjectName() { System.Windows.Threading.Dispatcher.CurrentDispatcher.VerifyAccess(); var SolutionBuildManager = VisualStudio.VSEvents.Instance?.SolutionBuildManager; IVsHierarchy ProjectHierarchy; if (SolutionBuildManager.get_StartupProject(out ProjectHierarchy) == VSConstants.S_OK && ProjectHierarchy != null) { object ProjectObject; ProjectHierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out ProjectObject); var SelectedStartupProject = (EnvDTE.Project)ProjectObject; if (SelectedStartupProject != null) { return(SelectedStartupProject.Name); } } return(null); }
public string GetCommandLine() { System.Windows.Threading.Dispatcher.CurrentDispatcher.VerifyAccess(); string debuggerCommandLine = ""; IVsHierarchy ProjectHierarchy; if (SolutionBuildManager.get_StartupProject(out ProjectHierarchy) == VSConstants.S_OK && ProjectHierarchy != null) { object ProjectObject; ProjectHierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out ProjectObject); var SelectedStartupProject = (EnvDTE.Project)ProjectObject; if (SelectedStartupProject != null) { var ActiveConfiguration = SelectedStartupProject.ConfigurationManager.ActiveConfiguration; if (ActiveConfiguration != null) { var PropertyStorage = ProjectHierarchy as IVsBuildPropertyStorage; if (PropertyStorage != null) { string ConfigurationName = MakeConfigurationName(ActiveConfiguration); if (PropertyStorage.GetPropertyValue("LocalDebuggerCommandArguments", ConfigurationName, (uint)_PersistStorageType.PST_USER_FILE, out debuggerCommandLine) != VSConstants.S_OK) { if (PropertyStorage.GetPropertyValue("StartArguments", ConfigurationName, (uint)_PersistStorageType.PST_USER_FILE, out debuggerCommandLine) != VSConstants.S_OK) { debuggerCommandLine = ""; } } } } } } return(debuggerCommandLine); }
private void GetFields(HttpContext context) { if (this.SelectedTaxonomyStrucure == null) { return; } ProjectHierarchy taxonomyStructure = new ProjectHierarchy(this.SelectedTaxonomyStrucure); string xPath = context.Request.Params["XPath"]; XmlNode xmlNode = taxonomyStructure.XmlDocument.SelectSingleNode(xPath); if (xmlNode == null) { return; } StringBuilder result = new StringBuilder(); // Run through all field xml nodes of the xml node. foreach (XmlNode xmlNodeField in xmlNode.SelectNodes("Field")) { ProjectHierarchyField field = new ProjectHierarchyField(taxonomyStructure, xmlNodeField); Panel pnlField = field.Render(this.IdLanguage); result.Append(pnlField.ToHtml()); result.Append("<br />"); } context.Response.Write(result.ToString()); // Set the http response's content type to plain text. context.Response.ContentType = "text/plain"; }
private void BindStudies() { Table table = new Table(); table.CssClass = "TableStudies"; TableRow tableRowHeadline = new TableRow(); tableRowHeadline.CssClass = "TableRowHeadline Color1"; TableCell tableCellHeadlineStudyName = new TableCell(); TableCell tableCellHeadlineCreationDate = new TableCell(); TableCell tableCellHeadlineTaxonomyStructureStatus = new TableCell(); tableCellHeadlineStudyName.Text = Global.LanguageManager.GetText("StudyName"); tableCellHeadlineCreationDate.Text = Global.LanguageManager.GetText("CreationDate"); tableCellHeadlineTaxonomyStructureStatus.Text = Global.LanguageManager.GetText("StudyStatus"); tableRowHeadline.Cells.Add(tableCellHeadlineStudyName); tableRowHeadline.Cells.Add(tableCellHeadlineCreationDate); tableRowHeadline.Cells.Add(tableCellHeadlineTaxonomyStructureStatus); table.Rows.Add(tableRowHeadline); if (Global.User.HasPermission(Global.PermissionCore.Permissions["UploadStudy"].Id)) { TableRow tableRowNew = new TableRow(); TableCell tableCellNew = new TableCell(); ImageButton btnNew = new ImageButton(); btnNew.ID = "btnNew"; btnNew.ImageUrl = "/Images/Icons/Add.png"; btnNew.Click += btnNew_Click; btnNew.Attributes.Add("onmousedown", "showSubmitLoading = false;"); tableCellNew.Controls.Add(btnNew); tableRowNew.Cells.Add(tableCellNew); table.Rows.Add(tableRowNew); } // Run through all studies of the client. foreach (Study study in Global.Core.Studies.Get().OrderByDescending(x => x.CreationDate)) { TableRow tableRow = new TableRow(); TableCell tableCellStudyName = new TableCell(); TableCell tableCellCreationDate = new TableCell(); TableCell tableCellTaxonomyStructureStatus = new TableCell(); TableCell tableCellOptions = new TableCell(); tableCellOptions.CssClass = "TableCellOptions"; tableCellOptions.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Right; tableCellStudyName.Text = study.Name; tableCellCreationDate.Text = study.CreationDate.ToString( Global.LanguageManager.GetText("DateFormat") + " " + Global.LanguageManager.GetText("TimeFormat") ); // Build the path to the study's taxonomy structure file. string fileName = Path.Combine( Request.PhysicalApplicationPath, "Fileadmin", "StudyTaxonomyStructures", Global.Core.ClientName, study.Id + ".xml" ); bool showDelete = true; OptionSwipe options = new OptionSwipe(); Option optionDownloadAssignment = new Option(); optionDownloadAssignment.Text = Global.LanguageManager.GetText("DownloadAssignment"); optionDownloadAssignment.CssClass = "DarkGrayBackground"; optionDownloadAssignment.OnClientClick = string.Format( "DownloadAssignment('{0}')", study.Id ); if (study.Status == StudyStatus.None) { /*Option optionSetHierarchy = new Option(); * optionSetHierarchy.Text = Global.LanguageManager.GetText("SetProjectHierarchy"); * optionSetHierarchy.CssClass = "BackgroundColor1"; * optionSetHierarchy.OnClientClick = string.Format( * "SetProjectHierachy('{0}')", * study.Id * );*/ Option optionDataAnalyser = new Option(); optionDataAnalyser.Text = Global.LanguageManager.GetText("RunDataAnalyser"); optionDataAnalyser.Style.Add("background", "#000000"); optionDataAnalyser.OnClientClick = string.Format( "RunDataAnalyser('{0}');", study.Id ); Option optionModifyVariables = new Option(); optionModifyVariables.Text = Global.LanguageManager.GetText("ModifyVariables"); optionModifyVariables.CssClass = "BackgroundColor2"; optionModifyVariables.OnClientClick = string.Format( "window.location='Variables.aspx?IdStudy={0}';", study.Id ); /*if (Global.User.HasPermission(Global.PermissionCore.Permissions["SetStudyHiarachy"].Id)) * options.Options.Add(optionSetHierarchy);*/ if (Global.User.HasPermission(Global.PermissionCore.Permissions["DownloadAssignment"].Id)) { options.Options.Add(optionDownloadAssignment); } if (Global.User.HasPermission(Global.PermissionCore.Permissions["ModifyVariables"].Id)) { options.Options.Add(optionModifyVariables); } if (Global.User.HasPermission(Global.PermissionCore.Permissions["DataAnalyser"].Id)) { options.Options.Add(optionDataAnalyser); } // Check if a taxonomy structure for the study is set. if (File.Exists(fileName)) { ProjectHierarchy hierarchy = new ProjectHierarchy(fileName); if (hierarchy.IsValid()) { tableCellTaxonomyStructureStatus.Text = Global.LanguageManager.GetText("ProjectHierarchySet"); } else { tableCellTaxonomyStructureStatus.Text = Global.LanguageManager.GetText("ProjectHierarchyIncomplete"); } } else { tableCellTaxonomyStructureStatus.Text = Global.LanguageManager.GetText("NoProjectHierarchySet"); } } else { string fileNameStatus = Path.Combine( Request.PhysicalApplicationPath, "Fileadmin", "RunningImports", study.Id.ToString() ); if (File.Exists(fileNameStatus)) { showDelete = false; string[] runningImport = File.ReadAllText(fileNameStatus).Split('|'); double progress = 0; DateTime responseInsertStarted; if (runningImport.Length > 1) { progress = double.Parse(runningImport[1]); } if (runningImport[0] == "Step6") { if (Global.User.HasPermission(Global.PermissionCore.Permissions["DownloadAssignment"].Id)) { options.Options.Add(optionDownloadAssignment); } } tableCellTaxonomyStructureStatus.CssClass = "Color1"; tableCellTaxonomyStructureStatus.Text = Global.LanguageManager.GetText("DataUploaderStatus" + runningImport[0]); tableCellTaxonomyStructureStatus.Text += " "; tableCellTaxonomyStructureStatus.Text += "<span class=\"Color2\">" + Math.Round(progress, 2) + "%</span>"; if (runningImport[0] == "Step6" && progress != 0) { if (runningImport.Length > 2) { if (!DateTime.TryParse(runningImport[2], out responseInsertStarted)) { responseInsertStarted = study.CreationDate; } } else { responseInsertStarted = study.CreationDate; } TimeSpan duration = DateTime.Now - responseInsertStarted; long etaSeconds = ((long)(duration.TotalSeconds / progress)) * 100; etaSeconds -= (long)duration.TotalSeconds; TimeSpan eta; try { eta = DateTime.Now.AddSeconds(etaSeconds) - DateTime.Now; } catch { eta = DateTime.Now - DateTime.Now; } string etaStr = ""; if (eta.Days != 0) { etaStr += eta.Days + "d "; } if (eta.Hours != 0) { etaStr += eta.Hours + "h "; } if (eta.Minutes != 0) { etaStr += eta.Minutes + "m "; } if (etaStr == "" || eta.TotalSeconds <= 0) { etaStr = "<1m"; } tableCellTaxonomyStructureStatus.Text += " " + string.Format( Global.LanguageManager.GetText("DataImportETA"), etaStr ); } } else { string fileNameError = Path.Combine( Request.PhysicalApplicationPath, "Fileadmin", study.Status == StudyStatus.ImportFailed ? "StudyUploadErrors" : "StudyDeletionErrors", study.Id.ToString() + ".log" ); string errorMessage = ""; if (File.Exists(fileNameError)) { errorMessage = File.ReadAllText(fileNameError); } errorMessage = HttpUtility.HtmlEncode(errorMessage.Split('\n')[0].Trim()); if (study.Status == StudyStatus.ImportFailed || study.Status == StudyStatus.DeletionFailed) { tableCellTaxonomyStructureStatus.Text = string.Format( "<a style=\"cursor:pointer;color:#FF0000;font-weight:bold;text-decoration:underline;\" ErrorMessage=\"{1}\" onclick=\"ShowImportErrorDetail(this.getAttribute('ErrorMessage'));\">{0}</a>", Global.LanguageManager.GetText("Study" + study.Status), errorMessage ); } else { tableCellTaxonomyStructureStatus.Text = string.Format( "{0}", Global.LanguageManager.GetText("Study" + study.Status) ); } } } if (study.Status != StudyStatus.Deleting && showDelete) { Option optionDeleteStudy = new Option(); optionDeleteStudy.Text = Global.LanguageManager.GetText("DeleteStudy"); optionDeleteStudy.CssClass = "RedBackground"; optionDeleteStudy.OnClientClick = string.Format( "DeleteStudy('{0}', '{1}');", HttpUtility.HtmlAttributeEncode(study.Id.ToString()), HttpUtility.HtmlAttributeEncode(study.Name) ); if (Global.User.HasPermission(Global.PermissionCore.Permissions["DeleteStudy"].Id)) { options.Options.Add(optionDeleteStudy); } } tableCellOptions.Controls.Add(options); tableRow.Cells.Add(tableCellStudyName); tableRow.Cells.Add(tableCellCreationDate); tableRow.Cells.Add(tableCellTaxonomyStructureStatus); tableRow.Cells.Add(tableCellOptions); table.Rows.Add(tableRow); } pnlStudies.Controls.Add(table); }