protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.QueryString["aD"] != null)
     {
         int alertid = Convert.ToInt32(Request.QueryString["aD"]);
         JobAlert obj = new JobAlert();
         obj.AlertDelete(alertid,0,"","","");
         divConfirm.Visible = true;
     }
 }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["aD"] != null)
            {
                int alertid = Convert.ToInt32(Request.QueryString["aD"]);
                string candidateguid = Request.QueryString["CID"] == null ? string.Empty : Request.QueryString["CID"].ToString();
                JobAlert obj = new JobAlert();
                obj.AlertConfirmation(alertid);
                divNotExist.Visible = true;
                edit.HRef = ConfigurationManager.AppSettings["baseURL"].ToString() + "Jobs/JobAlertEdit.shtml?alertId=" + alertid + "&CID=" + candidateguid;
                JobAlert alert = new JobAlert();
                DataSet ds = alert.getJobAlert(alertid, candidateguid);
                if (ds.Tables.Count > 0)
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        divConfirm.Visible = true;
                        divNotExist.Visible = false;
                        string body = System.IO.File.ReadAllText(Server.MapPath("~/Template") + "/alertConfirmedmail.htm");
                        string name = ds.Tables[0].Rows[0]["first"].ToString();
                        string sector = "<table>";
                        string location = "<table>";
                        string worktype = "<table>";
                        foreach (DataRow drSector in ds.Tables[3].Rows)
                        {
                            sector += "<tr><td>" + drSector["subclassification"].ToString() + "</td></tr>";
                        }
                        sector += "</table>";
                        foreach (DataRow drLocation in ds.Tables[1].Rows)
                        {
                            location += "<tr><td>" + drLocation["name"].ToString() + "</td></tr>";
                        }
                        location += "</table>";

                        foreach (DataRow drWorkType in ds.Tables[2].Rows)
                        {
                            worktype += "<tr><td>" + drWorkType["type"].ToString() + "</td></tr>";
                        }
                        worktype += "</table>";

                        string frequney = ds.Tables[0].Rows[0]["frequency"].ToString();
                        body = string.Format(body, name, sector, location, worktype, frequney, ConfigurationManager.AppSettings["baseURL"].ToString() + "Jobs/JobAlertEdit.shtml" + "?alertId=" + alertid + "&CID=" + candidateguid, ConfigurationManager.AppSettings["logoURL"].ToString());

                        string address = ConfigurationManager.AppSettings.Get("emailAddress");
                        string displayName = ConfigurationManager.AppSettings.Get("emailName");

                        MailMessage message = new MailMessage
                        {
                            From = new MailAddress(address, displayName),
                            Subject = "Your YOU Global Job Alert subscription is confirmed",
                            Body = body,
                            IsBodyHtml = true
                        };
                        message.To.Add(ds.Tables[0].Rows[0]["email"].ToString());
                        SmtpClient sc = new SmtpClient();
                        sc.Host = ConfigurationManager.AppSettings["smtpHost"].ToString();
                        string smtpUser = ConfigurationManager.AppSettings["smtpUserName"].ToString();
                        string smtpPwd = ConfigurationManager.AppSettings["smtpPassword"].ToString();
                        sc.Credentials = new System.Net.NetworkCredential(smtpUser, smtpPwd);
                        sc.Send(message);
                    }

                }

            }
        }
Пример #3
0
        public ActionResult JobAlertDelete(int alertId)
        {
            JobAlert obj = new JobAlert();
            obj.AlertDelete(alertId, 0, "", "", "");

            return View("JobAlertDelete");
        }
Пример #4
0
        public ActionResult JobAlertEdit(int alertId, string CID)
        {
            JobAlertModel model = new JobAlertModel();
            JobAlert alert = new JobAlert();
            if (string.IsNullOrEmpty(CID))
            {
                DataTable dt = new DataTable();
                dt = alert.getJobAlert(alertId);
                if (dt.Rows.Count == 0)
                    return View("JobAlertNotExist");
                else
                {
                    if (string.IsNullOrEmpty(dt.Rows[0]["candidateguid"].ToString()))
                    {
                        CID = alert.updateCandidateGUID(Convert.ToInt32(dt.Rows[0]["candidateid"].ToString()));
                        string body = System.IO.File.ReadAllText(Server.MapPath("~/Template") + "/alertupgradesecurity.htm");
                        string address = ConfigurationManager.AppSettings.Get("emailAddress");
                        string displayName = ConfigurationManager.AppSettings.Get("emailName");
                        MailMessage message = new MailMessage
                        {
                            From = new MailAddress(address, displayName),
                            Subject = "Please use the new link to manage your subscription",
                            Body = string.Format(body, dt.Rows[0]["first"].ToString(), "<a href='" + ConfigurationManager.AppSettings["baseURL"].ToString() + "Jobs/JobAlertEdit.shtml" + "?alertId=" + alertId + "&CID=" + CID + "' > click here</a>", "<img src='" + ConfigurationManager.AppSettings["logoURL"].ToString() + "' />"),
                            IsBodyHtml = true
                        };
                        message.To.Add(dt.Rows[0]["email"].ToString());
                        SmtpClient sc = new SmtpClient();
                        sc.Host = ConfigurationManager.AppSettings["smtpHost"].ToString();
                        string smtpUser = ConfigurationManager.AppSettings["smtpUserName"].ToString();
                        string smtpPwd = ConfigurationManager.AppSettings["smtpPassword"].ToString();
                        sc.Credentials = new System.Net.NetworkCredential(smtpUser, smtpPwd);
                        sc.Send(message);

                        return View("JobAlertSecurityUpgrade");
                    }
                    else
                        return View("JobAlertNotExist");
                }
            }

            DataSet ds = alert.getJobAlert(alertId, CID);
            if (ds.Tables.Count > 0)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    model.JobAlertId = Convert.ToInt32(ds.Tables[0].Rows[0]["job_alertId"].ToString());
                    model.CandidateId = Convert.ToInt32(ds.Tables[0].Rows[0]["candidateId"].ToString());
                    model.CandidateGUID = CID;
                    model.Name = ds.Tables[0].Rows[0]["first"].ToString();
                    model.SurName = ds.Tables[0].Rows[0]["last"].ToString();
                    model.Email = ds.Tables[0].Rows[0]["email"].ToString();
                    model.PhoneCode = ds.Tables[0].Rows[0]["phonecode"].ToString();
                    model.ContactNumber = ds.Tables[0].Rows[0]["phonenumber"].ToString();
                    model.MailFrequency = Convert.ToInt32(ds.Tables[0].Rows[0]["frequencyId"].ToString());

                    model.IndustrySelect = new List<int>();
                    foreach (DataRow drSector in ds.Tables[3].Rows)
                    {
                        model.IndustrySelect.Add(Convert.ToInt32(drSector["jobindustrysubid"].ToString()));
                    }

                    model.LocationSelect = new List<int>();
                    foreach (DataRow drLocation in ds.Tables[1].Rows)
                    {
                        model.LocationSelect.Add(Convert.ToInt32(drLocation["locationid"].ToString()));
                    }

                    model.WorkTypeSelect = new List<int>();
                    foreach (DataRow drWorktype in ds.Tables[2].Rows)
                    {
                        model.WorkTypeSelect.Add(Convert.ToInt32(drWorktype["job_typeid"].ToString()));
                    }

                    Common obj = new Common();
                    if (Session["ClassificationList"] == null)
                    {
                        Session.Add("ClassificationList", obj.JobClassificationList());
                    }

                    if (Session["LocationList"] == null)
                    {
                        Session.Add("LocationList", obj.LocationList());
                    }

                    if (Session["WorkTypeList"] == null)
                    {
                        Session.Add("WorkTypeList", obj.WorkTypeList());
                    }

                    if (Session["FrequencyList"] == null)
                    {
                        Session.Add("FrequencyList", obj.AlertFrequnecyList());
                    }

                    if (Session["JobIndustryList"] == null)
                    {
                        DataTable dt = obj.JobIndustryList();
                        DataRow dr = dt.NewRow();
                        dr[0] = "";
                        dr[1] = "-- Any --";
                        dr[2] = 0;
                        dt.Rows.InsertAt(dr, 0);
                        Session.Add("JobIndustryList", dt);
                    }

                    if (Session["JobIndustryResumeList"] == null)
                    {
                        DataTable dt = ((DataTable)Session["JobIndustryList"]).Copy();
                        dt.Rows.RemoveAt(0);
                        DataRow dr = dt.NewRow();
                        dr[0] = "";
                        dr[1] = "- Please Select -";
                        dr[2] = -1;
                        dt.Rows.InsertAt(dr, 0);
                        dr = dt.NewRow();
                        dr[0] = "Other";
                        dr[1] = "Other";
                        dr[2] = 0;
                        dt.Rows.InsertAt(dr, 1);
                        Session.Add("JobIndustryResumeList", dt);
                    }

                    if (Session["JobIndustySub"] == null)
                    {
                        DataTable dt = obj.JobIndustrySubList();
                        DataRow dr = dt.NewRow();
                        dr[0] = 0;
                        dr[1] = "-- Any --";
                        dr[2] = "";
                        dt.Rows.InsertAt(dr, 0);
                        Session.Add("JobIndustySub", dt);
                    }

                    if (Session["SearchLocationList"] == null)
                    {
                        DataTable dt = obj.LocationList();
                        DataRow dr = dt.NewRow();
                        dr[0] = "";
                        dr[1] = "-- Any --";
                        dr[2] = 0;
                        dt.Rows.InsertAt(dr, 0);
                        Session.Add("SearchLocationList", dt);
                    }

                    if (Session["SearchWorkTypeList"] == null)
                    {
                        DataTable dt = obj.WorkTypeList();
                        DataRow dr = dt.NewRow();
                        dr[0] = 0;
                        dr[1] = "-- Any --";
                        dr[2] = "";
                        dt.Rows.InsertAt(dr, 0);
                        Session.Add("SearchWorkTypeList", dt);
                    }
                    return View("JobAlertUpdate", model);
                }
            }
            return View("JobAlertNotExist");
        }
Пример #5
0
        public ActionResult JobAlert(JobAlertModel model)
        {
            if (ModelState.IsValid)
            {
                YG_Business.JobAlertInfo info = new YG_Business.JobAlertInfo();
                info.JobAlertId = model.JobAlertId;
                info.CadidateId = model.CandidateId;
                info.FirstName = model.Name;
                info.SurName = model.SurName;
                info.Email = model.Email;
                info.PhoneCode = model.PhoneCode;
                info.PhoneNo = model.ContactNumber;
                info.CreatedDate = DateTime.Now;
                info.FrequencyId = model.MailFrequency;
                info.WorkTypeList = new List<YG_Business.JobAlertWorkType>();
                info.LocationList = new List<YG_Business.JobAlertLocation>();
                info.IndustryList = new List<YG_Business.JobAlertIndustry>();
                YG_Business.JobAlertIndustry industryInfo;
                foreach (int indsurty in model.IndustrySelect)
                {
                    industryInfo = new YG_Business.JobAlertIndustry();
                    industryInfo.SubIndustryId = indsurty;
                    info.IndustryList.Add(industryInfo);
                }

                YG_Business.JobAlertLocation locationInfo;
                foreach (int location in model.LocationSelect)
                {
                    locationInfo = new YG_Business.JobAlertLocation();
                    locationInfo.LocationId = location;
                    info.LocationList.Add(locationInfo);
                }
                YG_Business.JobAlertWorkType workTypeInfo;
                foreach (int workType in model.WorkTypeSelect)
                {
                    workTypeInfo = new YG_Business.JobAlertWorkType();
                    workTypeInfo.WorkTypeId = workType;
                    info.WorkTypeList.Add(workTypeInfo);
                }
                string candidateguid = model.CandidateGUID;

                MailMessage message = new MailMessage();
                string address = ConfigurationManager.AppSettings.Get("emailAddress");
                string displayName = ConfigurationManager.AppSettings.Get("emailName");
                string body;
                JobAlert alert = new JobAlert();
                int alertId = 0;
                bool alertExist = false;
                if (model.JobAlertId == 0)
                {
                    alertId = alert.getJobAlertId(info.Email, ref candidateguid);
                }

                if (alertId > 0)
                {
                    body = System.IO.File.ReadAllText(Server.MapPath("~/Template") + "/alertExist.htm");
                    message = new MailMessage
                    {
                        From = new MailAddress(address, displayName),
                        Subject = "Please edit your YOU Global Job Alert subscription",
                        Body = string.Format(body, model.Name, "<a href='" + ConfigurationManager.AppSettings["baseURL"].ToString() + "Jobs/JobAlertEdit.shtml" + "?alertId=" + alertId + "&CID=" + candidateguid + "' > click here</a>", "<img src='" + ConfigurationManager.AppSettings["logoURL"].ToString() + "' />"),
                        IsBodyHtml = true
                    };
                    message.To.Add(model.Email);
                    alertExist = true;
                }
                else
                {
                    alertId = alert.InsertJobAlert(info, ref candidateguid);

                    body = System.IO.File.ReadAllText(Server.MapPath("~/Template") + "/alertemail.html");
                    body = string.Format(body, model.Name, "<a href='" + ConfigurationManager.AppSettings["subscribeConfirm"].ToString() + "?aD=" + alertId + "&CID=" + candidateguid + "' > click here</a>", "<img src='" + ConfigurationManager.AppSettings["logoURL"].ToString() + "' />");

                    if (model.JobAlertId == 0)
                    {
                        message = new MailMessage
                        {
                            From = new MailAddress(address, displayName),
                            Subject = "Please activate your YOU Global Job Alert subscription",
                            Body = body,
                            IsBodyHtml = true
                        };
                        message.To.Add(model.Email);
                    }
                    else
                    {
                        DataSet ds = alert.getJobAlert(alertId, candidateguid);
                        if (ds.Tables.Count > 0)
                        {
                            body = System.IO.File.ReadAllText(Server.MapPath("~/Template") + "/alertConfirmedmail.htm");
                            string name = ds.Tables[0].Rows[0]["first"].ToString();
                            string sector = "<table>";
                            string location = "<table>";
                            string worktype = "<table>";
                            foreach (DataRow drSector in ds.Tables[3].Rows)
                            {
                                sector += "<tr><td>" + drSector["subclassification"].ToString() + "</td></tr>";
                            }
                            sector += "</table>";
                            foreach (DataRow drLocation in ds.Tables[1].Rows)
                            {
                                location += "<tr><td>" + drLocation["name"].ToString() + "</td></tr>";
                            }
                            location += "</table>";

                            foreach (DataRow drWorkType in ds.Tables[2].Rows)
                            {
                                worktype += "<tr><td>" + drWorkType["type"].ToString() + "</td></tr>";
                            }
                            worktype += "</table>";

                            string frequney = ds.Tables[0].Rows[0]["frequency"].ToString();
                            body = string.Format(body, name, sector, location, worktype, frequney, ConfigurationManager.AppSettings["baseURL"].ToString() + "Jobs/JobAlertEdit.shtml" + "?alertId=" + alertId + "&CID=" + candidateguid, ConfigurationManager.AppSettings["logoURL"].ToString());
                        }
                        message = new MailMessage
                        {
                            From = new MailAddress(address, displayName),
                            Subject = "Your YOU Global Job Alert subscription is confirmed",
                            Body = body,
                            IsBodyHtml = true
                        };
                        message.To.Add(model.Email);
                    }
                }
                SmtpClient sc = new SmtpClient();
                sc.Host = ConfigurationManager.AppSettings["smtpHost"].ToString();
                string smtpUser = ConfigurationManager.AppSettings["smtpUserName"].ToString();
                string smtpPwd = ConfigurationManager.AppSettings["smtpPassword"].ToString();
                sc.Credentials = new System.Net.NetworkCredential(smtpUser, smtpPwd);
                sc.Send(message);

                if (alertExist)
                    return base.View("JobAlertExist");
                else
                {
                    if (model.JobAlertId == 0)
                    {
                        return base.View("JobAlertSuccess", alertId);
                    }
                    else
                    {
                        model.JobAlertId = alertId;
                        model.CandidateGUID = candidateguid;
                        return base.View("JobAlertEditSuccess", model);
                    }
                }
            }
            return base.View("JobAlertSuccess");
        }