Beispiel #1
0
        /// <summary>
        /// 处理网站的主方法
        /// </summary>
        /// <param name="sdPath">.sdsite的文件夹路径如zha\zhangling\projectname</param>
        /// <param name="projName">.sdsite的名projName</param>
        public bool ExecuteSdsite(string partPath, string projName)
        {
            try
            {
                string sdPath = AnyFilePath.GetTempFolderAbsolutePath(partPath) + projName + ".sdsite";
                //打开网站
                SdsiteDocument = new SdsiteXmlDocument(sdPath);
                SdsiteDocument.Load();

                _dealwithFileOrFolder             = new DealWithFileOrFolder();
                _dealwithFileOrFolder.SdsitesPath = partPath;

                #region  add by zhangling on 2008年6月23日
                //得到项目的创建时间
                string   _createTime = SdsiteDocument.DocumentElement.GetAttribute("createTime");
                DateTime dt;
                if (DateTime.TryParse(_createTime, out dt))
                {
                    _projCreateTime = DateTime.Parse(_createTime);
                }
                _projCreateTime = dt;
                //得到项目的发布时间
                string   _pubTime = SdsiteDocument.DocumentElement.GetAttribute("pubTime");
                DateTime _publishDt;
                if (DateTime.TryParse(_pubTime, out _publishDt))
                {
                    _publishTime = DateTime.Parse(_pubTime);
                }
                _publishTime = _publishDt;
                #endregion

                FolderXmlElement channelRootEle = SdsiteDocument.RootChannel;

                //做相应处理
                SearchAndProcess(channelRootEle);

                ///移动.sdsite
                ///modified by zhangling on 2008年6月12日
                string sourceFilePath = AnyFilePath.GetTempFolderAbsolutePath(partPath) + projName + ".sdsite";
                string targetFilePath = AnyFilePath.GetSdsitesFolderAbsolutePath(partPath) + projName + ".sdsite";
                FileService.FileMove(sourceFilePath, targetFilePath);

                //删除时出错
                FolderService.FolderDelete(AnyFilePath.GetTempFolderAbsolutePath(partPath));

                return(true);
            }
            catch (Exception ex)
            {
                ExceptionService.WriteExceptionLog(ex);
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 保存文件
        /// </summary>
        /// <param name="fileContent"></param>
        /// <returns></returns>
        private bool FileSave(byte[] fileContent, string fileUrl)
        {
            try
            {
                ///保存到临时文件夹
                ///modified by zhangling on 2008年6月12日
                string _fileUrl = Path.Combine(AnyFilePath.GetTempFolderAbsolutePath(_userFilePath), fileUrl);
                FileService.FileSave(fileContent, _fileUrl);

                ///接收到的文件数+1
                _fileCount += 1;

                ///总结接收文件的字节数
                _uploadFileBytesAmount += fileContent.Length;
                return(true);
            }
            catch (Exception e)
            {
                ExceptionService.WriteExceptionLog(e);
                return(false);
            }
        }
Beispiel #3
0
        //SdsiteXmlDocument sdsiteDocument;

        /// <summary>
        /// 开始生成网站
        /// </summary>
        /// <returns></returns>
        public bool StartBuild(string partPath, string projName)
        {
            string sdPath    = AnyFilePath.GetSdsitesFolderAbsolutePath(partPath);
            string buildPath = AnyFilePath.GetWebAbsolutePath(partPath);

            toHtmlHelperObj = new ToHtmlHelper(sdPath, buildPath);

            resStartPath = sdPath + @"Root\" + @"Resource";
            resToPath    = buildPath + @"\Resource";

            buildFile = new BuildFile();
            buildFile.SdsiteDocument  = toHtmlHelperObj.SdsiteXmlDocument;
            buildFile.ToHtmlHelperObj = toHtmlHelperObj;

            FolderXmlElement channelRootEle = toHtmlHelperObj.SdsiteXmlDocument.RootChannel;

            //string sdPath = AnyFilePath.GetSdsitesFolderAbsolutePath(partPath) + projName + ".sdsite";
            ////打开网站
            //this.sdsiteDocument = new SdsiteXmlDocument(sdPath);
            //this.sdsiteDocument.Load();
            //buildFile = new BuildFile();
            //buildFile.SdsiteDocument = this.sdsiteDocument;
            //buildFile.BuildFilePath = partPath;
            //FolderXmlElement channelRootEle = this.sdsiteDocument.RootChannel;

            try
            {
                SearchAndProcess(channelRootEle);

                return(true);
            }
            catch (Exception Ex)
            {
                ExceptionService.WriteExceptionLog(Ex);
                return(false);
            }
        }