Example #1
0
        /// <summary>
        /// 记录用户及项目的相关数据到表中
        /// </summary>
        private void RecordInfoToTable(DisposeSdsite sdsite)
        {
            string sql   = "select * from project where ProjectID=?_id";
            object value = DataAccess.SExecuteScalar(sql, _projectID);

            if (value != null)
            {
                //在其中一表中修改其相应的记录

                string updateSql = "update project set Publisher=?_publisher,PublisherIP=?_publisherIp,ProjectName=?name,"
                                   + "SoftwareVersion=?_softwareVersion,ProjectVersion=?_projectVersion,ServerVersion=?_serverVersion,"
                                   + "ProjectUpdateTime=?_startTime,IncludeFileAmount=?_includeFileAmount,Size=?_size,SizeOnDisk=?_sizeOnDisk,"
                                   + "TempletAmount=?_templetAmount,ChannelAmount=?_channelAmount,PageAmount=?_pageAmount,ResourceFileAmount=?_resourceFileAmount,"
                                   + "ProjectSavedPath=?_projectSavedPath,ProjectBuildedPath=?_projectBuildedPath,BuildedFileAmount=?_buildedFileAmount,"
                                   + "BuildedSize=?_buildedSize,BuildedSizeOnDisk=?_buildedSizeOnDisk where ProjectID=?_projectID";
                try
                {
                    int i = DataAccess.SExecuteNonQuery(updateSql, _publisherID, _publisherIP, _projectName, _softwareVersion, _projectVersion,
                                                        _serverVersion, _startTime, sdsite._includeFileAmount, _size, _sizeOnDisk, sdsite._templetAmount, sdsite._channelAmount,
                                                        sdsite._pageAmount, sdsite._resourceFileAmount, _projectSavedPath, _projectBuildedPath, _buildedFileAmount, _buildedSize, _buildedSizeOnDisk, _projectID);
                }
                catch (Exception ex)
                {
                    LogService.WriteServerRunLog(LogLevel.Fail, ex.GetType().FullName + ":" + ex.Message + "\r\n" + ex.StackTrace);
                }
            }
            else
            {
                string insertSql = "insert into project(Publisher,PublisherIP,ProjectID,ProjectName,SoftwareVersion,ProjectVersion,ServerVersion,"
                                   + "ProjectCreateTime,ProjectPublishTime,ProjectUpdateTime,ProjectDeleteTime,IncludeFileAmount,Size,SizeOnDisk,TempletAmount,"
                                   + "ChannelAmount,PageAmount,ResourceFileAmount,ProjectSavedPath,ProjectBuildedPath,BuildedFileAmount,BuildedSize,BuildedSizeOnDisk)"
                                   + " values(?rr,?ab,?aa,?a,?b,?c,?d,?ii,?e,?f,?g,?h,?r,?u,?i,?o,?p,?m,?z,?x,?k,?j,?y)";
                try
                {
                    int i = DataAccess.SExecuteNonQuery(insertSql, _publisherID, _publisherIP, _projectID, _projectName, _softwareVersion,
                                                        _projectVersion, _serverVersion, sdsite._projCreateTime, sdsite._publishTime, _startTime, _deleteTime, sdsite._includeFileAmount,
                                                        _size, _sizeOnDisk, sdsite._templetAmount, sdsite._channelAmount, sdsite._pageAmount, sdsite._resourceFileAmount, _projectSavedPath,
                                                        _projectBuildedPath, _buildedFileAmount, _buildedSize, _buildedSizeOnDisk);
                }
                catch (Exception ex)
                {
                    LogService.WriteServerRunLog(LogLevel.Fail, ex.GetType().FullName + ":" + ex.Message + "\r\n" + ex.StackTrace);
                }
            }
        }
Example #2
0
        /// <summary>
        /// 处理文件类型消息
        /// </summary>
        private void DealWithFileMessage(NetworkStream stream, FileMessageBag fileMsgBag)
        {
            //处理直接发送file包的情况(未经过用户验证)
            if (!_isRealUser)
            {
                return;
            }

            ///将当前上传文件加入待显示的字典
            string fileUrl = fileMsgBag.FileUrl;

            DisposeUserMethod.SetUserCurrentFile(fileUrl);

            ///接收文件
            byte[] fileContent = fileMsgBag.FileBody;

            if (FileSave(fileContent, fileUrl))
            {
                /// 向客户端发送文件url,表示此文件接收成功
                SendResponseMessage(stream, MessageType.FileReceive, fileUrl, 2);

                /// 还没接收完,继续接收
                if (_fileCount != _Total)
                {
                    GetMessage();
                }
                /// 接收完全,返回OK
                else
                {
                    //此信息写入日志
                    _receivedTime = DateTime.Now.ToString() + "." + DateTime.Now.Millisecond.ToString();


                    ///给客户端发送OK消息,表示所有文件接收完成
                    SendResponseMessage(stream, MessageType.FileReceive, string.Empty, 1);

                    LogService.WriteServerRunLog(LogLevel.Info, "来自" + _publisherIP + "的所有文件接收完成,开始整理接收的网站");

                    //将接收到的文件复制到相应的位置
                    DisposeSdsite disposeSdsite = new DisposeSdsite();

                    if (!disposeSdsite.ExecuteSdsite(_userFilePath, _projectName))
                    {
                        SendResponseMessage(stream, MessageType.FileTidy, string.Empty, 0);
                        return;
                    }
                    LogService.WriteServerRunLog(LogLevel.Info, "来自" + _publisherIP + "的sdsite文件已整理完毕,开始生成可浏览的网站");

                    //接收完毕,开始生成
                    //try
                    //{
                    //    //初始一下当前网站的根路径
                    //    string initPath = AnyFilePath.GetWebAbsolutePath(_userFilePath);
                    //    ToHtmlDirectoryService.InitializePath(initPath);

                    //    BuildSite buildSite = new BuildSite();

                    //    if (!buildSite.StartBuild(_userFilePath, _projectName))
                    //    {
                    //        SendResponseMessage(stream, MessageType.SiteBuild, string.Empty, 0);
                    //        return;
                    //    }
                    //}
                    //catch (Exception e)
                    //{
                    //    ExceptionService.WriteExceptionLog(e);
                    //    SendResponseMessage(stream, MessageType.SiteBuild, string.Empty, 0);
                    //    return;
                    //}

                    LogService.WriteServerRunLog(LogLevel.Info, "来自" + _publisherIP + "的sdsite文件,其网站生成完毕");

                    //此信息写入日志
                    _buildedTime = DateTime.Now.ToString() + "." + DateTime.Now.Millisecond.ToString();


                    //生成成功   返回消息;不管网站是否有同名,都将返回一个值(空,或是新网站名,或是原本的网站名)
                    SendResponseMessage(stream, MessageType.SiteBuild, _changedProjName, 1);

                    DisposeUserMethod.DeleteUser();
                    Client.Client.Close();

                    RecordLogToTable();

                    RecordInfoToTable(disposeSdsite);
                }
            }
        }