Ejemplo n.º 1
0
        private void IFetchNodeRefs()
        {
            pnCli2Vault_FetchNodeRefs req = new pnCli2Vault_FetchNodeRefs();
            req.Read(fStream);

            // Go ahead and prepare the response in case anything terrible happens
            pnVault2Cli_NodeRefsFetched reply = new pnVault2Cli_NodeRefsFetched();
            reply.fResult = ENetError.kNetSuccess;
            reply.fTransID = req.fTransID;

            // Let's spider the tree now :)
            List<uint> toFetch = new List<uint>();
            List<pnVaultNodeRef> refs = new List<pnVaultNodeRef>();
            toFetch.Add(req.fNodeID);
            for (int i = 0; i < toFetch.Count; i++) {
                pnSqlSelectStatement select = new pnSqlSelectStatement();
                select.AddColumn("ChildIdx");
                select.AddColumn("SaverIdx");
                select.AddWhere("ParentIdx", toFetch[i]);
                select.Table = "NodeRefs";

                try {
                    IDataReader r = select.Execute(fDb);
                    while (r.Read()) {
                        pnVaultNodeRef vnr = new pnVaultNodeRef(toFetch[i], (uint)r["ChildIdx"], (uint)r["SaverIdx"]);
                        if (!toFetch.Contains(vnr.fChild))
                            toFetch.Add(vnr.fChild);
                        refs.Add(vnr);
                    }

                    r.Close();
                } catch (pnDbException e) {
                    Error(e, "Failed to fetch NodeRefs");
                    reply.fResult = ENetError.kNetErrInternalError;
                }
            }

            if (refs.Count == 0)
                // The vault node may actually exist, but it certainly has no children.
                // Maybe FIXME at some point?
                reply.fResult = ENetError.kNetErrVaultNodeNotFound;
            else if (reply.fResult == ENetError.kNetSuccess)
                reply.fNodeRefs = refs.ToArray();
            reply.Send(fStream);
        }
Ejemplo n.º 2
0
 public override void Read(hsStream s)
 {
     fTransID = s.ReadUInt();
     fResult = (ENetError)s.ReadInt();
     fNodeRefs = new pnVaultNodeRef[s.ReadInt()];
     for (int i = 0; i < fNodeRefs.Length; i++) {
         fNodeRefs[i] = new pnVaultNodeRef();
         fNodeRefs[i].Read(s);
     }
 }
Ejemplo n.º 3
0
 private void IOnNodeRefsFetched(ENetError result, pnVaultNodeRef[] refs, object param)
 {
     pnAuth2Cli_VaultNodeRefsFetched reply = new pnAuth2Cli_VaultNodeRefsFetched();
     reply.fNodeRefs = refs;
     reply.fResult = result;
     reply.fTransID = (uint)param;
     lock (fStream) reply.Send(fStream);
 }