Example #1
0
        private static void WriteWindowForm(ExcelXmlWriter ew, string windowName, string formName)
        {
            System.Data.DataTable dt2 = Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_Window WHERE Name = '" + windowName + "'");
            ew.WriteExcelXml(dt2, "AD_Window");
            System.Data.DataTable dt3 = Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_Form WHERE Name = '" + formName + "'");
            ew.WriteExcelXml(dt3, "AD_Form");

            if (dt2.Rows.Count > 0)
            {
                dt3 = Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_Window_Tab WHERE Window = '" + dt2.Rows[0]["Name"].ToString() + "'");
                ew.WriteExcelXml(dt3, "AD_Window_Tab");

                System.Data.DataTable dt4 = Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_Window_Menu WHERE Window = '" + dt2.Rows[0]["Name"].ToString() + "'");
                ew.WriteExcelXml(dt4, "AD_Window_Menu");

                foreach (System.Data.DataRow row in dt4.Rows)
                {
                    System.Data.DataTable dt6 = Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_Process WHERE Name = '" + row["ExecuteParam"].ToString() + "'");
                    ew.WriteExcelXml(dt6, "AD_Process");
                }

                if (dt2.Rows[0]["WindowType"].ToString() == "5")
                {
                    WriteReport(ew, dt2.Rows[0]["Name"].ToString());
                }
                else
                {
                    WriteGrid(ew, dt3);
                }

                WriteWindowForm(ew, dt2.Rows[0]["DetailWindow"].ToString(), dt2.Rows[0]["DetailForm"].ToString());
            }
        }
Example #2
0
 private static void ExportSingleTable(string dirPath, string tableName)
 {
     using (ExcelXmlWriter ew = new ExcelXmlWriter(dirPath + "\\" + tableName + ".xml"))
     {
         ew.WriteExcelXml(Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM " + tableName), tableName);
     }
 }
Example #3
0
 protected void Save()
 {
     //var wrt = new ExcelXmlWriter();
     ExcelXmlWriter.SaveProductsToXml(_strFullPath);
     ExportStatistic.IsRun = false;
     //ExportStatistic.ThreadImport.Abort();
 }
        protected void Save(object arg)
        {
            var paging = (SqlPaging)arg;
            var wrt    = new ExcelXmlWriter();
            var orders = paging.GetCustomData("*", "", OrderService.GetOrderFromReader);

            wrt.SaveOrdersToXml(_strFullPath, orders);
            CommonStatistic.IsRun = false;
        }
Example #5
0
    protected void Save(object arg)
    {
        var orders = (List <Order>)arg;
        var wrt    = new ExcelXmlWriter();

        wrt.SaveOrdersToXml(_strFullPath, orders);
        ExportStatistic.IsRun = false;
        //ExportStatistic.ThreadImport.Abort();
    }
Example #6
0
        private static void WriteReport(ExcelXmlWriter ew, string reportName)
        {
            // Report Form
            System.Data.DataTable dt4 = Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_Report WHERE Name = '" + reportName + "'");
            ew.WriteExcelXml(dt4, "AD_Report");

            if (dt4.Rows.Count > 0)
            {
                System.Data.DataRow   row = dt4.Rows[0];
                System.Data.DataTable dt6 = Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_Report_Data WHERE Report = '" + row["Name"].ToString() + "'");
                ew.WriteExcelXml(dt6, "AD_Report_Data");

                WriteGrid(ew, dt6);
            }
        }
Example #7
0
        private void write_excel()
        {
            int       max_cols = 0;
            int       x        = 0;
            int       max_rows = 0;
            ArrayList a1       = new ArrayList();

            foreach (GridViewRow r1 in GridView1.Rows)
            {
                x = 0;
                foreach (TableCell c1 in r1.Cells)
                {
                    Grid_Element g1 = new Grid_Element();
                    a1.Add(g1); g1.m_value = c1.Text; g1.m_y = max_rows; g1.m_x = x; x++;
                }
                max_rows++; max_cols = x;
            }

            ExcelXmlWriter xl = new ExcelXmlWriter();

            xl.OutputToExcel(Response, a1, max_cols, max_rows, "SetLists");
        }
Example #8
0
        private static void WriteGrid(ExcelXmlWriter ew, System.Data.DataTable dt3)
        {
            System.Data.DataTable dt4 = null;
            foreach (System.Data.DataRow row in dt3.Rows)
            {
                dt4 = Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_Grid WHERE GridName = '" + row["GridName"].ToString() + "'");
                ew.WriteExcelXml(dt4, "AD_Grid");
            }

            System.Data.DataTable dt5;

            foreach (System.Data.DataRow row in dt3.Rows)
            {
                dt4 = Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_Grid_Column WHERE GridName = '" + row["GridName"].ToString() + "'");
                ew.WriteExcelXml(dt4, "AD_Grid_Column");

                foreach (System.Data.DataRow row1 in dt4.Rows)
                {
                    string gridColumnName = null;
                    if (row1["GridColumnName"] != System.DBNull.Value)
                    {
                        gridColumnName = row1["GridColumnName"].ToString();
                    }
                    else if (row1["Navigator"] != System.DBNull.Value)
                    {
                        gridColumnName = row1["Navigator"].ToString() + "." + row1["PropertyName"].ToString();
                    }
                    else
                    {
                        gridColumnName = row1["PropertyName"].ToString();
                    }
                    dt5 = Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_Grid_Column_Warning WHERE GroupName = '" + gridColumnName + "'");
                    ew.WriteExcelXml(dt5, "AD_Grid_Column_Warning");
                }
            }

            foreach (System.Data.DataRow row in dt3.Rows)
            {
                dt5 = Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_Grid_Row WHERE GridName = '" + row["GridName"].ToString() + "'");
                ew.WriteExcelXml(dt5, "AD_Grid_Row");
            }

            foreach (System.Data.DataRow row in dt3.Rows)
            {
                dt5 = Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_Grid_Cell WHERE GridName = '" + row["GridName"].ToString() + "'");
                ew.WriteExcelXml(dt5, "AD_Grid_Cell");
            }

            foreach (System.Data.DataRow row in dt3.Rows)
            {
                dt5 = Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_Grid_Related WHERE GridName = '" + row["GridName"].ToString() + "'");
                ew.WriteExcelXml(dt5, "AD_Grid_Related");
            }

            foreach (System.Data.DataRow row in dt3.Rows)
            {
                dt5 = Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_Grid_Group WHERE GridName = '" + row["GridName"].ToString() + "'");
                ew.WriteExcelXml(dt5, "AD_Grid_Group");
            }

            foreach (System.Data.DataRow row in dt3.Rows)
            {
                dt5 = Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_Grid_Filter WHERE GridName = '" + row["GridName"].ToString() + "'");
                ew.WriteExcelXml(dt5, "AD_Grid_Filter");
            }
        }
Example #9
0
        /// <summary>
        /// 把现有数据库中的所有配置保存到数据文件中(多个文件)
        /// </summary>
        /// <param name="dirPath"></param>
        public static void ExportAllToPath(string dirPath)
        {
            Feng.Utils.IOHelper.TryCreateDirectory(dirPath + s_exportPathOthers);
            Feng.Utils.IOHelper.TryCreateDirectory(dirPath + s_exportPathMenus);
            Feng.Utils.IOHelper.TryCreateDirectory(dirPath + s_exportPathWindows);
            Feng.Utils.IOHelper.TryCreateDirectory(dirPath + s_exportPathReports);
            Feng.Utils.IOHelper.TryCreateDirectory(dirPath + s_exportPathSelectWindows);

            // Others
            using (ExcelXmlWriter ew = new ExcelXmlWriter(dirPath + s_exportPathOthers + "\\AD_Alerts.xml"))
            {
                ew.WriteExcelXml(Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_AlertRule"), "AD_AlertRule");
                ew.WriteExcelXml(Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_Task"), "AD_Task");
            }

            using (ExcelXmlWriter ew = new ExcelXmlWriter(dirPath + s_exportPathOthers + "\\AD_MultiOrgs.xml"))
            {
                ew.WriteExcelXml(Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_Client"), "AD_Client");
                ew.WriteExcelXml(Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM Ad_Org"), "Ad_Org");
            }

            using (ExcelXmlWriter ew = new ExcelXmlWriter(dirPath + s_exportPathOthers + "\\AD_Buffers.xml"))
            {
                ew.WriteExcelXml(Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_EntityBuffer"), "AD_EntityBuffer");
                ew.WriteExcelXml(Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_NameValueMapping"), "AD_NameValueMapping");
                ew.WriteExcelXml(Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_SimpleParam"), "AD_SimpleParam");
                ew.WriteExcelXml(Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_Param_Creator"), "AD_Param_Creator");
            }

            ExportSingleTable(dirPath + s_exportPathOthers, "AD_Search_Custom");
            ExportSingleTable(dirPath + s_exportPathOthers, "AD_EventProcess");
            ExportSingleTable(dirPath + s_exportPathOthers, "AD_Server_TaskSchedule");
            ExportSingleTable(dirPath + s_exportPathOthers, "AD_Process");
            ExportSingleTable(dirPath + s_exportPathOthers, "AD_Web_Service");
            ExportSingleTable(dirPath + s_exportPathOthers, "AD_Command_Binding");
            ExportSingleTable(dirPath + s_exportPathOthers, "AD_Plugin");
            ExportSingleTable(dirPath + s_exportPathOthers, "AD_Resource");
            ExportSingleTable(dirPath + s_exportPathOthers, "AD_Resource");
            ExportSingleTable(dirPath + s_exportPathOthers, "AD_Resource");
            ExportSingleTable(dirPath + s_exportPathOthers, "AD_Resource");

            // Select Window
            System.Data.DataTable dt = Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM Ad_Window_Select");
            foreach (System.Data.DataRow row in dt.Rows)
            {
                using (ExcelXmlWriter ew = new ExcelXmlWriter(dirPath + s_exportPathSelectWindows + "\\AD_WindowSelect_" + row["Name"].ToString() + ".xml"))
                {
                    System.Data.DataTable dt2 = DbHelper.Instance.ExecuteDataTable("SELECT * FROM Ad_Window_Select WHERE NAME = '" + row["Name"].ToString() + "'");
                    ew.WriteExcelXml(dt2, "Ad_Window_Select");

                    WriteWindowForm(ew, row["Window"].ToString(), row["Form"].ToString());
                }
            }


            // Menus(main)
            IList <MenuInfo> menus;

            using (var rep = GenerateRepository())
            {
                menus = rep.List <MenuInfo>(NHibernate.Criterion.DetachedCriteria.For <MenuInfo>()
                                            .Add(NHibernate.Criterion.Expression.IsNotNull("ParentMenu")));
            }

            foreach (MenuInfo menuInfo in menus)
            {
                using (ExcelXmlWriter ew = new ExcelXmlWriter(dirPath + s_exportPathMenus + "\\AD_Menu_" + menuInfo.Name + ".xml"))
                {
                    string sql = "SELECT * FROM AD_Menu WHERE Name = '" + menuInfo.Name + "'";
                    dt = DbHelper.Instance.ExecuteDataTable(sql);
                    string parentName = (string)dt.Rows[0]["ParentMenu"];
                    ew.WriteExcelXml(dt, "AD_Menu");
                    while (true)
                    {
                        string sql2 = "SELECT * FROM AD_Menu WHERE Name = '" + parentName + "'";
                        System.Data.DataTable dtt = DbHelper.Instance.ExecuteDataTable(sql2);

                        if (dtt.Rows[0]["ParentMenu"] == System.DBNull.Value)
                        {
                            break;
                        }
                        parentName = (string)dtt.Rows[0]["ParentMenu"];
                        ew.WriteExcelXml(dtt, "AD_Menu");
                    }

                    if (menuInfo.Action != null)
                    {
                        dt = Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_Action WHERE Name = '" + menuInfo.Action.Name + "'");
                        ew.WriteExcelXml(dt, "AD_Action");

                        if (dt.Rows[0]["ActionType"].ToString() == "2")
                        {
                            System.Data.DataTable dt3 = Feng.Data.DbHelper.Instance.ExecuteDataTable("SELECT * FROM AD_Process WHERE Name = '" + dt.Rows[0]["Process"].ToString() + "'");
                            ew.WriteExcelXml(dt3, "AD_Process");
                        }
                        else
                        {
                            WriteWindowForm(ew, dt.Rows[0]["Window"].ToString(), dt.Rows[0]["Form"].ToString());
                        }
                    }
                }
            }

            // Windows
            IList <WindowInfo> windows;

            using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository(typeof(WindowInfo)))
            {
                windows = rep.List <WindowInfo>();
            }
            foreach (WindowInfo windowInfo in windows)
            {
                using (ExcelXmlWriter ew = new ExcelXmlWriter(dirPath + s_exportPathWindows + "\\AD_Window_" + windowInfo.Name + ".xml"))
                {
                    WriteWindowForm(ew, windowInfo.Name, null);
                }
            }

            // Report
            IList <ReportInfo> reports;

            using (IRepository rep = GenerateRepository())
            {
                reports = rep.List <ReportInfo>();
            }
            foreach (ReportInfo reportInfo in reports)
            {
                using (ExcelXmlWriter ew = new ExcelXmlWriter(dirPath + s_exportPathReports + "\\AD_Report_" + reportInfo.Name + ".xml"))
                {
                    WriteReport(ew, reportInfo.Name);
                }
            }
        }