2021-08-25

项目——视频点播系统

项目描述:
用户可以通过浏览器上传视频,并且对自己上传的视频进行管理,而其他用户可以通过浏览器观看视频
开发环境:
Centos7.5、vim、g++、makefile、gdb、git
重要技术:
基于mysql数据库实现视频数据的管理
使用httplib库实现http服务器的搭建
使用jsoncpp实现json格式的序列化与反序列化
使用前端三剑客(html+css+js)实现前端界面模块的优化
项目功能:
采用不太严谨的MVC 框架将项目实现划分为三个模块
数据管理模块:对数据进行同意管理,外界只能通过这个模块访问
前端界面模块:提供前端界面实现与用户的交互
业务处理模块:接收前端请求进行处理,完成用户的需求
项目实现过程
在mysql中执行语句与保存结果集存在线程安全问题
在查询视频信息中,查询语句执行成功了,但是在还没有保存结果集的时候有可能切换到另一个线程,如果另一个线程也在查询表中的信息,这时就会出问题。
执行语句与保存结果集是一个原子操作,要进行加解锁
Httplib搭建http服务器时对对线程的处理流程:
1.首先进来用户先实例化一个srv,创建一张表.
2.填充表中的路由信息,路由信息就是为了告诉srv对象什么请求调用什么函数,设置路由信息之后搭建tcp服务器,收到一个连接之后启动一个线程去处理这个连接;处理的过程就是先接收请求数据,按照http格式进行解析,解析完毕之后得到一个Request请求信息对象,得到请求信息之后然后在路由表中查找针对这个请求方法以及资源路径有没有一个对应的处理函数,如果没有返回404,如果找到了则调用这个函数(根据请求信息进行业务处理,业务处理完毕后给rsp中填充信息,填充完毕后),函数一旦运行完毕后,则会把Reponse中填充的信息组织成为一个http相应数据发送给客户端.
3.这时一个http请求就处理完成了.

以下是将XML转换为.NET Core实体模型的代码示例: ```csharp using System.Xml.Serialization; [XmlRoot(ElementName = "OTA_InventoryCheckRS")] public class InventoryCheckResponse { [XmlAttribute(AttributeName = "TimeStamp")] public string TimeStamp { get; set; } [XmlAttribute(AttributeName = "Version")] public string Version { get; set; } [XmlAttribute(AttributeName = "EchoToken")] public string EchoToken { get; set; } [XmlElement(ElementName = "HotelResult")] public HotelResult HotelResult { get; set; } } public class HotelResult { [XmlElement(ElementName = "HotelID")] public string HotelID { get; set; } [XmlElement(ElementName = "HotelProducts")] public HotelProducts HotelProducts { get; set; } } public class HotelProducts { [XmlElement(ElementName = "HotelProduct")] public HotelProduct HotelProduct { get; set; } } public class HotelProduct { [XmlElement(ElementName = "FreeCancelable")] public FreeCancelable FreeCancelable { get; set; } [XmlElement(ElementName = "RoomTypes")] public RoomTypes RoomTypes { get; set; } [XmlElement(ElementName = "RatePlans")] public RatePlans RatePlans { get; set; } [XmlElement(ElementName = "Prices")] public Prices Prices { get; set; } } public class FreeCancelable { [XmlAttribute(AttributeName = "FreeCancelableVal")] public string FreeCancelableVal { get; set; } } public class RoomTypes { [XmlElement(ElementName = "RoomType")] public RoomType RoomType { get; set; } } public class RoomType { [XmlAttribute(AttributeName = "RoomTypeCode")] public string RoomTypeCode { get; set; } } public class RatePlans { [XmlElement(ElementName = "RatePlan")] public RatePlan RatePlan { get; set; } } public class RatePlan { [XmlAttribute(AttributeName = "RatePlanCode")] public string RatePlanCode { get; set; } } public class Prices { [XmlElement(ElementName = "Price")] public Price Price { get; set; } } public class Price { [XmlElement(ElementName = "Base")] public Base Base { get; set; } } public class Base { [XmlAttribute(AttributeName = "EffectDate")] public string EffectDate { get; set; } [XmlAttribute(AttributeName = "SalePrice")] public string SalePrice { get; set; } [XmlAttribute(AttributeName = "BasePrice")] public string BasePrice { get; set; } [XmlAttribute(AttributeName = "Allotment")] public string Allotment { get; set; } [XmlAttribute(AttributeName = "DcOverSaleAllotment")] public string DcOverSaleAllotment { get; set; } [XmlAttribute(AttributeName = "DcAddAllotment")] public string DcAddAllotment { get; set; } [XmlAttribute(AttributeName = "DcContractAllotment")] public string DcContractAllotment { get; set; } [XmlAttribute(AttributeName = "DcBuyOutAllotment")] public string DcBuyOutAllotment { get; set; } } ``` 在调用方代码中,您可以使用以下代码将XML转换为.NET Core实体模型: ```csharp string xml = "<OTA_InventoryCheckRS TimeStamp=\"1629879848173\" Version=\"1.000\" EchoToken=\"18029461-194a-4c7e-b372-6eec346cebd4\"> <HotelResult> <HotelID>10000007</HotelID> <HotelProducts> <HotelProduct> <!--只有支持30分钟免费取消的酒店,才需要返回该节点--> <FreeCancelable FreeCancelableVal=\"true\" /> <RoomTypes> <RoomType RoomTypeCode=\"2106\"/> </RoomTypes> <RatePlans> <RatePlan RatePlanCode=\"302-4529\"/> </RatePlans> <Prices> <Price> <Base EffectDate=\"2021-08-25\" SalePrice=\"515.2\" BasePrice=\"515.2\" Allotment=\"53\" DcOverSaleAllotment=\"53\" DcAddAllotment=\"-1\" DcContractAllotment=\"-1\" DcBuyOutAllotment=\"-1\"/> </Price> </Prices> </HotelProduct> </HotelProducts> </HotelResult> </OTA_InventoryCheckRS>"; XmlSerializer serializer = new XmlSerializer(typeof(InventoryCheckResponse)); using StringReader reader = new StringReader(xml); InventoryCheckResponse response = (InventoryCheckResponse)serializer.Deserialize(reader); ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值