コード例 #1
0
    /// <summary>
    /// Open the Campaign
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void lnkOpenCampaign_Click(object sender, EventArgs e)
    {
        try
        {
            LinkButton btn        = (LinkButton)sender;
            int        campaignID = ValidationHelper.GetInteger(btn.CommandArgument, 0);
            Campaign   campaign   = CampaignProvider.GetCampaigns()
                                    .WhereEquals("NodeSiteID", CurrentSite.SiteID)
                                    .WhereEquals("CampaignID", campaignID)
                                    .FirstObject;
            if (campaign != null)
            {
                campaign.OpenCampaign = true;
                campaign.Update();

                var users = UserInfoProvider.GetUsers();
                if (users != null)
                {
                    foreach (var user in users)
                    {
                        ProductEmailNotifications.CampaignEmail(campaign.DocumentName, user.Email, "CampaignOpenEmail");
                    }
                }
                Response.Redirect(CurrentDocument.DocumentUrlPath);
            }
        }
        catch (Exception ex)
        {
            EventLogProvider.LogException("CMSWebParts_Kadena_Campaign_Web_Form_CampaignWebFormActions", "lnkOpenCampaign_Click", ex, CurrentSite.SiteID, ex.Message);
        }
    }
コード例 #2
0
 /// <summary>
 /// Closing the campaign
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public static void ProcessOrders(int campaignID)
 {
     try
     {
         Campaign campaign = CampaignProvider.GetCampaigns()
                             .WhereEquals("NodeSiteID", SiteContext.CurrentSiteID)
                             .WhereEquals("CampaignID", campaignID)
                             .FirstObject;
         if (campaign != null)
         {
             var _failedOrders = DIContainer.Resolve <IFailedOrderStatusProvider>();
             _failedOrders.UpdateCampaignOrderStatus(campaign.CampaignID);
             TaskInfo runTask = TaskInfoProvider.GetTaskInfo(ScheduledTaskNames.PrebuyOrderCreation, SiteContext.CurrentSiteID);
             if (runTask != null)
             {
                 runTask.TaskRunInSeparateThread = true;
                 runTask.TaskEnabled             = true;
                 runTask.TaskData = $"{campaign.CampaignID}|{SiteContext.CurrentSiteID}";
                 SchedulingExecutor.ExecuteTask(runTask);
             }
             var users = UserInfoProvider.GetUsers();
             if (users != null)
             {
                 foreach (var user in users)
                 {
                     ProductEmailNotifications.CampaignEmail(campaign.DocumentName, user.Email, "CampaignCloseEmail");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("Kadena_CMSWebParts_Kadena_Cart_FailedOrdersCheckout", "ProcessOrders", ex, SiteContext.CurrentSiteID, ex.Message);
     }
 }
コード例 #3
0
    /// <summary>
    /// Binding the links based on admin roles
    /// </summary>
    public void BindActions()
    {
        try
        {
            Campaign campaign = CampaignProvider.GetCampaigns()
                                .WhereEquals("NodeSiteID", CurrentSite.SiteID)
                                .WhereEquals("CampaignID", CampaignID)
                                .FirstObject;

            if (campaign != null)
            {
                bool   initiated             = campaign.GetBooleanValue("CampaignInitiate", false);
                bool   IsAnyprogramNotified  = IsAnyProgramNotified(campaign);
                bool   openCampaign          = campaign.GetBooleanValue("OpenCampaign", false);
                bool   isGlobalAdminNotified = AllProgramsNotified(campaign);
                bool   closeCampaign         = campaign.GetBooleanValue("CloseCampaign", false);
                string gAdminRoleName        = SettingsKeyInfoProvider.GetValue(CurrentSite.SiteName + ".KDA_GlobalAminRoleName");
                string adminRoleName         = SettingsKeyInfoProvider.GetValue(CurrentSite.SiteName + ".KDA_AdminRoleName");

                if (CurrentUser.IsInRole(gAdminRoleName, CurrentSiteName))
                {
                    BindActionsForGlobalAdmin(initiated, openCampaign, closeCampaign, IsAnyprogramNotified, isGlobalAdminNotified);
                }
                else if (CurrentUser.IsInRole(adminRoleName, CurrentSiteName))
                {
                    BindActionsForAdmin(initiated, openCampaign, closeCampaign, IsAnyprogramNotified, isGlobalAdminNotified);
                }
            }
        }
        catch (Exception ex)
        {
            EventLogProvider.LogException("CMSWebParts_Kadena_Campaign_Web_Form_CampaignWebFormActions", "BindActions", ex, CurrentSite.SiteID, ex.Message);
        }
    }
コード例 #4
0
    /// <summary>
    /// Get the Campaign Closed or not
    /// </summary>
    /// <param name="programID"></param>
    /// <returns></returns>
    public bool IsCampaignClosed(int programID)
    {
        bool isClosed = false;

        try
        {
            Program program = ProgramProvider.GetPrograms()
                              .WhereEquals("ProgramID", programID)
                              .Columns("CampaignID")
                              .FirstOrDefault();
            if (program != null)
            {
                Campaign campaign = CampaignProvider.GetCampaigns()
                                    .WhereEquals("CampaignID", program.CampaignID).Columns("CloseCampaign")
                                    .FirstOrDefault();
                if (campaign != null)
                {
                    isClosed = campaign.CloseCampaign;
                }
            }
        }
        catch (Exception ex)
        {
            EventLogProvider.LogException("Checking campaign Closed", "IsCampaignClosed()", ex, CurrentSite.SiteID, ex.Message);
        }
        return(isClosed);
    }
コード例 #5
0
 private CMS.DocumentEngine.Types.KDA.Campaign GetCampaign(string campaignName)
 {
     return(CampaignProvider.GetCampaigns()
            .OnSite(_site)
            .Where(x => x.DocumentName.Equals(campaignName))
            .FirstOrDefault());
 }
コード例 #6
0
    /// <summary>
    /// Get the brand list
    /// </summary>
    /// <param name="brandItemID"></param>
    /// <returns></returns>
    public string GetCampaign()
    {
        string returnValue = string.Empty;

        try
        {
            var Campaigns = CampaignProvider.GetCampaigns()
                            .Columns("CampaignID,Name")
                            .WhereEquals("Status", 1)
                            .OrderBy("Name")
                            .ToList();
            if (!DataHelper.DataSourceIsEmpty(Campaigns))
            {
                ddlCampaign.DataSource     = Campaigns;
                ddlCampaign.DataTextField  = "Name";
                ddlCampaign.DataValueField = "CampaignID";
                ddlCampaign.DataBind();
                string selectText = ValidationHelper.GetString(ResHelper.GetString("Kadena.ProgramForm.CampaignWaterMark"), string.Empty);
                ddlCampaign.Items.Insert(0, new ListItem(selectText, "0"));
            }
        }
        catch (Exception ex)
        {
            EventLogProvider.LogException("CMSWebParts_Kadena_Campaign_Web_Form_AddCampaignProducts", "GetCampaignName", ex, CurrentSite.SiteID, ex.Message);
        }
        return(returnValue);
    }
コード例 #7
0
 private void BindCampaignList(ISheet sheet)
 {
     string[] campaignNames = CampaignProvider.GetCampaigns().OnCurrentSite().Select(x => x.Name).ToArray();
     if (campaignNames != null && campaignNames.Count() > 0)
     {
         AddOneFromManyValidation(0, "CampaignNames", campaignNames, sheet);
     }
 }
コード例 #8
0
    /// <summary>
    /// Update Program
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnUpdateProgram_Click(object sender, EventArgs e)
    {
        try
        {
            int          campaignID = ValidationHelper.GetInteger(ddlCampaign.SelectedValue, 0);
            TreeProvider tree       = new TreeProvider(MembershipContext.AuthenticatedUser);
            if (Page.IsValid)
            {
                if (ViewState["programNodeID"] != null)
                {
                    if (ValidationHelper.GetDate(txtProgramDeliveryDate.Text, default(DateTime)).Date >= DateTime.Today)
                    {
                        Program program = ProgramProvider.GetProgram(ValidationHelper.GetInteger(ViewState["programNodeID"], 0), CurrentDocument.DocumentCulture, CurrentSiteName);

                        if (program != null)
                        {
                            program.DocumentName               = txtProgramName.Text;
                            program.ProgramName                = txtProgramName.Text;
                            program.ProgramDescription         = txtProgramDescription.Text;
                            program.BrandID                    = ValidationHelper.GetInteger(ddlBrand.SelectedValue, 0);
                            program.CampaignID                 = ValidationHelper.GetInteger(ddlCampaign.SelectedValue, 0);
                            program.Status                     = ValidationHelper.GetBoolean(ddlStatus.SelectedValue, true);
                            program.DeliveryDateToDistributors = ValidationHelper.GetDate(txtProgramDeliveryDate.Text, default(DateTime)).Date;
                            program.Update();
                        }
                        if (ViewState["CampaignID"] != null)
                        {
                            if (Convert.ToInt32(ViewState["CampaignID"]) != campaignID)
                            {
                                Campaign targetCampaign = CampaignProvider.GetCampaigns().WhereEquals("CampaignID", campaignID).FirstOrDefault();
                                if (targetCampaign != null && program != null)
                                {
                                    DocumentHelper.MoveDocument(program, targetCampaign, tree, true);
                                }
                            }
                        }
                        Response.Cookies["status"].Value    = QueryStringStatus.Updated;
                        Response.Cookies["status"].HttpOnly = false;
                        URLHelper.Redirect($"{CurrentDocument.Parent.DocumentUrlPath}?status={QueryStringStatus.Updated}");
                    }
                }
            }
        }
        catch (Exception ex)
        {
            EventLogProvider.LogInformation("CMSWebParts_Kadena_Programs_AddNewProgram", "btnUpdateProgram_Click", ex.Message);
        }
    }
コード例 #9
0
 /// <summary>
 /// returns open campaign
 /// </summary>
 /// <param name="inventoryType"></param>
 /// <returns></returns>
 public static Campaign GetOpenCampaign()
 {
     try
     {
         return(CampaignProvider.GetCampaigns().Columns("CampaignID,Name,StartDate,EndDate")
                .WhereEquals("OpenCampaign", true)
                .Where(new WhereCondition().WhereEquals("CloseCampaign", false).Or()
                       .WhereEquals("CloseCampaign", null))
                .WhereEquals("NodeSiteID", SiteContext.CurrentSiteID).FirstOrDefault());
     }
     catch (Exception ex)
     {
         EventLogProvider.LogInformation("ShoppingCartHelper", "GetOrderTotal", ex.Message);
         return(null);
     }
 }
コード例 #10
0
    /// <summary>
    /// Get the Program Ids in Open Campaign
    /// </summary>
    /// <returns></returns>
    public List <int> GetProgramIDs(int campaignID = default(int), int programID = default(int))
    {
        List <int> programIds = new List <int>();

        try
        {
            List <Campaign> campaigns = new List <Campaign>();
            if (campaignID != default(int))
            {
                campaigns = CampaignProvider.GetCampaigns()
                            .WhereEquals("CloseCampaign", true)
                            .Columns("CampaignID")
                            .WhereEquals("CampaignID", campaignID)
                            .ToList();
            }
            else
            {
                campaigns = CampaignProvider.GetCampaigns()
                            .Columns("CampaignID")
                            .WhereEquals("CloseCampaign", true)
                            .ToList();
            }
            if (!DataHelper.DataSourceIsEmpty(campaigns))
            {
                foreach (var campaign in campaigns)
                {
                    var programs = ProgramProvider.GetPrograms()
                                   .WhereEquals("CampaignID", campaign.CampaignID)
                                   .Columns("ProgramID")
                                   .ToList();
                    if (!DataHelper.DataSourceIsEmpty(programs))
                    {
                        foreach (var program in programs)
                        {
                            programIds.Add(program.ProgramID);
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            EventLogProvider.LogException("Get ProgramsIDs from CVampaign", "GetProgramIDs()", ex, CurrentSite.SiteID, ex.Message);
        }
        return(programIds);
    }
コード例 #11
0
 /// <summary>
 /// Redirect to products list
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void lnkUpdateProducts_Click(object sender, EventArgs e)
 {
     try
     {
         LinkButton btn        = (LinkButton)sender;
         int        campaignID = ValidationHelper.GetInteger(btn.CommandArgument, 0);
         Campaign   campaign   = CampaignProvider.GetCampaigns()
                                 .WhereEquals("NodeSiteID", CurrentSite.SiteID)
                                 .WhereEquals("CampaignID", campaignID)
                                 .FirstObject;
         Response.Redirect(campaign.DocumentUrlPath);
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("CMSWebParts_Kadena_Campaign_Web_Form_CampaignWebFormActions", "lnkUpdateProducts_Click", ex, CurrentSite.SiteID, ex.Message);
     }
 }
コード例 #12
0
 /// <summary>
 /// Closing the campaign
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void lnkCloseCampaign_Click(object sender, EventArgs e)
 {
     try
     {
         LinkButton btn        = (LinkButton)sender;
         int        campaignID = ValidationHelper.GetInteger(btn.CommandArgument, 0);
         if (!DIContainer.Resolve <IShoppingCartProvider>().ValidateAllCarts(campaignID: campaignID))
         {
             Response.Cookies["status"].Value    = QueryStringStatus.InvalidCartItems;
             Response.Cookies["status"].HttpOnly = false;
             return;
         }
         Campaign campaign = CampaignProvider.GetCampaigns()
                             .WhereEquals("NodeSiteID", CurrentSite.SiteID)
                             .WhereEquals("CampaignID", campaignID)
                             .FirstObject;
         if (campaign != null)
         {
             campaign.CloseCampaign = true;
             campaign.Update();
             var oderStatus = DIContainer.Resolve <IFailedOrderStatusProvider>();
             oderStatus.InsertCampaignOrdersInProgress(campaign.CampaignID);
             TaskInfo runTask = TaskInfoProvider.GetTaskInfo(ScheduledTaskNames.PrebuyOrderCreation, CurrentSite.SiteID);
             if (runTask != null)
             {
                 runTask.TaskRunInSeparateThread = true;
                 runTask.TaskEnabled             = true;
                 runTask.TaskData = $"{campaign.CampaignID}|{CurrentUser.UserID}";
                 SchedulingExecutor.ExecuteTask(runTask);
             }
             var users = UserInfoProvider.GetUsers();
             if (users != null)
             {
                 foreach (var user in users)
                 {
                     ProductEmailNotifications.CampaignEmail(campaign.DocumentName, user.Email, "CampaignCloseEmail");
                 }
             }
             Response.Redirect(CurrentDocument.DocumentUrlPath);
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("CMSWebParts_Kadena_Campaign_Web_Form_CampaignWebFormActions", "lnkCloseCampaign_Click", ex, CurrentSite.SiteID, ex.Message);
     }
 }
コード例 #13
0
 /// <summary>
 /// checking if Inbound form is finalized
 /// </summary>
 /// <param name="programID"></param>
 /// <returns></returns>
 public bool IsIBTFClosed(int?programID)
 {
     try
     {
         var program  = ProgramProvider.GetPrograms().WhereEquals("ProgramID", programID).Column("CampaignID").FirstOrDefault();
         var campaign = CampaignProvider.GetCampaigns().WhereEquals("CampaignID", program?.CampaignID ?? 0).FirstOrDefault();
         if (campaign != null)
         {
             return(campaign?.IBTFFinalized ?? false);
         }
         return(false);
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("IsIBTFClosed", "checking if IBTF of particular campaign is closed", ex, CurrentSite.SiteID, ex.Message);
         return(false);
     }
 }
コード例 #14
0
        public static object IsCampaignOpen(EvaluationContext context, params object[] parameters)
        {
            bool IsOpen = false;

            try
            {
                var campaign = CampaignProvider.GetCampaigns()
                               .WhereEquals("OpenCampaign", true)
                               .WhereEqualsOrNull("CloseCampaign", false)
                               .WhereEquals("NodeSiteID", SiteContext.CurrentSite.SiteID)
                               .FirstOrDefault();
                return(campaign != null ? campaign.StartDate <= DateTime.Now.Date && campaign.EndDate >= DateTime.Now.Date ? true : false : false);
            }
            catch (Exception ex)
            {
                EventLogProvider.LogInformation("Kadena Macro methods", "IsCampaignOpen", ex.Message);
                return(IsOpen);
            }
        }
コード例 #15
0
 /// <summary>
 /// Create New Program
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnAddProgram_Click(object sender, EventArgs e)
 {
     try
     {
         int campaignID = ValidationHelper.GetInteger(ddlCampaign.SelectedValue, 0);
         if (campaignID != 0)
         {
             Campaign     campaign     = new Campaign();
             TreeProvider tree         = new TreeProvider(MembershipContext.AuthenticatedUser);
             Campaign     CampaignNode = CampaignProvider.GetCampaigns().WhereEquals("CampaignID", campaignID).FirstOrDefault();
             if (Page.IsValid)
             {
                 if (CampaignNode != null)
                 {
                     if (ValidationHelper.GetDate(txtProgramDeliveryDate.Text, default(DateTime)).Date >= DateTime.Today)
                     {
                         Program program = new Program()
                         {
                             DocumentName               = txtProgramName.Text,
                             DocumentCulture            = SiteContext.CurrentSite.DefaultVisitorCulture,
                             ProgramName                = txtProgramName.Text,
                             ProgramDescription         = txtProgramDescription.Text,
                             BrandID                    = ValidationHelper.GetInteger(ddlBrand.SelectedValue, 0),
                             CampaignID                 = ValidationHelper.GetInteger(ddlCampaign.SelectedValue, 0),
                             Status                     = ValidationHelper.GetBoolean(ddlStatus.SelectedValue, true),
                             DeliveryDateToDistributors = ValidationHelper.GetDate(txtProgramDeliveryDate.Text, default(DateTime)).Date
                         };
                         program.Insert(CampaignNode, true);
                         Response.Cookies["status"].Value    = QueryStringStatus.Added;
                         Response.Cookies["status"].HttpOnly = false;
                         URLHelper.Redirect($"{CurrentDocument.Parent.DocumentUrlPath}?status={QueryStringStatus.Added}");
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogInformation("CMSWebParts_Kadena_Programs_AddNewProgram", "btnAddProgram_Click", ex.Message);
     }
 }
コード例 #16
0
 public static string GetCampaignNameByID(EvaluationContext context, params object[] parameters)
 {
     try
     {
         int    campaignID   = ValidationHelper.GetInteger(parameters[0], 0);
         string campaignName = string.Empty;
         var    campaign     = CampaignProvider.GetCampaigns().Columns("Name")
                               .WhereEquals("CampaignID", campaignID)
                               .WhereEquals("NodeSiteID", SiteContext.CurrentSiteID).FirstOrDefault();
         if (campaign != null)
         {
             campaignName = ValidationHelper.GetString(campaign.GetValue("Name"), string.Empty);
         }
         return(campaignName);
     }
     catch (Exception ex)
     {
         EventLogProvider.LogInformation("Kadena Macro methods", "BindPrograms", ex.Message);
         return(string.Empty);
     }
 }
コード例 #17
0
 /// <summary>
 /// Bind the Campaigns to dropdown
 /// </summary>
 public void BindCampaigns()
 {
     try
     {
         var camapaigns = CampaignProvider.GetCampaigns().Columns("CampaignID,Name")
                          .Where(new WhereCondition().WhereEquals("CloseCampaign", true))
                          .WhereEquals("NodeSiteID", CurrentSite.SiteID).OrderBy(x => x.Name).ToList();
         if (!DataHelper.DataSourceIsEmpty(camapaigns))
         {
             ddlCampaign.DataSource     = camapaigns;
             ddlCampaign.DataTextField  = "Name";
             ddlCampaign.DataValueField = "CampaignID";
             ddlCampaign.DataBind();
             string selectText = ValidationHelper.GetString(ResHelper.GetString("Kadena.CampaignProduct.SelectCampaignText"), string.Empty);
             ddlCampaign.Items.Insert(0, new ListItem(selectText, "0"));
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("Bind Campaigns to dropdown", "BindCampaigns()", ex, CurrentSite.SiteID, ex.Message);
     }
 }
コード例 #18
0
 public static string GetCampaignName(EvaluationContext context, params object[] parameters)
 {
     try
     {
         string campaignName = string.Empty;
         var    campaign     = CampaignProvider.GetCampaigns().Columns("Name")
                               .WhereEquals("OpenCampaign", true)
                               .Where(new WhereCondition().WhereEquals("CloseCampaign", false).Or()
                                      .WhereEquals("CloseCampaign", null))
                               .WhereEquals("NodeSiteID", SiteContext.CurrentSiteID).FirstOrDefault();
         if (campaign != null)
         {
             campaignName = ValidationHelper.GetString(campaign.GetValue("Name"), string.Empty);
         }
         return(campaignName);
     }
     catch (Exception ex)
     {
         EventLogProvider.LogInformation("Kadena Macro methods", "BindPrograms", ex.Message);
         return(string.Empty);
     }
 }
コード例 #19
0
 /// <summary>
 /// Binding programs based on campaign
 /// </summary>
 private void BindPrograms()
 {
     try
     {
         var campaign = CampaignProvider.GetCampaigns().Columns("CampaignID").WhereEquals("OpenCampaign", true).WhereEquals("NodeSiteID", CurrentSite.SiteID).FirstOrDefault();
         if (ValidationHelper.GetInteger(campaign.GetValue("CampaignID"), default(int)) != default(int))
         {
             var programs = ProgramProvider.GetPrograms().WhereEquals("NodeSiteID", CurrentSite.SiteID).WhereEquals("CampaignID", ValidationHelper.GetInteger(campaign.GetValue("CampaignID"), default(int))).Columns("ProgramName,ProgramID").Select(x => new Program {
                 ProgramID = x.ProgramID, ProgramName = x.ProgramName
             }).ToList().OrderBy(y => y.ProgramName);
             if (programs != null)
             {
                 ddlPrograms.DataSource     = programs;
                 ddlPrograms.DataTextField  = "ProgramName";
                 ddlPrograms.DataValueField = "ProgramID";
                 ddlPrograms.DataBind();
             }
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("CMSWebParts_Kadena_Catalog_PrebuyProductsFilter", ex.Message, ex);
     }
 }