Пример #1
0
        private void OnDisplaySMSLogList()
        {
            Result result = SMSLogBus.GetSMSLogList(_fromDate, _toDate, _type);

            if (result.IsOK)
            {
                MethodInvoker method = delegate
                {
                    ClearData();
                    DataTable dt = result.QueryResult as DataTable;
                    dgTracking.DataSource = result.QueryResult;
                    lbKetQuaTimDuoc.Text  = string.Format("Kết quả tìm được: {0}", dt.Rows.Count);
                };

                if (InvokeRequired)
                {
                    BeginInvoke(method);
                }
                else
                {
                    method.Invoke();
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("SMSLogBus.GetSMSLogList"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("SMSLogBus.GetSMSLogList"));
            }
        }
Пример #2
0
        private void OnSendSMS()
        {
            string strMobile = txtSoDienThoai.Text.Trim().Replace(";", ",");

            string[] mobileList = strMobile.Split(",".ToCharArray());

            string tinNhanMau = this.TinNhanMau;

            tinNhanMau = Utility.ConvertToUnSign3(tinNhanMau);
            tinNhanMau = tinNhanMau.Replace("#", "");
            tinNhanMau = tinNhanMau.Replace("\n", "\r\n");
            foreach (string mobile in mobileList)
            {
                if (mobile.Trim() == string.Empty)
                {
                    continue;
                }
                Stream       resStream = null;
                StreamReader sr        = null;
                try
                {
                    string url = string.Format("http://sms.vietguys.biz/api/?u=vigor&pwd=ahhsw&from=VigorHEALTH&phone={0}&sms={1}",
                                               mobile, tinNhanMau);

                    HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(url);
                    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                    resStream = response.GetResponseStream();
                    sr        = new StreamReader(resStream);
                    string responseFromServer = sr.ReadToEnd();
                    responseFromServer = responseFromServer.Replace("\t", "");

                    int    result = 0;
                    SMSLog smsLog = new SMSLog();
                    smsLog.Ngay         = DateTime.Now;
                    smsLog.NoiDung      = tinNhanMau;
                    smsLog.Mobile       = mobile;
                    smsLog.DocStaffGUID = Guid.Parse(Global.UserGUID);

                    if (int.TryParse(responseFromServer, out result))
                    {
                        switch (result)
                        {
                        case -1:
                            smsLog.Status = -1;
                            smsLog.Notes  = "Chưa nhập đầy đủ các tham số yêu cầu.";
                            break;

                        case -2:
                            smsLog.Status = -2;
                            smsLog.Notes  = "Không thể kết nối đến máy chủ VIETGUYS, máy chủ đang bận.";
                            break;

                        case -3:
                            smsLog.Status = -3;
                            smsLog.Notes  = "Thông tin xác nhận tài khoản chưa chính xác.";
                            break;

                        case -5:
                            smsLog.Status = -5;
                            smsLog.Notes  = "Thông tin xác nhận tài khoản chưa chính xác.";
                            break;

                        case -4:
                            smsLog.Status = -4;
                            smsLog.Notes  = "Tài khoản bị khóa.";
                            break;

                        case -6:
                            smsLog.Status = -6;
                            smsLog.Notes  = "Tài khoản bị khóa.";
                            break;

                        case -7:
                            smsLog.Status = -7;
                            smsLog.Notes  = "IP bị giới hạn truy cập, không được phép gửi từ IP này.";
                            break;

                        case -8:
                            smsLog.Status = -8;
                            smsLog.Notes  = "Giá trị Gửi-từ-đâu chưa được phép sử dụng, vui lòng liên hệ với VIETGUYS để khai báo trước khi sử dụng.";
                            break;

                        case -9:
                            smsLog.Status = -9;
                            smsLog.Notes  = "Tài khoản hết credits gửi tin.";
                            break;

                        case -10:
                            smsLog.Status = -10;
                            smsLog.Notes  = "Số điện thoại người nhận chưa chính xác.";
                            break;

                        case -11:
                            smsLog.Status = -11;
                            smsLog.Notes  = "Số điện thoại nằm trong danh sách Blacklist, là danh sách không muốn nhận tin nhắn.";
                            break;

                        case -12:
                            smsLog.Status = -12;
                            smsLog.Notes  = "Tài khoản không đủ credits để thực hiện gửi tin nhắn.";
                            break;
                        }
                    }
                    else
                    {
                        smsLog.Status = 0;
                        smsLog.Notes  = responseFromServer;
                    }

                    Result rs = SMSLogBus.InsertSMSLog(smsLog);
                    if (!rs.IsOK)
                    {
                        MsgBox.Show(this.Text, rs.GetErrorAsString("SMSLogBus.InsertSMSLog"), IconType.Error);
                        Utility.WriteToTraceLog(rs.GetErrorAsString("SMSLogBus.InsertSMSLog"));
                        return;
                    }
                }
                catch (Exception e)
                {
                    MM.MsgBox.Show(Application.ProductName, e.Message, IconType.Error);
                    Utility.WriteToTraceLog(e.Message);
                }
                finally
                {
                    if (sr != null)
                    {
                        sr.Close();
                        sr = null;
                    }

                    if (resStream != null)
                    {
                        resStream.Close();
                        resStream = null;
                    }
                }
            }
        }
Пример #3
0
        private void OnSendSMS()
        {
            List <DataRow> checkedRows = _dictPatient.Values.ToList();

            if (checkedRows.Count > 0)
            {
                if (MsgBox.Question(Application.ProductName, "Bạn có muốn gửi SMS những bệnh nhân mà bạn đã đánh dấu ?") == DialogResult.Yes)
                {
                    dlgSelectTinNhanMau dlg = new dlgSelectTinNhanMau();
                    if (dlg.ShowDialog(this) == DialogResult.OK)
                    {
                        Cursor.Current = Cursors.WaitCursor;
                        string tinNhanMau = dlg.TinNhanMau;
                        foreach (DataRow row in checkedRows)
                        {
                            string maBenhNhan  = row["FileNum"].ToString();
                            string tenBenhNhan = row["FullName"].ToString();
                            string ngaySinh    = row["DobStr"].ToString();
                            string gioiTinh    = row["GenderAsStr"].ToString();
                            string diaChi      = row["Address"].ToString();
                            string cmnd        = row["IdentityCard"].ToString();
                            string mobile      = row["Mobile"].ToString();
                            string email       = row["Email"].ToString();

                            string noiDung = tinNhanMau.Replace("#MaBenhNhan#", maBenhNhan);
                            noiDung = noiDung.Replace("#TenBenhNhan#", tenBenhNhan);
                            noiDung = noiDung.Replace("#NgaySinh#", ngaySinh);
                            noiDung = noiDung.Replace("#GioiTinh#", gioiTinh);
                            noiDung = noiDung.Replace("#DiaChi#", diaChi);
                            noiDung = noiDung.Replace("#CMND#", cmnd);
                            noiDung = noiDung.Replace("#Mobile#", mobile);
                            noiDung = noiDung.Replace("#Email#", email);
                            noiDung = Utility.ConvertToUnSign3(noiDung);
                            noiDung = noiDung.Replace("#", "");
                            noiDung = noiDung.Replace("\n", "\r\n");

                            Stream       resStream = null;
                            StreamReader sr        = null;
                            try
                            {
                                string url = string.Format("http://sms.vietguys.biz/api/?u=vigor&pwd=ahhsw&from=VigorHEALTH&phone={0}&sms={1}",
                                                           mobile, noiDung);

                                HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(url);
                                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                                resStream = response.GetResponseStream();
                                sr        = new StreamReader(resStream);
                                string responseFromServer = sr.ReadToEnd();
                                responseFromServer = responseFromServer.Replace("\t", "");

                                int    result = 0;
                                SMSLog smsLog = new SMSLog();
                                smsLog.Ngay         = DateTime.Now;
                                smsLog.NoiDung      = noiDung;
                                smsLog.Mobile       = mobile;
                                smsLog.PatientGUID  = Guid.Parse(row["PatientGUID"].ToString());
                                smsLog.DocStaffGUID = Guid.Parse(Global.UserGUID);

                                if (int.TryParse(responseFromServer, out result))
                                {
                                    switch (result)
                                    {
                                    case -1:
                                        smsLog.Status = -1;
                                        smsLog.Notes  = "Chưa nhập đầy đủ các tham số yêu cầu.";
                                        break;

                                    case -2:
                                        smsLog.Status = -2;
                                        smsLog.Notes  = "Không thể kết nối đến máy chủ VIETGUYS, máy chủ đang bận.";
                                        break;

                                    case -3:
                                        smsLog.Status = -3;
                                        smsLog.Notes  = "Thông tin xác nhận tài khoản chưa chính xác.";
                                        break;

                                    case -5:
                                        smsLog.Status = -5;
                                        smsLog.Notes  = "Thông tin xác nhận tài khoản chưa chính xác.";
                                        break;

                                    case -4:
                                        smsLog.Status = -4;
                                        smsLog.Notes  = "Tài khoản bị khóa.";
                                        break;

                                    case -6:
                                        smsLog.Status = -6;
                                        smsLog.Notes  = "Tài khoản bị khóa.";
                                        break;

                                    case -7:
                                        smsLog.Status = -7;
                                        smsLog.Notes  = "IP bị giới hạn truy cập, không được phép gửi từ IP này.";
                                        break;

                                    case -8:
                                        smsLog.Status = -8;
                                        smsLog.Notes  = "Giá trị Gửi-từ-đâu chưa được phép sử dụng, vui lòng liên hệ với VIETGUYS để khai báo trước khi sử dụng.";
                                        break;

                                    case -9:
                                        smsLog.Status = -9;
                                        smsLog.Notes  = "Tài khoản hết credits gửi tin.";
                                        break;

                                    case -10:
                                        smsLog.Status = -10;
                                        smsLog.Notes  = "Số điện thoại người nhận chưa chính xác.";
                                        break;

                                    case -11:
                                        smsLog.Status = -11;
                                        smsLog.Notes  = "Số điện thoại nằm trong danh sách Blacklist, là danh sách không muốn nhận tin nhắn.";
                                        break;

                                    case -12:
                                        smsLog.Status = -12;
                                        smsLog.Notes  = "Tài khoản không đủ credits để thực hiện gửi tin nhắn.";
                                        break;
                                    }
                                }
                                else
                                {
                                    smsLog.Status = 0;
                                    smsLog.Notes  = responseFromServer;
                                }

                                Result rs = SMSLogBus.InsertSMSLog(smsLog);
                                if (!rs.IsOK)
                                {
                                    MsgBox.Show(this.Text, rs.GetErrorAsString("SMSLogBus.InsertSMSLog"), IconType.Error);
                                    Utility.WriteToTraceLog(rs.GetErrorAsString("SMSLogBus.InsertSMSLog"));
                                    return;
                                }
                            }
                            catch (Exception e)
                            {
                                MM.MsgBox.Show(Application.ProductName, e.Message, IconType.Error);
                                Utility.WriteToTraceLog(e.Message);
                            }
                            finally
                            {
                                if (sr != null)
                                {
                                    sr.Close();
                                    sr = null;
                                }

                                if (resStream != null)
                                {
                                    resStream.Close();
                                    resStream = null;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những bệnh nhân cần gửi SMS.", IconType.Information);
            }
        }