protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            try
            {
                UserInfo objUserInfo = null;
                int      intUserID   = -1;
                if (Request.IsAuthenticated)
                {
                    objUserInfo = UserController.Instance.GetCurrentUserInfo();
                    if (objUserInfo != null)
                    {
                        intUserID = objUserInfo.UserID;
                    }
                }
                int intRoleId = -1;
                if (Request.QueryString["roleid"] != null)
                {
                    intRoleId = int.Parse(Request.QueryString["roleid"]);
                }
                string     strProcessorUserId = "";
                PortalInfo objPortalInfo      = PortalController.Instance.GetPortal(PortalSettings.PortalId);
                if (objPortalInfo != null)
                {
                    strProcessorUserId = objPortalInfo.ProcessorUserId;
                }
                Dictionary <string, string> settings = PortalController.Instance.GetPortalSettings(PortalSettings.PortalId);
                string strPayPalURL;
                if (intUserID != -1 && intRoleId != -1 && !String.IsNullOrEmpty(strProcessorUserId))
                {
                    // Sandbox mode
                    if (settings.ContainsKey("paypalsandbox") && !String.IsNullOrEmpty(settings["paypalsandbox"]) && settings["paypalsandbox"].ToLowerInvariant() == "true")
                    {
                        strPayPalURL = "https://www.sandbox.paypal.com/cgi-bin/webscr?";
                    }
                    else
                    {
                        strPayPalURL = "https://www.paypal.com/cgi-bin/webscr?";
                    }

                    if (Request.QueryString["cancel"] != null)
                    {
                        //build the cancellation PayPal URL
                        strPayPalURL += "cmd=_subscr-find&alias=" + Globals.HTTPPOSTEncode(strProcessorUserId);
                    }
                    else
                    {
                        strPayPalURL += "cmd=_ext-enter";
                        RoleInfo objRole = RoleController.Instance.GetRole(PortalSettings.PortalId, r => r.RoleID == intRoleId);
                        if (objRole.RoleID != -1)
                        {
                            int intTrialPeriod = 1;
                            if (objRole.TrialPeriod != 0)
                            {
                                intTrialPeriod = objRole.TrialPeriod;
                            }
                            int intBillingPeriod = 1;
                            if (objRole.BillingPeriod != 0)
                            {
                                intBillingPeriod = objRole.BillingPeriod;
                            }

                            //explicitely format numbers using en-US so numbers are correctly built
                            var    enFormat   = new CultureInfo("en-US");
                            string strService = string.Format(enFormat.NumberFormat, "{0:#####0.00}", objRole.ServiceFee);
                            string strTrial   = string.Format(enFormat.NumberFormat, "{0:#####0.00}", objRole.TrialFee);
                            if (objRole.BillingFrequency == "O" || objRole.TrialFrequency == "O")
                            {
                                //build the payment PayPal URL
                                strPayPalURL += "&redirect_cmd=_xclick&business=" + Globals.HTTPPOSTEncode(strProcessorUserId);
                                strPayPalURL += "&item_name=" +
                                                Globals.HTTPPOSTEncode(PortalSettings.PortalName + " - " + objRole.RoleName + " ( " + objRole.ServiceFee.ToString("#.##") + " " +
                                                                       PortalSettings.Currency + " )");
                                strPayPalURL += "&item_number=" + Globals.HTTPPOSTEncode(intRoleId.ToString());
                                strPayPalURL += "&no_shipping=1&no_note=1";
                                strPayPalURL += "&quantity=1";
                                strPayPalURL += "&amount=" + Globals.HTTPPOSTEncode(strService);
                                strPayPalURL += "&currency_code=" + Globals.HTTPPOSTEncode(PortalSettings.Currency);
                            }
                            else //recurring payments
                            {
                                //build the subscription PayPal URL
                                strPayPalURL += "&redirect_cmd=_xclick-subscriptions&business=" + Globals.HTTPPOSTEncode(strProcessorUserId);
                                strPayPalURL += "&item_name=" +
                                                Globals.HTTPPOSTEncode(PortalSettings.PortalName + " - " + objRole.RoleName + " ( " + objRole.ServiceFee.ToString("#.##") + " " +
                                                                       PortalSettings.Currency + " every " + intBillingPeriod + " " + GetBillingFrequencyText(objRole.BillingFrequency) + " )");
                                strPayPalURL += "&item_number=" + Globals.HTTPPOSTEncode(intRoleId.ToString());
                                strPayPalURL += "&no_shipping=1&no_note=1";
                                if (objRole.TrialFrequency != "N")
                                {
                                    strPayPalURL += "&a1=" + Globals.HTTPPOSTEncode(strTrial);
                                    strPayPalURL += "&p1=" + Globals.HTTPPOSTEncode(intTrialPeriod.ToString());
                                    strPayPalURL += "&t1=" + Globals.HTTPPOSTEncode(objRole.TrialFrequency);
                                }
                                strPayPalURL += "&a3=" + Globals.HTTPPOSTEncode(strService);
                                strPayPalURL += "&p3=" + Globals.HTTPPOSTEncode(intBillingPeriod.ToString());
                                strPayPalURL += "&t3=" + Globals.HTTPPOSTEncode(objRole.BillingFrequency);
                                strPayPalURL += "&src=1";
                                strPayPalURL += "&currency_code=" + Globals.HTTPPOSTEncode(PortalSettings.Currency);
                            }
                        }
                        var ctlList = new ListController();

                        strPayPalURL += "&custom=" + Globals.HTTPPOSTEncode(intUserID.ToString());
                        strPayPalURL += "&first_name=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.FirstName);
                        strPayPalURL += "&last_name=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.LastName);
                        try
                        {
                            if (objUserInfo.Profile.Country == "United States")
                            {
                                ListEntryInfo colList = ctlList.GetListEntryInfo("Region", objUserInfo.Profile.Region);
                                strPayPalURL += "&address1=" +
                                                Globals.HTTPPOSTEncode(Convert.ToString(!String.IsNullOrEmpty(objUserInfo.Profile.Unit) ? objUserInfo.Profile.Unit + " " : "") +
                                                                       objUserInfo.Profile.Street);
                                strPayPalURL += "&city=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.City);
                                strPayPalURL += "&state=" + Globals.HTTPPOSTEncode(colList.Value);
                                strPayPalURL += "&zip=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.PostalCode);
                            }
                        }
                        catch (Exception ex)
                        {
                            //issue getting user address
                            Logger.Error(ex);
                        }

                        //Return URL
                        if (settings.ContainsKey("paypalsubscriptionreturn") && !string.IsNullOrEmpty(settings["paypalsubscriptionreturn"]))
                        {
                            strPayPalURL += "&return=" + Globals.HTTPPOSTEncode(settings["paypalsubscriptionreturn"]);
                        }
                        else
                        {
                            strPayPalURL += "&return=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request)));
                        }

                        //Cancellation URL
                        if (settings.ContainsKey("paypalsubscriptioncancelreturn") && !string.IsNullOrEmpty(settings["paypalsubscriptioncancelreturn"]))
                        {
                            strPayPalURL += "&cancel_return=" + Globals.HTTPPOSTEncode(settings["paypalsubscriptioncancelreturn"]);
                        }
                        else
                        {
                            strPayPalURL += "&cancel_return=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request)));
                        }

                        //Instant Payment Notification URL
                        if (settings.ContainsKey("paypalsubscriptionnotifyurl") && !string.IsNullOrEmpty(settings["paypalsubscriptionnotifyurl"]))
                        {
                            strPayPalURL += "&notify_url=" + Globals.HTTPPOSTEncode(settings["paypalsubscriptionnotifyurl"]);
                        }
                        else
                        {
                            strPayPalURL += "&notify_url=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request)) + "/admin/Sales/PayPalIPN.aspx");
                        }
                        strPayPalURL += "&sra=1"; //reattempt on failure
                    }

                    //redirect to PayPal
                    Response.Redirect(strPayPalURL, true);
                }
                else
                {
                    if ((settings.ContainsKey("paypalsubscriptioncancelreturn") && !string.IsNullOrEmpty(settings["paypalsubscriptioncancelreturn"])))
                    {
                        strPayPalURL = settings["paypalsubscriptioncancelreturn"];
                    }
                    else
                    {
                        strPayPalURL = Globals.AddHTTP(Globals.GetDomainName(Request));
                    }

                    //redirect to PayPal
                    Response.Redirect(strPayPalURL, true);
                }
            }
            catch (Exception exc) //Page failed to load
            {
                Exceptions.ProcessPageLoadException(exc);
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// CreateEditor creates the control collection.
        /// </summary>
        /// <history>
        ///     [cnurse]	05/08/2006	created
        /// </history>
        /// -----------------------------------------------------------------------------
        protected override void CreateEditor()
        {
            CategoryDataField             = "PropertyCategory";
            EditorDataField               = "DataType";
            NameDataField                 = "PropertyName";
            RequiredDataField             = "Required";
            ValidationExpressionDataField = "ValidationExpression";
            ValueDataField                = "PropertyValue";
            VisibleDataField              = "Visible";
            VisibilityDataField           = "ProfileVisibility";
            LengthDataField               = "Length";

            base.CreateEditor();

            foreach (FieldEditorControl editor in Fields)
            {
                //Check whether Field is readonly
                string fieldName = editor.Editor.Name;
                ProfilePropertyDefinitionCollection definitions = editor.DataSource as ProfilePropertyDefinitionCollection;
                ProfilePropertyDefinition           definition  = definitions[fieldName];

                if (definition != null && definition.ReadOnly && (editor.Editor.EditMode == PropertyEditorMode.Edit))
                {
                    PortalSettings ps = PortalController.Instance.GetCurrentPortalSettings();
                    if (!PortalSecurity.IsInRole(ps.AdministratorRoleName))
                    {
                        editor.Editor.EditMode = PropertyEditorMode.View;
                    }
                }

                //We need to wire up the RegionControl to the CountryControl
                if (editor.Editor is DNNRegionEditControl)
                {
                    string country = null;

                    foreach (FieldEditorControl checkEditor in Fields)
                    {
                        if (checkEditor.Editor is DNNCountryEditControl)
                        {
                            if (editor.Editor.Category == checkEditor.Editor.Category)
                            {
                                var countryEdit = (DNNCountryEditControl)checkEditor.Editor;
                                country = Convert.ToString(countryEdit.Value);
                            }
                        }
                    }

                    //Create a ListAttribute for the Region
                    string countryKey = "Unknown";
                    int    entryId;
                    if (int.TryParse(country, out entryId))
                    {
                        ListController lc   = new ListController();
                        ListEntryInfo  item = lc.GetListEntryInfo(entryId);
                        if (item != null)
                        {
                            countryKey = item.Value;
                        }
                    }
                    countryKey = "Country." + countryKey;
                    var attributes = new object[1];
                    attributes[0] = new ListAttribute("Region", countryKey, ListBoundField.Id, ListBoundField.Text);
                    editor.Editor.CustomAttributes = attributes;
                }
            }
        }
Ejemplo n.º 3
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            cmdPurchase.Click += cmdPurchase_Click;
            cmdCancel.Click   += cmdCancel_Click;

            try
            {
                double dblTotal;
                string strCurrency;

                if ((Request.QueryString["RoleID"] != null))
                {
                    RoleID = Int32.Parse(Request.QueryString["RoleID"]);
                }
                if (Page.IsPostBack == false)
                {
                    if (RoleID != -1)
                    {
                        RoleInfo objRole = RoleController.Instance.GetRole(PortalSettings.PortalId, r => r.RoleID == RoleID);

                        if (objRole.RoleID != -1)
                        {
                            lblServiceName.Text = objRole.RoleName;
                            if (!Null.IsNull(objRole.Description))
                            {
                                lblDescription.Text = objRole.Description;
                            }
                            if (RoleID == PortalSettings.AdministratorRoleId)
                            {
                                if (!Null.IsNull(PortalSettings.HostFee))
                                {
                                    lblFee.Text = PortalSettings.HostFee.ToString("#,##0.00");
                                }
                            }
                            else
                            {
                                if (!Null.IsNull(objRole.ServiceFee))
                                {
                                    lblFee.Text = objRole.ServiceFee.ToString("#,##0.00");
                                }
                            }
                            if (!Null.IsNull(objRole.BillingFrequency))
                            {
                                var           ctlEntry = new ListController();
                                ListEntryInfo entry    = ctlEntry.GetListEntryInfo("Frequency", objRole.BillingFrequency);
                                lblFrequency.Text = entry.Text;
                            }
                            txtUnits.Text = "1";
                            if (objRole.BillingFrequency == "O") //one-time fee
                            {
                                txtUnits.Enabled = false;
                            }
                        }
                        else //security violation attempt to access item not related to this Module
                        {
                            Response.Redirect(_navigationManager.NavigateURL(), true);
                        }
                    }

                    //Store URL Referrer to return to portal
                    if (Request.UrlReferrer != null)
                    {
                        ViewState["UrlReferrer"] = Convert.ToString(Request.UrlReferrer);
                    }
                    else
                    {
                        ViewState["UrlReferrer"] = "";
                    }
                }
                if (RoleID == PortalSettings.AdministratorRoleId)
                {
                    strCurrency = Host.HostCurrency;
                }
                else
                {
                    strCurrency = PortalSettings.Currency;
                }
                dblTotal      = Convert.ToDouble(lblFee.Text) * Convert.ToDouble(txtUnits.Text);
                lblTotal.Text = dblTotal.ToString("#.##");

                lblFeeCurrency.Text   = strCurrency;
                lblTotalCurrency.Text = strCurrency;
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Ejemplo n.º 4
0
        protected void Page_Load(Object sender, EventArgs e)
        {
            try
            {
                double dblTotal;
                string strCurrency;

                if ((Request.QueryString["RoleID"] != null))
                {
                    RoleID = int.Parse(Request.QueryString["RoleID"]);
                }

                if (Page.IsPostBack == false)
                {
                    RoleController objRoles = new RoleController();

                    if (RoleID != -1)
                    {
                        RoleInfo objRole = objRoles.GetRole(RoleID, PortalSettings.PortalId);

                        if (objRole.RoleID != -1)
                        {
                            lblServiceName.Text = objRole.RoleName;
                            if (!Null.IsNull(objRole.Description))
                            {
                                lblDescription.Text = objRole.Description;
                            }
                            if (RoleID == PortalSettings.AdministratorRoleId)
                            {
                                if (!Null.IsNull(PortalSettings.HostFee))
                                {
                                    lblFee.Text = string.Format("{0:#,##0.00}", PortalSettings.HostFee);
                                }
                            }
                            else
                            {
                                if (!Null.IsNull(objRole.ServiceFee))
                                {
                                    lblFee.Text = string.Format("{0:#,##0.00}", objRole.ServiceFee);
                                }
                            }
                            if (!Null.IsNull(objRole.BillingFrequency))
                            {
                                ListController ctlEntry = new ListController();
                                ListEntryInfo  entry    = ctlEntry.GetListEntryInfo("Frequency", objRole.BillingFrequency);
                                lblFrequency.Text = entry.Text;
                            }
                            txtUnits.Text = "1";
                            if (objRole.BillingFrequency == "1")  // one-time fee
                            {
                                txtUnits.Enabled = false;
                            }
                        }
                        else // security violation attempt to access item not related to this Module
                        {
                            Response.Redirect(Globals.NavigateURL(), true);
                        }
                    }

                    // Store URL Referrer to return to portal
                    if (Request.UrlReferrer != null)
                    {
                        ViewState["UrlReferrer"] = Convert.ToString(Request.UrlReferrer);
                    }
                    else
                    {
                        ViewState["UrlReferrer"] = "";
                    }
                }

                if (RoleID == PortalSettings.AdministratorRoleId)
                {
                    strCurrency = Convert.ToString(Globals.HostSettings["HostCurrency"]);
                }
                else
                {
                    strCurrency = PortalSettings.Currency;
                }

                dblTotal      = Convert.ToDouble(lblFee.Text) * Convert.ToDouble(txtUnits.Text);
                lblTotal.Text = string.Format("{0:#,##0.00}", dblTotal);

                lblFeeCurrency.Text   = strCurrency;
                lblTotalCurrency.Text = strCurrency;
            }
            catch (Exception exc)  //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Ejemplo n.º 5
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The GetInstaller method instantiates the relevant Component Installer
        /// </summary>
        /// <param name="installerType">The type of Installer</param>
        /// -----------------------------------------------------------------------------
        public static ComponentInstallerBase GetInstaller(string installerType)
        {
            ComponentInstallerBase installer = null;

            switch (installerType)
            {
            case "File":
                installer = new FileInstaller();
                break;

            case "Assembly":
                installer = new AssemblyInstaller();
                break;

            case "ResourceFile":
                installer = new ResourceFileInstaller();
                break;

            case "AuthenticationSystem":
            case "Auth_System":
                installer = new AuthenticationInstaller();
                break;

            case "Script":
                installer = new ScriptInstaller();
                break;

            case "Config":
                installer = new ConfigInstaller();
                break;

            case "Cleanup":
                installer = new CleanupInstaller();
                break;

            case "Skin":
                installer = new SkinInstaller();
                break;

            case "Container":
                installer = new ContainerInstaller();
                break;

            case "Module":
                installer = new ModuleInstaller();
                break;

            case "CoreLanguage":
                installer = new LanguageInstaller(LanguagePackType.Core);
                break;

            case "ExtensionLanguage":
                installer = new LanguageInstaller(LanguagePackType.Extension);
                break;

            case "Provider":
                installer = new ProviderInstaller();
                break;

            case "SkinObject":
                installer = new SkinControlInstaller();
                break;

            case "UrlProvider":
                installer = new UrlProviderInstaller();
                break;

            case "Widget":
                installer = new WidgetInstaller();
                break;

            case "JavaScript_Library":
                installer = new JavaScriptLibraryInstaller();
                break;

            case "JavaScriptFile":
                installer = new JavaScriptFileInstaller();
                break;

            default:
                //Installer type is defined in the List
                var           listController = new ListController();
                ListEntryInfo entry          = listController.GetListEntryInfo("Installer", installerType);

                if (entry != null && !string.IsNullOrEmpty(entry.Text))
                {
                    //The class for the Installer is specified in the Text property
                    installer = (ComponentInstallerBase)Reflection.CreateObject(entry.Text, "Installer_" + entry.Value);
                }
                break;
            }
            return(installer);
        }
Ejemplo n.º 6
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Searches for and indexes modified users for the given portal.
        /// </summary>
        /// <returns>Count of indexed records</returns>
        /// -----------------------------------------------------------------------------
        public override int IndexSearchDocuments(int portalId,
                                                 ScheduleHistoryItem schedule, DateTime startDateLocal, Action <IEnumerable <SearchDocument> > indexer)
        {
            Requires.NotNull("indexer", indexer);
            const int saveThreshold      = BatchSize;
            var       totalIndexed       = 0;
            var       checkpointModified = false;

            startDateLocal = GetLocalTimeOfLastIndexedItem(portalId, schedule.ScheduleID, startDateLocal);
            var searchDocuments = new Dictionary <string, SearchDocument>();

            var needReindex = PortalController.GetPortalSettingAsBoolean(UserIndexResetFlag, portalId, false);

            if (needReindex)
            {
                startDateLocal = SqlDateTime.MinValue.Value.AddDays(1);
            }

            var controller       = new ListController();
            var textDataType     = controller.GetListEntryInfo("DataType", "Text");
            var richTextDataType = controller.GetListEntryInfo("DataType", "RichText");

            var profileDefinitions = ProfileController.GetPropertyDefinitionsByPortal(portalId, false, false)
                                     .Cast <ProfilePropertyDefinition>()
                                     .Where(d => (textDataType != null && d.DataType == textDataType.EntryID) ||
                                            (richTextDataType != null && d.DataType == richTextDataType.EntryID))
                                     .ToList();

            try
            {
                int startUserId;
                var checkpointData = GetLastCheckpointData(portalId, schedule.ScheduleID);
                if (string.IsNullOrEmpty(checkpointData) || !int.TryParse(checkpointData, out startUserId))
                {
                    startUserId = Null.NullInteger;
                }

                int         rowsAffected;
                IList <int> indexedUsers;
                do
                {
                    rowsAffected = FindModifiedUsers(portalId, startDateLocal,
                                                     searchDocuments, profileDefinitions, out indexedUsers, ref startUserId);

                    if (rowsAffected > 0 && searchDocuments.Count >= saveThreshold)
                    {
                        //remove existing indexes
                        DeleteDocuments(portalId, indexedUsers);
                        var values = searchDocuments.Values;
                        totalIndexed += IndexCollectedDocs(indexer, values);
                        SetLastCheckpointData(portalId, schedule.ScheduleID, startUserId.ToString());
                        SetLocalTimeOfLastIndexedItem(portalId, schedule.ScheduleID, values.Last().ModifiedTimeUtc.ToLocalTime());
                        searchDocuments.Clear();
                        checkpointModified = true;
                    }
                } while (rowsAffected > 0);

                if (searchDocuments.Count > 0)
                {
                    //remove existing indexes
                    DeleteDocuments(portalId, indexedUsers);
                    var values = searchDocuments.Values;
                    totalIndexed      += IndexCollectedDocs(indexer, values);
                    checkpointModified = true;
                }

                if (needReindex)
                {
                    PortalController.DeletePortalSetting(portalId, UserIndexResetFlag);
                }
            }
            catch (Exception ex)
            {
                checkpointModified = false;
                Exceptions.Exceptions.LogException(ex);
            }

            if (checkpointModified)
            {
                // at last reset start user pointer
                SetLastCheckpointData(portalId, schedule.ScheduleID, Null.NullInteger.ToString());
                SetLocalTimeOfLastIndexedItem(portalId, schedule.ScheduleID, DateTime.Now);
            }
            return(totalIndexed);
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Returns the collection of SearchDocuments populated with Tab MetaData for the given portal.
        /// </summary>
        /// <param name="portalId"></param>
        /// <param name="startDateLocal"></param>
        /// <returns></returns>
        /// <history>
        ///     [vnguyen]   04/16/2013  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public override IEnumerable <SearchDocument> GetSearchDocuments(int portalId, DateTime startDateLocal)
        {
            var searchDocuments = new Dictionary <string, SearchDocument>();

            var needReindex = PortalController.GetPortalSettingAsBoolean(UserIndexResetFlag, portalId, false);

            if (needReindex)
            {
                startDateLocal = SqlDateTime.MinValue.Value.AddDays(1);
            }

            var controller       = new ListController();
            var textDataType     = controller.GetListEntryInfo("DataType", "Text");
            var richTextDataType = controller.GetListEntryInfo("DataType", "RichText");

            var profileDefinitions = ProfileController.GetPropertyDefinitionsByPortal(portalId, false, false)
                                     .Cast <ProfilePropertyDefinition>()
                                     .Where(d => (textDataType != null && d.DataType == textDataType.EntryID) ||
                                            (richTextDataType != null && d.DataType == richTextDataType.EntryID)).ToList();

            try
            {
                var startUserId = Null.NullInteger;
                while (true)
                {
                    var reader = DataProvider.Instance()
                                 .GetAvailableUsersForIndex(portalId, startDateLocal, startUserId, BatchSize);
                    int rowsAffected = 0;
                    var indexedUsers = new List <int>();

                    while (reader.Read())
                    {
                        var userSearch = GetUserSearch(reader);
                        AddBasicInformation(searchDocuments, indexedUsers, userSearch, portalId);

                        //log the userid so that it can get the correct user collection next time.
                        if (userSearch.UserId > startUserId)
                        {
                            startUserId = userSearch.UserId;
                        }

                        foreach (var definition in profileDefinitions)
                        {
                            var propertyName = definition.PropertyName;

                            if (!ContainsColumn(propertyName, reader))
                            {
                                continue;
                            }

                            var propertyValue = reader[propertyName].ToString();

                            if (string.IsNullOrEmpty(propertyValue) || !propertyValue.Contains(ValueSplitFlag))
                            {
                                continue;
                            }

                            var splitValues = Regex.Split(propertyValue, Regex.Escape(ValueSplitFlag));

                            propertyValue = splitValues[0];
                            var visibilityMode     = ((UserVisibilityMode)Convert.ToInt32(splitValues[1]));
                            var extendedVisibility = splitValues[2];
                            var modifiedTime       = Convert.ToDateTime(splitValues[3]).ToUniversalTime();

                            if (string.IsNullOrEmpty(propertyValue))
                            {
                                continue;
                            }

                            var uniqueKey = string.Format("{0}_{1}", userSearch.UserId, visibilityMode).ToLowerInvariant();
                            if (visibilityMode == UserVisibilityMode.FriendsAndGroups)
                            {
                                uniqueKey = string.Format("{0}_{1}", uniqueKey, extendedVisibility);
                            }

                            if (searchDocuments.ContainsKey(uniqueKey))
                            {
                                var document = searchDocuments[uniqueKey];
                                document.Keywords.Add(propertyName, propertyValue);

                                if (modifiedTime > document.ModifiedTimeUtc)
                                {
                                    document.ModifiedTimeUtc = modifiedTime;
                                }
                            }
                            else
                            {
                                //Need remove use exists index for all visibilities.
                                if (!indexedUsers.Contains(userSearch.UserId))
                                {
                                    indexedUsers.Add(userSearch.UserId);
                                }

                                if (!string.IsNullOrEmpty(propertyValue))
                                {
                                    var searchDoc = new SearchDocument
                                    {
                                        SearchTypeId    = UserSearchTypeId,
                                        UniqueKey       = uniqueKey,
                                        PortalId        = portalId,
                                        ModifiedTimeUtc = modifiedTime,
                                        Description     = userSearch.FirstName,
                                        Title           = userSearch.DisplayName
                                    };
                                    searchDoc.Keywords.Add(propertyName, propertyValue);
                                    searchDoc.NumericKeys.Add("superuser", Convert.ToInt32(userSearch.SuperUser));
                                    searchDocuments.Add(uniqueKey, searchDoc);
                                }
                            }
                        }

                        rowsAffected++;
                    }

                    //close the data reader
                    reader.Close();

                    //remov exists indexes
                    DeleteDocuments(portalId, indexedUsers);

                    if (rowsAffected == 0)
                    {
                        break;
                    }
                }

                if (needReindex)
                {
                    PortalController.DeletePortalSetting(portalId, UserIndexResetFlag);
                }
            }
            catch (Exception ex)
            {
                Exceptions.Exceptions.LogException(ex);
            }

            return(searchDocuments.Values);
        }
Ejemplo n.º 8
0
        /// <summary>
        ///     Handles cmdSaveEntry.Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        ///     Using "CommandName" property of cmdSaveEntry to determine action to take (ListUpdate/AddEntry/AddList)
        /// </remarks>
        protected void OnSaveEntryClick(object sender, EventArgs e)
        {
            string entryValue;
            string entryText;

            if (UserInfo.IsSuperUser)
            {
                entryValue = txtEntryValue.Text;
                entryText  = txtEntryText.Text;
            }
            else
            {
                var ps = new PortalSecurity();

                entryValue = ps.InputFilter(txtEntryValue.Text, PortalSecurity.FilterFlag.NoScripting);
                entryText  = ps.InputFilter(txtEntryText.Text, PortalSecurity.FilterFlag.NoScripting);
            }
            var listController = new ListController();
            var listName       = string.IsNullOrEmpty(ListName) ? txtEntryName.Text : (!string.IsNullOrEmpty(ParentKey) ? ParentKey + ":" : string.Empty) + ListName;
            var entry          = new ListEntryInfo();

            {
                entry.DefinitionID = Null.NullInteger;
                entry.PortalID     = ListPortalID;
                entry.ListName     = listName;
                entry.Value        = entryValue;
                entry.Text         = entryText;
            }
            if (Page.IsValid)
            {
                Mode = "ListEntries";
                switch (cmdSaveEntry.CommandName.ToLower())
                {
                case "update":
                    entry.ListName  = ListName;
                    entry.ParentKey = SelectedList.ParentKey;
                    entry.EntryID   = int.Parse(txtEntryID.Text);
                    bool canUpdate = true;
                    foreach (var curEntry in listController.GetListEntryInfoItems(SelectedList.Name, entry.ParentKey, entry.PortalID))
                    {
                        if (entry.EntryID != curEntry.EntryID)                                 //not the same item we are trying to update
                        {
                            if (entry.Value == curEntry.Value)
                            {
                                Skin.AddModuleMessage(this, Localization.GetString("ItemAlreadyPresent", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                                canUpdate = false;
                                break;
                            }
                        }
                    }

                    if (canUpdate)
                    {
                        listController.UpdateListEntry(entry);
                        DataBind();
                    }
                    break;

                case "saveentry":
                    if (SelectedList != null)
                    {
                        entry.ParentKey = SelectedList.ParentKey;
                        entry.ParentID  = SelectedList.ParentID;
                        entry.Level     = SelectedList.Level;
                    }
                    if (chkEnableSortOrder.Checked)
                    {
                        entry.SortOrder = 1;
                    }
                    else
                    {
                        entry.SortOrder = 0;
                    }

                    if (listController.AddListEntry(entry) == Null.NullInteger)                     //entry already found in database
                    {
                        Skin.AddModuleMessage(this, Localization.GetString("ItemAlreadyPresent", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                        Mode = "AddEntry";
                    }
                    else
                    {
                        DataBind();
                    }

                    break;

                case "savelist":
                    if (ddlSelectParent.SelectedIndex != -1)
                    {
                        int           parentID    = int.Parse(ddlSelectParent.SelectedItem.Value);
                        ListEntryInfo parentEntry = listController.GetListEntryInfo(parentID);
                        entry.ParentID     = parentID;
                        entry.DefinitionID = parentEntry.DefinitionID;
                        entry.Level        = parentEntry.Level + 1;
                        entry.ParentKey    = parentEntry.Key;
                    }
                    if (chkEnableSortOrder.Checked)
                    {
                        entry.SortOrder = 1;
                    }
                    else
                    {
                        entry.SortOrder = 0;
                    }

                    if (listController.AddListEntry(entry) == Null.NullInteger)                             //entry already found in database
                    {
                        Skin.AddModuleMessage(this, Localization.GetString("ItemAlreadyPresent", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                    }
                    else
                    {
                        SelectedKey = entry.ParentKey.Replace(":", ".") + ":" + entry.ListName;
                        Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId, "", "Key=" + SelectedKey));
                    }
                    break;
                }
            }
        }
 /// <summary>
 /// This methods return the text description of the Frequency value
 /// </summary>
 /// <param name="value">value of the Frequency</param>
 /// <returns>text of the Frequency</returns>
 private string GetBillingFrequencyText(string value)
 {
     var ctlEntry = new ListController();
     ListEntryInfo entry = ctlEntry.GetListEntryInfo("Frequency", value);
     return entry.Text;
 }
Ejemplo n.º 10
0
        public static ComponentInstallerBase GetInstaller(string installerType)
        {
            ComponentInstallerBase installer = null;

            switch (installerType)
            {
            case "File":
                installer = new FileInstaller();
                break;

            case "Assembly":
                installer = new AssemblyInstaller();
                break;

            case "ResourceFile":
                installer = new ResourceFileInstaller();
                break;

            case "AuthenticationSystem":
            case "Auth_System":
                installer = new AuthenticationInstaller();
                break;

            case "DashboardControl":
                installer = new DashboardInstaller();
                break;

            case "Script":
                installer = new ScriptInstaller();
                break;

            case "Config":
                installer = new ConfigInstaller();
                break;

            case "Cleanup":
                installer = new CleanupInstaller();
                break;

            case "Skin":
                installer = new SkinInstaller();
                break;

            case "Container":
                installer = new ContainerInstaller();
                break;

            case "Module":
                installer = new ModuleInstaller();
                break;

            case "CoreLanguage":
                installer = new LanguageInstaller(LanguagePackType.Core);
                break;

            case "ExtensionLanguage":
                installer = new LanguageInstaller(LanguagePackType.Extension);
                break;

            case "Provider":
                installer = new ProviderInstaller();
                break;

            case "SkinObject":
                installer = new SkinControlInstaller();
                break;

            case "Widget":
                installer = new WidgetInstaller();
                break;

            default:
                ListController listController = new ListController();
                ListEntryInfo  entry          = listController.GetListEntryInfo("Installer", installerType);
                if (entry != null && !string.IsNullOrEmpty(entry.Text))
                {
                    installer = (ComponentInstallerBase)Reflection.CreateObject(entry.Text, "Installer_" + entry.Value);
                }
                break;
            }
            return(installer);
        }