@@ -208,7 +208,7 @@ public T Add<T>(T entity) where T : IEntity
208208 }
209209
210210 string resourceString = entity . GetType ( ) . Name . ToLower ( CultureInfo . InvariantCulture ) ;
211- if ( resourceString == "creditcardpaymenttxn" )
211+ if ( resourceString == "creditcardpaymenttxn" )
212212 {
213213 resourceString = "creditcardpayment" ;
214214 }
@@ -815,29 +815,29 @@ public T FindById<T>(T entity) where T : IEntity
815815 {
816816 resourceString = "creditcardpayment" ;
817817 }
818-
819818
820- // Convert to role base to get the Id property which is required to Find the entity.
821- IntuitEntity intuitEntity = entity as IntuitEntity ;
822- if ( intuitEntity == null )
823- {
824- IdsException exception = new IdsException ( Resources . EntityConversionFailedMessage ) ;
825- this . serviceContext . IppConfiguration . Logger . CustomLogger . Log ( Diagnostics . TraceLevel . Error , string . Format ( CultureInfo . InvariantCulture , Resources . ExceptionGeneratedMessage , exception . ToString ( ) ) ) ;
826- IdsExceptionManager . HandleException ( exception ) ;
827- }
828819
829- // Check whether the Id is null and throw an exception if it is null.
830- if ( string . IsNullOrWhiteSpace ( intuitEntity . Id ) && ( entity . GetType ( ) . Name != "Preferences" ) )
831- {
832- IdsException exception = new IdsException ( Resources . EntityIdNotNullMessage , new ArgumentNullException ( Resources . IdString ) ) ;
833- this . serviceContext . IppConfiguration . Logger . CustomLogger . Log ( Diagnostics . TraceLevel . Error , string . Format ( CultureInfo . InvariantCulture , Resources . ExceptionGeneratedMessage , exception . ToString ( ) ) ) ;
834- IdsExceptionManager . HandleException ( exception ) ;
835- }
836-
837- id = intuitEntity . Id ;
838-
839-
840-
820+ // Convert to role base to get the Id property which is required to Find the entity.
821+ IntuitEntity intuitEntity = entity as IntuitEntity ;
822+ if ( intuitEntity == null )
823+ {
824+ IdsException exception = new IdsException ( Resources . EntityConversionFailedMessage ) ;
825+ this . serviceContext . IppConfiguration . Logger . CustomLogger . Log ( Diagnostics . TraceLevel . Error , string . Format ( CultureInfo . InvariantCulture , Resources . ExceptionGeneratedMessage , exception . ToString ( ) ) ) ;
826+ IdsExceptionManager . HandleException ( exception ) ;
827+ }
828+
829+ // Check whether the Id is null and throw an exception if it is null.
830+ if ( string . IsNullOrWhiteSpace ( intuitEntity . Id ) && ( entity . GetType ( ) . Name != "Preferences" ) )
831+ {
832+ IdsException exception = new IdsException ( Resources . EntityIdNotNullMessage , new ArgumentNullException ( Resources . IdString ) ) ;
833+ this . serviceContext . IppConfiguration . Logger . CustomLogger . Log ( Diagnostics . TraceLevel . Error , string . Format ( CultureInfo . InvariantCulture , Resources . ExceptionGeneratedMessage , exception . ToString ( ) ) ) ;
834+ IdsExceptionManager . HandleException ( exception ) ;
835+ }
836+
837+ id = intuitEntity . Id ;
838+
839+
840+
841841
842842 string uri = string . Empty ;
843843
@@ -903,7 +903,7 @@ public T FindById<T>(T entity) where T : IEntity
903903 public ReadOnlyCollection < T > FindByParentId < T > ( T entity ) where T : IEntity
904904 {
905905 this . serviceContext . IppConfiguration . Logger . CustomLogger . Log ( Diagnostics . TraceLevel . Info , "Called Method FindByParentId." ) ;
906-
906+
907907 ServicesHelper . ValidateEntity ( entity , serviceContext ) ;
908908 ServicesHelper . ValidateEntityType ( entity , "TaxClassification" , serviceContext ) ;
909909
@@ -957,7 +957,7 @@ public ReadOnlyCollection<T> FindByLevel<T>(T entity) where T : IEntity
957957
958958 // Check whether the Level is null and throw an exception if it is null.
959959 ServicesHelper . ValidateId ( level , serviceContext ) ;
960-
960+
961961 string uri = string . Empty ;
962962 uri = string . Format ( CultureInfo . InvariantCulture , "{0}/company/{1}/{2}?level={3}" , CoreConstants . VERSION , this . serviceContext . RealmId , resourceString , level ) ;
963963
@@ -984,7 +984,7 @@ public ReadOnlyCollection<T> FindAll<T>(T entity, int startPosition = 1, int max
984984 ServicesHelper . ValidateEntity ( entity , serviceContext ) ;
985985 string resourceString = entity . GetType ( ) . Name ;
986986
987- if ( resourceString . ToLower ( CultureInfo . InvariantCulture ) == "creditcardpaymenttxn" )
987+ if ( resourceString . ToLower ( CultureInfo . InvariantCulture ) == "creditcardpaymenttxn" )
988988 {
989989 resourceString = "creditcardpayment" ;
990990 }
@@ -995,7 +995,7 @@ public ReadOnlyCollection<T> FindAll<T>(T entity, int startPosition = 1, int max
995995 string uri = string . Empty ;
996996 uri = string . Format ( CultureInfo . InvariantCulture , "{0}/company/{1}/{2}" , CoreConstants . VERSION , this . serviceContext . RealmId , resourceString . ToLower ( CultureInfo . InvariantCulture ) ) ;
997997
998- entities = PrepareAndExecuteHttpRequest < T > ( uri ) ;
998+ entities = PrepareAndExecuteHttpRequest < T > ( uri ) ;
999999 }
10001000 else
10011001 {
@@ -2091,36 +2091,15 @@ public byte[] Download(Attachable entity)
20912091
20922092 if ( uriResponse != null )
20932093 {
2094- const int unEscapeDotsAndSlashes = 0x2000000 ;
2095- FieldInfo fieldInfo = uriResponse . GetType ( ) . GetField ( "m_Syntax" , BindingFlags . Instance | BindingFlags . NonPublic ) ;
2096- if ( fieldInfo == null )
2097- {
2098- throw new MissingFieldException ( "'m_Syntax' field not found" ) ;
2099- }
2100- object uriParser = fieldInfo . GetValue ( uriResponse ) ;
2101-
2102- fieldInfo = typeof ( UriParser ) . GetField ( "m_Flags" , BindingFlags . Instance | BindingFlags . NonPublic ) ;
2103- if ( fieldInfo == null )
2104- {
2105- throw new MissingFieldException ( "'m_Flags' field not found" ) ;
2106- }
2107- object uriSyntaxFlags = fieldInfo . GetValue ( uriParser ) ;
2108- object backupSyntaxFlags = uriSyntaxFlags ;
2109-
2110- // Clear the flag that we don't want
2111- uriSyntaxFlags = ( int ) uriSyntaxFlags & ~ unEscapeDotsAndSlashes ;
2112-
2113- fieldInfo . SetValue ( uriParser , uriSyntaxFlags ) ;
2114-
21152094 HttpWebRequest downloadRequest = WebRequest . Create ( uriResponse ) as HttpWebRequest ;
21162095 downloadRequest . Method = HttpVerbType . GET . ToString ( ) ;
21172096
2118- WebResponse downloadResponse = downloadRequest . GetResponse ( ) ;
2119- BinaryReader streamReader = new BinaryReader ( downloadResponse . GetResponseStream ( ) ) ;
2120-
2121- fieldInfo . SetValue ( uriParser , backupSyntaxFlags ) ;
2097+ using ( WebResponse downloadResponse = downloadRequest . GetResponse ( ) )
2098+ using ( BinaryReader streamReader = new BinaryReader ( downloadResponse . GetResponseStream ( ) ) )
2099+ {
21222100
2123- return streamReader . ReadBytes ( int . Parse ( downloadResponse . Headers [ "Content-Length" ] ) ) ;
2101+ return streamReader . ReadBytes ( int . Parse ( downloadResponse . Headers [ "Content-Length" ] ) ) ;
2102+ }
21242103
21252104 // return response;
21262105 }
@@ -2129,7 +2108,7 @@ public byte[] Download(Attachable entity)
21292108 }
21302109
21312110 #endregion
2132-
2111+
21332112 /// <summary>
21342113 /// Prepare Http request for Reading Tax Cassification methods
21352114 /// </summary>
0 commit comments