Пример #1
0
 /// <summary>
 /// Nottify Admin
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnNotifyAdmin_Click(object sender, EventArgs e)
 {
     try
     {
         var      nodeGuid      = CurrentDocument.NodeGUID;
         var      emailTemplate = DIContainer.Resolve <IKenticoResourceService>().GetSettingsKey(SiteContext.CurrentSiteID, "KDA_CampaignProductAddedTemplate");
         Campaign campaign      = CampaignProvider.GetCampaign(nodeGuid, CurrentDocument.DocumentCulture, CurrentSite.SiteName);
         var      program       = ProgramProvider.GetPrograms()
                                  .WhereEquals("ProgramId", ddlPrograms.SelectedValue)
                                  .FirstOrDefault();
         if (program != null)
         {
             program.GlobalAdminNotified = true;
             program.Update();
             var roleName = SettingsKeyInfoProvider.GetValue(CurrentSite.SiteName + ".KDA_GlobalAminRoleName");
             var role     = RoleInfoProvider.GetRoleInfo(roleName, CurrentSite.SiteID);
             if (role != null)
             {
                 var users = RoleInfoProvider.GetRoleUsers(role.RoleID);
                 if (users != null)
                 {
                     foreach (var user in users.AsEnumerable().ToList())
                     {
                         ProductEmailNotifications.CampaignEmail(campaign.DocumentName, user.Field <string>("Email"), emailTemplate, program.DocumentName);
                     }
                 }
             }
             Response.Redirect(CurrentDocument.DocumentUrlPath, false);
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("CMSWebParts_Kadena_Campaign_Web_Form_CampaignProductsFilter", "btnNotifyAdmin_Click", ex, CurrentSite.SiteID, ex.Message);
     }
 }
Пример #2
0
    /// <summary>
    /// Bind the edit button based on roles.
    /// </summary>
    public void BindEditButton()
    {
        try
        {
            Campaign campaign = CampaignProvider.GetCampaign(CurrentDocument.NodeGUID, CurrentDocument.DocumentCulture, CurrentSiteName);
            if (campaign != null)
            {
                bool initiated             = campaign.GetBooleanValue("CampaignInitiate", false);
                bool openCampaign          = campaign.GetBooleanValue("OpenCampaign", false);
                bool isGlobalAdminNotified = campaign.GetBooleanValue("GlobalAdminNotified", false);
                bool closeCampaign         = campaign.GetBooleanValue("CloseCampaign", false);

                string globalAdminRoleName = SettingsKeyInfoProvider.GetValue(CurrentSite.SiteName + ".KDA_GlobalAminRoleName");
                string adminRoleName       = SettingsKeyInfoProvider.GetValue(CurrentSite.SiteName + ".KDA_AdminRoleName");

                lnkEdit.Text = ValidationHelper.GetString(ResHelper.GetString("Kadena.CampaignProduct.EditProductLink"), string.Empty);
                if (CurrentUser.IsInRole(globalAdminRoleName, CurrentSiteName))
                {
                    if (!openCampaign && !closeCampaign)
                    {
                        lnkEdit.Visible = true;
                        lnkEdit.Enabled = true;
                        BindEditURL();
                    }
                    else
                    {
                        lnkEdit.Visible  = true;
                        lnkEdit.Enabled  = false;
                        lnkEdit.CssClass = "disable";
                    }
                }
                else if (CurrentUser.IsInRole(adminRoleName, CurrentSiteName))
                {
                    if (!isGlobalAdminNotified && !openCampaign && !closeCampaign)
                    {
                        lnkEdit.Visible = true;
                        lnkEdit.Enabled = true;
                        BindEditURL();
                    }
                    else if (isGlobalAdminNotified || openCampaign || !closeCampaign)
                    {
                        lnkEdit.Visible  = true;
                        lnkEdit.Enabled  = false;
                        lnkEdit.CssClass = "disable";
                    }
                }
            }
        }
        catch (Exception ex)
        {
            EventLogProvider.LogException("CMSWebParts_Kadena_Campaign_Web_Form_ProductEditButton", "BindEditButton", ex, CurrentSite.SiteID, ex.Message);
        }
    }
Пример #3
0
 /// <summary>
 /// Binding the busttons based on roles
 /// </summary>
 public void BindButtons()
 {
     try
     {
         var      nodeGuid = CurrentDocument.NodeGUID;
         Campaign campaign = CampaignProvider.GetCampaign(nodeGuid, CurrentDocument.DocumentCulture, CurrentSite.SiteName);
         if (campaign != null)
         {
             var products = campaign.AllChildren.WithAllData
                            .Where(xx => xx.ClassName == CampaignsProduct.CLASS_NAME && xx.NodeSiteID == CurrentSite.SiteID)
                            .ToList();
             bool    initiated      = campaign.CampaignInitiate;
             bool    openCampaign   = campaign.OpenCampaign;
             bool    closeCampaign  = campaign.CloseCampaign;
             string  gAdminRoleName = SettingsKeyInfoProvider.GetValue(CurrentSite.SiteName + ".KDA_GlobalAminRoleName");
             string  adminRoleName  = SettingsKeyInfoProvider.GetValue(CurrentSite.SiteName + ".KDA_AdminRoleName");
             Program program        = ProgramProvider.GetPrograms()
                                      .WhereEquals("ProgramId", ddlPrograms.SelectedValue)
                                      .FirstOrDefault();
             var  gAdminNotified    = program != null ? program.GlobalAdminNotified : false;
             bool gAdminNotifiedAll = IsCampaignNotified();
             var  productsExist     = ProgramHasProducts(CurrentDocument.NodeID);
             if (CurrentUser.IsInRole(gAdminRoleName, SiteContext.CurrentSiteName))
             {
                 BindActionsForGlobalAdmin(initiated, openCampaign, closeCampaign, gAdminNotified, gAdminNotifiedAll, productsExist, program);
             }
             else if (CurrentUser.IsInRole(adminRoleName, SiteContext.CurrentSiteName))
             {
                 BindActionsForAdmin(initiated, openCampaign, closeCampaign, gAdminNotified, gAdminNotifiedAll, productsExist, program);
             }
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("CMSWebParts_Kadena_Campaign_Web_Form_CampaignProductsFilter", "BindButtons", ex, CurrentSite.SiteID, ex.Message);
     }
 }