Notes
Notes - notes.io |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Data.OracleClient;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Data.SqlTypes;
using System.Data;
using System.Net;
using System.Configuration;
using System.IO;
using System.Xml;
using System.Text;
using System.Xml.Linq;
// using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Security;
using System.Web.Services;
using System.Data.OleDb;
using System.Net.Mail;
using System.Drawing;
using System.Text.RegularExpressions;
using Perspective.Shared;
using System.Net.NetworkInformation;
using System.Windows.Forms;
using Newtonsoft.Json;
using System.Web.SessionState;
using System.Web.Services;
using System.Diagnostics;
using System.Web.Services.Protocols;
using System.Xml.Serialization;
using System.ComponentModel;
using SysXml = System.Xml;
public partial class SMS : System.Web.UI.Page
{
public static string uname ="";
protected void Page_Load(object sender, EventArgs e)
{
string username = User.Identity.Name;
string[] un = username.Split('\');
uname = un[1].ToUpper();
loguser(uname);
}
[WebMethod]
public static string Send_smsTo(string networkID, List<string> sendTo, string body)
{
uname = networkID;
string log = "";
List<string> ok= new List<string>();
List<string> failed= new List<string>();
log += "sendTo:n" + String.Join(", ", sendTo.ToArray()) +"nBody:n"+body;
List<string> ports =new List<string> {"port1", "port2", "port3", "port4"};
string url = ConfigurationManager.AppSettings["WebServiceCalls.SMS.URL"];
try
{
foreach (string num in sendTo)
{
foreach(string port in ports){
string newUrl = url.Replace("$PORT$", port);
if(Send(num, body, newUrl)){
ok.Add(num);
break;
}
else{
continue;
}
}
if(!ok.Contains(num)){
failed.Add(num);
}
}
log += "nSucceeded:n" + String.Join(", ", ok.ToArray());
log += "nFailed: n" + String.Join(", ", failed.ToArray());
addlog(log);
string result = "Succeeded: "+ok.Count+"nFailed: "+failed.Count+"nSee log file for more details";
return result;
}
catch (Exception e)
{
addlog(log + e.ToString());
return e.ToString();
}
}
static bool Send(string sendTo, string body, string url)
{
try{
HttpWebRequest request;
Stream stream;
string username, password, xml;
byte[] bytes;
xml = @"<?xml version=""1.0"" encoding=""UTF-8""?><request><bulk_msg><app_id>SMS464300</app_id><bulk_id>8</bulk_id><schedule status=""n""><date></date><time></time></schedule><delivery_report>0</delivery_report><message><title>SaudiAramco</title><lang_id>0</lang_id><body>{0}</body><values><msg_id>1</msg_id><mobile_no>{1}</mobile_no></values></message></bulk_msg></request>";
username = ConfigurationManager.AppSettings["WebServiceCalls.SMS.Username"];
username = EncryptionUtils.Decrypt(username, KryptoKey.PassPhrase, KryptoKey.SaltValue, KryptoKey.HashAlgorithm, KryptoKey.PasswordIterations, KryptoKey.InitVector, KryptoKey.KeySize);
password = ConfigurationManager.AppSettings["WebServiceCalls.SMS.Password"];
password = EncryptionUtils.Decrypt(password, KryptoKey.PassPhrase, KryptoKey.SaltValue, KryptoKey.HashAlgorithm, KryptoKey.PasswordIterations, KryptoKey.InitVector, KryptoKey.KeySize);
xml = string.Format(xml, body, sendTo);
request = (HttpWebRequest)WebRequest.Create(url + xml);
request.Method = "GET";
request.Credentials = new NetworkCredential(username, password, "COPMANYNAME");
WebProxy prox = new WebProxy();
prox.BypassProxyOnLocal = true;
request.Proxy = prox;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
if ((((HttpWebResponse)response).StatusDescription).Equals("OK"))
return true;
else
return false;
}
}
catch(Exception e){
addlog("failed at Send stagen"+"number: "+sendTo+"nbody: "+body+"nexception: "+e.ToString());
return false;
}
}
private static void loguser(string user){
//get date
DateTime now = DateTime.Now;
//get path
string path =getPath();
//prepare log
StringBuilder sb = new StringBuilder();
sb.Append("-------------" + Environment.NewLine +"new hit: "+ now + Environment.NewLine);
sb.Append("User: "+user + Environment.NewLine);
//write
File.AppendAllText(path, sb.ToString());
sb.Clear();
}
private static string getPath(){
//get date
DateTime now = DateTime.Now;
return ConfigurationManager.AppSettings["SSlog1"]
+ "-SMS-"
+ now.ToString("yyyy-MM-dd")
+ ConfigurationManager.AppSettings["SSlog2"];
}
private static bool addlog(string log){
loguser(uname);
try{
//get path
string path = getPath();
//prepare log
StringBuilder sb = new StringBuilder();
sb.Append("Log: " + Environment.NewLine + log + Environment.NewLine+"-------------" );
//write
File.AppendAllText(path, sb.ToString());
sb.Clear();
return true;
}catch(Exception e){
return false;
}
}
}
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team