public async Task <SMSClass> sendSMSUsingAPIAsync (DateTime smsDate, int notifyCategory, int notifyType, string phoneNo, string smsSubject, string smsBody, int counter) { DateTime myTimeNow = DateTime.Now; int epoch = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds; SMSClass smsObj = new SMSClass { datID = phoneNo + "-sms" + counter + "-" + epoch.ToString(), datType = notifyCategory, datNotify = notifyType, dtInsert = myTimeNow.ToString("yyyy-MM-ddTHH:mm:ssZ"), dtSchedule = smsDate.AddMinutes(1).ToString("yyyy-MM-ddTHH:mm:ssZ"), dtExpired = smsDate.AddYears(1).ToString("yyyy-MM-ddTHH:mm:ssZ"), smsTo = phoneNo, subject = smsSubject, body = smsBody }; var response = await WepApiMethod.SendApiAsync <SMSClass> (HttpVerbs.Post, $"BulkSMS", smsObj, WepApiMethod.APIEngine.EmailSMSAPI); if (response.isSuccess) { return(response.Data); } else { return(null); } }
public ObservableCollection <ProductClass> GetProducts(int InvestigationID) { ObservableCollection <ProductClass> ReturnList = new ObservableCollection <ProductClass>(); string connectionString = ConfigurationManager.ConnectionStrings["LEABrowser.Properties.Settings.LEADBConnectionString"].ConnectionString; using (SqlConnection con = new SqlConnection((connectionString))) { con.Open(); SqlCommand cmd = new SqlCommand(); try { if (InvestigationID == 0) { cmd = new SqlCommand("SELECT ID, Type, CreationDate, Source, Destination, InvestigationID, Text, Path, CallLengthInMS FROM ProductTable tblProduct FULL JOIN SMSMessageTable tblSMS ON tblProduct.ID = tblSMS.ProductID FULL JOIN VoiceCallTable tblCall ON tblProduct.ID = tblCall.ProductID ORDER BY CreationDate", con); } else { cmd = new SqlCommand("SELECT ID, Type, CreationDate, Source, Destination, InvestigationID, Text, Path, CallLengthInMS FROM ProductTable tblProduct FULL JOIN SMSMessageTable tblSMS ON tblProduct.ID = tblSMS.ProductID FULL JOIN VoiceCallTable tblCall ON tblProduct.ID = tblCall.ProductID WHERE InvestigationID = @InvestigationIDVal ORDER BY CreationDate", con); cmd.Parameters.AddWithValue("@InvestigationIDVal", InvestigationID); } using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { var itemToAdd = new ProductClass(); switch (int.Parse(reader["Type"].ToString())) { case ((int)ProductType.Call): itemToAdd = new CallClass(); itemToAdd.TypeIcon = new Bitmap(Properties.Resources.Call, new Size(20, 20)); (itemToAdd as CallClass).Path = reader["Path"].ToString(); (itemToAdd as CallClass).CallLengthInMS = long.Parse(reader["CallLengthInMS"].ToString()); itemToAdd.Type = ProductType.Call; break; case ((int)ProductType.SMS): itemToAdd = new SMSClass(); itemToAdd.TypeIcon = new Bitmap(Properties.Resources.SMS, new Size(20, 20)); (itemToAdd as SMSClass).Text = reader["Text"].ToString(); itemToAdd.Type = ProductType.SMS; break; } itemToAdd.ID = int.Parse(reader["ID"].ToString()); itemToAdd.CreationDate = DateTime.Parse(reader["CreationDate"].ToString()); itemToAdd.Source = reader["Source"].ToString(); itemToAdd.Destination = reader["Destination"].ToString(); itemToAdd.InvestigationID = int.Parse(reader["InvestigationID"].ToString()); ReturnList.Add(itemToAdd); } reader.Close(); } } catch (Exception ex) { MessageBox.Show("ERROR: " + ex.Message); } finally { if ((con != null) && (con.State == ConnectionState.Open)) { con.Close(); } if (cmd != null) { cmd.Dispose(); } } } return(ReturnList); }
private void btnLogin_Click(object sender, EventArgs e) { string LoginPhone = txt_phone.Text.Trim(); string LoginPass = txt_pk_1.Text + "-" + txt_pk_2.Text; using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConvenienceStore"].ConnectionString)) { using (var cmd = new SqlCommand("LoginPassCheck", con)) { con.Open(); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@employee_phone", LoginPhone); cmd.Parameters.AddWithValue("@employee_pk", LoginPass); string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; char[] charArray = chars.ToCharArray(); int numPasswd = 10; string newPasswd = string.Empty; int seed = Environment.TickCount; Random rd = new Random(seed); int tempNum = 0; for (int j = 0; j < numPasswd; j++) { tempNum = rd.Next(0, charArray.Length - 1); newPasswd += charArray[tempNum]; } cmd.Parameters.AddWithValue("@employee_pass", newPasswd); var sdr = cmd.ExecuteReader(); if (sdr.HasRows) { string phone = "01083237245"; SMSClass sms = new SMSClass(); string Message = "임시 비밀번호 입니다. 새 비밀번호로 바꿔주세요.\n" + newPasswd; sms.SetUser("banana52", "wjdxhd58"); sms.Add(phone, "01083237245", Message, "", "", "", 0); if (!sms.Connect()) { //Console.WriteLine("메세지 전송오류\n" + phone); MessageBox.Show("메세지 전송오류\n" + phone); } int resval = sms.Send(); if (resval == -1) { //Console.WriteLine("전송중 오류발생\n" + phone); MessageBox.Show("전송중 오류발생\n" + phone); } MessageBox.Show("전송이 완료되었습니다."); sms.Disconnect(); sdr.Close(); con.Close(); this.Hide(); MessageBox.Show(newPasswd); } else { MessageBox.Show("핸드폰 번호 또는 주민번호를 다시 확인해주세요."); return; } } } }