Exemple #1
0
        public ReturnValue SendMail(string subject, string textBody, string htmlBody)
        {
            ReturnValue result;

            try
            {
                EmailUtils.SendMail(appConfig.EmailServerSettings.FromEmail,
                                    appConfig.EmailServerSettings.ToEmail,
                                    subject,
                                    appConfig.EmailServerSettings.UseHtmlMail,
                                    appConfig.EmailServerSettings.UseHtmlMail ? htmlBody : textBody,
                                    appConfig.EmailServerSettings.Server,
                                    appConfig.EmailServerSettings.Port,
                                    appConfig.EmailServerSettings.UserName,
                                    appConfig.EmailServerSettings.Password,
                                    appConfig.EmailServerSettings.UseSSL,
                                    appConfig.EmailServerSettings.TimeoutInSec);
                result = ReturnValue.True();
            }
            catch (Exception ex)
            {
                log.Error(ex, $"Unable to send email to - {appConfig.EmailServerSettings.ToEmail}");
                result = ReturnValue.False($"Unable to send email to - {appConfig.EmailServerSettings.ToEmail}");
            }
            return(result);
        }
        protected static FR_Base Execute(DbConnection Connection, DbTransaction Transaction, P_L6MRMS_SEtR_1606 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_Base();


            List <ORM_MRS_RUN_MeasurementRun_AccountDownloadCode> downloadCodes = ORM_MRS_RUN_MeasurementRun_AccountDownloadCode.Query.Search(Connection, Transaction, new ORM_MRS_RUN_MeasurementRun_AccountDownloadCode.Query()
            {
                Tenant_RefID         = securityTicket.TenantID,
                IsDeleted            = false,
                MeasurementRun_RefID = Parameter.ReadingSessionId
            });

            foreach (var downloadCode in downloadCodes)
            {
                ORM_CMN_BPT_BusinessParticipant businessParticipant = new ORM_CMN_BPT_BusinessParticipant();
                var bpLoad = businessParticipant.Load(Connection, Transaction, downloadCode.Account_RefID);
                if (bpLoad.Status != FR_Status.Success)
                {
                    continue;
                }

                ORM_CMN_BPT_BusinessParticipant_AccessCode bpAccountCode = ORM_CMN_BPT_BusinessParticipant_AccessCode.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant_AccessCode.Query()
                {
                    Tenant_RefID = securityTicket.TenantID,
                    BusinessParticipant_RefID = businessParticipant.CMN_BPT_BusinessParticipantID
                }).SingleOrDefault();
                if (bpAccountCode == null)
                {
                    continue;
                }

                ORM_CMN_PER_PersonInfo personInfo = new ORM_CMN_PER_PersonInfo();
                var piLoad = personInfo.Load(Connection, Transaction, businessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID);
                if (piLoad.Status != FR_Status.Success)
                {
                    continue;
                }

                //sending email

                string subject = Parameter.EmailSubjectTemplate;
                string body    = String.Format
                                 (
                    Parameter.EmailBodyTemplate,
                    personInfo.FirstName,
                    personInfo.LastName,
                    downloadCode.DownloadCode,
                    bpAccountCode.Code
                                 );
                EmailUtils.SendMail(personInfo.PrimaryEmail, subject, body);
            }

            return(returnValue);

            #endregion UserCode
        }
        public string EsqueciSenha(string email)
        {
            var ret           = String.Empty;
            var dataInterface = new DataInterface();
            var retLogin      = dataInterface.GetLogin(email);

            if (retLogin.Sucesso)
            {
                var user       = (UsuarioModel)retLogin.Retorno;
                var corpoEmail = $"Olá {user.Nome}! <br/>" +
                                 "<p>Se você está recebendo este E-Mail é porque solicitou sua senha no sistema Anjo Azul <br/><br/>" +
                                 $"Seu usuário para acesso é: {user.EMail}<br/>" +
                                 $"Sua senha para acesso é: {user.Senha}<br/>" +
                                 "<br/>" +
                                 "Att.<br/>Sistema Anjo Azul!";
                return(EmailUtils.SendMail("Recuperação de Senha - Anjo Azul", corpoEmail, email));
            }
            else
            {
                return("Usuário não encontrado em nossa base de dados");
            }
        }
Exemple #4
0
        private void btSendTestEmail_Click(object sender, EventArgs e)
        {
            try
            {
                EmailUtils.SendMail(txtFromEmail.Text.Trim(),
                                    txtToEmail.Text.Trim(),
                                    "Test email from MonitorR",
                                    cbUseHtmlMessage.Checked,
                                    cbUseHtmlMessage.Checked ? "<html><b>Test html email from MonitorR</b></html>" : "Test email from MonitorR",
                                    txtEmailServerName.Text.Trim(),
                                    SafeUtils.Int(txtEmailPort.Text.Trim()),
                                    txtEmailUsername.Text.Trim(),
                                    txtEmailPassword.Text.Trim(),
                                    cbEmailUseSSL.Checked,
                                    10);

                MessageBox.Show($"Successfully sent the mail to {txtToEmail.Text}");
            }
            catch (Exception ex)
            {
                log.Error(ex, $"Unable to send email to - {txtToEmail.Text}");
                MessageBox.Show($"Unable to send email to - {txtToEmail.Text} \n\n Exception : \n" + ex.RecursivelyGetExceptionMessage());
            }
        }
Exemple #5
0
        protected static FR_L6BH_MBHR_1624 Execute(DbConnection Connection, DbTransaction Transaction, P_L6BH_MBHR_1624 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L6BH_MBHR_1624();
            returnValue.Result = new L6BH_MBHR_1624();
            returnValue.Result.areThereTreatmentsOrFollowupsBilledForParameters = false;
            List <TreatmentData> AllSortedTreatments = new List <TreatmentData>();
            List <Guid>          listOfPractices     = new List <Guid>();

            //treatments and followups for selected month and your (only treatment table)
            var allTreatmentsForTimeRange = cls_Get_Treatments_and_Followups_for_SelectedMonth_and_Year.Invoke(Connection, Transaction, new P_L5TR_GTaFfSMaY_1619()
            {
                SelectedMounth = Parameter.SelectedMounth, SelectedYear = Parameter.SelectedYear
            }, securityTicket).Result.ToList();

            if (allTreatmentsForTimeRange.Count > 0)
            {
                returnValue.Result.areThereTreatmentsOrFollowupsBilledForParameters = true;
            }
            else
            {
                return(returnValue);
            }

            List <Guid> listOfTreatmentIDs = allTreatmentsForTimeRange.Select(i => i.HEC_Patient_TreatmentID).ToList();

            //all treatments and followupss that have bill position table (for selected month, year)
            var treatmentData = cls_Get_BilledTreatmentData_for_Report.Invoke(Connection, Transaction, new P_L5BH_GBTDfR_1158()
            {
                TreatmentID = listOfTreatmentIDs.ToArray()
            }, securityTicket).Result.ToList();

            //get all practices
            listOfPractices = treatmentData.Select(i => i.TreatmentPractice_RefID).Distinct().ToList();

            //from this list remove all treatments/followups that do not have bill positions .... // what is left is old followups which do not have sepparate bill position
            foreach (var item in treatmentData)
            {
                var treatmentToRemove = allTreatmentsForTimeRange.Where(i => i.HEC_Patient_TreatmentID == item.HEC_Patient_TreatmentID).FirstOrDefault();
                if (treatmentToRemove != null)
                {
                    allTreatmentsForTimeRange.Remove(treatmentToRemove);
                }
            }
            var oldFollowups = allTreatmentsForTimeRange;

            #region Get all followups with their own bill position and organise them || FOLLOWUP DATA

            var followupsWihtOwnBillPosition = treatmentData.Where(i => i.External_PositionType == "Nachsorge").ToList();

            List <TreatmentData> followupsWihtOwnBillPositionSorted = new List <TreatmentData>();
            foreach (var item in followupsWihtOwnBillPosition)
            {
                TreatmentData followupData = new TreatmentData();
                followupData.Date          = item.TreatmentDate.ToString("dd.MM.yyyy", new CultureInfo("de-DE"));
                followupData.FirstName     = item.FirstName;
                followupData.LastName      = item.LastName;
                followupData.Birthday      = item.BirthDate.ToString("dd.MM.yyyy", new CultureInfo("de-DE"));
                followupData.Article       = item.Products[0].Product_Name.Contents[0].Content;;
                followupData.Vorgassnumber = item.VorgangsNumber;
                followupData.PracticeID    = item.TreatmentPractice_RefID;
                List <GPOS> GPOS     = new List <GPOS>();
                GPOS        gposData = new GPOS();
                gposData.Number = item.GPOS;
                gposData.Text   = "Nachsorgebehandlung";
                gposData.Price  = double.Parse(item.PositionValue_IncludingTax);
                GPOS.Add(gposData);
                followupData.GPOS = GPOS;
                if (item.TCode == "3")
                {
                    followupData.isAOKConfirmedStatus = true;
                }
                else
                {
                    followupData.isAOKConfirmedStatus = false;
                }
                followupsWihtOwnBillPositionSorted.Add(followupData);
            }
            #endregion

            //from all bill positions remove followups
            foreach (var item in followupsWihtOwnBillPosition)
            {
                treatmentData.Remove(item);
            }

            List <Guid> OLDFollowupsThatHaveTreatmentInDifferentPractice = new List <Guid>();
            foreach (var item in oldFollowups)
            {
                if (treatmentData.Where(i => i.HEC_Patient_TreatmentID == item.IfTreatmentFollowup_FromTreatment_RefID).ToList().Count == 0)
                {
                    OLDFollowupsThatHaveTreatmentInDifferentPractice.Add(item.HEC_Patient_TreatmentID);
                }
            }

            #region Organise Treatment data

            List <TreatmentData> TreatmentsSorted = new List <TreatmentData>();
            List <Guid>          Treatments       = treatmentData.Select(i => i.HEC_Patient_TreatmentID).Distinct().ToList();

            foreach (var treatmentID in Treatments)
            {
                var treatment = treatmentData.Where(i => i.HEC_Patient_TreatmentID == treatmentID && (i.External_PositionType == "Behandlung | Nachsorge" || i.External_PositionType == "Behandlung")).FirstOrDefault();

                TreatmentData treatmentSorted = new TreatmentData();
                treatmentSorted.Date          = treatment.TreatmentDate.ToString("dd.MM.yyyy", new CultureInfo("de-DE"));
                treatmentSorted.PracticeID    = treatment.TreatmentPractice_RefID;
                treatmentSorted.FirstName     = treatment.FirstName;
                treatmentSorted.LastName      = treatment.LastName;
                treatmentSorted.Birthday      = treatment.BirthDate.ToString("dd.MM.yyyy", new CultureInfo("de-DE"));
                treatmentSorted.Vorgassnumber = treatment.VorgangsNumber;
                if (treatment.Products != null && treatment.Products.Length > 0)
                {
                    treatmentSorted.Article = treatment.Products[0].Product_Name.Contents[0].Content;
                }
                else
                {
                    treatmentSorted.Article = "";
                }
                if (treatment.TCode == "3")
                {
                    treatmentSorted.isAOKConfirmedStatus = true;
                }
                else
                {
                    treatmentSorted.isAOKConfirmedStatus = false;
                }

                List <GPOS> GPOS     = new List <GPOS>();
                GPOS        gposData = new GPOS();
                gposData.Number = treatment.GPOS;
                gposData.Text   = "Erstbehandlung " + treatmentSorted.Article;
                gposData.Price  = 230;
                gposData.ID     = 1;
                GPOS.Add(gposData);

                if (treatment.External_PositionType == "Behandlung | Nachsorge")
                {
                    gposData        = new GPOS();
                    gposData.Number = treatment.GPOS;
                    gposData.Text   = "Nachsorgebehandlung";
                    if (treatmentSorted.Article != "Ozurdex")
                    {
                        gposData.Price = 60;
                    }
                    else
                    {
                        gposData.Price = 150;
                    }
                    gposData.ID = 2;
                    GPOS.Add(gposData);
                }

                gposData        = new GPOS();
                gposData.Number = String.Empty;
                gposData.Text   = "Management Pauschaule";
                gposData.Price  = 0;
                gposData.ID     = 5;
                GPOS.Add(gposData);

                if (treatmentSorted.Article.ToLower().Contains("bevacizumab"))
                {
                    var BevacuzimabTreatment = treatmentData.Where(i => i.HEC_Patient_TreatmentID == treatmentID && ((i.External_PositionType == "Zusatzposition Bevacuzimab") || i.External_PositionType == "Zusatzposition Bevacizumab")).FirstOrDefault();

                    if (BevacuzimabTreatment != null)
                    {
                        gposData        = new GPOS();
                        gposData.Number = BevacuzimabTreatment.GPOS;
                        gposData.Text   = "Medikamentenkosten Bevacizumab";
                        gposData.Price  = double.Parse(BevacuzimabTreatment.PositionValue_IncludingTax);
                        gposData.ID     = 3;
                        GPOS.Add(gposData);
                    }
                }

                var WartezeitenmanagementData = treatmentData.Where(i => i.HEC_Patient_TreatmentID == treatmentID && (i.External_PositionType == "Wartezeitenmanagement")).FirstOrDefault();

                if (WartezeitenmanagementData != null)
                {
                    gposData        = new GPOS();
                    gposData.Number = WartezeitenmanagementData.GPOS;
                    gposData.Text   = "Wartezeitenmanagement";
                    gposData.Price  = double.Parse(WartezeitenmanagementData.PositionValue_IncludingTax);
                    gposData.ID     = 4;
                    GPOS.Add(gposData);
                }


                GPOS = GPOS.OrderBy(i => i.ID).ToList();
                treatmentSorted.GPOS = GPOS;
                TreatmentsSorted.Add(treatmentSorted);
            }


            #endregion

            #region Combine Treatment bill positions with followup bill positions

            foreach (var item in followupsWihtOwnBillPositionSorted)
            {
                var treatment = TreatmentsSorted.Where(i => i.Date == item.Date && i.FirstName == item.FirstName && i.LastName == item.LastName && i.Birthday == item.Birthday).FirstOrDefault();
                if (treatment == null)
                {
                    TreatmentsSorted.Add(item);
                }
                else
                {
                    GPOS gposData = new GPOS();
                    gposData.Number = treatment.GPOS.Where(i => i.ID == 1).First().Number;
                    gposData.Text   = "Nachsorgebehandlung";
                    if (treatment.Article != "Ozurdex")
                    {
                        gposData.Price = 60;
                    }
                    else
                    {
                        gposData.Price = 150;
                    }
                    gposData.ID = 2;
                    treatment.GPOS.Add(gposData);
                    treatment.GPOS = treatment.GPOS.OrderBy(i => i.ID).ToList();
                }
            }

            #endregion

            #region Organise OLD Followups (followups that do not have sepparate bill position) and add them to all Treatments
            if (OLDFollowupsThatHaveTreatmentInDifferentPractice.Count > 0)
            {
                var rawDataForOldFollowups = cls_Get_BilledFollowupData_for_Report.Invoke(Connection, Transaction, new P_L5BH_GBFDfR_1443()
                {
                    FollowUpID = OLDFollowupsThatHaveTreatmentInDifferentPractice.ToArray()
                }, securityTicket).Result.ToList();

                rawDataForOldFollowups = rawDataForOldFollowups.Where(i => i.External_PositionType == "Behandlung | Nachsorge" || i.External_PositionType == "Behandlung").ToList();

                List <TreatmentData> OldFollowupsSorted = new List <TreatmentData>();

                foreach (var item in rawDataForOldFollowups)
                {
                    TreatmentData followup = new TreatmentData();
                    followup.Date          = item.FollowupDate.ToString("dd.MM.yyyy", new CultureInfo("de-DE"));
                    followup.PracticeID    = item.FollowupPracticeID;
                    followup.FirstName     = item.FirstName;
                    followup.LastName      = item.LastName;
                    followup.Birthday      = item.BirthDate.ToString("dd.MM.yyyy", new CultureInfo("de-DE"));
                    followup.Vorgassnumber = item.VorgangsNumber;
                    if (item.Products != null && item.Products.Length > 0)
                    {
                        followup.Article = item.Products[0].Product_Name.Contents[0].Content;
                    }
                    else
                    {
                        followup.Article = "";
                    }
                    if (item.TCode == "3")
                    {
                        followup.isAOKConfirmedStatus = true;
                    }
                    else
                    {
                        followup.isAOKConfirmedStatus = false;
                    }

                    List <GPOS> GPOS     = new List <GPOS>();
                    GPOS        gposData = new GPOS();
                    gposData.Number = item.GPOS;
                    gposData.Text   = "Nachsorgebehandlung";
                    if (followup.Article != "Ozurdex")
                    {
                        gposData.Price = 60;
                    }
                    else
                    {
                        gposData.Price = 150;
                    }
                    gposData.ID = 2;
                    GPOS.Add(gposData);

                    followup.GPOS = GPOS;
                    OldFollowupsSorted.Add(followup);
                }

                foreach (var item in OldFollowupsSorted)
                {
                    TreatmentsSorted.Add(item);
                }
            }
            #endregion


            #region get practice details

            P_L5PR_GPDfPID_1501 param = new P_L5PR_GPDfPID_1501();
            param.PracticeID = listOfPractices.ToArray();

            var practicesRawData = cls_Get_PracticeDetails_for_PracticeID.Invoke(Connection, Transaction, param, securityTicket).Result.ToList();


            List <WordReportData> WordDataByPractice = new List <WordReportData>();

            foreach (var practice in practicesRawData)
            {
                WordReportData wordData = new WordReportData();
                wordData.PracticeID                = practice.HEC_MedicalPractiseID;
                wordData.PracticeName              = practice.PracticeName;
                wordData.PracticeAddress           = practice.Street_Name + " " + practice.Street_Number;
                wordData.PracticePostalCodeAndCity = practice.ZIP + " " + practice.Town;
                wordData.SelectedMonth             = Parameter.SelectedMounth_String;
                wordData.Treatments                = TreatmentsSorted.Where(i => i.PracticeID == wordData.PracticeID).OrderBy(j => j.Date).ToList();

                WordDataByPractice.Add(wordData);
            }
            #endregion

            //Make word documents by practice and attach the documents to email
            List <Attachment> atts = new List <Attachment>();
            foreach (var practice in WordDataByPractice)
            {
                var parameters = new Dictionary <String, Object>();
                parameters.Add("WordReportData", practice);
                parameters.Add("LanguageCode", Parameter.LanguageCode);
                parameters.Add("ReportType", "RTF");

                string reportName = practice.PracticeName.Replace('/', '-');

                var report = new LucentisReports.DoctorsBillingReport();
                report.SetContext(parameters);
                MemoryStream ms1 = new MemoryStream();

                ms1 = report.ExportToMemoryStream();

                ms1.Seek(0, System.IO.SeekOrigin.Begin);

                Attachment att = new Attachment(ms1, "Doctors_Billing_" + reportName + "_" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm") + ".rtf", "application/doc");
                atts.Add(att);
            }

            string[] toMails;
            string   mailRes = (String)HttpContext.GetGlobalResourceObject("Global", "ReportMails");
#if DEBUG
            mailRes = (String)HttpContext.GetGlobalResourceObject("Global", "ReportMailsDebug");
#endif
            toMails = mailRes.Split(';');
            string subjectRes = (String)HttpContext.GetGlobalResourceObject("Global", "ReportMailSubject1");
            EmailUtils.SendMail(toMails, subjectRes, "", atts);
            return(returnValue);

            #endregion UserCode
        }
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    bool isEmail = Regex.IsMatch(model.Email, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase);
                    if (isEmail)
                    {
                        using (var db = new DBContext())
                        {
                            var cp = db.Customers.Where(a => a.Email.Trim() == model.Email.Trim()).FirstOrDefault();
                            if (cp != null)
                            {
                                ModelState.AddModelError("", "Email Address already exists..");
                            }
                            else
                            {
                                WebSecurity.CreateUserAndAccount(model.Email, model.Password);
                                Roles.AddUserToRoles(model.Email, new[] { "Customer" });
                                int currentUserId = WebSecurity.GetUserId(model.Email);
                                //WebSecurity.Login(model.Email, model.Password);

                                Customer customer = new Customer();
                                customer.MembershipId     = currentUserId;
                                customer.Email            = model.Email.Trim();
                                customer.FirstName        = string.Empty;
                                customer.LastName         = string.Empty;
                                customer.OrganizationName = string.Empty;
                                customer.CreateDate       = DateTime.Now;
                                db.Customers.Add(customer);
                                db.SaveChanges();

                                string strFreeUsers = appKeyReader.ReadKey("FreeUsers");
                                string strPaidUsers = appKeyReader.ReadKey("PaidUsers");

                                Subscriber subscriber = new Subscriber();
                                subscriber.CustomerId  = customer.CustomerId;
                                subscriber.FreeUsers   = string.IsNullOrEmpty(strFreeUsers) == true ? 0 : Convert.ToInt32(strFreeUsers);
                                subscriber.PaidUsers   = string.IsNullOrEmpty(strPaidUsers) == true ? 0 : Convert.ToInt32(strPaidUsers);
                                subscriber.IsActive    = true;
                                subscriber.CreatedDate = DateTime.Now;
                                subscriber.CreatedBy   = currentUserId;
                                db.Subscribers.Add(subscriber);
                                db.SaveChanges();

                                try
                                {
                                    //Successfully Register Mail Send to the User
                                    string toemail     = Convert.ToString(model.Email);
                                    string subject     = "Your free LiveMonitoring.com account has been created!";
                                    string messageBody = string.Empty;
                                    using (StreamReader reader = new StreamReader(Server.MapPath("~/App_Data/EmailTemplates/CustomerRegistration.html")))
                                    {
                                        messageBody = reader.ReadToEnd();
                                    }
                                    messageBody = messageBody.Replace("##Login##", model.Email);
                                    messageBody = messageBody.Replace("##Password##", model.Password);
                                    EmailUtils eu = new EmailUtils(toemail, subject, messageBody);
                                    if (eu.SendMail())
                                    {
                                    }

                                    WebSecurity.Login(model.Email, model.Password, false);

                                    return(RedirectToAction("Index", "Home"));
                                }
                                catch (Exception ex)
                                {
                                    ModelState.AddModelError("", "Error occured while sending email." + ex.Message);
                                }
                            }
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", "Invalid Email Address");
                    }
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
        public ActionResult ForgotPassword(ForgotPasswordModel model)
        {
            if (ModelState.IsValid)
            {
                MembershipUser user;
                using (var context = new DBContext())
                {
                    var foundUserName = (from u in context.tbl_UserProfile
                                         where u.UserName == model.Email
                                         select u.UserName).FirstOrDefault();
                    if (foundUserName != null)
                    {
                        user = Membership.GetUser(foundUserName.ToString());
                    }
                    else
                    {
                        user = null;
                    }
                }

                if (user != null)
                {
                    // Generae password token that will be used in the email link to authenticate user
                    var token = WebSecurity.GeneratePasswordResetToken(user.UserName);
                    // Generate the html link sent via email
                    string resetLink = "<a href='"
                                       + Url.Action("RecoverPassword", "Account", new { rt = token }, "http")
                                       + "'>Reset Password Link</a>";

                    try
                    {
                        //Forgot Password Mail Send to the User
                        string toemail     = Convert.ToString(model.Email);
                        string subject     = "Account Recovery - LiveMonitoring.com";
                        string messageBody = string.Empty;
                        using (StreamReader reader = new StreamReader(Server.MapPath("~/App_Data/EmailTemplates/ForgotPassword.html")))
                        {
                            messageBody = reader.ReadToEnd();
                        }
                        messageBody = messageBody.Replace("##user##", model.Email);
                        messageBody = messageBody.Replace("##resetLink##", resetLink);
                        EmailUtils eu = new EmailUtils(toemail, subject, messageBody);
                        if (eu.SendMail())
                        {
                        }

                        ModelState.AddModelError("", "Account recovery email sent. Check your inbox.");
                    }
                    catch (Exception ex)
                    {
                        ModelState.AddModelError("", "Error occured while sending email." + ex.Message);
                    }
                }
                else // Email not found
                {
                    /* Note: You may not want to provide the following information
                     * since it gives an intruder information as to whether a
                     * certain email address is registered with this website or not.
                     * If you're really concerned about privacy, you may want to
                     * forward to the same "Success" page regardless whether an
                     * user was found or not. This is only for illustration purposes.
                     */
                    ModelState.AddModelError("", "Email address not found.");
                }
            }

            /* You may want to send the user to a "Success" page upon the successful
             * sending of the reset email link. Right now, if we are 100% successful
             * nothing happens on the page. :P */
            return(View(model));
        }
Exemple #8
0
        protected static FR_Base Execute(DbConnection Connection, DbTransaction Transaction, P_L6TR_MRDfTre_1300 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode

            FR_Base returnValue = new FR_Base();
            returnValue.Status = FR_Status.Error_Internal;

            List <Converter> listOfConvertesForEdifactFiles = new List <Converter>();

            string excelFileName = string.Empty;
            Guid   headerID      = Guid.Empty;

            List <ExcelOutput> allExcelData = new List <ExcelOutput>();

            L6TR_GTBDpHICfID_1130 collectedData = null;
            if (Parameter.IsTreatment)
            {
                collectedData = cls_Get_TreatmentBillingData_per_HICompany_byIDs.Invoke(Connection, Transaction, new P_L6TR_GTBDpHICfID_1130()
                {
                    TreatmentID_List = Parameter.TreatmentID_List
                }, securityTicket).Result;
            }
            else
            {
                collectedData = cls_Get_FollowupBillingData_per_HICompany_byIDs.Invoke(Connection, Transaction, new P_L6TR_GFBDpHICfID_1412()
                {
                    TreatmentID_List = Parameter.TreatmentID_List
                }, securityTicket).Result.Data;
            }

            #region HeaderNum
            var tenantHeaders = ORM_BIL_BillHeader.Query.Search(Connection, Transaction, new ORM_BIL_BillHeader.Query()
            {
                Tenant_RefID = securityTicket.TenantID,
                IsDeleted    = false
            }).ToArray();
            tenantHeaders = tenantHeaders.OrderBy(t => t.Creation_Timestamp).ToArray();
            //var headersForThisYear = tenantHeaders.Where(h => h.Creation_Timestamp.Year == DateTime.Now.Year).ToArray(); // This was when we needed to restart the numbers at the end of each year
            var headersForThisYear = tenantHeaders;

            int  prevMaxHeaderNumber      = 0;
            long previousMaxPositionIndex = 0;
            if (headersForThisYear.Length > 0)
            {
                ORM_BIL_BillHeader prevHeader = null;
                foreach (var headerTY in headersForThisYear)
                {
                    int hn = 0;
                    if (int.TryParse(headerTY.BillNumber, out hn) && prevMaxHeaderNumber <= hn)
                    {
                        prevMaxHeaderNumber = hn;
                        prevHeader          = headerTY;
                    }
                }


                if (prevHeader != null)
                {
                    var positionQuery = new ORM_BIL_BillPosition.Query();
                    positionQuery.Tenant_RefID        = securityTicket.TenantID;
                    positionQuery.BIL_BilHeader_RefID = prevHeader.BIL_BillHeaderID;
                    var prevPositions = ORM_BIL_BillPosition.Query.Search(Connection, Transaction, positionQuery).ToArray();
                    if (prevPositions != null && prevPositions.Length > 0)
                    {
                        foreach (var prevPosition in prevPositions)
                        {
                            long number = 0;
                            if (long.TryParse(prevPosition.External_PositionReferenceField, out number) && previousMaxPositionIndex < number)
                            {
                                previousMaxPositionIndex = number;
                            }
                        }
                    }
                }
            }
            var edifactRes = ORM_BIL_BillHeaderExtension_EDIFACT.Query.Search(Connection, Transaction, new ORM_BIL_BillHeaderExtension_EDIFACT.Query()
            {
                Tenant_RefID = securityTicket.TenantID
            });
            #endregion

            int  currentEdifatNumber      = edifactRes.Where(e => e.Creation_Timestamp.Year == DateTime.Now.Year).Count() + 1;
            int  currentHeaderNumber      = prevMaxHeaderNumber + 1;
            long currentMaxPositionNumber = previousMaxPositionIndex;

            if (Parameter.IsBilling)
            {
                ORM_BIL_BillHeader header = new ORM_BIL_BillHeader();
                header.Tenant_RefID     = securityTicket.TenantID;
                header.BIL_BillHeaderID = Guid.NewGuid();
                header.BillNumber       = currentHeaderNumber.ToString();
                header.Save(Connection, Transaction);
                headerID = header.BIL_BillHeaderID;
            }

            foreach (var dataPerCompany in collectedData.HICompanies)
            {
                List <BillingInfo> listBInfo = new List <BillingInfo>();
                foreach (var pos in dataPerCompany.Positions)
                {
                    List <ArticleInfo>   articleList   = new List <ArticleInfo>();
                    List <DiagnosisInfo> diagnosisList = new List <DiagnosisInfo>();

                    foreach (var art in pos.ArticleInfos)
                    {
                        articleList.Add(new ArticleInfo(art.ArticleID.ToString(), art.Name.GetContent(Parameter.LanguageID), art.PZN, Convert.ToInt32(art.Quantity)));
                    }

                    foreach (var diag in pos.DiagnosisInfos)
                    {
                        diagnosisList.Add(new DiagnosisInfo(diag.strDiagnosisICD10, diag.cDiagnosisState.ToCharArray()[0]));
                    }

                    listBInfo.Add(new BillingInfo(
                                      !pos.bTreatmentIsFollowup ? pos.TreatmentID.ToString() : pos.FollowupID.ToString(),
                                      pos.iPatientInsuranceState,
                                      pos.PatientInsuranceNumber,
                                      pos.iPatientSex,
                                      pos.PatientFirstName,
                                      pos.PatientLastName,
                                      pos.dtPatientBirthDate,
                                      pos.strDoctorLANR,
                                      pos.strPracticeBSNR,
                                      diagnosisList,
                                      pos.cTreatmentLocalization.ToCharArray()[0],
                                      pos.bTreatmentIsFollowup,
                                      pos.iTreatmentNumber,
                                      articleList,
                                      pos.dtTreatment,
                                      pos.strFollowupPractice,
                                      pos.strFollowupDoctor,
                                      pos.strFollowupStatus,
                                      pos.dtFollowup));
                }

                Converter converter = new Converter(currentEdifatNumber, currentHeaderNumber, currentMaxPositionNumber,
                                                    dataPerCompany.Positions.OrderBy(p => p.dtTreatment).First().dtTreatment, dataPerCompany.Positions.OrderBy(p => p.dtTreatment).Last().dtTreatment,
                                                    listBInfo, dataPerCompany.HealthInsurance_Number, false);

                listOfConvertesForEdifactFiles.Add(converter);
                var excelData = converter.getExcel();

                if (excelFileName == string.Empty)
                {
                    excelFileName = converter.getExcelFilename();
                }

                allExcelData.AddRange(excelData);

                #region  Save GPOS, charged value, Additional position compensation, Relevant article and article quantity (if is billing)
                if (Parameter.IsBilling)
                {
                    var persistParam = new P_L6TR_PBD_1706()
                    {
                        EdifactNumber = currentEdifatNumber,
                        HeaderID      = headerID,
                        OutputData    = excelData.ToArray()
                    };
                    cls_Persist_TreatmentsBillData.Invoke(Connection, Transaction, persistParam, securityTicket);
                }
                #endregion

                currentEdifatNumber++;
                currentMaxPositionNumber = excelData.Max(e => e.iProcessNumber);
            }

            List <String>       LANR = allExcelData.Select(x => x.strDoctorLANR).ToList();
            P_L5DO_GDDfLfR_1409 parameterDoctorData = new P_L5DO_GDDfLfR_1409();
            parameterDoctorData.LANR = LANR.ToArray();
            List <L5DO_GDDfLfR_1409> doctorData = cls_Get_DoctorData_for_LANR_for_Reports.Invoke(Connection, Transaction, parameterDoctorData, securityTicket).Result.ToList();

            List <Attachment> atts = new List <Attachment>();
            string            file = ReportUtils.generateBillTreatmentsXLS(allExcelData, doctorData);

            MemoryStream ms = new MemoryStream(File.ReadAllBytes(file));
            atts.Add(new System.Net.Mail.Attachment(ms, excelFileName));

            foreach (var converter in listOfConvertesForEdifactFiles)
            {
                var edifact = converter.getEdifact();

                var tempFilePath = Path.GetTempFileName();
                using (System.IO.StreamWriter tempFile = new System.IO.StreamWriter(tempFilePath, true))
                {
                    tempFile.Write(converter.getAuf(1));
                }
                long tempFileSize = 0;
                if (File.Exists(tempFilePath))
                {
                    FileInfo fi = new FileInfo(tempFilePath);
                    tempFileSize = fi.Length;
                    fi.Delete();
                }
                atts.Add(Attachment.CreateAttachmentFromString(edifact, converter.getEdifactFilename()));
                atts.Add(Attachment.CreateAttachmentFromString(converter.getAuf(tempFileSize), converter.getAufFilename()));
            }

            string[] toMails;
            string   mailRes = (String)HttpContext.GetGlobalResourceObject("Global", "ReportMails");
#if DEBUG
            mailRes = (String)HttpContext.GetGlobalResourceObject("Global", "ReportMailsDebug");
#endif
            toMails = mailRes.Split(';');
            string subjectRes = (String)HttpContext.GetGlobalResourceObject("Global", "ReportMailSubject");

            EmailUtils.SendMail(toMails, subjectRes, "", atts);



            // @Laci, ako budes se prebacivao na thread odkomentarisi ovaj kod ispod

            //Thread emailThread = new Thread(() =>
            //{
            //    IEmail acceptEmail = EmailFactory.BasicEmail();
            //    acceptEmail.sendMailNotifier(toMails.ToList(), subjectRes, "", atts);
            //});
            //emailThread.Start();

            returnValue.Status = FR_Status.Success;

            return(returnValue);

            #endregion UserCode
        }