Exemple #1
0
 public void AssignRange(int startOutputId, int numberOfOutputs, IdSet partyIds)
 {
     for (int i = 0; i < numberOfOutputs; ++i)
     {
         _partyIds[startOutputId + i] = partyIds;
     }
 }
        public virtual int GetNewEquivalenceClassPosition()
        {
            IdSet set = new IdSet();

            foreach (EquivalenceClass element1 in EquivalenceClasses)
            {
                set.registerId(element1.Position);
            }
            return(set.NextValidId());
        }
Exemple #3
0
        public virtual int getNewCombinationPosition()
        {
            IdSet set = new IdSet();

            foreach (Combination com in Combinations)
            {
                set.registerId(com.Position);
            }
            return(set.NextValidId());
        }
 public void SetPartiallyCommittedFolderIds(IdSet value)
 {
     this.CheckDisposed("SetPartiallyCommittedFolderIds");
     using (Stream stream = HierarchySyncMetadataItem.SyncMetadataAttachmentStream.CreateAttachment(this, "PartiallyCommittedFolderIds", true))
     {
         if (value != null)
         {
             using (StreamWriter streamWriter = new StreamWriter(stream))
             {
                 value.SerializeWithReplGuids(streamWriter);
             }
         }
     }
 }
Exemple #5
0
        public override void Hacer()
        {
            try
            {
                Categoria         categoria  = Parameters[EActionsParameters.CATEGORIA] as Categoria;
                IList <Categoria> categorias = Parameters[EActionsParameters.CATEGORIAS] as IList <Categoria>;
                IdSet             idset      = Parameters[EActionsParameters.IDS] as IdSet;
                if (categorias == null || categoria == null || idset == null)
                {
                    return;
                }


                FCategoria catdialog = new FCategoria();
                catdialog.Text = this.name;

                Categoria newCategoria = new Categoria();
                newCategoria.Id = idset.getNextValidId();

                catdialog.ShowDialog();
                if (catdialog.DialogResult == DialogResult.OK)
                {
                    idset.registerId(newCategoria.Id);
                    if (newCategoria.Name != catdialog.txtNombre.Text)
                    {
                        newCategoria.Name = catdialog.txtNombre.Text;
                    }
                    if (newCategoria.Description != catdialog.txtDescripcion.Text)
                    {
                        newCategoria.Description = catdialog.txtDescripcion.Text;
                    }
                    //adicionar la categoria hija
                    categorias.Add(newCategoria);
                    if (categoria.Children.Count > 1)
                    {
                        newCategoria.Orden = categoria.Children[0] + newCategoria.Id.ToString();
                    }

                    ((List <Categoria>)categorias).Sort();
                    categoria.addCategoria(newCategoria);
                    //publicar la nueva categoria
                    Parameters.Add(EActionsParameters.NUEVA_CATEGORIA, newCategoria);
                }
            }
            catch (Exception e)
            {
                mensajes = "Ocurrio un error \n" + e.Message;
            }
        }
        //This method creates a set of 25 random non-repeating IDs to be used to pull data from the DB
        private void FillSet()
        {
            Random Rnd         = new Random();
            bool   ConfirmSize = false;

            while (!ConfirmSize)
            {
                int value = Rnd.Next(40); //40 will be changed to the # of rows in the DB
                IdSet.Add(value);
                if (IdSet.Count == Size)
                {
                    ConfirmSize = true;
                }
            }
        }
 public static void ExpandIdSet(IdSet idset, Action <byte[]> action)
 {
     foreach (GuidGlobCountSet guidGlobCountSet in idset)
     {
         foreach (GlobCountRange globCountRange in guidGlobCountSet.GlobCountSet)
         {
             for (ulong num = globCountRange.LowBound; num <= globCountRange.HighBound; num += 1UL)
             {
                 byte[] array     = new byte[22];
                 int    dstOffset = ExBitConverter.Write(guidGlobCountSet.Guid, array, 0);
                 Buffer.BlockCopy(IdConverter.GlobcntIntoByteArray(num), 0, array, dstOffset, 6);
                 action(array);
             }
         }
     }
 }
        public IdSet GetPartiallyCommittedFolderIds()
        {
            this.CheckDisposed("GetPartiallyCommittedFolderIds::get");
            IdSet result = null;

            using (Stream existingAttachment = HierarchySyncMetadataItem.SyncMetadataAttachmentStream.GetExistingAttachment(this, "PartiallyCommittedFolderIds", StreamBase.Capabilities.Readable))
            {
                if (existingAttachment != null)
                {
                    using (StreamReader streamReader = new StreamReader(existingAttachment))
                    {
                        result = IdSet.ParseWithReplGuids(streamReader);
                    }
                }
            }
            return(result);
        }
Exemple #9
0
        /// <summary>
        /// Create a node by reading in a pattern
        /// </summary>
        /// <param name="reader"></param>
        private Node(BinaryReader reader)
        {
            int version = reader.ReadInt32();

            switch (version) //version
            {
            default:
                //Data = reader.ReadByte();
                int len = reader.ReadInt32();
                for (int i = 0; i < len; ++i)
                {
                    IdSet.Add(reader.ReadInt32());
                }
                len = reader.ReadInt32();
                for (int i = 0; i < len; ++i)
                {
                    Links.Add(new Node(reader));
                }
                break;
            }
        }
Exemple #10
0
  public override void FetchTo( ResultSet rs, EvalEnv e )
  {
    ResultSet srs = Order == null ? rs : new Sorter( rs, SortSpec );
    srs = GroupSpec == null ? srs : new Grouper( srs, GroupSpec, AggSpec );

    Value[] tr = new Value[ TE.Cols.Count ];

    EvalEnv ee = new EvalEnv( e.Locals, tr, e.ResultSet );

    IdSet idSet = Where == null ? null : Where.GetIdSet( TE, ee );
    if ( idSet != null ) idSet = new IdCopy( idSet, ee ); // Need to take a copy of the id values if an index is used.

    rs.NewTable( Cols );

    Value [] outrow = new Value[ Exps.Count ]; 

    if ( idSet != null ) 
    // Fetch subset of source table using id values, send to ResultSet (if it satisfies any WHERE clause )
    {
      foreach ( long id in idSet.All( ee ) ) if ( TE.Get( id, tr, Used ) )
      {
        if ( Where == null || Where.Eval( ee ).B )
        {
          for ( int i = 0; i < Exps.Count; i += 1 ) outrow[ i ] = Exps[ i ].Eval( ee );   
          if ( !srs.NewRow( outrow ) ) break;
        }
      }
    }
    else 
    // Fetch every record in source table, send it to output ( if it satisfies any WHERE clause )
    {
      foreach ( bool ok in TE.GetAll( tr, Used, ee ) )
      if ( Where == null || Where.Eval( ee ).B )
      {
        for ( int i = 0; i < Exps.Count; i += 1 ) outrow[ i ] = Exps[ i ].Eval( ee );   
        if ( !srs.NewRow( outrow ) ) break;
      }
    }
    srs.EndTable();
  }
Exemple #11
0
 public void Assign(int outputId, IdSet partyIds)
 {
     _partyIds[outputId] = partyIds;
 }
Exemple #12
0
  public Select( G.List<Exp> exps, TableExpression te, Exp where, Exp[] group, OrderByExp[] order, bool [] used, SqlExec x )
  {
    /* There is more work to be done here, for example 2 * SUM(Total) is currently not allowed.
       Also if there is a GROUP BY, SELECT expressions should not be allowed to access fields not in the group list,
       unless thereis an enclosing aggregate function.
       Also maybe common sub-expression analysis, and perhaps constant folding, could be done?
    */ 

    Exps = exps; TE = te; Where = where; Order = order; 

    ColumnCount = exps.Count; 
    var names = new string[ ColumnCount ];
    var types = new DataType[ ColumnCount ];
    for ( int i = 0; i < ColumnCount; i += 1 )
    {
      names[ i ] = exps[ i ].Name;
      types[ i ] = exps[ i ].Type;
    }
    CI = new ColInfo( names, types );

    if ( x.ParseOnly ) return;

    Used = Util.ToList( used );

    if ( group != null )
    {
      // Compute AggSpec and GroupSpec
      var alist = new G.List<AggSpec>();
      for ( int i = 0; i < exps.Count; i += 1 )
      {
        Exp e = exps[ i ];
        AggOp op = e.GetAggOp();
        if ( op != AggOp.None )
        {
          AggSpec a = new AggSpec();
          a.ColIx = i;
          a.Type = e.Type;
          a.Op = op;
          alist.Add( a );
        }
      }
      AggSpec = alist.ToArray();

      var glist = new G.List<GroupSpec>();
      for ( int i=0; i < group.Length; i += 1 )
      {
        GroupSpec g = new GroupSpec();
        g.ColIx = Exps.Count;
        g.Type = group[ i ].Type;
        Exps.Add( group[ i ] );
        glist.Add( g );
      }
      GroupSpec = glist.ToArray();
    }

    if ( Order != null )
    {
      var sortSpec = new SortSpec[ Order.Length ]; 

      for ( int i = 0; i < Order.Length; i += 1 )
      {
        // Quite complicated as ORDER BY can use aliases or expressions.
        Exp e = Order[ i ].E;
        sortSpec[ i ].Desc = Order[ i ].Desc;

        int cix = -1;
        if ( e is ExpName )
        {
          string alias = ((ExpName)e).ColName;   
          for ( int j = 0; j < CI.Count; j += 1 )
          {
            if ( CI.Name[j] == alias )
            {
              e = Exps[ j ];
              cix = j;
              break;
            }
          }
        }
        if ( cix < 0 )
        {
          cix = Exps.Count;
          Exps.Add( e );
          e.Bind( x );   
        }     
        sortSpec[ i ].Type = e.Type;
        sortSpec[ i ].ColIx = cix;       
      }
      SortSpec = sortSpec;
    }

    Dvs = Util.GetDVList( Exps.ToArray() );

    if ( Where != null ) WhereD = Where.GetDB();

    Ids = Where == null ? null : Where.GetIdSet( TE );
    if ( Ids != null ) Ids = new IdCopy( Ids ); // Need to take a copy of the id values if an index is used.
  }
Exemple #13
0
 public GestionarCategoriasAction()
 {
     name  = "Gestionar Categorías";
     idSet = new IdSet();
 }
Exemple #14
0
 protected override void InitializeNewItemData(IStoreSession session, IFolder folder, HierarchySyncMetadataItem newMetadataItem)
 {
     if (folder != null)
     {
         bool flag = false;
         HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <VersionedId>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Getting UserConfiguration from folder {0}", folder.Id);
         using (UserConfiguration configuration = UserConfiguration.GetConfiguration(folder as Folder, new UserConfigurationName("PublicFolderSyncInfo", ConfigurationNameKind.Name), UserConfigurationTypes.Dictionary))
         {
             IDictionary dictionary = configuration.GetDictionary();
             ExDateTime  exDateTime;
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <ExDateTime>(dictionary, "FirstFailedSyncTimeAfterLastSuccess", out exDateTime))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <ExDateTime>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found FirstFailedSyncTimeAfterLastSuccess in UserConfiguration. Value {0}", exDateTime);
                 newMetadataItem.FirstFailedSyncTimeAfterLastSuccess = exDateTime;
                 flag = true;
             }
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <ExDateTime>(dictionary, "LastAttemptedSyncTime", out exDateTime))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <ExDateTime>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found LastAttemptedSyncTime in UserConfiguration. Value {0}", exDateTime);
                 newMetadataItem.LastAttemptedSyncTime = exDateTime;
                 flag = true;
             }
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <ExDateTime>(dictionary, "LastFailedSyncTime", out exDateTime))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <ExDateTime>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found LastFailedSyncTime in UserConfiguration. Value {0}", exDateTime);
                 newMetadataItem.LastFailedSyncTime = exDateTime;
                 flag = true;
             }
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <ExDateTime>(dictionary, "LastSuccessfulSyncTime", out exDateTime))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <ExDateTime>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found LastSuccessfulSyncTime in UserConfiguration. Value {0}", exDateTime);
                 newMetadataItem.LastSuccessfulSyncTime = exDateTime;
                 flag = true;
             }
             int num;
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <int>(dictionary, "NumberofAttemptsAfterLastSuccess", out num))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <int>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found NumberOfAttemptsAfterLastSuccess in UserConfiguration. Value {0}", num);
                 newMetadataItem.NumberOfAttemptsAfterLastSuccess = num;
                 flag = true;
             }
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <int>(dictionary, "NumberOfBatchesExecuted", out num))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <int>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found NumberOfBatchesExecuted in UserConfiguration. Value {0}", num);
                 newMetadataItem.NumberOfBatchesExecuted = num;
                 flag = true;
             }
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <int>(dictionary, "NumberOfFoldersSynced", out num))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <int>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found NumberOfFoldersSynced in UserConfiguration. Value {0}", num);
                 newMetadataItem.NumberOfFoldersSynced = num;
                 flag = true;
             }
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <int>(dictionary, "NumberOfFoldersToBeSynced", out num))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <int>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found NumberOfFoldersToBeSynced in UserConfiguration. Value {0}", num);
                 newMetadataItem.NumberOfFoldersToBeSynced = num;
                 flag = true;
             }
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <int>(dictionary, "BatchSize", out num))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <int>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found BatchSize in UserConfiguration. Value {0}", num);
                 newMetadataItem.BatchSize = num;
                 flag = true;
             }
             string text;
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <string>(dictionary, "LastSyncFailure", out text))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <string>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found LastSyncFailure in UserConfiguration. Value {0}", text);
                 newMetadataItem.LastSyncFailure = text;
                 flag = true;
             }
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <string>(dictionary, "SyncState", out text) && !string.IsNullOrWhiteSpace(text))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <string>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found SyncState in UserConfiguration. Value {0}", text);
                 using (Stream syncStateOverrideStream = newMetadataItem.GetSyncStateOverrideStream())
                 {
                     HierarchySyncMetadataItemHandler.CopyStringToMetadataAttachment(text, syncStateOverrideStream);
                     flag = true;
                 }
             }
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <string>(dictionary, "FinalJobSyncState", out text) && !string.IsNullOrWhiteSpace(text))
             {
                 HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <string>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found FinalJobSyncState in UserConfiguration. Value {0}", text);
                 using (Stream finalJobSyncStateWriteStream = newMetadataItem.GetFinalJobSyncStateWriteStream(true))
                 {
                     HierarchySyncMetadataItemHandler.CopyStringToMetadataAttachment(text, finalJobSyncStateWriteStream);
                     flag = true;
                 }
             }
             byte[] array;
             if (HierarchySyncMetadataItemHandler.TryGetLegacyMetadataValue <byte[]>(dictionary, "PartiallyCommittedFolderIds", out array))
             {
                 if (HierarchySyncMetadataItemHandler.PublicFolderTracer.IsTraceEnabled(TraceType.DebugTrace))
                 {
                     HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug <string>((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Found PartiallyCommittedFolderIds in UserConfiguration. Value {0}", Convert.ToBase64String(array));
                 }
                 using (Reader reader = Reader.CreateBufferReader(array))
                 {
                     newMetadataItem.SetPartiallyCommittedFolderIds(IdSet.ParseWithReplGuids(reader));
                     flag = true;
                 }
             }
         }
         if (flag)
         {
             HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Metadata Item was updated. Saving and reloading properties.");
             newMetadataItem.Save(SaveMode.FailOnAnyConflict);
             newMetadataItem.Load();
             return;
         }
     }
     else
     {
         HierarchySyncMetadataItemHandler.PublicFolderTracer.TraceDebug((long)this.GetHashCode(), "HierarchySyncMetadataItemHandler:InitializeNewItemData - Skipping import from UserConfiguration as no folder was provided.");
     }
 }
Exemple #15
0
 public OutputPrimitiveDeclaration(PrimitiveConverter converter, IdSet partyIds)
 {
     Converter = converter;
     PartyIds  = partyIds;
 }
Exemple #16
0
  public override G.IEnumerable<bool> GetAll( Value[] final, bool [] used, EvalEnv e )
  {
    Value[] tr = new Value[ TE.Cols.Count ];
    EvalEnv ee = new EvalEnv( e.Locals, tr, e.ResultSet );

    IdSet idSet = Where == null ? null : Where.GetIdSet( TE, ee );
    if ( idSet != null ) idSet = new IdCopy( idSet, ee ); // Need to take a copy of the id values if an index is used.

    StoredResultSet srs = Order == null ? null : new Sorter( null, SortSpec );
    srs = GroupSpec == null ? srs : new Grouper( srs, GroupSpec, AggSpec );

    Value [] outrow = srs != null ? new Value[ Exps.Count ] : null;

    if ( srs == null )
    {
      if ( idSet != null ) 
      {
        foreach ( long id in idSet.All( ee ) ) if ( TE.Get( id, tr, Used ) )
        {
          if ( Where == null || ( Where.Eval( ee ).B ) )
          {
            for ( int i = 0; i < final.Length; i += 1 ) final[ i ] = Exps[ i ].Eval( ee );  
            yield return true;
          }
        }
      }
      else 
      {
        foreach ( bool ok in TE.GetAll( tr, Used, ee ) )
        if ( Where == null || ( Where.Eval( ee ).B ) )
        {
          for ( int i = 0; i < final.Length; i += 1 ) final[ i ] = Exps[ i ].Eval( ee );  
          yield return true;
        }
      }
    }
    else
    {
      if ( idSet != null ) 
      {
        foreach ( long id in idSet.All( ee ) ) if ( TE.Get( id, tr, Used ) )
        {
          if ( Where == null || Where.Eval( ee ).B )
          {
            for ( int i = 0; i < Exps.Count; i += 1 ) outrow[ i ] = Exps[ i ].Eval( ee );  
            srs.NewRow( outrow ); 
          }
        }
      }
      else 
      {
        foreach ( bool ok in TE.GetAll( tr, Used, ee ) )
        if ( Where == null || Where.Eval( ee ).B )
        {
          for ( int i = 0; i < Exps.Count; i += 1 ) outrow[ i ] = Exps[ i ].Eval( ee );  
          srs.NewRow( outrow ); 
        }
      }
      foreach( bool b in srs.GetAll( final ) ) yield return true;
    }
  }