コード例 #1
0
ファイル: ManagerHome.aspx.cs プロジェクト: maziesmith/KOS
        protected void OutSms_Click(object sender, EventArgs e)
        {
            // отправка смс ЛоджикТелеком
            CookieContainer cookie     = new CookieContainer();
            TelAccess       soapclient = new TelAccess();

            soapclient.CookieContainer = cookie;

            // Init session
            InputLogon Param1 = new InputLogon();

            Param1.userName = "******";
            Param1.password = "******";
            ReturnValueBase rv1 = soapclient.logon(Param1);

            if (rv1.errorCode != 0)
            {
                throw new Exception(rv1.errorDescription);
            }
            // Send simple sms
            InputSendSimpleSms Param2 = new InputSendSimpleSms();

            Param2.sender                = "ClientInfo";
            Param2.phone                 = TextBox1.Text;
            Param2.text                  = TextBox2.Text;
            Param2.allowSince            = 0;
            Param2.allowSinceSpecified   = false;
            Param2.allowTill             = 0;
            Param2.allowTillSpecified    = false;
            Param2.usePhoneTimeSpecified = false;

            ReturnValueString rv2 = soapclient.sendSimpleSms(Param2);

            if (rv2.errorCode != 0)
            {
                throw new Exception(rv2.errorDescription);
            }
            else
            {
                Msg.Text = "СМС отправлено, id: " + rv2.strResult;
            }

            // Close session
            soapclient.logoff();
            // конец блока отправки смс ЛоджикТелеком
            TextBox1.Text = ""; TextBox2.Text = "";
        }
コード例 #2
0
ファイル: DiagrammTSG.aspx.cs プロジェクト: maziesmith/KOS
        protected void Save_Click(object sender, EventArgs e)
        {
            ListData ttx = addresses.Find(delegate(ListData i)
            {
                return(i.Title == Address.SelectedValue);
            });

            if (ttx == null)
            {
                return;
            }
            int ttxId = ttx.Id;

            if (Category.Text == " ")
            {
                Msg.Text = "Внимание! Вы забыли выбрать вид работ.";
                return;
            }

            using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                conn.Open();
                SqlCommand cmd  = new SqlCommand();
                DateTime   date = DateTime.Now;

                if (Uslugy.SelectedValue == "Эксплуатация лифтов")
                {
                    cmd = new SqlCommand("insert into Zayavky " +
                                         "(TtxId, LiftId, UserId, [Text], Category, [From], [Start]) " +
                                         "values (@ttxId, @liftId, (select UserId from Users where UserName=@user), @text, @c, @f, @s)", conn);
                    cmd.Parameters.AddWithValue("ttxId", ttxId);
                    cmd.Parameters.AddWithValue("liftId", Lift.SelectedValue);
                    cmd.Parameters.AddWithValue("user", User.Identity.Name);
                    cmd.Parameters.AddWithValue("text", Text.Text);
                    if (_role == "ODS_tsg")
                    {
                        cmd.Parameters.AddWithValue("c", Category.SelectedValue);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("c", "заявка");
                    }
                    if (_role == "ODS_tsg")
                    {
                        cmd.Parameters.AddWithValue("f", "ОДС");
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("f", "менеджер");
                    }
                    cmd.Parameters.AddWithValue("s", date);
                    cmd.ExecuteNonQuery();
                    cmd = new SqlCommand("select z.Id from Zayavky z " +
                                         "join Users u on z.UserId=u.UserId " +
                                         "where u.UserName=@user and z.LiftId=@liftId and [Start]=@s", conn);
                    cmd.Parameters.AddWithValue("liftId", Lift.SelectedValue);
                    cmd.Parameters.AddWithValue("user", User.Identity.Name);
                    cmd.Parameters.AddWithValue("s", date);
                    id = int.Parse(cmd.ExecuteScalar().ToString());
                }
                //Блок записи в базу событий
                //подготовка
                cmd = new SqlCommand("select ui.Family, ui.IO from UserInfo ui " +
                                     "join Users u on u.UserId=ui.UserId where u.UserName=@userName", conn);
                cmd.Parameters.AddWithValue("userName", User.Identity.Name);
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    fam = dr[0].ToString();
                }
                io = dr[1].ToString();
                dr.Close();
                cmd = new SqlCommand("select LiftId, IdU, IdM from Lifts " +
                                     "where LiftId=@lift", conn);
                cmd.Parameters.AddWithValue("lift", Lift.SelectedValue);
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    u = dr[1].ToString(); m = dr[2].ToString();
                }
                dr.Close();
                // запись события в базу
                string s = "";
                if (Uslugy.SelectedValue == "Эксплуатация лифтов" & Workers.SelectedValue != " ")
                {
                    s = "insert into Events (EventId, RegistrId, DataId, ZayavId, Sourse, Family, IO, TypeId, IdU, IdM, LiftId, ToApp, DateToApp, Address) " +
                        "values (@text, @reg, @s, @id, @f, @fam, @io, @c, @u, @m, @liftid, @toapp, @ta, @adr)";
                }
                else if (Uslugy.SelectedValue == "Эксплуатация лифтов" & Workers.SelectedValue == " ")
                {
                    s = "insert into Events (EventId, RegistrId, DataId, ZayavId, Sourse, Family, IO, TypeId, IdU, IdM, LiftId, ToApp, Address) " +
                        "values (@text, @reg, @s, @id, @f, @fam, @io, @c, @u, @m, @liftid, @toapp, @adr)";
                }
                else if (Uslugy.SelectedValue != "Эксплуатация лифтов" & (!string.IsNullOrEmpty(Text2.Text)))
                {
                    s = "insert into Events (EventId, RegistrId, DataId, Sourse, Family, IO, TypeId, IdU, IdM, LiftId, ToApp, DateToApp, Address) " +
                        "values (@text, @reg, @s, @f, @fam, @io, @c, @u, @m, @liftid, @toapp, @ta, @adr)";
                }
                else if (Uslugy.SelectedValue != "Эксплуатация лифтов" & (string.IsNullOrEmpty(Text2.Text)))
                {
                    s = "insert into Events (EventId, RegistrId, DataId, Sourse, Family, IO, TypeId, IdU, IdM, LiftId, ToApp, Address) " +
                        "values (@text, @reg, @s, @f, @fam, @io, @c, @u, @m, @liftid, @toapp, @adr)";
                }
                cmd = new SqlCommand(s, conn);
                cmd.Parameters.AddWithValue("text", Text.Text);
                cmd.Parameters.AddWithValue("s", date);
                if (Uslugy.SelectedValue == "Эксплуатация лифтов")
                {
                    cmd.Parameters.AddWithValue("toapp", Workers.SelectedValue);
                }
                else
                {
                    cmd.Parameters.AddWithValue("toapp", Text2.Text);
                }
                if (Text2.Text != " " || Workers.SelectedValue != " ")
                {
                    cmd.Parameters.AddWithValue("ta", date);
                }
                cmd.Parameters.AddWithValue("f", Text1.Text);
                cmd.Parameters.AddWithValue("id", id);
                cmd.Parameters.AddWithValue("fam", User.Identity.Name);
                cmd.Parameters.AddWithValue("reg", Uslugy.SelectedValue);
                cmd.Parameters.AddWithValue("io", FIO.SelectedValue);
                cmd.Parameters.AddWithValue("c", Category.SelectedValue);
                cmd.Parameters.AddWithValue("adr", Address.SelectedValue);
                cmd.Parameters.AddWithValue("u", u);
                cmd.Parameters.AddWithValue("m", m);
                if (Uslugy.SelectedValue == "Эксплуатация лифтов")
                {
                    cmd.Parameters.AddWithValue("liftId", Lift.SelectedValue);
                }
                else
                {
                    cmd.Parameters.AddWithValue("liftId", TextArea.Text);
                }
                cmd.ExecuteNonQuery();
                //  номер записанного события
                cmd = new SqlCommand("select e.Id from Events e" +
                                     " where e.ZayavId=@i", conn);
                cmd.Parameters.AddWithValue("i", id);
                SqlDataReader de = cmd.ExecuteReader();
                while (de.Read())
                {
                    _wz = de[0].ToString();
                }
                dr.Close();
                _nev = _wz;
                _id  = id.ToString();
                try
                {
                    //Сообщения на Email и почту
                    KOS.App_Code.Mail mail = new Mail(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
                    mail.SendMsg(Lift.SelectedValue, int.Parse(id.ToString()));
                }
                catch { Msg.Text = "Сбой почтовой службы! Регистрация услуг ТСЖ выполнена.  "; }
                // sms
                if (Category.SelectedValue == "застревание" || Category.SelectedValue == "останов")
                {
                    pr = "2345";
                    string wn  = "9269338001";
                    string str = User.Identity.Name;
                    if (str == "ODS_Emica")
                    {
                        wn = "9269338001";
                    }
                    else if (str == "ODS13" || Address.Text == "пр. Вернадского, 94 -1" || Address.Text == "пр. Вернадского, 94 -2" || Address.Text == "пр. Вернадского, 94 -3" || Address.Text == "пр. Вернадского, 94 -4" || Address.Text == "пр. Вернадского, 94 -5")
                    {
                        wn = "9268976775";
                    }
                    else if (str == "ODS14" || Address.Text == "пр. Вернадского, 92")
                    {
                        wn = "9253135718";
                    }
                    else if (str == "ODS21" || Address.Text == "ул. Никольская, д.12")
                    {
                        wn = "9264610904";
                    }
                    else if (str == "ODS22" || Address.Text == "ул. Никольская, д.10")
                    {
                        wn = "9296758809";
                    }
                    else if (str == "ODS25" || Address.Text == "Хилков пер. 1")
                    {
                        wn = "9264610904";
                    }
                    else if (str == "ODS41" || Address.Text == "ул. Ясная, д. 7" || Address.Text == "ул. Жасминовая, д. 7")
                    {
                        wn = "9267270995";
                    }
                    else if (str == "ODS42" || Address.Text == "ул. Ясная, д. 5" || Address.Text == "ул. Жасминовая, д. 5" || Address.Text == "ул. Ясная, д. 6" || Address.Text == "ул. Жасминовая, д. 6")
                    {
                        wn = "9629908871";
                    }
                    else if (str == "ODS_test")
                    {
                        wn = "9264062614";
                    }
                    string nomer   = wn;
                    string TextSms = Category.SelectedValue + "-адрес:" + Address.SelectedItem.Value + "-" + "лифт №:"
                                     + Lift.SelectedValue + ", отправьте " + pr + " " + _wz + " на 89037676333 о принятии";
                    // отправка смс SMS.ru-
                    string      myApiKey = "27B482E1-14AE-ACFB-C500-CCEC9C763C99"; // API ключ
                    SmsRu.SmsRu sms      = new SmsRu.SmsRu(myApiKey);              // Основная рассылка
                    var         response = sms.Send(nomer, TextSms);

                    // отправка смс ЛоджикТелеком
                    CookieContainer cookie     = new CookieContainer();
                    TelAccess       soapclient = new TelAccess();

                    soapclient.CookieContainer = cookie;

                    // Init session
                    InputLogon Param1 = new InputLogon();
                    Param1.userName = "******";
                    Param1.password = "******";
                    ReturnValueBase rv1 = soapclient.logon(Param1);

                    if (rv1.errorCode != 0)
                    {
                        throw new Exception(rv1.errorDescription);
                    }
                    // Send simple sms
                    InputSendSimpleSms Param2 = new InputSendSimpleSms();
                    Param2.sender                = "ClientInfo";
                    Param2.phone                 = "79269338001";
                    Param2.text                  = TextSms;
                    Param2.allowSince            = 0;
                    Param2.allowSinceSpecified   = false;
                    Param2.allowTill             = 0;
                    Param2.allowTillSpecified    = false;
                    Param2.usePhoneTimeSpecified = false;

                    ReturnValueString rv2 = soapclient.sendSimpleSms(Param2);
                    if (rv2.errorCode != 0)
                    {
                        throw new Exception(rv2.errorDescription);
                    }
                    else
                    {
                        Msg.Text = "СМС отправлено id: " + rv2.strResult;
                    }

                    // Close session
                    soapclient.logoff();
                    // конец блока отправки смс ЛоджикТелеком
                    //    Msg.Text = AsyncMethod.GetPost().ToString();
                    //    Task.Run(() => PostRequestAsync());
                    //    Msg.Text = GetPostSms().ToString();
                }
                Msg.Text = "Регистрация выполнена, отправлено сообщение на e-mail Менеджеру и СМС Дежурному механику. ";         // + Для связи с Дежурной службой нажмите кнопку сайтофона.

                Response.Redirect("~/Reg_tsg.aspx");
            }
        }