コード例 #1
0
 /// <summary>
 /// Bind the prograns to dropdown
 /// </summary>
 public void BindPrograms()
 {
     try
     {
         int campaignID = CurrentDocument.GetIntegerValue("CampaignID", default(int));
         if (campaignID != default(int))
         {
             var programs = ProgramProvider.GetPrograms()
                            .WhereEquals("NodeSiteID", CurrentSite.SiteID)
                            .WhereEquals("CampaignID", campaignID)
                            .Columns("ProgramID,ProgramName")
                            .ToList();
             if (programs != null)
             {
                 ddlPrograms.DataSource     = programs;
                 ddlPrograms.DataTextField  = "ProgramName";
                 ddlPrograms.DataValueField = "ProgramID";
                 ddlPrograms.DataBind();
                 string selectText = ValidationHelper.GetString(ResHelper.GetString("Kadena.CampaignProduct.SelectProgramText"), string.Empty);
                 ddlPrograms.Items.Insert(0, new ListItem(selectText, "0"));
             }
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("CMSWebParts_Kadena_Campaign_Web_Form_CampaignProductsFilter", "BindPrograms", ex, CurrentSite.SiteID, ex.Message);
     }
 }
コード例 #2
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);
     }
 }
コード例 #3
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);
    }
コード例 #4
0
 /// <summary>
 /// Binding programs based on campaign
 /// </summary>
 public void BindPrograms()
 {
     try
     {
         if ((OpenCampaign?.CampaignID ?? default(int)) != default(int))
         {
             var programs = ProgramProvider.GetPrograms()
                            .WhereEquals("NodeSiteID", CurrentSite.SiteID)
                            .WhereEquals("CampaignID", ValidationHelper.GetInteger(OpenCampaign.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";
                 string selectText = ValidationHelper.GetString(ResHelper.GetString("Kadena.Catalog.SelectProgramText"), string.Empty);
                 ddlPrograms.DataBind();
             }
         }
         ddlPrograms.Items.Insert(0, new ListItem(ResHelper.GetString("Kadena.Catalog.SelectProgramText"), "0"));
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("CMSWebParts_Kadena_CustomCatalogFilter BindPrograms", ex.Message, ex);
     }
 }
コード例 #5
0
 /// <summary>
 /// Bind the Program to dropdown
 /// </summary>
 public void BindPrograms()
 {
     try
     {
         if (OpenCampaign != null)
         {
             if (OpenCampaign.CampaignID != default(int))
             {
                 var programs = ProgramProvider.GetPrograms()
                                .WhereEquals("NodeSiteID", CurrentSite.SiteID)
                                .WhereEquals("CampaignID", OpenCampaign.CampaignID)
                                .Columns("ProgramName,ProgramID")
                                .ToList();
                 if (!DataHelper.DataSourceIsEmpty(programs))
                 {
                     ddlProgram.DataSource     = programs;
                     ddlProgram.DataTextField  = "ProgramName";
                     ddlProgram.DataValueField = "ProgramID";
                     ddlProgram.DataBind();
                     string selectText = ValidationHelper.GetString(ResHelper.GetString("Kadena.CampaignProduct.SelectProgramText"), string.Empty);
                     ddlProgram.Items.Insert(0, new ListItem(selectText, "0"));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("Bind Programs to dropdown", "BindPrograms()", ex, CurrentSite.SiteID, ex.Message);
     }
 }
コード例 #6
0
 private void BindProgramList(ISheet sheet)
 {
     string[] programNames = ProgramProvider.GetPrograms().OnCurrentSite().Select(x => x.ProgramName).ToArray();
     if (programNames != null && programNames.Count() > 0)
     {
         AddOneFromManyValidation(1, "ProgramNames", programNames, sheet);
     }
 }
コード例 #7
0
        public ActionResult Index(string Search, string Status, string Type, string Tags, string Category, DateTime? FromDate, DateTime? ToDate)
        {
            using (var provider = new ProgramProvider())
            {
                var programs = provider.Filter(Search, Status, Type, Tags, Category, FromDate, ToDate);

                return View(programs.Select(x => x.Program).OrderBy(x => x.Name));
            }
        }
コード例 #8
0
 public bool DeleteProgram(int programID)
 {
     if (programID != 0)
     {
         Program program = ProgramProvider.GetPrograms().WhereEquals("ProgramID", programID).TopN(1).FirstOrDefault();
         program.Delete();
         return(true);
     }
     return(false);
 }
コード例 #9
0
 void OnClose()
 {
     if (!EnsureSaved())
     {
         return;
     }
     ProgramProvider.Reset();
     CloseCommand.RaiseCanExecuteChanged();
     SaveAsCommand.RaiseCanExecuteChanged();
 }
コード例 #10
0
 void OnNew()
 {
     if (!EnsureSaved())
     {
         return;
     }
     ProgramProvider.Reset();
     CloseCommand.RaiseCanExecuteChanged();
     SaveAsCommand.RaiseCanExecuteChanged();
     StatusUpdateProvider.Publish(Resources.Strings.TitleBarViewModel_CreatedNewProgram);
 }
コード例 #11
0
 /// <summary>
 /// Initializes the control properties.
 /// </summary>
 protected void SetupControl()
 {
     if (this.StopProcessing)
     {
         // Do not process
     }
     else
     {
         lblProgramName.InnerText        = ProgramNameText;
         lblProgramDescription.InnerText = ProgramDescriptionText;
         lblBrandName.InnerText          = BrandNameText;
         lblCampaignName.InnerText       = CampaignNameText;
         btnAddProgram.Text  = SaveButtonText;
         lblStatus.InnerText = StatusTest;
         lblProgramDeliveryDate.InnerText = DeliveryDateToDistributors;
         btnCancelProgram.Text            = CancelButtonText;
         btnUpdateProgram.Text            = UpdateButtonText;
         programNameRequired.ErrorMessage = ResHelper.GetString("Kadena.Programs.ProgramNameRequired");
         revDescription.ErrorMessage      = ResHelper.GetString("Kadena.Programs.ProgramDescError");
         revProgramName.ErrorMessage      = ResHelper.GetString("Kadena.Programs.ProgramNameRangeMessage");
         compareDate.ErrorMessage         = ResHelper.GetString("Kadena.Programs.DeliveryDateRangeMessage");
         GetBrandName();
         GetCampaign();
         BindStatus();
         int programID = ValidationHelper.GetInteger(Request.QueryString["id"], 0);
         if (programID != 0)
         {
             Program program = ProgramProvider.GetPrograms().WhereEquals("ProgramID", programID).TopN(1).FirstOrDefault();
             if (program != null)
             {
                 txtProgramName.Text         = program.ProgramName;
                 txtProgramDescription.Text  = program.ProgramDescription;
                 ddlBrand.SelectedValue      = program.BrandID.ToString();
                 txtProgramDeliveryDate.Text = program.DeliveryDateToDistributors == default(DateTime) ? string.Empty : program.DeliveryDateToDistributors.ToShortDateString();
                 ddlCampaign.SelectedValue   = program.CampaignID.ToString();
                 btnAddProgram.Visible       = false;
                 btnUpdateProgram.Visible    = true;
                 ViewState["CampaignID"]     = program.CampaignID;
                 ViewState["programNodeID"]  = program.NodeID;
             }
         }
         else
         {
             btnAddProgram.Visible    = true;
             btnUpdateProgram.Visible = false;
         }
         if (!IsPostBack)
         {
             string currentDate = DateTime.Today.ToShortDateString();
             compareDate.ValueToCompare = currentDate;
         }
     }
 }
コード例 #12
0
 /// <summary>
 /// Bind programs to dropdown
 /// </summary>
 public void BindPrograms()
 {
     try
     {
         int capaignNodeID = ValidationHelper.GetInteger(Request.QueryString["camp"], default(int));
         if (capaignNodeID != default(int))
         {
             TreeProvider tree     = new TreeProvider(MembershipContext.AuthenticatedUser);
             var          campaign = DocumentHelper.GetDocument(capaignNodeID, CurrentDocument.DocumentCulture, tree);
             if (!DataHelper.DataSourceIsEmpty(campaign))
             {
                 int campaignID = campaign.GetIntegerValue("CampaignID", default(int));
                 if (campaignID != default(int))
                 {
                     var programs = ProgramProvider.GetPrograms()
                                    .WhereEquals("NodeSiteID", CurrentSite.SiteID)
                                    .WhereEquals("CampaignID", campaignID)
                                    .WhereEquals("Status", true)
                                    .WhereEqualsOrNull("GlobalAdminNotified", false)
                                    .Columns("ProgramName,ProgramID")
                                    .Select(x => new Program {
                         ProgramID = x.ProgramID, ProgramName = x.ProgramName
                     })
                                    .ToList();
                     if (programs.Count > 0)
                     {
                         if (!DataHelper.DataSourceIsEmpty(programs))
                         {
                             ddlProgram.DataSource     = programs;
                             ddlProgram.DataTextField  = "ProgramName";
                             ddlProgram.DataValueField = "ProgramID";
                             ddlProgram.DataBind();
                             string selectText = ValidationHelper.GetString(ResHelper.GetString("Kadena.CampaignProduct.SelectProgramText"), string.Empty);
                             ddlProgram.Items.Insert(0, new ListItem(selectText, "0"));
                         }
                     }
                     else
                     {
                         AddProductdiv.Visible = false;
                         Emptydata.Visible     = true;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("CMSWebParts_Kadena_Campaign_Web_Form_AddCampaignProducts", "BindPrograms", ex, CurrentSite.SiteID, ex.Message);
     }
 }
コード例 #13
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);
        }
    }
コード例 #14
0
 public static object GetProgramName(EvaluationContext context, params object[] parameters)
 {
     try
     {
         int     programID   = ValidationHelper.GetInteger(parameters[0], 0);
         string  programName = string.Empty;
         Program program     = ProgramProvider.GetPrograms().WhereEquals("NodeSiteID", SiteContext.CurrentSite.SiteID).WhereEquals("ProgramID", programID).Columns("ProgramName").FirstObject;
         programName = program?.ProgramName ?? string.Empty;
         return(programName);
     }
     catch (Exception ex)
     {
         EventLogProvider.LogInformation("Kadena Macro methods", "GetProgramName", ex.Message);
         return(string.Empty);
     }
 }
コード例 #15
0
 /// <summary>
 /// Bind Brand name to textbox using program id
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void ddlProgram_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         int programID = ValidationHelper.GetInteger(ddlProgram.SelectedValue, 0);
         if (programID != 0)
         {
             var program = ProgramProvider.GetPrograms()
                           .WhereEquals("NodeSiteID", CurrentSite.SiteID)
                           .WhereEquals("ProgramID", programID)
                           .FirstOrDefault();
             if (program != null)
             {
                 int brandItemID = program.BrandID;
                 if (brandItemID != 0)
                 {
                     ddlBrand.SelectedValue = brandItemID.ToString();
                     hfBrandItemID.Value    = brandItemID.ToString();
                     var brand = CustomTableItemProvider.GetItems(BrandItem.CLASS_NAME)
                                 .WhereEquals("ItemID", brandItemID)
                                 .Columns("ItemID,BrandCode").FirstOrDefault();
                     if (brand != null)
                     {
                         var pos = ConnectionHelper.ExecuteQuery("KDA.CampaignsProduct.GetCampaignPos", null, "CTE.POSNumber is null and KDA_POSNumber.BrandId=" + ValidationHelper.GetInteger(brand.GetValue("BrandCode"), 0));
                         if (!DataHelper.DataSourceIsEmpty(pos))
                         {
                             ddlPos.DataSource     = pos;
                             ddlPos.DataTextField  = "POSNumber";
                             ddlPos.DataValueField = "POSNumber";
                             ddlPos.DataBind();
                             string selectText = ValidationHelper.GetString(ResHelper.GetString("Kadena.CampaignProduct.SelectPOSText"), string.Empty);
                             ddlPos.Items.Insert(0, new ListItem(selectText, "0"));
                         }
                         else
                         {
                             ddlPos.Items.Clear();
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("CMSWebParts_Kadena_Campaign_Web_Form_AddCampaignProducts", "ddlProgram_SelectedIndexChanged ", ex, CurrentSite.SiteID, ex.Message);
     }
 }
コード例 #16
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);
    }
コード例 #17
0
 /// <summary>
 /// This methods returns inner HTML for pdf
 /// </summary>
 /// <param name="distributorCartData"></param>
 /// <returns></returns>
 public static string CreateCartInnerContent(List <DataRow> distributorCartData, string CurrentSiteName, int inventoryType)
 {
     try
     {
         string pdfProductContent = string.Empty;
         if (inventoryType == Convert.ToInt32(ProductType.GeneralInventory))
         {
             pdfProductContent = SettingsKeyInfoProvider.GetValue($@"{CurrentSiteName}.KDA_DistributorCartPDFHTMLBodyGI");
         }
         else
         {
             pdfProductContent = SettingsKeyInfoProvider.GetValue($@"{CurrentSiteName}.KDA_DistributorCartPDFHTMLBody");
         }
         StringBuilder sb       = new StringBuilder();
         var           skuIds   = distributorCartData.AsEnumerable().Select(x => x.Field <int>("SkUID")).ToList();
         var           products = CampaignsProductProvider.GetCampaignsProducts()
                                  .WhereEquals("NodeSiteID", SiteContext.CurrentSiteID).WhereIn("NodeSKUID", skuIds).Columns("NodeSKUID,State,ProgramID,QtyPerPack,EstimatedPrice").ToList();
         var programs    = ProgramProvider.GetPrograms().WhereIn("ProgramID", products.Select(x => x.ProgramID).ToList()).Columns("ProgramID,ProgramName").ToList();
         var stateGroups = CustomTableItemProvider.GetItems <StatesGroupItem>().WhereIn("ItemID", products.Select(x => x.State).ToList()).Columns("ItemID,States").ToList();
         distributorCartData.ForEach(row =>
         {
             var pdfContent  = pdfProductContent;
             var product     = products.Where(x => x.NodeSKUID == ValidationHelper.GetInteger(row["SKUID"], default(int))).FirstOrDefault();
             var programName = programs.Where(x => x.ProgramID == product.ProgramID).FirstOrDefault();
             var states      = stateGroups.Where(x => x.ItemID == product.State).FirstOrDefault();
             var skuValidity = ValidationHelper.GetDateTime(row["SKUValidUntil"], default(DateTime));
             pdfContent      = pdfContent.Replace("{PRODUCTNAME}", ValidationHelper.GetString(row["SKUName"], "&nbsp"))
                               .Replace("{SKUNUMBER}", ValidationHelper.GetString(row["SKUProductCustomerReferenceNumber"], "&nbsp"))
                               .Replace("{SKUUNITS}", ValidationHelper.GetString(row["SKUUnits"], "&nbsp"))
                               .Replace("{BUNDLECOST}", inventoryType == Convert.ToInt32(ProductType.GeneralInventory) ? ($"{CurrencyInfoProvider.GetFormattedPrice(ValidationHelper.GetDouble(row["SKUPrice"], default(double)), SiteContext.CurrentSiteID, true)}") : ($"{CurrencyInfoProvider.GetFormattedPrice(ValidationHelper.GetDouble(product.EstimatedPrice, default(double)), SiteContext.CurrentSiteID, true)}"))
                               .Replace("{BUNDLEQUANTITY}", ValidationHelper.GetString(product.QtyPerPack, "&nbsp"))
                               .Replace("{IMAGEURL}", GetProductImage(ValidationHelper.GetString(row["SKUImagePath"], default(string))))
                               .Replace("{VALIDSTATES}", ValidationHelper.GetString(states?.States, "&nbsp"))
                               .Replace("{EXPIREDATE}", skuValidity != default(DateTime) ? skuValidity.ToString("MMM dd, yyyy") : "&nbsp")
                               .Replace("{PROGRAMNAME}", ValidationHelper.GetString(programName?.ProgramName, "&nbsp"));
             sb.Append(pdfContent);
         });
         return(sb.ToString());
     }
     catch (Exception ex)
     {
         EventLogProvider.LogInformation("CartPDFHelper", "CreateCartInnerContent", ex.Message);
         return(string.Empty);
     }
 }
コード例 #18
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);
     }
 }
コード例 #19
0
 /// <summary>
 /// Allow the Products updates
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnAllowUpates_Click(object sender, EventArgs e)
 {
     try
     {
         var program = ProgramProvider.GetPrograms()
                       .WhereEquals("ProgramId", ddlPrograms.SelectedValue)
                       .FirstOrDefault();
         if (program != null)
         {
             program.GlobalAdminNotified = false;
             program.Update();
             Response.Redirect(CurrentDocument.DocumentUrlPath);
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("CMSWebParts_Kadena_Campaign_Web_Form_CampaignProductsFilter", "btnAllowUpates_Click", ex, CurrentSite.SiteID, ex.Message);
     }
 }
コード例 #20
0
 private Program GetProgram(string campaignName, string programName)
 {
     if (string.IsNullOrWhiteSpace(campaignName) || string.IsNullOrWhiteSpace(programName))
     {
         return(null);
     }
     CMS.DocumentEngine.Types.KDA.Campaign campaign = GetCampaign(campaignName);
     if (campaign != null)
     {
         return(ProgramProvider.GetPrograms()
                .OnSite(_site)
                .Where(x => x.NodeParentID.Equals(campaign.NodeID) && x.ProgramName.Equals(programName))
                .FirstOrDefault());
     }
     else
     {
         return(null);
     }
 }
コード例 #21
0
    /// <summary>
    /// Get the Program Ids in Open Campaign
    /// </summary>
    /// <returns></returns>
    public List <int> GetProgramIDs()
    {
        List <int> programIds = new List <int>();

        try
        {
            if (OpenCampaign != null)
            {
                programIds = ProgramProvider.GetPrograms()
                             .WhereEquals("CampaignID", OpenCampaign.CampaignID)
                             .Columns("ProgramID")
                             .Select(x => x.ProgramID).ToList <int>();
            }
        }
        catch (Exception ex)
        {
            EventLogProvider.LogException("Get ProgramsIDs from CVampaign", "GetProgramIDs()", ex, CurrentSite.SiteID, ex.Message);
        }
        return(programIds);
    }
コード例 #22
0
 /// <summary>
 /// Binding brands based on program
 /// </summary>
 /// <param name="programID"></param>
 private void BindBrands(String programID)
 {
     try
     {
         var brandID = ProgramProvider.GetPrograms().WhereEquals("NodeSiteID", CurrentSite.SiteID).WhereEquals("ProgramID", ValidationHelper.GetInteger(programID, default(int))).Columns("BrandID").Select(x => new Program {
             BrandID = x.BrandID
         }).FirstOrDefault();
         var brand = CustomTableItemProvider.GetItems(BrandItem.CLASS_NAME).Columns("BrandName,ItemID").WhereEquals("ItemID", ValidationHelper.GetInteger(brandID.GetValue("BrandID"), default(int))).TopN(1).Select(x => new BrandItem {
             ItemID = x.Field <int>("ItemID"), BrandName = x.Field <string>("BrandName")
         }).FirstOrDefault();
         ddlBrands.DataSource     = brand;
         ddlBrands.DataTextField  = "BrandName";
         ddlBrands.DataValueField = "ItemID";
         ddlBrands.DataBind();
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("Binding brands based on program", ex.Message, ex);
     }
 }
コード例 #23
0
        public new ActionResult View(string id)
        {
            using (var provider = new ProgramProvider())
            {
                var program = provider.GetProgram(id, true);

                if(program.Program.BlockedBy17)
                {
                    if (SessionVariables.CurrentUser != null && SessionVariables.CurrentUser.Age < 17)
                    {
                        return View("Blocked", program);
                    }

                    return View(program);
                }
                else
                {
                    return View(program);
                }
            }
        }
コード例 #24
0
 /// <summary>
 /// Gets the campaign and programid of the product
 /// </summary>
 /// <param name="skuID"></param>
 private void GetPrebuyData(int skuID)
 {
     try
     {
         var productDocument = DocumentHelper.GetDocuments("KDA.CampaignsProduct").WhereEquals("NodeSKUID", skuID).Columns("NodeSKUID,ProgramID").FirstOrDefault();
         if (!DataHelper.DataSourceIsEmpty(productDocument))
         {
             ProductProgramID  = ValidationHelper.GetInteger(productDocument?.GetValue("ProgramID"), default(int));
             ProductShippingID = ShippingID;
             var program = ProgramProvider.GetPrograms()
                           .WhereEquals("ProgramID", ProductProgramID)
                           .FirstOrDefault();
             if (!DataHelper.DataSourceIsEmpty(program))
             {
                 ProductCampaignID = program.CampaignID;
             }
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("CustomerCartOperations.ascx.cs", "GetPrebuyData()", ex);
     }
 }
コード例 #25
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);
     }
 }
コード例 #26
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);
     }
 }
コード例 #27
0
 /// <summary>
 /// Getting programs based on open campaign
 /// </summary>
 /// <param name="campaignID"></param>
 /// <returns></returns>
 public List <int> GetProgramIDs(int campaignID)
 {
     try
     {
         List <int> programIds = new List <int>();
         var        programs   = ProgramProvider.GetPrograms()
                                 .WhereEquals("CampaignID", OpenCampaign.CampaignID)
                                 .Columns("ProgramID")
                                 .ToList();
         if (!DataHelper.DataSourceIsEmpty(programs))
         {
             foreach (var program in programs)
             {
                 programIds.Add(program.ProgramID);
             }
         }
         return(programIds);
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("get program based on open campaign", ex.Message, ex);
         return(default(List <int>));
     }
 }
コード例 #28
0
        public void Save(ProgramViewSD model)
        {
            try
            {
                if (model.ImageFile != null && model.ImageFile.ContentLength > 0)
                {
                    var fileName = DataAccess.Utilities.GenerateUniqueID() + Path.GetExtension(model.ImageFile.FileName);

                    try
                    {
                        var result = AwsHelpers.UploadImage(fileName, model.ImageFile);

                        model.Program.Image = fileName;
                    }
                    catch (Exception ex)
                    {
                        string s = string.Empty;
                    }
                }
            }
            catch (Exception ex)
            {
                string s = string.Empty;
            }

            using (var projectProvider = new ProgramProvider())
            {
                if (model.New)
                {
                    try
                    {
                        projectProvider.Insert(model.Program);
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message.ContainsValue("PRIMARY"))
                        {
                            projectProvider.Update(model.Program);
                        }
                    }
                }
                else
                {
                    projectProvider.Update(model.Program);
                }
            }
        }
コード例 #29
0
        public ActionResult _JoinWithFinePrint(string id, string userType, bool accepted)
        {
            if (accepted)
            {
                if (!string.IsNullOrEmpty(userType))
                {
                    using (var programUserProvider = new ProgramUserProvider())
                    {
                        var programUsers = programUserProvider.GetForProgram(id, ProgramUserTypes.Participant);

                        if (!programUsers.Any(x => x.UserId.Equals(SessionVariables.CurrentUser.Id)))
                        {
                            var programUser = new ProgramUserSD
                            {
                                Id = DataAccess.Utilities.GenerateUniqueID(),
                                DateCreated = DateTime.Now,
                                ProgramId = id,
                                UserId = SessionVariables.CurrentUser.Id,
                                UserType = userType,
                                Status = ProgramUserStatus.Active
                            };

                            programUserProvider.Insert(programUser);

                            AlertMessage = "<strong>Congratulations!</strong> You have successfully joined this program.  If you have any questions, please contact the program administrator or sponsor. Share the news with your friends! <div class='fb-share-button' data-href='" + ApplicationCache.Instance.SiteUrl + "/Site/ViewProgram/" + id + "' style='vertical-align: middle;'></div>";
                            AlertMessageType = AlertMessageTypes.Success;
                        }
                        else
                        {
                            AlertMessage = "<strong>Uh oh!</strong> It looks like you are already a participant of this program.";
                            AlertMessageType = AlertMessageTypes.Failure;
                        }

                        return RedirectTo("/Site/ViewProgram/" + id);
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Please select if you are a volunteer or participant");
                }
            }
            else
            {
                ModelState.AddModelError("", "Please agree to the terms");
            }

            using (var provider = new ProgramProvider())
            {
                var program = provider.GetProgram(id);

                return PartialView("_Join", program);
            }
        }
コード例 #30
0
        public ActionResult ThinkTank(string type, string typeId, string locationType, string visibility)
        {
            ViewBag.LocationType = locationType;
            ViewBag.Visibility = visibility;

            using (var provider = new ProgramProvider())
            {
                var programs = provider.GetForLocationType(locationType, visibility, typeId);

                return View(programs);
            }
        }
コード例 #31
0
        public ActionResult _DeleteComment(string id, string programId)
        {
            using (var provider = new ProgramCommentProvider())
            {
                provider.Delete(id);
            }

            using (var provider = new ProgramProvider())
            {
                var program = provider.GetProgram(programId);

                return PartialView("_Comments", program);
            }
        }
コード例 #32
0
        public ActionResult _AddComment(ProgramCommentSD model)
        {
            using (var provider = new ProgramCommentProvider())
            {
                model.Id = DataAccess.Utilities.GenerateUniqueID();
                model.DateCreated = DateTime.Now;
                model.UserId = SessionVariables.CurrentUser.Id;

                provider.Insert(model);
            }

            using (var provider = new ProgramProvider())
            {
                var program = provider.GetProgram(model.ProgramId);

                return PartialView("_Comments", program);
            }
        }
コード例 #33
0
    /// <summary>
    /// Insert product data to database
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string imagePath = string.Empty;

        try
        {
            int programID = ValidationHelper.GetInteger(ddlProgram.SelectedValue, default(int));
            if (programID != default(int))
            {
                Program      program    = new Program();
                TreeProvider tree       = new TreeProvider(MembershipContext.AuthenticatedUser);
                var          programDoc = ProgramProvider.GetPrograms()
                                          .WhereEquals("NodeSiteID", CurrentSite.SiteID)
                                          .Columns("NodeID")
                                          .WhereEquals("ProgramID", programID)
                                          .FirstOrDefault();
                if (!DataHelper.DataSourceIsEmpty(programDoc))
                {
                    int programNodeID = programDoc.NodeID;
                    var document      = DocumentHelper.GetDocument(programNodeID, CurrentDocument.DocumentCulture, tree);
                    var createNode    = tree.SelectSingleNode(SiteContext.CurrentSiteName, document.NodeAliasPath, CurrentDocument.DocumentCulture);
                    if (createNode != null)
                    {
                        string itemSpecsID, customItemSpecs;
                        GetItemSpecsValue(out itemSpecsID, out customItemSpecs);
                        CampaignsProduct products = new CampaignsProduct()
                        {
                            ProgramID       = ValidationHelper.GetInteger(ddlProgram.SelectedValue, default(int)),
                            EstimatedPrice  = ValidationHelper.GetDouble(txtEstimatedprice.Text, default(double)),
                            BrandID         = ValidationHelper.GetInteger(hfBrandItemID.Value, default(int)),
                            CategoryID      = ValidationHelper.GetInteger(ddlProductcategory.SelectedValue, default(int)),
                            QtyPerPack      = ValidationHelper.GetInteger(txtQty.Text, default(int)),
                            ItemSpecs       = ValidationHelper.GetString(itemSpecsID, string.Empty),
                            CustomItemSpecs = ValidationHelper.GetString(customItemSpecs, string.Empty),
                            State           = ValidationHelper.GetInteger(ddlState.SelectedValue, default(int)),
                            ProductName     = ValidationHelper.GetString(txtProductName.Text, string.Empty)
                        };
                        products.DocumentName    = ValidationHelper.GetString(txtProductName.Text, string.Empty);
                        products.DocumentCulture = CurrentDocument.DocumentCulture;
                        if (productImage.HasFile)
                        {
                            string libraryFolderName = SettingsKeyInfoProvider.GetValue(CurrentSite.SiteName + ".KDA_ImagesFolderName");
                            imagePath = UploadImage.UploadImageToMeadiaLibrary(productImage, libraryFolderName);
                        }
                        SKUInfo newProduct = new SKUInfo()
                        {
                            SKUName             = ValidationHelper.GetString(txtProductName.Text, string.Empty),
                            SKUNumber           = ValidationHelper.GetString("00000", string.Empty),
                            SKUShortDescription = ValidationHelper.GetString(txtProductName.Text, string.Empty),
                            SKUDescription      = ValidationHelper.GetString(txtLongDescription.Text, string.Empty),
                            SKUEnabled          = ValidationHelper.GetString(ddlStatus.SelectedValue, "1") == "1" ? true : false,
                            SKUImagePath        = imagePath,
                            SKUSiteID           = CurrentSite.SiteID,
                            SKUProductType      = SKUProductTypeEnum.EProduct,
                            SKUPrice            = 0
                        };
                        if (!string.IsNullOrEmpty(txtExpireDate.Text))
                        {
                            newProduct.SKUValidUntil = ValidationHelper.GetDateTime(txtExpireDate.Text, DateTime.MinValue);
                        }
                        newProduct.SetValue("SKUProductCustomerReferenceNumber", ValidationHelper.GetString(ddlPos.SelectedValue, string.Empty));
                        SKUInfoProvider.SetSKUInfo(newProduct);
                        products.NodeSKUID = newProduct.SKUID;
                        products.Insert(createNode, true);
                        int capaignNodeID = ValidationHelper.GetInteger(Request.QueryString["camp"], default(int));
                        var campDoc       = DocumentHelper.GetDocument(capaignNodeID, CurrentDocument.DocumentCulture, tree);
                        if (campDoc != null)
                        {
                            Response.Redirect($"{campDoc.DocumentUrlPath}?status={QueryStringStatus.Added}");
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            EventLogProvider.LogException("CMSWebParts_Kadena_Campaign_Web_Form_AddCampaignProducts", "btnSave_Click", ex, CurrentSite.SiteID, ex.Message);
        }
    }
コード例 #34
0
        public ActionResult UnFlag(string id)
        {
            using (var provider = new ProgramProvider())
            {
                provider.Flag(id, false);
            }

            AlertMessage = "You have un-flagged this program.";
            AlertMessageType = AlertMessageTypes.Success;

            return Redirect("/Site/ViewProgram/" + id);
        }
コード例 #35
0
        public ActionResult Cancel(string id)
        {
            using (var programProvider = new ProgramProvider())
            {
                var program = programProvider.GetProgram(id);

                if (!program.ProgramUsers.Any(x => x.UserType.Equals(ProgramUserTypes.Administrator) && x.UserId.Equals(SessionVariables.CurrentUser.Id)) && !SessionVariables.CurrentUser.SuperAdmin)
                {
                    return RedirectToAction("AccessDenied", "Error");
                }

                program.Program.Status = ProgramStatus.Cancelled;

                programProvider.Update(program.Program);

                return DefaultRedirect;
            }
        }
コード例 #36
0
        public ActionResult Delete(string id)
        {
            using (var provider = new ProgramProvider())
            {
                provider.Delete(id);

                return DefaultRedirect;
            }
        }
コード例 #37
0
    /// <summary>
    /// Update the product data.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        try
        {
            int          programID = ValidationHelper.GetInteger(ddlProgram.SelectedValue, 0);
            TreeProvider tree      = new TreeProvider(MembershipContext.AuthenticatedUser);
            if (ViewState["ProductNodeID"] != null)
            {
                CampaignsProduct product = CampaignsProductProvider.GetCampaignsProduct(ValidationHelper.GetInteger(ViewState["ProductNodeID"], 0), CurrentDocument.DocumentCulture, CurrentSiteName);
                if (product != null)
                {
                    string itemSpecsID, customItemSpecs;
                    GetItemSpecsValue(out itemSpecsID, out customItemSpecs);
                    product.DocumentName    = ValidationHelper.GetString(txtProductName.Text, string.Empty);
                    product.ProgramID       = ValidationHelper.GetInteger(ddlProgram.SelectedValue, 0);
                    product.State           = ValidationHelper.GetInteger(ddlState.SelectedValue, default(int));
                    product.BrandID         = ValidationHelper.GetInteger(ddlBrand.SelectedValue, default(int));
                    product.CategoryID      = ValidationHelper.GetInteger(ddlProductcategory.SelectedValue, 0);
                    product.QtyPerPack      = ValidationHelper.GetInteger(txtQty.Text, default(int));
                    product.ItemSpecs       = ValidationHelper.GetString(itemSpecsID, string.Empty);
                    product.CustomItemSpecs = ValidationHelper.GetString(customItemSpecs, string.Empty);
                    product.EstimatedPrice  = ValidationHelper.GetDouble(txtEstimatedprice.Text, default(double));
                    product.ProductName     = ValidationHelper.GetString(txtProductName.Text, string.Empty);
                    SKUInfo updateProduct = SKUInfoProvider.GetSKUs().WhereEquals("SKUID", product.NodeSKUID).FirstObject;
                    if (updateProduct != null)
                    {
                        if (productImage.HasFile)
                        {
                            string libraryFolderName = SettingsKeyInfoProvider.GetValue(CurrentSite.SiteName + ".KDA_ImagesFolderName");
                            if (updateProduct.SKUImagePath != string.Empty)
                            {
                                UploadImage.DeleteImage(updateProduct.SKUImagePath, libraryFolderName);
                            }
                            updateProduct.SKUImagePath = UploadImage.UploadImageToMeadiaLibrary(productImage, libraryFolderName);
                        }
                        updateProduct.SKUName             = ValidationHelper.GetString(txtProductName.Text, string.Empty);
                        updateProduct.SKUShortDescription = ValidationHelper.GetString(txtProductName.Text, string.Empty);
                        updateProduct.SKUDescription      = ValidationHelper.GetString(txtLongDescription.Text, string.Empty);
                        updateProduct.SKUValidUntil       = ValidationHelper.GetDate(txtExpireDate.Text, DateTime.MinValue);
                        updateProduct.SKUEnabled          = ValidationHelper.GetString(ddlStatus.SelectedValue, "1") == "1" ? true : false;
                        updateProduct.SKUSiteID           = CurrentSite.SiteID;
                        updateProduct.SKUProductType      = SKUProductTypeEnum.EProduct;
                        updateProduct.SKUPrice            = 0;
                        SKUInfoProvider.SetSKUInfo(updateProduct);
                    }
                    product.Update();
                }

                if (ViewState["ProgramID"] != null)
                {
                    if (ValidationHelper.GetInteger(ViewState["ProgramID"], 0) != programID)
                    {
                        var targetProgram = ProgramProvider.GetPrograms()
                                            .WhereEquals("NodeSiteID", CurrentSite.SiteID)
                                            .WhereEquals("ProgramID", programID)
                                            .Column("NodeID")
                                            .FirstOrDefault();
                        if (targetProgram != null)
                        {
                            var tagetDocument = DocumentHelper.GetDocument(targetProgram.NodeID, CurrentDocument.DocumentCulture, tree);
                            var targetPage    = tree.SelectSingleNode(SiteContext.CurrentSiteName, tagetDocument.NodeAliasPath, CurrentDocument.DocumentCulture);
                            if ((product != null) && (targetPage != null))
                            {
                                DocumentHelper.MoveDocument(product, targetPage, tree, true);
                            }
                        }
                    }
                }
                int capaignNodeID = ValidationHelper.GetInteger(Request.QueryString["camp"], default(int));
                var campDoc       = DocumentHelper.GetDocument(capaignNodeID, CurrentDocument.DocumentCulture, tree);
                if (campDoc != null)
                {
                    Response.Redirect($"{campDoc.DocumentUrlPath}?status={QueryStringStatus.Updated}");
                }
            }
        }
        catch (Exception ex)
        {
            EventLogProvider.LogException("CMSWebParts_Kadena_Campaign_Web_Form_AddCampaignProducts", "btnUpdate_Click", ex, CurrentSite.SiteID, ex.Message);
        }
    }
コード例 #38
0
        public ActionResult Edit(ProgramViewSD item)
        {
            if (ModelState.IsValid)
            {
                if (item.ImageFile != null && item.ImageFile.ContentLength > 0)
                {
                    var fileName = DataAccess.Utilities.GenerateUniqueID() + Path.GetExtension(item.ImageFile.FileName);

                    try
                    {
                        var result = AwsHelpers.UploadImage(fileName, item.ImageFile);

                        item.Program.Image = fileName;
                    }
                    catch (Exception ex)
                    {
                        AlertMessage = "Your program has been saved successfully, but there was a problem uploading your image.  Please contact our support if you continue to have problems.";
                    }
                }

                using (var provider = new ProgramProvider())
                {
                    provider.Update(item.Program);
                }

                return Redirect("/Site/ViewProgram/" + item.Program.Id);
            }

            return View(DefaultViews.CreateEdit, item);
        }
コード例 #39
0
        public ActionResult Edit(string id)
        {
            using (var provider = new ProgramProvider())
            {
                var item = provider.GetProgram(id);

                if (!item.ProgramUsers.Where(x => !string.IsNullOrEmpty(x.UserId)).Any(x => x.UserType.Equals(ProgramUserTypes.Administrator) && x.UserId.Equals(SessionVariables.CurrentUser.Id)) && !SessionVariables.CurrentUser.SuperAdmin)
                {
                    return RedirectToAction("AccessDenied", "Error");
                }

                return View(DefaultViews.CreateEdit, item);
            }
        }
コード例 #40
0
 /// <summary>
 /// Creating products PDF from Html
 /// </summary>
 /// <returns></returns>
 public void CreateProductPDF(string selectedValues)
 {
     try
     {
         if (!string.IsNullOrEmpty(selectedValues))
         {
             var programs = ProgramProvider.GetPrograms()
                            .Columns("ProgramName,BrandID,DeliveryDateToDistributors")
                            .WhereEquals("CampaignID", OpenCampaign?.CampaignID ?? default(int))
                            .ToList();
             lblNoProducts.Visible = false;
             List <string> selectedProducts = selectedValues.Split(',').ToList();
             var           skuDetails       = SKUInfoProvider.GetSKUs()
                                              .WhereIn("SKUID", selectedProducts)
                                              .ToList();
             string htmlTextheader    = SettingsKeyInfoProvider.GetValue($@"{CurrentSiteName}.ProductsPDFHeader");
             string programFooterText = SettingsKeyInfoProvider.GetValue($@"{CurrentSiteName}.KDA_ProgramFooterText");
             if (TypeOfProduct == (int)ProductsType.PreBuy && OpenCampaign != null)
             {
                 htmlTextheader = htmlTextheader.Replace("CAMPAIGNNAME", OpenCampaign?.Name);
                 htmlTextheader = htmlTextheader.Replace("OrderStartDate", OpenCampaign.StartDate == default(DateTime) ? string.Empty : OpenCampaign.StartDate.ToString("MMM dd, yyyy"));
                 htmlTextheader = htmlTextheader.Replace("OrderEndDate", OpenCampaign.EndDate == default(DateTime) ? string.Empty : OpenCampaign.EndDate.ToString("MMM dd, yyyy"));
             }
             string generalInventory = string.Empty;
             if (TypeOfProduct == (int)ProductsType.GeneralInventory)
             {
                 generalInventory = SettingsKeyInfoProvider.GetValue($@"{CurrentSiteName}.KDA_GeneralInventoryCover");
             }
             List <int> brands          = new List <int>();
             string     programsContent = string.Empty;
             if (TypeOfProduct == (int)ProductsType.PreBuy && OpenCampaign != null)
             {
                 foreach (var program in programs)
                 {
                     string programContent = SettingsKeyInfoProvider.GetValue($@"{CurrentSiteName}.ProgramsContent");
                     brands.Add(program.BrandID);
                     programContent   = programContent.Replace("ProgramBrandName", program.ProgramName);
                     programContent   = programContent.Replace("ProgramDate", program.DeliveryDateToDistributors == default(DateTime) ? string.Empty : program.DeliveryDateToDistributors.ToString("MMM dd, yyyy"));
                     programsContent += programContent;
                     programContent   = string.Empty;
                 }
                 programsContent += programFooterText.Replace("PROGRAMFOOTERTEXT", ResHelper.GetString("Kadena.Catalog.ProgramFooterText"));
             }
             else
             {
                 var productItems = CampaignsProductProvider.GetCampaignsProducts()
                                    .WhereEquals("NodeSiteID", CurrentSite.SiteID)
                                    .Where(new WhereCondition().WhereEquals("ProgramID", null).Or().WhereEquals("ProgramID", 0))
                                    .ToList();
                 var inventoryList = productItems
                                     .Join(skuDetails, x => x.NodeSKUID, y => y.SKUID, (x, y) => new { x.BrandID, y.SKUNumber, x.Product.SKUProductCustomerReferenceNumber })
                                     .ToList();
                 foreach (var giProducts in inventoryList)
                 {
                     brands.Add(giProducts.BrandID);
                 }
             }
             string pdfProductsContentWithBrands = string.Empty;
             string closingDiv = SettingsKeyInfoProvider.GetValue("ClosingDIV").ToString();
             if (!DataHelper.DataSourceIsEmpty(selectedProducts))
             {
                 foreach (var brand in brands.Distinct())
                 {
                     string productBrandHeader = SettingsKeyInfoProvider.GetValue($@"{CurrentSiteName}.PDFBrand");
                     if (TypeOfProduct == (int)ProductsType.PreBuy)
                     {
                         productBrandHeader = productBrandHeader.Replace("BrandName", programs.Where(x => x.BrandID == brand).Select(y => y.ProgramName).FirstOrDefault());
                     }
                     else if (TypeOfProduct == (int)ProductsType.GeneralInventory)
                     {
                         productBrandHeader = productBrandHeader.Replace("BrandName", GetBrandName(brand));
                     }
                     List <CampaignsProduct> productItems = new List <CampaignsProduct>();
                     if (TypeOfProduct == (int)ProductsType.PreBuy)
                     {
                         productItems = CampaignsProductProvider.GetCampaignsProducts().WhereNotEquals("ProgramID", null).WhereEquals("NodeSiteID", CurrentSite.SiteID).WhereIn("ProgramID", GetProgramIDs(OpenCampaign.CampaignID)).ToList();
                     }
                     else if (TypeOfProduct == (int)ProductsType.GeneralInventory)
                     {
                         productItems = CampaignsProductProvider.GetCampaignsProducts().Where(new WhereCondition().WhereEquals("ProgramID", null).Or().WhereEquals("ProgramID", 0)).WhereEquals("NodeSiteID", CurrentSite.SiteID).ToList();
                     }
                     var catalogList = productItems
                                       .Join(skuDetails, x => x.NodeSKUID, y => y.SKUID, (x, y) => new { x.ProductName, x.EstimatedPrice, x.BrandID, x.ProgramID, x.QtyPerPack, x.State, y.SKUPrice, y.SKUNumber, x.Product.SKUProductCustomerReferenceNumber, y.SKUDescription, y.SKUShortDescription, y.SKUImagePath, y.SKUValidUntil })
                                       .Where(x => x.BrandID == brand)
                                       .ToList();
                     string pdfProductsContent = string.Empty;
                     if (!DataHelper.DataSourceIsEmpty(catalogList))
                     {
                         foreach (var product in catalogList)
                         {
                             var    stateInfo         = CustomTableItemProvider.GetItems <StatesGroupItem>().WhereEquals("ItemID", product.State).FirstOrDefault();
                             string pdfProductContent = SettingsKeyInfoProvider.GetValue($@"{CurrentSiteName}.PDFInnerHTML");
                             pdfProductContent   = pdfProductContent.Replace("IMAGEGUID", GetProductImage(product.SKUImagePath));
                             pdfProductContent   = pdfProductContent.Replace("PRODUCTPARTNUMBER", product?.SKUProductCustomerReferenceNumber ?? string.Empty);
                             pdfProductContent   = pdfProductContent.Replace("PRODUCTBRANDNAME", GetBrandName(product.BrandID));
                             pdfProductContent   = pdfProductContent.Replace("PRODUCTSHORTDESCRIPTION", product?.ProductName ?? string.Empty);
                             pdfProductContent   = pdfProductContent.Replace("PRODUCTDESCRIPTION", product?.SKUDescription ?? string.Empty);
                             pdfProductContent   = pdfProductContent.Replace("PRODUCTVALIDSTATES", stateInfo?.States.Replace(",", ", ") ?? string.Empty);
                             pdfProductContent   = pdfProductContent.Replace("PRODUCTCOSTBUNDLE", TypeOfProduct == (int)ProductsType.PreBuy ? ($"{CurrencyInfoProvider.GetFormattedPrice(ValidationHelper.GetDouble(product.EstimatedPrice, default(double)), CurrentSite.SiteID, true)}") : ($"{CurrencyInfoProvider.GetFormattedPrice(ValidationHelper.GetDouble(product.SKUPrice, default(double)), CurrentSite.SiteID, true)}"));
                             pdfProductContent   = pdfProductContent.Replace("PRODUCTBUNDLEQUANTITY", product?.QtyPerPack.ToString() ?? string.Empty);
                             pdfProductContent   = pdfProductContent.Replace("PRODUCTEXPIRYDATE", product?.SKUValidUntil != default(DateTime) ? product?.SKUValidUntil.ToString("MMM dd, yyyy") : string.Empty ?? string.Empty);
                             pdfProductsContent += pdfProductContent;
                             pdfProductContent   = string.Empty;
                             selectedProducts.Remove(product.SKUNumber);
                         }
                         pdfProductsContentWithBrands += productBrandHeader + pdfProductsContent + closingDiv;
                         productBrandHeader            = string.Empty;
                     }
                 }
             }
             string pdfClosingDivs = SettingsKeyInfoProvider.GetValue($@"{CurrentSiteName}.PdfEndingTags");
             string html           = pdfProductsContentWithBrands + pdfClosingDivs;
             byte[] pdfByte        = default(byte[]);
             NReco.PdfGenerator.HtmlToPdfConverter PDFConverter = new NReco.PdfGenerator.HtmlToPdfConverter();
             PDFConverter.License.SetLicenseKey(SettingsKeyInfoProvider.GetValue("KDA_NRecoOwner", CurrentSite.SiteID), SettingsKeyInfoProvider.GetValue("KDA_NRecoKey", CurrentSite.SiteID));
             PDFConverter.LowQuality = SettingsKeyInfoProvider.GetBoolValue("KDA_NRecoLowQuality", CurrentSite.SiteID);
             if (TypeOfProduct == (int)ProductsType.PreBuy)
             {
                 pdfByte = PDFConverter.GeneratePdf(html, htmlTextheader + programsContent + closingDiv);
             }
             else
             {
                 pdfByte = PDFConverter.GeneratePdf(html, generalInventory + closingDiv);
             }
             string fileName = string.Empty;
             if (TypeOfProduct == (int)ProductsType.PreBuy)
             {
                 fileName = ValidationHelper.GetString(ResHelper.GetString("KDA.CatalogGI.PrebuyFileName"), string.Empty) + ".pdf";
             }
             else
             {
                 fileName = ValidationHelper.GetString(ResHelper.GetString("KDA.CatalogGI.GeneralInventory"), string.Empty) + ".pdf";
             }
             Response.Clear();
             MemoryStream ms = new MemoryStream(pdfByte);
             Response.ContentType = "application/pdf";
             Response.AddHeader("content-disposition", "attachment;filename=" + fileName);
             Response.Buffer = true;
             ms.WriteTo(Response.OutputStream);
             Response.End();
         }
         else
         {
             Bindproducts();
             noProductSelected.Visible = true;
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("creating html", ex.Message, ex);
     }
 }
コード例 #41
0
        public ActionResult _AddAttendance(string userId, string programId)
        {
            using (var programProvider = new ProgramProvider())
            {
                var program = programProvider.Get(programId);

                var attendance = new ProgramAttendanceSD
                {
                    UserId = userId, 
                    ProgramId = programId, 
                    Method = ProgramAttendanceMethods.Manual, 
                    Hours = Convert.ToDecimal(program.EventLength)
                };

                return PartialView("_AddAttendance", attendance);
            }
        }
コード例 #42
0
        public ActionResult Flag(string id)
        {
            using (var provider = new ProgramProvider())
            {
                provider.Flag(id, true);
            }

            AlertMessage = "You have flagged this program for review";

            return Redirect("/Site/ViewProgram/" + id);
        }
コード例 #43
0
        public ActionResult Admin(string status, string locationType)
        {
            ViewBag.LocationType = locationType;
            ViewBag.Status = status;

            using (var provider = new ProgramProvider())
            {
                var programs = provider.GetForAdmin(status, locationType);

                return View(programs);
            }
        }