コード例 #1
0
        /// <summary>
        /// This method is used to get revision manifest data element from a list of data element.
        /// </summary>
        /// <param name="dataElements">Specify the data element list.</param>
        /// <param name="cellData">Specify the cell data element.</param>
        /// <param name="revisionIDMappings">Specify mapping of revision id.</param>
        /// <returns>Return the revision manifest data element.</returns>
        public static RevisionManifestDataElementData GetRevisionManifestDataElementData(List <DataElement> dataElements, CellManifestDataElementData cellData, Dictionary <ExGuid, ExGuid> revisionIDMappings)
        {
            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 dataElement = dataElements.Find(element => element.DataElementExtendedGUID.Equals(revisionMapping));

            if (dataElement == null)
            {
                throw new InvalidOperationException("Cannot find the revision data element with ExGuid " + revisionMapping.GUID.ToString());
            }

            return(dataElement.GetData <RevisionManifestDataElementData>());
        }
コード例 #2
0
        /// <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);
        }