Exemplo n.º 1
0
        private bool ExistGroup(string sid, string groupName, ref int groupid, 
							 			string epriseName, ref int enterpriseid)
        {
            try
            {
                Initialize(sid);
                if (cacheMem.IsInCache(DBTables.GROUPS + groupName))
                {
                    if (cacheMem.IsInCache(DBTables.ENTERPRISES + epriseName))
                    {
                        EnterpriseStruct es = (EnterpriseStruct) cacheMem.GetCacheData(
                                  					DBTables.ENTERPRISES + epriseName);
                        GroupStruct gs = (GroupStruct) cacheMem.GetCacheData(
                                             		DBTables.GROUPS + groupName);
                        if (gs.enterpriseid != es.id)
                        {
                            InvalidGroupException ige = new InvalidGroupException();
                            throw ige;
                        }
                        else
                            return true;
                    }
                    else
                    {
                        InvalidGroupException ige = new InvalidGroupException();
                        throw ige;
                    }
                }
                else
                {
                    GroupStruct g = groups.GetGroupByName(groupName);
                    EnterpriseStruct e = enterprises.GetEnterpriseByName(epriseName);
                    if (g.enterpriseid != e.id)
                    {
                        InvalidGroupException ige = new InvalidGroupException();
                        throw ige;
                    }
                    cacheMem.SetCacheData(g, DBTables.GROUPS + g.name);
                    groupid = g.id;
                    enterpriseid = e.id;
                    return true;
                }
            }
            catch (NullGroupException ex)
            {
                return false;
            }
            catch (InvalidGroupException ige)
            {
                InvalidGroupException wrappedEx = new
                    InvalidGroupException(
                        ErrorManager.AddLayer(ige,RunningClass.GetName(this), RunningClass.GetMethod()));
                throw wrappedEx;
            }
            catch (Exception ex)
            {
                Exception wrappedEx = new Exception(
                    ErrorManager.AddLayer(ex, RunningClass.GetName(this), RunningClass.GetMethod()));
                throw wrappedEx;
            }
        }
Exemplo n.º 2
0
 private bool ExistEnterprise(string sid, string epriseName)
 {
     try
     {
         Initialize(sid);
         if (cacheMem.IsInCache(DBTables.ENTERPRISES + epriseName))
             return true;
         else
         {
             EnterpriseStruct e = enterprises.GetEnterpriseByName(epriseName);
             cacheMem.SetCacheData(e, DBTables.ENTERPRISES + e.name);
             return true;
         }
     }
     catch (NullEnterpriseException ex)
     {
         return false;
     }
     catch (InvalidGroupException ige)
     {
         InvalidGroupException wrappedEx = new
             InvalidGroupException(
                 ErrorManager.AddLayer(ige,	RunningClass.GetName(this), RunningClass.GetMethod()));
         throw wrappedEx;
     }
     catch (Exception ex)
     {
         Exception wrappedEx = new Exception(
             ErrorManager.AddLayer(ex, RunningClass.GetName(this), RunningClass.GetMethod()));
         throw wrappedEx;
     }
 }