Ejemplo n.º 1
0
 public void RemoveResourceSecurityInformation(string cluster, string resource)
 {
     lock (_store)
     {
         //JsonSerializer<IResourceItem> serializer = new JsonSerializer<IResourceItem>();
         ICollectionStore      collection    = ((SystemDatabaseStore)_store).Collections[Alachisoft.NosDB.Core.Util.MiscUtil.SystemCollection.SecurityInformationCollection];
         IList <IJSONDocument> jsonDocuments = new List <IJSONDocument>();
         JSONDocument          doc           = new JSONDocument();
         bool found = false;
         if (resource != null)
         {
             doc.Key = resource;
             found   = FindDocument(resource, Alachisoft.NosDB.Core.Util.MiscUtil.SystemCollection.SecurityInformationCollection, out doc);
             if (found)
             {
                 IDocumentsWriteOperation deleteOperation = new DeleteDocumentsOperation();
                 deleteOperation.Collection = Alachisoft.NosDB.Core.Util.MiscUtil.SystemCollection.SecurityInformationCollection;
                 deleteOperation.Database   = MiscUtil.SYSTEM_DATABASE;
                 jsonDocuments.Add(doc);
                 deleteOperation.Documents = jsonDocuments;
                 _store.DeleteDocuments(deleteOperation);
             }
         }
     }
 }
Ejemplo n.º 2
0
        internal List<FailedDocument> DeleteDocuments(ICollection<string> documentKeys, bool noResponse)
        {
           
            List<JSONDocument> documents = new List<JSONDocument>();
            foreach (string documentKey in documentKeys)
            {
                if (documentKey != null)
                {
                    JSONDocument jdoc = new JSONDocument();
                    jdoc.Key = documentKey;
                    documents.Add(jdoc);
                }
                //else
                //    throw new ArgumentException("Document key cannot be an empty string or null");
            }

            DeleteDocumentsOperation deleteDocumentsOperation = new DeleteDocumentsOperation();
            deleteDocumentsOperation.Documents = documents.Cast<IJSONDocument>().ToList();
            deleteDocumentsOperation.Database = _database.DatabaseName;
            deleteDocumentsOperation.Collection = _collectionName;
            deleteDocumentsOperation.NoResponse = noResponse;

            DeleteDocumentsResponse deleteDocumentsResponse = (DeleteDocumentsResponse)_database.ExecutionMapper.DeleteDocuments(deleteDocumentsOperation);

            if (!deleteDocumentsResponse.IsSuccessfull)
            {
                if (deleteDocumentsResponse.FailedDocumentsList == null || deleteDocumentsResponse.FailedDocumentsList.Count == 0)
                {
                    throw new DataException(ErrorMessages.GetErrorMessage(deleteDocumentsResponse.ErrorCode, deleteDocumentsResponse.ErrorParams));
                }
                return deleteDocumentsResponse.FailedDocumentsList;
            }
            return new List<FailedDocument>();
        }
Ejemplo n.º 3
0
 public void RemoveUserInformation(string username)
 {
     lock (_store)
     {
         ICollectionStore      collection    = ((SystemDatabaseStore)_store).Collections[Alachisoft.NosDB.Core.Util.MiscUtil.SystemCollection.UserInformationCollection];
         IList <IJSONDocument> jsonDocuments = new List <IJSONDocument>();
         JSONDocument          doc           = new JSONDocument();
         bool found = false;
         if (username != null)
         {
             doc.Key = username;
             found   = FindDocument(username, Alachisoft.NosDB.Core.Util.MiscUtil.SystemCollection.UserInformationCollection, out doc);
             if (found)
             {
                 IDocumentsWriteOperation deleteOperation = new DeleteDocumentsOperation();
                 deleteOperation.Collection = Alachisoft.NosDB.Core.Util.MiscUtil.SystemCollection.UserInformationCollection;
                 deleteOperation.Database   = MiscUtil.SYSTEM_DATABASE;
                 jsonDocuments.Add(doc);
                 deleteOperation.Documents = jsonDocuments;
                 _store.DeleteDocuments(deleteOperation);
             }
         }
     }
 }