Exemplo n.º 1
0
        public ActionResult Client([Bind(Include = "clientid,userid,countryid")] hc_client_user hC_CLIENT_USERS, long year = 0)
        {
            Session["button"] = "";
            cache();
            if (Session["userid"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            else
            {
                var userinfo = (long)Session["userid"];
                var mapped   = db.hc_client_user.Where(x => x.Userid == userinfo).FirstOrDefault();
                if (mapped != null)
                {
                    year = 2018;
                    long data = DateTime.Now.Month;


                    long uid      = (long)Session["userid"];
                    var  countrys = db.hc_client_user.Where(x => x.Userid == uid).OrderBy(x => x.HCM_COUNTRIES.CountryTitle).First();
                    long country  = (long)countrys.Countryid;
                    var  clients  = db.hc_client_user.Where(x => x.Userid == uid && x.Countryid == country).OrderBy(x => x.HC_CLIENTS.ClientName).First();
                    long client   = (long)clients.Clientid;
                    var  lobs     = db.HC_CLIENT_BRANCH.Where(m => m.ClientID == client).Join(db.hc_client_user.Where(x => x.Userid == uid),
                                                                                              d => d.ClientID,
                                                                                              f => f.Clientid,

                                                                                              (d, f) => d).OrderBy(x => x.RID).First();
                    long lobid = (long)lobs.RID;
                    ViewBag.clid = client;
                    string mymonths   = "" + DateTimeFormatInfo.CurrentInfo.GetAbbreviatedMonthName((int)data) + "";
                    string lobdata    = string.Empty;
                    string clientdata = string.Empty;

                    getClient(country, new long[] { client });
                    getlob(new long[] { client }, country);
                    ViewBag.Status = null;
                    ViewBag.year   = year;
                    bindState();
                    lobdata       = "";
                    clientdata    = "" + client + "";
                    ViewBag.VALUE = db.TimeSheetappliGrid(clientdata, lobdata, year, mymonths);
                    templatedata();



                    GetYears();
                    GetMonths((long)year, new[] { data });

                    return(View());
                }
                else
                {
                    TempData["mapped"] = "Client is not mapped to you";
                    ViewBag.mapped     = "Client is not mapped to you";
                    return(RedirectToAction("Dash", "Dashboard"));
                }
            }
        }
        public void BarChart([Bind(Include = "clientid,userid,countryid")] hc_client_user hC_CLIENT_USERS, long country, long year, long[] month)
        {
            long id = (long)Session["userid"];

            try
            {
                string countries = string.Empty; // Initialize a string to hold the comma-delimited data as empty
                if (country != 0)
                {
                    countries = "" + country + "";
                }
                else
                {
                    bindState();
                    IEnumerable <SelectListItem> count = (IEnumerable <SelectListItem>)TempData["country"];
                    foreach (var item in count)
                    {
                        if (countries.Length > 0)
                        {
                            countries += ","; // Add a comma if data already exists
                        }

                        countries += "" + item.Value + "";
                    }
                }
                string mymonths = string.Empty;
                if (month[0] == 0)
                {
                    if (year == 2018)
                    {
                        for (int i = 1; i <= DateTime.Now.Month; i++)

                        {
                            if (mymonths.Length > 0)
                            {
                                mymonths += ","; // Add a comma if data already exists
                            }

                            mymonths += "" + DateTimeFormatInfo.CurrentInfo.GetAbbreviatedMonthName(i) + "";
                        }
                    }
                    else
                    {
                        mymonths += "" + "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec" + "";
                    }
                }
                else
                {
                    foreach (var item in month)
                    {
                        if (mymonths.Length > 0)
                        {
                            mymonths += ","; // Add a comma if data already exists
                        }

                        mymonths += "" + DateTimeFormatInfo.CurrentInfo.GetAbbreviatedMonthName((int)item) + "";
                    }
                }
                List <long> lstClientID = new List <long>();
                List <int?> lstTSCount  = new List <int?>();
                List <TimeSheetBarChart_Result> TimeSheet = new List <TimeSheetBarChart_Result>();
                HCClientuserModel.ProductWiseSales(out TimeSheet, id, countries, year, mymonths);

                ViewBag.TimeSheet = TimeSheet;
            }
            catch (Exception ex)
            {
                string ip = Request.UserHostAddress;
                errorfile.SendErrorToText(ex, ip);
                throw;
            }
        }
        public ActionResult Dash([Bind(Include = "clientid,userid,countryid")] hc_client_user hC_CLIENT_USERS)
        {
            if (TempData["mapped"] != null)
            {
                ViewBag.mapped = TempData["mapped"];
            }
            else
            {
                ViewBag.mapped = "";
            }
            cache();
            if (Session["userid"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            else
            {
                long country = 0;

                long year = 2018;
                long data = 0;
                if (year != 2018)
                {
                    data = 0;
                }
                else
                {
                    data = DateTime.Now.Month;
                }
                long[] months    = new[] { data };
                string countries = string.Empty; // Initialize a string to hold the comma-delimited data as empty
                if (country != 0)
                {
                    countries = "" + country + "";
                }
                else
                {
                    bindState();
                    IEnumerable <SelectListItem> count = (IEnumerable <SelectListItem>)TempData["country"];
                    foreach (var item in count)
                    {
                        if (countries.Length > 0)
                        {
                            countries += ","; // Add a comma if data already exists
                        }

                        countries += "" + item.Value + "";
                    }
                }
                string mymonths = string.Empty;
                if (months[0] == 0)
                {
                    if (year == 2018)
                    {
                        for (int i = 1; i <= DateTime.Now.Month; i++)

                        {
                            if (mymonths.Length > 0)
                            {
                                mymonths += ","; // Add a comma if data already exists
                            }

                            mymonths += "" + DateTimeFormatInfo.CurrentInfo.GetAbbreviatedMonthName(i) + "";
                        }
                    }
                    else
                    {
                        mymonths += "" + "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec" + "";
                    }
                }
                else
                {
                    foreach (var item in months)
                    {
                        if (mymonths.Length > 0)
                        {
                            mymonths += ","; // Add a comma if data already exists
                        }

                        mymonths += "" + DateTimeFormatInfo.CurrentInfo.GetAbbreviatedMonthName((int)item) + "";
                    }
                }
                long userid = (long)Session["userid"];
                bindState();
                BarChart(hC_CLIENT_USERS, 0, year, new[] { data });
                GetYears();
                clientmapping();
                var countrys = db.HCM_COUNTRIES.OrderBy(x => x.CountryTitle).Select(x => x.RID).FirstOrDefault();
                getclient(countrys, 0);
                GetMonths(year, new[] { data });
                ViewBag.viewall = db.TimeSheetBarChartDashBoardViewAll(userid, countries, year, mymonths);
                var mapped = db.hc_client_user.Where(x => x.Userid == userid).FirstOrDefault();
                if (mapped == null)
                {
                    ViewBag.mapped = "Client is not mapped to you";
                }
                return(View());
            }
        }
Exemplo n.º 4
0
        public string Sendmail(hc_client_user obj, HC_EMAIL_SENT_LOG model, string filename, string uploadefile, long country)
        {
            string message = string.Empty;
            string mesdata = string.Empty;
            int    flag    = 1;

            //message= mail(obj,obj.EmailSubject, obj.EMailBody, "*****@*****.**", null, null, uploadefile, filename, country);
            // if (message == "Problem while sending email, Please check details.")
            // {
            //     mesdata += "  Email is not sent to"+ "*****@*****.**"+" .  ";
            //     flag = 0;
            // }

            if (obj.ToEmail != null)
            {
                string[] Toemail = obj.ToEmail.Split(';');
                foreach (string item in Toemail)
                {
                    message = mail(obj, obj.EmailSubject, obj.EMailBody, item, null, null, uploadefile, filename, country);
                    if (message == "Problem while sending email, Please check details.")
                    {
                        mesdata += " Email is not sent to" + item + " .  ";

                        flag = 0;
                    }
                }
            }

            if (obj.EmailCC != null)
            {
                string[] emailcc = obj.EmailCC.Split(';');
                foreach (string item in emailcc)
                {
                    message = mail(obj, obj.EmailSubject, obj.EMailBody, null, null, item, uploadefile, filename, country);
                    if (message == "Problem while sending email, Please check details.")
                    {
                        mesdata += " Email is not sent to" + item + " .  ";

                        flag = 0;
                    }
                }
            }

            if (obj.EmailBCC != null)
            {
                string[] emailbcc = obj.EmailBCC.Split(';');
                foreach (string item in emailbcc)
                {
                    message = mail(obj, obj.EmailSubject, obj.EMailBody, null, item, null, uploadefile, filename, country);
                    if (message == "Problem while sending email, Please check details.")
                    {
                        mesdata += "  Email is not sent to" + item + " .  ";
                        flag     = 0;
                    }
                }
            }



            if (flag == 1)
            {
                obj.message = "Email Send." + mesdata;
            }
            else
            {
                obj.message = mesdata + " Please check details.";
            }

            TempData["country"] = obj.country;
            TempData["client"]  = obj.clients;
            TempData["lob"]     = obj.lobs;
            TempData["year"]    = obj.years;
            TempData["month"]   = obj.monthdata;
            TempData["message"] = obj.message;


            cache();

            Session["button"] = "";

            return(obj.message);
        }
Exemplo n.º 5
0
        public string mail(hc_client_user obj, string EmailSubject = null, string EMailBody = null, string ToEmail = null, string EmailBCC = null, string EmailCC = null, string fileupload = null, string fileUploader = null, long country = 0)
        {
            HC_EMAIL_SENT_LOG model = new HC_EMAIL_SENT_LOG();

            try
            {
                var message = new MailMessage();
                var from    = db.IHD_Country_EmailID.Where(x => x.CountryID == country).Select(x => x.CounEmailID).FirstOrDefault();
                message.From       = new MailAddress(from); // replace with valid value
                message.Subject    = EmailSubject;
                message.Body       = EMailBody;
                message.IsBodyHtml = true;
                var smtp = new SmtpClient
                {
                    Host                  = "mailbrd.collabera.com",
                    Port                  = 25,
                    EnableSsl             = false,
                    DeliveryMethod        = SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = false,
                };
                if (ToEmail != null)
                {
                    if (fileupload != "")
                    {
                        string[] filesdata = fileupload.Split(',');
                        foreach (string item in filesdata)
                        {
                            Attachment attachment = new Attachment(Path.Combine(Server.MapPath("~/uploadfolder/"), item));
                            message.Attachments.Add(attachment);
                        }
                    }
                    if (fileUploader != "")
                    {
                        string[] files = fileUploader.Split(',');
                        foreach (string item in files)
                        {
                            var value    = new WebClient();
                            var filepath = Path.Combine(Server.MapPath("~/uploadfolder/"), item);

                            var filedest = Path.Combine(Server.MapPath("~/uploadeddata/"), item);
                            value.DownloadFile(filepath, filedest);
                            Attachment attachment = new Attachment(filepath, MimeMapping.GetMimeMapping(filepath));

                            message.Attachments.Add(attachment);

                            value.Dispose();
                        }
                    }
                    message.To.Add(new MailAddress(ToEmail));
                    smtp.Send(message);
                    var data = db.TimeSheetDetailsAgainstCandidate(obj.clid).ToArray();
                    foreach (var datainfo in data)
                    {
                        model.employeeno          = obj.clid;
                        model.TSStartdate         = datainfo.StartDate;
                        model.TSEnddate           = datainfo.EndDate;
                        model.TemplateId          = (int)obj.tempid;
                        model.EmailSent           = DateTime.Now;
                        model.DateEmailSentUserId = (long)Session["userid"];
                        db.HC_EMAIL_SENT_LOG.Add(model);
                        db.SaveChanges();
                    }
                }
                if (EmailCC != null)
                {
                    if (fileupload != "")
                    {
                        string[] filesdata = fileupload.Split(',');
                        foreach (string item in filesdata)
                        {
                            Attachment attachment = new Attachment(Path.Combine(Server.MapPath("~/uploadfolder/"), item));
                            message.Attachments.Add(attachment);
                        }
                    }
                    if (fileUploader != "")
                    {
                        string[] files = fileUploader.Split(',');
                        foreach (string item in files)
                        {
                            var value    = new WebClient();
                            var filepath = Path.Combine(Server.MapPath("~/uploadfolder/"), item);
                            var filedest = Path.Combine(Server.MapPath("~/uploadeddata/"), item);
                            //FileInfo file = new FileInfo(filedest);
                            //file.Delete();

                            value.DownloadFile(filepath, filedest);
                            Attachment attachment = new Attachment(filepath, MimeMapping.GetMimeMapping(filepath));

                            message.Attachments.Add(attachment);

                            value.Dispose();
                        }
                    }

                    message.CC.Add(new MailAddress(EmailCC));
                    smtp.Send(message);
                }
                if (EmailBCC != null)
                {
                    if (fileupload != "")
                    {
                        string[] filesdata = fileupload.Split(',');
                        foreach (string item in filesdata)
                        {
                            Attachment attachment = new Attachment(Path.Combine(Server.MapPath("~/uploadfolder/"), item));
                            message.Attachments.Add(attachment);
                        }
                    }

                    if (fileUploader != "")
                    {
                        string[] files = fileUploader.Split(',');
                        foreach (string item in files)
                        {
                            var value    = new WebClient();
                            var filepath = Path.Combine(Server.MapPath("~/uploadfolder/"), item);
                            var filedest = Path.Combine(Server.MapPath("~/uploadeddata/"), item);


                            value.DownloadFile(filepath, filedest);

                            Attachment attachment = new Attachment(filepath, MimeMapping.GetMimeMapping(filepath));

                            message.Attachments.Add(attachment);
                            value.Dispose();
                        }
                    }

                    message.Bcc.Add(new MailAddress(EmailBCC));
                    smtp.Send(message);
                }

                return("Email Send.");
            }

            catch (Exception ex)
            {
                string ip = Request.UserHostAddress;
                errorfile.SendErrorToText(ex, ip);
                return("Problem while sending email, Please check details.");
            }
        }
Exemplo n.º 6
0
        public ActionResult SendEmail(string cid, string month, string clid = null, string name = null, string from = null, string till = null, string bulkemail = null, long countryid = 0, int lobid = 0, long year = 0)
        {
            templatedata();
            hc_client_user model = new hc_client_user();

            if (bulkemail != null)
            {
                ViewBag.bulk = "1";
                string[] m          = bulkemail.Split(',');
                string   offemail   = string.Empty;
                string   peremail   = string.Empty;
                string   bothemails = string.Empty;
                string   emailids   = string.Empty;
                foreach (var item in m)
                {
                    var value = db.HC_RESUME_BANK.Where(x => x.EmployeeNo == item).FirstOrDefault();
                    if (value.ExOfficialEmailID != null)
                    {
                        if (value.ExOfficialEmailID != "")
                        {
                            if (offemail.Length > 0)
                            {
                                offemail += ";"; // Add a comma if data already exists
                            }

                            offemail += "" + value.ExOfficialEmailID + "";
                        }
                    }
                    if (value.EmailID != null)
                    {
                        if (value.EmailID != "")
                        {
                            if (peremail.Length > 0)
                            {
                                peremail += ";"; // Add a comma if data already exists
                            }

                            peremail += "" + value.EmailID + "";
                        }
                    }
                }
                ViewBag.offemail = offemail;
                ViewBag.peremail = peremail;
                if (offemail == null)
                {
                    ViewBag.bothemail = peremail;
                }
                if (peremail == null)
                {
                    ViewBag.bothemail = offemail;
                }
                if (offemail != null && peremail != null)
                {
                    ViewBag.bothemail = offemail + ";" + peremail;
                }
            }
            else
            {
                ViewBag.bulk = "0";

                ViewBag.a  = from;
                ViewBag.b  = till;
                model.name = name;

                var value = db.HC_RESUME_BANK.Where(x => x.EmployeeNo == clid).First();
                ViewBag.offemail = value.ExOfficialEmailID;
                ViewBag.peremail = value.EmailID;
                if (value.ExOfficialEmailID == null)
                {
                    ViewBag.bothemail = value.EmailID;
                }
                if (value.EmailID == null)
                {
                    ViewBag.bothemail = value.ExOfficialEmailID;
                }
                if (value.ExOfficialEmailID != null && value.EmailID != null)
                {
                    ViewBag.bothemail = value.ExOfficialEmailID + ";" + value.EmailID;
                }
                model.clid = clid;
                model.from = from;
                model.till = till;
            }

            model.EmailBCC    = db.IHD_Country_EmailID.Where(x => x.CountryID == countryid).Select(x => x.CounEmailID).FirstOrDefault();
            model.country     = countryid;
            model.clients     = cid;
            model.lob         = lobid;
            model.monthdata   = month;
            model.year        = year;
            model.buttonvalue = "1";

            Session["button"] = "1";
            return(View(model));
        }
Exemplo n.º 7
0
        public ActionResult Client(hc_client_user model, HC_EMAIL_SENT_LOG obj, long[] client, long[] month, long year = 0, long country = 0, long lob = 0, string Imagepath = null, string closedata = null, string uplodedfile = null)
        {
            if (Session["userid"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            else
            {
                var userinfo = (long)Session["userid"];
                var data     = db.hc_client_user.Where(x => x.Userid == userinfo).FirstOrDefault();
                if (data != null)
                {
                    if (model.buttonvalue == "1")
                    {
                        string[]    clientinfo  = model.clients.Split(',');
                        string[]    monthinfo   = model.monthdata.Split(',');
                        List <long> clientarray = new List <long>();
                        foreach (string s in clientinfo)
                        {
                            long val;

                            if (long.TryParse(s, out val))
                            {
                                clientarray.Add(val);
                            }
                        }

                        client = clientarray.ToArray();
                        List <long> montharray = new List <long>();
                        foreach (string s in monthinfo)
                        {
                            long val;

                            if (long.TryParse(s, out val))
                            {
                                montharray.Add(val);
                            }
                        }

                        month = montharray.ToArray();
                    }
                    var mesaage = string.Empty;
                    if (closedata == "0")
                    {
                        if (Session["button"].ToString() == "1")
                        {
                            mesaage = Sendmail(model, obj, Imagepath, uplodedfile, country);
                        }
                    }

                    long   id       = (long)Session["userid"];
                    string mymonths = string.Empty;
                    if (month[0] == 0)
                    {
                        if (year == 2018)
                        {
                            for (int i = 1; i <= DateTime.Now.Month; i++)

                            {
                                if (mymonths.Length > 0)
                                {
                                    mymonths += ","; // Add a comma if data already exists
                                }

                                mymonths += "" + DateTimeFormatInfo.CurrentInfo.GetAbbreviatedMonthName(i) + "";
                            }
                        }
                        else
                        {
                            mymonths += "" + "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec" + "";
                        }
                    }
                    else
                    {
                        foreach (var item in month)
                        {
                            if (mymonths.Length > 0)
                            {
                                mymonths += ","; // Add a comma if data already exists
                            }

                            mymonths += "" + DateTimeFormatInfo.CurrentInfo.GetAbbreviatedMonthName((int)item) + "";
                        }
                    }
                    string lobdata    = string.Empty;
                    string clientdata = string.Empty;

                    var monthname = model.valclient;

                    getClient(country, client);
                    getlob(client, country, lob);

                    if (client[0] == 0)
                    {
                        foreach (var item in ViewBag.clients)
                        {
                            if (clientdata.Length > 0)
                            {
                                clientdata += ","; // Add a comma if data already exists
                            }

                            clientdata += "" + item.Value + "";
                        }
                    }
                    else
                    {
                        foreach (var item in client)
                        {
                            if (clientdata.Length > 0)
                            {
                                clientdata += ","; // Add a comma if data already exists
                            }

                            clientdata += "" + item + "";
                        }
                    }

                    if (lob == 0)
                    {
                        foreach (var item in ViewBag.lobs)
                        {
                            if (lobdata.Length > 0)
                            {
                                lobdata += ","; // Add a comma if data already exists
                            }

                            lobdata += "" + item.Value + "";
                        }
                    }
                    else
                    {
                        lobdata = "" + lob + "";
                    }



                    ViewBag.VALUE = db.TimeSheetappliGrid(clientdata, lobdata, year, mymonths);

                    bindState();
                    GetYears();
                    GetMonths((long)year, month);
                    ViewBag.count = country;


                    if (mesaage != null)
                    {
                        ViewBag.Status = mesaage;
                    }
                    else
                    {
                        ViewBag.Status = null;
                    }

                    return(View());
                }
                else
                {
                    return(RedirectToAction("Dash", "Dashboard"));
                }
            }
        }