Answers for Q1 and Q2
A1:
1. enetity-data model mapping:

2. database design
2.1 sql
create table A_manufacturer_info(
manu_id int primary key identity(1,1) not null,
manu_code char(8) not null,--manufacturer code
manu_name nvarchar(50) not null,--manufacturer name
manu_logo varchar(100)--manufacturer logo URL
);
insert into A_manufacturer_info values('mfc00000','mfc000en','http://0');
insert into A_manufacturer_info values('mfc00001','mfc001en','http://1');
insert into A_manufacturer_info values('mfc00002','mfc002en','http://2');
create table A_product_category(
category_id smallint primary key not null,
category_name varchar(20) not null,
category_code varchar(10) not null,
parent_id smallint default 0 not null,
category_level tinyint default 1 not null--level/ optional field,default three grade classifications
);
insert into A_product_category values(1,'products','0000','',0);
insert into A_product_category values(2,'books','0001',1,1);
insert into A_product_category values(3,'software ','0002',1,1);
insert into A_product_category values(4,'philosophy','0003',2,2);
insert into A_product_category values(5,'literature ','0004',2,2);
insert into A_product_category values(6,'utilities','0005',3,2)
insert into A_product_category values(7,'confucianism','0006',4,3)
create table A_product_info(
pro_id int primary key identity(1,1) not null,
pro_code char(16) not null,
pro_name nvarchar(30),--en
price decimal(18,3),
description nvarchar(50),
manu_id int not null foreign key references A_manufacturer_info(manu_id),
one_category_id smallint not null,--one level category id / optional field
two_category_id smallint not null,-- optional field
thr_category_id smallint not null-- optional field
);
insert into A_product_info values('pro0','metaphysics',45.97,'metaphysics',1,2,4,0);
insert into A_product_info values('pro1','mencius',45.47,'mencius',1,2,4,7);
insert into A_product_info values('pro2','lin_yutang',65.9,'lin yutang',2,2,5,0);
insert into A_product_info values('pro3','file_management',542.5,'file management',3,3,6,0);
2.2 table view
A_product_category:

A_product_info:

A_manufacturer_info

3.retrieve all n-level category products recursively
3.1 sql
WITH TEST_CTE
AS
(
select category_name , parent_id ,category_id,Cast(category_id as nvarchar(4000)) as route, Cast(category_name as nvarchar(4000)) as path from A_product_category where A_product_category.parent_id=1
union all
select t.category_name ,t.parent_id , t.category_id ,CTE.route+'-'+Cast(t.category_id as nvarchar(4000)) ROUTE,CTE.path+'-'+Cast(t.category_name as nvarchar(4000)) PATH
from A_product_category t join TEST_CTE CTE on t.parent_id = CTE.category_id
)
SELECT t.path ,p.pro_name FROM TEST_CTE t join A_product_info p on p.two_category_id=category_id where p.one_category_id=2 and p.thr_category_id=0 --two level category
union SELECT t.path ,p.pro_name FROM TEST_CTE t join A_product_info p on p.thr_category_id=category_id --three level category
union SELECT t.path ,p.pro_name FROM TEST_CTE t join A_product_info p on p.two_category_id=category_id where p.one_category_id=3 and p.thr_category_id=0
--order by t.parent_id desc,t.category_id
OPTION(MAXRECURSION 10)
3.2 result view

A2:
1. demo:

<form id="form1" runat="server">
<div>
<br />
User: <asp:TextBox ID="TextBox1" value="johnsmith" style="width: 192px" runat="server"></asp:TextBox>
<br />
<br />
Message: <textarea id="TextArea1" runat="server"></textarea>
<asp:Button ID="Button3" runat="server" Text="contact us" OnClick="Button3_Click" />
</div>
</form>
2.code-behind implementation:
public class MailInput
{
public MailInput()
{
}
public string MailFrom;
public string MailTo;
public string MailName;
public string MailCc;
public string MailSubject;//邮件主题
public string MailBody;//邮件内容
public string Link;
public string MailAppId;
public string MailBCC;
// public string lang;
// public string MailToName;
}
protected void Button3_Click(object sender, EventArgs e)
{
MailInput mailInput = new MailInput();
mailInput.MailTo = "wh.lu@asmpt.com";
mailInput.MailName = "Dear HR";
mailInput.MailFrom = TextBox1.Text.ToLower().ToString().Trim()+"@reasonables.com";
bool flag = false;
mailInput.MailSubject = "Test for Net.Mail";
mailInput.MailBody = "<font face=Arial size=2><br>" + mailInput.MailName + ":<br><br>"
+ " " + TextArea1.InnerText + "<br><br>" + "Best Regards," + "<br><br>"
+ TextBox1.Text.ToString();
SendEmailWS.SendEmailWS s= new SendEmailWS.SendEmailWS();
List<string[]> header = new List<string[]> { new string[] { "h1", "any_header"} };
s.Send_Email_Header(header, mailInput.MailFrom, mailInput.MailTo, mailInput.MailCc, mailInput.MailBCC, mailInput.MailSubject, mailInput.MailBody, 1, true, "10008499", "ReworkOperationSystem");
}
public string[] Send_Email_Header(List<String[]> mail_header, string mail_from, string mail_to, string mail_cc, string mail_bcc, string mail_subj, string mail_body, int priority, bool IsLogBody, string strRequester, string strAppName)
{
IDictionary<string, string> header = null;
if (mail_header != null)
{
header = new Dictionary<string, string>();
foreach (string[] temp in mail_header)
{
header.Add(temp[0], temp[1]);
}
}
return SendEmail(header, mail_from, mail_to, mail_cc, mail_bcc, mail_subj, mail_body, priority, IsLogBody, null, strRequester, strAppName);
}
private string[] SendEmail(IDictionary<string, string> mail_header, string mail_from, string mail_to, string mail_cc, string mail_bcc, string mail_subj, string mail_body, int priority, bool IsLogBody, ISet<string> att_path, string strRequester, string strAppName)
{
string[] ret_msg = new string[2];
ret_msg[0] = "S";
IsEmailTest(ref mail_from, ref mail_to, ref mail_cc, ref mail_bcc, ref mail_body);
if (string.IsNullOrWhiteSpace(strRequester))
{
ret_msg[0] = "E";
ret_msg[1] = "Requester is required";
return ret_msg;
}
if (string.IsNullOrWhiteSpace(strAppName))
{
ret_msg[0] = "E";
ret_msg[1] = "Application name is required";
return ret_msg;
}
/*
if (!WebService1.SecurityHandler.IsAuthRight(GetHostName(Context.Request.UserHostName), strAppName.Trim()))
{
ret_msg[0] = "E";
ret_msg[1] = "Access denied: " + GetHostName(Context.Request.UserHostName) + " app:" + strAppName;
WriteLog(mail_from, mail_to, mail_subj, mail_body, strRequester, strAppName, IsLogBody, ret_msg[1].ToString());
SendAdmin(strAppName);
//return ret_msg;
}*/
try
{
System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
if (string.IsNullOrWhiteSpace(mail_from))
{
mail_from = ConfigurationManager.AppSettings["mailFrom"];
}
else
{
mail_from = mail_from.Trim(new char[] { ',', ' ', ';' });
}
string fromnames = "Jhon Smith";
MailAddress from = new MailAddress(mail_from, fromnames);//邮件来源地址。
mailMessage.From = from;
if (mail_to == null)
{
ret_msg[0] = "E";
ret_msg[1] = "Mail to is required";
return ret_msg;
}
else
{
mail_to = mail_to.Replace(';', ',').Trim(new char[] { ',', ' ' });
if (string.IsNullOrEmpty(mail_to))
{
ret_msg[0] = "E";
ret_msg[1] = "Mail to is required";
return ret_msg;
}
}
mailMessage.To.Add(mail_to);
if (mail_header != null)
{
foreach (KeyValuePair<string, string> temp in mail_header)
{
mailMessage.Headers.Add(temp.Key, temp.Value);
}
}
if (mail_cc != null)
{
mail_cc = mail_cc.Replace(';', ',').Trim(new char[] { ',', ' ' });
if (!string.IsNullOrEmpty(mail_cc))
{
mailMessage.CC.Add(mail_cc);
}
}
if (mail_bcc != null)
{
mail_bcc = mail_bcc.Replace(';', ',').Trim(new char[] { ',', ' ' });
if (!string.IsNullOrEmpty(mail_bcc))
{
mailMessage.Bcc.Add(mail_bcc);
}
}
mailMessage.Subject = mail_subj;
mailMessage.Body = mail_body;
mailMessage.IsBodyHtml = true;
mailMessage.BodyEncoding = System.Text.Encoding.GetEncoding("utf-8");
switch (priority)
{
case 0: mailMessage.Priority = System.Net.Mail.MailPriority.Low;
break;
case 1: mailMessage.Priority = System.Net.Mail.MailPriority.Normal;
break;
case 2: mailMessage.Priority = System.Net.Mail.MailPriority.High;
break;
default: mailMessage.Priority = System.Net.Mail.MailPriority.Normal;
break;
}
if (att_path != null)
{
foreach (string temp in att_path)
{
mailMessage.Attachments.Add(new System.Net.Mail.Attachment(temp));
}
}
mailMessage.Sender = new MailAddress("web@reasonables.com");
//初始化 SmtpClient 类的新实例。
System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient();
mailClient.Host = "127.0.0.1";//ConfigurationManager.AppSettings["mailSvr"];
mailClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.PickupDirectoryFromIis;
mailClient.Send(mailMessage);
//mailMessage.Attachments.Dispose(); //一定要释放该对象,否则无法删除附件
//WriteLog(mail_from, mail_to, mail_subj, mail_body, strRequester, strAppName, IsLogBody);
#region
//alternative way
//System.Web.Mail.MailMessage mailmsg = new System.Web.Mail.MailMessage();
//mailmsg.Subject = "Test for Web.Mail"; mailmsg.From = ConfigurationManager.AppSettings["mailFrom"];
//mailmsg.To = "wh.lu@asmpt.com";
//mailmsg.BodyFormat = System.Web.Mail.MailFormat.Html;
//mailmsg.BodyEncoding = System.Text.Encoding.GetEncoding("utf-8");
//mailmsg.Body = "anybody";
//System.Web.Mail.SmtpMail.SmtpServer = "127.0.0.1";
//System.Web.Mail.SmtpMail.Send(mailmsg);
#endregion
}
catch (Exception ex)
{
ret_msg[0] = "E";
ret_msg[1] = ex.ToString();
//WriteExceptionLog(ex, mail_from, mail_to, mail_subj, mail_body, strRequester, strAppName, IsLogBody);
}
return ret_msg;
}
3. result
3.1 email content format:

3.2 email header:
Received: from ******.com (*.1*.1.*0) by
*****.com (1*.1.*0) with Microsoft SMTP Server id
1*.3.*68.0; Mon, 24 Aug 2020 21:32:30 +0800
Received: from mail pickup service by *****.com with Microsoft
SMTPSVC; Mon, 24 Aug 2020 21:32:30 +0800
h1: any_header
MIME-Version: 1.0
Sender: <web@reasonables.com>
From: Jhon Smith <smith@reasonables.com>
To: <wh.lu@**.com>
Date: Mon, 24 Aug 2020 21:32:29 +0800
Subject: Test for Net.Mail
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: base64
Message-ID: <****5t8NlqD000038df@*****.com>
X-OriginalArrivalTime: 24 Aug 2020 13:32:30.0078 (UTC) FILETIME=[**91E0:01D***B]
Return-Path: web@reasonables.com
X-MS-Exchange-Organization-AuthSource: ****.com
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 10
X-MS-Exchange-Organization-AVStamp-Mailbox: SMEX{~Ks;1618300;0;This mail has
been scanned by Trend Micro ScanMail for Microsoft Exchange;
X-MS-Exchange-Organization-SCL: 0
Answers for Q1 and Q2的更多相关文章
- CS231n -Assignments 1 Q1 and Q2
前言 最近在youtube 上学习CS231n的课程,并尝试完成Assgnments,收获很多,这里记录下过程和结果以及过程中遇到的问题,我并不是只是完成需要补充的代码段,对于自己不熟悉的没用过的库函 ...
- Black Box 分类: POJ 栈和队列 2015-08-05 14:07 2人阅读 评论(0) 收藏
Black Box Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 8754 Accepted: 3599 Description ...
- 2014北邮新生归来赛解题报告d-e
D: 399. Who Is Joyful 时间限制 3000 ms 内存限制 65536 KB 题目描述 There are several little buddies standing in a ...
- hdu3713 Double Maze
Problem Description Unlike single maze, double maze requires a common sequence of commands to solve ...
- POJ2104 K-th Number [整体二分]
题目传送门 K-th Number Time Limit: 20000MS Memory Limit: 65536K Total Submissions: 69053 Accepted: 24 ...
- HDU4261 Estimation
题意 Estimation Time Limit: 40000/15000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others ...
- POJ 1984 Navigation Nightmare 【经典带权并查集】
任意门:http://poj.org/problem?id=1984 Navigation Nightmare Time Limit: 2000MS Memory Limit: 30000K To ...
- POJ2104 K-th Number —— 区间第k小 整体二分
题目链接:https://vjudge.net/problem/POJ-2104 K-th Number Time Limit: 20000MS Memory Limit: 65536K Tota ...
- Spark MLlib LDA 源代码解析
1.Spark MLlib LDA源代码解析 http://blog.csdn.net/sunbow0 Spark MLlib LDA 应该算是比較难理解的,当中涉及到大量的概率与统计的相关知识,并且 ...
随机推荐
- 第一章 Java快速入门
1.1.安装开发环境 第一步:打开下载地址,下载对应平台的 JDK 安装包 第二步:打开下载软件,全部默认下一步傻瓜式安装 1.2.配置环境变量 第一步:配置JAVA_HOME 第二步:配置CLASS ...
- Oracle Dataguard故障转移(failover)操作
注意:故障转移会破坏DG的主从关系,使其变为互不相关的2个数据库,谨慎使用. (一)故障转移操作流程图 (二)故障转移操作流程 备注:以下操作步骤与上面流程图步骤一一对应 STEP1:刷新所有未发送到 ...
- Day08_商品规格管理
学于黑马和传智播客联合做的教学项目 感谢 黑马官网 传智播客官网 微信搜索"艺术行者",关注并回复关键词"乐优商城"获取视频和教程资料! b站在线视频 0.学习 ...
- 巩固复习(Hany驿站原创)_python的礼物
Python编程语言简介 https://www.cnblogs.com/hany-postq473111315/p/12256134.html Python环境搭建及中文编码 https://www ...
- Kylin Flink Cube 引擎的前世今生
Apache Kylin™ 是一个开源的.分布式的分析型数据仓库,提供 Hadoop/Spark 之上的 SQL 查询接口及多维分析(OLAP)能力以支持超大规模数据,它能在亚秒内查询巨大的表. Ky ...
- PHP uksort() 函数
------------恢复内容开始------------ 实例 使用用户自定义的比较函数对数组 $arr 中的元素按键名进行排序: <?phpfunction my_sort($a,$b){ ...
- PHP unpack() 函数
实例 从二进制字符串对数据进行解包: <?php$data = "PHP";print_r(unpack("C*",$data));?>高佣联盟 w ...
- [NLP]LSTM理解
简介 LSTM(Long short-term memory,长短期记忆)是一种特殊的RNN,主要是为了解决长序列训练过程中的梯度消失问题.以下先从RNN介绍. 简说RNN RNN(Recurrent ...
- boost之signal的使用
文章目录 简介 代码 模板实现: 测试代码 运行结果 简介 boost是C++的一个扩展库,被称为C++准标准库,里面的组件很丰富,并且引用方便,85%的组件只需要引用头文件即可使用. 并且在嵌入式系 ...
- 开源丨CloudBase CMS 内容管理系统!简单易用企业内容管理流
背景 云开发CloudBase CMS 是云开发推出的一站式云端内容管理系统,助力企业的数据运营管理工作. 开发者可以直接在云开发扩展能力中一键安装 CloudBase CMS,免费使用 CloudB ...