public System.Data.DataTable Query(string psSQL) { System.Data.DataTable loDataReturn = null; System.Data.DataSet loDS = new System.Data.DataSet(); SQLiteConnection loSql_con; SQLiteDataAdapter loSQLAdapter; loSql_con = getConnection(); loSQLAdapter = new SQLiteDataAdapter(psSQL, loSql_con); loDS.Reset(); loSQLAdapter.Fill(loDS); loDataReturn = loDS.Tables[0]; loDS.Tables.Remove(loDataReturn); loDS.Clear(); loDS.Dispose(); loSql_con.Close(); loSql_con.Dispose(); loSQLAdapter.Dispose(); return(loDataReturn); }
public void StartClientProcess() { initServerList(); string appName = IAPL.Transport.Configuration.Config.GetAppSettingsValue("pingservername", "FTP Tool"); string serverPort = IAPL.Transport.Configuration.Config.GetAppSettingsValue("pingserverport", "9988"); string serverIP = ""; foreach (System.Data.DataTable dt in this.mainDataSet.Tables) { foreach (System.Data.DataRow row in dt.Rows) { serverIP = IAPL.Transport.Util.CommonTools.ValueToString(row["ipaddress"]); if (serverIP.Trim().Length > 0 && serverPort.Trim().Length > 0) { this.runClientNow(serverIP, serverPort, appName); } } } for (int i = 0; i < mainDataSet.Tables.Count; i++) { mainDataSet.Tables[i].Dispose(); } mainDataSet.Dispose(); }
/// <summary> /// 将DataSet导出为excel,一个Table对应一个sheet /// </summary> /// <param name="ds"></param> public static void DataSetToExcel(System.Data.DataSet ds, string fileName) { ExcelHandler eh = new ExcelHandler(); SheetExcelForm frm = new SheetExcelForm(); eh.ProcessHandler = frm.AddProcess; eh.ProcessErrorHandler = new Action <string>((msg) => { MessageBox.Show(msg); }); try { frm.Show(); Delay(20); eh.DataSet2Excel(ds, null, fileName); ds.Dispose(); } catch (Exception ex) { MessageBox.Show("导出Excel错误:" + ex.Message); } finally { Delay(20); frm.Close(); } }
/// <summary> /// 导出Excel,以旧列名-新列名词典为标头 /// </summary> /// <param name="dt"></param> /// <param name="dicCoumnNameMapping"></param> public static void DataTableToExcel(System.Data.DataTable dt, Dictionary <string, string> dicCoumnNameMapping, string fileName) { ExcelHandler eh = new ExcelHandler(); SheetExcelForm frm = new SheetExcelForm(); eh.ProcessHandler = frm.AddProcess; eh.ProcessErrorHandler = new Action <string>((msg) => { MessageBox.Show(msg); }); try { frm.Show(); Delay(20); var ds = new System.Data.DataSet(); ds.Tables.Add(dt); eh.DataSet2Excel(ds, dicCoumnNameMapping, fileName); ds.Tables.Remove(dt); ds.Dispose(); } catch (Exception ex) { MessageBox.Show("导出Excel错误:" + ex.Message); } finally { Delay(20); frm.Close(); } }
public static void CreateMenuJson() { string jsPath = Utils.GetMapPath(BaseConfigs.GetForumPath.ToLower() + "admin/xml/navmenu.js"); System.Data.DataSet dsSrc = new System.Data.DataSet(); dsSrc.ReadXml(configPath); StringBuilder menustr = new StringBuilder(); menustr.Append("var toptabmenu = "); menustr.Append(Utils.DataTableToJSON(dsSrc.Tables[2])); menustr.Append("\r\nvar mainmenu = "); menustr.Append(Utils.DataTableToJSON(dsSrc.Tables[0])); menustr.Append("\r\nvar submenu = "); menustr.Append(Utils.DataTableToJSON(dsSrc.Tables[1])); menustr.Append("\r\nvar shortcut = "); if (dsSrc.Tables.Count < 4) { menustr.Append("[]"); } else { menustr.Append(Utils.DataTableToJSON(dsSrc.Tables[3])); } WriteJsonFile(jsPath, menustr); dsSrc.Dispose(); }
/// <summary> /// Free query result. /// </summary> /// <param name="result">Query result</param> public static void FreeResult(Object result) { System.Data.DataSet ds = (System.Data.DataSet)((Object[])result)[1]; ds.Dispose(); ((Object[])result)[0] = 0; ((Object[])result)[1] = null; }
/// <summary> /// 导出Excel,以旧列名-新列名词典为标头 /// </summary> /// <param name="dt"></param> /// <param name="dicCoumnNameMapping"></param> public static void DataTableToExcel(System.Data.DataTable dt, Dictionary<string, string> dicCoumnNameMapping, string fileName) { ExcelHandler eh = new ExcelHandler(); SheetExcelForm frm = new SheetExcelForm(); eh.ProcessHandler = frm.AddProcess; eh.ProcessErrorHandler = new Action<string>((msg) => { MessageBox.Show(msg); }); try { frm.Show(); Delay(20); var ds = new System.Data.DataSet(); ds.Tables.Add(dt); eh.DataSet2Excel(ds, dicCoumnNameMapping, fileName); ds.Tables.Remove(dt); ds.Dispose(); } catch (Exception ex) { MessageBox.Show("导出Excel错误:" + ex.Message); } finally { Delay(20); frm.Close(); } }
public void Dispose() { if (_ds != null) { _ds.Dispose(); } }
/// <summary> /// 数据绑定 /// </summary> private void BindData() { try { string sqlColumns = " ROW_NUMBER() OVER(ORDER BY pe.id) AS RowNum,pe.id ID,us.Name Name,ed.Name WorkPlace,eui.Position Position,epi.ExamName ExamName,es.SubjectName SubjectName, pe.Score Score,pe.ExamState ExamState "; string sqlEnd = sql; //加载查询条件 string textSearch = ttbSearchMessage.Text; if (!string.IsNullOrEmpty(textSearch)) { if (sql_inj(textSearch)) { //存在SQL注入风险 } else { sqlEnd = sql + " and( us.Name like '" + textSearch + "' or ed.Name like '" + textSearch + "' or eui.Position like '" + textSearch + "' or epi.ExamName like '" + textSearch + "' or es.SubjectName like '" + textSearch + "')"; } } //数据量 条数 int count = Helpers.DbHelperSQL.Query("select pe.id " + sqlEnd).Tables[0].Rows.Count; //排序判断 if (Grid1.SortDirection == "ASC") { sqlEnd += " order by " + Grid1.SortField + " ASC"; } else { sqlEnd += " order by " + Grid1.SortField + " desc"; } sqlEnd = "select " + sqlColumns + sqlEnd; //数据加载及绑定 System.Data.DataSet ds = Helpers.DbHelperSQL.Query(sqlEnd); System.Data.DataTable data = ds.Tables[0]; Grid1.RecordCount = count; int pageIndexMax = (Grid1.PageIndex + 1) * Grid1.PageSize; int pageIndexmin = pageIndexMax - Grid1.PageSize; Grid1.DataSource = data.Select("" + pageIndexmin + " < RowNum and RowNum <=" + pageIndexMax + ""); Grid1.DataBind(); ds.Dispose(); data.Dispose(); } catch (Exception ex) { throw ex; } }
/// <summary> /// 按照模板导出 /// </summary> /// <param name="dt">要导出的datatable</param> /// <param name="templateFile">要导出的excel模板文件</param> /// <param name="saveFile">要保存的文件名,可以为空</param> public void DataTableToExcelWithTemplate(System.Data.DataTable dt, string templateFile, string saveFile) { ExcelHandler eh = new ExcelHandler(); try { string exportDir = "~/ExcelFile/";//注意:该文件夹您须事先在服务器上建好才行 if (System.IO.Directory.Exists(GetPhysicalPath(exportDir)) == false) { System.IO.Directory.CreateDirectory(GetPhysicalPath(exportDir)); } if (string.IsNullOrEmpty(saveFile)) saveFile = DateTime.Now.ToString("yyyyMMddHHmmssfff_") + ".xls"; //设置文件在服务器上的路径 string physicalFileName = GetPhysicalPath(System.IO.Path.Combine(exportDir, saveFile)); eh.ProcessErrorHandler = this.ErrorMessageHandler; var ds = new System.Data.DataSet(); ds.Tables.Add(dt); string tmpFile = eh.ExportWithTemplate(dt, templateFile, physicalFileName, false); ds.Tables.Remove(dt); ds.Dispose(); //==============返回客户端 ResponeToClient(physicalFileName, saveFile); try { if (!string.IsNullOrEmpty(tmpFile)) { System.IO.FileInfo fi = new System.IO.FileInfo(tmpFile); if (fi.Exists) { fi.Attributes = System.IO.FileAttributes.Normal; System.IO.File.Delete(tmpFile); } } } catch (Exception ex) { AddMessage(ex.Message); } } catch (Exception ex) { if (this.ErrorMessageHandler != null) ErrorMessageHandler("导出过程中出错," + ex.Message); if (ErrorHandler != null) ErrorHandler(ex); GC.Collect(); } }
public void DataTableToExcle(System.Data.DataTable dt, Dictionary <string, string> dicCoumnNameMapping, string fileName) { try { string exportDir = "~/ExcelFile/";//注意:该文件夹您须事先在服务器上建好才行 if (System.IO.Directory.Exists(GetPhysicalPath(exportDir)) == false) { System.IO.Directory.CreateDirectory(GetPhysicalPath(exportDir)); } if (string.IsNullOrEmpty(fileName)) { fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xls"; } //设置文件在服务器上的路径 string physicalFileName = GetPhysicalPath(System.IO.Path.Combine(exportDir, fileName)); ExcelHandler eh = new ExcelHandler(); eh.ProcessErrorHandler = this.ErrorMessageHandler; var ds = new System.Data.DataSet(); ds.Tables.Add(dt); eh.DataSet2Excel(ds, dicCoumnNameMapping, physicalFileName); ds.Tables.Remove(dt); ds.Dispose(); //==============返回客户端 ResponeToClient(physicalFileName, fileName); } catch (Exception ex) { if (this.ErrorMessageHandler != null) { ErrorMessageHandler("导出过程中出错," + ex.Message); } if (ErrorHandler != null) { ErrorHandler(ex); } GC.Collect(); } }
public void OutputAction(string filename) { var dt = Helper.Client.InvokeSync <WayDataTable>("GetActions", Database.id).ToDataTable(); var dset = new System.Data.DataSet(); dset.Tables.Add(dt); dset.DataSetName = this.Database.Guid; string path = Path.GetDirectoryName(filename); if (Directory.Exists(path) == false) { Directory.CreateDirectory(path); } System.IO.FileStream fs = System.IO.File.Create(filename); dt.WriteXml(fs, System.Data.XmlWriteMode.WriteSchema); fs.Close(); dt.Dispose(); dset.Dispose(); }
private System.Data.DataSet ProcessDataSetWithMoreData() { System.Data.DataSet a = null; try { a = new System.Data.DataSet(); a.Locale = System.Globalization.CultureInfo.InvariantCulture; a.Tables.Add(new System.Data.DataTable("table1", "urn:table1")); a.Tables[0].Locale = System.Globalization.CultureInfo.InvariantCulture; a.Tables[0].Columns.Add("col1_1", typeof(int)); a.Tables[0].Columns.Add("col1_2", typeof(string)); a.Tables[0].Rows.Add(1, "hello1"); a.Tables[0].Rows.Add(2, "hello2"); a.Tables[0].Rows.Add(System.DBNull.Value, System.DBNull.Value); a.Tables.Add(new System.Data.DataTable("table2", "urn:table2")); a.Tables[1].Locale = System.Globalization.CultureInfo.InvariantCulture; a.Tables[1].Columns.Add("col2_1", typeof(bool)); a.Tables[1].Columns.Add("col2_2", typeof(decimal)); a.Tables[1].Rows.Add(true, 1.0m); a.Tables[1].Rows.Add(false, 99.0m); int i = 1; this.CustomiseProcessDataSetWithMoreData(a, ref i); _testContext.BeginTimer("GeneratedAsmxSampleTest_ProcessDataSetWithMoreData"); try { return(testAsmxServiceSoapClient.ProcessDataSetWithMoreData(a, i)); } finally { _testContext.EndTimer("GeneratedAsmxSampleTest_ProcessDataSetWithMoreData"); } } finally { a.Dispose(); } }
private System.Data.DataSet ProcessDataSet() { System.Data.DataSet data = null; try { data = new System.Data.DataSet(); data.Locale = System.Globalization.CultureInfo.InvariantCulture; data.Tables.Add(new System.Data.DataTable("table1", "urn:table1")); data.Tables[0].Locale = System.Globalization.CultureInfo.InvariantCulture; data.Tables[0].Columns.Add("col1_1", typeof(int)); data.Tables[0].Columns.Add("col1_2", typeof(string)); data.Tables[0].Rows.Add(1, "hello1"); data.Tables[0].Rows.Add(2, "hello2"); data.Tables[0].Rows.Add(System.DBNull.Value, System.DBNull.Value); data.Tables.Add(new System.Data.DataTable("table2", "urn:table2")); data.Tables[1].Locale = System.Globalization.CultureInfo.InvariantCulture; data.Tables[1].Columns.Add("col2_1", typeof(bool)); data.Tables[1].Columns.Add("col2_2", typeof(decimal)); data.Tables[1].Rows.Add(true, 1.0m); data.Tables[1].Rows.Add(false, 99.0m); this.CustomiseProcessDataSet(data); _testContext.BeginTimer("GeneratedSampleTestWithProxyFromServerTrace_ProcessDataSet"); try { return(dataSetsClient.ProcessDataSet(data)); } finally { _testContext.EndTimer("GeneratedSampleTestWithProxyFromServerTrace_ProcessDataSet"); } } finally { data.Dispose(); } }
/// <summary> /// дXML�ĵ� /// </summary> /// <param name="name">���ݿ������������</param> /// <param name="con_str">���ݿ������Դ��Ϣ</param> public void writeXML(string name , ConfigStruct con_str) { try { //����һ��dataset System.Data.DataSet ds = new System.Data.DataSet("Autoconfig"); //�ж��Ƿ����config.xml�ļ�,������ڴӸ��ļ��ж�ȡ���ݵ�dataset if(System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory.TrimEnd(new char[] {'\\'}) +"\\" +_FileName)) { ds.ReadXml(AppDomain.CurrentDomain.BaseDirectory.TrimEnd(new char[] {'\\'}) +"\\" +_FileName); } //�ж��Ƿ���ڸñ�,���������ɾ���ñ� if(ds.Tables.IndexOf(name.ToUpper()) != -1 ) { ds.Tables.Remove(name.ToUpper()); } //����һ��datatable System.Data.DataTable dt = new System.Data.DataTable(name.ToUpper()); //Ϊ�¶���ı������� dt.Columns.Add("key"); dt.Columns.Add("value"); SymmetricMethod sm = new SymmetricMethod(); //���Ӽ�¼���¶���ı��� dt.Rows.Add(new object[2]{ sm.Encrypto( str_HA ), sm.Encrypto( con_str.hostAddress)}); dt.Rows.Add(new object[2]{ sm.Encrypto( str_UN ), sm.Encrypto( con_str.userName)}); dt.Rows.Add(new object[2]{ sm.Encrypto( str_PWD ), sm.Encrypto( con_str.password)}); dt.Rows.Add(new object[2]{ sm.Encrypto( str_DBN ), sm.Encrypto( con_str.DBName)}); //�������ӵ�������µ�dataset�� ds.Tables.Add(dt); //д��xml�ĵ� ds.WriteXml(AppDomain.CurrentDomain.BaseDirectory.TrimEnd(new char[] {'\\'}) +"\\" +_FileName); //�ͷ�datatable �� dataset dt.Dispose(); ds.Dispose(); } catch(Exception exp) { //System.Windows.Forms.MessageBox.Show(exp.Message); throw exp; } }
/// <summary> /// 按照模板导出 /// </summary> /// <param name="dt">要导出的datatable</param> /// <param name="templateFile">要导出的excel模板文件</param> /// <param name="saveFile">要保存的文件名,可以为空</param> public void DataTableToExcelWithTemplate(System.Data.DataTable dt, string templateFile, string saveFile) { ExcelHandler eh = new ExcelHandler(); try { string exportDir = "~/ExcelFile/";//注意:该文件夹您须事先在服务器上建好才行 if (System.IO.Directory.Exists(GetPhysicalPath(exportDir)) == false) { System.IO.Directory.CreateDirectory(GetPhysicalPath(exportDir)); } if (string.IsNullOrEmpty(saveFile)) { saveFile = DateTime.Now.ToString("yyyyMMddHHmmssfff_") + ".xls"; } //设置文件在服务器上的路径 string physicalFileName = GetPhysicalPath(System.IO.Path.Combine(exportDir, saveFile)); eh.ProcessErrorHandler = this.ErrorMessageHandler; var ds = new System.Data.DataSet(); ds.Tables.Add(dt); string tmpFile = eh.ExportWithTemplate(dt, templateFile, physicalFileName, false); ds.Tables.Remove(dt); ds.Dispose(); //==============返回客户端 ResponeToClient(physicalFileName, saveFile); try { if (!string.IsNullOrEmpty(tmpFile)) { System.IO.FileInfo fi = new System.IO.FileInfo(tmpFile); if (fi.Exists) { fi.Attributes = System.IO.FileAttributes.Normal; System.IO.File.Delete(tmpFile); } } } catch (Exception ex) { AddMessage(ex.Message); } } catch (Exception ex) { if (this.ErrorMessageHandler != null) { ErrorMessageHandler("导出过程中出错," + ex.Message); } if (ErrorHandler != null) { ErrorHandler(ex); } GC.Collect(); } }
public void DataTableToExcle(System.Data.DataTable dt, Dictionary<string, string> dicCoumnNameMapping, string fileName) { try { string exportDir = "~/ExcelFile/";//注意:该文件夹您须事先在服务器上建好才行 if (System.IO.Directory.Exists(GetPhysicalPath(exportDir)) == false) { System.IO.Directory.CreateDirectory(GetPhysicalPath(exportDir)); } if (string.IsNullOrEmpty(fileName)) fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xls"; //设置文件在服务器上的路径 string physicalFileName = GetPhysicalPath(System.IO.Path.Combine(exportDir, fileName)); ExcelHandler eh = new ExcelHandler(); eh.ProcessErrorHandler = this.ErrorMessageHandler; var ds = new System.Data.DataSet(); ds.Tables.Add(dt); eh.DataSet2Excel(ds, dicCoumnNameMapping, physicalFileName); ds.Tables.Remove(dt); ds.Dispose(); //==============返回客户端 ResponeToClient(physicalFileName, fileName); } catch (Exception ex) { if (this.ErrorMessageHandler != null) ErrorMessageHandler("导出过程中出错," + ex.Message); if (ErrorHandler != null) ErrorHandler(ex); GC.Collect(); } }
public ActionResult Report(string filter) { //if (report.Acao == RP.Report.TipoAcao.Agendar) //{ // return RP.Report.Generic.Json(report); //} int idUsuario = _idUsuario > 0 ? _idUsuario : Convert.ToInt32(Request["idUsuario"]); Dictionary<string, System.Data.DataSet> listData = new Dictionary<string, System.Data.DataSet>(); System.Data.DataSet ds = new System.Data.DataSet(); System.Data.DataTable table = new System.Data.DataTable("table"); System.Data.DataRow row; string titulo; BLL.MenuBLL menuBLL; BLL.AcaoBLL acaoBLL; try { using (var db = new Context()) { menuBLL = new BLL.MenuBLL(db, idUsuario); acaoBLL = new BLL.AcaoBLL(db, idUsuario); var menus = menuBLL.Search(filter); table.Columns.Add(new System.Data.DataColumn("idmenu", System.Type.GetType("System.Int32"))); table.Columns.Add(new System.Data.DataColumn("nmmenu", System.Type.GetType("System.String"))); table.Columns.Add(new System.Data.DataColumn("nmacao", System.Type.GetType("System.String"))); table.Columns.Add(new System.Data.DataColumn("dsacao", System.Type.GetType("System.String"))); table.Columns.Add(new System.Data.DataColumn("acaomenu", System.Type.GetType("System.String"))); foreach (Menu menu in menus) { var acoes = acaoBLL.Find(e => e.idMenu == menu.idMenu).ToList(); if (acoes.Count() > 0) { foreach (Acao acao in acoes) { row = table.NewRow(); row["idmenu"] = menu.idMenu; row["nmmenu"] = menu.nmMenu; row["nmacao"] = acao.nmAcao; row["dsacao"] = acao.dsAcao; row["acaomenu"] = acao.nmMenu; table.Rows.Add(row); } } else { row = table.NewRow(); row["idmenu"] = menu.idMenu; row["nmmenu"] = menu.nmMenu; table.Rows.Add(row); } } ds.Tables.Add(table); listData.Add("subentidade.rpt", RP.Sistema.BLL.EntidadeBLL.getDtSetEntidade(db)); listData.Add("table", ds); } titulo = string.Format("<center>Relação de Menus{0}</center>", !string.IsNullOrEmpty(filter) ? ("</br>Nome contendo: " + filter) : ""); return View(); //return RP.Report.Generic.Report(new RP.Report.Generic.GenericData //{ // exportTO = RP.Report.Generic.stringTOExportFormatType("PDF"), // fileRPT = "relModulo.rpt", // listData = listData, // parameters = new Dictionary<string, object> { { "titulo", titulo } }, //}); } catch (RP.Report.Exception rex) { RP.Util.Entity.ErroLog.Add(rex, Session.SessionID, idUsuario); return RedirectToAction("Index", "Erro"); } catch (Exception ex) { RP.Util.Entity.ErroLog.Add(ex, Session.SessionID, idUsuario); return RedirectToAction("Index", "Erro"); } finally { ds.Dispose(); } }
public ActionResult Report(string filter) { //if (report.Acao == RP.Report.TipoAcao.Agendar) //{ // return RP.Report.Generic.Json(report); //} int idUsuario = _idUsuario > 0 ? _idUsuario : Convert.ToInt32(Request["idUsuario"]); Dictionary<string, System.Data.DataSet> listData = new Dictionary<string, System.Data.DataSet>(); System.Data.DataSet ds = new System.Data.DataSet(); System.Data.DataTable table = new System.Data.DataTable("table"); System.Data.DataRow row; string titulo; BLL.AreaBLL areaBLL; try { using (var db = new Context()) { areaBLL = new BLL.AreaBLL(db, idUsuario); var areas = areaBLL.Search(filter); table.Columns.Add(new System.Data.DataColumn("idarea", System.Type.GetType("System.Int32"))); table.Columns.Add(new System.Data.DataColumn("nmarea", System.Type.GetType("System.String"))); table.Columns.Add(new System.Data.DataColumn("dsarea", System.Type.GetType("System.String"))); table.Columns.Add(new System.Data.DataColumn("flusaurl", System.Type.GetType("System.String"))); foreach (Area area in areas) { row = table.NewRow(); row["idarea"] = area.idArea; row["nmarea"] = area.nmArea; row["dsarea"] = area.dsArea; row["flusaurl"] = area.flUsaURL; table.Rows.Add(row); } ds.Tables.Add(table); listData.Add("subentidade.rpt", RP.Sistema.BLL.EntidadeBLL.getDtSetEntidade(db)); listData.Add("table", ds); } titulo = string.Format("<center>Relação de Áreas{0}</center>", !string.IsNullOrEmpty(filter) ? ("</br>Nome contendo: " + filter) : ""); //return View(); return RP.Report.Generic.Report(new RP.Report.Generic.GenericData { exportTO = RP.Report.Generic.stringTOExportFormatType("PDF"), fileRPT = "relArea.rpt", listData = listData, parameters = new Dictionary<string, object> { { "titulo", titulo } }, }); } catch (RP.Report.Exception rex) { RP.Util.Entity.ErroLog.Add(rex, Session.SessionID, idUsuario); return RedirectToAction("Index", "Erro"); } catch (Exception ex) { RP.Util.Entity.ErroLog.Add(ex, Session.SessionID, idUsuario); return RedirectToAction("Index", "Erro"); } finally { ds.Dispose(); } }
private void OpenWorbook(string fileName) { try { bool bContinue = true; if (string.IsNullOrEmpty(fileName)) { bContinue = false; using (OpenFileDialog openFileDialog = new OpenFileDialog() { Filter = Properties.Resources.FILE_OPENFILE_FILTER }) { if (openFileDialog.ShowDialog() == DialogResult.OK) { fileName = openFileDialog.FileName; openFileDialog.RestoreDirectory = false; bContinue = true; } } } if (bContinue) { Cursor.Current = Cursors.WaitCursor; System.Threading.Tasks.Task WorbookOpenThread = System.Threading.Tasks.Task.Run(() => { WorbookOpen(); }); WorbookOpenThread.Wait(); CatchupUIThread(); Cursor.Current = Cursors.Default; } void WorbookOpen() { using (System.IO.FileStream stream = System.IO.File.Open(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read)) { using (System.Data.DataSet WorkBookDataSet = new System.Data.DataSet()) { System.Data.DataSet workbookdataset = WorkBookDataSet; switch (System.IO.Path.GetExtension(fileName).ToUpperInvariant()) { case Constants.FILE_CSV_EXTENSION: using (IExcelDataReader reader = ExcelReaderFactory.CreateCsvReader(stream)) { workbookdataset = reader.AsDataSet(new ExcelDataSetConfiguration() { ConfigureDataTable = (_) => new ExcelDataTableConfiguration() { UseHeaderRow = true } }); DataTableCollection = workbookdataset.Tables; } break; case Constants.FILE_XLS_EXTENSION: using (IExcelDataReader reader = ExcelReaderFactory.CreateBinaryReader(stream)) { workbookdataset = reader.AsDataSet(new ExcelDataSetConfiguration() { ConfigureDataTable = (_) => new ExcelDataTableConfiguration() { UseHeaderRow = true } }); DataTableCollection = workbookdataset.Tables; } break; default: using (IExcelDataReader reader = ExcelReaderFactory.CreateOpenXmlReader(stream)) { workbookdataset = reader.AsDataSet(new ExcelDataSetConfiguration() { ConfigureDataTable = (_) => new ExcelDataTableConfiguration() { UseHeaderRow = true } }); DataTableCollection = workbookdataset.Tables; } break; } workbookdataset.Dispose(); } ClassLibraryStandard.DataTableMethods.CreateAutoIncrementID(DataTableCollection, Constants.KEY_COLUMN); } } void CatchupUIThread() { DropPreLoadPictureBox.Visible = false; FilenameTextBox.Text = fileName; SheetComboBox.Items.Clear(); foreach (System.Data.DataTable table in DataTableCollection) { SheetComboBox.Items.Add(table.TableName); } SaveAsLastFileOpened(fileName); SheetComboBox.SelectedIndex = 0; SheetComboBox.Enabled = true; SaveWorkbookButton.Enabled = true; SetSpreadsheetChanges(false); } } catch (System.IO.IOException ex) { MessageBox.Show(ClassLibraryStandard.FileInteropServices.IsFileLocked(ex) ? string.Format(UserHelper.culture, Properties.Resources.NOTIFY_FILEINUSE, System.Environment.NewLine, fileName) : string.Format(UserHelper.culture, Properties.Resources.NOTIFY_FILEOPEN_FAILED, System.Environment.NewLine, fileName), Properties.Resources.CAPTION_OPEN_WORKBOOK, MessageBoxButtons.OK, MessageBoxIcon.Error); if (log != null) { log.Error(ClassLibraryStandard.FileInteropServices.IsFileLocked(ex) ? string.Format(UserHelper.culture, Properties.Resources.NOTIFY_FILEINUSE, System.Environment.NewLine, fileName) : string.Format(UserHelper.culture, Properties.Resources.NOTIFY_FILEOPEN_FAILED, System.Environment.NewLine, fileName), ex); } if (FilenameTextBox.Text == fileName) { FilenameTextBox.Clear(); } } }
/// <summary> /// ��XML�ĵ� /// </summary> /// <param name="name">Ҫȡ�������ļ��е�ָ������Դ������,��:��ϵͳ "oldsystem" </param> public ConfigStruct readXML(string name) { try { //�����µĽṹ���� ConfigStruct cfg = new ConfigStruct(); //����һ���µ�dataset System.Data.DataSet ds = new System.Data.DataSet(); //�ж��ļ��Ƿ����,��������ʾ������һ���յĽṹ���� if (System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory.TrimEnd(new char[] {'\\'}) +"\\"+_FileName)) { //����������ȡconfig.xml�ļ������� ds.ReadXml(AppDomain.CurrentDomain.BaseDirectory.TrimEnd(new char[] {'\\'}) +"\\" +_FileName); } else { // System.Windows.Forms.MessageBox.Show("config.xml�ļ�������!" , "����", // System.Windows.Forms.MessageBoxButtons.OK , // System.Windows.Forms.MessageBoxIcon.Warning); return new ConfigStruct(); } //�жϱ��Ƿ����,��������ʾ������һ���յĽṹ���� if (ds.Tables.IndexOf(name.ToUpper())== -1 ) { // System.Windows.Forms.MessageBox.Show("��config.xml�в����ҵ���ص�����Դ��������Ϣ!" , "����", // System.Windows.Forms.MessageBoxButtons.OK , // System.Windows.Forms.MessageBoxIcon.Warning); return new ConfigStruct(); } SymmetricMethod sm = new SymmetricMethod(); // cfg.hostAddress = "CIT16-PC"; //cfg.userName ="******"; //cfg.password ="******"; //cfg.DBName = "AutoUpDateData"; //������ȡ��ֵ cfg.hostAddress = sm.Decrypto(ds.Tables[name.ToUpper()].Select("key='" + sm.Encrypto(str_HA) + "'")[0]["value"].ToString()); cfg.userName = sm.Decrypto(ds.Tables[name.ToUpper()].Select("key='" + sm.Encrypto(str_UN) + "'")[0]["value"].ToString()); cfg.password = sm.Decrypto(ds.Tables[name.ToUpper()].Select("key='" + sm.Encrypto(str_PWD) + "'")[0]["value"].ToString()); cfg.DBName = sm.Decrypto(ds.Tables[name.ToUpper()].Select("key='" + sm.Encrypto(str_DBN) + "'")[0]["value"].ToString()); ds.Dispose(); return cfg; } catch//(Exception exp) { //System.Windows.Forms.MessageBox.Show(exp.Message); return new ConfigStruct(); } }
protected void Page_Load(object sender, EventArgs e) { //查找菜单功能 string searchinfo = DNTRequest.GetString("searchinf"); if (searchinfo != "") { System.Data.DataSet dsSrc = new System.Data.DataSet(); dsSrc.ReadXml(Utils.GetMapPath(BaseConfigs.GetForumPath.ToLower() + "admin/xml/navmenu.config")); menucount = dsSrc.Tables["toptabmenu"].Rows.Count; int count = 0; bool isexist = false; sb.Append("<table width=\"98%\" align=\"center\"><tr>"); foreach (System.Data.DataRow dr in dsSrc.Tables["submain"].Rows) { //先找出子菜单表中的相关菜单 if (dr["menutitle"].ToString().IndexOf(searchinfo) >= 0) { isexist = true; if (count >= 3) { count = 0; sb.Append("</tr><tr>"); } sb.Append("<td align=\"left\" width=\"33%\">"); try { sb.Append("[" + dsSrc.Tables["mainmenu"].Select("menuid=" + dr["menuparentid"].ToString().ToString().Trim())[0]["menutitle"].ToString().Trim() + "]"); } catch {; } sb.Append("<a href=\"#\" onclick=\"javascript:resetindexmenu('showmainmenu','toptabmenuid','mainmenulist','" + dr["link"] + "');\">" + dr["menutitle"].ToString().ToString() + "</a></td>"); foreach (System.Data.DataRow toptabdr in dsSrc.Tables["toptabmenu"].Rows) { //当顶部菜单(tabmenu)中的mainmenuidlist中出现子菜单(submenu)中父menuparentid字符时 if (("," + toptabdr["mainmenuidlist"].ToString() + ",").IndexOf("," + dr["menuparentid"] + ",") >= 0) { sb.Replace("toptabmenuid", toptabdr["id"].ToString()); sb.Replace("mainmenulist", toptabdr["mainmenulist"].ToString()); string[] idlist = toptabdr["mainmenuidlist"].ToString().Split(','); for (int i = 0; i < idlist.Length; i++) { if (idlist[i] == dr["menuparentid"].ToString()) //找出要显示的mainmenuid { sb.Replace("showmainmenu", toptabdr["mainmenulist"].ToString().Split(',')[i]); break; } } break; } } count++; } } if (!isexist) { sb.Append("没有找到相匹配的结果"); } sb.Append("</tr></table>"); dsSrc.Dispose(); } else { sb.Append("您未输入任何搜索关键字"); } }
/// <summary> /// </summary> /// <param name="idProfile"></param> /// <param name="reg"></param> public static bool sendNotificaAnnullamento(string idProfile, DocsPaVO.utente.Registro reg) { #region nuova gestione interop string err = ""; bool esito = true; //presume successo //todo da calcolare; try { // estrazione dati + controllo mittente est o int System.Data.DataSet dsMitt = null; System.Data.DataSet dsProto = null; DocsPaDB.Query_DocsPAWS.Interoperabilita obj = new DocsPaDB.Query_DocsPAWS.Interoperabilita(); obj.getMittSegn(out dsMitt, idProfile); if ((InteroperabilitaUtils.InteropIntNoMail || InteroperabilitaSemplificataManager.IsDocumentReceivedWithIS(idProfile)) && dsMitt != null && dsMitt.Tables[0].Rows.Count > 0 && dsMitt.Tables["INFO_MITT"].Rows[0]["CHA_TIPO_IE"] != null && !dsMitt.Tables["INFO_MITT"].Rows[0]["CHA_TIPO_IE"].Equals(System.DBNull.Value)) { obj.getDatiProtoSpedito(out dsProto, idProfile); string sep = DocsPaDB.Utils.Personalization.getInstance(reg.idAmministrazione).getSepSegnatura(); string codAmm = DocsPaDB.Utils.Personalization.getInstance(reg.idAmministrazione).getCodiceAmministrazione(); string[] protoMitt = dsMitt.Tables["INFO_MITT"].Rows[0]["VAR_PROTO_IN"].ToString().Split(sep.ToCharArray(), 2); string dataProtoMitt = dsMitt.Tables["INFO_MITT"].Rows[0]["DTA_PROTO_IN"].ToString(); string dataProto = dsProto.Tables["INFO_PROTO"].Rows[0]["DTA_PROTO"].ToString(); string numProto = dsProto.Tables["INFO_PROTO"].Rows[0]["NUM_PROTO"].ToString(); string dataAnnulla = dsProto.Tables["INFO_PROTO"].Rows[0]["DTA_ANNULLA"].ToString(); string motivoAnnulla = dsProto.Tables["INFO_PROTO"].Rows[0]["VAR_AUT_ANNULLA"].ToString(); if (protoMitt != null && dataProtoMitt != null && protoMitt.Length > 1) { DocsPaVO.Interoperabilita.NotificaAnnullamento not = new DocsPaVO.Interoperabilita.NotificaAnnullamento(); not.codAmm = codAmm; not.codAmm_Mitt = codAmm; //so che viene dalla stessa amm, ma in futuro posso valutarlo nelle multiamm, dalla dpa_stato_invio ?. not.codAOO = reg.codRegistro; not.codAOO_Mitt = protoMitt[0]; not.dataRegistr_Mitt = dataProtoMitt.Substring(0, dataProtoMitt.IndexOf(" ")); not.dataRegistrazione = dataProto.Substring(0, dataProtoMitt.IndexOf(" "));; not.numeroRegistr_Mitt = protoMitt[1]; not.numeroRegistrazione = numProto; not.dataAnnullamento = dataAnnulla; not.motivoAnnullamento = motivoAnnulla; // Se il documento è stato ricevuto per interoperabilità semplificata, l'elaborazione // viene demandata al gestore dell'IS if (InteroperabilitaSemplificataManager.IsDocumentReceivedWithIS(idProfile)) { esito = BusinessLogic.interoperabilita.Semplificata.SimplifiedInteroperabilityRecordDroppedAndExceptionManager.SendDocumentDroppedOrExceptionProofToSender(not.motivoAnnullamento, idProfile, not.codAmm, true); } else { //ATTENZIONE SOSTITUIRE CON NUOVA PROCEDURA esito = BusinessLogic.Interoperabilità.InteroperabilitaNotificaAnnullamento.processaNotificaAnnullamento(not, out err); } } dsMitt.Dispose(); dsProto.Dispose(); } else #endregion { esito = sendNotificaAnnulla(idProfile, reg); } } catch (Exception e) { esito = false; logger.Debug("Errore nella gestione dell'interoperabilità. (sendRicevutaRitorno)" + " ", e); throw e; } return(esito); }