public static ArrayList List(int comId, int caseId, short sta, Pager pager) { /* SupplierCaseEvaluationRequestList @comId int=0, @caseId int=0, @sta smallint=0, @pageIndex int=1, @pageSize int=20, @sort int=0 */ //[Id], CaseId,CaseTitle,CompanyId,CompanyName, //ClientName, ClientTitle, ClientPhoneNumber, ClientEmail, Message, [Datetime], Status ArrayList list = new ArrayList(); SqlParameter[] prams ={ Database.MakeInParam("@comId",SqlDbType.Int,comId), Database.MakeInParam("@caseId",SqlDbType.Int,caseId), Database.MakeInParam("@sta",SqlDbType.SmallInt,sta), Database.MakeInParam("@pageIndex",SqlDbType.Int,pager.PageIndex), Database.MakeInParam("@pageSize",SqlDbType.Int,pager.PageSize), Database.MakeInParam("@sort",SqlDbType.Int,pager.SortNum) }; SqlDataReader reader = null; try { reader = Database.ExecuteReader(CommandType.StoredProcedure, "SupplierCaseEvaluationRequestList", prams); if (reader.Read()) { pager.RecordCount = reader.GetInt32(0); if (reader.NextResult()) { while (reader.Read()) { SupplierCaseEvaluationRequest request = new SupplierCaseEvaluationRequest(); request.id = reader.GetInt32(0); request.caseId = reader.GetInt32(1); request.caseTitle = reader.IsDBNull(2)?"":reader.GetString(2); request.companyId = reader.GetInt32(3); request.companyName = reader.IsDBNull(4) ? "" : reader.GetString(4); request.clientName = reader.GetString(5); request.clientTitle = reader.GetString(6); request.clientPhoneNumber = reader.GetString(7); request.clientEmail = reader.GetString(8); request.message = reader.GetString(9); request.datetime = reader.GetDateTime(10); request.status = (CaseEvaluationRequestStatus)(reader.GetInt16(11)); list.Add(request); } } } reader.Close(); } catch { //throw; } finally { if (reader != null) { reader.Close(); } } return list; }
private void SendInvisitEval() { if (Request.Form["invisitEvalCaseId"] == null || Request.Form["clientName"] == null || Request.Form["clientContact"] == null || Request.Form["clientTitle"] == null || Request.Form["clientPhone"] == null || Request.Form["clientEmail"] == null) { Response.Write("false"); return; } int caseId = 0; try { caseId = Convert.ToInt32(Request.Form["invisitEvalCaseId"]); } catch { // } if(caseId==0) { Response.Write("false"); return; } string cltName = Request.Form["clientName"]; string cltTitle = Request.Form["clientContact"].Trim() + " " + Request.Form["clientTitle"].Trim(); string cltPhone = Request.Form["clientPhone"]; string cltEmail = Request.Form["clientEmail"].Trim(); string sms = Request.Form["message"] == null ? "" : Util.HtmlEncode(Request.Form["message"].Trim()); if (!Util.IsValidEmail(cltEmail)) { Response.Write("�ʼ���ַ����"); return; } if (cltEmail.ToLower()==SupplierEmail.ToLower()) { Response.Write("���������Լ���"); return; } CompanyCase ca = CompanyCase.Get(caseId, SupplierId); if (ca == null) { Response.Write("��ȡ������Ϣʱ����"); return; } if (ca.Status==CaseStatus.Evaluating) { Response.Write("�ð����Ѿ��������ۣ���ȴ���"); return; } if (ca.Status == CaseStatus.Evalueated) { Response.Write("�ð����Ѿ������۹��������ظ��������ۣ�"); return; } if (!IsMatchEmailAndUrl(ca.ClientWebsite,cltEmail)) { Response.Write("�ʼ���ַ(" + cltEmail + ")�Ϳͻ���ַ(" + ca.ClientWebsite + ")�����ϣ����ܷ����������룡"); return; } StringBuilder caseDesc = new StringBuilder(); caseDesc.AppendLine("\n�ͻ����ƣ�" + Util.HtmlEncode(cltName)); //caseDesc.AppendLine("��ϵ�ˣ�" + cltTitle); //caseDesc.AppendLine("��ϵ�绰��" + cltPhone); caseDesc.AppendLine("\n�������ڣ�" + ca.Period); caseDesc.AppendLine("\n���������ı�����"); caseDesc.AppendLine(Util.HtmlEncode(ca.Background)); caseDesc.AppendLine("\n������������"); caseDesc.AppendLine(Util.HtmlEncode(ca.Description)); caseDesc.AppendLine("\n������������"); caseDesc.AppendLine(Util.HtmlEncode(ca.Result)); if (!String.IsNullOrEmpty(sms)) { caseDesc.AppendLine("\n\n"+SupplierComName+" ���������ԣ�"); caseDesc.AppendLine(Util.HtmlEncode(sms)); } //���������ʼ� bool mailSended = false; MailTempItem mailTemp = MailTemplates.GetTemplate("sp_invisit_case_evaluation"); if (mailTemp != null) { string[] args = new string[] { cltTitle, SupplierComName, ca.Title, caseDesc.ToString(), CrypticString.Encrypt("email="+cltEmail+"&comid="+SupplierId.ToString()+"&caseid="+caseId.ToString(),true) }; SmtpMail sm = SmtpMail.Instance; sm.AddRecipient(new string[] { cltEmail }); sm.Html = mailTemp.Html; sm.Subject = String.Format(mailTemp.Subject, args); sm.Body = String.Format(mailTemp.Body, args); mailSended = sm.Send(); if (!mailSended) { Log.AddLog(LogType.SystemLog, cltEmail, "���Ͱ������������ʼ�ʧ�ܣ�" + sm.ErrorMessage + ""); } else { //���������¼ SupplierCaseEvaluationRequest req = new SupplierCaseEvaluationRequest(SupplierId, caseId); req.ClientName = cltName; req.ClientTitle = cltTitle; req.ClientPhoneNumber = cltPhone; req.ClientEmail = cltEmail; req.Message = sms; req.Save(); } } //����ϵͳ��Ϣ //StringBuilder sysMsg = new StringBuilder(); //if (mailSended) //{ // sysMsg.AppendLine("<p>������ɹ���</p>"); //} //else //{ // sysMsg.AppendLine("<p>�����ʧ�ܣ�</p>"); // sysMsg.AppendLine("<p>�������ڽ���������ʼ� " + cltEmail + " ���⣬�����뷢��ʧ�ܣ�</p>"); //} //sysMsg.AppendLine("<p>�������ƣ�" + ca.Title + "</p>"); //sysMsg.AppendLine("<p>���͵���"+cltEmail + " (" +Util.HtmlEncode(cltTitle)+")</p>"); //sysMsg.AppendLine("<p>�ͻ����ƣ�"+cltName+"</p>"); //sysMsg.AppendLine("<p>��ϵ�绰��"+cltPhone+"</p>"); //sysMsg.AppendLine("<p>����ʱ�䣺"+DateTime.Now.ToString()+"</p>"); //if (!String.IsNullOrEmpty(sms)) //{ // sysMsg.AppendLine("<p>�������ԣ�" + Util.HtmlEncode(sms) + "</p>"); //} //MailTempItem msgTemp = MailTemplates.GetTemplate(mailSended ? "msg_sp_case_invisit_evaluation_ok" : "msg_sp_case_invisit_evaluation_failed"); //Message msg = new Message(MessageType.SystemNotice); //msg.CompanyId = SupplierId; //msg.Priority = MessagePriority.Normal; //msg.Title = String.Format(msgTemp.Subject,ca.Title,""); //msg.Body = String.Format(msgTemp.Body, ca.Title, sysMsg.ToString()); //msg.Save(); Response.Write(mailSended.ToString().ToLower()); }
public static SupplierCaseEvaluationRequest Get(int id,int comId) { /* SupplierCaseEvaluationRequestGet @id int, @comId int=0 */ //[Id], CaseId,CaseTitle,CompanyId,CompanyName, //ClientName, ClientTitle, ClientPhoneNumber, ClientEmail, Message, [Datetime], Status SupplierCaseEvaluationRequest request = null; SqlDataReader reader = null; try { reader = Database.ExecuteReader(CommandType.StoredProcedure, "SupplierCaseEvaluationRequestGet", new SqlParameter[] { Database.MakeInParam("@id",SqlDbType.Int,id), Database.MakeInParam("@comId",SqlDbType.Int,comId) }); if (reader.Read()) { request = new SupplierCaseEvaluationRequest(); request.id = reader.GetInt32(0); request.caseId = reader.GetInt32(1); request.caseTitle = reader.GetString(2); request.companyId = reader.GetInt32(3); request.companyName = reader.GetString(4); request.clientName = reader.GetString(5); request.clientTitle = reader.GetString(6); request.clientPhoneNumber = reader.GetString(7); request.clientEmail = reader.GetString(8); request.message = reader.GetString(9); request.datetime = reader.GetDateTime(10); request.status = (CaseEvaluationRequestStatus)(reader.GetInt16(11)); } reader.Close(); } catch { // } finally { if (reader != null) { reader.Close(); } } return request; }