public JsonResult SelectAgentAll(string PageIndex = "1", string SearchItem = "")
        {
            try
            {
                DataSet   ds         = new DataSet();
                int       statusCode = 1;
                DataTable dtbl       = new DataTable();
                BlAgent   blagent    = new BlAgent();
                blagent.UserCode   = Convert.ToInt64(Session["ID_Agent"]);
                blagent.FK_Company = Convert.ToInt64(Session["ID_Company"]);

                blagent.AgCode  = SearchItem;
                blagent.AgName  = SearchItem;
                blagent.DepName = SearchItem;

                blagent.PageIndex = Convert.ToInt32(PageIndex);
                ds = blagent.SelectAllData();
                DataTable Dt = ds.Tables[0];

                return(Json(Converttojson(Dt), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ///
                return(Json(ex));
            }
        }
        public JsonResult FillAgent(Int64 ID_Agent)
        {
            try
            {
                DataSet   ds      = new DataSet();
                DataTable dtbl    = new DataTable();
                BlAgent   blagent = new BlAgent();
                blagent.UserCode   = Convert.ToInt64(Session["ID_Agent"]);
                blagent.FK_Company = Convert.ToInt64(Session["ID_Company"]);
                blagent.MasterID   = ID_Agent;
                ds = blagent.SelectAllData();
                DataTable  Dt          = ds.Tables[0];
                DataTable  Dt1         = ds.Tables[1];
                BlFunction blfunctions = new BlFunction();
                Dt.Rows[0]["AgPassword"] = blfunctions.DecryptAgent(Convert.ToString(Dt.Rows[0]["AgPassword"].ToString()));
                blfunctions = null;



                return(Json(new { table = "" + Converttojson(Dt) + "", table1 = "" + Converttojson(Dt1) + "" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(ex));
            }
        }
        public JsonResult FillAgentChangePassword()
        {
            try
            {
                DataSet   ds      = new DataSet();
                DataTable dtbl    = new DataTable();
                BlAgent   blagent = new BlAgent();
                blagent.UserCode   = Convert.ToInt64(Session["ID_Agent"]);
                blagent.FK_Company = Convert.ToInt64(Session["ID_Company"]);
                blagent.MasterID   = Convert.ToInt64(Session["ID_Agent"]);
                ds = blagent.SelectAllData();
                DataTable Dt = ds.Tables[0];


                return(Json(Converttojson(Dt), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(ex));
            }
        }
        public ActionResult UpdateTicketAssign(BlTickets ObjBlTickets)
        {
            DataSet ds  = new DataSet();
            DataSet ds1 = new DataSet();

            ObjBlTickets.FK_Company = Convert.ToInt64(Session["ID_Company"]);
            ObjBlTickets.AgentCode  = Convert.ToInt64(Session["ID_Agent"]);

            long statusCode = 0;

            statusCode = ObjBlTickets.UpdateTicketAssign();

            try
            {
                BlAgent blAgent = new BlAgent();
                blAgent.MasterID = ObjBlTickets.AgentCode;
                ds = blAgent.SelectAllData();
                DataTable Dt        = ds.Tables[0];
                var       Fromagent = Dt.Rows[0]["AgName"].ToString();
                blAgent = null;

                BlAgent blAgentto = new BlAgent();
                blAgentto.MasterID = ObjBlTickets.AgentTo;
                ds1 = blAgentto.SelectAllData();
                DataTable Dt1     = ds1.Tables[0];
                var       toagent = Dt1.Rows[0]["AgName"].ToString();

                List <string> toagentmailid = new List <string>();
                toagentmailid.Add(Dt1.Rows[0]["Agemail"].ToString());
                blAgentto = null;

                List <string> resumesids = new List <string>();
                if (ObjBlTickets.MasterID != 0)
                {
                    resumesids.Add(ObjBlTickets.MasterID.ToString());
                }
                else
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.LoadXml(ObjBlTickets.XmlTickets);

                    string xpath = "root/Tickets/ID_Tickets";
                    var    nodes = xmlDoc.SelectNodes(xpath);

                    foreach (XmlNode childrenNode in nodes)
                    {
                        resumesids.Add(childrenNode.InnerText);
                    }
                }


                // DataTable dt2= ObjBlTickets.SelectAllData();

                var resumeno = ""; ///dt2.Rows[0]["TickNo"].ToString();
                //var candidatename = dt2.Rows[0]["CandidateName"].ToString();


                string htmlbody = "<p><strong> SMART RECRUITER RESUME ASSIGNED </strong></p> <p>Hi " + toagent + ", </p>";
                htmlbody += "<p><a  href='" + ConfigurationManager.AppSettings["api-url"] + "/Resumes/Resumes'> Click here </a> to View All resumes</p>";
                htmlbody += "<p>Please find this <strong>";
                foreach (var res in resumesids)
                {
                    htmlbody += "<a  href='" + ConfigurationManager.AppSettings["api-url"] + "/Resumes/Resumes?ID_Resumes=" + res + "'> RESUME " + resumeno + "</a></strong><br/>";
                }
                // htmlbody += " <p>Candidate Name&nbsp;:&nbsp;<strong>"+ candidatename + "</strong><br />";
                htmlbody += "<br />";
                htmlbody += "Assigned by : " + Fromagent + " in SmartRecruiter</p>";

                SendMail("SMARTRECRUITER RESUME ASSIGNED", htmlbody, toagentmailid);
            }
            catch (Exception ex)
            {
            }

            ObjBlTickets = null;
            return(Json(new { statusCode = "" + statusCode + "" }, JsonRequestBehavior.AllowGet));
        }