Ejemplo n.º 1
0
        /// <summary>
        /// Saves the dataset encrypted in specified file
        /// </summary>
        /// <param name="dataset">Dataset to save</param>
        /// <param name="username">Username for encryption</param>
        /// <param name="password">Password for encryption</param>
        /// <param name="fileName">File name where to save</param>
        /// <param name="compress">Should the file be compressed</param>
        internal static void EncryptDataSet(System.Data.DataSet dataset, string username, string password, string fileName, bool compress)
        {
            // Check the parameters
            if (dataset == null ||
                string.IsNullOrEmpty(username) ||
                string.IsNullOrEmpty(password) ||
                string.IsNullOrEmpty(fileName))
            {
                throw new System.ArgumentNullException("All arguments must be supplied.");
            }

            // Save the dataset as encrypted
            using (System.Security.Cryptography.Aes aes = Cryptography.InitAes(username, password)) {
                using (System.IO.FileStream fileStream = new System.IO.FileStream(fileName, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite, System.IO.FileShare.None)) {
                    using (System.Security.Cryptography.CryptoStream cryptoStream = new System.Security.Cryptography.CryptoStream(fileStream, aes.CreateEncryptor(), System.Security.Cryptography.CryptoStreamMode.Write)) {
                        if (compress)
                        {
                            // when compression is requested, use GZip
                            using (System.IO.Compression.GZipStream zipStream = new System.IO.Compression.GZipStream(cryptoStream, System.IO.Compression.CompressionMode.Compress)) {
                                dataset.WriteXml(zipStream, System.Data.XmlWriteMode.WriteSchema);
                                zipStream.Flush();
                            }
                        }
                        else
                        {
                            dataset.WriteXml(cryptoStream, System.Data.XmlWriteMode.WriteSchema);
                            cryptoStream.FlushFinalBlock();
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static System.Data.DataSet dsFtp = new System.Data.DataSet();            // 存储Ftp队列表

        /// <summary>
        /// Ftp上传请求入队
        /// </summary>
        /// <param name="Folder">文件目录</param>
        /// <param name="FileName">文件名</param>
        /// <param name="FtpSrv">Ftp服务器IP</param>
        /// <param name="FtpPort">端口</param>
        /// <param name="FtpU">用户名</param>
        /// <param name="FtpP">密码</param>
        /// <param name="FtpFolder">要上传到的Ftp目录</param>
        /// <returns></returns>
        public static void Ftp_Enqueue(string Folder, string FileName, string FtpSrv, int FtpPort, string FtpU, string FtpP, string FtpFolder)
        {
            if (!Folder.EndsWith("\\"))
            {
                Folder += "\\";
            }

            if (FtpFile == null || FtpFile.Length < 1)
            {
                FtpFile = GlobalObject.XmlConfigChain[typeof(FtpQueue), "FtpFile"];
                // 加载Ftp队列数据
                if (FtpFile != null && File.Exists(FtpQueue.FtpFile))
                {
                    FtpQueue.dsFtp.ReadXml(FtpQueue.FtpFile);
                }
            }
            if (FtpFile == null || FtpFile.Length < 1)
            {
                throw new Exception("无法保存队列,请检查队列文件设置");
            }

            if (dsFtp.Tables.Count == 0)
            {
                // 给定架构
                System.Data.DataTable dt = dsFtp.Tables.Add("FtpQueue");
                dt.Columns.Add("ID", typeof(int));
                dt.Columns.Add("Folder");
                dt.Columns.Add("FileName");
                dt.Columns.Add("FtpSrv");
                dt.Columns.Add("FtpPort", typeof(int));
                dt.Columns.Add("FtpU");
                dt.Columns.Add("FtpP");
                dt.Columns.Add("FtpFolder");

                dt.Columns["ID"].AutoIncrementSeed = 1;
                dt.Columns["ID"].AutoIncrementStep = 1;
                dt.Columns["ID"].AutoIncrement     = true;
            }

            System.Data.DataRow dr = dsFtp.Tables[0].NewRow();
            dr["Folder"]    = Folder;
            dr["FileName"]  = FileName;
            dr["FtpSrv"]    = FtpSrv;
            dr["FtpPort"]   = FtpPort;
            dr["FtpU"]      = FtpU;
            dr["FtpP"]      = FtpP;
            dr["FtpFolder"] = FtpFolder;
            dsFtp.Tables[0].Rows.InsertAt(dr, 0);

            // 存回文件
            dsFtp.WriteXml(FtpFile, System.Data.XmlWriteMode.WriteSchema);
        }
Ejemplo n.º 3
0
        public static void SaveData()
        {
            System.Data.DataSet   ds    = new System.Data.DataSet("SteamworkGUI");
            System.Data.DataTable table = new System.Data.DataTable("Data");
            ds.Tables.Add(table);

            table.Columns.Add("account", typeof(string));
            table.Columns.Add("appid", typeof(int));
            table.Columns.Add("language", typeof(string));

            System.Data.DataRow row = table.NewRow();
            row[0] = MainWindow._instance.user_name;
            row[1] = MainWindow._instance.Appid;
            row[2] = MainWindow._instance.LanguagePack;

            ds.Tables["Data"].Rows.Add(row);
            string path = Environment.CurrentDirectory + "/data.xml";

            try
            {
                ds.WriteXml(path);
            }
            catch
            {
            }
        }
Ejemplo n.º 4
0
        public static void Test()
        {
            string inFile     = @"D:\username\Desktop\Mappe1.ods";
            string outFileXml = @"D:\username\Desktop\mysheet.xml";
            string outFile    = @"D:\username\Desktop\notmysheet.ods";

            if (System.Environment.OSVersion.Platform == System.PlatformID.Unix)
            {
                inFile     = "/root/Documents/mysheet.ods";
                outFileXml = "/root/Documents/mysheet.xml";
                outFile    = "/root/Documents/notmysheet.ods";
            } // End if (System.Environment.OSVersion.Platform == System.PlatformID.Unix)

            OdsReaderWriter odr = new OdsReaderWriter();

            using (System.Data.DataSet ds = odr.ReadOdsFile(inFile))
            {
                System.Console.WriteLine(ds.Tables.Count);
                using (System.IO.FileStream fs = System.IO.File.OpenWrite(outFileXml))
                {
                    //ds.WriteXml(fs, System.Data.XmlWriteMode.WriteSchema);
                    ds.WriteXml(fs, System.Data.XmlWriteMode.IgnoreSchema);
                } // End Using fs

                odr.WriteOdsFile(ds, outFile);
            } // End Using ds
        }     // End Sub Test
		internal static void Process (List<string> assemblies, string outputPath)
		{
			List<string> valid_config_files = new List<string> ();
			foreach (string assembly in assemblies) {
				string assemblyConfig = assembly + ".config";
				if (File.Exists (assemblyConfig)) {
					XmlDocument doc = new XmlDocument ();
					try {
						doc.Load (assemblyConfig);
					} catch (XmlException) {
						doc = null;
					}
					if (doc != null)
						valid_config_files.Add (assemblyConfig);
				}
			}
			
			if (valid_config_files.Count == 0)
				return;

			string first_file = valid_config_files [0];
			System.Data.DataSet dataset = new System.Data.DataSet ();
			dataset.ReadXml (first_file);
			valid_config_files.Remove (first_file);
			
			foreach (string config_file in valid_config_files) {
				System.Data.DataSet next_dataset = new System.Data.DataSet ();
				next_dataset.ReadXml (config_file);
				dataset.Merge (next_dataset);
			}
			dataset.WriteXml (outputPath + ".config");
		}
Ejemplo n.º 6
0
 private static System.Data.DataSet GetSettingDataSet()
 {
     if (_CurrentDataSet == null)
     {
         string cPath           = ConfigPath;
         System.Data.DataSet ds = new System.Data.DataSet();
         if (System.IO.File.Exists(cPath))
         {
             ds.ReadXml(cPath);
         }
         else
         {
             System.Data.DataTable dt = new System.Data.DataTable();
             dt.TableName = "SoftSetting";
             dt.Columns.Add("DataKeys");
             dt.Columns.Add("DataValues");
             ds.Tables.Add(dt);
             ds.DataSetName = "SystemSetting";
             string dir = System.IO.Path.GetDirectoryName(cPath);
             if (!System.IO.Directory.Exists(dir))
             {
                 System.IO.Directory.CreateDirectory(dir);
             }
             ds.WriteXml(cPath);
         }
         _CurrentDataSet = ds;
     }
     return(_CurrentDataSet);
 }
Ejemplo n.º 7
0
        public static void SetSoftConfig(string pKey, string pNValue)
        {
            System.Data.DataSet   ds  = GetSettingDataSet();
            System.Data.DataRow[] drs = ds.Tables[0].Select("DataKeys='" + pKey + "'");
            if (drs.Length > 0)
            {
                if (drs[0]["DataValues"].ToString() == pNValue)
                {
                    return;                                            //值没有发生改变
                }
                else
                {
                    drs[0]["DataValues"] = pNValue;
                }
            }
            else
            {
                System.Data.DataRow dr = ds.Tables[0].NewRow();
                dr["DataKeys"]   = pKey;
                dr["DataValues"] = pNValue;
                ds.Tables[0].Rows.Add(dr);
            }
            string cPath = (ConfigPath);

            ds.WriteXml(cPath);
            _CurrentDataSet = null;
        }
Ejemplo n.º 8
0
        private bool bSalvaDadosInternet(bool bProxy, string strProxyHost, string strProxyPort, bool bProxyAutentication, string strProxyUser, string strProxyPassword)
        {
            bool bRetorno = true;

            System.Data.DataSet   dtstProxy = new System.Data.DataSet(DATASET_NAME);
            System.Data.DataTable dttbProxy = new System.Data.DataTable(DATASET_PROXY_NAME);
            dttbProxy.Columns.Add(DATASET_HOST_NAME);
            dttbProxy.Columns.Add(DATASET_PORT_NAME);
            dttbProxy.Columns.Add(DATASET_USER_NAME);
            dttbProxy.Columns.Add(DATASET_PASSWORD_NAME);
            dtstProxy.Tables.Add(dttbProxy);

            System.Data.DataRow dtrwProxy = dttbProxy.NewRow();
            dtrwProxy[DATASET_HOST_NAME]     = strProxyHost;
            dtrwProxy[DATASET_PORT_NAME]     = strProxyPort;
            dtrwProxy[DATASET_USER_NAME]     = strProxyUser;
            dtrwProxy[DATASET_PASSWORD_NAME] = strProxyPassword;
            dttbProxy.Rows.Add(dtrwProxy);

            try{
                dtstProxy.WriteXml(m_strFileConfigPath + m_strFileConfigName);
            }catch {
                bRetorno = false;
            }
            return(bRetorno);
        }
Ejemplo n.º 9
0
 private void CheckPath(string p)
 {
     try
     {
         if (string.IsNullOrEmpty(p))
         {
             p = PicPath;
         }
         if (Directory.Exists(p) && Directory.GetFiles(p, "*.jpg", SearchOption.TopDirectoryOnly).Length > 0)
         {
             PicPath = p;
             DS.Tables[0].Rows.Find(br.Name)[1] = p.Replace(AppPath, ".");
             DS.WriteXml(AppPath + "\\ShowPic.Dat", System.Data.XmlWriteMode.WriteSchema);
             ls.Clear();
             foreach (string s in Directory.GetFiles(PicPath, "*.jpg", SearchOption.TopDirectoryOnly))
             {
                 ls.Add(s);
             }
         }
         else
         {
             MessageBox.Show("目录中没有图片,请重新选择路径");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 10
0
        private static void NewMethod()
        {
            ds = new System.Data.DataSet("X");
            {
                ds.Tables.Add(Class1.CreateDataStoreConfigTable( ));
                ds.Tables.Add(Class1.CreateDataStoreSnapshotFileTable( ));
                ds.Tables.Add(Class1.CreateMetadataItemTable( ));
            }
            Class1.LoadDataStoreSnapshotFilesTable(ds);
            {
                ActiveQueryBuilder.Core.SQLContext sc = Class1.CreateAqbSqlContext4SQLiteOffline(filepath);
                Class1.DrillDownAqbSqlContext(sc, ds.Tables[Class1.MetadataItem_TblName], "Ale");
            }

            //ds.Tables.Add( Class1.CreateDataSetSnapshotTable( ) );
            //ds.Tables.Add( Class1.CreateMetadataItemTable( ) );
            //Class1.ZZZZZZZZ( ds );
            ////
            ////
            ds.WriteXml(filepath2);
            //{
            //   ds.RemotingFormat = System.Data.SerializationFormat.Binary;
            //   using( System.IO.FileStream fs = new System.IO.FileStream( filepath3, System.IO.FileMode.Create ) )
            //   {
            //      System.Runtime.Serialization.Formatters.Binary.BinaryFormatter fmt = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter( );
            //      fmt.Serialize( fs, ds );
            //      fs.Close( );
            //   }
            //}
            //{
            //   System.Data.DataSet o = new System.Data.DataSet( );
            //   o.ReadXml( filepath2 );
            //}
        }
Ejemplo n.º 11
0
        public static void PersistLog(System.Data.DataTable dt)
        {
            System.Data.DataSet ds = dt.DataSet;
            // ds.Tables.Add(dt);
            string filePath = String.Format("{0}/{1}", GetExecutingPath(), REQUESTLOG_FILENAME);

            ds.WriteXml(filePath);
        }
Ejemplo n.º 12
0
 private void CheckPath(string p)
 {
     try
     {
         if (string.IsNullOrEmpty(p))
         {
             foreach (string s in Directory.GetFiles(AppPath + "\\PPT", "*.ppt", SearchOption.TopDirectoryOnly))
             {
                 PPTPath = s;
                 break;
             }
         }
         else
         {
             PPTPath = p;
         }
         PPTPath = PPTPath.Replace(AppPath, ".");
         if (!string.IsNullOrEmpty(PPTPath) && File.Exists(PPTPath))
         {
             FileInfo fi   = new FileInfo(PPTPath);
             string   path = fi.DirectoryName + "\\" + fi.Name.Replace(fi.Extension, string.Empty);
             bool     err  = false;
             if (Directory.Exists(path))
             {
                 if (Directory.GetFiles(path, "*.jpg", SearchOption.TopDirectoryOnly).Length == 0)
                 {
                     err = true;
                     Directory.Delete(path, true);
                 }
             }
             else
             {
                 err = true;
             }
             if (err)
             {
                 PowerPoint.Presentation pr = new PowerPoint.Application().Presentations.Open((PPTPath.StartsWith(".") ? AppPath + PPTPath.TrimStart('.') : PPTPath), PowerPoint.MsoTriState.msoTrue, PowerPoint.MsoTriState.msoFalse, PowerPoint.MsoTriState.msoFalse);
                 pr.SaveAs(path + ".jpg", PowerPoint.PpSaveAsFileType.ppSaveAsJPG, PowerPoint.MsoTriState.msoTrue);
                 pr.Close();
             }
             foreach (string s in Directory.GetFiles(path, "*.jpg", SearchOption.TopDirectoryOnly))
             {
                 ImageBrush b = new ImageBrush();
                 b.ImageSource   = new BitmapImage(new Uri(s, UriKind.RelativeOrAbsolute));
                 b.Stretch       = Stretch.UniformToFill;
                 Bor1.Background = b;
                 break;
             }
             DS.Tables[0].Rows.Find(br.Name)[1] = PPTPath;
             DS.WriteXml(AppPath + "\\ShowPPT.Dat", System.Data.XmlWriteMode.WriteSchema);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 13
0
 /// <summary>
 /// 储存XML
 /// </summary>
 /// <param name="dtYhm"></param>
 /// <param name="sDSName"></param>
 /// <param name="sXMLPath"></param>
 public void SaveXML(System.Data.DataTable dtYhm, string sDSName, string sXMLPath)
 {
     lock (this)
     {
         System.Data.DataSet set = new System.Data.DataSet(sDSName);
         set.Tables.Add(dtYhm.Copy());
         set.WriteXml(sXMLPath);
     }
 }
Ejemplo n.º 14
0
        public void GetMyTestDataXmlFile()
        {
            var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["IntegrationTests.Properties.Settings.TDDWithMVCConnectionString"].ConnectionString;

            var mySqlDatabase = new SqlDbUnitTest(connectionString);

            mySqlDatabase.ReadXmlSchema(DatabaseXsd02);

            System.Data.DataSet ds = mySqlDatabase.GetDataSetFromDb();
            ds.WriteXml(TestdataXml02);
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Converts the provided dataset into an XPathNavigator instance.
 /// </summary>
 /// <param name="ds"></param>
 /// <param name="context"></param>
 /// <returns></returns>
 protected virtual XPathNavigator ConvertDataSetToXPath(System.Data.DataSet ds, string rootTable, PDFDataContext context)
 {
     using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
     {
         //ds.Tables[rootTable].DefaultView.ToTable().WriteXml(ms);
         ds.WriteXml(ms);
         ms.Flush();
         ms.Position = 0;
         XPathDocument doc = new XPathDocument(ms);
         return(doc.CreateNavigator());
     }
 }
Ejemplo n.º 16
0
 public bool bCriaBackup()
 {
     try
     {
         m_cls_dba_ConectionDB.Log           = true;
         m_cls_dba_ConectionDB.FonteDosDados = mdlDataBaseAccess.FonteDados.DataBase;
         System.Collections.ArrayList arlListaArquivo = new System.Collections.ArrayList();
         System.Data.DataSet          dtsetTemp       = new System.Data.DataSet("Backup");
         invocarMetodosDataAccessGet(ref dtsetTemp);
         System.Data.DataTable dtTbTemp = new System.Data.DataTable(TBVERSAOBACKUPTEXTO);
         dtTbTemp.Columns.Add(DATABACKUP, System.Type.GetType("System.DateTime"));
         dtTbTemp.Columns.Add(VERSAOBACKUPTEXTO, System.Type.GetType("System.String"));
         dtTbTemp.Columns.Add(VERSAOSISCOBRASTEXTO, System.Type.GetType("System.String"));
         System.Data.DataRow dtRow = dtTbTemp.NewRow();
         dtRow[DATABACKUP]           = m_dtDataBackup;
         dtRow[VERSAOBACKUPTEXTO]    = m_rdRandomico.Next().ToString();
         dtRow[VERSAOSISCOBRASTEXTO] = m_rdRandomico.Next().ToString();
         dtsetTemp.Tables.Add(dtTbTemp);
         if (!System.IO.Directory.Exists(m_strDiretorioTemporario))
         {
             System.IO.Directory.CreateDirectory(m_strDiretorioTemporario);
         }
         dtsetTemp.WriteXml(m_strDiretorioTemporario + "\\" + ARQUIVOXML, System.Data.XmlWriteMode.WriteSchema);
         arlListaArquivo.Add(m_strDiretorioTemporario + "\\" + ARQUIVOXML);
         mdlCompactacao.clsCompactacao obj = new mdlCompactacao.clsCompactacao(ref m_cls_ter_tratadorErro);
         if (!System.IO.Directory.Exists(m_strEnderecoBackup))
         {
             System.IO.Directory.CreateDirectory(m_strEnderecoBackup);
         }
         if (System.IO.File.Exists(m_strEnderecoBackup + "\\" + m_strArquivoBackup))
         {
             System.IO.File.Delete(m_strEnderecoBackup + "\\" + m_strArquivoBackup);
         }
         obj.compacta(ref arlListaArquivo, m_strEnderecoBackup + "\\" + m_strArquivoBackup, mdlCompactacao.NIVELCOMPACTACAO.MAXIMO);
         try
         {
             System.IO.File.Delete(m_strDiretorioTemporario + "\\" + ARQUIVOXML);
             System.IO.Directory.Delete(m_strDiretorioTemporario, true);
         }
         catch
         {
         }
     }
     catch
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Write the dataset to the stream using the specified format.
        /// </summary>
        /// <param name="destination"></param>
        /// <param name="source"></param>
        /// <param name="format"></param>
        public static void Write(System.IO.Stream destination, System.Data.DataSet source, StreamDataSetFormat format)
        {
            switch (format)
            {
            case StreamDataSetFormat.XML:
                source.WriteXml(destination, System.Data.XmlWriteMode.WriteSchema);
                break;

            case StreamDataSetFormat.Binary:
                BinWriteDataSetToStream(destination, source);
                break;

            default:
                throw new ApplicationException("StreamDataSet Format not supported");
            }
        }
Ejemplo n.º 18
0
        public bool bCriaArquivo()
        {
            bool bRetorno = false;

            try
            {
                System.Data.DataSet dtSetArquivoConfiguracao = new System.Data.DataSet("Siscobras");
                if (System.IO.File.Exists(m_strPathArquivo))
                {
                    System.IO.File.Delete(m_strPathArquivo);
                }
                dtSetArquivoConfiguracao.WriteXml(m_strPathArquivo);
                bRetorno = true;
            }catch {
            }
            return(bRetorno);
        }
        static void CreateDemoData(InMemoryDataStore inMemoryDataStore)
        {
            var ds = new System.Data.DataSet();

            using (var ms = new System.IO.MemoryStream()) {
                using (var writer = System.Xml.XmlWriter.Create(ms)) {
                    inMemoryDataStore.WriteXml(writer);
                    writer.Flush();
                }
                ms.Flush();
                ms.Position = 0;
                ds.ReadXml(ms);
            }
            var gen        = new GenHelper();
            var idsAccount = new List <string>();
            var dtAccounts = ds.Tables["Accounts"];

            for (int i = 0; i < 200; i++)
            {
                var id = gen.MakeTosh(20);
                idsAccount.Add(id);
                dtAccounts.Rows.Add(id, gen.GetFullName());
            }
            var dtMessages = ds.Tables["Messages"];

            for (int i = 0; i < 5000; i++)
            {
                var id1 = gen.Next(idsAccount.Count);
                var id2 = gen.Next(idsAccount.Count - 1);
                dtMessages.Rows.Add(null, GenHelper.ToTitle(gen.MakeBlah(gen.Next(7))), gen.MakeBlahBlahBlah(5 + gen.Next(100), 7),
                                    idsAccount[id1], idsAccount[(id1 + id2 + 1) % idsAccount.Count]);
            }
            ds.AcceptChanges();
            using (var ms = new System.IO.MemoryStream()) {
                ds.WriteXml(ms, System.Data.XmlWriteMode.WriteSchema);
                ms.Flush();
                ms.Position = 0;
                using (var reader = System.Xml.XmlReader.Create(ms)) {
                    inMemoryDataStore.ReadXml(reader);
                }
            }
        }
Ejemplo n.º 20
0
        internal static void Process(List <string> assemblies, string outputPath)
        {
            List <string> valid_config_files = new List <string> ();

            foreach (string assembly in assemblies)
            {
                string assemblyConfig = assembly + ".config";
                if (File.Exists(assemblyConfig))
                {
                    XmlDocument doc = new XmlDocument();
                    try {
                        doc.Load(assemblyConfig);
                    } catch (XmlException) {
                        doc = null;
                    }
                    if (doc != null)
                    {
                        valid_config_files.Add(assemblyConfig);
                    }
                }
            }

            if (valid_config_files.Count == 0)
            {
                return;
            }

            string first_file = valid_config_files [0];

            System.Data.DataSet dataset = new System.Data.DataSet();
            dataset.ReadXml(first_file);
            valid_config_files.Remove(first_file);

            foreach (string config_file in valid_config_files)
            {
                System.Data.DataSet next_dataset = new System.Data.DataSet();
                next_dataset.ReadXml(config_file);
                dataset.Merge(next_dataset);
            }
            dataset.WriteXml(outputPath + ".config");
        }
Ejemplo n.º 21
0
        internal static void Process(ILRepack repack)
        {
            try
            {
                var validConfigFiles = new List <string>();
                foreach (string assembly in repack.MergedAssemblyFiles)
                {
                    string assemblyConfig = assembly + ".config";
                    if (!File.Exists(assemblyConfig))
                    {
                        continue;
                    }
                    var doc = new XmlDocument();
                    doc.Load(assemblyConfig);
                    validConfigFiles.Add(assemblyConfig);
                }

                if (validConfigFiles.Count == 0)
                {
                    return;
                }

                string firstFile = validConfigFiles[0];
                var    dataset   = new System.Data.DataSet();
                dataset.ReadXml(firstFile);
                validConfigFiles.Remove(firstFile);

                foreach (string configFile in validConfigFiles)
                {
                    var nextDataset = new System.Data.DataSet();
                    nextDataset.ReadXml(configFile);
                    dataset.Merge(nextDataset);
                }
                dataset.WriteXml(repack.Options.OutputFile + ".config");
            }
            catch (Exception e)
            {
                repack.Logger.Error("Failed to merge configuration files: " + e);
            }
        }
Ejemplo n.º 22
0
        internal static void Process(ILRepack repack)
        {
            try
            {
                var validConfigFiles = new List<string>();
                foreach (string assembly in repack.MergedAssemblyFiles)
                {
                    string assemblyConfig = assembly + ".config";
                    if (File.Exists(assemblyConfig))
                    {
                        var doc = new XmlDocument();
                        doc.Load(assemblyConfig);
                        validConfigFiles.Add(assemblyConfig);
                    }
                }

                if (validConfigFiles.Count == 0)
                    return;

                string firstFile = validConfigFiles[0];
                var dataset = new System.Data.DataSet();
                dataset.ReadXml(firstFile);
                validConfigFiles.Remove(firstFile);

                foreach (string configFile in validConfigFiles)
                {
                    var nextDataset = new System.Data.DataSet();
                    nextDataset.ReadXml(configFile);
                    dataset.Merge(nextDataset);
                }
                dataset.WriteXml(repack.OutputFile + ".config");
            }
            catch (Exception e)
            {
                repack.ERROR("Failed to merge configuration files: " + e);
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 写入配置信息
        /// </summary>
        /// <param name="config">配置信息</param>
        public static void WriteConfig(Config config)
        {
            if (!Directory.Exists(configPath))
            {
                Directory.CreateDirectory(configPath);
            }

            //创建一个config.xml程序,写入同步配置文件
            System.Data.DataSet   ds    = new System.Data.DataSet("Config");
            System.Data.DataTable table = new System.Data.DataTable("System");
            ds.Tables.Add(table);
            table.Columns.Add("ProjectNum", typeof(string));
            table.Columns.Add("ProjectName", typeof(string));
            table.Columns.Add("OnloadUrl", typeof(string));
            table.Columns.Add("HumanSql", typeof(string));
            table.Columns.Add("AttendSql", typeof(string));

            System.Data.DataRow row = table.NewRow();
            row[0] = config.projectNum;
            row[1] = config.projectName;
            row[2] = config.onloadUrl;
            try
            {
                FileInfo file   = new FileInfo(datePath + "QueryHuman.sql");
                string   script = file.OpenText().ReadToEnd();
                row[3] = script.Replace("dbo.", "");
            }
            catch
            {
                row[3] = "select top(1) * from TEmployee where Car != 1";
            }
            row[4] = "select * from TEmployee";

            ds.Tables["System"].Rows.Add(row);
            ds.WriteXml(configPath + "config.xml");
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Creates the XML schema
        /// </summary>
        /// <param name="className">Class name</param>
        /// <param name="methodName">Method name</param>
        /// <param name="paramList">Parameters list</param>
        /// <returns></returns>
        public Byte[] GetAxDataCreateSchema(string className, string methodName, params object[] paramList)
        {
            XmlDocument xmlDoc = new XmlDocument();

            try
            {
                this.AxLoginAs();
                AxaptaObject axObj = _Axapta.CreateAxaptaObject(className);
                string ret = (string)this.CallAxMethod(className, methodName, paramList);

                //convert string into XML document
                xmlDoc.LoadXml(ret);

                //create XML data reader to populate dataset
                XmlNodeReader xmlReader = new XmlNodeReader(xmlDoc.DocumentElement);
                System.Data.DataSet ds = new System.Data.DataSet();

                //load dataset with XML data (load schema)
                ds.ReadXml(xmlReader, System.Data.XmlReadMode.InferSchema);

                //GZIP compress dataset with schema. Return byte array
                MemoryStream ms = new MemoryStream();
                System.IO.Compression.GZipStream zip = new System.IO.Compression.GZipStream(ms, System.IO.Compression.CompressionMode.Compress);
                ds.WriteXml(zip, System.Data.XmlWriteMode.WriteSchema);
                zip.Close();
                ms.Close();
                axObj.Dispose();

                return ms.GetBuffer();
            }
            catch (Microsoft.Dynamics.AxaptaException ex)
            {
                this.WriteErrorToEventLog(ex);
                SoapException se = new SoapException(ex.Message, SoapException.ServerFaultCode, ex.InnerException);
                throw se;
            }
            catch (Exception ex)
            {
                this.WriteErrorToEventLog(ex);
                SoapException se = new SoapException(ex.Message, SoapException.ClientFaultCode, ex.InnerException);
                throw se;
            }
            finally
            {
                this.AxLogoff();
            }
        }
        /// <summary>
        /// 执行
        /// </summary>
        /// <returns>返回执行结果</returns>
        public override object Do()
        {
            string path = this.GetValStrByKey("Path") + "_" + DateTime.Now.ToString("yy年MM月dd日HH时mm分");

            if (System.IO.Directory.Exists(path))
            {
                return("系统正在执行中,请稍后。");
            }

            System.IO.Directory.CreateDirectory(path);
            System.IO.Directory.CreateDirectory(path + "\\Flow.流程模板");
            System.IO.Directory.CreateDirectory(path + "\\Frm.表单模板");

            Flows fls = new Flows();

            fls.RetrieveAll();
            FlowSorts sorts = new FlowSorts();

            sorts.RetrieveAll();

            // 生成流程模板。
            foreach (FlowSort sort in sorts)
            {
                string pathDir = path + "\\Flow.流程模板\\" + sort.No + "." + sort.Name;
                System.IO.Directory.CreateDirectory(pathDir);
                foreach (Flow fl in fls)
                {
                    fl.DoExpFlowXmlTemplete(pathDir);
                }
            }

            // 生成表单模板。
            foreach (FlowSort sort in sorts)
            {
                string pathDir = path + "\\Frm.表单模板\\" + sort.No + "." + sort.Name;
                System.IO.Directory.CreateDirectory(pathDir);
                foreach (Flow fl in fls)
                {
                    string pathFlowDir = pathDir + "\\" + fl.No + "." + fl.Name;
                    System.IO.Directory.CreateDirectory(pathFlowDir);
                    Nodes nds = new Nodes(fl.No);
                    foreach (Node nd in nds)
                    {
                        MapData             md = new MapData("ND" + nd.NodeID);
                        System.Data.DataSet ds = md.GenerHisDataSet();
                        ds.WriteXml(pathFlowDir + "\\" + nd.NodeID + "." + nd.Name + ".Frm.xml");
                    }
                }
            }

            // 流程表单模板.
            SysFormTrees frmSorts = new SysFormTrees();

            frmSorts.RetrieveAll();
            foreach (SysFormTree sort in frmSorts)
            {
                string pathDir = path + "\\Frm.表单模板\\" + sort.No + "." + sort.Name;
                System.IO.Directory.CreateDirectory(pathDir);

                MapDatas mds = new MapDatas();
                mds.Retrieve(MapDataAttr.FK_FrmSort, sort.No);
                foreach (MapData md in mds)
                {
                    System.Data.DataSet ds = md.GenerHisDataSet();
                    ds.WriteXml(pathDir + "\\" + md.No + "." + md.Name + ".Frm.xml");
                }
            }
            return("生成成功,请打开" + path + "。<br>如果您想共享出来请压缩后发送到template@ccflow.org");
        }
Ejemplo n.º 26
0
        public bool getData(string job, string rowIndex,string po,bool isEnBlanco)
        {
            bool outPut = false;
            System.Data.DataSet DTS = null;
            System.Data.SqlClient.SqlDataAdapter myDataAdapter = null;
            SqlDataReader dr =null;
            bool isStart = true;
            int recNum = 0;
            string _qtyShipped = null;
            string _description = null;
            int _componentNumber = 0;
            string spacio = new string(' ', 17);
            int myY = 555;
            int myCopyY = 160;
            string sql =
                    "SELECT P.PackageID, P.ShipmentNumber, P.Quantity, P.Weight, P.FreightCost, P.ShipMethod, P.ShipDate, P.ComponentNumber, P.StartNumber, " +
                    "P.EndNumber, P.TrackingNumber, P.NumberofPackages, S.JobNumber, S.ShipmentNumber, S.ShipName, S.ShipAddress1, S.ShipAddress2, S.ShipAddress3, " +
                    "S.ShipCountry, S.ShipCity, S.ShipState, S.ShipZip, S.ShipCountry, S.ShipContact, S.ShipPhone, S.ShipFax, S.ShipInNameOf, S.FOB, " +
                    "S.Instructions, OC.BackOrder as BackOrderShipment, SR.Description as SalesRepName, SV.Description as ShipDescription, OH.PONumber, " +
                    "OH.JobDescription, OC.Description as ComponentDescription, C.BillName, C.BillAddress1, C.BillAddress2, C.BillCity, C.BillState, C.BillZip, " +
                    "C.BillPhone, C.BillFax, C.BillContact, C.BillCountry, OQ.Quantity as OrderQuantity, OH.CustAccount, OH.CustName, OH.CustAddress1, " +
                    "OH.CustAddress2, OH.CustAddress3, OH.CustCity, OH.CustState, OH.CustZip, OH.CustPhone, OH.CustFax, OH.CustContact, OH.FormNumber, " +
                    "OH.OriginalJobNumber, OH.ReleaseNumber, P.Description as PackageDescription, OC.BackOrderQuantity as BackOrderQuantity, P.OddPackageQty, " +
                    "S.MShipInstructions, OH.PlantID, P.PostageCost, C.TermsCode, S.Residence, OH.DeliveryDate, S.Email, OH.CSR, P.TotalQtyShipped, OH.ProofDate, " +
                    "OH.ProofTime, OH.ProofDeliveryDate, P.ShipViaService, SS.Description as ShipingServiceDescription, OH.DistPO, OC.FinGoodCode, OH.OrderDate, " +
                    "S.ThirdPartyBilling, S.Shipped, S.SequenceNumber, P.OddPackageWeight " +
                    "FROM Package P INNER JOIN Shipment S ON P.ShipmentNumber = S.ShipmentNumber " +
                    "INNER JOIN OrderHeader OH ON S.JobNumber = OH.JobNumber  " +
                    "INNER JOIN Customer C ON OH.CustAccount = C.Account  " +
                    "LEFT JOIN OrderComponent OC ON P.JobNumber = OC.JobNumber AND ((P.ComponentNumber = OC.ComponentNumber) OR " +
                    "(P.ComponentNumber = 0 AND OC.ComponentNumber = 1)) LEFT JOIN OrderQtyTable OQ ON OC.JobNumber = OQ.JobNumber AND " +
                    "OC.ComponentNumber = OQ.ComponentNumber AND OC.QtyOrdIndex = OQ.QuantityLineNo " +
                    "LEFT JOIN SalesRep SR ON OH.SalesRepCode = SR.Code " +
                    "LEFT JOIN ShipVia SV ON P.ShipMethod = SV.Code " +
                    "LEFT JOIN ShipViaService SS ON P.ShipMethod = SS.ShipviaCode AND P.ShipViaService = SS.Code " +
                    "WHERE S.JobNumber = '" + job + "' and s.sequencenumber='" + rowIndex + "';";

            string sqlGetConduceNum = "select max(ConduceNum) from tblConduce";
            int conduceNum = 0;

            string myPdfFile = null;
            string pdfCopy = null;
            if (po.Trim().Length > 0)
            {
                po += "-";
                po +=myPdfFile;
                myPdfFile = po;
            }
            pdfCopy = myPdfFile;

            try
            {
                mySQlCnn();

                myDataAdapter = new SqlDataAdapter();
                myDataAdapter.TableMappings.Add("Table", "Table1");
                DTS = new System.Data.DataSet("Table1");

                sqlCmd.CommandType = System.Data.CommandType.Text;
                sqlCmd.CommandText = sqlGetConduceNum;
                conduceNum =  (int) sqlCmd.ExecuteScalar();
                conduceNum++;
                if (!isEnBlanco)
                {
                    sqlCmd.CommandText = sql;
                    myDataAdapter.SelectCommand = sqlCmd;
                    myDataAdapter.Fill(DTS);
                    DTS.WriteXml(@"prueba.xml");
                    dr = sqlCmd.ExecuteReader();
                }

                // crate el PDF
                if (isEnBlanco)
                {
                    job = "EnBlanco";
                }
                myPdfFile = GetRegistry.Registry.read("Software\\mop\\Conduce", "pdfPath");
                myPdfFile += conduceNum + "-" + job + "-" + rowIndex + "-" + DateTime.Now.ToString("yyyMMdd") + ".pdf";
                pdfCopy ="Copy_" +  myPdfFile;

                Document document = new Document(PageSize.LETTER);
                Document Copydocument = new Document(PageSize.LETTER);

                PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(myPdfFile, FileMode.Create));
                PdfWriter Copywriter = PdfWriter.GetInstance(document, new FileStream(pdfCopy, FileMode.Create));

                document.Open();
                Copydocument.Open();

                //  we grab the ContentByte and do some stuff with it
                PdfContentByte cb = writer.DirectContent;

                // para ver el pdf
                System.Diagnostics.Process pr = new System.Diagnostics.Process();
                pr.StartInfo.FileName = myPdfFile;

                // Set font
                BaseFont tahoma = BaseFont.CreateFont("tahoma.ttf", BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
                Font font = new Font(tahoma, 9, Font.NORMAL);
                Font fontH = new Font(tahoma, 10, Font.BOLD);
                Font fontT = new Font(tahoma, 8, Font.NORMAL);

                // Set Img
                string img = GetRegistry.Registry.read("Software\\mop\\Conduce", "img");
                string newImg = GetRegistry.Registry.read("Software\\mop\\Conduce", "newImg");

                iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(img);
                jpg.ScaleToFit(PageSize.LETTER.Width, PageSize.LETTER.Height);
                jpg.SetAbsolutePosition(0, 0);
                jpg.Alignment = iTextSharp.text.Image.ALIGN_CENTER;
                document.Add(jpg);

                //Copy
                iTextSharp.text.Image copyJpg = iTextSharp.text.Image.GetInstance(newImg);
                copyJpg.ScaleToFit(PageSize.LETTER.Width, PageSize.LETTER.Height);
                copyJpg.SetAbsolutePosition(0, 0);
                copyJpg.Alignment = iTextSharp.text.Image.ALIGN_CENTER;
                Copydocument.Add(copyJpg);

                cb.BeginText();

                if (!isEnBlanco)
                {
                    while (dr.Read())
                    {
                        recNum++;
                        if (isStart)
                        {
                            cb.SetFontAndSize(tahoma, 9);
                            int Y = 717;
                            int CopyY = 320;
                            string CustPhone = "";
                            string CustName = dr["CustName"].ToString().Trim();
                            string ShipAddress1 = dr["ShipAddress1"].ToString().Trim();
                            string ShipAddress2 = dr["ShipAddress2"].ToString().Trim();
                            string ShipAddress3 = dr["ShipAddress3"].ToString().Trim();
                            string ShipCity = dr["ShipCity"].ToString().Trim();
                            string ShipState = dr["ShipState"].ToString().Trim();
                            string ShipZip = dr["ShipZip"].ToString().Trim();
                            string ShipContact = dr["ShipContact"].ToString().Trim();
                            if (dr["CustPhone"].ToString().Trim().Length >= 14)
                            {
                                CustPhone = dr["CustPhone"].ToString().Trim().Substring(0, 14);
                            }
                            else
                            {
                                CustPhone = dr["CustPhone"].ToString().Trim();
                            }

                            string JobNumber = dr["JobNumber"].ToString().Trim();
                            DateTime ShipDate = DateTime.Now;

                            if (dr["ShipDate"].ToString().Trim().Length > 0)
                            {
                                ShipDate = Convert.ToDateTime(dr["ShipDate"]);
                            }

                            string PONumber = dr["PONumber"].ToString().Trim();

                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, CustName, 95, Y, 0); Y = Y - 10;
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, ShipAddress1, 95, Y, 0); Y = Y - 10;
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, ShipAddress2, 95, Y, 0); Y = Y - 10;
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, ShipAddress3, 95, Y, 0); Y = Y - 10;

                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, ShipCity, 95, Y, 0);
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, ShipState, 205, Y, 0);
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, ShipZip, 225, Y, 0);

                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, ShipContact, 100, 640, 0);
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, CustPhone, 77, 625, 0);

                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, ShipDate.ToString("MM/dd/yyyy"), 420, 697, 0);
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, ShipDate.ToString("MM/dd/yyyy"), 420, 300, 0); //copia

                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, conduceNum.ToString("000000000#"), 490, 697, 0);
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, conduceNum.ToString("000000000#"), 490, 300, 0); // copia

                            // copia
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, CustName, 95, CopyY, 0); CopyY = CopyY - 10;
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, ShipAddress1, 95, CopyY, 0); CopyY = CopyY - 10;
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, ShipAddress2, 95, CopyY, 0); CopyY = CopyY - 10;
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, ShipAddress3, 95, CopyY, 0); CopyY = CopyY - 10;

                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, ShipCity, 95, CopyY, 0);
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, ShipState, 205, CopyY, 0);
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, ShipZip, 225, CopyY, 0);

                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, ShipContact, 100, 243, 0);
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, CustPhone, 77, 228, 0);

                            isStart = false;
                            //cb.SetFontAndSize(tahoma, 9);
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, JobNumber, 492, 629, 0);
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, JobNumber, 492, 232, 0); // copia

                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, PONumber, 400, 629, 0);
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, PONumber, 400, 232, 0);// copia

                        }
                        string OddPackageQty = dr["OddPackageQty"].ToString();
                        string TotalQtyShipped = dr["TotalQtyShipped"].ToString();

                        _qtyShipped = qtyShipped(dr["Quantity"].ToString(), dr["NumberofPackages"].ToString());
                        _componentNumber = Convert.ToInt16(dr["ComponentNumber"].ToString());
                        _description = Description(dr["PackageDescription"].ToString(), _componentNumber, dr["JobDescription"].ToString(), dr["ComponentDescription"].ToString());

                        cb.SetFontAndSize(tahoma, 7);

                        if (_qtyShipped != "0")
                        {
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, recNum.ToString(), 60, myY, 0);

                            if (TotalQtyShipped == _qtyShipped)
                            {
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, _qtyShipped, 81, myY, 0);
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, dr["NumberofPackages"].ToString(), 118, myY, 0);
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, dr["Quantity"].ToString(), 145, myY, 0);
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, _description, 238, myY, 0);
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "0", 180, myY, 0);
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "0", 215, myY, 0);
                            }
                            else
                            {
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, TotalQtyShipped, 81, myY, 0);
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, dr["NumberofPackages"].ToString(), 118, myY, 0);
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, dr["Quantity"].ToString(), 145, myY, 0);
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "1", 180, myY, 0);
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, OddPackageQty, 215, myY, 0);
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, _description, 238, myY, 0);

                            }
                            myY = myY - 10;
                            // copia
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, recNum.ToString(), 60, myCopyY, 0);

                            if (TotalQtyShipped == _qtyShipped)
                            {
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, _qtyShipped, 81, myCopyY, 0);
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, dr["NumberofPackages"].ToString(), 118, myCopyY, 0);
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, dr["Quantity"].ToString(), 145, myCopyY, 0);
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, _description, 238, myCopyY, 0);
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "0", 180, myCopyY, 0);
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "0", 215, myCopyY, 0);
                            }
                            else
                            {
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, TotalQtyShipped, 81, myCopyY, 0);
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, dr["NumberofPackages"].ToString(), 118, myCopyY, 0);
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, dr["Quantity"].ToString(), 145, myCopyY, 0);
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "1", 180, myCopyY, 0);
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, OddPackageQty, 215, myCopyY, 0);
                                cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, _description, 238, myCopyY, 0);

                            }

                            /*
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, recNum.ToString(), 60, myCopyY, 0);
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, _qtyShipped, 90, myCopyY, 0);
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, dr["NumberofPackages"].ToString(), 140, myCopyY, 0);
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, dr["Quantity"].ToString(), 185, myCopyY, 0);
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, _description, 220, myCopyY, 0);
                             */

                            myCopyY = myCopyY - 10;
                        }
                    }//end while
                }
                else
                {
                    cb.SetFontAndSize(tahoma, 9);
                    cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, conduceNum.ToString("000000000#"), 490, 697, 0);
                    cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, conduceNum.ToString("000000000#"), 490, 300, 0); // copia
                }//end if enBlanco

                cb.EndText();
                document.Close();
                Copydocument.Close();
                if (!isEnBlanco)   dr.Close();
                outPut = true;

                sqlCmd.CommandText = "insert into tblConduce(ConduceNum,pdfFile,Date) values(" + conduceNum.ToString() + ",'" + myPdfFile + "','" + DateTime.Now.ToString("yyyyMMdd") + "')";
                sqlCmd.ExecuteNonQuery();

                pr.Start(); // para ver el pdf  en pantalla
            }
            catch (Exception ex)
            {
                throw (new Exception(ex.Message + " - getitem - "));
            }
            finally
            {
                DTS = null;
                myDataAdapter = null;
            }
            return outPut;
        }
Ejemplo n.º 27
0
        private string strRetornaValor(string strSessao, string strNomeVariavel, string strValorDefault)
        {
            string strRetorno = "";

            if (System.IO.File.Exists(m_strPathArquivo))
            {
                System.Data.DataSet dtSetArquivoConfiguracao = new System.Data.DataSet();
                try
                {
                    dtSetArquivoConfiguracao.ReadXml(m_strPathArquivo);
                }
                catch
                {                         // Arquivo XML esta incorreto
                    return(strValorDefault);
                }

                // Procurando a Sessao
                System.Data.DataTable dttbSessao = null;
                for (int nCont = 0; nCont < dtSetArquivoConfiguracao.Tables.Count; nCont++)
                {
                    if (dtSetArquivoConfiguracao.Tables[nCont].TableName == strSessao)
                    {
                        dttbSessao = dtSetArquivoConfiguracao.Tables[nCont];
                    }
                }
                // Sessao nao existe , criando ela
                if (dttbSessao == null)
                {
                    dttbSessao = dtSetArquivoConfiguracao.Tables.Add(strSessao);
                }

                // Procurando a Variavel
                bool bAchouVariavel = false;
                for (int nCont = 0; nCont < dttbSessao.Columns.Count; nCont++)
                {
                    if (dttbSessao.Columns[nCont].ColumnName == strNomeVariavel)
                    {
                        bAchouVariavel = true;
                        if (dttbSessao.Rows.Count == 0)
                        {
                            System.Data.DataRow dtrwSessao = dttbSessao.NewRow();
                            dttbSessao.Rows.Add(dtrwSessao);
                        }
                        strRetorno = dttbSessao.Rows[0][dttbSessao.Columns[nCont].ColumnName].ToString();
                        if (strRetorno == "")
                        {
                            strRetorno = strValorDefault;
                            dttbSessao.Rows[0][dttbSessao.Columns[nCont].ColumnName] = strRetorno;
                        }
                    }
                }
                // Variavel nao existe, criando ela
                if (!bAchouVariavel)
                {
                    dttbSessao.Columns.Add(strNomeVariavel);
                    if (dttbSessao.Rows.Count == 0)
                    {
                        System.Data.DataRow dtrwSessao = dttbSessao.NewRow();
                        dttbSessao.Rows.Add(dtrwSessao);
                    }
                    strRetorno = dttbSessao.Rows[0][strNomeVariavel].ToString();
                    if (strRetorno == "")
                    {
                        strRetorno = strValorDefault;
                        dttbSessao.Rows[0][strNomeVariavel] = strRetorno;
                    }
                }

                // Salvando o Arquivo XML
                try
                {
                    dtSetArquivoConfiguracao.WriteXml(m_strPathArquivo);
                }catch {
                }
            }
            return(strRetorno);
        }
Ejemplo n.º 28
0
        /// <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;
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 储存数据到xml
        /// </summary>
        public void WriteXml(string str = "")
        {
            //创建一个数据集,将其写入xml文件
            //string filename = DateTime.Now.ToString("yyyyMMddHHmmss") + "model.xml";
            string filename = "\\model" + str + ".xml";

            System.Data.DataSet   ds    = new System.Data.DataSet("MODEL");
            System.Data.DataTable table = new System.Data.DataTable("w");
            ds.Tables.Add(table);
            table.Columns.Add("c1", typeof(double));
            table.Columns.Add("c2", typeof(double));
            for (int i = 0; i < 200; i++)
            {
                System.Data.DataRow row = table.NewRow();
                for (int j = 0; j < 2; j++)
                {
                    row[j] = w[j, i];
                }
                ds.Tables["w"].Rows.Add(row);
            }
            table = new System.Data.DataTable("w0");
            ds.Tables.Add(table);
            table.Columns.Add("c1", typeof(double));
            table.Columns.Add("c2", typeof(double));
            for (int i = 0; i < 1; i++)
            {
                System.Data.DataRow row = table.NewRow();
                for (int j = 0; j < 2; j++)
                {
                    row[j] = w0[j, i];
                }
                ds.Tables["w0"].Rows.Add(row);
            }
            table = new System.Data.DataTable("b");
            ds.Tables.Add(table);
            table.Columns.Add("c1", typeof(double));
            table.Columns.Add("c2", typeof(double));
            for (int i = 0; i < 1; i++)
            {
                System.Data.DataRow row = table.NewRow();
                for (int j = 0; j < 2; j++)
                {
                    row[j] = b[j, i];
                }
                ds.Tables["b"].Rows.Add(row);
            }
            table = new System.Data.DataTable("checkpoint");
            ds.Tables.Add(table);
            table.Columns.Add("trainumber", typeof(int));
            table.Columns.Add("batch", typeof(int));
            table.Columns.Add("rate", typeof(double));
            System.Data.DataRow row1 = table.NewRow();
            row1[0] = trainumber;
            row1[1] = batch;
            row1[2] = rate;
            ds.Tables["checkpoint"].Rows.Add(row1);
            string pathbase = Environment.CurrentDirectory;
            string path     = pathbase + filename;

            ds.WriteXml(path);
            textBox1.Text = "写入数据成功!数据见" + path;
        }
Ejemplo n.º 30
0
        static void Main(string[] args)
        {
            String database = "";
            String entity   = "";

            try
            {
                Console.WriteLine("Hello World!");
                // Create general web service link.
                HSFWebService       hsfWebService       = new HSFWebService();
                HSFEntityWebService hsfEntityWebService = new HSFEntityWebService();

                //call with hsfEntityWebService1 to forward to proxy proxyTrace012 to capture request xml
                HSFEntityWebService hsfEntityWebService1 = new HSFEntityWebService("abc");
                // Create session with user/password.
                String sessionID = hsfWebService.CreateSession("admin", "Welcome1");
                if (sessionID == "")
                {
                    throw new Exception("Can not create a valid session.");
                }
                Console.WriteLine("Session ID : " + sessionID);

                hsfWebService.OpenServer(sessionID, "HSFServer");
                string[] databases = hsfWebService.EnumDatabases(sessionID);
                if (databases.Length < 1)
                {
                    throw new Exception("There are no databases in the current server.");
                }

                // Open database.
                if (database == null || database == "")
                {
                    database = databases[0];
                }
                Console.WriteLine("Database : " + database);
                hsfWebService.OpenDatabase(sessionID, database);


                System.Data.DataSet entities = hsfWebService.EnumEntities(sessionID, "", "All");
                if (entities == null || entities.Tables["Entities"] == null)
                {
                    throw new Exception("There are no entities in this database");
                }
                System.Data.DataRow[] entityRows = entities.Tables["Entities"].Select();
                if (entityRows.Length < 1)
                {
                    throw new Exception("There are no entities in this database");
                }
                entity = (string)entityRows[1]["ID"];
                Console.WriteLine("Entity : " + entity);


                // Open entity.
                hsfEntityWebService.OpenEntity(sessionID, entity, false);

                // Mark entity as opened.
                Boolean entityOpened = true;

                // Get list of time periods.
                System.Data.DataSet timePeriods = hsfEntityWebService.EnumTimePeriods(sessionID);
                if (timePeriods == null || timePeriods.Tables["TimePeriods"] == null)
                {
                    throw new Exception("There are no time periods in this entity");
                }
                System.Data.DataRow[] timePeriodRows = timePeriods.Tables["TimePeriods"].Select();
                if (timePeriodRows.Length < 1)
                {
                    throw new Exception("here are no time periods in this entity");
                }
                int timeCols = timePeriodRows.Length;

                System.Data.DataSet scenarios = hsfEntityWebService.EnumScenarios(sessionID);
                if (scenarios == null || scenarios.Tables["Scenarios"] == null)
                {
                    throw new Exception("There are no scenarios in this entity");
                }
                System.Data.DataRow[] scenarioRows = scenarios.Tables["Scenarios"].Select();
                if (scenarioRows.Length < 1)
                {
                    throw new Exception("here are no scenarios in this entity");
                }

                System.Data.DataSet accounts = hsfEntityWebService.EnumAccounts(sessionID);
                if (accounts == null || accounts.Tables["Accounts"] == null)
                {
                    throw new Exception("There are no accounts in this entity");
                }
                System.Data.DataTable accountTable = accounts.Tables["Accounts"];
                System.Data.DataRow[] accountRows  = accountTable.Select();
                if (accountRows.Length < 1)
                {
                    throw new Exception("here are no accounts in this entity");
                }

                System.Data.DataSet dataCellsOut = null;
                // Create data set for GetCellData call.
                System.Data.DataSet   dataCellsIn      = new System.Data.DataSet();
                System.Data.DataTable dataCellsInTable = dataCellsIn.Tables.Add("DataCells");

                // Add columns to the table.
                dataCellsInTable.Columns.Add("Entity", typeof(string));
                dataCellsInTable.Columns.Add("Account", typeof(string));
                dataCellsInTable.Columns.Add("Time", typeof(string));
                dataCellsInTable.Columns.Add("Scenario", typeof(string));
                dataCellsInTable.Columns.Add("Measure", typeof(string));
                dataCellsInTable.Columns.Add("CustomMembers", typeof(string));

                for (int j = 0; j < timeCols; j++)
                {
                    System.Data.DataRow dataRow = dataCellsInTable.NewRow();
                    dataRow["Entity"]        = entity;
                    dataRow["Account"]       = "100.00.000";
                    dataRow["Measure"]       = "Output";
                    dataRow["Scenario"]      = "Base";
                    dataRow["Time"]          = timePeriodRows[j]["ID"];
                    dataRow["CustomMembers"] = "";
                    dataCellsInTable.Rows.Add(dataRow);
                }


                Console.WriteLine("Request Payload");
                dataCellsIn.WriteXml("E:\\VisualStudio2015Workspace\\CSharp_HSF_ConsoleApplication\\GetEntityDataCells.xml", System.Data.XmlWriteMode.WriteSchema);

                Console.WriteLine("Press any key to proceed.");
                Console.ReadKey();

                // Call GetDataCells.
                dataCellsOut = hsfEntityWebService.GetEntityDataCells(sessionID, dataCellsIn);
                if (dataCellsOut == null)
                {
                    throw new Exception("DataCells data set not found.");
                }

                System.Data.DataTable dataCellsOutTable = dataCellsOut.Tables["DataCells"];
                System.Data.DataRow[] valueRows         = dataCellsOutTable.Select();
                System.Data.DataRow[] valueRows2        = valueRows;
                Console.WriteLine(valueRows.Length);
                for (int i = 0; i < valueRows2.Length; i++)
                {
                    System.Data.DataRow dataRow = valueRows2[i];
                    String text = "<DataCell ";
                    text += "Account=\"";
                    text += dataRow["Account"];
                    text += "\" Scenario=\"";
                    text += dataRow["Scenario"];
                    text += "\" Time=\"";
                    text += dataRow["Time"];
                    text += "\" Measure=\"";
                    text += dataRow["Measure"];
                    text += "\" Value=\"";
                    text += dataRow["Value"];
                    Console.WriteLine(text);
                }

                Console.WriteLine("calling setentitydatacells");
                Console.WriteLine("Press any key to proceed.");
                Console.ReadKey();

                System.Data.DataSet   dataCellsOutSet     = null;
                System.Data.DataSet   dataCellsInSet      = new System.Data.DataSet();
                System.Data.DataTable dataCellsInTableSet = dataCellsInSet.Tables.Add("DataCells");

                // Add columns to the table.
                dataCellsInTableSet.Columns.Add("Entity", typeof(string));
                dataCellsInTableSet.Columns.Add("Account", typeof(string));
                dataCellsInTableSet.Columns.Add("Time", typeof(string));
                dataCellsInTableSet.Columns.Add("Scenario", typeof(string));
                dataCellsInTableSet.Columns.Add("Measure", typeof(string));
                dataCellsInTableSet.Columns.Add("Value", typeof(string));
                dataCellsInTableSet.Columns.Add("CustomMembers", typeof(string));

                for (int j = 0; j < 10; j++)
                {
                    System.Data.DataRow dataRowSet = dataCellsInTableSet.NewRow();
                    dataRowSet["Entity"]        = entity;
                    dataRowSet["Account"]       = "100.00.000";
                    dataRowSet["Measure"]       = "Output";
                    dataRowSet["Scenario"]      = "Base";
                    dataRowSet["Time"]          = timePeriodRows[j]["ID"];
                    dataRowSet["Value"]         = "100";
                    dataRowSet["CustomMembers"] = "";
                    dataCellsInTableSet.Rows.Add(dataRowSet);
                }

                dataCellsInSet.WriteXml("E:\\VisualStudio2015Workspace\\CSharp_HSF_ConsoleApplication\\SetEntityDataCells.xml", System.Data.XmlWriteMode.WriteSchema);
                // Call SetDataCells.

                //call with hsfEntityWebService1 to forward to proxy proxyTrace012 to capture request xml
                //dataCellsOutSet = hsfEntityWebService1.SetEntityDataCells(sessionID, dataCellsInSet,"csharpConsoleClient");

                // dataCellsOutSet = hsfEntityWebService.SetEntityDataCells(sessionID, dataCellsInSet, "csharpConsoleClient");
                // if (dataCellsOutSet == null) throw new Exception("DataCells data set not found.");

                // System.Data.DataTable dataCellsOutTableSet = dataCellsOutSet.Tables["DataCells"];
                // if (dataCellsOutTableSet == null) throw new Exception("DataCells table not found.");

                System.Data.DataSet dataCellsOutAccountList = hsfEntityWebService.EnumAccounts(sessionID);
                dataCellsOutAccountList.WriteXml("E:\\VisualStudio2015Workspace\\CSharp_HSF_ConsoleApplication\\EnumAccountsResponse.xml", System.Data.XmlWriteMode.WriteSchema);
            }
            catch (Exception e)
            {
                Console.WriteLine("*******************************************************");
                Console.WriteLine("IN EXCEPTION");
                Console.WriteLine(e.StackTrace);
                Console.WriteLine("Press any key to proceed.");
                Console.ReadKey();
            }
            finally
            {
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey();
            }
        }