Exemplo n.º 1
0
        public FileListDetails GetFileDetails(int nID)
        {
            SqlConnection con = new SqlConnection(connectionString);
            SqlCommand    cmd = new SqlCommand("GetFileUsingID", con);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int, 4));
            cmd.Parameters["@ID"].Value = nID;

            try
            {
                con.Open();
                SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow);
                if (!reader.HasRows)
                {
                    return(null);
                }

                reader.Read();

                FileListDetails fld = new FileListDetails((int)reader["ID"], (string)reader["FileName"], (string)reader["Description"]);

                reader.Close();

                return(fld);
            }
            catch (SqlException err)
            {
                // Replace the error with something less specific.
                // You could also log the error now.
                throw new ApplicationException("Data error." + err.ToString());
            }
            finally
            {
                con.Close();
            }

            //return retVal;
        }
Exemplo n.º 2
0
        public FileListDetails GetFileDetails(int nID)
        {
            SqlConnection con = new SqlConnection(connectionString);
            SqlCommand cmd = new SqlCommand("GetFileUsingID", con);
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int, 4));
            cmd.Parameters["@ID"].Value = nID;

            try
            {
                con.Open();
                SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow);
                if (!reader.HasRows) return null;

                reader.Read();

                FileListDetails fld = new FileListDetails((int)reader["ID"], (string)reader["FileName"], (string)reader["Description"]);

                reader.Close();

                return fld;

            }
            catch (SqlException err)
            {
                // Replace the error with something less specific.
                // You could also log the error now.
                throw new ApplicationException("Data error." + err.ToString());
            }
            finally
            {
                con.Close();
            }

            //return retVal;
        }
        protected void sendEmail(int nUserID, string strEmail, string strToken, FileListDetails fld)
        {
            //Response.Write("UserID= " + nUserID + "<br>Email= " + strEmail + "<br>Token= " + strToken);

            RequestTable table = new RequestTable();

            table.InsertRequest(new RequestDetails(nUserID, strToken));

            string strURL = ResolveServerUrl("/download",false);

            string strLogoURL = ResolveServerUrl("/Images/Pitt-Logo.gif", false);

            string strDownloadLink = strURL + "?&file=" + fld.FileName +  "&id=" + strToken;

            string strMsg = "<body> <img src=\"" + strLogoURL + "\" /> <br> We have recieved your request to download our software package. " +
            "The following is a link containing the software you requested: <br>" + strDownloadLink + " </body>";

            MailMessage msgeme = new MailMessage("*****@*****.**", strEmail, "My Statistics Software Download Link", strMsg);
            msgeme.IsBodyHtml = true;

            //SmtpClient smtpclient = new SmtpClient("in.mailjet.com", 587);
            SmtpClient smtpclient = new SmtpClient("smtp.pitt.edu",25);
            smtpclient.UseDefaultCredentials = false;
            smtpclient.EnableSsl = true;
            //smtpclient.Credentials = new NetworkCredential("rocmail", "##password");
            smtpclient.DeliveryMethod = SmtpDeliveryMethod.Network;

            //smtpclient.Port = 587;
            //smtpclient.Host = "smtp.pitt.edu";

            smtpclient.Send(msgeme);

            //try
            //{
            //    smtpclient.Send(msgeme);
            //}
            //catch (Exception ex)
            //{

            //    String message = ex.Message;

            //    Response.Write("<script language='javascript'>alert('" +
            //        Server.HtmlEncode(message) + "')</script>");
            //}

            // Now we should check if the email address has been verified and if so redirect to that instead of the Email Sent page.

            var response = base.Response;

            if (!db.HasUserVerifiedEmail(nUserID))
            {
                response.Redirect("./DownloadEmailSent.aspx");
            }
            else
            {
                response.Redirect(strDownloadLink);
            }
        }
Exemplo n.º 4
0
        protected void sendEmail(int nUserID, string strEmail, string strToken, FileListDetails fld)
        {
            //Response.Write("UserID= " + nUserID + "<br>Email= " + strEmail + "<br>Token= " + strToken);

            RequestTable table = new RequestTable();

            table.InsertRequest(new RequestDetails(nUserID, strToken));

            string strURL = ResolveServerUrl("/download", false);

            string strLogoURL = ResolveServerUrl("/Images/Pitt-Logo.gif", false);

            string strDownloadLink = strURL + "?&file=" + fld.FileName + "&id=" + strToken;

            string strMsg = "<body> <img src=\"" + strLogoURL + "\" /> <br> We have recieved your request to download our software package. " +
                            "The following is a link containing the software you requested: <br>" + strDownloadLink + " </body>";

            MailMessage msgeme = new MailMessage("*****@*****.**", strEmail, "My Statistics Software Download Link", strMsg);

            msgeme.IsBodyHtml = true;

            //SmtpClient smtpclient = new SmtpClient("in.mailjet.com", 587);
            SmtpClient smtpclient = new SmtpClient("smtp.pitt.edu", 25);

            smtpclient.UseDefaultCredentials = false;
            smtpclient.EnableSsl             = true;
            //smtpclient.Credentials = new NetworkCredential("rocmail", "##password");
            smtpclient.DeliveryMethod = SmtpDeliveryMethod.Network;

            //smtpclient.Port = 587;
            //smtpclient.Host = "smtp.pitt.edu";

            smtpclient.Send(msgeme);

            //try
            //{
            //    smtpclient.Send(msgeme);
            //}
            //catch (Exception ex)
            //{


            //    String message = ex.Message;

            //    Response.Write("<script language='javascript'>alert('" +
            //        Server.HtmlEncode(message) + "')</script>");
            //}


            // Now we should check if the email address has been verified and if so redirect to that instead of the Email Sent page.

            var response = base.Response;

            if (!db.HasUserVerifiedEmail(nUserID))
            {
                response.Redirect("./DownloadEmailSent.aspx");
            }
            else
            {
                response.Redirect(strDownloadLink);
            }
        }