コード例 #1
0
        /// <summary>
        /// 本类中使用新建的connection ,记得要关闭
        /// </summary>
        /// <returns></returns>
        private static DbConnection NewAConnection()
        {
#if DEBUG
            string       connectionstring = ConfigurationManager.ConnectionStrings["oracleConnection"].ToString();
            DbConnection connection       = new OleDbConnection(connectionstring);
#else
            XConnNode         node             = XConnNode.CreateNode();
            string            connectionstring = node.ConnString["属性数据"];
            DbProviderFactory provider         = DbProviderFactories.GetFactory(node.ProviderName["属性数据"]);
            DbConnection      connection       = provider.CreateConnection();
            connection.ConnectionString = connectionstring;
#endif
            return(connection);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: justseven/FCInterfaceData
        private static void InsertFCFHT(string fileName, string ftpAdd, string ftpUser, string ftpPassword, string ftpPort, byte[] buffer, string hid, string ZID)
        {
            string ftpHead;

            if (string.IsNullOrEmpty(ftpPort))
            {
                ftpHead = "ftp://" + ftpAdd;
            }
            else
            {
                ftpHead = "ftp://" + ftpAdd + ":" + ftpPort;
            }
            FtpCheckDirectoryExist(ftpHead, "FC_H/" + ZID + "/", ftpUser, ftpPassword);
            if (fileCheckExist(ftpHead + "/FC_H/" + ZID + "/", fileName, ftpUser, ftpPassword))
            {
                return;
            }
            string        ftpAddree = ftpHead + "/FC_H/" + ZID + "/" + fileName;
            FtpWebRequest reqFTP    = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpAddree));

            reqFTP.Method        = WebRequestMethods.Ftp.UploadFile;
            reqFTP.UseBinary     = true;
            reqFTP.ContentLength = buffer.Length;
            reqFTP.Credentials   = new NetworkCredential(ftpUser, ftpPassword);

            //FtpWebResponse response = (FtpWebResponse)reqFTP.GetRequestStream();
            Stream ftpStream = reqFTP.GetRequestStream();

            ftpStream.Write(buffer, 0, buffer.Length);
            ftpStream.Close();
            //response.Close();
            string insertGGKSql = string.Format(@"Insert into pub_attachlst(attachid, fileid,parenttype,parentnode,attachname,attachtype,uploadby,uploadtime,sortnum)
                                                                             values(:attachid,:fileid,'户','{0}','分层分户图','jpg','权集',sysdate,0)", hid);

#if DEBUG
            string       connectionstring = ConfigurationManager.ConnectionStrings["bdcggkConnection"].ToString();
            DbConnection connection       = new OleDbConnection(connectionstring);
#else
            XConnNode         node             = XConnNode.CreateNode();
            string            connectionstring = node.ConnString["公共数据"];
            DbProviderFactory provider         = DbProviderFactories.GetFactory(node.ProviderName["公共数据"]);
            DbConnection      connection       = provider.CreateConnection();
            connection.ConnectionString = connectionstring;
#endif
            DbCommand   command   = connection.CreateCommand();
            DbParameter attachidP = command.CreateParameter();
            attachidP.ParameterName = ":attachid";
            attachidP.Value         = Guid.NewGuid().ToString("N");
            DbParameter fileidP = command.CreateParameter();
            fileidP.ParameterName = ":fileid";
            string fileid = Guid.NewGuid().ToString("N");
            fileidP.Value = fileid;
            command.Parameters.Add(attachidP);
            command.Parameters.Add(fileidP);
            command.Connection = connection;
            int ggint = DBHelper.ExecuteNonQuery(insertGGKSql, command);
            if (ggint > 0)
            {
                string insertWDKSql = string.Format(@"Insert into DOC_BINFILE(binid,fileid,filename,extname,filesize,isencrypted,iscompressed,ftpath)
                                                                        values(:binid,'{0}','分层分户图','jpg','{1}','否','否','{2}')", fileid, buffer.Length.ToString(), "/FC_H/" + ZID + "/" + fileName);

#if DEBUG
                string       connectionwdstring = ConfigurationManager.ConnectionStrings["bdcwdkConnection"].ToString();
                DbConnection wdconnection       = new OleDbConnection(connectionwdstring);
#else
                XConnNode         node1 = XConnNode.CreateNode();
                string            connectionwdstring = node1.ConnString["文档数据"];
                DbProviderFactory provider1          = DbProviderFactories.GetFactory(node.ProviderName["文档数据"]);
                DbConnection      wdconnection       = provider1.CreateConnection();
                wdconnection.ConnectionString = connectionwdstring;
#endif
                DbCommand   wdcommand = wdconnection.CreateCommand();
                DbParameter binidp    = wdcommand.CreateParameter();
                binidp.ParameterName = ":binid";
                binidp.Value         = Guid.NewGuid().ToString("N");
                wdcommand.Parameters.Add(binidp);
                wdcommand.Connection = wdconnection;
                DBHelper.ExecuteNonQuery(insertWDKSql, wdcommand);
                string    insertWDKSql2 = string.Format(@"Insert into DOC_FILE(fileid,filename,creator,createtime)
                                                                values('{0}','分层分户图','权集',sysdate)", fileid);
                DbCommand wdcommand2    = wdconnection.CreateCommand();
                wdcommand.Connection = wdconnection;
                DBHelper.ExecuteNonQuery(insertWDKSql2, wdcommand2);
            }
        }