Beispiel #1
0
        public static string CloseTicket(List <string> studentsData, string heatId, string teacherId, string crn, string termCode, string classDate)
        //public static void CreateTicket(string staffNumber, string crn, string termCode)
        {
            string returnValue = "none";

            try
            {
                UtilResultObject res = new UtilResultObject();

                StudentAttendanceClient response = new StudentAttendanceClient();

                res = response.UpdateHEATTicketStatus(WebConfigurationManager.AppSettings["webServiceUsername"], WebConfigurationManager.AppSettings["webServicePassword"], heatId);

                if (res.Status)
                {
                    returnValue = "Ticket Closed";
                }
            }
            catch (Exception e)
            {
                returnValue = e.Message;
                throw e;
            }

            return(returnValue);
        }
Beispiel #2
0
        public static List <HeatData> CreateTicket(string staffNumber, string crn, string termCode)
        {
            List <HeatData> heatData    = new List <HeatData>();
            string          sentToEmail = WebConfigurationManager.AppSettings["ToEmail"];

            try
            {
                UtilResultObject res = new UtilResultObject();

                StudentAttendanceClient response = new StudentAttendanceClient();

                Files.dbConnection con = new Files.dbConnection(); // 218720 VP  // 22178 VS

                string sclearsql = string.Concat("SELECT * FROM [IntHub].[dbo].[StaffBKI] " +
                                                 "WHERE BarCode = @staffNumber" +
                                                 " and isActive = 1 and StaffType in ('Payroll BT','Payroll KI')"
                                                 );
                SqlParameter[] parameter =
                {
                    new SqlParameter("@staffNumber", SqlDbType.VarChar)
                    {
                        Value = staffNumber
                    }
                };
                DataTable tempTable = null;
                tempTable = con.executeSelectQuery(sclearsql, parameter);
                string emailTofromDB = WebConfigurationManager.AppSettings["ToEmail"];

                if ((tempTable == null) || (tempTable.Rows.Count == 0))
                {
                    emailTofromDB = WebConfigurationManager.AppSettings["ToEmailLogin"];
                }
                else
                {
                    foreach (DataRow dr in tempTable.Rows)
                    {
                        emailTofromDB = dr["Login"].ToString();
                        sentToEmail   = dr["EmailInstitute"].ToString();
                    }
                }

                res = response.CreateHEATTicket(WebConfigurationManager.AppSettings["webServiceUsername"],
                                                WebConfigurationManager.AppSettings["webServicePassword"],
                                                emailTofromDB,
                                                staffNumber,
                                                crn,
                                                termCode);

                if (res.Status)
                {
                    try
                    {
                        MailMessage mail       = new MailMessage();
                        SmtpClient  SmtpServer = new SmtpClient("mail-relay.kbtm.kangan.edu.au");

                        mail.From = new MailAddress(WebConfigurationManager.AppSettings["FromEmail"]);

                        //Files.dbConnection con = new Files.dbConnection(); // 218720 VP  // 22178 VS


                        //string sclearsql = string.Concat("SELECT * FROM [IntHub].[dbo].[StaffBKI] " +
                        //                                         "WHERE BarCode = @staffNumber" +
                        //                                         " and isActive = 1 and StaffType in ('Payroll BT','Payroll KI')"
                        //                                );
                        //SqlParameter[] parameter = {
                        //                        new SqlParameter("@staffNumber", SqlDbType.VarChar) { Value =staffNumber }
                        //                         };
                        //DataTable tempTable = null;

                        //tempTable = con.executeSelectQuery(sclearsql, parameter);

                        //if ((tempTable == null) || (tempTable.Rows.Count == 0))
                        //{
                        //    mail.To.Add(WebConfigurationManager.AppSettings["ToEmail"]);
                        //}
                        //else
                        //{
                        //    foreach (DataRow dr in tempTable.Rows)
                        //    {
                        //        //dr["EmailInstitute"].ToString();
                        //        mail.To.Add(dr["EmailInstitute"].ToString());
                        //        sentToEmail = dr["EmailInstitute"].ToString();
                        //    }
                        //}
                        //where BarCode = CONVERT(varchar(50), 218720 )

                        mail.To.Add(sentToEmail);

                        mail.Subject = "Student Attendance Missing";

                        string heatCloseUrl = WebConfigurationManager.AppSettings["AttendanceSubmission"];
                        //string heatCloseUrl = WebConfigurationManager.AppSettings["HeatTicketClose"];

                        string url = heatCloseUrl + "?heatId=" + res.Message +
                                     "&teacherId=" + staffNumber
                                     + "&crn=" + crn
                                     + "&termCode=" + termCode
                                     + "&classDate=" + DateTime.Now.ToString("dd'/'MM'/'yyyy");

                        mail.Body = @"Heat Ticket is created." + " The id is:- " + res.Message + "\n" + url;

                        SmtpServer.Port = 25;

                        //SmtpServer.Send(mail);


                        HeatData hd = new HeatData();
                        hd.heatId        = res.Message;
                        hd.message       = res.Status.ToString();
                        hd.sentToEmail   = sentToEmail;
                        hd.emailTofromDB = emailTofromDB;
                        heatData.Add(hd);

                        return(heatData);
                    }
                    catch (Exception ex)
                    {
                        return(heatData);

                        throw ex;
                        //MessageBox.Show(ex.ToString());
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }

            //return message;
            return(heatData);
        }