Esempio n. 1
0
        public ActionResult OprFileManager(string id = "")
        {
            var istdate = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now, TimeZoneInfo.Local.Id, "India Standard Time");

            ManageCompMaster  companyMaster = new ManageCompMaster();
            fileManagerAdd    objmodel      = new fileManagerAdd();
            ManageFileManager filemanager   = new ManageFileManager();

            if (id == "")
            {
                var companyList = companyMaster.compmastersListByCustId(ProjectSession.custid);
                ViewBag.CompanyList = new SelectList(companyList, "compid", "compname");

                var categoryList = filemanager.GetFileCategory();
                ViewBag.CategoryList = new SelectList(categoryList, "catid", "catname");

                objmodel.uploadeddateString = istdate.ToString("dd/MM/yyyy");
                objmodel.filedateString     = istdate.ToString("dd/MM/yyyy");
            }
            else
            {
                var fileMData   = filemanager.GetFileManagerById(id, ProjectSession.custid);
                var fileDetails = filemanager.GetFileDetailsById(fileMData.fileid, ProjectSession.custid);
                objmodel.fileid             = fileMData.fileid;
                objmodel.fileid1            = fileMData.fileid1.Value;
                objmodel.compid             = fileMData.compid;
                objmodel.compfinid          = fileMData.compfinid;
                objmodel.filecatid          = fileMData.filecatid;
                objmodel.filesubcatid       = fileMData.filesubcatid;
                objmodel.filetitle          = fileMData.filetitle;
                objmodel.filedate           = fileMData.filedate;
                objmodel.uploadeddateString = fileMData.uploadeddate.Value.ToShortDateString();
                objmodel.filedateString     = fileMData.filedate.Value.ToShortDateString();
                objmodel.uploadeddate       = fileMData.uploadeddate.Value;
                objmodel.filedescr          = fileMData.filedescr;
                objmodel.filemanagerdtl     = filemanager.GetFileDetailsById(fileMData.fileid, ProjectSession.custid);


                //objmodel.filedtlid = fileDetails.filedtlid;
                //objmodel.fileimageSaved = fileDetails.fileimage;
                //objmodel.filetype = fileDetails.filetype;
                //objmodel.filename = fileDetails.filename;
                //objmodel.filedtlid1 = fileDetails.filedtlid1.Value;
                //  var imagetype = objmodel.filetype.Substring(1, objmodel.filetype.Length - 1);

                var companyList = companyMaster.compmastersListByCustId(ProjectSession.custid);
                ViewBag.CompanyList = new SelectList(companyList, "compid", "compname", objmodel.compid);

                var categoryList = filemanager.GetFileCategory();
                ViewBag.CategoryList = new SelectList(categoryList, "catid", "catname", objmodel.filecatid);

                //ViewBag.Base64String = "data:image/"+imagetype +";base64," + Convert.ToBase64String(objmodel.fileimageSaved, 0, objmodel.fileimageSaved.Length);
            }
            return(View(objmodel));
        }
Esempio n. 2
0
        public ActionResult SendEmail(string fileid, string email)
        {
            try
            {
                ManageFileManager filemanager = new ManageFileManager();
                var fileMData = filemanager.GetFileDetailsById(fileid, ProjectSession.custid);


                emailsetting settings = Common.GetEmailSettings(ProjectSession.custid);

                string      smtpAddress     = settings.smtpname;
                int         portNumber      = Convert.ToInt32(settings.portno);
                bool        enableSSL       = Convert.ToBoolean(settings.enablessl);
                MailMessage mail            = new MailMessage();
                string      FromMailAddress = settings.emailid;
                string      password        = settings.password;

                mail.From = new MailAddress(FromMailAddress, "IEP Reports");
                if (Request.IsLocal.Equals(true))
                {
                    mail.To.Add(new MailAddress("*****@*****.**"));
                }
                else
                {
                    mail.To.Add(new MailAddress(email));
                }
                mail.Subject    = "File attachments";
                mail.Body       = "Test Email";
                mail.IsBodyHtml = true;
                foreach (var item in fileMData)
                {
                    Stream stream = new MemoryStream(item.fileimage);
                    // if (!string.IsNullOrEmpty(AttachmentPath))
                    {
                        System.Net.Mail.Attachment attachment;
                        attachment = new System.Net.Mail.Attachment(stream, item.filename);
                        mail.Attachments.Add(attachment);
                    }
                }
                bool sentMail = false;
                using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
                {
                    smtp.Credentials = new NetworkCredential(FromMailAddress, password);
                    smtp.EnableSsl   = enableSSL;
                    try
                    {
                        smtp.Send(mail);
                    }
                    catch (Exception ex)
                    {
                    }
                }


                //fileManagerrepo.SaveFile(file, filename, fileId);
                return(new ReplyFormat().Success(Message.SUCCESS));
            }
            catch (Exception ex)
            {
                return(new ReplyFormat().Error(ex.Message.ToString()));
            }
        }