Esempio n. 1
0
        public void Render()
        {
            base.CssClass = "LinkBiDefinitionProperties";

            Table table = new Table();

            TableRow tableRowName = new TableRow();

            TableCell tableCellNameTitle = new TableCell();
            TableCell tableCellNameValue = new TableCell();
            TableCell tableCellButtons   = new TableCell();

            tableCellButtons.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Right;

            System.Web.UI.WebControls.Label lblName = new System.Web.UI.WebControls.Label();
            lblName.Text = base.LanguageManager.GetText("Name");

            TextBox txtName = new TextBox();

            txtName.Text = this.Definition.Properties.Name;

            txtName.Attributes.Add(
                "onchange",
                "UpdateLinkBiSavedReportName('" + this.Definition.FileName.Replace("\\", "/") + "', this.value, '" + this.Definition.FileName.Replace("\\", "") + "')"
                );

            OptionSwipe swiper = new OptionSwipe();

            Option optionUpdate   = new Option();
            Option optionDownload = new Option();
            Option optionEdit     = new Option();

            optionUpdate.Text   = base.LanguageManager.GetText("Update");
            optionDownload.Text = base.LanguageManager.GetText("Download");
            optionEdit.Text     = base.LanguageManager.GetText("Edit");

            optionUpdate.Style.Add("background", "#61CF71");
            optionDownload.CssClass = "BackgroundColor1";
            optionEdit.Style.Add("background", "#FFA719");

            optionUpdate.OnClientClick = string.Format(
                "DeployLinkBiReport('{0}', [{1}]);return false;",
                this.Definition.FileName.Replace("\\", "/"),
                string.Join(",", this.Definition.Properties.ServerConnections.Values.Select(x => "'" + x.Identity + "'"))
                );

            optionDownload.OnClientClick = string.Format(
                "DownloadLinkBiReport('{0}');return false;",
                this.Definition.FileName.Replace("\\", "/")
                );

            optionEdit.OnClientClick = string.Format(
                "EditLinkBiReport('{0}');return false;",
                this.Definition.FileName.Replace("\\", "/")
                );

            if (this.Definition.Properties.ServerConnections.Count > 0)
            {
                swiper.Options.Add(optionUpdate);
            }

            swiper.Options.Add(optionDownload);
            swiper.Options.Add(optionEdit);

            optionUpdate.Render();
            optionDownload.Render();
            optionEdit.Render();

            swiper.Render();

            tableCellNameTitle.Controls.Add(lblName);
            tableCellNameValue.Controls.Add(txtName);
            tableCellButtons.Controls.Add(swiper);

            tableRowName.Cells.Add(tableCellNameTitle);
            tableRowName.Cells.Add(tableCellNameValue);
            tableRowName.Cells.Add(tableCellButtons);

            table.Rows.Add(tableRowName);

            TableRow  tableRowServerConnections  = new TableRow();
            TableCell tableCellServerConnections = new TableCell();

            tableCellServerConnections.ColumnSpan = 3;

            foreach (LinkBiServerConnection serverConnection in this.Definition.Properties.ServerConnections.Values)
            {
                LinkBiServerConnectionControl serverConnectionControl = new LinkBiServerConnectionControl(serverConnection);

                serverConnectionControl.Render();

                if (Page != null)
                {
                    Page.ClientScript.RegisterStartupScript(
                        this.GetType(),
                        "CheckLinkBiServerConnection" + serverConnection.Identity,
                        "loadFunctions.push(function() { CheckLinkBiServerConnection('" + this.Definition.FileName.Replace("\\", "/") + "', '" + serverConnection.Identity + "') });",
                        true
                        );
                }

                tableCellServerConnections.Controls.Add(serverConnectionControl);
            }

            tableCellServerConnections.Controls.Add(new LiteralControl("<div style=\"clear:both\"></div>"));

            tableCellServerConnections.Controls.Add(new LiteralControl(string.Format(
                                                                           "<img onclick=\"AddServerConnection('{0}');\" style=\"cursor:pointer\" src=\"/Images/Icons/Cloud/NewDirectory.png\" " +
                                                                           "onmouseover=\"this.src='/Images/Icons/Cloud/NewDirectory_Hover.png';\" onmouseout=\"this.src='/Images/Icons/Cloud/NewDirectory.png';\" />",
                                                                           this.Definition.FileName.Replace("\\", "/")
                                                                           )));

            tableRowServerConnections.Cells.Add(tableCellServerConnections);

            table.Rows.Add(tableRowServerConnections);

            base.Controls.Add(table);
        }
        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    += "&nbsp;";
                        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 += "&nbsp;" + 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);
        }
Esempio n. 3
0
        private void RenderSearch(TableCell tableCellSearch)
        {
            Table table = new Table();

            table.CssClass = "VariableSelectionSelectorSearchTable";

            TableRow tableRow = new TableRow();

            TableCell tableCellChapter  = new TableCell();
            TableCell tableCellSettings = new TableCell();
            TableCell tableCell         = new TableCell();

            tableCell.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Left;

            tableCellChapter.CssClass  = "VariableSelectionSelectorTableCellChapter";
            tableCellSettings.CssClass = "VariableSelectionSelectorTableCellSettings";

            DropDownList ddlChapter = new DropDownList();

            ddlChapter.CssClass = "VariableSelectionSelectorChapter BorderColor1";

            BindChapters(ddlChapter);

            OptionSwipe settings = new OptionSwipe();

            settings.Direction = OptionSwiperDirection.Bottom;

            Option optionDisplayNoDataVariables = new Option();

            optionDisplayNoDataVariables.Text = base.LanguageManager.GetText("DisplayNoDataVariables") + "<input type=\"checkbox\" checked=\"true\" />";

            Option optionDataCheckEnabled = new Option();

            optionDataCheckEnabled.Text = base.LanguageManager.GetText("EnableDataCheck") + "<input type=\"checkbox\" checked=\"true\" />";

            optionDisplayNoDataVariables.Style.Add("background", "#61CF71");
            optionDataCheckEnabled.CssClass = "BackgroundColor2";

            settings.Options.Add(optionDisplayNoDataVariables);
            settings.Options.Add(optionDataCheckEnabled);

            if (this.RenderAsynch)
            {
                optionDisplayNoDataVariables.Render();
                optionDataCheckEnabled.Render();
                settings.Render();
            }

            TextBox txtSearch = new TextBox();

            txtSearch.CssClass = "VariableSelectionSelectorSearch BorderColor1";

            ddlChapter.Attributes.Add("onchange", string.Format(
                                          "SearchVariables(this, GetChildByAttribute(this.parentNode.parentNode, 'class', 'VariableSelectionSelectorSearch BorderColor1', true), " +
                                          "GetChildByAttribute(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode, 'class', '{0}', true))",
                                          "VariableSelectionSelectorVariables BorderColor1"
                                          ));

            txtSearch.Attributes.Add("onkeyup", string.Format(
                                         "SearchVariables(GetChildByAttribute(this.parentNode.parentNode, 'class', 'VariableSelectionSelectorSearch BorderColor1', true), this, " +
                                         "GetChildByAttribute(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode, 'class', '{0}', true))",
                                         "VariableSelectionSelectorVariables BorderColor1"
                                         ));


            tableCellChapter.Controls.Add(ddlChapter);
            tableCellSettings.Controls.Add(settings);
            tableCell.Controls.Add(txtSearch);

            tableRow.Cells.Add(tableCellChapter);
            tableRow.Cells.Add(tableCellSettings);
            tableRow.Cells.Add(tableCell);

            table.Rows.Add(tableRow);

            tableCellSearch.Controls.Add(table);
        }