[Test, Ignore] public void TestOverfow() { OverFlow myOverflowBase = new OverFlow("0"); OverFlow myOverflow = new OverFlow("10"); myOverflow.AttributeName = "CLAIM:CLAIM_TYPE"; myOverflow.Caption = " Claim (C) or Occurence (O)?"; Assert.IsFalse(myOverflow.ShowWhenEmpty); myOverflow.Sequence = 10; myOverflow.CaptionLength = 40; myOverflowBase.Add(myOverflow); myOverflow = new OverFlow("20"); Assert.IsFalse(myOverflow.ShowWhenEmpty); myOverflow.Sequence = 20; myOverflow.CaptionLength = 40; myOverflowBase.Add(myOverflow); string strXml = myOverflowBase.ToString(); Assert.IsTrue(strXml.Length > 0); Console.WriteLine("{0}", strXml); Console.WriteLine("{0}", myOverflowBase.ToXml()); }
[Test, Ignore] public void TestOverfowSet() { OverFlow myOverflow = OverflowSet.BuildOverflowSet("11", "PAU"); Console.WriteLine("************** GetAttributeDescriptions()"); Console.WriteLine(myOverflow.GetAttributeDescriptions()); Console.WriteLine("************** Overflow ToSting()"); Assert.IsNotNull(myOverflow); string strXml = myOverflow.ToString(); Assert.IsTrue(strXml.Length > 0); //Console.WriteLine("{0}",strXml); //Console.WriteLine("{0}",myOverflow.ToXml()); IEnumerator enumList = myOverflow.GetEnumerator(); while (enumList.MoveNext()) { OverFlow currentOver = (OverFlow)enumList.Current; Console.WriteLine("{0}", currentOver.ToString()); } }
/// <summary> /// BUGBUG: the data access should be factored to DAL /// </summary> /// <param name="ahsId"></param> /// <param name="lobCd"></param> /// <returns></returns> static public OverFlow BuildOverflowSet(string ahsId, string lobCd) { OverFlow result = null; OracleConnection sqlConn = null; OracleCommand sqlCommand = null; OracleDataReader dr = null; string connString = "Data Source=FNSPROD; user id=FNSOWNER; password=ctown_prod; Persist Security info=False;"; string strSQL = "DBCLASSLIBRARY.GetOverflowSet"; try { // create connection sqlConn = new OracleConnection(connString); sqlCommand = new OracleCommand(strSQL, sqlConn); sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.Parameters.Add("p_accntHrcyStepId", OracleType.Int32); sqlCommand.Parameters.Add("p_LineOfBusiness", OracleType.Char); sqlCommand.Parameters.Add("results", OracleType.Cursor); sqlCommand.Parameters[0].Value = ahsId; sqlCommand.Parameters[1].Value = lobCd; sqlCommand.Parameters[2].Direction = ParameterDirection.Output; // open connection to the database sqlConn.Open(); // execute SQL statement dr = sqlCommand.ExecuteReader(); int iSequence = 0; // Always call Read before accessing data. while (dr.Read()) { if (null == result) // do we have a root node? { result = new OverFlow("0"); result.AHSID = ahsId; result.LOB_CD = lobCd; } ++iSequence; OverFlow currentOverflow = new OverFlow(iSequence.ToString()); currentOverflow.AHSID = ahsId; currentOverflow.LOB_CD = lobCd; currentOverflow.Sequence = dr.GetInt32(0); currentOverflow.AttributeName = dr.GetString(1); result.AddAttributeDescription(dr.GetString(1)); if (!dr.IsDBNull(2)) { currentOverflow.Caption = dr.GetString(2); } else { currentOverflow.Caption = String.Empty; } if (!dr.IsDBNull(3)) { currentOverflow.Mapping = dr.GetString(3); } else { currentOverflow.Mapping = String.Empty; } if (!dr.IsDBNull(4)) { currentOverflow.CaptionLength = dr.GetInt32(4); } else { currentOverflow.CaptionLength = 0; } currentOverflow.ShowWhenEmpty = (dr.GetString(5) == "Y"); result.Add(currentOverflow); } } catch (Exception E) { Console.WriteLine("ERROR: RunSQLReturnDataReader {0}", E.ToString()); // rethow error //throw E; } finally { // clean up sqlCommand.Dispose(); dr.Close(); sqlConn.Close(); } result.ResetDepth(); return(result); }