业务场景:客户需要在Cloud中获取第三方系统的数据,但是第三方系统的数据库是oracle,这是就需要连接oracle数据库获取数据了。

需要引用Oracle.ManagedDataAccess.dll这个类库

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.Metadata.EntityElement;
using System.Text.RegularExpressions;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.Bill.PlugIn.Args;
using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel;
using Kingdee.BOS.Core.Metadata;
using System.Data;
using Kingdee.BOS.Util;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS;
using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.JSON;
using Kingdee.BOS.Core.Bill;
using Kingdee.BOS.Core.Metadata.ControlElement;
using Kingdee.BOS.Cache;
//using System.Data.OracleClient;
using Oracle.ManagedDataAccess.Client;
using Kingdee.BOS.WebApi.Client;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Kingdee.BOS.Orm.DataEntity;

namespace GetDataPlugIn
{
    public class GetData : AbstractBillPlugIn
    {
        K3CloudApiClient client = new K3CloudApiClient("http://win-bu6omsa7a39/K3Cloud/");
        public override void ButtonClick(ButtonClickEventArgs e)
        {
            base.ButtonClick(e);
            if (e.Key.ToUpperInvariant() == "F_DEV_BUTTON")

{

OracleConnection conn11 = null;
                conn11 = OpenConn();
                var cmd11 = conn11.CreateCommand();
                string Sql;
                Sql = "select * from EAS_T_Voucher ";
                cmd11.CommandText += Sql;
                cmd11.CommandType = CommandType.Text;
                using (OracleDataReader rdr11 = cmd11.ExecuteReader())
                {
                    DataTable dt11 = new DataTable();
                    dt11.Load(rdr11);
                    int RowCount11;
                    RowCount11 = dt11.Rows.Count;
                    for (int i = 0; RowCount11 > i; i++)
                    {
                        OracleConnection conn = null;
                        conn = OpenConn();
                        var cmd = conn.CreateCommand();
                        String VoucherId = dt11.Rows[i]["fid"].ToString();
                        String seleSql = "select * from EAS_T_VoucherEntry where 凭证ID='" + VoucherId + "'";
                        cmd.CommandText += seleSql;
                        cmd.CommandType = CommandType.Text;
                        using (OracleDataReader rdr = cmd.ExecuteReader())
                        {
                            DataTable dt = new DataTable();
                            dt.Load(rdr);
                            int RowCount;
                            RowCount = dt.Rows.Count;
                            int EntryRow = 0;
                            for (int j = 0; j < RowCount; j++)
                            {
                                EntryRow = this.View.Model.GetEntryRowCount("FEntity");

String LoanType = dt.Rows[j]["方向"].ToString();
                                Decimal FLocalAmount = Decimal.Parse(dt.Rows[j]["FLocalAmount"].ToString());

String DESCR = dt.Rows[j]["FDescription"].ToString();
                                String AccountItem = dt.Rows[j]["会计科目"].ToString();
                                String StrAssAct = dt.Rows[j]["核算项目"].ToString();
                                String Account = dt.Rows[j]["科目编码"].ToString();
                                if (!string.IsNullOrWhiteSpace(StrAssAct))
                                {
                                    DateTime FBizDate = DateTime.Parse(dt.Rows[j]["业务日期"].ToString());
                                    Decimal ItemAmount = Decimal.Parse(dt.Rows[j]["核算行金额"].ToString());

String EASAssNum = null;
                                    String cus = dt.Rows[j]["客户"].ToString();
                                    String Sup = dt.Rows[j]["供应商"].ToString();
                                    String por = dt.Rows[j]["其他"].ToString();
                                    String bank = dt.Rows[j]["银行账户"].ToString();
                                    String admin = dt.Rows[j]["行政组织"].ToString();
                                    String comp = dt.Rows[j]["公司"].ToString();
                                    String cost = dt.Rows[j]["成本中心"].ToString();
                                    String person = dt.Rows[j]["职员"].ToString();
                                    String StrAssAct1 = dt.Rows[j]["FGeneralAssActType1ID"].ToString();
                                    String StrAssAct2 = dt.Rows[j]["FGeneralAssActType2ID"].ToString();
                                    String StrAssAct3 = dt.Rows[j]["FGeneralAssActType3ID"].ToString();
                                    String StrAssAct4 = dt.Rows[j]["FGeneralAssActType4ID"].ToString();
                                    String StrAssAct5 = dt.Rows[j]["FGeneralAssActType5ID"].ToString();
                                    String StrAssAct6 = dt.Rows[j]["FGeneralAssActType6ID"].ToString();
                                    String StrAssAct7 = dt.Rows[j]["FGeneralAssActType7ID"].ToString();
                                    String StrAssAct8 = dt.Rows[j]["FGeneralAssActType8ID"].ToString();
                                    String StrAssAct9 = dt.Rows[j]["FGeneralAssActType9ID"].ToString();
                                    String StrAssAct10 = dt.Rows[j]["FGeneralAssActType10ID"].ToString();
                                    String entryId = dt.Rows[j]["分录ID"].ToString();
                                    if (StrAssAct8 != null)
                                    {
                                        String haha = StrAssAct8;
                                    }

if (string.IsNullOrWhiteSpace(cus)
                                        && string.IsNullOrWhiteSpace(por)
                                        && string.IsNullOrWhiteSpace(bank)
                                        && string.IsNullOrWhiteSpace(admin)
                                        && string.IsNullOrWhiteSpace(comp)
                                        && string.IsNullOrWhiteSpace(cost)
                                        && string.IsNullOrWhiteSpace(person)
                                        )
                                    {

String AsstActType = "select fnumber from T_BD_GeneralAsstActType ";
                                        if (!string.IsNullOrWhiteSpace(StrAssAct1))
                                        {
                                            AsstActType += "where fid = '" + StrAssAct1 + "'";
                                        }
                                        if (!string.IsNullOrWhiteSpace(StrAssAct2)
)
                                        {
                                            AsstActType += "where fid = '" + StrAssAct2 + "'";
                                        }
                                        if (!string.IsNullOrWhiteSpace(StrAssAct3))
                                        {
                                            AsstActType += "where fid = '" + StrAssAct3 + "'";
                                        }
                                        if (!string.IsNullOrWhiteSpace(StrAssAct4))
                                        {
                                            AsstActType += "where fid = '" + StrAssAct4 + "'";
                                        }
                                        if (!string.IsNullOrWhiteSpace(StrAssAct5))
                                        {
                                            AsstActType += "where fid = '" + StrAssAct5 + "'";
                                        }
                                        if (!string.IsNullOrWhiteSpace(StrAssAct6))
                                        {
                                            AsstActType += "where fid = '" + StrAssAct6 + "'";
                                        }
                                        if (!string.IsNullOrWhiteSpace(StrAssAct7))
                                        {
                                            AsstActType += "where fid = '" + StrAssAct7 + "'";
                                        }
                                        if (!string.IsNullOrWhiteSpace(StrAssAct8))
                                        {
                                            AsstActType += "where fid = '" + StrAssAct8 + "'";
                                        }
                                        if (!string.IsNullOrWhiteSpace(StrAssAct9))
                                        {
                                            AsstActType += "where fid = '" + StrAssAct9 + "'";
                                        }
                                        if (!string.IsNullOrWhiteSpace(StrAssAct10))
                                        {
                                            AsstActType += "where fid = '" + StrAssAct10 + "'";
                                        }
                                        OracleConnection conn2 = null;
                                        conn2 = OpenConn();
                                        var cmd111 = conn2.CreateCommand();
                                        cmd111.CommandText += AsstActType;
                                        cmd111.CommandType = CommandType.Text;
                                        using (OracleDataReader rdr1 = cmd111.ExecuteReader())
                                        {
                                            DataTable zjy = new DataTable();
                                            zjy.Load(rdr1);
                                            int zjyCount;
                                            zjyCount = zjy.Rows.Count;
                                            for (int g = 0; g < zjyCount; g++)
                                            {
                                                EntryRow = this.View.Model.GetEntryRowCount("FEntity");
                                                EASAssNum = zjy.Rows[g]["Fnumber"].ToString();

this.View.Model.SetValue("F_DEV_LoanType", LoanType, EntryRow - 1);
                                                this.View.Model.SetValue("F_DEV_FLocalAmount", FLocalAmount, EntryRow - 1);
                                                this.View.Model.SetValue("F_DEV_ItemAmount", ItemAmount, EntryRow - 1);
                                                this.View.Model.SetValue("F_DEV_AccountItem", AccountItem, EntryRow - 1);
                                                this.View.Model.SetValue("F_DEV_Account", Account, EntryRow - 1);
                                                this.View.Model.SetValue("F_DEV_Voucherid", dt11.Rows[i]["fid"].ToString(), EntryRow - 1);
                                                this.View.Model.SetValue("F_DEV_EASACCNO", dt11.Rows[i]["凭证号"].ToString(), EntryRow - 1);
                                                this.View.Model.SetValue("F_DEV_EASAssNum", EASAssNum, EntryRow - 1);
                                                this.View.Model.SetValue("F_DEV_StrAssAct", StrAssAct, EntryRow - 1);
                                                this.View.Model.SetValue("F_DEV_Date", FBizDate, EntryRow - 1);
                                                this.View.Model.SetValue("F_DEV_FEXPLANATION", DESCR, EntryRow - 1);
                                                this.View.Model.CreateNewEntryRow("FEntity");

}
                                            conn2.Close();

}
                                    }
                                    else
                                    {
                                        EntryRow = this.View.Model.GetEntryRowCount("FEntity");
                                        EASAssNum = cus + Sup + por + bank + admin + comp + cost + person;
                                        this.View.Model.SetValue("F_DEV_StrAssAct", StrAssAct, EntryRow - 1);
                                        this.View.Model.SetValue("F_DEV_EASAssNum", EASAssNum, EntryRow - 1);
                                        this.View.Model.SetValue("F_DEV_LoanType", LoanType, EntryRow - 1);
                                        this.View.Model.SetValue("F_DEV_FLocalAmount", FLocalAmount, EntryRow - 1);
                                        this.View.Model.SetValue("F_DEV_ItemAmount", ItemAmount, EntryRow - 1);
                                        this.View.Model.SetValue("F_DEV_AccountItem", AccountItem, EntryRow - 1);
                                        this.View.Model.SetValue("F_DEV_Account", Account, EntryRow - 1);
                                        this.View.Model.SetValue("F_DEV_Voucherid", dt11.Rows[i]["fid"].ToString(), EntryRow - 1);
                                        this.View.Model.SetValue("F_DEV_EASACCNO", dt11.Rows[i]["凭证号"].ToString(), EntryRow - 1);
                                        this.View.Model.SetValue("F_DEV_Date", FBizDate, EntryRow - 1);
                                        this.View.Model.SetValue("F_DEV_FEXPLANATION", DESCR, EntryRow - 1);
                                        this.View.Model.CreateNewEntryRow("FEntity");

}

}
                                else
                                {
                                    EntryRow = this.View.Model.GetEntryRowCount("FEntity");
                                    this.View.Model.SetValue("F_DEV_StrAssAct", StrAssAct, EntryRow - 1);
                                    this.View.Model.SetValue("F_DEV_LoanType", LoanType, EntryRow - 1);
                                    this.View.Model.SetValue("F_DEV_FLocalAmount", FLocalAmount, EntryRow - 1);
                                    this.View.Model.SetValue("F_DEV_AccountItem", AccountItem, EntryRow - 1);
                                    this.View.Model.SetValue("F_DEV_Account", Account, EntryRow - 1);
                                    this.View.Model.SetValue("F_DEV_Voucherid", dt11.Rows[i]["fid"].ToString(), EntryRow - 1);
                                    this.View.Model.SetValue("F_DEV_EASACCNO", dt11.Rows[i]["凭证号"].ToString(), EntryRow - 1);
                                    this.View.Model.SetValue("F_DEV_FEXPLANATION", DESCR, EntryRow - 1);
                                    this.View.Model.CreateNewEntryRow("FEntity");

}

}

}
                        conn.Close();

}

}
                conn11.Close();
            }
        }

static OracleConnection OpenConn()
        {
            try
            {
                OracleConnection conn = new OracleConnection();
                conn.ConnectionString = "Data Source=  (DESCRIPTION =    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.33)(PORT = 1521))" +
                "(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME =  test)));User Id=hrpdb;Password=password;";
                conn.Open();
                return conn;
            }
            catch (Exception)
            {

//MessageBox.Show(ex.Message);
            }
            return null;

}
    }
}

Cloud插件,链接oracle数据库的更多相关文章

  1. 历尽磨难之PL/SQL链接Oracle数据库

    说起来都是泪啊,上司布置的任务需要远程连接Oracle数据库,说实话这又是我人生中的第一次.我听到以后觉得不是什么大问题,然而我错了..错的很厉害! 我搞了一天一夜才弄好,这里面原因有很多,大体来讲还 ...

  2. 关于vs2008使用oracleclient链接oracle数据库报报错OCIEnvCreate 失败,返回代码为 -1,但错误消息文本不可用

    用vs2008链接oracle数据库出现问题,报错OCIEnvCreate 失败,返回代码为 -1,但错误消息文本不可用,从网上找了好久方法,有两种oracle客户端文件权限,和运行vs2008以管理 ...

  3. 有关.NET链接Oracle数据库,使用连接池pooling=true时问题

    .net链接oracle数据库时,当链接字符串中pooling=true时,视图结构变更时程序报错问题,还请高手指教 现象: 链接字符串: 注意:这里pooling=true: 测试视图: 执行的SQ ...

  4. Oracle 远程链接oracle数据库服务器的配置

    远程链接oracle数据库服务器的配置 by:授客 QQ:1033553122 原理: 一.Oracle客户端与服务器端的通讯机制 1.OracleNet协议 如下图所示,Oracle通过Oracle ...

  5. 链接oracle数据库 生成表对应的javabean

    package com.databi.utils; import java.io.File; import java.io.FileOutputStream; import java.io.IOExc ...

  6. Java JDBC链接Oracle数据库

    package com.test.test; import java.io.FileInputStream;import java.io.FileNotFoundException;import ja ...

  7. python链接oracle数据库以及数据库的增删改查实例

    初次使用python链接oracle,所以想记录下我遇到的问题,便于向我这样初次尝试的朋友能够快速的配置好环境进入开发环节. 1.首先,python链接oracle数据库需要配置好环境. 我的相关环境 ...

  8. Python链接Oracle数据库

    说明:以下所需安装的所有软件版本必须跟系统一致,即系统是64位,软件就得是64位,否则会出现各种链接报错的情况. 现以64位系统,python 3.6.5  64位为例: (一)安装cx_Oracle ...

  9. ABP框架EF6链接Oracle数据库手动迁移

    环境:VS2017 + ABP官方模板(不含Zero) +Oracle 11Gx64DB  + Oracle 11Gx32Client(PLSQL工具访问) 一.Abp项目的下载以及运行 1.创建ab ...

随机推荐

  1. Spark RDD基本概念、宽窄依赖、转换行为操作

    目录 RDD概述 RDD的内部代码 案例 小总结 转换.行动算子 宽.窄依赖 Reference 本文介绍一下rdd的基本属性概念.rdd的转换/行动操作.rdd的宽/窄依赖. RDD:Resilie ...

  2. [译]课程 3: 更多关于 Jobs 和 JobsDetails

    译者注: 目录在这 [译]Quartz.NET 3.x 教程 译者注: 原文在这 Lesson 3: More About Jobs & JobDetails 正如你在 课程 2 中看到的, ...

  3. Http2优点

    1.信道复用 2.分帧传输 3.Server Push Http/1.1与Http/2对比网站: https://http2.akamai.com/demo https://http2.akamai. ...

  4. Java集合效率问题

    凑算式 B DEFA + --- + ------- = 10 C GHI (如果显示有问题,可以参见[图1.jpg]) 这个算式中A~I代表1~9的数字,不同的字母代表不同的数字. 比如:6+8/3 ...

  5. 封装dropdown模块(使用到之前写好的动画组件,封装下拉菜单)

    用 showhide 改写dropdown 模块: 1.首先在 css中新增动画相关样式 /*showhide组件的样式*/ .fadeOut{ opacity:; visibility: hidde ...

  6. redis之master.slave主从复制

    简介 主机数据更新后根据配置和策略,自动同步到备机的master/slave机制,master以写为主,slave以读为主 从库配置 配置从库,不配主库 配置从库: 格式: slaveof 主库ip ...

  7. python——面向对象(1),基础

    """面向对象:抽象化编程思想.类,对象:用类来创建(实例化)对象.类:一系列特征和行为相同的事物总和, 1.属性:特征 2.行为:方法 定义类 :PEP 8要求标识符的 ...

  8. win10下GO的环境配置

    目录 问题描述 环境变量配置 问题描述 win10 下配置 GO 语言的运行环境,主要是环境变量的设置 环境变量配置 在windows的PATH变量中添加go的可执行文件所在的目录: PATH=D:\ ...

  9. 关于对 softirq、work_queue、tasklet 学习后的一点总结

    本文基于linux版本:4.14.111 简单的总结下 softirq.work_queue.tasklet 三种中断下半部的工作原理及区别,并附上三种形式的简单实例. 一.运行原理① softirq ...

  10. 重写了下Ajax请求Webservice,顺便复习一下Javascript的闭包概念

    var AjaxRequest = function(){ //返回处理结果的回调函数 this.agentCallBack = {}; //javascript 调用domino代理的方法. thi ...