Esempio n. 1
0
        private void loadFields_Click(object sender, EventArgs e)
        {
            try
            {
                if (!check())
                {
                    return;
                }
                this.dataGridView1.Rows.Clear();
                m_dt           = new ReadTable(m_systemName.ToUpper().Trim());
                m_dt.TableName = m_tableName;
                ReadTableFieldCollection fields = m_dt.GetAllFieldsOfTable();
                if (fields == null || fields.Count == 0)
                {
                    return;
                }

                for (int i = 0; i < fields.Count; i++)
                {
                    this.dataGridView1.Rows.Add(fields[i].Active, fields[i].FieldName, fields[i].FieldText, fields[i].CheckTable);
                }
                dataGridView1.AutoResizeColumns();
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }
Esempio n. 2
0
    public static ReadTable GetInstance()
    {
        if (instance == null)
        {
            instance = new ReadTable();
        }
        return(instance);

        throw new System.NotImplementedException();
    }
Esempio n. 3
0
        public void ReadTable_withStringWhereCondition_ShouldReturnReadTableOutputModel(int tableRowCount, int testResultValue, string whereCondition)
        {
            RfcErrorInfo errorInfo;

            string testValueString = testResultValue.ToString();
            uint   stringLength    = (uint)testValueString.Length;
            uint   rowCount        = (uint)tableRowCount;

            InteropMock
            .Setup(p => p.GetRowCount(TableHandle, out rowCount, out errorInfo));
            InteropMock
            .Setup(p =>
                   p.GetString(It.IsAny <IntPtr>(), It.IsAny <string>(), It.IsAny <char[]>(), It.IsAny <uint>(), out stringLength,
                               out errorInfo))
            .Returns((IntPtr funHandler, string name, char[] buffer, uint bufferLength, uint valueLength, RfcErrorInfo rfcErrorInfo) =>
            {
                if (bufferLength <= 0)
                {
                    return(RfcResultCodes.RFC_BUFFER_TOO_SMALL);
                }
                var testArray = testValueString.ToCharArray();
                Buffer.BlockCopy(testArray, 0, buffer, 0, Buffer.ByteLength(testArray));
                return(RfcResultCodes.RFC_OK);
            });

            var readTable = new ReadTable <ReadTableOutputModel>(PropertyCacheMock.Object, InteropMock.Object);

            List <ReadTableOutputModel> resultModel = readTable.GetTable(ConnectionMock.Object, new List <string> {
                whereCondition
            });

            resultModel.Should().NotBeNull();
            resultModel.Should().HaveCount((int)rowCount);
            resultModel.First().Value.Should().Be(testResultValue);

            PropertyCacheMock.Verify(x => x.GetPropertyInfo(typeof(ReadTableOutputModel), "TESTPROPERTY"), Times.AtLeast(1));

            //Input Parameter Check
            InteropMock.Verify(x => x.SetString(FunctionHandle, "QUERY_TABLE", "TESTTABLE", 9, out errorInfo), Times.Once);
            InteropMock.Verify(x => x.SetString(FunctionHandle, "DELIMITER", "|", 1, out errorInfo), Times.Once);
            InteropMock.Verify(x => x.SetString(FunctionHandle, "NO_DATA", "", 0, out errorInfo), Times.Once);
            InteropMock.Verify(x => x.SetInt(FunctionHandle, "ROWCOUNT", 0, out errorInfo), Times.Once);
            InteropMock.Verify(x => x.SetInt(FunctionHandle, "ROWSKIPS", 0, out errorInfo), Times.Once);
            InteropMock.Verify(x => x.SetString(LineHandle, "FIELDNAME", "TESTPROPERTY", 12, out errorInfo), Times.Once);

            var outputArray = new char[testValueString.ToCharArray().Length + 1];

            Buffer.BlockCopy(testValueString.ToCharArray(), 0, outputArray, 0, Buffer.ByteLength(testValueString.ToCharArray()));
            //Output Parameter Check
            InteropMock.Verify(
                x => x.GetString(RowHandle, "WA", outputArray, (uint)outputArray.Length, out stringLength,
                                 out errorInfo), Times.AtLeast(1));

            InteropMock.Verify(x => x.Invoke(RfcConnectionHandle, FunctionHandle, out errorInfo), Times.Once);
        }
 public void BasicWorkflow()
 {
     var data = GetResolvedTestData();
     {
         ReadTable<TestData> table;
         using (var readOnlyByteArray = new ReadOnlyByteArray(data))
         {
             table = new ReadTable<TestData>(new DataConverter<TestData>(), readOnlyByteArray);
         }
         CheckTableMatchesTestData(table);
     }
 }
Esempio n. 5
0
        void SetDataToExcel(ReadTable p_dt, Worksheet p_ws)
        {
            //在当前激活的工作表上存放数据
            p_ws = Globals.Factory.GetVstoObject(Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet);

            ListObject ls;

            if (!p_ws.Controls.Contains(_tableName))
            {
                int count = p_ws.ListObjects.Count;
                for (int i = 1; i < count + 1; i++)
                {
                    if (p_ws.ListObjects[i].Name == _tableName)
                    {
                        p_ws.ListObjects[i].Delete();
                        // ws.Controls.Remove(_tableName);
                    }
                }

                ls = p_ws.Controls.AddListObject(p_ws.Range["A2"], _tableName);
            }
            else
            {
                ls = (ListObject)p_ws.Controls[_tableName];
            }
            ls.SetDataBinding(p_dt.Result);
            p_ws.Rows[1].Clear();
            // ReadTableFieldCollection co = dt.Fields;
            for (int i = 0; i < p_dt.Fields.Count; i++)
            {
                p_ws.Cells.set_Item(1, i + 1, p_dt.Fields[i].FieldText);
                ls.ListColumns[i + 1].Name = p_dt.Fields[i].FieldName;
            }

            //清空两行抬头,并重新设置。

            p_ws.Columns.AutoFit();
            p_ws.Columns.ShrinkToFit = true;

            //saveContext();

            p_ws                = Globals.Factory.GetVstoObject(Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet);
            p_ws.Name           = _tableName;
            p_ws.ActivateEvent += new Microsoft.Office.Interop.Excel.DocEvents_ActivateEventHandler(ws_ActivateEvent);
            p_ws.Deactivate    += new Microsoft.Office.Interop.Excel.DocEvents_DeactivateEventHandler(ws_Deactivate);
            MessageBox.Show("加载完成");
        }
Esempio n. 6
0
        //加载表数据
        void loadTableData()
        {
            try
            {
                dt = new ReadTable(_systemName.ToUpper().Trim());
                dt.SetCustomFunctionName("ZVI_RFC_READ_TABLE");
                dt.TableName = _tableName;
                //  dt.Fields.Clear();
                // dt.Options.Clear();
                //从界面上加载条件与字段列表
                for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    if (dataGridView1.Rows[i].Cells["FieldName"].Value != null)
                    {
                        if (dataGridView1.Rows[i].Cells["Select"] != null & (bool)dataGridView1.Rows[i].Cells["Select"].Value == true)
                        {
                            string s = dataGridView1.Rows[i].Cells["FieldName"].Value.ToString();
                            if (!string.IsNullOrEmpty(s))
                            {
                                dt.AddField(s);
                            }
                        }
                    }
                }

                for (int i = 0; i < dataGridView2.Rows.Count; i++)
                {
                    if (dataGridView2[0, i].Value != null)
                    {
                        string s = dataGridView2[0, i].Value.ToString();
                        if (!string.IsNullOrEmpty(s))
                        {
                            dt.AddCriteria(s);
                        }
                    }
                }

                dt.RowCount = Convert.ToInt32(rowNum.Text);
                dt.Run();
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }
 public static void importDataFromTableByAttribute(object destObject)
 {
     lock (MUTEX_OBJECT)
     {
         FieldInfo[] fields = destObject.GetType().GetFields();
         foreach (FieldInfo field in fields)
         {
             foreach (object attribute in field.GetCustomAttributes(true))
             {
                 Type type = attribute.GetType();
                 if (type.Equals(Type.GetType("System.TableAttribute")))
                 {
                     FieldInfo[] tableAttribute = type.GetFields();
                     string      tableName      = tableAttribute[0].GetValue(attribute).ToString();
                     string      primaryKey     = tableAttribute[1].GetValue(attribute).ToString();
                     string      key            = tableAttribute[2].GetValue(attribute).ToString();
                     string      value          = ReadTable.GetInstance().GetValue(tableName, primaryKey, key);
                     field.SetValue(destObject, TypeDescriptor.GetConverter(field.FieldType).ConvertFrom(value));
                 }
             }
         }
     }
 }
 /// <summary>
 /// 竖向配表函数
 /// </summary>
 /// <param name="destObject"></param>
 /// <param name="tableName"></param>
 /// <param name="valueName"></param>
 public static void improtDataFromTable(object destObject, string tableName, string valueName)
 {
     lock (MUTEX_OBJECT)
     {
         Dictionary <string, Dictionary <string, string> > tmp_tables = ReadTable.GetInstance().GetTable(tableName);
         List <FieldInfo> table_params = new List <FieldInfo>();
         FieldInfo[]      field_infos  = destObject.GetType().GetFields();
         foreach (FieldInfo tmp in field_infos)
         {
             if (tmp.Name.Contains(TABLE_PARAMS))
             {
                 table_params.Add(tmp);
             }
         }
         foreach (FieldInfo tmp in table_params)
         {
             if (!tmp_tables.ContainsKey(tmp.Name))
             {
                 continue;
             }
             tmp.SetValue(destObject, TypeDescriptor.GetConverter(tmp.FieldType).ConvertFrom(tmp_tables[tmp.Name][valueName]));
         }
     }
 }
 private static void CheckTableMatchesTestData(ReadTable<TestData> table)
 {
     foreach (var entry in TestData)
     {
         TestData value;
         Assert.IsTrue(table.TryGetValue(entry.Key, out value));
         Assert.AreEqual(value, entry.Data);
     }
 }
Esempio n. 10
0
 /// <summary>
 /// 根据编号查询数据
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public override TEntity RetrieveById(TPrimaryKey id)
 {
     return(ReadTable.Find(id));
 }
        public void NestedTables()
        {
            var testTableByteArray = GetResolvedTestData();
            var nestTable = new WriteTable<byte[]>(new ByteArrayConverter());
            nestTable.Add("table1", testTableByteArray);
            nestTable.Add("table2", testTableByteArray);
            var data = nestTable.Resolve();
            using (var readOnlyByteArray = new ReadOnlyByteArray(data))
            {
                var table = new ReadTable<byte[]>(new ByteArrayConverter(), readOnlyByteArray);

                byte[] readTableBytes;
                Assert.IsTrue(table.TryGetValue("table1", out readTableBytes));
                Assert.IsTrue(readTableBytes.Where((b, i) => b != testTableByteArray[i]).Count() == 0);
                Assert.IsTrue(table.TryGetValue("table2", out readTableBytes));
                Assert.IsTrue(readTableBytes.Where((b, i) => b != testTableByteArray[i]).Count() == 0);
            }
        }
Esempio n. 12
0
 /// <summary>
 /// 异步根据编号查询实体
 /// </summary>
 /// <param name="id">实体编号</param>
 /// <returns>创建后的实体集</returns>
 public override async Task <TEntity> RetrieveByIdAsync(TPrimaryKey id)
 {
     return(await ReadTable.FindAsync(id));
 }
Esempio n. 13
0
 //加载表数据
 void loadTableData()
 {
     try
     {
         SendMessage("开始");
         m_dt = new ReadTable(m_systemName);
         m_dt.EventMessage += dt_eventMessage;
         // dt.SetCustomFunctionName("Z_XTRACT_IS_TABLE");
         m_dt.SetCustomFunctionName("ZVI_RFC_READ_TABLE");
         m_dt.TableName = m_tableName;
         m_dt.Delimiter = m_delimiter;
         //  dt.Fields.Clear();
         // dt.Options.Clear();
         //从界面上加载条件与字段列表
         SendMessage("加载字段列表");
         for (int i = 0; i < dataGridView1.Rows.Count; i++)
         {
             if (dataGridView1.Rows[i].Cells["FieldName"].Value != null)
             {
                 if (dataGridView1.Rows[i].Cells[0].Value != null)
                 {
                     if ((bool)dataGridView1.Rows[i].Cells[0].Value == true)
                     {
                         string s = dataGridView1.Rows[i].Cells["FieldName"].Value.ToString();
                         if (!string.IsNullOrEmpty(s))
                         {
                             m_dt.AddField(s);
                         }
                     }
                 }
             }
         }
         SendMessage("加载条件");
         for (int i = 0; i < dataGridView2.Rows.Count; i++)
         {
             if (dataGridView2[0, i].Value != null)
             {
                 string s = dataGridView2[0, i].Value.ToString();
                 if (!string.IsNullOrEmpty(s))
                 {
                     m_dt.AddCriteria(s);
                 }
             }
         }
         m_dt.RowCount = Convert.ToInt32(rowNum.Text);
         SendMessage("开始异步调用");
         try
         {
             Thread thread = new Thread(new ThreadStart(excute));
             thread.Start();
         }
         catch (Exception e)
         {
             MessageBox.Show(e.Message);
         }
     }
     catch (Exception ee)
     {
         MessageBox.Show(ee.Message);
     }
 }
Esempio n. 14
0
 public void Init()
 {
     _WindowCfg = ReadTable.Read <Dictionary <int, WindowCfg> >("WindowCfg");
 }
Esempio n. 15
0
 /// <summary>
 /// 根据编号查询数据
 /// </summary>
 /// <param name="ids"></param>
 /// <returns></returns>
 public override IList <TEntity> RetrieveByIds(IList <TPrimaryKey> ids)
 {
     return(ReadTable.Where(t => ids.Contains(t.Id)).ToList());
 }
Esempio n. 16
0
 /// <summary>
 /// 查询数据
 /// </summary>
 /// <param name="predicate"></param>
 /// <returns></returns>
 public override IQueryable <TEntity> Retrieve(Expression <Func <TEntity, bool> > predicate)
 {
     return(ReadTable.Where(predicate));
 }
Esempio n. 17
0
        private DataTable BeginExecuteQuery()
        {
            string name;
            string str2 = this._query;

            SAPTableAttribute[] customAttributes = (SAPTableAttribute[])this._originalType.GetCustomAttributes(typeof(SAPTableAttribute), false);
            if ((customAttributes == null) || (customAttributes.Length == 0))
            {
                name = this._originalType.Name;
            }
            else if (!string.IsNullOrEmpty(customAttributes[0].Name))
            {
                name = customAttributes[0].Name;
            }
            else
            {
                name = this._originalType.Name;
            }
            //if (!this.Connection.Ping())
            //{
            //    this.Connection.
            //    this.Connection.Open();
            //}
            ReadTable table = new ReadTable(this.Connection)
            {
                TableName = name
            };

            table.EventMessage += table_eventMessage;
            if (this._useMultibyteExtraction)
            {
                table.Delimiter = "|";
            }
            if (!string.IsNullOrEmpty(str2))
            {
                table.WhereClause = str2;
            }
            if (this._skip > 0)
            {
                table.RowSkip = this._skip;
            }
            if (this._take > 0)
            {
                table.RowCount = this._take;
            }
            if (((customAttributes != null) && (customAttributes.Length > 0)) && !string.IsNullOrEmpty(customAttributes[0].CustomFunctionName))
            {
                table.SetCustomFunctionName(customAttributes[0].CustomFunctionName);
            }
            PropertyInfo[] properties = this._originalType.GetProperties();
            for (int i = 0; i < properties.Length; i++)
            {
                SAPColumnAttribute[] attributeArray2 = (SAPColumnAttribute[])properties[i].GetCustomAttributes(typeof(SAPColumnAttribute), false);
                string fieldName = properties[i].Name;
                if (((attributeArray2 != null) && (attributeArray2.Length > 0)) && !string.IsNullOrEmpty(attributeArray2[0].Name))
                {
                    fieldName = attributeArray2[0].Name;
                }
                table.AddField(fieldName);
            }
            if (this.Log != null)
            {
                this.Log.WriteLine("SAPConnect.ReadTable:");
                this.Log.WriteLine(" => TableName = {0}", name);
                this.Log.WriteLine(" => RowSkip = {0}", this._skip);
                this.Log.WriteLine(" => RowCount = {0}", this._take);
                this.Log.WriteLine(" => WhereClause = {0}", str2);
                this.Log.WriteLine(" => OrderByClause = {0}", this._orderBy);
            }
            table.Run();
            DataTable result = table.Result;

            if (!string.IsNullOrEmpty(this._orderBy))
            {
                result.DefaultView.Sort = this._orderBy;
            }
            return(result);
        }
Esempio n. 18
0
 /// <summary>
 /// 查询数据条数
 /// </summary>
 /// <param name="predicate"></param>
 /// <returns></returns>
 public override int Count(Expression <Func <TEntity, bool> > predicate)
 {
     return(ReadTable.Where(predicate).Count());
 }
Esempio n. 19
0
 /// <summary>
 /// 查询数据条数
 /// </summary>
 /// <param name="predicate"></param>
 /// <returns></returns>
 public override Task <int> CountAsync(Expression <Func <TEntity, bool> > predicate)
 {
     return(ReadTable.Where(predicate).CountAsync());
 }
Esempio n. 20
0
 /// <summary>
 /// 查询所有数据
 /// </summary>
 /// <returns></returns>
 public override IList <TEntity> RetrieveAll()
 {
     return(ReadTable.Where(t => true).ToList());
 }
 public void MappedBasicWorkFlow()
 {
     var data = GetResolvedTestData();
     File.WriteAllBytes("test.data", data);
     try
     {
         using (var mappedData = new Mapper("test.data"))
         {
             var table = new ReadTable<TestData>(new DataConverter<TestData>(), mappedData);
             CheckTableMatchesTestData(table);
         }
     }
     finally
     {
         File.Delete("test.data");
     }
 }
Esempio n. 22
0
    /** \brief Linearly interpolates a y value at given x and z values
     *  \param filename name of file with x y and z data
     *  \param x x-coordinate to interpolate at
     *  \param z z-coordinate to interpolate at
     *  \return y value interpolated at given x and z values
     */
    public static double interpY(string filename, double x, double z)
    {
        StreamWriter outfile;

        outfile = new StreamWriter("log.txt", true);
        outfile.WriteLine("function interpY called with inputs: {");
        outfile.Write("  filename = ");
        outfile.Write(filename);
        outfile.WriteLine(", ");
        outfile.Write("  x = ");
        outfile.Write(x);
        outfile.WriteLine(", ");
        outfile.Write("  z = ");
        outfile.WriteLine(z);
        outfile.WriteLine("  }");
        outfile.Close();

        int           i;
        List <double> x_z_1;
        List <double> y_z_1;
        List <double> x_z_2;
        List <double> y_z_2;
        int           j;
        int           k_2;
        double        y_1;
        double        y_2;

        List <List <double> > x_matrix = new List <List <double> >(0);
        List <List <double> > y_matrix = new List <List <double> >(0);
        List <double>         z_vector = new List <double>(0);

        ReadTable.read_table(filename, z_vector, x_matrix, y_matrix);
        i       = find(z_vector, z);
        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'i' assigned ");
        outfile.Write(i);
        outfile.WriteLine(" in module Interpolation");
        outfile.Close();
        x_z_1   = extractColumn(x_matrix, i);
        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'x_z_1' assigned ");
        outfile.Write("[");
        for (int list_i1 = 0; list_i1 < x_z_1.Count - 1; list_i1++)
        {
            outfile.Write(x_z_1[list_i1]);
            outfile.Write(", ");
        }
        if (x_z_1.Count > 0)
        {
            outfile.Write(x_z_1[x_z_1.Count - 1]);
        }
        outfile.Write("]");
        outfile.WriteLine(" in module Interpolation");
        outfile.Close();
        y_z_1   = extractColumn(y_matrix, i);
        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'y_z_1' assigned ");
        outfile.Write("[");
        for (int list_i1 = 0; list_i1 < y_z_1.Count - 1; list_i1++)
        {
            outfile.Write(y_z_1[list_i1]);
            outfile.Write(", ");
        }
        if (y_z_1.Count > 0)
        {
            outfile.Write(y_z_1[y_z_1.Count - 1]);
        }
        outfile.Write("]");
        outfile.WriteLine(" in module Interpolation");
        outfile.Close();
        x_z_2   = extractColumn(x_matrix, i + 1);
        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'x_z_2' assigned ");
        outfile.Write("[");
        for (int list_i1 = 0; list_i1 < x_z_2.Count - 1; list_i1++)
        {
            outfile.Write(x_z_2[list_i1]);
            outfile.Write(", ");
        }
        if (x_z_2.Count > 0)
        {
            outfile.Write(x_z_2[x_z_2.Count - 1]);
        }
        outfile.Write("]");
        outfile.WriteLine(" in module Interpolation");
        outfile.Close();
        y_z_2   = extractColumn(y_matrix, i + 1);
        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'y_z_2' assigned ");
        outfile.Write("[");
        for (int list_i1 = 0; list_i1 < y_z_2.Count - 1; list_i1++)
        {
            outfile.Write(y_z_2[list_i1]);
            outfile.Write(", ");
        }
        if (y_z_2.Count > 0)
        {
            outfile.Write(y_z_2[y_z_2.Count - 1]);
        }
        outfile.Write("]");
        outfile.WriteLine(" in module Interpolation");
        outfile.Close();
        try {
            j       = find(x_z_1, x);
            outfile = new StreamWriter("log.txt", true);
            outfile.Write("var 'j' assigned ");
            outfile.Write(j);
            outfile.WriteLine(" in module Interpolation");
            outfile.Close();
            k_2     = find(x_z_2, x);
            outfile = new StreamWriter("log.txt", true);
            outfile.Write("var 'k_2' assigned ");
            outfile.Write(k_2);
            outfile.WriteLine(" in module Interpolation");
            outfile.Close();
        } catch {
            throw new Exception("Interpolation of y failed");
        }
        y_1     = lin_interp(x_z_1[j], y_z_1[j], x_z_1[j + 1], y_z_1[j + 1], x);
        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'y_1' assigned ");
        outfile.Write(y_1);
        outfile.WriteLine(" in module Interpolation");
        outfile.Close();
        y_2     = lin_interp(x_z_2[k_2], y_z_2[k_2], x_z_2[k_2 + 1], y_z_2[k_2 + 1], x);
        outfile = new StreamWriter("log.txt", true);
        outfile.Write("var 'y_2' assigned ");
        outfile.Write(y_2);
        outfile.WriteLine(" in module Interpolation");
        outfile.Close();
        return(lin_interp(z_vector[i], y_1, z_vector[i + 1], y_2, z));
    }
Esempio n. 23
0
    /** \brief Linearly interpolates a z value at given x and y values
     *  \param filename name of file with x y and z data
     *  \param x x-coordinate to interpolate at
     *  \param y y-coordinate to interpolate at
     *  \return z value interpolated at given x and y values
     */
    public static double func_interpZ(string filename, double x, double y)
    {
        StreamWriter outfile;

        outfile = new StreamWriter("log.txt", true);
        outfile.WriteLine("function func_interpZ called with inputs: {");
        outfile.Write("  filename = ");
        outfile.Write(filename);
        outfile.WriteLine(", ");
        outfile.Write("  x = ");
        outfile.Write(x);
        outfile.WriteLine(", ");
        outfile.Write("  y = ");
        outfile.WriteLine(y);
        outfile.WriteLine("  }");
        outfile.Close();

        List <double>         x_z_1;
        List <double>         y_z_1;
        List <double>         x_z_2;
        List <double>         y_z_2;
        int                   j;
        int                   k_2;
        double                y_1;
        double                y_2;
        List <List <double> > x_matrix = new List <List <double> >(0);
        List <List <double> > y_matrix = new List <List <double> >(0);
        List <double>         z_vector = new List <double>(0);

        ReadTable.func_read_table(filename, z_vector, x_matrix, y_matrix);
        for (int i = 0; i < z_vector.Count - 1; i += 1)
        {
            x_z_1   = func_extractColumn(x_matrix, i);
            outfile = new StreamWriter("log.txt", true);
            outfile.Write("var 'x_z_1' assigned to ");
            outfile.Write("[");
            for (int list_i1 = 0; list_i1 < x_z_1.Count - 1; list_i1++)
            {
                outfile.Write(x_z_1[list_i1]);
                outfile.Write(", /f ");
            }
            if (x_z_1.Count > 0)
            {
                outfile.Write(x_z_1[x_z_1.Count - 1]);
            }
            outfile.Write("]");
            outfile.WriteLine(" in module Interpolation");
            outfile.Close();
            y_z_1   = func_extractColumn(y_matrix, i);
            outfile = new StreamWriter("log.txt", true);
            outfile.Write("var 'y_z_1' assigned to ");
            outfile.Write("[");
            for (int list_i1 = 0; list_i1 < y_z_1.Count - 1; list_i1++)
            {
                outfile.Write(y_z_1[list_i1]);
                outfile.Write(", /f ");
            }
            if (y_z_1.Count > 0)
            {
                outfile.Write(y_z_1[y_z_1.Count - 1]);
            }
            outfile.Write("]");
            outfile.WriteLine(" in module Interpolation");
            outfile.Close();
            x_z_2   = func_extractColumn(x_matrix, i + 1);
            outfile = new StreamWriter("log.txt", true);
            outfile.Write("var 'x_z_2' assigned to ");
            outfile.Write("[");
            for (int list_i1 = 0; list_i1 < x_z_2.Count - 1; list_i1++)
            {
                outfile.Write(x_z_2[list_i1]);
                outfile.Write(", /f ");
            }
            if (x_z_2.Count > 0)
            {
                outfile.Write(x_z_2[x_z_2.Count - 1]);
            }
            outfile.Write("]");
            outfile.WriteLine(" in module Interpolation");
            outfile.Close();
            y_z_2   = func_extractColumn(y_matrix, i + 1);
            outfile = new StreamWriter("log.txt", true);
            outfile.Write("var 'y_z_2' assigned to ");
            outfile.Write("[");
            for (int list_i1 = 0; list_i1 < y_z_2.Count - 1; list_i1++)
            {
                outfile.Write(y_z_2[list_i1]);
                outfile.Write(", /f ");
            }
            if (y_z_2.Count > 0)
            {
                outfile.Write(y_z_2[y_z_2.Count - 1]);
            }
            outfile.Write("]");
            outfile.WriteLine(" in module Interpolation");
            outfile.Close();
            try {
                j       = func_find(x_z_1, x);
                outfile = new StreamWriter("log.txt", true);
                outfile.Write("var 'j' assigned to ");
                outfile.Write(j);
                outfile.WriteLine(" in module Interpolation");
                outfile.Close();
                k_2     = func_find(x_z_2, x);
                outfile = new StreamWriter("log.txt", true);
                outfile.Write("var 'k_2' assigned to ");
                outfile.Write(k_2);
                outfile.WriteLine(" in module Interpolation");
                outfile.Close();
            } catch {
                continue;
            }
            y_1     = func_lin_interp(x_z_1[j], y_z_1[j], x_z_1[j + 1], y_z_1[j + 1], x);
            outfile = new StreamWriter("log.txt", true);
            outfile.Write("var 'y_1' assigned to ");
            outfile.Write(y_1);
            outfile.WriteLine(" in module Interpolation");
            outfile.Close();
            y_2     = func_lin_interp(x_z_2[k_2], y_z_2[k_2], x_z_2[k_2 + 1], y_z_2[k_2 + 1], x);
            outfile = new StreamWriter("log.txt", true);
            outfile.Write("var 'y_2' assigned to ");
            outfile.Write(y_2);
            outfile.WriteLine(" in module Interpolation");
            outfile.Close();
            if (y_1 <= y && y <= y_2)
            {
                return(func_lin_interp(y_1, z_vector[i], y_2, z_vector[i + 1], y));
            }
        }
        throw new Exception("Interpolation of z failed");
    }
Esempio n. 24
0
 /// <summary>
 /// 获取未跟踪查询对象
 /// </summary>
 public IQueryable <TEntity> FindAsNoTracking()
 {
     return(ReadTable.AsNoTracking());
 }