Revision Manifest data element
Inheritance: DataElementData
        /// <summary>
        /// This method is used to create the revision manifest data element.
        /// </summary>
        /// <param name="rootObjectExGuid">Specify the root node object extended GUID.</param>
        /// <param name="baseRevisionID">Specify the base revision Id.</param>
        /// <param name="refferenceObjectDataExGuidList">Specify the reference object data extended list.</param>
        /// <param name="revisionMapping">Input/output parameter to represent the mapping of revision manifest.</param>
        /// <param name="currentRevisionID">Output parameter to represent the revision GUID.</param>
        /// <returns>Return the revision manifest data element.</returns>
        public static DataElement CreateRevisionManifestDataElement(ExGuid rootObjectExGuid, ExGuid baseRevisionID, List <ExGuid> refferenceObjectDataExGuidList, ref Dictionary <ExGuid, ExGuid> revisionMapping, out ExGuid currentRevisionID)
        {
            RevisionManifestDataElementData data = new RevisionManifestDataElementData();

            data.RevisionManifest.RevisionID     = new ExGuid(1u, Guid.NewGuid());
            data.RevisionManifest.BaseRevisionID = new ExGuid(baseRevisionID);

            // Set the root object data ExGuid
            data.RevisionManifestRootDeclareList.Add(new RevisionManifestRootDeclare()
            {
                RootExtendedGUID = new ExGuid(2u, RootExGuid), ObjectExtendedGUID = new ExGuid(rootObjectExGuid)
            });

            // Set all the reference object data
            if (refferenceObjectDataExGuidList != null)
            {
                foreach (ExGuid dataGuid in refferenceObjectDataExGuidList)
                {
                    data.RevisionManifestObjectGroupReferencesList.Add(new RevisionManifestObjectGroupReferences(dataGuid));
                }
            }

            DataElement dataElement = new DataElement(DataElementType.RevisionManifestDataElementData, data);

            revisionMapping.Add(data.RevisionManifest.RevisionID, dataElement.DataElementExtendedGUID);
            currentRevisionID = data.RevisionManifest.RevisionID;
            return(dataElement);
        }
Exemple #2
0
        private List <RevisionStoreObjectGroup> ParseObjectGroup(CellID objectGroupCellID, MSOneStorePackage package)
        {
            StorageIndexCellMapping         storageIndexCellMapping = package.FindStorageIndexCellMapping(objectGroupCellID);
            CellManifestDataElementData     cellManifest            = this.FindCellManifest(storageIndexCellMapping.CellMappingExtendedGUID);
            List <RevisionStoreObjectGroup> objectGroups            = new List <RevisionStoreObjectGroup>();

            package.CellManifests.Add(cellManifest);
            StorageIndexRevisionMapping revisionMapping =
                package.FindStorageIndexRevisionMapping(cellManifest.CellManifestCurrentRevision.CellManifestCurrentRevisionExtendedGUID);
            RevisionManifestDataElementData revisionManifest =
                this.FindRevisionManifestDataElement(revisionMapping.RevisionMappingExtendedGUID);

            package.RevisionManifests.Add(revisionManifest);
            RevisionManifestRootDeclare encryptionKeyRoot = revisionManifest.RevisionManifestRootDeclareList.Where(r => r.RootExtendedGUID.Equals(new ExGuid(3, Guid.Parse("4A3717F8-1C14-49E7-9526-81D942DE1741")))).SingleOrDefault();
            bool isEncryption = encryptionKeyRoot != null;

            foreach (RevisionManifestObjectGroupReferences objRef in revisionManifest.RevisionManifestObjectGroupReferencesList)
            {
                ObjectGroupDataElementData dataObject = objectGroupDataElements.Where(d => d.DataElementExtendedGUID.Equals(
                                                                                          objRef.ObjectGroupExtendedGUID)).Single().Data as ObjectGroupDataElementData;

                RevisionStoreObjectGroup objectGroup = RevisionStoreObjectGroup.CreateInstance(objRef.ObjectGroupExtendedGUID, dataObject, isEncryption);
                objectGroups.Add(objectGroup);
            }

            return(objectGroups);
        }
Exemple #3
0
        private HeaderCell ParseHeaderCell(RevisionManifestDataElementData headerCellRevisionManifest)
        {
            ExGuid      rootObjectId = headerCellRevisionManifest.RevisionManifestObjectGroupReferencesList[0].ObjectGroupExtendedGUID;
            DataElement element      = this.objectGroupDataElements
                                       .Where(d => d.DataElementExtendedGUID.Equals(rootObjectId)).SingleOrDefault();

            return(HeaderCell.CreateInstance((ObjectGroupDataElementData)element.Data));
        }
        /// <summary>
        /// This method is used to get the list of object group data element from a list of data element.
        /// </summary>
        /// <param name="dataElements">Specify the data element list.</param>
        /// <param name="storageIndexExGuid">Specify the storage index extended GUID.</param>
        /// <param name="rootExGuid">Output parameter to represent the root node object.</param>
        /// <returns>Return the list of object group data elements.</returns>
        public static List <ObjectGroupDataElementData> GetDataObjectDataElementData(List <DataElement> dataElements, ExGuid storageIndexExGuid, out ExGuid rootExGuid)
        {
            ExGuid manifestMappingGuid;
            Dictionary <CellID, ExGuid> cellIDMappings;
            Dictionary <ExGuid, ExGuid> revisionIDMappings;

            AnalyzeStorageIndexDataElement(dataElements, storageIndexExGuid, out manifestMappingGuid, out cellIDMappings, out revisionIDMappings);
            StorageManifestDataElementData manifestData = GetStorageManifestDataElementData(dataElements, manifestMappingGuid);

            if (manifestData == null)
            {
                throw new InvalidOperationException("Cannot find the storage manifest data element with ExGuid " + manifestMappingGuid.GUID.ToString());
            }

            CellManifestDataElementData     cellData     = GetCellManifestDataElementData(dataElements, manifestData, cellIDMappings);
            RevisionManifestDataElementData revisionData = GetRevisionManifestDataElementData(dataElements, cellData, revisionIDMappings);

            return(GetDataObjectDataElementData(dataElements, revisionData, out rootExGuid));
        }
        /// <summary>
        /// This method is used to create the revision manifest data element.
        /// </summary>
        /// <param name="rootObjectExGuid">Specify the root node object extended GUID.</param>
        /// <param name="baseRevisionID">Specify the base revision Id.</param>
        /// <param name="refferenceObjectDataExGuidList">Specify the reference object data extended list.</param>
        /// <param name="revisionMapping">Input/output parameter to represent the mapping of revision manifest.</param>
        /// <param name="currentRevisionID">Output parameter to represent the revision GUID.</param>
        /// <returns>Return the revision manifest data element.</returns>
        public static DataElement CreateRevisionManifestDataElement(ExGuid rootObjectExGuid, ExGuid baseRevisionID, List<ExGuid> refferenceObjectDataExGuidList, ref Dictionary<ExGuid, ExGuid> revisionMapping, out ExGuid currentRevisionID)
        {
            RevisionManifestDataElementData data = new RevisionManifestDataElementData();
            data.RevisionManifest.RevisionID = new ExGuid(1u, Guid.NewGuid());
            data.RevisionManifest.BaseRevisionID = new ExGuid(baseRevisionID);

            // Set the root object data ExGuid
            data.RevisionManifestRootDeclareList.Add(new RevisionManifestRootDeclare() { RootExtendedGUID = new ExGuid(2u, RootExGuid), ObjectExtendedGUID = new ExGuid(rootObjectExGuid) });

            // Set all the reference object data
            if (refferenceObjectDataExGuidList != null)
            {
                foreach (ExGuid dataGuid in refferenceObjectDataExGuidList)
                {
                    data.RevisionManifestObjectGroupReferencesList.Add(new RevisionManifestObjectGroupReferences(dataGuid));
                }
            }

            DataElement dataElement = new DataElement(DataElementType.RevisionManifestDataElementData, data);
            revisionMapping.Add(data.RevisionManifest.RevisionID, dataElement.DataElementExtendedGUID);
            currentRevisionID = data.RevisionManifest.RevisionID;
            return dataElement;
        }
        /// <summary>
        /// This method is used to get a list of object group data element from a list of data element.
        /// </summary>
        /// <param name="dataElements">Specify the data element list.</param>
        /// <param name="revisionData">Specify the revision data.</param>
        /// <param name="rootExGuid">Specify the root node object extended GUID.</param>
        /// <returns>Return the list of object group data element.</returns>
        public static List<ObjectGroupDataElementData> GetDataObjectDataElementData(List<DataElement> dataElements, RevisionManifestDataElementData revisionData, out ExGuid rootExGuid)
        {
            rootExGuid = null;

            foreach (RevisionManifestRootDeclare kv in revisionData.RevisionManifestRootDeclareList)
            {
                if (kv.RootExtendedGUID.Equals(new ExGuid(2u, RootExGuid)))
                {
                    rootExGuid = kv.ObjectExtendedGUID;
                    break;
                }
            }

            List<ObjectGroupDataElementData> dataList = new List<ObjectGroupDataElementData>();

            foreach (RevisionManifestObjectGroupReferences kv in revisionData.RevisionManifestObjectGroupReferencesList)
            {
                DataElement dataElement = dataElements.Find(element => element.DataElementExtendedGUID.Equals(kv.ObjectGroupExtendedGUID));
                if (dataElement == null)
                {
                    throw new InvalidOperationException("Cannot find the object group data element with ExGuid " + kv.ObjectGroupExtendedGUID.GUID.ToString());
                }

                dataList.Add(dataElement.GetData<ObjectGroupDataElementData>());
            }

            return dataList;
        }
        /// <summary>
        /// This method is used to get a list of object group data element from a list of data element.
        /// </summary>
        /// <param name="dataElements">Specify the data element list.</param>
        /// <param name="revisionData">Specify the revision data.</param>
        /// <param name="rootExGuid">Specify the root node object extended GUID.</param>
        /// <returns>Return the list of object group data element.</returns>
        public static List <ObjectGroupDataElementData> GetDataObjectDataElementData(List <DataElement> dataElements, RevisionManifestDataElementData revisionData, out ExGuid rootExGuid)
        {
            rootExGuid = null;

            foreach (RevisionManifestRootDeclare kv in revisionData.RevisionManifestRootDeclareList)
            {
                if (kv.RootExtendedGUID.Equals(new ExGuid(2u, RootExGuid)))
                {
                    rootExGuid = kv.ObjectExtendedGUID;
                    break;
                }
            }

            List <ObjectGroupDataElementData> dataList = new List <ObjectGroupDataElementData>();

            foreach (RevisionManifestObjectGroupReferences kv in revisionData.RevisionManifestObjectGroupReferencesList)
            {
                DataElement dataElement = dataElements.Find(element => element.DataElementExtendedGUID.Equals(kv.ObjectGroupExtendedGUID));
                if (dataElement == null)
                {
                    throw new InvalidOperationException("Cannot find the object group data element with ExGuid " + kv.ObjectGroupExtendedGUID.GUID.ToString());
                }

                dataList.Add(dataElement.GetData <ObjectGroupDataElementData>());
            }

            return(dataList);
        }
        /// <summary>
        /// This method is used to try to analyze the returned whether data elements are complete.
        /// </summary>
        /// <param name="dataElements">Specify the data elements list.</param>
        /// <param name="storageIndexExGuid">Specify the storage index extended GUID.</param>
        /// <returns>If the data elements start with the specified storage index extended GUID are complete, return true. Otherwise return false.</returns>
        public static bool TryAnalyzeWhetherFullDataElementList(List <DataElement> dataElements, ExGuid storageIndexExGuid)
        {
            ExGuid manifestMappingGuid;
            Dictionary <CellID, ExGuid> cellIDMappings;
            Dictionary <ExGuid, ExGuid> revisionIDMappings;

            if (!AnalyzeStorageIndexDataElement(dataElements, storageIndexExGuid, out manifestMappingGuid, out cellIDMappings, out revisionIDMappings))
            {
                return(false);
            }

            if (cellIDMappings.Count == 0)
            {
                return(false);
            }

            if (revisionIDMappings.Count == 0)
            {
                return(false);
            }

            StorageManifestDataElementData manifestData = GetStorageManifestDataElementData(dataElements, manifestMappingGuid);

            if (manifestData == null)
            {
                return(false);
            }

            foreach (StorageManifestRootDeclare kv in manifestData.StorageManifestRootDeclareList)
            {
                if (!cellIDMappings.ContainsKey(kv.CellID))
                {
                    throw new InvalidOperationException(string.Format("Cannot fin the Cell ID {0} in the cell id mapping", kv.CellID.ToString()));
                }

                ExGuid      cellMappingID = cellIDMappings[kv.CellID];
                DataElement dataElement   = dataElements.Find(element => element.DataElementExtendedGUID.Equals(cellMappingID));
                if (dataElement == null)
                {
                    return(false);
                }

                CellManifestDataElementData cellData = dataElement.GetData <CellManifestDataElementData>();
                ExGuid currentRevisionExGuid         = cellData.CellManifestCurrentRevision.CellManifestCurrentRevisionExtendedGUID;
                if (!revisionIDMappings.ContainsKey(currentRevisionExGuid))
                {
                    throw new InvalidOperationException(string.Format("Cannot find the revision id {0} in the revisionMapping", currentRevisionExGuid.ToString()));
                }

                ExGuid revisionMapping = revisionIDMappings[currentRevisionExGuid];
                dataElement = dataElements.Find(element => element.DataElementExtendedGUID.Equals(revisionMapping));
                if (dataElement == null)
                {
                    return(false);
                }

                RevisionManifestDataElementData revisionData = dataElement.GetData <RevisionManifestDataElementData>();
                foreach (RevisionManifestObjectGroupReferences reference in revisionData.RevisionManifestObjectGroupReferencesList)
                {
                    dataElement = dataElements.Find(element => element.DataElementExtendedGUID.Equals(reference.ObjectGroupExtendedGUID));
                    if (dataElement == null)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }