Example #1
0
        /// <summary>
        /// 直接执行sql语句下载excel
        /// </summary>
        /// <param name="form"></param>
        /// <param name="entity"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public override int Update(FormM form, DFDictionary entity, ref string message)
        {
            form.GetControlM("ConfigFile").MustInput  = string.Empty;
            form.GetControlM("SqlFilePath").MustInput = string.Empty;
            CheckInput(form, entity);
            var       sql = entity["SQL"];
            DataTable dt  = null;

            using (var db = Pub.DB)
            {
                dt = db.ExecuteDataTable(sql);
            }
            var inputResultPath = ExportHelper.ExportDataTable(dt);
            var url             = DFPub.PhysicalToRelative(inputResultPath);

            base.WriteScript(string.Format("downloadFile('{0}')", url), ref message);
            return(DFPub.EXECUTE_SUCCESS);
        }
        private DFDictionary ClientReport(DFDictionary dict)
        {
            FormM        form   = null;
            DFDictionary entity = null;

            DFPub.SetDBEntity(dict, ref form, ref entity);
            var ret     = new DFDictionary();
            var message = string.Empty;
            var da      = NinjectHelper.Get <IDA>(form.DAImp);

            try
            {
                if (null == da)
                {
                    throw new Exception("Invalid DAImp");
                }
                if (da.Update(form, entity, ref message) != 0)
                {
                    ret.Add("hasError", "true");
                }
                var baseDA = (BaseDA)da;
                ret.Add("Debug", entity["Debug"]);
                ret.Add("ReportName", Path.GetFileName(baseDA.ReportPath));
                ret.Add("UploadFileUrl", baseDA.GetUrlFolder() + "/kindeditor/asp.net/upload_json.ashx");
                ret.Add("ReportUrl", baseDA.GetUrlRoot() + DFPub.PhysicalToRelative(baseDA.ReportPath));
                if (baseDA.ReportDataSource != null)
                {
                    ret.Add("ReportDataSource", Convert.ToBase64String(SerializeHelper.DataSetSerializer(baseDA.ReportDataSource)));
                }
                ret.Add("error", message);
                m_log.Debug(JsonSerializeHelper.SerializeObject(ret));
            }
            catch (Exception ex)
            {
                ret.Add("hasError", "true");
                ret.Add("error", ex.Message);
                m_log.Error(ex.Message, ex);
            }
            return(ret);
        }
Example #3
0
        public override void SetAccess(FormM form, DFDictionary entity)
        {
            SetSelectDataSource(form, "ConfigFile",
                                Directory.GetFiles(GetImportConfigXmlPath(string.Empty), "*.xml")
                                .Select(a => new DFSelectItem(Path.GetFileNameWithoutExtension(a), DFPub.PhysicalToRelative(a))).ToList());
            IDBHelper dbHelper;

            using (var db = Pub.DB)
            {
                dbHelper = DBHelper.GetDBHelper(db);
            }
            SetSelectDataSource(form, "SearchTableName", dbHelper.LoadTables().Select(a => new DFSelectItem(a.TableName, a.TableName)).ToList(), true);
            base.SetAccess(form, entity);
        }
Example #4
0
        /// <summary>
        /// 保存到xml中
        /// </summary>
        /// <param name="form"></param>
        /// <param name="entity"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        private int btnSave(FormM form, DFDictionary entity, ref string message)
        {
            var list        = GetGridClientData <VM_ColumnMetadata>(entity);
            var tableName   = entity["TableName"];
            var xmlFileName = entity["XmlFileName"];

            ArgumentCheck.CheckMustInput(entity, "XmlFileName");
            Save(xmlFileName, tableName, list);

            // 更新界面上的配置文件下拉框,因为如果新增的话,就多了一个xml
            SetSelectDataSource(form, "ConfigFile",
                                Directory.GetFiles(GetImportConfigXmlPath(string.Empty), "*.xml")
                                .Select(a => new DFSelectItem(Path.GetFileNameWithoutExtension(a), DFPub.PhysicalToRelative(a))).ToList());
            return(DFPub.EXECUTE_SUCCESS);
        }
Example #5
0
        public override int Insert(FormM form, DFDictionary entity, ref string message)
        {
            form.GetControlM("SQL").MustInput = string.Empty;
            CheckInput(form, entity);
            var path       = DFPub.RelativeToPhysical(entity["SqlFilePath"]);
            var configPath = DFPub.RelativeToPhysical(entity["ConfigFile"]);
            var dt         = ReadExcel(path);

            if (dt.Columns.Contains("Result"))
            {
                dt.Columns.Remove("Result");
            }
            dt.Columns.Add("Result", typeof(string));
            var tables = GetTableConfig(configPath);

            ProcessData(dt, tables, entity);

            var failed  = dt.AsEnumerable().Count(a => a.GetValue("Result").Length > 0);
            var success = dt.AsEnumerable().Count(a => a.GetValue("Result").Length == 0);

            ExcelReader.WriteDataTableToExcel(dt, path);
            if (failed > 0)
            {
                message = string.Format("成功导入 {0},导入失败 {1},请查看失败日志<br><a href='{2}'>{2}</a>", success, failed, DFPub.PhysicalToRelative(path));
                return(DFPub.EXECUTE_ERROR);
            }
            else
            {
                message = string.Format("成功导入 {0}", success);
                return(DFPub.EXECUTE_SUCCESS);
            }
        }
Example #6
0
 public override void SetAccess(FormM form, DFDictionary entity)
 {
     SetSelectDataSource(form, "ConfigFile",
                         Directory.GetFiles(GetImportConfigXmlPath(string.Empty), "*.xml")
                         .Select(a => new DFSelectItem(Path.GetFileNameWithoutExtension(a), DFPub.PhysicalToRelative(a))).ToList());
     base.SetAccess(form, entity);
 }
        public void ProcessRequest(HttpContext context)
        {
            InitializeHelper.Init();
            var dict        = DFPub.GetDFDictionary(context.Request);
            var action      = dict["action"].ToLower();
            var contentType = context.Request.ContentType;

            if (string.IsNullOrWhiteSpace(contentType))
            {
                contentType = "application/json;charset=utf-8";
            }
            context.Response.ContentType = contentType;
            switch (action)
            {
            case "queryform":
                if (dict.Data.ContainsKey(DFPub.DF_DATAGRID_EXPORT))
                {
                    var vm = QueryForm(dict);
                    if (vm.hasError)
                    {
                        m_log.Error(vm.error);
                    }
                    context.Response.Write(JsonSerializeHelper.SerializeObject(new DataGridVM()
                    {
                        data = DFPub.PhysicalToRelative(vm.data.ToString())
                    }));
                }
                else
                {
                    context.Response.Write(JsonSerializeHelper.SerializeObject(QueryForm(dict)));
                }
                break;

            case "deleteform":
                context.Response.Write(JsonSerializeHelper.SerializeObject(DeleteForm(dict)));
                break;

            case "clientreport":
                context.Response.Write(JsonSerializeHelper.SerializeObject(ClientReport(dict)));
                break;

            case "querylist":
                context.Response.Write(JsonSerializeHelper.SerializeObject(QueryList(dict)));
                break;

            case "saveparameter":
                context.Response.Write(JsonSerializeHelper.SerializeObject(SaveParameter(context, dict)));
                break;

            case "uploadfile":
                context.Response.Write(JsonSerializeHelper.SerializeObject(UploadFile(context, dict)));
                break;

            case "deleteuploadfile":
                context.Response.Write(JsonSerializeHelper.SerializeObject(DeleteUploadFile(context, dict)));
                break;

            //case "kanban":
            //    context.Response.Write(JsonSerializeHelper.SerializeObject(Kanban(context)));
            //    break;
            default:
                context.Response.Write(JsonSerializeHelper.SerializeObject(ExecuteMethod(dict["action"], dict)));
                break;
            }
        }