Beispiel #1
0
 void InitializeNewScript()
 {
     ViewState[Definition.XSLFolderName] = Definition.XSLFolderName;
     if (IsTrackingEmailMode)
     {
         txtTrackingEmailTemplate.Text = string.Concat("<style type=\"text/css\">", "\r\n",
                                                       ".normal, .normalBold {font-family: Verdana, Tahoma, Arial, Helvetica;font-size: 11px;font-weight: normal;}",
                                                       "\r\n", ".normalBold{font-weight: bold;}", "\r\n",
                                                       "</style>", "\r\n",
                                                       XslTemplatingUtilities.GenerateDetailViewTokenText
                                                           (UdtController.GetSchemaDataset().Tables[
                                                               DataSetTableName.Fields],
                                                           includeEditLink: false));
     }
     else
     {
         txtListTemplate.Text               = BuildContent(GetBasicElements());
         txtListTemplateDelimiter.Enabled   = false;
         txtListTemplateDelimiter.BackColor = Color.LightGray;
         txtDetailTemplate.Text             =
             XslTemplatingUtilities.GenerateDetailViewTokenText(
                 _schemaDataSet.Tables[DataSetTableName.Fields]);
     }
     txtFolderName.Text    = Definition.XSLFolderName;
     txtFileName.MaxLength =
         Convert.ToInt32(200 -
                         (ModuleContext.PortalSettings.HomeDirectoryMapPath + "/" +
                          Definition.XSLFolderName + "/").Length);
 }
Beispiel #2
0
        public void RaisePostBackEvent(string eventArgument)
        {
            switch (eventArgument)
            {
            case "ResetModuleTabSettings":
                ModulesController.DeleteTabModuleSettings(ModuleContext.TabModuleId);
                break;

            case "SaveSettingsAsDefault":
                SaveSettings();
                var tabModuleSettings = ModulesController.GetTabModuleSettings(ModuleContext.TabModuleId);

                foreach (string key in tabModuleSettings.Keys)
                {
                    ModulesController.UpdateModuleSetting(ModuleContext.ModuleId, key,
                                                          tabModuleSettings[key].ToString());
                }
                break;

            case "DeleteAll":
                UdtController.DeleteRows();
                Response.Redirect(Globals.NavigateURL(ModuleContext.TabId), true);
                break;
            }
        }
Beispiel #3
0
 public bool InitializeUDT()
 {
     _udtController = new UdtController();
     // TODO: Test: Missing Config/wrong entries/correct entries
     _udtController.CreateConnection(ConfigurationManager.AppSettings["kc"], ConfigurationManager.AppSettings["port"]);
     // TODO: Test: Wrong UDT Name/correct UDT Name
     _udtController.GetUdt("SoccerUDT");
     return(false);
 }
Beispiel #4
0
 protected void cmdRebuildTrackingEmail_Click(object sender, EventArgs e)
 {
     txtTrackingEmailTemplate.Text = string.Concat("<style type=\"text/css\">", "\r\n",
                                                   ".normal, .normalBold {font-family: Verdana, Tahoma, Arial, Helvetica;font-size: 11px;font-weight: normal;}",
                                                   "\r\n", ".normalBold{font-weight: bold;}", "\r\n", "</style>",
                                                   "\r\n",
                                                   XslTemplatingUtilities.GenerateDetailViewTokenText(
                                                       UdtController.GetSchemaDataset().Tables[
                                                           DataSetTableName.Fields], includeEditLink: false));
 }
Beispiel #5
0
        public void RaisePostBackEvent(string eventArgument)
        {
            var modSecurity = new ModuleSecurity(ModuleContext);

            if (eventArgument == "DeleteAll" && modSecurity.IsAllowedToAdministrateModule())
            {
                UdtController.DeleteRows();
                Response.Redirect(Globals.NavigateURL(ModuleContext.TabId), true);
            }
        }
Beispiel #6
0
 public bool InitializeUDT(string KCName, string port)
 {
     _udtController = new UdtController();
     // TODO: Test: empty entry/wrong entries/correct entries
     _udtController.CreateConnection(KCName, port);
     // TODO: Test: Wrong UDT Name/correct UDT Name
     _udtController.GetUdt("SoccerUDT");
     return(false);
     //j
 }
        bool HasAddPermissonByQuota()
        {
            var userquota = Settings.UserRecordQuota;

            if (userquota > 0 && Request.IsAuthenticated)
            {
                var ds = UdtController.GetDataSet(false);
                return(ModuleSecurity.HasAddPermissonByQuota(ds.Tables[DataSetTableName.Fields],
                                                             ds.Tables[DataSetTableName.Data], userquota,
                                                             UserInfo.GetSafeUsername()));
            }
            return(true);
        }
Beispiel #8
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///   BindDataUsingXslTransform fetchs the data from the database and binds it to the grid
        /// </summary>
        /// -----------------------------------------------------------------------------
        void BindDataUsingXslTransform(string styleSheet)
        {
            try
            {
                DataSet.Tables.Add(UdtController.Context("",
                                                         Settings.SortFieldId.ToString(),
                                                         Settings.SortOrder,
                                                         Settings.Paging.ToString()));

                DataSet.Tables[DataSetTableName.Data]
                .FilterAndSort(GetRowFilter(Settings.Filter, _search.Filter()), SortField, SortOrder)
                .Top(Settings.TopCount);

                var xslTrans = new XslCompiledTransform();

                var script = Utilities.ReadStringFromFile(styleSheet, PortalId);
                var reader = new XmlTextReader(new StringReader(script));
                xslTrans.Load(reader);

                using (XmlReader xmlData = new XmlTextReader(new StringReader(DataSet.GetXml())))
                {
                    using (var stringWriter = new StringWriter())
                    {
                        //Dynamic UDT Params. Add all Request parameters that starts with "UDT_{moduleid}_Param*" as "Param*" named XSL parameter
                        var args = new XsltArgumentList();
                        var udtParameterPrefix = string.Format(Definition.QueryStringParameter, ModuleContext.ModuleId);
                        foreach (string paramKey in Request.Params.Keys)
                        {
                            if (paramKey != null && paramKey.ToLowerInvariant().StartsWith(udtParameterPrefix))
                            {
                                args.AddParam(paramKey.ToLowerInvariant().Substring(udtParameterPrefix.Length - 5),
                                              string.Empty, Request[paramKey]);
                            }
                        }
                        xslTrans.Transform(xmlData, args, stringWriter);
                        XslOutput.Controls.Add(new LiteralControl(stringWriter.ToString()));
                    }
                }

                XslOutput.Visible = true;
            }
            catch (Exception exc)
            {
                HandleException(exc,
                                string.Format("{0}<br/>StyleSheet:{1}",
                                              Localization.GetString("XslFailed.ErrorMessage", LocalResourceFile),
                                              styleSheet));
                BindDataToDataGrid();
            }
        }
Beispiel #9
0
 void cmdDelete_Click(object sender, EventArgs e)
 {
     if (_hasDeletePermission)
     {
         try
         {
             UdtController.DeleteRow(_userDefinedRowId);
             RecordDeleted();
             Response.Redirect(Globals.NavigateURL(ModuleContext.TabId), true);
         }
         catch (Exception exc) //Module failed to load
         {
             Exceptions.ProcessModuleLoadException(this, exc);
         }
     }
 }
Beispiel #10
0
        void Page_Load(object sender, EventArgs e)
        {
            _schemaDataSet = UdtController.GetSchemaDataset();
            SetupClientScripts();

            if (!IsPostBack)
            {
                if (Request.QueryString["fileid"].AsString().Length > 0 ||
                    Request.QueryString["Edit"].AsString().ToLowerInvariant() == "current")
                {
                    IFileInfo file = null;
                    if (Request.QueryString["Edit"].AsString().ToLowerInvariant() == "current")
                    {
                        var script = ModuleContext.Settings[SettingName.XslUserDefinedStyleSheet].ToString();
                        if (!string.IsNullOrEmpty(script))
                        {
                            file = FileManager.Instance.GetFile(ModuleContext.PortalId, script);
                        }
                        ReturnUrl = Globals.NavigateURL();
                    }
                    else
                    {
                        var fileId = int.Parse(Request.QueryString["fileid"]);
                        file      = FileManager.Instance.GetFile(fileId);
                        ReturnUrl = ModuleContext.EditUrl("Manage");
                    }
                    if (file != null &&
                        file.Extension.ToLowerInvariant().StartsWith("xsl") &&
                        Utilities.HasWritePermission(file.Folder, ModuleContext.PortalId))
                    {
                        EditExistingScriptAndTemplates(file);
                    }
                    else
                    {
                        InitializeNewScript();
                    }
                }
                else
                {
                    InitializeNewScript();
                }
                ListTemplateSetHeaderAndFooter();
                TemplatesPopulateColumnDropDownLists();
                TemplatesSetVisibility(!IsTrackingEmailMode);
            }
        }
Beispiel #11
0
        void cmdGenerateXslt_Click(object sender, EventArgs e)
        {
            lblTemplateError.Visible  = false;
            lblXslScriptError.Visible = false;
            lblSaveXslError.Visible   = false;

            var listTemplate   = txtListTemplate.Text;
            var detailTemplate = txtDetailTemplate.Text;
            var headerTemplate = txtHeaderTemplate.Text;

            if (IsTrackingEmailMode)
            {
                if (isValid(txtTrackingEmailTemplate.Text, ErrorOutput.XslTranformation, addRoot: true))
                {
                    txtXslScript.Text =
                        XslTemplatingUtilities.TransformTokenTextToXslScript(UdtController.GetSchemaDataset(),
                                                                             txtTrackingEmailTemplate.Text);
                    txtXslScript.Enabled = true;
                    ShowXslEditor();
                }
            }
            else
            {
                if (isValid(listTemplate, ErrorOutput.XslTranformation, addRoot: true) &&
                    (!chkShowDetailView.Checked || isValid(detailTemplate, ErrorOutput.XslTranformation, addRoot: true)))
                {
                    txtXslScript.Text = XslTemplatingUtilities.TransformTokenTextToXslScript(_schemaDataSet, listTemplate,
                                                                                             detailTemplate,
                                                                                             headerTemplate,
                                                                                             chkEnablePaging.Checked,
                                                                                             chkEnableSorting.Checked,
                                                                                             chkEnableSearch.Checked,
                                                                                             chkShowDetailView.Checked,
                                                                                             CurrentListType);
                    txtXslScript.Enabled = true;
                    ShowXslEditor();
                }
            }
        }
        void cmdUpdate_Click(object sender, EventArgs e)
        {
            if (_hasUpdatePermission)
            {
                try
                {
                    //warning message of validation has failed
                    var warningMessage = string.Empty;
                    warningMessage = _editControls.Values.Where(edit => !edit.IsValid())
                                     .Aggregate(warningMessage,
                                                (current, edit) => current + string.Format(
                                                    "<li><b>{0}</b><br />{1}</li>",
                                                    edit.FieldTitle,
                                                    edit.ValidationMessage));
                    if (CaptchaNeeded() && !_ctlCaptcha.IsValid)
                    {
                        warningMessage += string.Format("<li><b>{0}</b><br />{1}</li>",
                                                        Localization.GetString("Captcha.Text", LocalResourceFile),
                                                        Localization.GetString("CaptchaError.Text", LocalResourceFile));
                    }

                    if (ModuleContext.PortalSettings.UserId == -1 && Settings.ForceCaptchaForAnonymous && Settings.PreferReCaptcha)
                    {
                        string encodedResponse = Request.Form["g-recaptcha-response"];
                        if (!ReCaptcha.Validate(encodedResponse, Settings.ReCaptchaSecretKey))
                        {
                            warningMessage += string.Format("<li><b>{0}</b><br />{1}</li>",
                                                            Localization.GetString("ReCaptcha.Text", LocalResourceFile), Localization.GetString("ReCaptchaError.Text", LocalResourceFile));
                        }
                    }

                    if (warningMessage == string.Empty)
                    {
                        //'Save values for every field separately
                        foreach (var edit in _editControls.Values)
                        {
                            var value = edit.Value;
                            CurrentRow[edit.FieldTitle] = value;
                        }

                        UdtController.UpdateRow(Data);
                        RecordUpdated();

                        switch (Settings.ListOrForm)
                        {
                        case "List":
                            Response.Redirect(Globals.NavigateURL(ModuleContext.TabId), true);
                            break;

                        case "FormAndList":
                        case "ListAndForm":
                            var url = IsNewRow
                                              ? Request.RawUrl
                                              : Globals.NavigateURL(ModuleContext.TabId);
                            Response.Redirect(url,
                                              true);
                            break;

                        case "Form":
                            switch (Settings.UponSubmitAction)
                            {
                            case "Text":
                                divForm.Visible = false;
                                ShowUponSubmit();
                                break;

                            case "Form":
                                Response.Redirect(
                                    Globals.NavigateURL(ModuleContext.TabId, "",
                                                        string.Format("OnSubmit={0}", ModuleId)), true);
                                break;

                            default:
                                var strRedirectUrl = Settings.UponSubmitRedirect ?? Globals.NavigateURL(ModuleContext.TabId);
                                Response.Redirect(Globals.LinkClick(strRedirectUrl, ModuleContext.TabId,
                                                                    ModuleContext.ModuleId));
                                break;
                            }
                            break;
                        }
                    }
                    else
                    {
                        var moduleControl = (PortalModuleBase)(((Parent.Parent) is PortalModuleBase) ? Parent.Parent : this);
                        UI.Skins.Skin.AddModuleMessage(moduleControl, string.Format("<ul style=\"padding-left:1.6em;padding-bottom:0;\">{0}</ul>", warningMessage),
                                                       ModuleMessage.ModuleMessageType.RedError);
                    }
                }
                catch (Exception exc) //Module failed to load
                {
                    Exceptions.ProcessModuleLoadException(this, exc);
                }

                if (ModuleId == HrDbData.ListOfHrsModuleId)
                {
                    UpdateActiveHRsInVacancies();
                    UpdateActiveHRsInCamps();
                }
            }
        }