Beispiel #1
0
        private void updateSMS(int status, string smsID)
        {
            try
            {
                //This is my connection string i have assigned the database file address path
                string MyConnection2 = ConfigurationManager.AppSettings["constring"];
                //This is my update query in which i am taking input from the user through windows forms and update the record.
                string Query = "update sms set smsStatus='" + status + "' where smsID='" + smsID + "';";
                //This is  MySqlConnection here i have created the object and pass my connection string.
                MySqlConnection MyConn2    = new MySqlConnection(MyConnection2);
                MySqlCommand    MyCommand2 = new MySqlCommand(Query, MyConn2);
                MySqlDataReader MyReader2;
                MyConn2.Open();
                MyReader2 = MyCommand2.ExecuteReader();

                while (MyReader2.Read())
                {
                }
                MyConn2.Close();//Connection closed here
            }
            catch (Exception ex)
            {
                var err2 = new LogUtility.Error()
                {
                    ErrorDescription = ex.Message + Environment.NewLine + ex.InnerException,
                    ErrorTime        = DateTime.Now,
                    ModulePointer    = "Error Sending SMS",
                    StackTrace       = ex.StackTrace
                };
                LogUtility.ActivityLogger.WriteErrorLog(err2);
            }
        }
Beispiel #2
0
        public int CountPendingTrans()
        {
            int count = 0;

            try
            {
                using (MySqlConnection con = new MySqlConnection())
                {
                    //con.ConnectionString = ConfigurationManager.AppSettings["MySQLCon"];
                    //con.ConnectionString = "Server=172.21.1.35; Database=jaiz_db; Uid=appsoluser; Pwd=@ppSol@Jaiz;";
                    con.ConnectionString = ConfigurationManager.AppSettings["constring"];
                    con.Open();
                    MySqlCommand cmd = new MySqlCommand();
                    cmd.Connection  = con;
                    cmd.CommandText = "SELECT Count(*) FROM routing WHERE routeStatus='0'";

                    count = Convert.ToInt32(cmd.ExecuteScalar());
                }
            }
            catch (Exception ex)
            {
                var err2 = new LogUtility.Error()
                {
                    ErrorDescription = ex.Message + Environment.NewLine + ex.InnerException,
                    ErrorTime        = DateTime.Now,
                    ModulePointer    = "Error Counting Transactions",
                    StackTrace       = ex.StackTrace
                };
                LogUtility.ActivityLogger.WriteErrorLog(err2);
            }

            return(count);
        }
Beispiel #3
0
        public void WriteLog(string message, string subject)
        {
            var err2 = new LogUtility.Error()
            {
                ErrorDescription = message,
                ErrorTime        = DateTime.Now,
                ModulePointer    = subject,
                //StackTrace = ex.StackTrace
            };

            LogUtility.ActivityLogger.WriteErrorLog(err2);
        }
        protected void Application_Error(object sender, EventArgs e)
        {
            // Code that runs when an unhandled error occurs
            Exception Ex = Server.GetLastError();

            Server.ClearError();
            // IDP s = new IDP();
            var err2 = new LogUtility.Error()
            {
                ErrorDescription = "Error Accessing the Application: " + Ex.InnerException.ToString() + " Error Message" + Ex.Message,
                ErrorTime        = DateTime.Now,
                ModulePointer    = "Error",
                StackTrace       = Ex.Message
            };

            LogUtility.ActivityLogger.WriteErrorLog(err2);
            //s.ErrorLog(Ex.Message);
        }
Beispiel #5
0
        public async void PushTransactions()
        {
            bool chkConn = false;

            try
            {
                chkConn = chk_con();
                if (chkConn)
                {
                    var client = new HttpClient();
                    ServicePointManager.Expect100Continue = true;
                    ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;
                    using (MySqlConnection con = new MySqlConnection())
                    {
                        //con.ConnectionString = ConfigurationManager.AppSettings["MySQLCon"];
                        //con.ConnectionString = "Server=172.21.1.35; Database=jaiz_db; Uid=appsoluser; Pwd=@ppSol@Jaiz;";
                        con.ConnectionString = ConfigurationManager.AppSettings["constring"];
                        con.Open();
                        MySqlCommand cmd = new MySqlCommand();
                        cmd.Connection  = con;
                        cmd.CommandText = "SELECT * FROM routing WHERE routeStatus='0'";
                        // cmd.Parameters.Add("username", MySqlDbType.VarChar).Value = username;


                        var url       = "";
                        var routeJSON = "";
                        int transID;

                        MySqlDataReader rdr = cmd.ExecuteReader();
                        if (rdr.HasRows)
                        {
                            //rdr.Read();


                            while (rdr.Read())
                            {
                                transID   = Convert.ToInt16(rdr["routeID"].ToString());
                                url       = rdr["routeURL"].ToString();
                                routeJSON = rdr["routeJSON"].ToString();

                                //update the transactions to prevent double picking
                                updateTrans(2, transID);
                                //var rs = JsonConvert.SerializeObject(t);
                                WriteLog(routeJSON, "Transaction Picked for posting");


                                var content = new StringContent(routeJSON, Encoding.UTF8, "application/json");


                                HttpResponseMessage result = null;
                                ServicePointManager.Expect100Continue = true;
                                ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;
                                ServicePointManager.ServerCertificateValidationCallback = new
                                                                                          RemoteCertificateValidationCallback
                                                                                          (
                                    delegate { return(true); }
                                                                                          );
                                result = client.PostAsync(url, content).Result;


                                var r  = result.Content.ReadAsStringAsync().Result.Replace("\\", "");
                                var rr = JsonConvert.DeserializeObject <PostingResult>(r);


                                if (rr.status == "00")
                                {
                                    var m = "Status:" + rr.status + " Message:" + rr.message;
                                    WriteLog(m, "Transaction Synching Successful");
                                    //updateMessage(1, smsID);
                                    updateTrans(1, transID);
                                    //Console.WriteLine("Success");
                                }
                                else
                                {
                                    // updateMessage(2, smsID);
                                    var m = "Status:" + rr.status + " Message:" + rr.message;
                                    WriteLog(m, "Transaction Synching Failed");
                                    updateTrans(0, transID);
                                    //Console.WriteLine("Error");
                                }
                            }
                        }
                    }
                }
                else
                {
                    WriteLog(DateTime.Now + ":No internet connection detected, waiting to try again", "Internet Connection Error");
                }
            }
            catch (Exception ex)
            {
                var err2 = new LogUtility.Error()
                {
                    ErrorDescription = ex.Message + Environment.NewLine + ex.InnerException,
                    ErrorTime        = DateTime.Now,
                    ModulePointer    = "Error Sending Transactions",
                    StackTrace       = ex.StackTrace
                };
                LogUtility.ActivityLogger.WriteErrorLog(err2);
            }
        }
Beispiel #6
0
        private void SelectTransOnQueue(object sender, ElapsedEventArgs e)
        {
            TransSender i     = new TransSender();
            int         count = i.CountPendingTrans();
            Thread      tr1   = null;
            Thread      tr2   = null;
            Thread      tr3   = null;
            Thread      tr4   = null;
            Thread      tr5   = null;
            Thread      tr6   = null;
            Thread      tr7   = null;
            Thread      tr8   = null;
            Thread      tr9   = null;
            Thread      tr10  = null;


            if (count > 0)
            {
                try
                {
                    tr1 = new Thread(delegate() { i.PushTransactions(); });
                    tr1.Start();

                    //tr2 = new Thread(delegate () { i.PushTransactions(1); });
                    //tr2.Start();

                    //tr3 = new Thread(delegate () { i.PushTransactions(2); });
                    //tr3.Start();

                    //tr4 = new Thread(delegate () { i.PushTransactions(3); });
                    //tr4.Start();

                    //tr5 = new Thread(delegate () { i.PushTransactions(4); });
                    //tr5.Start();

                    //tr6 = new Thread(delegate () { i.PushTransactions(5); });
                    //tr6.Start();

                    //tr7 = new Thread(delegate () { i.PushTransactions(6); });
                    //tr7.Start();

                    //tr8 = new Thread(delegate () { i.PushTransactions(7); });
                    //tr8.Start();

                    //tr9 = new Thread(delegate () { i.PushTransactions(8); });
                    //tr9.Start();

                    //tr10 = new Thread(delegate () { i.PushTransactions(9); });
                    //tr10.Start();
                }
                catch (Exception ex)
                {
                    var err22 = new LogUtility.Error()
                    {
                        ErrorDescription = "Error Code:" + ex.InnerException + " Response Message:" + ex.Message + Environment.NewLine + ex.Message,
                        ErrorTime        = DateTime.Now,
                        ModulePointer    = "Transaction Synchng Error",
                        StackTrace       = ex.InnerException.ToString()
                    };
                    LogUtility.ActivityLogger.WriteErrorLog(err22);
                }
            }
        }