Beispiel #1
0
        public CResult DataReaderQueryRequest(string sSql)
        {
            oSqlConnection     = new SqlConnection();
            m_oCConnectionToDB = new CConnection();
            oSqlConnection     = m_oCConnectionToDB.GetDBConnection();

            SqlCommand    sqlComm        = new SqlCommand(sSql, oSqlConnection);
            SqlDataReader oSqlDataReader = sqlComm.ExecuteReader();

            oCResult.Data = oSqlDataReader;

            return(oCResult);
        }
        public DataSet  DataAdapterQueryRequest(string sSql)
        {
            m_oCConnectionToDB = new CConnection();
            oSqlConnection     = new SqlConnection();
            oDataSet           = new DataSet();
            oSqlConnection     = m_oCConnectionToDB.GetDBConnection();
            SqlDataAdapter oSqlDataAdapter = new SqlDataAdapter(sSql, oSqlConnection);

            try
            {
                oSqlDataAdapter.Fill(oDataSet, "Common");
                //oCResult.IsSuccess = true;
                //oCResult.Message = "Successfull";
                //oCResult.Data = oDataSet;
            }
            catch (Exception ex)
            {
                //oCResult.IsSuccess = false;
                //oCResult.Message = ex.ToString();
            }
            return(oDataSet);
        }
Beispiel #3
0
        private void SearchExeFile(string c)
        {
            //OMSProcessMail ap = new OMSProcessMail();
            DirectoryInfo dir                = new DirectoryInfo(c);
            SqlConnection oSqlConnection     = new SqlConnection();
            CConnection   m_oCConnectionToDB = new CConnection();

            foreach (FileInfo f in dir.GetFiles())
            {
                String     Sender   = "";
                String     pathname = "C:\\OMS\\Others\\Sender.dbz";
                FileStream fsIn     = new FileStream(pathname, FileMode.Open, FileAccess.Read, FileShare.Read);
                using (StreamReader sr = new StreamReader(fsIn, fileEncoding, true))
                {
                    Sender = sr.ReadLine();
                }

                String Mail = "";
                pathname = "C:\\OMS\\Others\\Mail.dbz";
                fsIn     = new FileStream(pathname, FileMode.Open, FileAccess.Read, FileShare.Read);
                using (StreamReader sr = new StreamReader(fsIn, fileEncoding, true))
                {
                    Mail = sr.ReadLine();
                }
                oSqlConnection = m_oCConnectionToDB.GetDBConnection();
                DataSet oDataSet = new DataSet();

                //Modified   :   Saurav Biswas Kartik /OCT-21-2009 [Start]
                //Summary    :   To mail to all user [user aleart only]
                //oDataSet = m_oCSQLCommandExecutor.DataAdapterQueryRequest("SELECT  *  FROM SecurityUser WHERE (UsrDepartment = 'Administration') and  UsrLevel= 'Administrator' and UsrActive='Y'", oSqlConnection);
                string strUser = "";
                strUser  = f.Name;
                strUser  = strUser.Substring(0, strUser.IndexOf("_"));
                oDataSet = m_oCSQLCommandExecutor.DataAdapterQueryRequest("SELECT * FROM SecurityUser WHERE UsrActive='Y' And UsrUserName = '******'", oSqlConnection);
                //Modified   :   Saurav Biswas Kartik /OCT-21-2009 [End]

                if (oDataSet.Tables[0].Rows.Count > 0)
                {
                    File.Copy(f.FullName, "C:\\OMS\\Mail_Mail\\" + f.Name.ToString(), true);
                    File.Delete(f.FullName);
                    for (int k = 0; k <= oDataSet.Tables[0].Rows.Count - 1; k++)
                    {
                        if (oDataSet.Tables[0].Rows[k]["UsrEmailAddress"].ToString() != "")
                        {
                            //Kartik Checking Oct-21-2009 [START]
                            StreamWriter sw = File.AppendText("c:\\Test1.txt");
                            sw.WriteLine(oDataSet.Tables[0].Rows[k]["UsrEmailAddress"].ToString());
                            sw.Close();
                            //Kartik Checking Oct-21-2009 [END]

                            pathname = "C:\\OMS\\Mail_Mail\\" + f.Name.ToString();  // @"D:\TransferPurchase\Buy03022009Purchase.txt";

                            string      s;
                            MailMessage mail = new MailMessage();
                            mail.To      = oDataSet.Tables[0].Rows[k]["UsrEmailAddress"].ToString();
                            mail.From    = Sender;
                            mail.Subject = f.Name.ToString();
                            mail.Body    = f.Name.ToString();
                            MailAttachment attachment = new MailAttachment(pathname); //create the attachment
                            mail.Attachments.Add(attachment);                         //add the attachment
                            SmtpMail.SmtpServer = Mail;                               //your real server goes here
                            SmtpMail.Send(mail);
                        }
                        else
                        {
                            File.Copy(f.FullName, "C:\\OMS\\OMS_Mail_Err\\" + f.Name.ToString(), true);
                            File.Delete(f.FullName);
                        }
                    }
                }
            }
        }