예제 #1
0
        /*
         * public NOKEntity GetNOK(int nokID)
         * {
         *  try
         *  {
         *      NOKAdapter nokAdapter = new NOKAdapter();
         *      PersonBL personBL = new PersonBL();
         *
         *      DataSet ds = _nokDA.GetNOK(nokID);
         *      if ((ds.Tables != null) && (ds.Tables.Contains(SII.HCD.Administrative.Entities.TableNames.NOKTable)) && (ds.Tables[SII.HCD.Administrative.Entities.TableNames.NOKTable].Rows.Count > 0))
         *      {
         *          int personID = SIIConvert.ToInteger(ds.Tables[SII.HCD.Administrative.Entities.TableNames.NOKTable].Rows[0]["PersonID"].ToString(), 0);
         *          int kinshipID = SIIConvert.ToInteger(ds.Tables[SII.HCD.Administrative.Entities.TableNames.NOKTable].Rows[0]["KinshipID"].ToString(), 0);
         *
         *          DataSet ds2;
         *
         #region Kinships
         *          ds2 = _kinshipDA.GetKinshipByID(kinshipID);
         *          if ((ds2 != null) && (ds2.Tables.Contains(SII.HCD.Administrative.Entities.TableNames.KinshipTable)))
         *          {
         *              DataTable dt = ds2.Tables[SII.HCD.Administrative.Entities.TableNames.KinshipTable].Copy();
         *              ds.Tables.Add(dt);
         *          }
         #endregion
         *
         #region Person
         *          if (personID <= 0)
         *          {
         *              throw new Exception(Properties.Resources.ERROR_NOKPersonNotFound);
         *          }
         *          SII.HCD.BackOffice.Entities.PersonEntity myPerson = personBL.GetPerson(personID);
         #endregion
         *
         *          NOKEntity result = nokAdapter.GetInfo(ds.Tables[SII.HCD.Administrative.Entities.TableNames.NOKTable].Rows[0], ds);
         *          result.Person = myPerson;
         *          LOPDLogger.Write(EntityNames.NOKEntityName, nokID, ActionType.View);
         *          return result;
         *      }
         *      else
         *          return null;
         *  }
         *  catch (Exception ex)
         *  {
         *      if (ExceptionPolicy.HandleException(ex, ExceptionPolicies.Service)) throw;
         *      return null;
         *  }
         * }
         */
        public NOKEntity GetNOK(int nokID)
        {
            try
            {
                #region Person
                PersonBL personBL = new PersonBL();
                int      personID = 0;
                personID = personBL.obtenerPersonID_From_NOK(nokID);

                if (personID == 0)
                {
                    throw new Exception(Properties.Resources.ERROR_NOKPersonNotFound);
                }
                PersonEntity myPerson   = null;
                var          HiloPerson = System.Threading.Tasks.Task.Factory.StartNew(() => myPerson = personBL.GetPerson(personID));
                #endregion

                DataSet ds = _nokDA.GetNOK(nokID);
                if ((ds.Tables != null) && (ds.Tables.Contains(SII.HCD.Administrative.Entities.TableNames.NOKTable)) && (ds.Tables[SII.HCD.Administrative.Entities.TableNames.NOKTable].Rows.Count > 0))
                {
                    DataSet ds2 = new DataSet();
                    foreach (DataTable oTabla in ds.Tables)
                    {
                        if (oTabla.Rows.Count > 0)
                        {
                            ds2.Tables.Add(oTabla.Copy());
                        }
                    }

                    NOKAdapter nokAdapter = new NOKAdapter();
                    NOKEntity  result     = nokAdapter.GetInfo(ds.Tables[SII.HCD.Administrative.Entities.TableNames.NOKTable].Rows[0], ds2);
                    HiloPerson.Wait();
                    result.Person = myPerson;
                    LOPDLogger.Write(EntityNames.NOKEntityName, nokID, ActionType.View);
                    ds.Dispose();
                    ds2.Dispose();
                    return(result);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                if (ExceptionPolicy.HandleException(ex, ExceptionPolicies.Service))
                {
                    throw;
                }
                return(null);
            }
        }