コード例 #1
0
        public static async void getFile(string filename)
        {
            string df_text = @"\Root\Files\Customer Files\CoolHeat Comfort Customer List\Residential Customers\" + filename;
            string s       = JsonClass.JSONSerialize <DatabaseFunctions.data>(new DatabaseFunctions.data
            {
                df_text1 = df_text
            });

            byte[]         bytes          = Encoding.UTF8.GetBytes(s);
            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("http://174.114.166.80/getCusFile.php");

            httpWebRequest.Method        = "POST";
            httpWebRequest.ContentType   = "application/x-www-form-urlencoded";
            httpWebRequest.ContentLength = (long)bytes.Length;
            httpWebRequest.GetRequestStream().Write(bytes, 0, bytes.Length);
            Stream responseStream = ((HttpWebResponse)httpWebRequest.GetResponse()).GetResponseStream();
            int    num            = 1024;

            byte[]     buffer     = new byte[num];
            string     path       = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            FileStream fileStream = File.Create(path + "CHStreamFile" + filename);
            int        count;

            while ((count = responseStream.Read(buffer, 0, num)) != 0)
            {
                fileStream.Write(buffer, 0, count);
            }
            await Browser.OpenAsync(filename, BrowserLaunchMode.SystemPreferred);
        }
コード例 #2
0
 public static void SendToPhp(bool PBX, string statement, TaskCallback call)
 {
     try
     {
         data d = new data();
         d.df_text1 = statement;
         string requestUriString;
         if (PBX)
         {
             requestUriString = "http://192.168.0.69/accessPBX.php";
         }
         else
         {
             requestUriString = "http://192.168.0.69/access.php";
         }
         string         text           = JsonClass.JSONSerialize <DatabaseFunctions.data>(d);
         byte[]         bytes          = Encoding.UTF8.GetBytes(text);
         HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(requestUriString);
         httpWebRequest.Method        = "POST";
         httpWebRequest.ContentType   = "application/x-www-form-urlencoded";
         httpWebRequest.ContentLength = (long)bytes.Length;
         httpWebRequest.GetRequestStream().Write(bytes, 0, bytes.Length);
         Stream       responseStream = ((HttpWebResponse)httpWebRequest.GetResponse()).GetResponseStream();
         StreamReader streamReader   = new StreamReader(responseStream);
         call(streamReader.ReadToEnd());
         streamReader.Close();
         responseStream.Close();
     }
     catch (WebException ex)
     {
         string str = ex.ToString();
         Console.WriteLine("--->" + str);
     }
 }
コード例 #3
0
        public static string[] getCustomerFileList(string name)
        {
            string s = JsonClass.JSONSerialize <DatabaseFunctions.data>(new DatabaseFunctions.data
            {
                df_text1 = name
            });
            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("http://174.114.166.80/getCusFolders.php");

            httpWebRequest.Method = "POST";
            byte[] bytes = Encoding.UTF8.GetBytes(s);
            httpWebRequest.ContentType   = "application/x-www-form-urlencoded";
            httpWebRequest.ContentLength = (long)bytes.Length;
            Stream requestStream = httpWebRequest.GetRequestStream();

            requestStream.Write(bytes, 0, bytes.Length);
            WebResponse  response       = httpWebRequest.GetResponse();
            Stream       responseStream = response.GetResponseStream();
            StreamReader streamReader   = new StreamReader(responseStream);

            string[] result = FormatFunctions.SplitToPairs(streamReader.ReadToEnd());
            httpWebRequest.Abort();
            streamReader.Close();
            responseStream.Close();
            response.Close();
            requestStream.Close();
            return(result);
        }
コード例 #4
0
 public static void SendBatchToPHP(List <string> statementList)
 {
     try
     {
         string[] statements = statementList.ToArray();
         string   text       = JsonClass.JSONSerialize <DatabaseFunctions.dataArray>(new DatabaseFunctions.dataArray
         {
             BatchLength = statements.Length,
             statements  = statements
         });
         HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("http://174.114.166.80/accessBatched.php");
         httpWebRequest.Method = "POST";
         string s     = text;
         byte[] bytes = Encoding.UTF8.GetBytes(s);
         httpWebRequest.ContentType   = "application/x-www-form-urlencoded";
         httpWebRequest.ContentLength = (long)bytes.Length;
         httpWebRequest.GetRequestStream().Write(bytes, 0, bytes.Length);
         httpWebRequest.Abort();
     }
     catch (WebException ex)
     {
         string str = ex.ToString();
         Console.WriteLine("--->" + str);
     }
 }
コード例 #5
0
        public static string getCallFile(string Date, string filename, TaskCallback call)
        {
            string[] array   = FormatFunctions.CleanDate(Date);
            string   df_text = string.Concat(new string[]
            {
                @"CDR\",
                array[0],
                @"\",
                array[1],
                @"\",
                array[2],
                @"\",
                filename
            });
            string s = JsonClass.JSONSerialize <DatabaseFunctions.data>(new DatabaseFunctions.data
            {
                df_text1 = df_text
            });

            byte[]         bytes          = Encoding.UTF8.GetBytes(s);
            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("http://174.114.166.80/getCusFile.php");

            httpWebRequest.Method        = "POST";
            httpWebRequest.ContentType   = "application/x-www-form-urlencoded";
            httpWebRequest.ContentLength = (long)bytes.Length;
            httpWebRequest.GetRequestStream().Write(bytes, 0, bytes.Length);
            Stream responseStream = ((HttpWebResponse)httpWebRequest.GetResponse()).GetResponseStream();
            int    num            = 1024;

            byte[]     buffer     = new byte[num];
            string     path       = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            FileStream fileStream = File.Create(path + "CHStreamFile" + filename);
            int        count;

            while ((count = responseStream.Read(buffer, 0, num)) != 0)
            {
                fileStream.Write(buffer, 0, count);
            }
            httpWebRequest.Abort();
            return("CHStreamFile" + filename);
        }
コード例 #6
0
        public static async void SendToPhpB(bool PBX, string statement, TaskCallback call)
        {
            try
            {
                data d = new data();
                d.df_text1 = statement;
                string requestUriString;
                if (inOffice())
                {
                    if (PBX)
                    {
                        requestUriString = "http://192.168.0.69/accessPBX.php";
                    }
                    else
                    {
                        requestUriString = "http://192.168.0.69/access.php";
                    }
                }
                else
                {
                    if (PBX)
                    {
                        requestUriString = "http://174.114.166.80/accessPBX.php";
                    }
                    else
                    {
                        requestUriString = "http://174.114.166.80/access.php";
                    }
                }
                string        text    = JsonClass.JSONSerialize <DatabaseFunctions.data>(d);
                StringContent content = new StringContent(text, Encoding.UTF8);
                var           result  = await clientH.PostAsync(requestUriString, content).ConfigureAwait(false);

                var t = await result.Content.ReadAsStringAsync();

                call(t);
            }
            catch (HttpRequestException e)
            {
            }
        }
コード例 #7
0
 public static void SendToPhp(string statement)
 {
     try
     {
         string text = JsonClass.JSONSerialize <data>(new data
         {
             df_text1 = statement
         });
         HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("http://192.168.0.69/access.php");
         httpWebRequest.Method = "POST";
         string s     = text;
         byte[] bytes = Encoding.UTF8.GetBytes(s);
         httpWebRequest.ContentType   = "application/x-www-form-urlencoded";
         httpWebRequest.ContentLength = (long)bytes.Length;
         httpWebRequest.GetRequestStream().Write(bytes, 0, bytes.Length);
     }
     catch (WebException ex)
     {
         string str = ex.ToString();
         Console.WriteLine("--->" + str);
     }
 }
コード例 #8
0
 public static void SendToPDFPrinter(string data)
 {
     try
     {
         string text = JsonClass.JSONSerialize <DatabaseFunctions.data>(new DatabaseFunctions.data
         {
             df_text1 = data
         });
         HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("http://174.114.166.80/SendPDF.php");
         httpWebRequest.Method = "POST";
         string s     = text;
         byte[] bytes = Encoding.UTF8.GetBytes(s);
         httpWebRequest.ContentType   = "application/x-www-form-urlencoded";
         httpWebRequest.ContentLength = (long)bytes.Length;
         httpWebRequest.GetRequestStream().Write(bytes, 0, bytes.Length);
         httpWebRequest.Abort();
     }
     catch (WebException ex)
     {
         string str = ex.ToString();
         Console.WriteLine("--->" + str);
     }
 }