} // RenderEdit

        public override Rss.RssItem[] GetRssFeedItems(CmsPage page, CmsPlaceholderDefinition placeholderDefinition, CmsLanguage langToRenderFor)
        {
            List <Rss.RssItem> ret = new List <Rss.RssItem>();
            Dictionary <CmsPage, CmsPlaceholderDefinition[]> childJobPages = CmsContext.getAllPlaceholderDefinitions("JobPostingDetails", page, CmsContext.PageGatheringMode.ChildPagesOnly);

            if (childJobPages.Count > 0)
            {
                JobPostingLocation[] allLocations            = JobPostingLocation.FetchAll();
                JobPostingLocation   theAllLocationsLocation = JobPostingLocation.getAllLocations(allLocations);

                JobPostingDb             db             = new JobPostingDb();
                JobPostingAggregatorData aggregatorData = db.getJobPostingAggregatorData(page, placeholderDefinition.Identifier, langToRenderFor, true);

                // -- grab all the details for all child job pages.


                foreach (CmsPage childPage in childJobPages.Keys)
                {
                    foreach (CmsPlaceholderDefinition phDef in childJobPages[childPage])
                    {
                        JobPostingDetailsData dataObj = db.getJobPostingDetailsData(childPage, phDef.Identifier, langToRenderFor, true);
                        if (!dataObj.IsExpired && (aggregatorData.LocationId < 0 || aggregatorData.LocationId == theAllLocationsLocation.JobLocationId || dataObj.LocationId == aggregatorData.LocationId))
                        {
                            Rss.RssItem rssItem = CreateAndInitRssItem(childPage, langToRenderFor);
                            rssItem.Description = childPage.renderAllPlaceholdersToString(langToRenderFor, CmsPage.RenderPlaceholderFilterAction.RunAllPageAndPlaceholderFilters);
                            ret.Add(rssItem);
                        }
                    }
                } // foreach child page
            }


            return(ret.ToArray());
        }
        /// <summary>
        /// Renders the placeholder in EditMode
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="page"></param>
        /// <param name="identifier"></param>
        /// <param name="langToRenderFor"></param>
        /// <param name="paramList"></param>
        public override void RenderInEditMode(HtmlTextWriter writer, CmsPage page, int identifier, CmsLanguage langToRenderFor, string[] paramList)
        {
            string       placeholderId = "JobAggregatorDetails_" + page.Id.ToString() + "_" + identifier.ToString() + langToRenderFor.shortCode;
            JobPostingDb db            = new JobPostingDb();

            JobPostingAggregatorData aggregatorData = db.getJobPostingAggregatorData(page, identifier, langToRenderFor, true);

            JobPostingLocation[] locations    = JobPostingLocation.FetchAll();
            JobPostingLocation   AllLocations = JobPostingLocation.getAllLocations(locations);

            // ------- CHECK THE FORM FOR ACTIONS
            string action = PageUtils.getFromForm(placeholderId + "_Action", "");

            if (action.Trim().ToLower() == "update")
            {
                // save the data to the database

                int newLocationId = PageUtils.getFromForm("location_" + placeholderId, AllLocations.JobLocationId);

                aggregatorData.LocationId = newLocationId;

                bool b = db.saveUpdatedJobPostingAggregatorData(aggregatorData);
                if (!b)
                {
                    writer.Write("Error saving updates to database!");
                }
            }
            StringBuilder html = new StringBuilder();

            html.Append("<div class=\"JobPostingAggregator Edit\">");
            html.Append("<table width=\"100%\" border=\"0\">");

            // -- Job Location drop-down

            html.Append("<tr>");
            html.Append("<td>Job Location To Display:</td>");
            html.Append("</tr>");
            html.Append("<tr>");

            html.Append("<td>" + PageUtils.getDropDownHtml("location_" + placeholderId, "location_" + placeholderId, JobPostingLocation.ToNameValueCollection(locations, CmsContext.currentLanguage, true), aggregatorData.LocationId.ToString()) + "</td>");
            html.Append("</tr>");

            html.Append("</table>" + Environment.NewLine);

            html.Append(PageUtils.getHiddenInputHtml(placeholderId + "_Action", "update"));

            html.Append("</div>" + Environment.NewLine);

            writer.Write(html.ToString());
        } // RenderEdit
        /// <summary>
        /// Renders the placeholder in ViewMode
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="page"></param>
        /// <param name="identifier"></param>
        /// <param name="langToRenderFor"></param>
        /// <param name="paramList"></param>
        public override void RenderInViewMode(HtmlTextWriter writer, CmsPage page, int identifier, CmsLanguage langToRenderFor, string[] paramList)
        {
            AddJobPostingCommandToEditMenu(page, page);

            Dictionary <CmsPage, CmsPlaceholderDefinition[]> childJobPages = CmsContext.getAllPlaceholderDefinitions("JobPostingDetails", page, CmsContext.PageGatheringMode.FullRecursion);

            JobPostingLocation[] allLocations            = JobPostingLocation.FetchAll();
            JobPostingLocation   theAllLocationsLocation = JobPostingLocation.getAllLocations(allLocations);

            JobPostingDb             db             = new JobPostingDb();
            JobPostingAggregatorData aggregatorData = db.getJobPostingAggregatorData(page, identifier, langToRenderFor, true);

            // -- grab all the details for all child job pages.

            Dictionary <CmsPage, List <JobPostingDetailsData> > childJobDetails = new Dictionary <CmsPage, List <JobPostingDetailsData> >();

            foreach (CmsPage childPage in childJobPages.Keys)
            {
                childJobDetails[childPage] = new List <JobPostingDetailsData>();
                foreach (CmsPlaceholderDefinition phDef in childJobPages[childPage])
                {
                    JobPostingDetailsData dataObj = db.getJobPostingDetailsData(childPage, phDef.Identifier, langToRenderFor, true);
                    childJobDetails[childPage].Add(dataObj);
                }
            } // foreach child page

            // -- do HTML output only for the location
            StringBuilder html       = new StringBuilder();
            bool          jobsOutput = false;

            foreach (JobPostingLocation location in allLocations)
            {
                if (aggregatorData.LocationId < 0 || aggregatorData.LocationId == theAllLocationsLocation.JobLocationId || location.JobLocationId == aggregatorData.LocationId)
                {
                    string jobHtml = getHtmlForJobsInLocation(childJobDetails, location, langToRenderFor);
                    if (jobHtml != "")
                    {
                        html.Append(jobHtml);
                        jobsOutput = true;
                    }
                }
            } // foreach

            if (!jobsOutput)
            {
                html.Append("<p class=\"noJobsMessage\">There are currently no jobs available</p>");
            }

            writer.Write(html.ToString());
        }
Ejemplo n.º 4
0
        }  // createNewJobPostingAggregatorData

        public bool saveUpdatedJobPostingAggregatorData(JobPostingAggregatorData data)
        {
            if (data.JobSummaryId < 0)
            {
                return(false);
            }

            string sql = "update jobsummary set ";

            sql += " locationId = " + data.LocationId.ToString() + " ";
            sql += " where JobSummaryId = " + data.JobSummaryId.ToString();

            int numAffected = this.RunUpdateQuery(sql);

            return(numAffected > 0);
        }
Ejemplo n.º 5
0
        public JobPostingAggregatorData getJobPostingAggregatorData(CmsPage page, int identifier, CmsLanguage language, bool createNewIfDoesNotExist)
        {
            if (page.Id < 0 || identifier < 0)
            {
                return(new JobPostingAggregatorData());
            }

            string sql = "";

            sql  = "select * from jobsummary s ";
            sql += " where s.pageid = " + page.Id.ToString() + " and s.identifier = " + identifier.ToString() + " and langShortCode = '" + dbEncode(language.shortCode) + "' and s.deleted is null;";

            DataSet ds = this.RunSelectQuery(sql);

            if (this.hasSingleRow(ds))
            {
                JobPostingAggregatorData data = new JobPostingAggregatorData();
                DataRow dr = ds.Tables[0].Rows[0];

                data.JobSummaryId = Convert.ToInt32(dr["JobSummaryId"]);
                data.LocationId   = Convert.ToInt32(dr["locationId"]);

                return(data);
            }
            else
            {
                if (createNewIfDoesNotExist)
                {
                    JobPostingAggregatorData data = new JobPostingAggregatorData();
                    bool b = createNewJobPostingAggregatorData(page, identifier, language, data);

                    if (!b)
                    {
                        throw new Exception("getJobPostingDetailsData database error: Error creating new placeholder");
                    }
                    else
                    {
                        return(data);
                    }
                }
                else
                {
                    throw new Exception("getJobPostingDetailsData database error: placeholder does not exist");
                }
            }
        }
Ejemplo n.º 6
0
        public bool createNewJobPostingAggregatorData(CmsPage page, int identifier, CmsLanguage language, JobPostingAggregatorData data)
        {
            string sql = "insert into jobsummary (pageid, identifier, langShortCode, locationId) values (";

            sql += page.Id.ToString() + "," + identifier.ToString() + ",";
            sql += "'" + dbEncode(language.shortCode) + "', ";
            sql += "" + (data.LocationId.ToString()) + " ";
            sql += "); ";

            int newId = this.RunInsertQuery(sql);

            if (newId > -1)
            {
                data.JobSummaryId = newId;
                return(page.setLastUpdatedDateTimeToNow());
            }
            else
            {
                return(false);
            }
        }  // createNewJobPostingAggregatorData