Esempio n. 1
0
        private string GetDiscountValueById(int orderID)
        {
            var ev = new EventLogProvider();

            try
            {
                string discountCouponValue = string.Empty;
                string sql = "SELECT [DiscountCouponID],[DiscountCouponValue] FROM [COM_DiscountCoupon] " +
                             "INNER JOIN [COM_Order] ON [COM_Order].[OrderDiscountCouponID] = [COM_DiscountCoupon].[DiscountCouponID] " +
                             "WHERE [COM_Order].[OrderID] = @orderID";
                var param = new QueryDataParameters();
                param.Add(new DataParameter("@orderID", orderID));
                DataSet ds = ConnectionHelper.ExecuteQuery(sql, param, QueryTypeEnum.SQLQuery);
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    foreach (DataRow reader in ds.Tables[0].Rows)
                    {
                        discountCouponValue = ValidationHelper.GetString(reader["DiscountCouponValue"], string.Empty);
                        return(discountCouponValue);
                    }
                }
                return(discountCouponValue);
            }
            catch (Exception ex)
            {
                CMS.EventLog.EventLogProvider.LogEvent("E", "", "", ex.Message, "CMSModuleLoader.GetDiscountValueById", 0, "", 0, "", "", 0, "", "", "", DateTime.Now);
                // ev.LogEvent("E", DateTime.Now, "CMSModuleLoader.GetDiscountValueById", ex.Message);
            }
            return(null);
        }
Esempio n. 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        siteId = CMSContext.CurrentSiteID;

        emailsEnabled  = EmailHelper.Settings.EmailsEnabled(CMSContext.CurrentSiteName);
        emailsEnabled |= SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSGenerateNewsletters");

        // Display disabled information
        if (!emailsEnabled)
        {
            ShowWarning(GetString("NewsletterEmailQueue_List.EmailsDisabled"), null, null);
        }

        // Initialize unigrid
        gridElem.OnAction            += new OnActionEventHandler(gridElem_OnAction);
        gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound);
        gridElem.WhereCondition       = "EmailSiteID = @SiteID";

        QueryDataParameters parameters = new QueryDataParameters();

        parameters.Add("@SiteID", siteId);

        gridElem.QueryParameters = parameters;

        InitializeActionMenu();
    }
Esempio n. 3
0
        private List <int> GetSkuidByCustomerId(int shopcartcustomerid)
        {
            var ev = new EventLogProvider();

            try
            {
                List <int> list = null;
                string     sql  = "SELECT [SKUID]  FROM [COM_ShoppingCartSKU] as ss";
                sql += " INNER JOIN [COM_ShoppingCart] as s";
                sql += " ON s.[ShoppingCartID] = ss.[ShoppingCartID]";
                sql += " WHERE s.[ShoppingCartCustomerID] = @shopcartcustomerid";
                var param = new QueryDataParameters();
                param.Add(new DataParameter("@shopcartcustomerid", shopcartcustomerid));
                DataSet ds = ConnectionHelper.ExecuteQuery(sql, param, QueryTypeEnum.SQLQuery);
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    list = new List <int>();
                    foreach (DataRow reader in ds.Tables[0].Rows)
                    {
                        int sku = ValidationHelper.GetInteger(reader["SKUID"], 0);
                        list.Add(sku);
                    }
                }
                return(list);
            }
            catch (Exception ex)
            {
                CMS.EventLog.EventLogProvider.LogEvent("E", "", "", ex.Message, "CMSModuleLoader.GetSkuidByUserId", 0, "", 0, "", "", 0, "", "", "", DateTime.Now);
                //   ev.LogEvent("E", DateTime.Now, "CMSModuleLoader.GetSkuidByUserId", ex.Message);
            }
            return(null);
        }
Esempio n. 4
0
        private string GetSkuProductTypeBySkuId(int skuid)
        {
            var ev = new EventLogProvider();

            try
            {
                string typeproduct = string.Empty;
                string sql         = "SELECT [SKUID],[SKUProductType] FROM [COM_SKU] WHERE skuid = @skuid";
                var    param       = new QueryDataParameters();
                param.Add(new DataParameter("@skuid", skuid));
                DataSet ds = ConnectionHelper.ExecuteQuery(sql, param, QueryTypeEnum.SQLQuery);
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    foreach (DataRow reader in ds.Tables[0].Rows)
                    {
                        typeproduct = ValidationHelper.GetString(reader["SKUProductType"], string.Empty);
                        return(typeproduct);
                    }
                }
                return(typeproduct);
            }
            catch (Exception ex)
            {
                CMS.EventLog.EventLogProvider.LogEvent("E", "", "", ex.Message, "CMSModuleLoader.GetSkuProductTypeBySkuId", 0, "", 0, "", "", 0, "", "", "", DateTime.Now);
                // ev.LogEvent("E", DateTime.Now, "CMSModuleLoader.GetSkuProductTypeBySkuId", ex.Message);
            }
            return(null);
        }
    private void SetWhereCondition()
    {
        // Check existence of CMS.BookingEvent dataclass
        if (DataClassInfoProvider.GetDataClassInfo("CMS.BookingEvent") != null)
        {
            gridElem.WhereCondition = "(NodeLinkedNodeID IS NULL AND NodeSiteID = " + CurrentSiteInfo.SiteID + ")";

            // Filter time interval
            if (EventScope == "all")
            {
                return;
            }

            string conditionOperator = (EventScope == "upcoming") ? ">=" : "<=";
            gridElem.WhereCondition = SqlHelper.AddWhereCondition(gridElem.WhereCondition, String.Format("EventDate {0} @Date", conditionOperator));

            QueryDataParameters parameters = new QueryDataParameters();
            parameters.Add("@Date", DateTime.Now);

            gridElem.QueryParameters = parameters;
        }
        else
        {
            // Document type with code name 'CMS.BookingEvent' does not exist
            ShowError(GetString("Events_List.NoBookingEventClass"));
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        this.CurrentMaster.Title.TitleText = GetString("newsletter_issue_openedby.title");
        this.CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Newsletter/module.png");

        issueId = QueryHelper.GetInteger("issueid", 0);
        if (issueId == 0)
        {
            RequestHelper.EndResponse();
        }

        // Filter by Issue ID (from querystring)
        QueryDataParameters parameters = new QueryDataParameters();
        parameters.Add("@IssueID", issueId);

        UniGrid.QueryParameters = parameters;

        // Filter by Site ID to prevent accessing issues from sites other than current site
        string whereCondition = SqlHelperClass.GetWhereCondition("SiteID", CMSContext.CurrentSiteID);

        UniGrid.WhereCondition = SqlHelperClass.AddWhereCondition(whereCondition, fltOpenedBy.WhereCondition);
        UniGrid.Pager.DefaultPageSize = 15;
        UniGrid.Pager.ShowPageSize = false;
        UniGrid.FilterLimit = 1;
        UniGrid.OnExternalDataBound += UniGrid_OnExternalDataBound;
    }
    /// <summary>
    /// Returns where condition.
    /// </summary>
    private string GetWhereCondition()
    {
        String where = String.Empty;

        if (!dtpFrom.IsValidRange() || !dtpTo.IsValidRange())
        {
            ShowError(GetString("general.errorinvaliddatetimerange"));
            return(String.Empty);
        }

        where = SqlHelperClass.AddWhereCondition(where, tsfFrom.GetCondition());
        where = SqlHelperClass.AddWhereCondition(where, tsfSource.GetCondition());

        mParameters = new QueryDataParameters();

        DateTime from = dtpFrom.SelectedDateTime;
        DateTime to   = dtpTo.SelectedDateTime;

        if (from != DateTimeHelper.ZERO_TIME)
        {
            where = SqlHelperClass.AddWhereCondition(where, "ABTestOpenFrom > @from");

            mParameters.Add("@from", from);
        }

        if (to != DateTimeHelper.ZERO_TIME)
        {
            where = SqlHelperClass.AddWhereCondition(where, "ABTestOpenTo < @to");

            mParameters.Add("@to", to);
        }

        return(where);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        ci = (ContactInfo)EditedObject;
        if (ci == null)
        {
            RedirectToAccessDenied(GetString("general.invalidparameters"));
        }

        modifyAllowed = AuthorizationHelper.AuthorizedModifyContact(false);

        contactId = QueryHelper.GetInteger("contactid", 0);

        gridElem.ObjectType = ContactMembershipCustomerListInfo.OBJECT_TYPE;

        // Query parameters
        QueryDataParameters parameters = new QueryDataParameters();

        parameters.Add("@ContactId", contactId);

        gridElem.QueryParameters      = parameters;
        gridElem.OnAction            += gridElem_OnAction;
        gridElem.OnExternalDataBound += gridElem_OnExternalDataBound;

        // Hide header actions for global contact or merged contact.
        CurrentMaster.HeaderActionsPlaceHolder.Visible = modifyAllowed;
    }
Esempio n. 9
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        string Query = "update [servranx].[dbo].[CMS_Class] set [ClassShowAsSystemTable] = 1 where ClassName = 'ecommerce.address'";
        QueryDataParameters parameters = new QueryDataParameters();

        ConnectionHelper.ExecuteQuery(Query, parameters, QueryTypeEnum.SQLQuery, true);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        int currentUi = MembershipContext.AuthenticatedUser.UserID;

        var currentCust = CustomerInfoProvider.GetCustomerInfoByUserID(currentUi);

        if (currentCust != null)
        {
            const string query = "SELECT [OrderID] FROM [COM_Order] WHERE [OrderCustomerID] = @customerid";
            var          param = new QueryDataParameters();
            param.Add(new DataParameter("@customerid", currentCust.CustomerID));
            DataSet ds = ConnectionHelper.ExecuteQuery(query, param, QueryTypeEnum.SQLQuery);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                var list = new List <ProductModel>();
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    int orderId = ValidationHelper.GetInteger(row["OrderID"], 0);
                    if (orderId > 0)
                    {
                        var pdt = GetDownLoadFile(orderId);
                        if (pdt != null)
                        {
                            list.Add(pdt);
                        }
                    }
                }

                List = list;
            }
        }
    }
    /// <summary>
    /// Returns contact's points in specified score on current site.
    /// </summary>
    /// <param name="contact">Contact info object</param>
    /// <param name="scoreName">Score name</param>
    public static int GetScore(object contact, object scoreName)
    {
        ContactInfo ci = (ContactInfo)contact;
        string score = ValidationHelper.GetString(scoreName, string.Empty);
        int siteId = CMSContext.CurrentSiteID;

        if ((ci != null) && (siteId > 0) && (!string.IsNullOrEmpty(score)))
        {
            // Prepare DB query
            QueryDataParameters parameters = new QueryDataParameters();
            parameters.Add("@ContactID", ci.ContactID);
            parameters.Add("@ScoreName", score);
            parameters.Add("@SiteID", siteId);

            string where = "(Expiration IS NULL OR Expiration > GetDate()) AND (ContactID=@ContactID) AND (ScoreName=@ScoreName) AND (ScoreSiteID=@SiteID)";

            // Get sum of points of the contact in specified score
            DataSet ds = SqlHelperClass.ExecuteQuery("om.score.selectdatajoined", parameters, "SUM(Value) AS Score", where, null, -1);

            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                return ValidationHelper.GetInteger(ds.Tables[0].Rows[0][0], 0);
            }
        }

        return 0;
    }
Esempio n. 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        QueryDataParameters parameters = new QueryDataParameters();

        parameters.Add("@ContactID", ContactID);

        // Choose correct object type ("query") according to contact type
        if (IsGlobalContact)
        {
            gridElem.ObjectType = OnlineMarketingObjectType.IPGLOBALLIST;
        }
        else if (IsMergedContact)
        {
            gridElem.ObjectType = OnlineMarketingObjectType.IPMERGEDLIST;
        }
        else
        {
            gridElem.ObjectType = OnlineMarketingObjectType.IPLIST;
        }
        gridElem.QueryParameters      = parameters;
        gridElem.WhereCondition       = WhereCondition;
        gridElem.ZeroRowsText         = GetString("om.ip.noips");
        gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound);
        gridElem.OnAction            += new OnActionEventHandler(gridElem_OnAction);
    }
Esempio n. 13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckUIElementAccessHierarchical(ModuleName.ONLINEMARKETING, "ContactMembership.Subscribers");
        ci = (ContactInfo)EditedObject;
        if (ci == null)
        {
            RedirectToAccessDenied(GetString("general.invalidparameters"));
        }

        CheckReadPermission(ci.ContactSiteID);

        globalContact = (ci.ContactSiteID <= 0);
        mergedContact = (ci.ContactMergedWithContactID > 0);
        modifyAllowed = ContactHelper.AuthorizedModifyContact(ci.ContactSiteID, false);

        contactId = QueryHelper.GetInteger("contactid", 0);

        string where = null;
        // Filter only site members in CMSDesk (for global contacts)
        if (!IsSiteManager && globalContact && AuthorizedForSiteContacts)
        {
            where = " (ContactSiteID IS NULL OR ContactSiteID=" + SiteContext.CurrentSiteID + ")";
        }

        // Choose correct object ("query") according to type of contact
        if (globalContact)
        {
            gridElem.ObjectType = ContactMembershipGlobalSubscriberListInfo.OBJECT_TYPE;
        }
        else if (mergedContact)
        {
            gridElem.ObjectType = ContactMembershipMergedSubscriberListInfo.OBJECT_TYPE;
        }
        else
        {
            gridElem.ObjectType = ContactMembershipSubscriberListInfo.OBJECT_TYPE;
        }

        // Query parameters
        QueryDataParameters parameters = new QueryDataParameters();

        parameters.Add("@ContactId", contactId);

        gridElem.WhereCondition       = where;
        gridElem.QueryParameters      = parameters;
        gridElem.OnAction            += gridElem_OnAction;
        gridElem.OnExternalDataBound += gridElem_OnExternalDataBound;

        // Hide header actions for global contact or merged contact.
        CurrentMaster.HeaderActionsPlaceHolder.Visible = modifyAllowed && !globalContact && !mergedContact;

        // Setup subscriber selector
        selectSubscriber.UniSelector.SelectionMode     = SelectionModeEnum.MultipleButton;
        selectSubscriber.UniSelector.OnItemsSelected  += UniSelector_OnItemsSelected;
        selectSubscriber.UniSelector.ReturnColumnName  = "SubscriberID";
        selectSubscriber.UniSelector.DisplayNameFormat = "{%SubscriberFullName%} ({%SubscriberEmail%})";
        selectSubscriber.ShowSiteFilter = false;
        selectSubscriber.IsLiveSite     = false;
        selectSubscriber.SiteID         = ci.ContactSiteID;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckUIElementAccessHierarchical(ModuleName.CONTACTMANAGEMENT, "ContactMembership.Users");
        ci = (ContactInfo)EditedObject;
        if (ci == null)
        {
            RedirectToAccessDenied(GetString("general.invalidparameters"));
        }

        modifyAllowed = AuthorizationHelper.AuthorizedModifyContact(false);

        contactId = QueryHelper.GetInteger("contactid", 0);

        string where = null;

        gridElem.ObjectType = ContactMembershipUserListInfo.OBJECT_TYPE;

        // Query parameters
        QueryDataParameters parameters = new QueryDataParameters();

        parameters.Add("@ContactId", contactId);

        gridElem.WhereCondition       = where;
        gridElem.QueryParameters      = parameters;
        gridElem.OnAction            += gridElem_OnAction;
        gridElem.OnExternalDataBound += gridElem_OnExternalDataBound;

        CurrentMaster.HeaderActionsPlaceHolder.Visible = modifyAllowed;
    }
Esempio n. 15
0
    public string GetDocuments(string date)
    {
        try
        {
            var query =
                @"
SELECT  DocumentLastPublished,DocumentContent, [Description], case when ISNULL(DocumentMenuJavascript, '') = '' then NodeAliasPath  else Replace(Replace(Replace(Replace( Replace(Documentmenujavascript,'window.open(',''),')','') ,'''_blank'';return false;','') ,''',',''),'''','') end as NodeAliasPath ,View_SME_CONTENT_MenuItem_Joined.NodeName,View_SME_CONTENT_MenuItem_Joined.IsSecuredNode ,View_SME_CONTENT_MenuItem_Joined.NodeOwnerFullName,View_SME_CONTENT_MenuItem_Joined.DocumentPageDescription ,View_SME_CONTENT_MenuItem_Joined.DocumentPageKeyWords ,View_SME_CONTENT_MenuItem_Joined.DocumentPageTitle , SearchResultName = CASE View_SME_CONTENT_MenuItem_Joined.DocumentName WHEN '' THEN '/' else DocumentName END
FROM View_SME_CONTENT_MenuItem_Joined 
WHERE 
    SiteName= @SiteName
    AND (Published = 1)  AND ((DocumentSearchExcluded IS NULL) OR (DocumentSearchExcluded = 0))
    AND ClassName in ('CMS.MenuItem','SME.MenuItem')  AND (@IgnoreDate = 1 OR DocumentModifiedWhen   >= @CreatedWhen) 
ORDER BY   DocumentLastPublished,DocumentName ";

            var parameters = new QueryDataParameters();
            parameters.Add("@SiteName", CMS.SiteProvider.SiteContext.CurrentSiteName);

            var createdWhen = DateTime.Now;
            parameters.Add("@IgnoreDate", !DateTime.TryParse(date, out createdWhen), typeof(bool));
            parameters.AddDateTime("@CreatedWhen", createdWhen);

            var ds = CMS.DataEngine.ConnectionHelper.ExecuteQuery(query, parameters, CMS.DataEngine.QueryTypeEnum.SQLQuery);

            return(ds == null ? String.Empty : ds.GetXml());
        }
        catch (Exception ex)
        {
            return(String.Empty);
        }
    }
Esempio n. 16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (PageSize >= 0)
        {
            gridElem.Pager.DefaultPageSize = PageSize;
        }
        gridElem.OrderBy                   = OrderBy;
        gridElem.WhereCondition            = WhereCondition;
        gridElem.OnExternalDataBound      += gridElem_OnExternalDataBound;
        gridElem.GridOptions.ShowSelection = ShowSelection;

        // Set gridelement empty list info text either to set property or default value
        gridElem.ZeroRowsText         = String.IsNullOrEmpty(ZeroRowsText) ? GetString("om.activities.noactivities") : GetString(ZeroRowsText);
        gridElem.FilteredZeroRowsText = String.IsNullOrEmpty(FilteredZeroRowsText) ? GetString("om.activities.noactivities.filtered") : GetString(FilteredZeroRowsText);

        if (ContactID > 0)
        {
            gridElem.Query = "om.activity.selectcontactactivitylist";

            QueryDataParameters parameters = new QueryDataParameters();
            parameters.AddId("@ContactID", ContactID);

            gridElem.QueryParameters = parameters;
        }

        modifyPermission = AuthorizationHelper.AuthorizedManageActivity(SiteContext.CurrentSiteID, false);

        ScriptHelper.RegisterDialogScript(Page);

        string scriptBlock = string.Format(@"
            function ViewDetails(id) {{ modalDialog('{0}' + id, 'ActivityDetails', '900', '950'); return false; }}",
                                           ResolveUrl(@"~/CMSModules/Activities/Pages/Tools/Activities/Activity/Activity_Details.aspx"));

        ScriptHelper.RegisterClientScriptBlock(this, GetType(), "Actions", scriptBlock, true);
    }
Esempio n. 17
0
    protected DataSet gridUsers_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords)
    {
        var parameters = new QueryDataParameters();

        parameters.Add("@search", "%" + txtSearch.Text + "%");
        parameters.Add("@siteID", SiteContext.CurrentSite.SiteID);

        string where = "UserName NOT LIKE N'public'";

        // If user is not global administrator
        if (!MembershipContext.AuthenticatedUser.IsGlobalAdministrator)
        {
            // Do not select hidden users
            where = SqlHelper.AddWhereCondition(where, "((UserIsHidden IS NULL) OR (UserIsHidden=0))");

            // Select only approved users
            where = SqlHelper.AddWhereCondition(where, "((UserWaitingForApproval IS NULL) OR (UserWaitingForApproval = 0))");

            // Select only enabled users
            where = SqlHelper.AddWhereCondition(where, UserInfoProvider.USER_ENABLED_WHERE_CONDITION);
        }

        // Load all users for current site
        if (SiteContext.CurrentSite != null)
        {
            // Public user has no actions
            if (MembershipContext.AuthenticatedUser.IsPublic())
            {
                gridUsers.GridView.Columns[0].Visible = false;
            }
        }

        return(ConnectionHelper.ExecuteQuery("cms.user.finduserinsite", parameters, where, "UserName ASC", currentTopN, "View_CMS_User.UserID,UserName,UserNickName,FullName", currentOffset, currentPageSize, ref totalRecords));
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        this.CurrentMaster.Title.TitleText  = GetString("newsletter_issue_openedby.title");
        this.CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Newsletter/module.png");

        issueId = QueryHelper.GetInteger("issueid", 0);
        if (issueId == 0)
        {
            RequestHelper.EndResponse();
        }

        // Filter by Issue ID (from querystring)
        QueryDataParameters parameters = new QueryDataParameters();

        parameters.Add("@IssueID", issueId);

        UniGrid.QueryParameters = parameters;

        // Filter by Site ID to prevent accessing issues from sites other than current site
        string whereCondition = SqlHelperClass.GetWhereCondition("SiteID", CMSContext.CurrentSiteID);

        UniGrid.WhereCondition        = SqlHelperClass.AddWhereCondition(whereCondition, fltOpenedBy.WhereCondition);
        UniGrid.Pager.DefaultPageSize = 15;
        UniGrid.Pager.ShowPageSize    = false;
        UniGrid.FilterLimit           = 1;
        UniGrid.OnExternalDataBound  += UniGrid_OnExternalDataBound;
    }
Esempio n. 19
0
    protected DataSet gridUsers_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords)
    {
        object[,] searchParams = new object[2, 3];
        searchParams[0, 0]     = "@search";
        searchParams[0, 1]     = "%" + txtSearch.Text + "%";
        searchParams[1, 0]     = "@siteID";
        searchParams[1, 1]     = CMSContext.CurrentSite.SiteID;

        string where = "UserName NOT LIKE N'public'";

        // If user is not global administrator and control is in LiveSite mode
        if (IsLiveSite && !CMSContext.CurrentUser.IsGlobalAdministrator)
        {
            // Do not select hidden users
            where = SqlHelperClass.AddWhereCondition(where, "((UserIsHidden IS NULL) OR (UserIsHidden=0))");

            // Select only approved users
            where = SqlHelperClass.AddWhereCondition(where, "((UserWaitingForApproval IS NULL) OR (UserWaitingForApproval = 0))");

            // Select only enabled users
            where = SqlHelperClass.AddWhereCondition(where, UserInfoProvider.USER_ENABLED_WHERE_CONDITION);
        }

        // Load all users for current site
        if (CMSContext.CurrentSite != null)
        {
            // Public user has no actions
            if (CMSContext.CurrentUser.IsPublic())
            {
                gridUsers.GridView.Columns[0].Visible = false;
            }
        }

        return(ConnectionHelper.ExecuteQuery("cms.user.finduserinsite", QueryDataParameters.FromArray(searchParams), where, "UserName ASC", currentTopN, "View_CMS_User.UserID,UserName,UserNickName,FullName", currentOffset, currentPageSize, ref totalRecords));
    }
Esempio n. 20
0
        public static object GetAllActiveCultures(EvaluationContext context, params object[] parameters)
        {
            //Get the cultures from the cache if they exist
            string strCultures = CacheHelper.GetItem("GetAllActiveCulturesQueryStringCache") as string;

            if (String.IsNullOrWhiteSpace(strCultures))
            {
                //Build Query
                var cultureQuery = new DataQuery("cms.culture.selectsitecultures");
                cultureQuery.AddColumns("CultureCode");
                QueryDataParameters queryParameters = new QueryDataParameters();
                queryParameters.Add("@SiteID", SiteContext.CurrentSiteID);
                cultureQuery.Parameters = queryParameters;

                DataSet cultures = cultureQuery.Result;

                //Store all cultures in a string with each culture separated by |
                if (!DataHelper.DataSourceIsEmpty(cultures))
                {
                    foreach (DataRow culture in cultures.Tables[0].Rows)
                    {
                        strCultures += culture["CultureCode"] + "|";
                    }
                }

                //Remove trailing |
                strCultures = strCultures.Remove(strCultures.Length - 1);

                //Store resulting string in the cache
                CacheHelper.Add("GetAllActiveCulturesQueryStringCache", strCultures, null, DateTime.Now.AddHours(1), System.Web.Caching.Cache.NoSlidingExpiration);
            }

            return(strCultures);
        }
Esempio n. 21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ci = (ContactInfo)EditedObject;
        CheckReadPermission(ci.ContactSiteID);

        globalContact = (ci.ContactSiteID <= 0);
        mergedContact = (ci.ContactMergedWithContactID > 0);
        modifyAllowed = ContactHelper.AuthorizedModifyContact(ci.ContactSiteID, false);

        contactId = QueryHelper.GetInteger("contactid", 0);

        string where = null;
        // Filter only site members in CMSDesk (for global contacts)
        if (!IsSiteManager && globalContact && AuthorizedForSiteContacts)
        {
            where += " (ContactSiteID IS NULL OR ContactSiteID=" + CMSContext.CurrentSiteID + ")";
        }

        // Choose correct object ("query") according to type of contact
        if (globalContact)
        {
            gridElem.ObjectType = OnlineMarketingObjectType.MEMBERSHIPGLOBALCUSTOMERLIST;
        }
        else if (mergedContact)
        {
            gridElem.ObjectType = OnlineMarketingObjectType.MEMBERSHIPMERGEDCUSTOMERLIST;
        }
        else
        {
            gridElem.ObjectType = OnlineMarketingObjectType.MEMBERSHIPCUSTOMERLIST;
        }

        // Query parameters
        QueryDataParameters parameters = new QueryDataParameters();

        parameters.Add("@ContactId", contactId);

        gridElem.WhereCondition       = where;
        gridElem.QueryParameters      = parameters;
        gridElem.OnAction            += new OnActionEventHandler(gridElem_OnAction);
        gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound);

        // Hide header actions for global contact
        CurrentMaster.HeaderActionsPlaceHolder.Visible = modifyAllowed && !globalContact && !mergedContact;

        // Setup customer selector
        try
        {
            ucSelectCustomer = (FormEngineUserControl)Page.LoadUserControl("~/CMSModules/Ecommerce/FormControls/CustomerSelector.ascx");
            ucSelectCustomer.SetValue("Mode", "OnlineMarketing");
            ucSelectCustomer.SetValue("SiteID", ci.ContactSiteID);
            ucSelectCustomer.Changed   += new EventHandler(ucSelectCustomer_Changed);
            ucSelectCustomer.IsLiveSite = false;
            pnlSelectCustomer.Controls.Clear();
            pnlSelectCustomer.Controls.Add(ucSelectCustomer);
        }
        catch
        {
        }
    }
Esempio n. 22
0
    private double GetPriceFromPriceID(int priceID, int countryID, int cartUnit, double vatrate)
    {
        double result = 0;
        QueryDataParameters parameters = new QueryDataParameters();

        parameters.Add("@ShippingUnits", cartUnit);
        parameters.Add("@CountryID", countryID);
        parameters.Add("@VATRate", vatrate);
        string where = string.Format("ItemID={0}", priceID.ToString());
        GeneralConnection cn = ConnectionHelper.GetConnection();
        DataSet           ds = cn.ExecuteQuery("customtable.shippingextension.ShippingCostListByCountry", parameters, where);


        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            foreach (DataRow drow in ds.Tables[0].Rows)
            {
                if ((int)drow["ItemId"] == priceID)
                {
                    result = ValidationHelper.GetDouble(drow["ShippingTotalPrice"], 0);
                    return(result);
                }
            }
        }
        return(result);
    }
Esempio n. 23
0
    /// <summary>
    /// Returns where condition.
    /// </summary>
    private string GetWhereCondition()
    {
        String where = String.Empty;

        if (!dtpFrom.IsValidRange() || !dtpTo.IsValidRange())
        {
            lblError.Text = GetString("general.errorinvaliddatetimerange");
            lblError.Visible = true;
            return String.Empty;
        }

        where = SqlHelperClass.AddWhereCondition(where, tsfFrom.GetCondition());
        where = SqlHelperClass.AddWhereCondition(where, tsfSource.GetCondition());

        mParameters = new QueryDataParameters();

        DateTime from = dtpFrom.SelectedDateTime;
        DateTime to = dtpTo.SelectedDateTime;

        if (from != DateTimeHelper.ZERO_TIME)
        {
            where = SqlHelperClass.AddWhereCondition(where, "ABTestOpenFrom > @from");

            mParameters.Add("@from", from);
        }

        if (to != DateTimeHelper.ZERO_TIME)
        {
            where = SqlHelperClass.AddWhereCondition(where, "ABTestOpenTo < @to");

            mParameters.Add("@to", to);
        }

        return where;
    }
Esempio n. 24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        reminderPopupDialog.Hide();

        // Grid initialization
        gridElem.OnAction              += new OnActionEventHandler(gridElem_OnAction);
        gridElem.OnExternalDataBound   += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound);
        gridElem.GridView.RowDataBound += new GridViewRowEventHandler(GridView_RowDataBound);
        gridElem.GridView.RowCreated   += new GridViewRowEventHandler(GridView_RowCreated);
        gridElem.ZeroRowsText           = GetString("pm.projectstask.notasksfound");
        gridElem.DelayedReload          = true;

        QueryDataParameters parameters = new QueryDataParameters();

        parameters.Add("@Now", DateTime.Now);
        gridElem.QueryParameters = parameters;

        switch (OrderByType)
        {
        case ProjectTaskOrderByEnum.ProjectOrder:
            gridElem.OrderBy = "ProjectTaskProjectOrder";
            break;

        case ProjectTaskOrderByEnum.UserOrder:
            gridElem.OrderBy = "ProjectTaskUserOrder";
            break;
        }

        if (!String.IsNullOrEmpty(OrderBy))
        {
            gridElem.OrderBy += (!String.IsNullOrEmpty(gridElem.OrderBy)) ? ", " : "";
            gridElem.OrderBy += OrderBy;
        }
    }
    /// <summary>
    /// Returns contact's points in specified score on current site.
    /// </summary>
    /// <param name="contact">Contact info object</param>
    /// <param name="scoreName">Score name</param>
    public static int GetScore(object contact, object scoreName)
    {
        ContactInfo ci     = (ContactInfo)contact;
        string      score  = ValidationHelper.GetString(scoreName, string.Empty);
        int         siteId = CMSContext.CurrentSiteID;

        if ((ci != null) && (siteId > 0) && (!string.IsNullOrEmpty(score)))
        {
            // Prepare DB query
            QueryDataParameters parameters = new QueryDataParameters();
            parameters.Add("@ContactID", ci.ContactID);
            parameters.Add("@ScoreName", score);
            parameters.Add("@SiteID", siteId);

            string where = "(Expiration IS NULL OR Expiration > GetDate()) AND (ContactID=@ContactID) AND (ScoreName=@ScoreName) AND (ScoreSiteID=@SiteID)";

            // Get sum of points of the contact in specified score
            DataSet ds = SqlHelperClass.ExecuteQuery("om.score.selectdatajoined", parameters, "SUM(Value) AS Score", where, null, -1);

            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                return(ValidationHelper.GetInteger(ds.Tables[0].Rows[0][0], 0));
            }
        }

        return(0);
    }
Esempio n. 26
0
        private DiscountCouponInfo GetDiscountByOrderId(int orderID)
        {
            var ev = new EventLogProvider();

            try
            {
                DiscountCouponInfo discountCouponInfo = new DiscountCouponInfo();
                string             sql = "SELECT [DiscountCouponID],[DiscountCouponValue],[DiscountCouponIsFlatValue],[DiscountCouponValidTo] FROM [COM_DiscountCoupon] " +
                                         "INNER JOIN [COM_Order] ON [COM_Order].[OrderDiscountCouponID] = [COM_DiscountCoupon].[DiscountCouponID] " +
                                         "WHERE [COM_Order].[OrderID] = @orderID";
                var param = new QueryDataParameters();
                param.Add(new DataParameter("@orderID", orderID));
                DataSet ds = ConnectionHelper.ExecuteQuery(sql, param, QueryTypeEnum.SQLQuery);
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    foreach (DataRow reader in ds.Tables[0].Rows)
                    {
                        discountCouponInfo.DiscountCouponID          = ValidationHelper.GetInteger(reader["DiscountCouponID"], 0);
                        discountCouponInfo.DiscountCouponIsFlatValue = ValidationHelper.GetBoolean(reader["DiscountCouponIsFlatValue"], false);
                        discountCouponInfo.DiscountCouponValue       = ValidationHelper.GetDouble(reader["DiscountCouponValue"], 0);
                        discountCouponInfo.DiscountCouponValidTo     = ValidationHelper.GetDateTime(reader["DiscountCouponValidTo"], DateTime.MinValue);
                        return(discountCouponInfo);
                    }
                }
                return(discountCouponInfo);
            }
            catch (Exception ex)
            {
                ev.LogEvent("E", DateTime.Now, "CMSModuleLoader.GetDiscountValueById", ex.Message);
            }
            return(null);
        }
Esempio n. 27
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (filter != null)
        {
            filter.IsLiveSite            = IsLiveSite;
            filter.ShowSiteFilter        = ShowSiteNameColumn;
            filter.ShowContactNameFilter = ShowContactNameColumn;
        }

        QueryDataParameters parameters = new QueryDataParameters();

        parameters.Add("@ContactID", ContactID);

        // Choose correct object type ("query") according to contact type
        if (IsGlobalContact)
        {
            gridElem.ObjectType = IPGlobalListInfo.OBJECT_TYPE;
        }
        else if (IsMergedContact)
        {
            gridElem.ObjectType = IPMergedListInfo.OBJECT_TYPE;
        }
        else
        {
            gridElem.ObjectType = IPListInfo.OBJECT_TYPE;
        }
        gridElem.QueryParameters      = parameters;
        gridElem.WhereCondition       = WhereCondition;
        gridElem.ZeroRowsText         = GetString("om.ip.noips");
        gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound);
        gridElem.OnAction            += new OnActionEventHandler(gridElem_OnAction);
    }
Esempio n. 28
0
        /// <summary>
        /// Mimics the Repeater with Custom Query, including caching
        /// </summary>
        /// <param name="QueryName">The Query Name</param>
        /// <param name="OrderBy">Order By</param>
        /// <param name="SelectTopN">TopN</param>
        /// <param name="WhereCondition">Where Condition</param>
        /// <param name="Columns">Columns</param>
        /// <param name="QueryParameters">Query Parameters to pass to query.</param>
        /// <param name="CacheItemName">Unique identifier for the cache, REQUIRED for caching.</param>
        /// <param name="CacheMinutes">Optional Cache Minutes, will use site's default cache minutes if not provided.</param>
        /// <param name="CacheDependencies">Cache Dependencies</param>
        /// <returns></returns>
        public static DataSet ExecuteQuery(
            string QueryName,
            string OrderBy        = null,
            int SelectTopN        = -1,
            string WhereCondition = null,
            string Columns        = null,
            QueryDataParameters QueryParameters = null,
            string CacheItemName       = null,
            int CacheMinutes           = -1,
            string[] CacheDependencies = null)
        {
            List <object> CacheItemNameParts = new List <object>();

            if (CacheMinutes == -1)
            {
                // Check cache settings
                CacheMinutes = CacheHelper.CacheMinutes(SiteContext.CurrentSiteName);
            }

            if (CacheMinutes > 0 && !string.IsNullOrWhiteSpace(CacheItemName))
            {
                // Fill up the CacheItemNameParts
                if (QueryParameters != null)
                {
                    foreach (DataParameter QueryParam in QueryParameters)
                    {
                        CacheItemNameParts.Add(string.Format("{0}|{1}", QueryParam.Name, QueryParam.Value));
                    }
                }
                if (!string.IsNullOrWhiteSpace(WhereCondition))
                {
                    CacheItemNameParts.Add(WhereCondition);
                }
                if (!string.IsNullOrWhiteSpace(OrderBy))
                {
                    CacheItemNameParts.Add(OrderBy);
                }
                if (!string.IsNullOrWhiteSpace(Columns))
                {
                    CacheItemNameParts.Add(Columns);
                }
                if (SelectTopN > -1)
                {
                    CacheItemNameParts.Add(SelectTopN);
                }
                return(CacheHelper.Cache <DataSet>(cs =>
                {
                    if (cs.Cached)
                    {
                        cs.CacheDependency = CacheHelper.GetCacheDependency(CacheDependencies);
                    }
                    return ConnectionHelper.ExecuteQuery(QueryName, QueryParameters, WhereCondition, OrderBy, SelectTopN, Columns);
                }, new CacheSettings(CacheMinutes, CacheItemName, "Result", QueryName, CacheItemNameParts)));
            }
            else
            {
                return(ConnectionHelper.ExecuteQuery(QueryName, QueryParameters, WhereCondition, OrderBy, SelectTopN, Columns));
            }
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        CurrentMaster.Title.TitleText  = GetString("newsletter_issue_openedby.title");
        CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Newsletter/module.png");

        issueId = QueryHelper.GetInteger("issueid", 0);
        if (issueId == 0)
        {
            RequestHelper.EndResponse();
        }

        IssueInfo issue = IssueInfoProvider.GetIssueInfo(issueId);

        EditedObject = issue;

        // Prevent accessing issues from sites other than current site
        if (issue.IssueSiteID != CMSContext.CurrentSiteID)
        {
            RedirectToResourceNotAvailableOnSite("Issue with ID " + issueId);
        }

        // Issue is the main A/B test issue
        isMainABTestIssue = issue.IssueIsABTest && !issue.IssueIsVariant;
        if (isMainABTestIssue)
        {
            // Initialize variant selector in the filter
            fltOpenedBy.IssueId = issue.IssueID;

            if (RequestHelper.IsPostBack())
            {
                // Get issue ID from variant selector
                issueId = fltOpenedBy.IssueId;
            }

            // Reset ID for main issue, grid will show data from main and winner variant issues
            if (issueId == issue.IssueID)
            {
                issueId = 0;
            }
        }

        QueryDataParameters parameters = null;

        if (issueId > 0)
        {
            parameters = new QueryDataParameters();
            // Filter by Issue ID (from querystring or variant selector in case of A/B test issue)
            parameters.Add("@IssueID", issueId);
        }

        UniGrid.QueryParameters       = parameters;
        UniGrid.WhereCondition        = fltOpenedBy.WhereCondition;
        UniGrid.Pager.DefaultPageSize = PAGESIZE;
        UniGrid.Pager.ShowPageSize    = false;
        UniGrid.FilterLimit           = 1;
        UniGrid.OnExternalDataBound  += UniGrid_OnExternalDataBound;
        UniGrid.OnBeforeDataReload   += UniGrid_OnBeforeDataReload;
    }
Esempio n. 30
0
    protected void Page_Load(object sender, EventArgs e)
    {
        RaiseOnCheckPermissions(PERMISSION_READ, this);

        if (!Visible)
        {
            EnableViewState = false;
        }

        if (MediaLibraryID > 0)
        {
            // Get information on current library
            permissionArray.Add("filecreate");
            permissionArray.Add("foldercreate");
            permissionArray.Add("filedelete");
            permissionArray.Add("folderdelete");
            permissionArray.Add("filemodify");
            permissionArray.Add("foldermodify");
            permissionArray.Add("libraryaccess");

            if ((ResLibrary != null) && (LibraryInfo != null))
            {
                // Retrieve permission matrix data
                QueryDataParameters parameters = new QueryDataParameters();
                parameters.Add("@ID", ResLibrary.ResourceID);
                parameters.Add("@LibraryID", MediaLibraryID);
                parameters.Add("@SiteID", LibraryInfo.LibrarySiteID);

                // Exclude generic roles from matrix
                string where = "(RoleName NOT IN ('_authenticated_', '_everyone_', '_notauthenticated_'))";

                if (permissionArray != null)
                {
                    where += " AND PermissionName IN (";
                    foreach (string permission in permissionArray)
                    {
                        where += "'" + permission + "',";
                    }
                    where  = where.TrimEnd(',');
                    where += ") ";
                }

                // Setup matrix control
                gridMatrix.QueryParameters = parameters;
                gridMatrix.WhereCondition  = where;
                gridMatrix.CssClass        = "permission-matrix";
                gridMatrix.OnItemChanged  += gridMatrix_OnItemChanged;

                // Check 'Modify' permission
                if (!MediaLibraryInfoProvider.IsUserAuthorizedPerLibrary(LibraryInfo, "manage"))
                {
                    Enable             = false;
                    gridMatrix.Enabled = false;
                    ShowError(String.Format(GetString("general.accessdeniedonpermissionname"), "Manage"));
                }
            }
        }
    }
Esempio n. 31
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Initialize score filter
        FormFieldInfo ffi = new FormFieldInfo();

        ffi.Name                           = " HAVING SUM(Value)";
        ffi.DataType                       = FormFieldDataTypeEnum.Integer;
        ucScoreFilter.FieldInfo            = ffi;
        ucScoreFilter.DefaultOperator      = ">=";
        ucScoreFilter.WhereConditionFormat = "{0} {2} {1}";

        // Get modify permission of current user
        modifyPermission = ContactHelper.AuthorizedModifyContact(SiteId, false);

        // Set where condition
        gridElem.WhereCondition = "(ScoreId = @ScoreID) AND (Expiration IS NULL OR Expiration > @CurrentDate) GROUP BY OM_SelectScoreContact.ContactID, ContactFullNameJoined, ContactStatusID"
                                  + ucScoreFilter.GetWhereCondition();

        // Add parameters
        QueryDataParameters parameters = new QueryDataParameters();

        parameters.AddDateTime("@CurrentDate", DateTime.Now);
        parameters.AddId("@CurrentSiteID", SiteId);
        parameters.AddId("@ScoreID", QueryHelper.GetInteger("ScoreID", 0));
        gridElem.QueryParameters = parameters;

        // Register OnExternalDataBound
        gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound);
        gridElem.OnBeforeFiltering   += new OnBeforeFiltering(gridElem_OnBeforeFiltering);

        // Initialize dropdown lists
        if (!RequestHelper.IsPostBack())
        {
            drpAction.Items.Add(new ListItem(GetString("general." + Action.SelectAction), Convert.ToInt32(Action.SelectAction).ToString()));
            if ((modifyPermission || ContactGroupHelper.AuthorizedModifyContactGroup(SiteId, false)) && ContactGroupHelper.AuthorizedReadContactGroup(SiteId, false))
            {
                drpAction.Items.Add(new ListItem(GetString("om.account." + Action.AddToGroup), Convert.ToInt32(Action.AddToGroup).ToString()));
            }
            if (modifyPermission)
            {
                drpAction.Items.Add(new ListItem(GetString("om.account." + Action.ChangeStatus), Convert.ToInt32(Action.ChangeStatus).ToString()));
            }
            drpWhat.Items.Add(new ListItem(GetString("om.contact." + What.Selected), Convert.ToInt32(What.Selected).ToString()));
            drpWhat.Items.Add(new ListItem(GetString("om.contact." + What.All), Convert.ToInt32(What.All).ToString()));
        }
        else
        {
            if (RequestHelper.CausedPostback(btnOk))
            {
                // Set delayed reload for unigrid if mass action is performed
                gridElem.DelayedReload = true;
            }
        }

        // Register JS scripts
        RegisterScripts();
    }
Esempio n. 32
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ci = (ContactInfo)EditedObject;
        CheckReadPermission(ci.ContactSiteID);

        globalContact = (ci.ContactSiteID <= 0);
        mergedContact = (ci.ContactMergedWithContactID > 0);
        modifyAllowed = ContactHelper.AuthorizedModifyContact(ci.ContactSiteID, false);

        contactId = QueryHelper.GetInteger("contactid", 0);

        string where = null;
        // Filter only site members in CMSDesk (for global contacts)
        if (!IsSiteManager && globalContact && AuthorizedForSiteContacts)
        {
            where += " (ContactSiteID IS NULL OR ContactSiteID=" + CMSContext.CurrentSiteID + ")";
        }

        // Choose correct query according to type of contact
        if (globalContact)
        {
            gridElem.ObjectType = OnlineMarketingObjectType.MEMBERSHIPGLOBALUSERLIST;
        }
        else if (mergedContact)
        {
            gridElem.ObjectType = OnlineMarketingObjectType.MEMBERSHIPMERGEDUSERLIST;
        }
        else
        {
            gridElem.ObjectType = OnlineMarketingObjectType.MEMBERSHIPUSERLIST;
        }

        // Query parameters
        QueryDataParameters parameters = new QueryDataParameters();

        parameters.Add("@ContactId", contactId);

        gridElem.WhereCondition       = where;
        gridElem.QueryParameters      = parameters;
        gridElem.OnAction            += new OnActionEventHandler(gridElem_OnAction);
        gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound);

        // Setup user selector
        selectUser.UniSelector.SelectionMode       = SelectionModeEnum.MultipleButton;
        selectUser.UniSelector.OnItemsSelected    += new EventHandler(UniSelector_OnItemsSelected);
        selectUser.UniSelector.ReturnColumnName    = "UserID";
        selectUser.UniSelector.ButtonImage         = GetImageUrl("Objects/CMS_User/add.png");
        selectUser.UniSelector.DialogLink.CssClass = "MenuItemEdit";
        selectUser.ShowSiteFilter = false;
        selectUser.ResourcePrefix = "addusers";
        selectUser.UniSelector.DialogButton.CssClass = "LongButton";
        selectUser.IsLiveSite = false;
        selectUser.SiteID     = ci.ContactSiteID;

        // Hide header actions for global contact or merged contact
        CurrentMaster.HeaderActionsPlaceHolder.Visible = modifyAllowed && !globalContact && !mergedContact;
    }
Esempio n. 33
0
    /// <summary>
    /// Returns query parameters for permission matrix.
    /// </summary>
    /// <param name="siteId">Site ID</param>
    /// <param name="permissionId">Permission ID</param>
    /// <param name="permissionName">Permission display name</param>
    /// <returns>Two dimensional object array.</returns>
    private QueryDataParameters GetQueryParameters(int siteId, int permissionId, string permissionName)
    {
        QueryDataParameters parameters = new QueryDataParameters();

        parameters.Add("@SiteID", (ValidationHelper.GetString(siteSelector.Value, String.Empty) == siteSelector.GlobalRecordValue) ? 0 : siteId);
        parameters.Add("@PermissionID", permissionId);
        parameters.Add("@PermissionDisplayName", ResHelper.LocalizeString(permissionName));

        return(parameters);
    }
Esempio n. 34
0
    protected void dlComment_DeleteCommand(object source, DataListCommandEventArgs e)
    {
        int CommentID = Convert.ToInt32(dlComment.DataKeys[e.Item.ItemIndex]);

        string delete = string.Format("DELETE FROM [Form_blog_comment] WHERE commentID ='" + CommentID + "'");
        QueryDataParameters queryparam = new QueryDataParameters();
        DataSet dataSet = ConnectionHelper.ExecuteQuery(delete, queryparam, QueryTypeEnum.SQLQuery);

        BindDataList();
    }
Esempio n. 35
0
    protected void BindDataList()
    {
        int nodeID = CMS.DocumentEngine.DocumentContext.CurrentDocument.NodeID;

        string serviceType = string.Format("SELECT * FROM [Form_blog_comment] WHERE BlogNodeID ='" + nodeID + "' ORDER BY FormInserted DESC");
        QueryDataParameters queryparam = new QueryDataParameters();
        DataSet dataSet = ConnectionHelper.ExecuteQuery(serviceType, queryparam, QueryTypeEnum.SQLQuery);

        dlComment.DataSource = dataSet.Tables[0];
        dlComment.DataBind();
    }
Esempio n. 36
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get culture ID from query string
        uiCultureID = QueryHelper.GetInteger("UIcultureID", 0);

        // Get requested culture
        ui = UICultureInfoProvider.GetSafeUICulture(uiCultureID);

        UICultureInfo dui = null;
        // Check if edited UI culture is the default UI culture
        if ((ui != null) && CMSString.Equals(ui.UICultureCode, CultureHelper.DefaultUICulture, true))
        {
            dui = ui;
            // Use different grid definition
            gridStrings.GridName = "List_defaultculture.xml";
        }
        else
        {
            // Ty to get default UI culture
            try
            {
                dui = UICultureInfoProvider.GetUICultureInfo(CultureHelper.DefaultUICulture);
            }
            catch
            {
            }
        }

        if (dui != null)
        {
            EditedObject = ui;

            // Prepare query params for the grid
            QueryDataParameters parameters = new QueryDataParameters();
            parameters.Add("@Culture", ui.UICultureID);
            parameters.AddId("@DefaultUICultureID", dui.UICultureID);

            // Setup the grid
            gridStrings.QueryParameters = parameters;
            gridStrings.OnAction += UniGridUICultures_OnAction;
            gridStrings.OnExternalDataBound += UniGridStrings_OnExternalDataBound;

            InitializeMasterPage();
        }
        else
        {
            // Default UI culture does not exist - hide the grid and display error message
            gridStrings.StopProcessing = true;

            ShowError(String.Format(GetString("uiculture.defaultnotexist"), CultureHelper.DefaultUICulture));
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        gridStrings.OnAction += UniGridCultures_OnAction;

        CurrentMaster.DisplaySiteSelectorPanel = true;

        cultureSelector.OnSelectionChanged += cultureSelector_OnSelectionChanged;
        cultureSelector.DropDownSingleSelect.AutoPostBack = true;
        cultureSelector.OnListItemCreated += cultureSelector_OnListItemCreated;

        mCultureCode = QueryHelper.GetString("culturecode", CultureHelper.DefaultUICultureCode);
        mCultureInfo = CultureInfoProvider.GetCultureInfo(mCultureCode);

        if (mCultureInfo != null && mDefaultUICultureInfo != null)
        {
            QueryDataParameters parameters = new QueryDataParameters();
            parameters.Add("@Culture", mCultureInfo.CultureID);
            parameters.AddId("@DefaultCultureID", mDefaultUICultureInfo.CultureID);
            gridStrings.QueryParameters = parameters;

            string defaultTextCaption = String.Format(GetString("culture.defaultwithparameter"), CultureHelper.DefaultUICultureCode);
            gridStrings.GridColumns.Columns.Find(column => column.Source == "DefaultText").Caption = defaultTextCaption;

            if (CurrentCultureIsDefault)
            {
                // Set default translation column to full width
                gridStrings.GridColumns.Columns[2].Width = "100%";

                // Remove 'CultureText' column if current culture is default
                gridStrings.GridColumns.Columns.RemoveAt(1);
            }
            else
            {
                if (!LocalizationHelper.ResourceFileExistsForCulture(mCultureInfo.CultureCode))
                {
                    string url = "http://devnet.kentico.com/download/localization-packs";
                    string downloadPage = String.Format(@"<a href=""{0}"" target=""_blank"" >{1}</a> ", url, HTMLHelper.HTMLEncode(url));
                    ShowInformation(String.Format(GetString("culture.downloadlocalization"), downloadPage));
                }
            }

            InitializeMasterPage();
        }
        else
        {
            gridStrings.StopProcessing = true;
            ShowError(String.Format(GetString("culture.doesntexist"), HTMLHelper.HTMLEncode(mCultureCode)));
        }
    }
Esempio n. 38
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get culture ID from query string
        uiCultureID = QueryHelper.GetInteger("UIcultureID", 0);

        // Get requested culture
        ui = UICultureInfoProvider.GetSafeUICulture(uiCultureID);
        EditedObject = ui;

        UICultureInfo dui = null;
        if (string.Equals(ui.UICultureCode, CultureHelper.DefaultUICulture, StringComparison.InvariantCultureIgnoreCase))
        {
            dui = ui;
            gridStrings.GridName = "List_defaultculture.xml";
        }
        else
        {
            // Ty to get default UI culture
            try
            {
                dui = UICultureInfoProvider.GetUICultureInfo(CultureHelper.DefaultUICulture);
            }
            catch
            { }
        }

        if (dui != null)
        {
            QueryDataParameters parameters = new QueryDataParameters();
            parameters.Add("@Culture", ui.UICultureID);
            parameters.AddId("@DefaultUICultureID", dui.UICultureID);

            // Setup the grid
            gridStrings.QueryParameters = parameters;
            gridStrings.OnAction += UniGridUICultures_OnAction;
            gridStrings.OnExternalDataBound += UniGridStrings_OnExternalDataBound;

            InitializeMasterPage();
        }
        else
        {
            // Default UI culture does not exist - hide the grid and display error message
            gridStrings.StopProcessing = true;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        stepsGrid.OnAction += stepsGrid_OnAction;
        stepsGrid.DataBinding += stepsGrid_DataBinding;

        int workflowId = QueryHelper.GetInteger("workflowid", 0);

        // Control initialization
        InitializeMasterPage(workflowId);

        // Prepare the steps query parameters
        QueryDataParameters parameters = new QueryDataParameters();
        parameters.Add("@StepWorkflowID", workflowId);
        stepsGrid.WhereCondition = "StepWorkflowID = @StepWorkflowID";
        stepsGrid.QueryParameters = parameters;

        stepsGrid.OnExternalDataBound += stepsGrid_OnExternalDataBound;
    }
    /// <summary>
    /// Generates sample data.
    /// </summary>
    private void GenerateData()
    {
        try
        {
            QueryDataParameters parameters = new QueryDataParameters();
            parameters.Add("siteId", CMSContext.CurrentSiteID);

            ConnectionHelper.ExecuteQuery("ecommerce.order.generateSampleData", parameters);

            // Log successful attempt
            EventLogProvider eventLog = new EventLogProvider();
            eventLog.LogEvent("I", DateTime.Now, "E-commerce data generator", "DATAGENERATED", CMSContext.CurrentSiteID);
            ShowConfirmation(GetString("com.reports.datagenerated"));
        }
        catch (Exception ex)
        {
            EventLogProvider.LogException("Reports", "Generate", ex);
            ShowError(GetString("com.reports.operationFailed"));
        }
    }
Esempio n. 41
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        try
        {
            litArchive.Text = (string)this.GetValue("Header");

            string serviceType = string.Format("SELECT categoryname FROM [customtable_Category]");
            QueryDataParameters queryparam = new QueryDataParameters();
            DataSet dataSet = ConnectionHelper.ExecuteQuery(serviceType, queryparam, QueryTypeEnum.SQLQuery);

            if (!DataHelper.DataSourceIsEmpty(dataSet))
            {
                rptCategory.DataSource = dataSet.Tables[0];
                rptCategory.DataBind();
            }
        }

        catch (Exception ex1)
        {
            Response.Write(ex1.Message.ToString() + ex1.StackTrace.ToString());
        }
    }
Esempio n. 42
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.Visible)
        {
            this.EnableViewState = false;
        }

        // Get group resource info
        resGroups = ResourceInfoProvider.GetResourceInfo("CMS.Groups");
        if (resGroups != null)
        {
            // Retrive permission matrix data
            QueryDataParameters parameters = new QueryDataParameters();
            parameters.Add("@ID", resGroups.ResourceId);
            parameters.Add("@GroupID", this.GroupID);
            parameters.Add("@SiteID", CMSContext.CurrentSiteID);

            // Setup WHERE condition
            string where = "RoleGroupID=" + this.GroupID.ToString() + "AND PermissionDisplayInMatrix = 0";

            // Setup grid control
            gridMatrix.QueryParameters = parameters;
            gridMatrix.WhereCondition = where;
            gridMatrix.ContentBefore = "<table class=\"PermissionMatrix\" cellspacing=\"0\" cellpadding=\"0\" rules=\"rows\" border=\"1\" style=\"border-collapse:collapse;\">";
            gridMatrix.ContentAfter = "</table>";

            gridMatrix.OnItemChanged += new UniMatrix.ItemChangedEventHandler(gridMatrix_OnItemChanged);

            // Disable permission matrix if user has no MANAGE rights
            if (!CMSContext.CurrentUser.IsGroupAdministrator(this.GroupID))
            {
                if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.groups", CMSAdminControl.PERMISSION_MANAGE))
                {
                    this.Enabled = false;
                    gridMatrix.Enabled = false;
                    lblError.Text = String.Format(ResHelper.GetString("CMSSiteManager.AccessDeniedOnPermissionName"), "Manage");
                    lblError.Visible = true;
                }
            }
        }
    }
    /// <summary>
    /// Setups grid query parameters.
    /// </summary>
    private void SetupGridQueryParameters()
    {
        // Create query parameters
        QueryDataParameters parameters = new QueryDataParameters();
        parameters.Add("@Now", DateTime.Now);

        if (ListingType == ListingTypeEnum.OutdatedDocuments)
        {
            parameters.Add("@SiteID", SiteContext.CurrentSiteID);
        }

        // Initialize UserID query parameter
        int userID = currentUserInfo.UserID;
        if (ListingType == ListingTypeEnum.PendingDocuments)
        {
            parameters.Add("@SiteID", SiteInfoProvider.GetSiteID(SiteName));

            if ((currentUserInfo.IsGlobalAdministrator) || (currentUserInfo.IsAuthorizedPerResource("CMS.Content", "manageworkflow")))
            {
                userID = -1;
            }
        }

        parameters.Add("@UserID", userID);

        // Document Age
        if (DocumentAge != String.Empty)
        {
            string[] ages = DocumentAge.Split(';');
            if (ages.Length == 2)
            {
                // Add from a to values to temp parameters
                int from = ValidationHelper.GetInteger(ages[1], 0);
                int to = ValidationHelper.GetInteger(ages[0], 0);

                if (@from > 0)
                {
                    gridElem.WhereCondition = SqlHelper.AddWhereCondition(gridElem.WhereCondition, SOURCE_MODIFIEDWHEN + " >= @FROM");
                    parameters.Add("@FROM", DateTime.Now.AddDays((-1) * @from));
                }

                if (to > 0)
                {
                    gridElem.WhereCondition = SqlHelper.AddWhereCondition(gridElem.WhereCondition, SOURCE_MODIFIEDWHEN + " <= @TO");
                    parameters.Add("@TO", DateTime.Now.AddDays((-1) * to));
                }
            }
        }

        // Set parameters
        gridElem.QueryParameters = parameters;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (filter != null)
        {
            filter.ShowContactSelector = ShowContactNameColumn;
            filter.ShowSiteFilter = ShowSiteNameColumn;
            filter.ShowIPFilter = ShowIPAddressColumn;
        }

        if (PageSize >= 0)
        {
            gridElem.Pager.DefaultPageSize = PageSize;
        }
        gridElem.OrderBy = OrderBy;
        gridElem.WhereCondition = WhereCondition;
        if (SiteID > 0)
        {
            gridElem.WhereCondition = SqlHelper.AddWhereCondition(gridElem.WhereCondition, "ActivitySiteID = " + SiteID);
        }
        gridElem.OnExternalDataBound += gridElem_OnExternalDataBound;

        // Set gridelement empty list info text either to set property or default value
        gridElem.ZeroRowsText = String.IsNullOrEmpty(ZeroRowsText) ? GetString("om.activities.noactivities") : GetString(ZeroRowsText);
        gridElem.FilteredZeroRowsText = String.IsNullOrEmpty(FilteredZeroRowsText) ? GetString("om.activities.noactivities.filtered") : GetString(FilteredZeroRowsText);

        if (ContactID > 0)
        {
            gridElem.ObjectType = "om.activitycontactlist";
            if (IsMergedContact)
            {
                gridElem.ObjectType = "om.activitycontactmergedlist";
            }
            if (IsGlobalContact)
            {
                gridElem.ObjectType = "om.activitycontactgloballist";
            }

            QueryDataParameters parameters = new QueryDataParameters();
            parameters.AddId("@ContactID", ContactID);

            gridElem.QueryParameters = parameters;
        }

        // Check permission modify for current site only. To be able to display other sites user must be global admin = no need to check permission.
        modifyPermission = ActivityHelper.AuthorizedManageActivity(SiteContext.CurrentSiteID, false);

        ScriptHelper.RegisterDialogScript(Page);

        string scriptBlock = string.Format(@"
            function ViewDetails(id) {{ modalDialog('{0}' + id, 'ActivityDetails', '900', '950'); return false; }}",
            ResolveUrl(@"~/CMSModules/ContactManagement/Pages/Tools/Activities/Activity/Activity_Details.aspx"));

        ScriptHelper.RegisterClientScriptBlock(this, GetType(), "Actions", scriptBlock, true);
    }
Esempio n. 45
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (StopProcessing)
        {
            // Do nothing
            return;
        }
        gridElem.IsLiveSite = IsLiveSite;
        gridElem.OnExternalDataBound += gridElem_OnExternalDataBound;
        gridElem.HideControlForZeroRows = false;
        currentUserInfo = CMSContext.CurrentUser;

        // Initialize strings
        string strDays = GetString("MyDesk.OutdatedDocuments.Days");
        string strWeeks = GetString("MyDesk.OutdatedDocuments.Weeks");
        string strMonths = GetString("MyDesk.OutdatedDocuments.Months");
        string strYears = GetString("MyDesk.OutdatedDocuments.Years");

        // Set proper XML for control type
        switch (ListingType)
        {
            case ListingTypeEnum.CheckedOut:
                gridElem.ZeroRowsText = GetString("mydesk.ui.nochecked");
                gridElem.WhereCondition = "View_CMS_Tree_Joined.DocumentCheckedOutByUserID = @UserID";
                break;

            case ListingTypeEnum.MyDocuments:
                gridElem.ZeroRowsText = GetString("general.nodatafound");
                gridElem.WhereCondition = "View_CMS_Tree_Joined.NodeOwner = @UserID";
                break;

            case ListingTypeEnum.RecentDocuments:
                gridElem.ZeroRowsText = GetString("general.nodatafound");
                gridElem.WhereCondition = "((View_CMS_Tree_Joined.DocumentCreatedByUserID = @UserID OR View_CMS_Tree_Joined.DocumentModifiedByUserID = @UserID OR View_CMS_Tree_Joined.DocumentCheckedOutByUserID = @UserID))";
                break;

            case ListingTypeEnum.PendingDocuments:
                gridElem.ZeroRowsText = GetString("mydesk.ui.nowaitingdocs");
                gridElem.WhereCondition = "CMS_WorkflowStep.StepName <> 'edit' AND CMS_WorkflowStep.StepName <> 'published' AND CMS_WorkflowStep.StepName <> 'archived' AND (View_CMS_Tree_Joined.DocumentWorkflowStepID IN ( SELECT StepID FROM CMS_Workflowsteproles LEFT JOIN View_CMS_UserRole_MembershipRole_ValidOnly_Joined ON View_CMS_UserRole_MembershipRole_ValidOnly_Joined.RoleID = CMS_WorkflowStepRoles.RoleID WHERE View_CMS_UserRole_MembershipRole_ValidOnly_Joined.UserID = @UserID ) OR @UserID = -1)";
                break;

            case ListingTypeEnum.OutdatedDocuments:
                // Initialize controls
                if (!RequestHelper.IsPostBack())
                {
                    // Fill the dropdown list
                    drpFilter.Items.Add(strDays);
                    drpFilter.Items.Add(strWeeks);
                    drpFilter.Items.Add(strMonths);
                    drpFilter.Items.Add(strYears);

                    // Load default value
                    txtFilter.Text = "1";
                    drpFilter.SelectedValue = strYears;

                    // Bind dropdown lists
                    BindDropDowns();
                }

                gridElem.WhereCondition = "((DocumentCreatedByUserID = @UserID OR DocumentModifiedByUserID = @UserID OR DocumentCheckedOutByUserID = @UserID) AND " + SOURCE_MODIFIEDWHEN + "<=@OlderThan AND " + SOURCE_NODESITEID + "=@SiteID)";
                // Add where condition
                if (!string.IsNullOrEmpty(txtDocumentName.Text))
                {
                    gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, GetOutdatedWhereCondition(SOURCE_DOCUMENTNAME, drpDocumentName, txtDocumentName));
                }
                if (!string.IsNullOrEmpty(txtDocumentType.Text))
                {
                    gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, GetOutdatedWhereCondition(SOURCE_CLASSDISPLAYNAME, drpDocumentType, txtDocumentType));
                }

                gridElem.ZeroRowsText = GetString("mydesk.ui.nooutdated");
                // Show custom filter
                plcOutdatedFilter.Visible = true;
                break;

            case ListingTypeEnum.WorkflowDocuments:
                break;

            case ListingTypeEnum.PageTemplateDocuments:
                gridElem.ZeroRowsText = GetString("Administration-PageTemplate_Header.Documents.nodata");
                break;

            case ListingTypeEnum.CategoryDocuments:
                gridElem.ZeroRowsText = GetString("Category_Edit.Documents.nodata");
                break;

            case ListingTypeEnum.ProductDocuments:
                break;

            case ListingTypeEnum.TagDocuments:
                gridElem.ZeroRowsText = GetString("taggroup_edit.documents.nodata");
                break;

            case ListingTypeEnum.DocTypeDocuments:
                gridElem.ZeroRowsText = GetString("DocumentType_Edit_General.Documents.nodata");
                break;

            case ListingTypeEnum.All:
                gridElem.ZeroRowsText = GetString("mydesk.ui.nodata");
                break;
        }

        // Page Size
        if (!RequestHelper.IsPostBack() && !String.IsNullOrEmpty(ItemsPerPage))
        {
            gridElem.Pager.DefaultPageSize = ValidationHelper.GetInteger(ItemsPerPage, -1);
        }

        // Order
        switch (ListingType)
        {
            case ListingTypeEnum.WorkflowDocuments:
            case ListingTypeEnum.OutdatedDocuments:
            case ListingTypeEnum.PageTemplateDocuments:
            case ListingTypeEnum.CategoryDocuments:
            case ListingTypeEnum.TagDocuments:
            case ListingTypeEnum.ProductDocuments:
            case ListingTypeEnum.DocTypeDocuments:
                gridElem.OrderBy = SOURCE_DOCUMENTNAME;
                break;

            default:
                gridElem.OrderBy = OrderBy;
                break;
        }

        if (ListingType == ListingTypeEnum.All)
        {
            gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, String.Format("(UserID1 = {0} OR  UserID2 = {0} OR UserID3 = {0})", currentUserInfo.UserID));
        }

        // Create query parameters
        QueryDataParameters parameters = new QueryDataParameters();

        if (ListingType == ListingTypeEnum.OutdatedDocuments)
        {
            parameters.Add("@SiteID", CMSContext.CurrentSite.SiteID);

            DateTime olderThan = DateTime.Now;
            int dateTimeValue = ValidationHelper.GetInteger(txtFilter.Text, 0);
            if (drpFilter.SelectedValue == strDays)
            {
                olderThan = olderThan.AddDays(-dateTimeValue);
            }
            else if (drpFilter.SelectedValue == strWeeks)
            {
                olderThan = olderThan.AddDays(-dateTimeValue * 7);
            }
            else if (drpFilter.SelectedValue == strMonths)
            {
                olderThan = olderThan.AddMonths(-dateTimeValue);
            }
            else if (drpFilter.SelectedValue == strYears)
            {
                olderThan = olderThan.AddYears(-dateTimeValue);
            }

            parameters.Add("@OlderThan", olderThan);
        }
        // Initialize UserID query parameter
        int userID = currentUserInfo.UserID;
        if (ListingType == ListingTypeEnum.PendingDocuments)
        {
            if ((currentUserInfo.IsGlobalAdministrator) || (currentUserInfo.IsAuthorizedPerResource("CMS.Content", "manageworkflow")))
            {
                userID = -1;
            }
        }

        parameters.Add("@UserID", userID);

        // Document Age
        if (DocumentAge != String.Empty)
        {
            string[] ages = DocumentAge.Split(';');
            if (ages.Length == 2)
            {
                // Add from a to values to temp parameters
                int from = ValidationHelper.GetInteger(ages[1], 0);
                int to = ValidationHelper.GetInteger(ages[0], 0);

                if (from > 0)
                {
                    gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, SOURCE_MODIFIEDWHEN + " >= @FROM");
                    parameters.Add("@FROM", DateTime.Now.AddDays((-1) * from));
                }

                if (to > 0)
                {
                    gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, SOURCE_MODIFIEDWHEN + " <= @TO");
                    parameters.Add("@TO", DateTime.Now.AddDays((-1) * to));
                }
            }
        }

        // Site name
        if (!String.IsNullOrEmpty(SiteName) && (SiteName != UniGrid.ALL))
        {
            SiteInfo site = SiteInfoProvider.GetSiteInfo(SiteName);
            if (site != null)
            {
                gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, SOURCE_NODESITEID + " = " + site.SiteID);
                UniGrid.GridColumns.Columns.RemoveAll(c => (c.Source == SOURCE_SITENAME || c.Source == SOURCE_NODESITEID));
            }
        }

        // Path filter
        if (Path != String.Empty)
        {
            if (ListingType == ListingTypeEnum.All)
            {
                gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, SOURCE_DOCUMENTNAMEPATH + " LIKE N'" + CMSContext.ResolveCurrentPath(Path).Replace("'", "''") + "'");
            }
            else
            {
                gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, SOURCE_NODEALIASPATH + " LIKE N'" + CMSContext.ResolveCurrentPath(Path).Replace("'", "''") + "'");
            }
        }

        // Document type filer
        if (!String.IsNullOrEmpty(DocumentType))
        {
            string[] types = DocumentType.Split(';');
            gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, SqlHelperClass.GetWhereCondition<string>(SOURCE_CLASSNAME, types, true));
        }

        // Document name filter
        if (DocumentName != String.Empty)
        {
            gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, SOURCE_DOCUMENTNAME + " LIKE N'%" + SqlHelperClass.GetSafeQueryString(DocumentName, false) + "%'");
        }

        // Site running filter
        if ((SiteName == UniGrid.ALL) && DisplayOnlyRunningSites)
        {
            gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, "SiteName IN (SELECT SiteName FROM CMS_Site WHERE SiteStatus = 'RUNNING')");
        }

        // Set parameters
        gridElem.QueryParameters = parameters;
    }
Esempio n. 46
0
    protected void Page_Load(object sender, EventArgs e)
    {
        reminderPopupDialog.Hide();

        // Grid initialization
        gridElem.OnAction += new OnActionEventHandler(gridElem_OnAction);
        gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound);
        gridElem.GridView.RowDataBound += new GridViewRowEventHandler(GridView_RowDataBound);
        gridElem.GridView.RowCreated += new GridViewRowEventHandler(GridView_RowCreated);
        gridElem.ZeroRowsText = GetString("pm.projectstask.notasksfound");
        gridElem.DelayedReload = true;

        QueryDataParameters parameters = new QueryDataParameters();
        parameters.Add("@Now", DateTime.Now);
        gridElem.QueryParameters = parameters;

        switch (OrderByType)
        {
            case ProjectTaskOrderByEnum.ProjectOrder:
                gridElem.OrderBy = "ProjectTaskProjectOrder";
                break;

            case ProjectTaskOrderByEnum.UserOrder:
                gridElem.OrderBy = "ProjectTaskUserOrder";
                break;
        }

        if (!String.IsNullOrEmpty(OrderBy))
        {
            gridElem.OrderBy += (!String.IsNullOrEmpty(gridElem.OrderBy)) ? ", " : "";
            gridElem.OrderBy += OrderBy;
        }

        showArrows = GetSortingArrowsVisibility();
    }
    /// <summary>
    /// Gets query parameters for the permission matrix.
    /// </summary>
    /// <returns>Two dimensional object array of query parameters.</returns>
    private QueryDataParameters GetQueryParameters()
    {
        QueryDataParameters parameters = new QueryDataParameters();
        parameters.Add("@ID", ValidationHelper.GetInteger(SelectedID, 0));
        parameters.Add("@SiteID", (GlobalRoles ? 0 : SiteID == 0 ? SiteContext.CurrentSiteID : SiteID));
        parameters.Add("@DisplayInMatrix", true);

        return parameters;
    }
    /// <summary>
    /// Load data.
    /// </summary>
    public void LoadData()
    {
        process = true;
        if (!Visible || StopProcessing)
        {
            EnableViewState = false;
            process = false;
        }

        IsLiveSite = false;

        if (ProjectID > 0)
        {
            // Get information on current project
            project = ProjectInfoProvider.GetProjectInfo(ProjectID);
        }

        // Get project resource
        resProjects = ResourceInfoProvider.GetResourceInfo("CMS.ProjectManagement");

        if ((resProjects != null) && (project != null))
        {
            QueryDataParameters parameters = new QueryDataParameters();
            parameters.Add("@ID", resProjects.ResourceId);
            parameters.Add("@ProjectID", project.ProjectID);
            parameters.Add("@SiteID", CMSContext.CurrentSiteID);

            string where = "";
            int groupId = project.ProjectGroupID;

            // Build where condition
            if (groupId > 0)
            {
                where = "RoleGroupID=" + groupId.ToString() + " AND PermissionDisplayInMatrix = 0";
            }
            else
            {
                where = "RoleGroupID IS NULL AND PermissionDisplayInMatrix = 0";
            }

            // Setup matrix control
            gridMatrix.IsLiveSite = IsLiveSite;
            gridMatrix.QueryParameters = parameters;
            gridMatrix.WhereCondition = where;
            gridMatrix.ContentBefore = "<table class=\"PermissionMatrix\" cellspacing=\"0\" cellpadding=\"0\" rules=\"rows\" border=\"1\" style=\"border-collapse:collapse;\">";
            gridMatrix.ContentAfter = "</table>";
        }
    }
Esempio n. 49
0
        /// <summary>
        /// Returns DataSet of attendees which are joined with the specified order
        /// </summary>
        /// <param name="orderId">Order ID.</param>    
        public static DataSet GetAttendees(int orderId)
        {
            // Prepare the parameters
            var parameters = new QueryDataParameters {{"@OrderId", orderId}};

            var conn = ConnectionHelper.GetConnection();
            return conn.ExecuteQuery("SELECT * FROM Events_Attendee WHERE " + COLUMN_ATTENDEE_ORDERID + " = @OrderID", parameters, QueryTypeEnum.SQLQuery, false);
        }
Esempio n. 50
0
    private void SetWhereCondition()
    {
        // Check existence of CMS.BookingEvent dataclass
        if (DataClassInfoProvider.GetDataClass("CMS.BookingEvent") != null)
        {
            // Filter site name
            string siteName = SiteName;
            if (siteName == String.Empty)
            {
                siteName = CMSContext.CurrentSiteName;
            }

            // If not show all
            if (siteName != TreeProvider.ALL_SITES)
            {
                gridElem.WhereCondition = "(NodeLinkedNodeID IS NULL AND SiteName LIKE '" + siteName + "')";
            }
            else
            {
                gridElem.WhereCondition = "NodeLinkedNodeID IS NULL";
            }

            // Filter time interval
            if (EventScope != "all")
            {
                if (EventScope == "upcoming")
                {
                    gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, "EventDate >= @Date");
                }
                else
                {
                    gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, "EventDate <= @Date");
                }

                QueryDataParameters parameters = new QueryDataParameters();
                parameters.Add("@Date", DateTime.Now);

                gridElem.QueryParameters = parameters;
            }
        }
        else
        {
            // Document type with code name 'CMS.BookingEvent' does not exist
            lblError.Visible = true;
            lblError.Text = GetString("Events_List.NoBookingEventClass");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        RaiseOnCheckPermissions(PERMISSION_READ, this);

        if (!Visible)
        {
            EnableViewState = false;
        }

        if (MediaLibraryID > 0)
        {
            // Get information on current library
            permissionArray.Add("filecreate");
            permissionArray.Add("foldercreate");
            permissionArray.Add("filedelete");
            permissionArray.Add("folderdelete");
            permissionArray.Add("filemodify");
            permissionArray.Add("foldermodify");
            permissionArray.Add("libraryaccess");

            if ((ResLibrary != null) && (LibraryInfo != null))
            {
                // Retrieve permission matrix data
                QueryDataParameters parameters = new QueryDataParameters();
                parameters.Add("@ID", ResLibrary.ResourceID);
                parameters.Add("@LibraryID", MediaLibraryID);
                parameters.Add("@SiteID", LibraryInfo.LibrarySiteID);

                // Exclude generic roles from matrix
                string where = "(RoleName NOT IN ('_authenticated_', '_everyone_', '_notauthenticated_')) AND ";

                if (LibraryInfo.LibraryGroupID > 0)
                {
                    where += "RoleGroupID=" + LibraryInfo.LibraryGroupID.ToString();
                }
                else
                {
                    where += "RoleGroupID IS NULL";
                }

                if (permissionArray != null)
                {
                    where += " AND PermissionName IN (";
                    foreach (string permission in permissionArray)
                    {
                        where += "'" + permission + "',";
                    }
                    where = where.TrimEnd(',');
                    where += ") ";
                }

                // Setup matrix control
                gridMatrix.QueryParameters = parameters;
                gridMatrix.WhereCondition = where;
                gridMatrix.CssClass = "permission-matrix";
                gridMatrix.OnItemChanged += gridMatrix_OnItemChanged;

                // Check 'Modify' permission
                if (!MediaLibraryInfoProvider.IsUserAuthorizedPerLibrary(LibraryInfo, "manage"))
                {
                    Enable = false;
                    gridMatrix.Enabled = false;
                    ShowError(String.Format(GetString("general.accessdeniedonpermissionname"), "Manage"));
                }
            }
        }
    }
    /// <summary>
    /// Indicates if table has identity column defined
    /// </summary>
    /// <param name="tableName">Table name</param>
    /// <param name="columnName">Column name</param>
    /// <returns>Returns TRUE if table has identity column</returns>
    private static bool IsIdentityColumn(string tableName, string columnName)
    {
        const string queryText = @"SELECT COLUMNPROPERTY(OBJECT_ID(@tableName), @columnName, 'IsIdentity')";

        var queryData = new QueryDataParameters
        {
            { "tableName", tableName },
            { "columnName", columnName }
        };

        var result = ConnectionHelper.ExecuteScalar(queryText, queryData, QueryTypeEnum.SQLQuery);
        return ValidationHelper.GetBoolean(result, false);
    }
    /// <summary>
    /// Build list where condition.
    /// </summary>
    private string ucTaskList_BuildCondition(object sender, string whereCondition)
    {
        // Keep current user
        var currentUser = MembershipContext.AuthenticatedUser;

        // Switch by display type
        switch (TasksDisplayType)
        {
            // Tasks owned by me
            case TasksDisplayTypeEnum.TasksOwnedByMe:
                whereCondition = SqlHelper.AddWhereCondition(whereCondition, "ProjectTaskOwnerID = " + currentUser.UserID);
                break;

            // Tasks assigned to me
            case TasksDisplayTypeEnum.TasksAssignedToMe:
                whereCondition = SqlHelper.AddWhereCondition(whereCondition, "ProjectTaskAssignedToUserID = " + currentUser.UserID);
                break;

            // Project tasks
            case TasksDisplayTypeEnum.ProjectTasks:
                // Check whether project names are defined
                if (!String.IsNullOrEmpty(ProjectNames))
                {
                    string condition = SqlHelper.GetSafeQueryString(ProjectNames, false);
                    condition = "N'" + condition.Replace(";", "',N'") + "'";
                    // Add condition for specified projects
                    condition = "ProjectTaskProjectID IN (SELECT ProjectID FROM PM_Project WHERE ProjectName IN (" + condition + "))";

                    // Add condition for private task, only if current user isn't project management admin
                    if (!currentUser.IsAuthorizedPerResource("CMS.ProjectManagement", PERMISSION_MANAGE))
                    {
                        condition = SqlHelper.AddWhereCondition(condition, "(ProjectTaskIsPrivate = 0 OR ProjectTaskIsPrivate IS NULL) OR (ProjectTaskOwnerID = " + currentUser.UserID + " OR ProjectTaskAssignedToUserID = " + currentUser.UserID + " OR ProjectOwner = " + currentUser.UserID + ")");
                    }

                    // Complete where condition
                    whereCondition = SqlHelper.AddWhereCondition(whereCondition, condition);
                }
                // If project names aren't defined do nothing
                else
                {
                    whereCondition = "(1=2)";
                }
                break;
        }

        // Do not display finished tasks
        if (!ShowFinishedTasks)
        {
            whereCondition = SqlHelper.AddWhereCondition(whereCondition, "TaskStatusIsFinished = 0");
        }

        // Do not display on time tasks
        if (!ShowOnTimeTasks)
        {
            whereCondition = SqlHelper.AddWhereCondition(whereCondition, "((ProjectTaskDeadline < @Now) OR (ProjectTaskDeadline IS NULL))");
        }

        // Do not display overdue tasks
        if (!ShowOverdueTasks)
        {
            whereCondition = SqlHelper.AddWhereCondition(whereCondition, "((ProjectTaskDeadline > @Now) OR (ProjectTaskDeadline IS NULL))");
        }

        // Do not display private tasks
        if (!ShowPrivateTasks)
        {
            whereCondition = SqlHelper.AddWhereCondition(whereCondition, "ProjectTaskIsPrivate = 0");
        }

        // Task assigned to me, Task owned by me webparts
        if ((!ShowOnTimeTasks) || (!ShowOverdueTasks))
        {
            var parameters = new QueryDataParameters();
            parameters.Add("@Now", DateTime.Now);

            ucTaskList.Grid.QueryParameters = parameters;
        }

        // Add security condition - display only tasks which are assigned or owned by the current user or which are a part of a project where the current user is authorised to Read from
        whereCondition = SqlHelper.AddWhereCondition(whereCondition, ProjectTaskInfoProvider.CombineSecurityWhereCondition(whereCondition, currentUser, SiteName));

        return whereCondition;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        CurrentMaster.Title.TitleText = GetString("newsletter_issue_openedby.title");
        CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Newsletter/module.png");

        issueId = QueryHelper.GetInteger("issueid", 0);
        if (issueId == 0)
        {
            RequestHelper.EndResponse();
        }

        IssueInfo issue = IssueInfoProvider.GetIssueInfo(issueId);
        EditedObject = issue;

        // Prevent accessing issues from sites other than current site
        if (issue.IssueSiteID != CMSContext.CurrentSiteID)
        {
            RedirectToResourceNotAvailableOnSite("Issue with ID " + issueId);
        }

        // Issue is the main A/B test issue
        isMainABTestIssue = issue.IssueIsABTest && !issue.IssueIsVariant;
        if (isMainABTestIssue)
        {
            // Initialize variant selector in the filter
            fltOpenedBy.IssueId = issue.IssueID;

            if (RequestHelper.IsPostBack())
            {
                // Get issue ID from variant selector
                issueId = fltOpenedBy.IssueId;
            }

            // Reset ID for main issue, grid will show data from main and winner variant issues
            if (issueId == issue.IssueID)
            {
                issueId = 0;
            }
        }

        QueryDataParameters parameters = null;
        if (issueId > 0)
        {
            parameters = new QueryDataParameters();
            // Filter by Issue ID (from querystring or variant selector in case of A/B test issue)
            parameters.Add("@IssueID", issueId);
        }

        UniGrid.QueryParameters = parameters;
        UniGrid.WhereCondition = fltOpenedBy.WhereCondition;
        UniGrid.Pager.DefaultPageSize = PAGESIZE;
        UniGrid.Pager.ShowPageSize = false;
        UniGrid.FilterLimit = 1;
        UniGrid.OnExternalDataBound += UniGrid_OnExternalDataBound;
        UniGrid.OnBeforeDataReload += UniGrid_OnBeforeDataReload;
    }
Esempio n. 55
0
    /// <summary>
    /// Load query definition from XML.
    /// </summary>
    /// <param name="queryNode">XML query definition node</param>
    private void LoadQueryDefinition(XmlNode queryNode)
    {
        if (queryNode != null)
        {
            Query = queryNode.Attributes["name"].Value;

            // Set the columns property if columns are defined
            LoadColumns(queryNode);
            LoadAllColumns(queryNode);

            // Load the query parameters
            XmlNodeList parameters = queryNode.SelectNodes("parameter");
            if ((parameters != null) && (parameters.Count > 0))
            {
                QueryDataParameters newParams = new QueryDataParameters();

                // Process all parameters
                foreach (XmlNode param in parameters)
                {
                    object value = null;
                    string name = param.Attributes["name"].Value;

                    switch (param.Attributes["type"].Value.ToLower())
                    {
                        case "string":
                            value = param.Attributes["value"].Value;
                            break;

                        case "int":
                            value = ValidationHelper.GetInteger(param.Attributes["value"].Value, 0);
                            break;

                        case "double":
                            value = Convert.ToDouble(param.Attributes["value"].Value);
                            break;

                        case "bool":
                            value = Convert.ToBoolean(param.Attributes["value"].Value);
                            break;
                    }

                    newParams.Add(name, value);
                }

                QueryParameters = newParams;
            }
        }
    }
    /// <summary>
    /// Load data.
    /// </summary>
    public void LoadData()
    {
        mProcess = true;
        if (!Visible || StopProcessing)
        {
            EnableViewState = false;
            mProcess = false;
        }

        IsLiveSite = false;

        if (ProjectID > 0)
        {
            // Get information on current project
            mProject = ProjectInfoProvider.GetProjectInfo(ProjectID);
        }

        // Get project resource
        mResProjects = ResourceInfoProvider.GetResourceInfo("CMS.ProjectManagement");

        if ((mResProjects != null) && (mProject != null))
        {
            QueryDataParameters parameters = new QueryDataParameters();
            parameters.Add("@ID", mResProjects.ResourceId);
            parameters.Add("@ProjectID", mProject.ProjectID);
            parameters.Add("@SiteID", SiteContext.CurrentSiteID);

            string where;
            int groupId = mProject.ProjectGroupID;

            // Build where condition
            if (groupId > 0)
            {
                where = "RoleGroupID=" + groupId + " AND PermissionDisplayInMatrix = 0";
            }
            else
            {
                where = "RoleGroupID IS NULL AND PermissionDisplayInMatrix = 0";
            }

            // Setup matrix control
            gridMatrix.IsLiveSite = IsLiveSite;
            gridMatrix.QueryParameters = parameters;
            gridMatrix.WhereCondition = where;
            gridMatrix.CssClass = "permission-matrix";
        }
    }
Esempio n. 57
0
    /// <summary>
    /// Add from and to condition depending on given properties.
    /// </summary>
    private void AddTimeCondition()
    {
        QueryDataParameters parameters = new QueryDataParameters();

        if (From != DateTimeHelper.ZERO_TIME)
        {
            parameters.Add("@MVTestOpenFrom", From);

            gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, "(MVTestOpenFrom>= @MVTestOpenFrom) OR (MVTestOpenTo IS NULL)");
        }

        if (To != DateTimeHelper.ZERO_TIME)
        {
            parameters.Add("@MVTestOpenTo", To);

            gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, "(ABTestOpenTo<= @MVTestOpenTo) OR (MVTestOpenTo IS NULL) ");
        }

        gridElem.QueryParameters = parameters;
    }
    protected DataSet gridUsers_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords)
    {
        var parameters = new QueryDataParameters();
        parameters.Add("@search", "%" + txtSearch.Text + "%");
        parameters.Add("@siteID", SiteContext.CurrentSite.SiteID);

        string where = "UserName NOT LIKE N'public'";

        // If user is not global administrator
        if (!MembershipContext.AuthenticatedUser.IsGlobalAdministrator)
        {
            // Do not select hidden users
            where = SqlHelper.AddWhereCondition(where, "((UserIsHidden IS NULL) OR (UserIsHidden=0))");

            // Select only approved users
            where = SqlHelper.AddWhereCondition(where, "((UserWaitingForApproval IS NULL) OR (UserWaitingForApproval = 0))");

            // Select only enabled users
            where = SqlHelper.AddWhereCondition(where, UserInfoProvider.USER_ENABLED_WHERE_CONDITION);
        }

        // Load all users for current site
        if (SiteContext.CurrentSite != null)
        {
            // Public user has no actions
            if (MembershipContext.AuthenticatedUser.IsPublic())
            {
                gridUsers.GridView.Columns[0].Visible = false;
            }
        }

        return ConnectionHelper.ExecuteQuery("cms.user.finduserinsite", parameters, where, "UserName ASC", currentTopN, "View_CMS_User.UserID,UserName,UserNickName,FullName", currentOffset, currentPageSize, ref totalRecords);
    }
Esempio n. 59
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ci = (ContactInfo)EditedObject;
        this.CheckReadPermission(ci.ContactSiteID);

        globalContact = (ci.ContactSiteID <= 0);
        mergedContact = (ci.ContactMergedWithContactID > 0);
        modifyAllowed = ContactHelper.AuthorizedModifyContact(ci.ContactSiteID, false);

        contactId = QueryHelper.GetInteger("contactid", 0);

        string where = null;
        // Filter only site members in CMSDesk (for global contacts)
        if (!this.IsSiteManager && globalContact && AuthorizedForSiteContacts)
        {
            where += " (ContactSiteID IS NULL OR ContactSiteID=" + CMSContext.CurrentSiteID + ")";
        }

        fltElem.ShowContactNameFilter = globalContact;
        fltElem.ShowSiteFilter = this.IsSiteManager && globalContact;

        // Choose correct query according to type of contact
        if (globalContact)
        {
            gridElem.ObjectType = OnlineMarketingObjectType.MEMBERSHIPGLOBALUSERLIST;
        }
        else if (mergedContact)
        {
            gridElem.ObjectType = OnlineMarketingObjectType.MEMBERSHIPMERGEDUSERLIST;
        }
        else
        {
            gridElem.ObjectType = OnlineMarketingObjectType.MEMBERSHIPUSERLIST;
        }

        // Query parameters
        QueryDataParameters parameters = new QueryDataParameters();
        parameters.Add("@ContactId", contactId);

        where = SqlHelperClass.AddWhereCondition(where, fltElem.WhereCondition);
        gridElem.WhereCondition = where;
        gridElem.QueryParameters = parameters;
        gridElem.OnAction += new OnActionEventHandler(gridElem_OnAction);
        gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound);

        // Setup user selector
        selectUser.UniSelector.SelectionMode = SelectionModeEnum.MultipleButton;
        selectUser.UniSelector.OnItemsSelected += new EventHandler(UniSelector_OnItemsSelected);
        selectUser.UniSelector.ReturnColumnName = "UserID";
        selectUser.UniSelector.ButtonImage = GetImageUrl("Objects/CMS_User/add.png");
        selectUser.ImageDialog.CssClass = "NewItemImage";
        selectUser.LinkDialog.CssClass = "NewItemLink";
        selectUser.ShowSiteFilter = false;
        selectUser.ResourcePrefix = "addusers";
        selectUser.DialogButton.CssClass = "LongButton";
        selectUser.IsLiveSite = false;
        selectUser.SiteID = ci.ContactSiteID;

        // Hide header actions for global contact or merged contact
        this.CurrentMaster.HeaderActionsPlaceHolder.Visible = modifyAllowed && !globalContact && !mergedContact;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckUIElementAccessHierarchical(ModuleName.ONLINEMARKETING, "ContactMembership.Users");
        ci = (ContactInfo)EditedObject;
        if (ci == null)
        {
            RedirectToAccessDenied(GetString("general.invalidparameters"));
        }
        CheckReadPermission(ci.ContactSiteID);

        globalContact = (ci.ContactSiteID <= 0);
        mergedContact = (ci.ContactMergedWithContactID > 0);
        modifyAllowed = ContactHelper.AuthorizedModifyContact(ci.ContactSiteID, false);

        contactId = QueryHelper.GetInteger("contactid", 0);

        string where = null;
        // Filter only site members in CMSDesk (for global contacts)
        if (!IsSiteManager && globalContact && AuthorizedForSiteContacts)
        {
            where += " (ContactSiteID IS NULL OR ContactSiteID=" + SiteContext.CurrentSiteID + ")";
        }

        // Choose correct query according to type of contact
        if (globalContact)
        {
            gridElem.ObjectType = ContactMembershipGlobalUserListInfo.OBJECT_TYPE;
        }
        else if (mergedContact)
        {
            gridElem.ObjectType = ContactMembershipMergedUserListInfo.OBJECT_TYPE;
        }
        else
        {
            gridElem.ObjectType = ContactMembershipUserListInfo.OBJECT_TYPE;
        }

        // Query parameters
        QueryDataParameters parameters = new QueryDataParameters();
        parameters.Add("@ContactId", contactId);

        gridElem.WhereCondition = where;
        gridElem.QueryParameters = parameters;
        gridElem.OnAction += gridElem_OnAction;
        gridElem.OnExternalDataBound += gridElem_OnExternalDataBound;

        // Setup user selector
        selectUser.UniSelector.SelectionMode = SelectionModeEnum.MultipleButton;
        selectUser.UniSelector.OnItemsSelected += UniSelector_OnItemsSelected;
        selectUser.UniSelector.ReturnColumnName = "UserID";
        selectUser.ShowSiteFilter = false;
        selectUser.ResourcePrefix = "addusers";
        selectUser.IsLiveSite = false;
        selectUser.SiteID = ci.ContactSiteID;

        // Hide header actions for global contact or merged contact.
        CurrentMaster.HeaderActionsPlaceHolder.Visible = modifyAllowed && !globalContact && !mergedContact;
    }