Ejemplo n.º 1
0
        /*
         * private void UpdateMsSQL(SqlConnection con2, int DirCustomersID)
         * {
         *  using (SqlCommand cmd = new SqlCommand("INSERT INTO DirCustomersHistory (DirCustomersHistoryTypeID, DirCustomersID)values(1, @DirCustomersID)", con2))
         *  {
         *      SQLiteParameter parDirCustomersID = new SQLiteParameter("@DirCustomersID", System.Data.SqlDbType.Int); cmd.Parameters.Add(parDirCustomersID).Value = DirCustomersID;
         *      cmd.ExecuteNonQuery();
         *  }
         * }
         */

        private void SendMail(string pEMail)
        {
            //Class.Functions.FunMailSend funMailSend = new Class.Functions.FunMailSend();
            Classes.Function.FunctionMSSQL.FunMailSend funMailSend = new Classes.Function.FunctionMSSQL.FunMailSend();
            funMailSend.SendTo_OtherEMail("Напоминание паролей в 'ВТорговомОблаке'. Складской учет и торговля онлайн.", TextMail(pEMail), pEMail);

            try { funMailSend.SendTo_ESklad24("Напоминание паролей.", "Для EMail: " + pEMail); }
            catch { }
        }
Ejemplo n.º 2
0
        private void SendMail()
        {
            //Class.Functions.FunMailSend funMailSend = new Class.Functions.FunMailSend();
            Classes.Function.FunctionMSSQL.FunMailSend funMailSend = new Classes.Function.FunctionMSSQL.FunMailSend();

            funMailSend.SendTo_OtherEMail("Подтверждение регистрации в Web-сервисе 'ВТорговомОблаке'. Складской учет онлайн.", TextMail(), pEMail);

            try { funMailSend.SendTo_ESklad24("Подтверждение регистрации.", "Login: "******"<br />Клиент получил следующий текст:<hr />" + TextMail()); }
            catch { }
        }
Ejemplo n.º 3
0
        private bool mRegistration(Models.Login.Dir.DirCustomerReg dirCustomerReg, int iLanguage)
        {
            //Для записи в БД, т.к. использовать "dirCustomerReg" нельзя!
            Models.Login.Dir.DirCustomer dirCustomer = new Models.Login.Dir.DirCustomer();

            if (dirCustomerReg != null && ModelState.IsValid)
            {
                try
                {
                    using (DbConnectionLogin con = new DbConnectionLogin("ConnStrMSSQL"))
                    {
                        #region Проверка
                        // на существования такого логина
                        int iCount =
                            (
                                (
                                    from dirCustomers in con.DirCustomers
                                    where dirCustomers.Login == dirCustomerReg.Login
                                    select dirCustomers.Login
                                ).Concat
                                (
                                    from dirLoginNot in con.DirLoginNot
                                    where dirLoginNot.Login == dirCustomerReg.Login
                                    select dirLoginNot.Login
                                )
                            ).Count();

                        if (iCount > 0)
                        {
                            con.Database.Connection.Close(); ViewData["Msg"] = Classes.Language.Login.Language.msg1(iLanguage); return(false);
                        }

                        // на существования такого реферала
                        if (dirCustomerReg.Refer != 0)
                        {
                            int iCountRefer =
                                (
                                    from DirCustomers in con.DirCustomers
                                    where dirCustomerReg.DirCustomersID == dirCustomerReg.Refer
                                    select dirCustomerReg.Login
                                ).Count();
                            if (iCountRefer == 0)
                            {
                                dirCustomerReg.Refer = 0;
                            }
                        }
                        #endregion

                        #region Сохраняем
                        //Формирование пароля
                        Classes.Function.FunctionMSSQL.RandomSymbol randomSymbol = new Classes.Function.FunctionMSSQL.RandomSymbol();
                        dirCustomerReg.Pswd = randomSymbol.ReturnRandom(10);

                        //Переносим данные в "нужную" модель: dirCustomerReg => dirCustomer
                        dirCustomer.DirCustomersDate = DateTime.Now;
                        dirCustomer.Email            = dirCustomerReg.Email;
                        dirCustomer.Login            = dirCustomerReg.Login;
                        dirCustomer.DomainName       = dirCustomerReg.Login;
                        dirCustomer.Pswd             = dirCustomerReg.Pswd;
                        dirCustomer.Telefon          = dirCustomerReg.Telefon;
                        dirCustomer.FIO           = dirCustomerReg.FIO;
                        dirCustomer.DirLanguageID = dirCustomerReg.DirLanguageID;
                        dirCustomer.DirCountryID  = dirCustomerReg.DirCountryID;
                        dirCustomer.Refer         = dirCustomerReg.Refer;
                        dirCustomer.SendMail      = false;
                        dirCustomer.Active        = false;
                        dirCustomer.Pay           = true;
                        dirCustomer.Confirmed     = false;

                        con.Entry(dirCustomer).State = EntityState.Added;
                        try
                        {
                            con.SaveChanges();
                        }
                        catch (System.Data.Entity.Validation.DbEntityValidationException ex)
                        {
                            System.Text.StringBuilder sb = new System.Text.StringBuilder();

                            foreach (var failure in ex.EntityValidationErrors)
                            {
                                //sb.AppendFormat("{0} failed validation\n", failure.Entry.Entity.GetType());
                                foreach (var error in failure.ValidationErrors)
                                {
                                    sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage);
                                    sb.AppendLine();
                                }
                            }

                            throw new System.Data.Entity.Validation.DbEntityValidationException(
                                      //"Entity Validation Failed - errors follow:\n" +
                                      sb.ToString(), ex
                                      ); // Add the original exception as the innerException
                        }

                        /*catch (Exception ex)
                         * {
                         *  throw new System.InvalidOperationException(ex.Message);
                         * }*/

                        #endregion
                    }

                    #region Отправка письма на E-Mail
                    try
                    {
                        //Текс на русском
                        string sSendTest = Classes.Language.Login.Language.txtRegistrationMail(dirCustomer, iLanguage);
                        Classes.Function.FunctionMSSQL.FunMailSend funMailSend = new Classes.Function.FunctionMSSQL.FunMailSend();
                        //Отправка клиенту
                        funMailSend.SendTo_OtherEMail(Classes.Language.Login.Language.msg2(iLanguage), sSendTest, dirCustomer.Email);
                        //Отправка себе
                        try { funMailSend.SendTo_ESklad24(Classes.Language.Login.Language.msg2(iLanguage), "E-Mail: " + dirCustomer.Email + ", Login: "******"<br />" + Classes.Language.Login.Language.msg2(iLanguage) + "<hr />" + sSendTest); } catch { }
                    }
                    catch (Exception ex)
                    {
                        ViewData["Msg"]   = Classes.Language.Login.Language.msg4(iLanguage) + ex.Message + "";
                        ViewData["Title"] = Classes.Language.Login.Language.msg5(iLanguage);
                        return(true);
                    }
                    #endregion

                    using (DbConnectionLogin con = new DbConnectionLogin("ConnStrMSSQL"))
                    {
                        #region Пишем в БД, что Мейл отправлен (SendMail=true)
                        dirCustomer.SendMail         = true;
                        con.Entry(dirCustomer).State = EntityState.Modified;
                        con.SaveChanges();
                        #endregion
                    }
                }
                catch (Exception ex)
                {
                    string sMsg = exceptionEntry.Return(ex);
                    ViewData["Msg"] = Classes.Language.Login.Language.error(iLanguage) + ": <br />" + sMsg + "<br /> " + Classes.Language.Login.Language.msg6(iLanguage) + ": <a href='mailto:[email protected]' rel='nofollow'>[email protected]</a>"; return(false);
                }


                ViewData["Title"] = Classes.Language.Login.Language.msg5(iLanguage);
                ViewData["Msg"]   = Classes.Language.Login.Language.msg7(iLanguage);
                return(true);
            }
            else
            {
                return(false);
            }
        }