586. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 10/26/2017 10:44:23 PM Eastern Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

586.1 Files compared

# Location File Last Modified
1 Fri Oct 27 02:44:23 2017 UTC
2 OSCIF_BMS_v2_iter 2_September_2017.zip\BMS_Cand\Source\Sources\BMS.Vista.TestEis\BMS.Utils ProxyManager.cs Wed Oct 18 18:47:02 2017 UTC

586.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 0 0
Changed 0 0
Inserted 1 398
Removed 0 0

586.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

586.4 Active regular expressions

No regular expressions were active.

586.5 Comparison detail

        1   using Syst em;
        2   using Syst em.Collect ions.Gener ic;
        3   using Syst em.Linq;
        4   using Syst em.Text;
        5   using Syst em.Collect ions;
        6   using Syst em.Service Model;
        7   using Syst em.Service Model.Chan nels;
        8   using Syst em.Reflect ion;
        9  
        10   namespace  BMS.Utils
        11   {
        12       /// <s ummary>
        13       /// WC F Proxy Ma nager used  to keep a  list of a ll proxies  and recre ate them o n faulted  or closed  state.
        14       /// </ summary>
        15       public  class Pro xyManager
        16       {
        17           pr ivate stat ic Hashtab le _proxie s = new Ha shtable();
        18           st atic BmsLo gger logge r = new Bm sLogger("B MS.Utils.P roxyManage r - ");
        19  
        20           // / <summary >
        21           // / Return a  cached pr oxy.
        22           // / </summar y>
        23           // / <typepar am name="T ">ICommuni cationObje ct proxy t ype</typep aram>
        24           // / <returns >The cache d proxy.</ returns>
        25           pu blic stati c T GetPro xy<T>(stri ng endpoin tName) whe re T : cla ss, ICommu nicationOb ject, IDis posable, n ew()
        26           {
        27                DateTime  entryInLo gMethodTim e = DateTi me.UtcNow;
        28                if (Info World.Trac ing.IWTrac e.IsEntryE nabled)
        29                {
        30                    Info World.Trac ing.IWTrac e.Entry(Sy stem.Refle ction.Meth odBase.Get CurrentMet hod(), ent ryInLogMet hodTime);
        31                }
        32                try
        33                {
        34                    stri ng proxyKe y = null;
        35                    if ( endpointNa me.Contain s(".Window s") || end pointName. StartsWith ("EVS."))
        36                         proxyKey =  endpointN ame;
        37                    else
        38                    {
        39                         string use rName = Ge tCurrentUs erName();
        40                         if (!strin g.IsNullOr Empty(user Name))
        41                             proxyK ey = endpo intName +  "_" + user Name;
        42                         else
        43                             proxyK ey = endpo intName;
        44                    }
        45  
        46                    lock  (_proxies )
        47                    {                      
        48                         if (!_prox ies.Contai ns(proxyKe y))
        49                             _proxi es.Add(pro xyKey, new  PoolProxy <T>());
        50  
        51                         PoolProxy< T> pool =  ((PoolProx y<T>)_prox ies[proxyK ey]);
        52                         T proxy =  pool.Take( );
        53  
        54                         if (proxy  != null &&  proxy.Sta te != Comm unicationS tate.Opene d)
        55                         {
        56                             proxy. Abort();
        57                             proxy  = null;
        58                         }
        59                         // Create  the proxy  if not fou nd in the  pool.
        60                         if (proxy  == null)                      
        61                             proxy  = CreatePr oxy<T>(end pointName) ;                      
        62                        
        63                         return pro xy;
        64                    }
        65                }
        66                finally
        67                {
        68                    if ( InfoWorld. Tracing.IW Trace.IsEx itEnabled)
        69                    {
        70                         InfoWorld. Tracing.IW Trace.Exit (System.Re flection.M ethodBase. GetCurrent Method(),  DateTime.U tcNow, ent ryInLogMet hodTime);
        71                    }
        72                }
        73           }
        74  
        75           pr ivate stat ic T Creat eProxy<T>( string end pointName)  where T :  class, IC ommunicati onObject,  new()
        76           {
        77                DateTime  entryInLo gMethodTim e = DateTi me.UtcNow;
        78                if (Info World.Trac ing.IWTrac e.IsEntryE nabled)
        79                {
        80                    Info World.Trac ing.IWTrac e.Entry(Sy stem.Refle ction.Meth odBase.Get CurrentMet hod(), ent ryInLogMet hodTime);
        81                }
        82                try
        83                {
        84                    if ( String.IsN ullOrEmpty (endpointN ame))
        85                         return new  T();
        86                    retu rn (T)Acti vator.Crea teInstance (typeof(T) , endpoint Name);
        87                }
        88                finally
        89                {
        90                    if ( InfoWorld. Tracing.IW Trace.IsEx itEnabled)
        91                    {
        92                         InfoWorld. Tracing.IW Trace.Exit (System.Re flection.M ethodBase. GetCurrent Method(),  DateTime.U tcNow, ent ryInLogMet hodTime);
        93                    }
        94                }
        95           }
        96  
        97           pu blic stati c void Ret urnProxy<T >(T proxy,  string en dpointName ) where T  : class, I Communicat ionObject,  IDisposab le
        98           {
        99                DateTime  entryInLo gMethodTim e = DateTi me.UtcNow;
        100                if (Info World.Trac ing.IWTrac e.IsEntryE nabled)
        101                {
        102                    Info World.Trac ing.IWTrac e.Entry(Sy stem.Refle ction.Meth odBase.Get CurrentMet hod(), ent ryInLogMet hodTime);
        103                }
        104                try
        105                {
        106                    bool  shouldClo se = false ;
        107  
        108                    stri ng proxyKe y = null;
        109                    if ( endpointNa me.Contain s(".Window s") || end pointName. StartsWith ("EVS."))
        110                         proxyKey =  endpointN ame;
        111                    else
        112                    {
        113                         string use rName = Ge tCurrentUs erName();
        114                         if (!strin g.IsNullOr Empty(user Name))
        115                             proxyK ey = endpo intName +  "_" + user Name;
        116                         else
        117                             proxyK ey = endpo intName;
        118                    }
        119  
        120                    lock  (_proxies )
        121                    {
        122                         if (_proxi es.Contain s(proxyKey ))
        123                         {                       
        124                             PoolPr oxy<T> poo l = ((Pool Proxy<T>)_ proxies[pr oxyKey]);
        125                             should Close = !p ool.Return (proxy);
        126                         }
        127                    }                  
        128                    // C lose the p roxy if it 's not put  back into  pool
        129                    if ( shouldClos e)
        130                    {
        131                         //Tracer.T raceMessag e(string.F ormat("Poo l for prox y endpoint  {0} is fu ll!", prox yKey));
        132                         try
        133                         {
        134                             proxy. Close();
        135                         }
        136                         catch
        137                         {
        138                             proxy. Abort();                           
        139                         }
        140                         proxy.Disp ose();
        141                         proxy = nu ll;
        142                    }                  
        143                }
        144                finally
        145                {
        146                    if ( InfoWorld. Tracing.IW Trace.IsEx itEnabled)
        147                    {
        148                         InfoWorld. Tracing.IW Trace.Exit (System.Re flection.M ethodBase. GetCurrent Method(),  DateTime.U tcNow, ent ryInLogMet hodTime);
        149                    }
        150                }
        151           }
        152  
        153           pu blic stati c void Cle arUserProx ies(string  userName)
        154           {
        155                DateTime  entryInLo gMethodTim e = DateTi me.UtcNow;
        156                if (Info World.Trac ing.IWTrac e.IsEntryE nabled)
        157                {
        158                    Info World.Trac ing.IWTrac e.Entry(Sy stem.Refle ction.Meth odBase.Get CurrentMet hod(), ent ryInLogMet hodTime);
        159                }
        160                try
        161                {
        162                    stri ng partKey  = "_" + u serName;
        163                    List <string> k eysToRemov e = new Li st<string> ();
        164                    lock  (_proxies )
        165                    {
        166                         foreach (s tring key  in _proxie s.Keys)
        167                         {
        168                             if (ke y.EndsWith (partKey,  StringComp arison.Inv ariantCult ureIgnoreC ase))
        169                             {
        170                                 tr y
        171                                 {
        172                                      keysToRe move.Add(k ey);
        173                                      MethodIn fo method  = _proxies [key].GetT ype().GetM ethod("Cle ar");
        174                                      method.I nvoke(_pro xies[key],  null);
        175                                 }
        176                                 ca tch (Excep tion ex)
        177                                 {
        178                                      Tracer.T raceMessag e("ProxyMa nager.Clea rUserProxi es for use r " + user Name + " a nd key " +  key + " e xception") ;
        179                                      Tracer.T raceExcept ion(ex);
        180                                 }
        181                             }
        182                         }
        183                         foreach (s tring key  in keysToR emove)
        184                         {
        185                             _proxi es[key] =  null;
        186                             _proxi es.Remove( key);
        187                         }
        188                    }
        189                }
        190                catch (E xception e x)
        191                {
        192                    Trac er.TraceMe ssage("Pro xyManager. ClearUserP roxies for  user " +  userName +  " excepti on");
        193                    Trac er.TraceEx ception(ex );
        194                }
        195                finally
        196                {
        197                    if ( InfoWorld. Tracing.IW Trace.IsEx itEnabled)
        198                    {
        199                         InfoWorld. Tracing.IW Trace.Exit (System.Re flection.M ethodBase. GetCurrent Method(),  DateTime.U tcNow, ent ryInLogMet hodTime);
        200                    }
        201                }
        202           }         
        203  
        204           // / <summary >
        205           // / Checks t he current  state of  an existin g proxy.
        206           // / </summar y>
        207           // / <param n ame="proxy ">The comm unication  object (pr oxy) to be  checked.< /param>
        208           // / <returns >False is  proxy is u nsable, tr ue otherwi se.</retur ns>
        209           pu blic stati c bool Che ckProxyIns tance(ICom munication Object pro xy)
        210           {
        211                DateTime  entryInLo gMethodTim e = DateTi me.UtcNow;
        212                if (Info World.Trac ing.IWTrac e.IsEntryE nabled)
        213                {
        214                    Info World.Trac ing.IWTrac e.Entry(Sy stem.Refle ction.Meth odBase.Get CurrentMet hod(), ent ryInLogMet hodTime);
        215                }
        216                try
        217                {
        218                    try
        219                    {
        220                         if (proxy  == null)
        221                             return  false;
        222                         if (proxy. State == S ystem.Serv iceModel.C ommunicati onState.Fa ulted)
        223                             return  false;
        224                         if (proxy. State == S ystem.Serv iceModel.C ommunicati onState.Cl osed)
        225                             return  false;
        226                         if (proxy. State == S ystem.Serv iceModel.C ommunicati onState.Cl osing)
        227                             return  false;
        228                         return tru e;
        229                    }
        230                    catc h { return  false; }
        231                }
        232                finally
        233                {
        234                    if ( InfoWorld. Tracing.IW Trace.IsEx itEnabled)
        235                    {
        236                         InfoWorld. Tracing.IW Trace.Exit (System.Re flection.M ethodBase. GetCurrent Method(),  DateTime.U tcNow, ent ryInLogMet hodTime);
        237                    }
        238                }
        239           }
        240           
        241           // / <summary >
        242           // / Verifies  whether t he excepti on is non- critical -  the proxy  can be re created.
        243           // / </summar y>
        244           // / <param n ame="e">Th rown excep tion</para m>
        245           // / <returns >True is e xception i s not vita l and the  proxy can  be recreat ed.</retur ns>
        246           pu blic stati c bool Che ckThrownEx ception(Sy stem.Excep tion e)
        247           {
        248                DateTime  entryInLo gMethodTim e = DateTi me.UtcNow;
        249                if (Info World.Trac ing.IWTrac e.IsEntryE nabled)
        250                {
        251                    Info World.Trac ing.IWTrac e.Entry(Sy stem.Refle ction.Meth odBase.Get CurrentMet hod(), ent ryInLogMet hodTime);
        252                }
        253                try
        254                {
        255                    if ( e is Syste m.ServiceM odel.Secur ity.Messag eSecurityE xception)
        256                         return tru e;
        257                    if ( e is Syste m.ServiceM odel.Fault Exception)
        258                         return fal se;
        259                    if ( e is Syste m.ServiceM odel.Commu nicationEx ception)
        260                         return tru e;
        261                    if ( e is Syste m.TimeoutE xception)
        262                         return tru e;
        263                    if ( e is Syste m.ServiceM odel.Commu nicationOb jectAborte dException )
        264                         return tru e;
        265                    retu rn false;
        266                }
        267                finally
        268                {
        269                    if ( InfoWorld. Tracing.IW Trace.IsEx itEnabled)
        270                    {
        271                         InfoWorld. Tracing.IW Trace.Exit (System.Re flection.M ethodBase. GetCurrent Method(),  DateTime.U tcNow, ent ryInLogMet hodTime);
        272                    }
        273                }
        274           }
        275           
        276           // / <summary >
        277           // / Returns  the curren t HttpSess ion id. If  this meth od is call ed outside  a HttpCon text
        278           // / it tries  to find t he session  id in the  WCF Opera tionContex t in HttpR equestMess age header s.
        279           // / </summar y>
        280           // / <returns >The curre nt HTTP Se ssion ID.< /returns>
        281           pu blic stati c string G etCurrentS essionID()
        282           {
        283                DateTime  entryInLo gMethodTim e = DateTi me.UtcNow;
        284                if (Info World.Trac ing.IWTrac e.IsEntryE nabled)
        285                {
        286                    Info World.Trac ing.IWTrac e.Entry(Sy stem.Refle ction.Meth odBase.Get CurrentMet hod(), ent ryInLogMet hodTime);
        287                }
        288                try
        289                {
        290                    Stri ng result  = String.E mpty;
        291                    if ( System.Web .HttpConte xt.Current  != null & & System.W eb.HttpCon text.Curre nt.Session  != null & & System.W eb.HttpCon text.Curre nt.Session ["User"] ! = null)
        292                         return Sys tem.Web.Ht tpContext. Current.Se ssion.Sess ionID;
        293                    if ( OperationC ontext.Cur rent != nu ll &&
        294                         OperationC ontext.Cur rent.Incom ingMessage Properties  != null & & Operatio nContext.C urrent.Ins tanceConte xt.State = = Communic ationState .Opened)
        295                    {
        296                         try
        297                         {
        298                             KeyVal uePair<str ing, objec t> propert y = Operat ionContext .Current.I ncomingMes sageProper ties.First OrDefault( a => a.Key  == HttpRe questMessa geProperty .Name);
        299                             if (pr operty.Val ue != null  && proper ty.Value i s HttpRequ estMessage Property)
        300                             {
        301                                 Ht tpRequestM essageProp erty val =  null;
        302                                 va l = proper ty.Value a s HttpRequ estMessage Property;
        303                                 if  (val != n ull) {
        304                                 if  (val.Head ers.HasKey s() && val .Headers.A llKeys.Con tains(Cons tants.HTTP _SESSION_I D_HTTP_HEA DER))
        305                                      return v al.Headers [Constants .HTTP_SESS ION_ID_HTT P_HEADER];
        306                                 }
        307                             }
        308                         }
        309                         catch (Sys tem.Object DisposedEx ception)
        310                         {
        311                             return  string.Em pty;
        312                         }
        313                    }
        314                    retu rn string. Empty;
        315                }
        316                finally
        317                {
        318                    if ( InfoWorld. Tracing.IW Trace.IsEx itEnabled)
        319                    {
        320                         InfoWorld. Tracing.IW Trace.Exit (System.Re flection.M ethodBase. GetCurrent Method(),  DateTime.U tcNow, ent ryInLogMet hodTime);
        321                    }
        322                }
        323           }
        324  
        325           // / <summary >
        326           // / Returns  the curren t HttpSess ion id. If  this meth od is call ed outside  a HttpCon text
        327           // / it tries  to find t he session  id in the  WCF Opera tionContex t in HttpR equestMess age header s.
        328           // / </summar y>
        329           // / <returns >The curre nt HTTP Se ssion ID.< /returns>
        330           pu blic stati c string G etCurrentS essionID2( )
        331           {
        332                DateTime  entryInLo gMethodTim e = DateTi me.UtcNow;
        333                if (Info World.Trac ing.IWTrac e.IsEntryE nabled)
        334                {
        335                    Info World.Trac ing.IWTrac e.Entry(Sy stem.Refle ction.Meth odBase.Get CurrentMet hod(), ent ryInLogMet hodTime);
        336                }
        337                try
        338                {
        339                    Stri ng result  = String.E mpty;
        340                    if ( System.Web .HttpConte xt.Current  != null & & System.W eb.HttpCon text.Curre nt.Session  != null)
        341                         return Sys tem.Web.Ht tpContext. Current.Se ssion.Sess ionID;
        342                    if ( OperationC ontext.Cur rent != nu ll &&
        343                         OperationC ontext.Cur rent.Incom ingMessage Properties  != null & & Operatio nContext.C urrent.Ins tanceConte xt.State = = Communic ationState .Opened)
        344                    {
        345                         try
        346                         {
        347                             KeyVal uePair<str ing, objec t> propert y = Operat ionContext .Current.I ncomingMes sageProper ties.First OrDefault( a => a.Key  == HttpRe questMessa geProperty .Name);
        348                             if (pr operty.Val ue != null  && proper ty.Value i s HttpRequ estMessage Property)
        349                             {
        350                                 Ht tpRequestM essageProp erty val =  null;
        351                                 va l = proper ty.Value a s HttpRequ estMessage Property;
        352                                 if  (val != n ull) {
        353                                 if  (val.Head ers.HasKey s() && val .Headers.A llKeys.Con tains(Cons tants.HTTP _SESSION_I D_HTTP_HEA DER))
        354                                      return v al.Headers [Constants .HTTP_SESS ION_ID_HTT P_HEADER];
        355                                 }
        356                             }
        357                         }
        358                         catch (Sys tem.Object DisposedEx ception)
        359                         {
        360                             return  string.Em pty;
        361                         }
        362                    }
        363                    retu rn string. Empty;
        364                }
        365                finally
        366                {
        367                    if ( InfoWorld. Tracing.IW Trace.IsEx itEnabled)
        368                    {
        369                         InfoWorld. Tracing.IW Trace.Exit (System.Re flection.M ethodBase. GetCurrent Method(),  DateTime.U tcNow, ent ryInLogMet hodTime);
        370                    }
        371                }
        372           }
        373  
        374           pu blic stati c string G etCurrentU serName()
        375           {
        376                DateTime  entryInLo gMethodTim e = DateTi me.UtcNow;
        377                if (Info World.Trac ing.IWTrac e.IsEntryE nabled)
        378                {
        379                    Info World.Trac ing.IWTrac e.Entry(Sy stem.Refle ction.Meth odBase.Get CurrentMet hod(), ent ryInLogMet hodTime);
        380                }
        381                try
        382                {
        383                    Stri ng result  = String.E mpty;
        384                    if ( System.Web .HttpConte xt.Current  != null & & System.W eb.HttpCon text.Curre nt.Session  != null & & System.W eb.HttpCon text.Curre nt.Session ["UserName "] != null )                 
        385                         return Sys tem.Web.Ht tpContext. Current.Se ssion["Use rName"].To String();
        386                                      
        387                    retu rn string. Empty;
        388                }
        389                finally
        390                {
        391                    if ( InfoWorld. Tracing.IW Trace.IsEx itEnabled)
        392                    {
        393                         InfoWorld. Tracing.IW Trace.Exit (System.Re flection.M ethodBase. GetCurrent Method(),  DateTime.U tcNow, ent ryInLogMet hodTime);
        394                    }
        395                }
        396           }
        397       }
        398   }