예제 #1
0
        public static string LoadRefreshCycle()
        {
            string path = Application.StartupPath + "\\SysConfig\\RefreshCycle.txt";
            string info = FileOperate.ReadFile(path);

            return(info);
        }
예제 #2
0
    private void Awake()
    {
        var json = FileOperate.ReadFileToString("arpg/Code/Json/demo/txt/equip.json");

        JsonParseError jsonError = new JsonParseError();
        JsonDocument   document  = JsonDocument.fromJson(json, ref jsonError);

        if (jsonError.error == ParseError.NoError)
        {
            if (document.isObject())
            {
                var o = document.toObject();
                foreach (var item in o.keys())
                {
                    var v = o.value(item);
                    if (v.isArray())
                    {
                        var a = v.toArray();
                        foreach (var t in a.all())
                        {
                            if (t.isObject())
                            {
                                Debug.Log(t.toObject().value("name").toString());
                            }
                        }
                    }
                }
            }
        }
    }
예제 #3
0
        public async Task <bool> DeleteArticle(int articleId)
        {
            //文章Id必须要符合规范
            if (articleId <= 0)
            {
                _logger.LogError("传入文章Id不合规范");
                return(false);
            }

            //首先删除Redis缓存中的记录
            string redisArticleKey = PostConsts.ArticleBaseKey + articleId;
            await _cacheManager
            .GetCache(PostConsts.RedisForArticleStore)
            .RemoveAsync(redisArticleKey);

            //获取指定文章
            Article article = await _articleRepository
                              .FirstOrDefaultAsync(a => a.Id == articleId);

            if (article != null)
            {
                //删除数据库中的记录
                await _articleRepository.DeleteAsync(article);
            }

            //删除指定路径的存储在硬盘上的文章
            await FileOperate.DeleteArticleAsync(article.ArticleUrl, _logger);

            //删除评论区
            await _commentRepository.DeleteCommentAreaAsync(articleId.ToString());

            return(true);
        }
예제 #4
0
        public JsonResult UpdateDZControl()
        {
            JsonResult jsonResult;
            string     item = base.Request.Form["key"];

            if (string.IsNullOrEmpty(item))
            {
                return(base.Json(new { Code = 1, Msg = "签名错误" }));
            }
            if (FormsAuthentication.HashPasswordForStoringInConfigFile(item, "MD5") != this.myKey)
            {
                return(base.Json(new { Code = 1, Msg = "签名错误" }));
            }
            int num  = Convert.ToInt32(base.Request.Form["sid"]);
            int num1 = Convert.ToInt32(base.Request.Form["winRate"]);

            try
            {
                FileOperate.IniWriteValue(num.ToString(), "WinRate", num1.ToString(), this.dzPath);
                jsonResult = base.Json(new { Code = 0, Msg = "操作成功" });
            }
            catch (Exception exception)
            {
                jsonResult = base.Json(new { Code = 1, Msg = string.Concat("请检查文件", this.dzPath, "是否有写入权限") });
            }
            return(jsonResult);
        }
예제 #5
0
 /// <summary>
 /// 删除过期广告
 /// </summary>
 public void AdvertOverTime()
 {
     try
     {
         string error = "";
         List <AMS_Advertisement> modelList = SeatManage.Bll.AdvertisementOperation.GetAdList(true, AdType.None);
         foreach (AMS_Advertisement model in modelList.Where(model => model.Type != AdType.SchoolNotice))
         {
             model.ImageFilePath = AMS_Advertisement.GetDownloadFile(model.AdContent);
             foreach (string file in model.ImageFilePath.Where(file => !FileOperate.FileDelete(file, (SeatManage.EnumType.SeatManageSubsystem)System.Enum.Parse(typeof(SeatManage.EnumType.SeatManageSubsystem), model.Type.ToString()))))
             {
                 WriteLog.Write(string.Format("删除过期广告处理遇到异常:文件{0}删除失败", file));
             }
             error = SeatManage.Bll.AdvertisementOperation.DeleteAdModel(model);
             if (!string.IsNullOrEmpty(SeatManage.Bll.AdvertisementOperation.DeleteAdModel(model)))
             {
                 WriteLog.Write(string.Format("删除过期广告处理遇到异常:{0}", error));
             }
         }
     }
     catch (Exception e)
     {
         WriteLog.Write(string.Format("删除过期广告处理遇到异常:{0}", e.Message));
     }
 }
예제 #6
0
 /// <summary>
 /// 导出离线版本
 /// </summary>
 public bool DownloadPlaylist(string downloadpath)
 {
     try
     {
         downloadpath = downloadpath + "\\MediaPlaylist_" + ServerDateTime.Now.Value.ToShortDateString();
         DirectoryInfo dir = new DirectoryInfo(downloadpath);
         if (!dir.Exists)
         {
             dir.Create();
         }
         else
         {
             throw new Exception("存在相同的文件夹,请重新选择目录!");
         }
         AMS_PlayListMd5Model model = AMS_PlayListMd5Model.Parse(ToModel().ToXml());
         model.Id          = _id;
         model.ReleaseDate = _SubmitDate;
         if (!string.IsNullOrEmpty(_Number) && _ItemList.Count > 0 && (_BeginDate < _EndDate))
         {
             foreach (AMS_VideoMd5Item item in model.VideoFiles)
             {
                 if (item.RelativeUrl == item.Name)
                 {
                     FileOperate fo = new FileOperate();
                     if (!fo.FileDownLoad(downloadpath + "\\" + item.RelativeUrl, item.RelativeUrl, SeatManage.EnumType.SeatManageSubsystem.MediaFiles))
                     {
                         throw new Exception("文件" + item.Name + "离线保存失败!");
                     }
                 }
                 else
                 {
                     File.Copy(item.RelativeUrl, downloadpath + "\\" + item.Name);
                 }
                 foreach (AMS_VideoMd5Item videoitem in model.PlayVideoItems)
                 {
                     videoitem.RelativeUrl = videoitem.Name;
                     videoitem.md5value    = videoitem.md5value;
                 }
             }
             string xml     = model.ToXml();
             string xmlpath = downloadpath + "\\playList.xml";
             //写入文件
             FileStream   fs = new FileStream(xmlpath, FileMode.Create, FileAccess.Write);
             StreamWriter sw = new StreamWriter(fs);
             sw.Write(xml);
             sw.Close();
             fs.Close();
             return(true);
         }
         else
         {
             throw new Exception("信息填写错误!请仔细检查!");
         }
     }
     catch (Exception ex)
     {
         System.Windows.Forms.MessageBox.Show(ex.Message);
         return(false);
     }
 }
예제 #7
0
        public JsonResult UpdateBRControl()
        {
            JsonResult jsonResult;
            string     item = base.Request.Form["key"];

            if (string.IsNullOrEmpty(item))
            {
                return(base.Json(new { Code = 1, Msg = "签名错误" }));
            }
            if (FormsAuthentication.HashPasswordForStoringInConfigFile(item, "MD5") != this.myKey)
            {
                return(base.Json(new { Code = 1, Msg = "签名错误" }));
            }
            int     num  = Convert.ToInt32(base.Request.Form["sid"]);
            int     num1 = Convert.ToInt32(base.Request.Form["StorageDeduct"]);
            decimal num2 = Convert.ToDecimal(base.Request.Form["StorageStart"]);

            try
            {
                FileOperate.IniWriteValue(num.ToString(), "StorageDeduct", num1.ToString(), this.brPath);
                if (num2 != new decimal(0))
                {
                    decimal num3 = Convert.ToDecimal(FileOperate.IniReadValue(num.ToString(), "StorageStart", this.brPath));
                    string  str  = num.ToString();
                    decimal num4 = num3 + num2;
                    FileOperate.IniWriteValue(str, "StorageStart", num4.ToString(), this.brPath);
                }
                jsonResult = base.Json(new { Code = 0, Msg = "操作成功" });
            }
            catch (Exception exception)
            {
                jsonResult = base.Json(new { Code = 1, Msg = string.Concat("请检查文件", this.brPath, "是否有写入权限") });
            }
            return(jsonResult);
        }
예제 #8
0
 /// <summary>
 /// 根据ID删除模型中的数据
 /// </summary>
 /// <param name="Info"></param>
 public void ModelDelete(HXD.ModelField.Model.Model Info)
 {
     try
     {
         DataSet ds = HXD.DBUtility.SQLHelper.ExecuteDataset("select * from " + Info.TableName + " where id in(" + Info.Temp + ")");
         for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
         {
             for (int c = 0; c < ds.Tables[0].Columns.Count; c++)
             {
                 if (ds.Tables[0].Rows[i][c].ToString().IndexOf("/") == 0 && ds.Tables[0].Rows[i][c].ToString().Length > 30)
                 {
                     string[] files = ds.Tables[0].Rows[i][c].ToString().Split(',');
                     for (int k = 0; k < files.Length; k++)
                     {
                         if (files[k].IndexOf("/") == 0)
                         {
                             HXD.Common.Utils.DelThumbnail(files[k]); //删除所有缩略图文件
                             FileOperate.DeleteFile(files[k]);        //删除原始文件
                         }
                     }
                 }
                 if (ds.Tables[0].Rows[i][c].ToString().Length > 30)
                 {
                     FileOperate.GetImgTag(ds.Tables[0].Rows[i][c].ToString());//删除内容中的图片
                     //FileOperate.DelFiles(ds.Tables[0].Rows[i][c].ToString(), "url", "flv");//删除内容中的Flv
                 }
             }
         }
         SQLHelper.ExecuteNonQuery("ModelDelete", Info.Temp, Info.TableName);
     }
     catch { }
 }
예제 #9
0
파일: BaseDataMgr.cs 프로젝트: hjj0416/Demo
    public void Save()
    {
        string filePath = Path.Combine(Application.persistentDataPath, file_path);
        string json     = JsonUtility.ToJson(data);

        FileOperate.WriteFile(filePath, json);
    }
예제 #10
0
        /// <summary>
        /// 上传试卷
        /// </summary>
        /// <returns></returns>
        public void UploadExamFile(string studentCode, M_MyJob job, string filePath)
        {
            string state    = string.Empty;
            string rXml     = string.Empty;
            string result   = string.Empty;
            string message  = string.Empty;
            string fileName = string.Empty;

            byte[]        fileByte = null;
            StringBuilder sbParam  = new StringBuilder();

            fileName = Path.GetFileName(filePath);
            fileByte = FileOperate.SetFileToByteArray(filePath);
            sbParam.AppendFormat("<Code>{0}</Code>", studentCode);
            sbParam.AppendFormat("<FileName>{0}</FileName>", fileName);
            sbParam.AppendFormat("<FileID>{0}</FileID>", job.FileID);
            sbParam.AppendFormat("<HWID>{0}</HWID>", job.HWID);
            rXml   = publicClass.ReturnRequest(sbParam.ToString(), Globals.CODE_UploadExamFile);
            result = Globals.SERVICE.examupload(rXml, Globals.CODE_UploadExamFile, fileByte);

            if (publicClass.IsRight(result))
            {
                state = xmlUnit.GetXmlNodeValue(result, "state");
            }
            else
            {
                message = errorMessage;
            }
        }
예제 #11
0
        public void Execute(IJobExecutionContext context)
        {
            var           dbName      = ConfigurationManager.AppSettings["ReductDbName"];
            var           openAway    = ConfigurationManager.AppSettings["ReductOpenAway"];
            var           dbName_Data = ConfigurationManager.AppSettings["ReductDataPath"];
            var           dbName_Log  = ConfigurationManager.AppSettings["ReductLogPath"];
            var           movePath    = ConfigurationManager.AppSettings["ReductMovePath"];
            IReductSqlBLL bll         = new ReductSqlBLL();

            try
            {
                var dbFile = FileOperate.GetLatestFileTimeInfo(openAway, ".bak");
                if (dbFile != null)
                {
                    FlashLogger.Info(string.Format("最新备份文件[{0}],\r\n数据库[{1}]\r\n正在还原中...", dbFile.FullName, dbName));
                    FlashLogger.Info(bll.ReductGo(dbName, dbFile.FullName));
                    FlashLogger.Info(string.Format("开始移动数据库备份文件,\r\n[{0}]\r\n   --->\r\n[{1}]", dbFile.FullName, movePath + dbFile.Name));
                    FileOperate.FileMove(dbFile.FullName, movePath + dbFile.Name);
                    FlashLogger.Info("删除目录下多余的备份文件!");
                    FileOperate.DeleteFolderFiles(openAway);
                    FlashLogger.Info("备份文件还原完毕!");
                }
                else
                {
                    FlashLogger.Error("未找到数据库备份文件,还原失败");
                }
            }
            catch (Exception ex)
            {
                FlashLogger.Error("ReductSqlJob_Execute:" + ex.Message);
            }
        }
예제 #12
0
    //更新服务器列表
    public static UpdateRetCode ParseRoleList(string account, string roleListFile, List <AccountRoleInfo> roleList, List <ServerInfo> testServerList)
    {
        try
        {
            StreamReader reader = FileOperate.OpenTextFile(roleListFile);
            if (reader == null)
            {
                return(UpdateRetCode.role_list_no_file);
            }

            string text = reader.ReadToEnd();
            reader.Close();

            string ext = Path.GetExtension(roleListFile);
            if (ext != null && ext.ToLower() == ".json")  // Unity官方说 string.Equals效率优于string.Compare
            {
                if (!AccountRoleInfo.ParseFromJsonString(account, text, roleList, testServerList))
                {
                    return(UpdateRetCode.role_list_parse_err);
                }
            }
            else
            {
                FileOperate.DeleteFile(roleListFile);
                return(UpdateRetCode.role_list_parse_err);
            }
        }
        catch (Exception e)
        {
            Common.HobaDebuger.LogErrorFormat("An Exception was raised when ParseRoleList, {0}", e);
            return(UpdateRetCode.role_list_parse_err);
        }
        return(UpdateRetCode.success);
    }
예제 #13
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="idList"></param>
        /// <returns></returns>
        public ActionResult Delete(string idList)
        {
            var json = new JsonHelp()
            {
                Status = "n", Msg = "删除失败"
            };

            try
            {
                var list = idList.Split(',');
                foreach (var item in list)
                {
                    var path = Server.MapPath("/backup/" + item);
                    FileOperate.DelFile(path);
                }
                json.Status = "y";
                json.Msg    = "删除成功";
                DB.SysLogs.setAdminLog(Enums.EventType.Backup, "数据库删除成功[" + idList + "]");
            }
            catch (Exception e)
            {
                LogHelper.Error("删除数据库出错:" + e.Message);
            }
            return(Json(json));
        }
예제 #14
0
    public static DownloadTaskErrorCode FetchByUrl(string url, string destFile, int timeout, out string errMsg)
    {
        if (!FileOperate.MakeDir(destFile))
        {
            Common.HobaDebuger.LogWarning(HobaText.Format("[FetchByUrl] MakeDir {0} Failed!", destFile));
        }

        if (FileOperate.IsFileExist(destFile))
        {
            FileOperate.DeleteFile(destFile);
        }

        string hostName = UpdateUtility.GetHostName(url);

        var code = UpdateUtility.GetByUrl(
            url,
            hostName,
            destFile,
            timeout,          //10s
            null,
            null,
            out errMsg);

        return(code);
    }
예제 #15
0
    //解析服务器版本信息
    public UpdateRetCode TryGetLatestVersionFromServer()
    {
        UpdateRetCode code = UpdateRetCode.success;

        try
        {
            StreamReader reader = FileOperate.OpenTextFile(strGameNewVerFile);
            if (reader == null)
            {
                return(UpdateRetCode.patcher_no_ver_file);
            }

            if (!m_VersionMan.LoadVersions(reader))
            {
                reader.Close();
                code = UpdateRetCode.patcher_invalid_ver_file;
                FileOperate.DeleteFile(strGameNewVerFile);
            }
            else
            {
                reader.Close();
            }
        }
        catch (Exception)
        {
            code = UpdateRetCode.patcher_ver_err;
        }


        return(code);
    }
예제 #16
0
    //从服务器下载 version.txt 到 strGameNewVerFile
    public DownloadTaskErrorCode FetchServerVersionFile(string url, string hostName, string savedFile, int timeout, out string errMsg)
    {
        if (!FileOperate.MakeDir(savedFile))
        {
            LogString(HobaText.Format("[FetchServerVersionFile] MakeDir {0} Failed!", savedFile));
        }

        if (FileOperate.IsFileExist(savedFile))
        {
            FileOperate.DeleteFile(savedFile);
        }

        //测试
        //         int filesize2 = (int)SeasideResearch.LibCurlNet.External.CURL_GetUrlFileSize(url, timeout);
        //         LogString(HobaString.Format("c++ url FileSize: {0}, fileSize: {1}", url, filesize2));
        //
        //         int filesize = (int)UpdateUtility.GetUrlFileSizeEx(url, hostName, timeout);
        //         LogString(HobaString.Format("url FileSize: {0}, fileSize: {1}", url, filesize));

        var code = UpdateUtility.GetByUrl(
            url,
            hostName,
            savedFile,
            timeout,          //10s
            null,
            null,
            out errMsg);

        return(code);
    }
예제 #17
0
    private bool GetLocalVersion(out ELEMENT_VER version)
    {
        bool success = false;

        version = new ELEMENT_VER(0, 0, 0, 0);
        string strLine;

        try
        {
            StreamReader reader = FileOperate.OpenTextFile(strGameOldVerFile);
            if (reader == null)
            {
                goto END;
            }

            strLine = reader.ReadLine();
            reader.Close();

            if (strLine != null)
            {
                if (version.Parse(strLine))
                {
                    success = true;
                }
            }
        }
        catch (Exception)
        {
            goto END;
        }
END:
        return(success);
    }
예제 #18
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";



            if (context.Request.QueryString.Count > 0)
            {
                if (context.Request.QueryString["com"] == "delete")
                {
                    if (context.Request.QueryString["path"].Length > 0)
                    {
                        string path = context.Request.QueryString["path"].ToString();
                        if (File.Exists(path))
                        {
                            FileOperate.FileDel(path);
                            if (context.Request.QueryString["page"] == "1")
                            {
                                context.Response.Redirect("~/editor/Editor.aspx");
                            }
                            else
                            {
                                context.Response.Redirect("~/");
                            }
                        }
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var src  = Server.UrlDecode(MyRequest.GetQueryString("src"));
            var name = Server.UrlDecode(MyRequest.GetQueryString("name"));

            if (src != null)
            {
                var fileExt = src.Substring(src.LastIndexOf('.') + 1);
                if (Utils.IsTxtExt(fileExt))
                {
                    //读取文件显示
                    if (File.Exists(Server.MapPath(src)))
                    {
                        ShowFileName(src, name);
                        //var content = FileOperate.Read_Txt(Server.MapPath(src), code);
                        var content = FileOperate.ReadFile(Server.MapPath(src), Encoding.Default);
                        content = content.Replace("\n", "<br />");
                        this.txtContainner.InnerHtml = content;
                        //ResponsePreview(src);
                    }
                    else
                    {
                        this.txtContainner.InnerHtml = "预览文件不存在!";
                    }
                }
            }
        }
예제 #20
0
 void Handler(string logString, string stackTrace, LogType type)
 {
     if (type == LogType.Error || type == LogType.Exception || type == LogType.Assert)
     {
         FileOperate.FileWriteAdd("Log", "log.log", logString);
     }
 }
예제 #21
0
        /// <summary>
        /// 读取配置文件
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public string ReadLogFile(string filePath)
        {
            string log = string.Empty;

            log = FileOperate.ReadFile(filePath);
            return(log);
        }
        //
        // GET: /FileManage/

        public ActionResult FileManage(string path)
        {
            ViewBag.Path = path;
            List <FileShowModel> list = FileOperate.GetFoldAllModel(HttpUtility.UrlDecode(path));

            return(View(list));
        }
        protected void DownLoadFile(String filePath, string fileName)
        {
            if (fileName == "")
            {
                fileName = FileOperate.GetFileName(filePath);
            }
            filePath = Server.MapPath(filePath);
            var file = new System.IO.FileInfo(filePath);

            if (System.IO.File.Exists(filePath) & filePath.Contains("upload"))
            {
                Response.Clear();
                Response.AddHeader("Content-Disposition",
                                   "attachment;   filename=" + HttpUtility.UrlEncode(fileName));
                Response.AddHeader("Content-Length", file.Length.ToString());
                Response.ContentType = "application/octet-stream";
                //Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
                Response.WriteFile(file.FullName);
                Response.Flush();
                //Response.End();
            }
            else
            {
                Response.Write("附件不存在!");
                Response.Flush();
            }
        }
예제 #24
0
        /// <summary>
        /// 获取更新程序
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static bool GetUpgrade(int id)
        {
            Model.ProgramUpgradeModel programModel = BLL.ProgramUpgradeBLL.GetProgramInfoById(id);
            if (programModel != null)
            {
                FileOperate advertfileOperate = new FileOperate();
                SeatManage.EnumType.SeatManageSubsystem systemType = (SeatManage.EnumType.SeatManageSubsystem)(int) programModel.Application;

                SeatManage.Bll.FileOperate           seatmanagefileOperate = new SeatManage.Bll.FileOperate();
                SeatManage.ClassModel.FileUpdateInfo programInfo           = SeatManage.ClassModel.FileUpdateInfo.Convert(programModel.AutoUpdaterXml);
                List <string> filePath = programInfo.BuildUpdateFilePaths();
                foreach (string path in filePath)
                {
                    string fullPath = string.Format("{0}{1}", ServiceSet.TempFilePath, path);
                    //文件下载
                    if (!advertfileOperate.FileDownLoad(fullPath, path, systemType))
                    {
                        return(false);
                    }
                    if (!seatmanagefileOperate.UpdateFile(fullPath, path, systemType))
                    {
                        return(false);
                    }
                }
                //执行完成,不需要更新数据库。
                //上传完毕删除本地的文件以及文件夹。
                SeatManage.ClassModel.FileUpdateInfo.DelDirectorys(ServiceSet.TempFilePath);
                return(true);
            }
            return(true);
        }
 protected void ShowFileName(String inFilePath, String fileName)
 {
     if (fileName == "")
     {
         fileName = FileOperate.GetFileName(inFilePath);
     }
     this.divFileName.InnerText = fileName;
 }
예제 #26
0
 /// <summary>
 /// 下载完成调用
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     //到此则一个文件下载完毕
     DownloadCompliteFileInfo = (SynFileInfo)e.UserState;
     if (DownloadCompliteFileInfo.FileSize != DownloadCompliteFileInfo.Size)
     {
         DownloadCompliteFileInfo.RowObject.Cells["Image"].Value    = Resources.cross;
         DownloadCompliteFileInfo.RowObject.Cells["SynSpeed"].Value = "0%";
         ECON++;
         this.DownloadSize = this.DownloadSize - DownloadCompliteFileInfo.FileSize;
     }
     else
     {
         this.infor.DownloadFileList.Remove(this.infor.DownloadFileList.Where(c => c.Name == DownloadCompliteFileInfo.DocName).FirstOrDefault());
         DownloadCompliteFileInfo.RowObject.Cells["Image"].Value = Resources.tick;
         CON++;
         lbl_SUM.Text = string.Format("文件:{0}/{1}", CON, SUM);
         string  path = "//File[@Name='" + DownloadCompliteFileInfo.DocName + "']";
         XmlNode root = file[2].SelectSingleNode(path);
         if (root == null)
         {
             XmlElement subElement = localDoc.CreateElement("File");
             subElement.SetAttribute("Name", DownloadCompliteFileInfo.DocName);
             subElement.SetAttribute("Version", DownloadCompliteFileInfo.Version);
             subElement.SetAttribute("Size", DownloadCompliteFileInfo.Size.ToString());
             file[2].AppendChild(subElement);
         }
         else
         {
             root.Attributes[1].Value = DownloadCompliteFileInfo.Version;
             root.Attributes[2].Value = DownloadCompliteFileInfo.Size.ToString();
         }
         localDoc.Save(xmlPath);
     }
     m_SynFileInfoList.Remove(DownloadCompliteFileInfo);
     if (m_SynFileInfoList.Count <= 0)
     {
         tr.Abort();
         pb_All.Value  = (int)this.DownloadSize;
         lbl_Size.Text = string.Format("大小:{0}/{1}", FileOperate.GetAutoSizeString(this.DownloadSize, 2), TotalSize);
         if (ECON != 0)
         {
             lbl_Error.Text    = "文件更新失败" + ECON + "个,请尝试重新更新!\n提示:本地网络限制或访问服务器会更新失败";
             lbl_Error.Visible = true;
             btn_OK.Text       = "重新更新";
         }
         else
         {
             CutNewFile();
             CreateDesk();
             CompledUpdate();
         }
         file[0].InnerText = this.version;
         file[1].InnerText = this.remark;
         localDoc.Save(xmlPath);
         btn_OK.Enabled = true;
     }
 }
        protected void ResponsePreview(String pdfFilePath)
        {
            string fileName = FileOperate.GetFileName(pdfFilePath);

            Response.ContentType = "Application/pdf";
            Response.AddHeader("content-disposition", "filename=" + fileName);
            Response.WriteFile(Server.MapPath(pdfFilePath));
            Response.End();
        }
예제 #28
0
        public static void CreateNewsHtml(String newsId, String fileName, bool checkExists)
        {
            if ((!checkExists) || (!System.IO.File.Exists(fileName)))
            {
                var news = new BLL.news.V_NewsInfo().GetModel(Int64.Parse(newsId));
                if (news != null)
                {
                    // 读取模板文件
                    string temp    = HttpContext.Current.Server.MapPath("/home/news/template/news_template.html");
                    String newsStr = FileOperate.ReadFile(temp);
                    newsStr = newsStr.Replace("titlexxx", news.NI_Tile);
                    StringBuilder sb = new StringBuilder();
                    if (news.UI_RealName != "")
                    {
                        sb.Append("<span>发布者:").Append(news.UI_RealName).Append("</span>");
                    }
                    var isCampusCol = IsCampusCol(news.NCh_Id);
                    if (isCampusCol)
                    {
                        var newsChannel = new BLL.news.News_NewsChannel().GetModel(news.NCh_Id);
                        //content += "<p>来源:<a href='" + newsChannel.NCh_RssUrl + "'>" + newsChannel.NCh_Name + "</a></p>";
                        sb.Append("&nbsp;&nbsp;<span>来源:" + newsChannel.NCh_Name + "</span>");
                    }
                    sb.Append("&nbsp;&nbsp;");
                    sb.Append(news.CN_PubDate);
                    //sb.Append("&nbsp;&nbsp;").Append("阅读次数:").Append(news.NI_ReadNum);
                    newsStr = newsStr.Replace("desxxx", sb.ToString());
                    String content = HttpContext.Current.Server.HtmlDecode(news.NI_Content);

                    //newsStr = newsStr.Replace("contentxxx", content);
                    newsStr = newsStr.Replace("contentxxx", NewsHelper.SetHtmlImgWidth(content, "98%", ""));
                    sb.Clear();
                    var newsAttach = new BLL.news.News_NewsInfo().GetModel(Int64.Parse(newsId)).NewsAttach;
                    if (newsAttach != null && newsAttach.Count > 0)
                    {
                        sb.Append("<p class='attachTitle'>附件:</p>");
                        var itemCnt = 1;
                        foreach (var item in newsAttach)
                        {
                            sb.Append("<p class='attachItem'>(").Append(itemCnt).Append(")&nbsp;<a href='")
                            .Append("/home/news/Attach.aspx?id=").Append(DESEncrypt.Encrypt(item.NA_Id.ToString()))
                            .Append("&address=").Append(HttpUtility.UrlEncode(item.NA_Address))
                            .Append("&name=").Append(HttpUtility.UrlEncode(item.NA_Name))
                            .Append("' target='_blank' >")
                            .Append(item.NA_Name)
                            .Append("</a>")
                            .Append(OnlineViewHelper.GetOnlineViewWrapLink(item.NA_Address, item.NA_Name))
                            .Append("</p>");
                            itemCnt++;
                        }
                    }
                    newsStr = newsStr.Replace("attachxxx", sb.ToString());
                    //写文件
                    FileOperate.WriteNewFile(fileName, newsStr);
                }
            }
        }
예제 #29
0
        public ArticleHandler(RuleConfig ruleConfig)
        {
            this._ruleConfig     = ruleConfig;
            this._fileOperate    = new FileOperate();
            this._articleBuilder = new ArticleBuilder();
            this._sqlOperate     = new SqlOperate();

            this._currentRule = new JsonArticleRule(ruleConfig.Rules);
        }
예제 #30
0
    private byte[] LuaScriptsLoader(ref string filepath)
    {
        filepath = filepath.Replace(".", "/") + ".lua";
#if UNITY_EDITOR
        filepath = Path.Combine(luafloder, filepath);
        filepath = Path.Combine(Application.dataPath, filepath);
        return(FileOperate.ReadFileBytes(filepath));
#endif
    }