public virtual void Add(ReadTableField NewParameter)
 {
     base.List.Add(NewParameter);
 }
Пример #2
0
        public void Run()
        {
            try
            {
                SendMessage("Run开始");
                IRfcFunction function;
                IRfcTable    table2;
                this._LastPrimaryKey = "";
                this._FetchedRows    = 0;
                if ((this._RowCount == 0) && (this._PackageSize > 0))
                {
                    this._RowCount = 0x11d260c0;
                }
                this.anzahlaufrufe = 0;
                if (this._FunctionName.Equals(""))
                {
                    bool isUnicode = this._des.Repository.UnicodeEnabled;

                    if (this._UsePrimaryKeyPackaging)
                    {
                        throw new SAPException(Messages.Donotuseprimaykeypackagingwithoutacustomfunctionmodule);
                        //throw new Exception("Donot use primaykey packaging without a custom function module");
                    }

                    function = _des.Repository.CreateFunction("RFC_READ_TABLE");
                }
                else
                {
                    try
                    {
                        SendMessage("读取函数元数据" + _FunctionName);
                        function = this._des.Repository.CreateFunction(this._FunctionName);
                        SendMessage("读取函数元数据完成" + _FunctionName);
                    }
                    catch (RfcAbapException ee)
                    {
                        throw new SAPException(ee.Key + ee.Message);
                    }
                    IRfcTable table3 = function.GetTable("OPTIONS");
                    table2 = function.GetTable("FIELDS");
                    IRfcTable table = function.GetTable("DATA");
                }
                if (this._UsePrimaryKeyPackaging)
                {
                    this._PrimaryKeys.Clear();
                    IRfcFunction function2 = _des.Repository.CreateFunction("DDIF_FIELDINFO_GET");//.GenerateFunctionObjectForDDIF_FIELDINFO_GET(this.con.IsUnicode);
                    //function2.Connection = this.con;
                    function2["TABNAME"].SetValue(this.TableName);
                    function2.Invoke(_des);
                    foreach (IRfcStructure structure in function2.GetTable("DFIES_TAB").ToList())
                    {
                        if (structure["KEYFLAG"].GetValue().ToString().Equals("X"))
                        {
                            ReadTableField newParameter = new ReadTableField(structure["FIELDNAME"].GetValue().ToString(), Convert.ToInt32(structure["OUTPUTLEN"].GetValue()), "C", "", 0);
                            this._PrimaryKeys.Add(newParameter);
                            // this.con.Log("Primary key Add " + newParameter);
                        }
                    }
                }
                if (this.UsePrimaryKeyPackaging)
                {
                    for (int j = 0; j < this._PrimaryKeys.Count; j++)
                    {
                        // table2.AddRow()["FIELDNAME"] = this._PrimaryKeys[j].FieldName;
                        table2 = function.GetTable("FIELDS");
                        table2.Append();
                        table2.CurrentRow["FIELDNAME"].SetValue(this._PrimaryKeys[j].FieldName);
                    }
                    if (this.fields.Count == 0)
                    {
                        this.GetAllFieldsOfTable();
                        for (int k = 0; k < this._Fields.Count; k++)
                        {
                            this.AddField(this._Fields[k].FieldName);
                        }
                    }
                }
                for (int i = 0; i < this.fields.Count; i++)
                {
                    table2 = function.GetTable("FIELDS");
                    table2.Append();
                    table2.CurrentRow["FIELDNAME"].SetValue(this.fields[i].ToString());
                }
                function["QUERY_TABLE"].SetValue(this.TableName);
                if ((this._PackageSize > 0) && ((this._RowCount > this._PackageSize) || (this._RowCount == 0)))
                {
                    function["ROWCOUNT"].SetValue(this._PackageSize);
                    function["ROWSKIPS"].SetValue(0);
                }
                else
                {
                    function["ROWCOUNT"].SetValue(this._RowCount);
                    function["ROWSKIPS"].SetValue(this._RowSkip);
                }
                if (this.OHSExtraction)
                {
                    function["ROWCOUNT"].SetValue(0);
                    function["ROWSKIPS"].SetValue(0);
                    this.OHSLastPackageNr = 1;
                    function["REQUESTID"].SetValue(this.OHSRequestID);
                    function["PACKETID"].SetValue(this.OHSLastPackageNr);
                }

                this.ExecuteRFC_READ_TABLE(ref function);
                this.fields.Clear();
                this.t = new DataTable();
                SendMessage("初始化DATATABLE开始");
                this.t.BeginInit();
                table2 = function.GetTable("FIELDS");
                if (this.UsePrimaryKeyPackaging)
                {
                    this._Fields.Clear();
                    for (int m = this._PrimaryKeys.Count; m < table2.RowCount; m++)
                    {
                        IRfcStructure structure4 = table2[m];
                        this.t.Columns.Add(table2[m][0].GetValue().ToString().Trim(), Type.GetType("System.String"));
                        this._Fields.Add(new ReadTableField(structure4["FIELDNAME"].GetValue().ToString(), Convert.ToInt32(structure4["LENGTH"].GetValue()), structure4["TYPE"].GetValue().ToString(), structure4["FIELDTEXT"].GetValue().ToString(), 0));
                    }
                }
                else
                {
                    this._Fields.Clear();
                    for (int n = 0; n < table2.RowCount; n++)
                    {
                        IRfcStructure structure5 = table2[n];
                        this.t.Columns.Add(table2[n][0].GetValue().ToString().Trim(), Type.GetType("System.String"));
                        this._Fields.Add(new ReadTableField(structure5["FIELDNAME"].GetValue().ToString(), Convert.ToInt32(structure5["LENGTH"].GetValue()), structure5["TYPE"].GetValue().ToString(), structure5["FIELDTEXT"].GetValue().ToString(), 0));
                    }
                }
                this.t.EndInit();
                SendMessage("初始化DATATABLE结束");
                this.ProcessRetrievdData(ref this.t, function);
                bool flag2 = false;
                if ((this._PackageSize > 0) && (this._FetchedRows < this._RowCount))
                {
                    flag2 = true;
                }
                while (flag2)
                {
                    if (this.OHSExtraction)
                    {
                        function["ROWCOUNT"].SetValue(0);
                        function["ROWSKIPS"].SetValue(0);
                        this.OHSLastPackageNr++;
                        function["REQUESTID"].SetValue(this.OHSRequestID);
                        function["PACKETID"].SetValue(this.OHSLastPackageNr);
                    }
                    else
                    {
                        function["ROWCOUNT"].SetValue(this.PackageSize);
                        function["ROWSKIPS"].SetValue(this._FetchedRows);
                        if ((this.RowCount > 0) && ((this._FetchedRows + this.PackageSize) > this.RowCount))
                        {
                            function["ROWCOUNT"].SetValue(this.RowCount - this._FetchedRows);
                        }
                    }
                    function.GetTable("DATA").Clear();
                    this.ExecuteRFC_READ_TABLE(ref function);
                    this.ProcessRetrievdData(ref this.t, function);
                    if ((this._FetchedRows >= this._RowCount) && (this._RowCount > 0))
                    {
                        flag2 = false;
                    }
                    if (function.GetTable("DATA").RowCount < this.PackageSize)
                    {
                        flag2 = false;
                    }
                    if (this.OHSExtraction && (function.GetTable("DATA").RowCount > 0))
                    {
                        flag2 = true;
                    }
                }
                SendMessage("Run结束");
            }
            catch (Exception e)
            {
                if (this.EventMessage != null)
                {
                    this.EventMessage(e.Message);
                }
                else
                {
                    throw;
                }
            }
            //function.Tables["DATA"].Dispose();
        }
Пример #3
0
 public virtual void Add(ReadTableField NewParameter)
 {
     base.List.Add(NewParameter);
 }
Пример #4
0
        public void Run()
        {
            try
            {

                SendMessage("Run开始");
                IRfcFunction function;
                IRfcTable table2;
                this._LastPrimaryKey = "";
                this._FetchedRows = 0;
                if ((this._RowCount == 0) && (this._PackageSize > 0))
                {
                    this._RowCount = 0x11d260c0;
                }
                this.anzahlaufrufe = 0;
                if (this._FunctionName.Equals(""))
                {
                    bool isUnicode = this._des.Repository.UnicodeEnabled;

                    if (this._UsePrimaryKeyPackaging)
                    {
                        throw new SAPException(Messages.Donotuseprimaykeypackagingwithoutacustomfunctionmodule);
                        //throw new Exception("Donot use primaykey packaging without a custom function module");
                    }

                    function = _des.Repository.CreateFunction("RFC_READ_TABLE");
                }
                else
                {
                    try
                    {
                        SendMessage("读取函数元数据" + _FunctionName);
                        function = this._des.Repository.CreateFunction(this._FunctionName);
                        SendMessage("读取函数元数据完成" + _FunctionName);
                    }
                    catch (RfcAbapException ee)
                    {
                        throw new SAPException(ee.Key + ee.Message);
                    }
                    IRfcTable table3 = function.GetTable("OPTIONS");
                    table2 = function.GetTable("FIELDS");
                    IRfcTable table = function.GetTable("DATA");
                }
                if (this._UsePrimaryKeyPackaging)
                {
                    this._PrimaryKeys.Clear();
                    IRfcFunction function2 = _des.Repository.CreateFunction("DDIF_FIELDINFO_GET");//.GenerateFunctionObjectForDDIF_FIELDINFO_GET(this.con.IsUnicode);
                    //function2.Connection = this.con;
                    function2["TABNAME"].SetValue(this.TableName);
                    function2.Invoke(_des);
                    foreach (IRfcStructure structure in function2.GetTable("DFIES_TAB").ToList())
                    {
                        if (structure["KEYFLAG"].GetValue().ToString().Equals("X"))
                        {
                            ReadTableField newParameter = new ReadTableField(structure["FIELDNAME"].GetValue().ToString(), Convert.ToInt32(structure["OUTPUTLEN"].GetValue()), "C", "", 0);
                            this._PrimaryKeys.Add(newParameter);
                            // this.con.Log("Primary key Add " + newParameter);
                        }
                    }
                }
                if (this.UsePrimaryKeyPackaging)
                {
                    for (int j = 0; j < this._PrimaryKeys.Count; j++)
                    {
                        // table2.AddRow()["FIELDNAME"] = this._PrimaryKeys[j].FieldName;
                        table2 = function.GetTable("FIELDS");
                        table2.Append();
                        table2.CurrentRow["FIELDNAME"].SetValue(this._PrimaryKeys[j].FieldName);
                    }
                    if (this.fields.Count == 0)
                    {
                        this.GetAllFieldsOfTable();
                        for (int k = 0; k < this._Fields.Count; k++)
                        {
                            this.AddField(this._Fields[k].FieldName);
                        }
                    }
                }
                for (int i = 0; i < this.fields.Count; i++)
                {
                    table2 = function.GetTable("FIELDS");
                    table2.Append();
                    table2.CurrentRow["FIELDNAME"].SetValue(this.fields[i].ToString());
                }
                function["QUERY_TABLE"].SetValue(this.TableName);
                if ((this._PackageSize > 0) && ((this._RowCount > this._PackageSize) || (this._RowCount == 0)))
                {
                    function["ROWCOUNT"].SetValue(this._PackageSize);
                    function["ROWSKIPS"].SetValue(0);
                }
                else
                {
                    function["ROWCOUNT"].SetValue(this._RowCount);
                    function["ROWSKIPS"].SetValue(this._RowSkip);
                }
                if (this.OHSExtraction)
                {
                    function["ROWCOUNT"].SetValue(0);
                    function["ROWSKIPS"].SetValue(0);
                    this.OHSLastPackageNr = 1;
                    function["REQUESTID"].SetValue(this.OHSRequestID);
                    function["PACKETID"].SetValue(this.OHSLastPackageNr);
                }

                this.ExecuteRFC_READ_TABLE(ref function);
                this.fields.Clear();
                this.t = new DataTable();
                SendMessage("初始化DATATABLE开始");
                this.t.BeginInit();
                table2 = function.GetTable("FIELDS");
                if (this.UsePrimaryKeyPackaging)
                {
                    this._Fields.Clear();
                    for (int m = this._PrimaryKeys.Count; m < table2.RowCount; m++)
                    {
                        IRfcStructure structure4 = table2[m];
                        this.t.Columns.Add(table2[m][0].GetValue().ToString().Trim(), Type.GetType("System.String"));
                        this._Fields.Add(new ReadTableField(structure4["FIELDNAME"].GetValue().ToString(), Convert.ToInt32(structure4["LENGTH"].GetValue()), structure4["TYPE"].GetValue().ToString(), structure4["FIELDTEXT"].GetValue().ToString(), 0));
                    }
                }
                else
                {
                    this._Fields.Clear();
                    for (int n = 0; n < table2.RowCount; n++)
                    {
                        IRfcStructure structure5 = table2[n];
                        this.t.Columns.Add(table2[n][0].GetValue().ToString().Trim(), Type.GetType("System.String"));
                        this._Fields.Add(new ReadTableField(structure5["FIELDNAME"].GetValue().ToString(), Convert.ToInt32(structure5["LENGTH"].GetValue()), structure5["TYPE"].GetValue().ToString(), structure5["FIELDTEXT"].GetValue().ToString(), 0));
                    }
                }
                this.t.EndInit();
                SendMessage("初始化DATATABLE结束");
                this.ProcessRetrievdData(ref this.t, function);
                bool flag2 = false;
                if ((this._PackageSize > 0) && (this._FetchedRows < this._RowCount))
                {
                    flag2 = true;
                }
                while (flag2)
                {
                    if (this.OHSExtraction)
                    {
                        function["ROWCOUNT"].SetValue(0);
                        function["ROWSKIPS"].SetValue(0);
                        this.OHSLastPackageNr++;
                        function["REQUESTID"].SetValue(this.OHSRequestID);
                        function["PACKETID"].SetValue(this.OHSLastPackageNr);
                    }
                    else
                    {
                        function["ROWCOUNT"].SetValue(this.PackageSize);
                        function["ROWSKIPS"].SetValue(this._FetchedRows);
                        if ((this.RowCount > 0) && ((this._FetchedRows + this.PackageSize) > this.RowCount))
                        {
                            function["ROWCOUNT"].SetValue(this.RowCount - this._FetchedRows);
                        }
                    }
                    function.GetTable("DATA").Clear();
                    this.ExecuteRFC_READ_TABLE(ref function);
                    this.ProcessRetrievdData(ref this.t, function);
                    if ((this._FetchedRows >= this._RowCount) && (this._RowCount > 0))
                    {
                        flag2 = false;
                    }
                    if (function.GetTable("DATA").RowCount < this.PackageSize)
                    {
                        flag2 = false;
                    }
                    if (this.OHSExtraction && (function.GetTable("DATA").RowCount > 0))
                    {
                        flag2 = true;
                    }
                }
                SendMessage("Run结束");
            }
            catch (Exception e)
            {
                if (this.EventMessage != null)
                {
                    this.EventMessage(e.Message);
                }
                else
                {
                    throw;
                }

            }
            //function.Tables["DATA"].Dispose();
        }