Example #1
0
        /// <summary>
        /// 生成控制器
        /// </summary>
        /// <param name="table">表名</param>
        /// <returns></returns>
        public string GetCodeBuilderController(string table)
        {
            StringBuilder sbController = new StringBuilder();

            sbController.Append("using AnJie.ERP.Business;\r\n");
            sbController.Append("using AnJie.ERP.Entity;\r\n");
            sbController.Append("using AnJie.ERP.Utilities;\r\n");
            sbController.Append("using System;\r\n");
            sbController.Append("using System.Collections;\r\n");
            sbController.Append("using System.Collections.Generic;\r\n");
            sbController.Append("using System.Data;\r\n");
            sbController.Append("using System.Linq;\r\n");
            sbController.Append("using System.Web;\r\n");
            sbController.Append("using System.Web.Mvc;\r\n\r\n");

            sbController.Append("namespace AnJie.ERP.WebApp.Areas." + AreasName + ".Controllers\r\n");
            sbController.Append("{\r\n");

            sbController.Append("    /// <summary>\r\n");
            sbController.Append("    /// " + ClassName + "控制器\r\n");
            sbController.Append("    /// </summary>\r\n");
            sbController.Append("    public class " + ControllerName + " : PublicController<" + EntityName + ">\r\n");
            sbController.Append("    {\r\n");
            sbController.Append("    }\r\n");
            sbController.Append("}");
            WriteCodeBuilder(table + "\\" + ControllerName + ".cs", sbController.ToString());

            string strFilePath = "~/CodeMatic/" + table;
            string strZipPath  = "~/CodeMatic/" + table + ".zip";

            GZipHelper.ZipFile(strFilePath, strZipPath);
            DirFileHelper.DeleteDirectory("~/CodeMatic/" + table);
            return(sbController.ToString());
        }
Example #2
0
        /// <summary>
        /// 生成控制器
        /// </summary>
        /// <param name="table">表名</param>
        /// <returns></returns>
        public string GetCodeBuilderController(string table)
        {
            StringBuilder sb_Controller = new StringBuilder();

            sb_Controller.Append("/*\r\n");
            sb_Controller.Append("* 姓名:gxlbang\r\n");
            sb_Controller.AppendFormat("* 类名:{0}\r\n", EntityName);
            sb_Controller.Append("* CLR版本:\r\n");
            sb_Controller.AppendFormat("* 创建时间:{0}\r\n", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            sb_Controller.Append("* 功能描述:\r\n");
            sb_Controller.Append("*\r\n");
            sb_Controller.Append("* 修改历史:\r\n");
            sb_Controller.Append("*\r\n");
            sb_Controller.Append("* ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\r\n");
            sb_Controller.Append("* ┃            Copyright(c) gxlbang ALL rights reserved                    ┃\r\n");
            sb_Controller.Append("* ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\r\n");
            sb_Controller.Append("*/\r\n");
            sb_Controller.Append("using LeaRun.Business;\r\n");
            sb_Controller.Append("using LeaRun.Entity;\r\n");
            sb_Controller.Append("using LeaRun.Utilities;\r\n");
            sb_Controller.Append("using System;\r\n");
            sb_Controller.Append("using System.Collections;\r\n");
            sb_Controller.Append("using System.Collections.Generic;\r\n");
            sb_Controller.Append("using System.Data;\r\n");
            sb_Controller.Append("using System.Linq;\r\n");
            sb_Controller.Append("using System.Web;\r\n");
            sb_Controller.Append("using System.Web.Mvc;\r\n\r\n");

            sb_Controller.Append("namespace LeaRun.WebApp.Areas." + AreasName + ".Controllers\r\n");
            sb_Controller.Append("{\r\n");

            sb_Controller.Append("    /// <summary>\r\n");
            sb_Controller.Append("    /// " + ClassName + "控制器\r\n");
            sb_Controller.Append("    /// </summary>\r\n");
            sb_Controller.Append("    public class " + ControllerName + " : PublicController<" + EntityName + ">\r\n");
            sb_Controller.Append("    {\r\n");
            sb_Controller.Append("    }\r\n");
            sb_Controller.Append("}");
            WriteCodeBuilder(table + "\\" + ControllerName + ".cs", sb_Controller.ToString());

            string strFilePath = "~/Areas/CodeMaticModule/DataModel/CodeMatic/" + table;
            string strZipPath  = "~/Areas/CodeMaticModule/DataModel/CodeMatic/" + table + ".zip";

            GZipHelper.ZipFile(strFilePath, strZipPath);
            DirFileHelper.DeleteDirectory("~/Areas/CodeMaticModule/DataModel/CodeMatic/" + table);
            return(sb_Controller.ToString());
        }
Example #3
0
        /// <summary>
        /// 删除视频资源
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelVideoFile_Click(object sender, EventArgs e)
        {
            string videoFile = "";

            if (dgvVideoFiles.SelectedRows.Count == 0)
            {
                return;
            }
            DialogResult dialogResult = PublicClass.ShowMessageOKCancel("您确定要删除吗?");

            if (dialogResult == DialogResult.OK)
            {
                try
                {
                    M_ExerciseFile files = dgvVideoFiles.SelectedRows[0].DataBoundItem as M_ExerciseFile;
                    videoFile = files.FilePath;
                    listFile.Remove(files);
                    //删除视频资源包
                    DirFileHelper.DeleteDirectory(videoFile);
                }
                catch (IOException)
                {
                    string errorMessage = string.Format("无法删除该文件,文件正在被另一个人或程序使用。\n关闭任何可能使用这个文件的程序,重新试一次。");
                    PublicClass.ShowErrorMessageOk(errorMessage);
                }
                catch (Exception ex)
                {
                    PublicClass.ShowMessageOk(ex.Message);
                }
                finally
                {
                    //刷新列表
                    LoadVideoFiles();
                }
            }
        }
Example #4
0
        /// <summary>
        /// 下载资源文件
        /// </summary>
        /// <param name="copyPath"></param>
        /// <returns></returns>
        private void DownLoad(string copyPath)
        {
            bool   downResult  = false;
            string downLoadUrl = string.Empty;
            string filePath    = string.Empty;
            string fileName    = string.Empty;
            string savePath    = string.Empty;
            string downPath    = Globals.DownLoadDir;

            try
            {
                if (dgvResult.SelectedRows.Count == 0)
                {
                    return;
                }
                M_Resource resource = dgvResult.SelectedRows[0].DataBoundItem as M_Resource;
                btnDownLoad.Enabled = false;
                //下载地址
                downLoadUrl = string.Format("{0}/{1}", fileHost, resource.RSPath.Replace(@"\", @"/"));
                //文件路径
                filePath = resource.RSPath;
                //文件名
                fileName = Path.GetFileName(filePath);
                //下载文件保存路径
                savePath = string.Format("{0}{1}", downPath, fileName);
                //下载作业
                downResult = CommonUtil.DownloadFile(downLoadUrl, savePath, tsbBar, tsbMessage, "下载进度:");
                if (downResult)
                {
                    switch (resource.RSType)
                    {
                    case MyResourceType.ZhangTao:
                        //解压资源到目录
                        ZipFileTools.UnZipSZL(savePath, copyPath);
                        break;

                    case MyResourceType.TiKU:
                        downPath = string.Format(@"{0}\{1}", downPath, Path.GetFileNameWithoutExtension(fileName));
                        //解压资源到目录
                        ZipFileTools.UnZipSZL(savePath, downPath);
                        DirectoryInfo directoryInfo = new DirectoryInfo(downPath);
                        FileInfo[]    fileInfo      = directoryInfo.GetFiles(); //只取.srk文件
                        if (fileInfo.Length > 0)
                        {
                            DownLoadTopicDB(fileInfo[0].FullName);
                        }
                        DirFileHelper.DeleteDirectory(downPath);
                        break;

                    case MyResourceType.ZiLiao:
                        //解压资源到目录
                        ZipFileTools.UnZipSZL(savePath, copyPath);
                        break;

                    default:
                        //解压资源到目录
                        ZipFileTools.UnZipSZL(savePath, copyPath);
                        break;
                    }
                    //删除下载文件
                    DirFileHelper.DeleteFile(savePath);
                    //设置已下载状态
                    dgvResult.SelectedRows[0].Cells["DownLoadState"].Value = "已下载";
                }
            }
            catch (Exception ex)
            {
                Msg.ShowError("资源下载失败,详情请参考系统错误日志。");
                LogHelper.WriteLog(typeof(frmResource), ex);
                CommonUtil.WriteLog(ex);
            }
            finally
            {
                btnDownLoad.Enabled = true;
            }
        }