Object Group data element
Inheritance: DataElementData
Beispiel #1
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);
        }
Beispiel #2
0
        /// <summary>
        /// Get EditorsTable from server response.
        /// </summary>
        /// <param name="subResponse">The sub response from server.</param>
        /// <param name="site">Transfer ITestSite into this operation, for this operation to use ITestSite's function.</param>
        /// <returns>The instance of EditorsTable.</returns>
        public static EditorsTable GetEditorsTableFromResponse(FsshttpbResponse subResponse, ITestSite site)
        {
            if (subResponse == null || subResponse.DataElementPackage == null || subResponse.DataElementPackage.DataElements == null)
            {
                site.Assert.Fail("The parameter CellResponse is not valid, check whether the CellResponse::DataElementPackage or CellResponse::DataElementPackage::DataElements is null.");
            }

            foreach (DataElement de in subResponse.DataElementPackage.DataElements)
            {
                if (de.Data.GetType() == typeof(ObjectGroupDataElementData))
                {
                    ObjectGroupDataElementData ogde = de.Data as ObjectGroupDataElementData;

                    if (ogde.ObjectGroupData == null || ogde.ObjectGroupData.ObjectGroupObjectDataList.Count == 0)
                    {
                        continue;
                    }

                    for (int i = 0; i < ogde.ObjectGroupData.ObjectGroupObjectDataList.Count; i++)
                    {
                        if (IsEditorsTableHeader(ogde.ObjectGroupData.ObjectGroupObjectDataList[i].Data.Content.ToArray()))
                        {
                            string editorsTableXml = null;

                            // If the current object group object data is the header byte array 0x1a, 0x5a, 0x3a, 0x30, 0, 0, 0, 0, then the immediate following object group object data will contain the Editor table xml.
                            byte[] buffer             = ogde.ObjectGroupData.ObjectGroupObjectDataList[i + 1].Data.Content.ToArray();
                            System.IO.MemoryStream ms = null;
                            try
                            {
                                ms = new System.IO.MemoryStream();
                                ms.Write(buffer, 0, buffer.Length);
                                ms.Position = 0;
                                using (DeflateStream stream = new DeflateStream(ms, CompressionMode.Decompress))
                                {
                                    stream.Flush();
                                    byte[] decompressBuffer = new byte[buffer.Length * 3];
                                    stream.Read(decompressBuffer, 0, buffer.Length * 3);
                                    stream.Close();
                                    editorsTableXml = System.Text.Encoding.UTF8.GetString(decompressBuffer);
                                }

                                ms.Close();
                            }
                            finally
                            {
                                if (ms != null)
                                {
                                    ms.Dispose();
                                }
                            }

                            return(GetEditorsTable(editorsTableXml));
                        }
                    }
                }
            }

            throw new InvalidOperationException("Cannot find any data group object data contain editor tables information.");
        }
        /// <summary>
        /// Create the instacne of Header Cell.
        /// </summary>
        /// <param name="objectElement">The instance of ObjectGroupDataElementData.</param>
        /// <returns>Returns the instacne of HeaderCell.</returns>
        public static HeaderCell CreateInstance(ObjectGroupDataElementData objectElement)
        {
            HeaderCell instance = new HeaderCell();

            instance.ObjectDeclaration = objectElement.ObjectGroupDeclarations.ObjectDeclarationList[0];
            ObjectGroupObjectData objectData = objectElement.ObjectGroupData.ObjectGroupObjectDataList[0];

            instance.ObjectData = new ObjectSpaceObjectPropSet();
            instance.ObjectData.DoDeserializeFromByteArray(objectData.Data.Content.ToArray(), 0);

            return(instance);
        }
            /// <summary>
            /// This method is used to travel the node tree and build the ObjectGroupDataElementData and the extra data element list.
            /// </summary>
            /// <param name="node">Specify the object node.</param>
            /// <param name="dataElements">Specify the list of data elements.</param>
            private void TravelNodeObject(NodeObject node, ref List <DataElement> dataElements)
            {
                if (node is IntermediateNodeObject)
                {
                    ObjectGroupDataElementData data = new ObjectGroupDataElementData();
                    data.ObjectGroupDeclarations.ObjectDeclarationList.Add(this.CreateObjectDeclare(node));
                    data.ObjectGroupData.ObjectGroupObjectDataList.Add(this.CreateObjectData(node as IntermediateNodeObject));

                    dataElements.Add(new DataElement(DataElementType.ObjectGroupDataElementData, data));

                    foreach (LeafNodeObject child in (node as IntermediateNodeObject).IntermediateNodeObjectList)
                    {
                        this.TravelNodeObject(child, ref dataElements);
                    }
                }
                else if (node is LeafNodeObject)
                {
                    LeafNodeObject intermediateNode = node as LeafNodeObject;

                    ObjectGroupDataElementData data = new ObjectGroupDataElementData();
                    data.ObjectGroupDeclarations.ObjectDeclarationList.Add(this.CreateObjectDeclare(node));
                    data.ObjectGroupData.ObjectGroupObjectDataList.Add(this.CreateObjectData(intermediateNode));

                    if (intermediateNode.DataNodeObjectData != null)
                    {
                        data.ObjectGroupDeclarations.ObjectDeclarationList.Add(this.CreateObjectDeclare(intermediateNode.DataNodeObjectData));
                        data.ObjectGroupData.ObjectGroupObjectDataList.Add(this.CreateObjectData(intermediateNode.DataNodeObjectData));
                        dataElements.Add(new DataElement(DataElementType.ObjectGroupDataElementData, data));
                        return;
                    }

                    if (intermediateNode.DataNodeObjectData == null && intermediateNode.IntermediateNodeObjectList != null)
                    {
                        dataElements.Add(new DataElement(DataElementType.ObjectGroupDataElementData, data));

                        foreach (LeafNodeObject child in intermediateNode.IntermediateNodeObjectList)
                        {
                            this.TravelNodeObject(child, ref dataElements);
                        }

                        return;
                    }

                    throw new System.InvalidOperationException("The DataNodeObjectData and IntermediateNodeObjectList properties in LeafNodeObjectData type cannot be null in the same time.");
                }
            }
            /// <summary>
            /// This method is used to travel the node tree and build the ObjectGroupDataElementData and the extra data element list.
            /// </summary>
            /// <param name="node">Specify the object node.</param>
            /// <param name="dataElements">Specify the list of data elements.</param>
            private void TravelNodeObject(NodeObject node, ref List<DataElement> dataElements)
            {
                if (node is RootNodeObject)
                {
                    ObjectGroupDataElementData data = new ObjectGroupDataElementData();
                    data.ObjectGroupDeclarations.ObjectDeclarationList.Add(this.CreateObjectDeclare(node));
                    data.ObjectGroupData.ObjectGroupObjectDataList.Add(this.CreateObjectData(node as RootNodeObject));

                    dataElements.Add(new DataElement(DataElementType.ObjectGroupDataElementData, data));

                    foreach (IntermediateNodeObject child in (node as RootNodeObject).IntermediateNodeObjectList)
                    {
                        this.TravelNodeObject(child, ref dataElements);
                    }
                }
                else if (node is IntermediateNodeObject)
                {
                    IntermediateNodeObject intermediateNode = node as IntermediateNodeObject;

                    ObjectGroupDataElementData data = new ObjectGroupDataElementData();
                    data.ObjectGroupDeclarations.ObjectDeclarationList.Add(this.CreateObjectDeclare(node));
                    data.ObjectGroupData.ObjectGroupObjectDataList.Add(this.CreateObjectData(intermediateNode));

                    if (intermediateNode.DataNodeObjectData != null)
                    {
                        data.ObjectGroupDeclarations.ObjectDeclarationList.Add(this.CreateObjectDeclare(intermediateNode.DataNodeObjectData));
                        data.ObjectGroupData.ObjectGroupObjectDataList.Add(this.CreateObjectData(intermediateNode.DataNodeObjectData));
                        dataElements.Add(new DataElement(DataElementType.ObjectGroupDataElementData, data));
                        return;
                    }

                    if (intermediateNode.DataNodeObjectData == null && intermediateNode.IntermediateNodeObjectList != null)
                    {
                        dataElements.Add(new DataElement(DataElementType.ObjectGroupDataElementData, data));

                        foreach (IntermediateNodeObject child in intermediateNode.IntermediateNodeObjectList)
                        {
                            this.TravelNodeObject(child, ref dataElements);
                        }

                        return;
                    }
                   
                    throw new System.InvalidOperationException("The DataNodeObjectData and IntermediateNodeObjectList properties in IntermediateNodeObject type cannot be null in the same time.");
                }
            }
        public static RevisionStoreObjectGroup CreateInstance(ExGuid objectGroupId, ObjectGroupDataElementData dataObject, bool isEncryption)
        {
            RevisionStoreObjectGroup objectGroup = new RevisionStoreObjectGroup(objectGroupId);
            Dictionary <ExGuid, RevisionStoreObject> objectDict = new Dictionary <ExGuid, RevisionStoreObject>();

            if (isEncryption == false)
            {
                RevisionStoreObject revisionObject = null;
                for (int i = 0; i < dataObject.ObjectGroupDeclarations.ObjectDeclarationList.Count; i++)
                {
                    ObjectGroupObjectDeclare objectDeclaration = dataObject.ObjectGroupDeclarations.ObjectDeclarationList[i];
                    ObjectGroupObjectData    objectData        = dataObject.ObjectGroupData.ObjectGroupObjectDataList[i];

                    if (!objectDict.ContainsKey(objectDeclaration.ObjectExtendedGUID))
                    {
                        revisionObject = new RevisionStoreObject();
                        revisionObject.ObjectGroupID = objectGroupId;
                        revisionObject.ObjectID      = objectDeclaration.ObjectExtendedGUID;
                        objectDict.Add(objectDeclaration.ObjectExtendedGUID, revisionObject);
                    }
                    else
                    {
                        revisionObject = objectDict[objectDeclaration.ObjectExtendedGUID];
                    }
                    if (objectDeclaration.ObjectPartitionID.DecodedValue == 4)
                    {
                        revisionObject.JCID = new JCIDObject(objectDeclaration, objectData);
                    }
                    else if (objectDeclaration.ObjectPartitionID.DecodedValue == 1)
                    {
                        revisionObject.PropertySet = new PropertySetObject(objectDeclaration, objectData);
                        if (Convert.ToBoolean(revisionObject.JCID.JCID.IsFileData) == false)
                        {
                            revisionObject.ReferencedObjectID       = objectData.ObjectExGUIDArray;
                            revisionObject.ReferencedObjectSpacesID = objectData.CellIDArray;
                        }
                    }
                }

                for (int i = 0; i < dataObject.ObjectGroupDeclarations.ObjectGroupObjectBLOBDataDeclarationList.Count; i++)
                {
                    ObjectGroupObjectBLOBDataDeclaration objectGroupObjectBLOBDataDeclaration = dataObject.ObjectGroupDeclarations.ObjectGroupObjectBLOBDataDeclarationList[i];
                    ObjectGroupObjectDataBLOBReference   objectGroupObjectDataBLOBReference   = dataObject.ObjectGroupData.ObjectGroupObjectDataBLOBReferenceList[i];
                    if (!objectDict.ContainsKey(objectGroupObjectBLOBDataDeclaration.ObjectExGUID))
                    {
                        revisionObject = new RevisionStoreObject();
                        objectDict.Add(objectGroupObjectBLOBDataDeclaration.ObjectExGUID, revisionObject);
                    }
                    else
                    {
                        revisionObject = objectDict[objectGroupObjectBLOBDataDeclaration.ObjectExGUID];
                    }
                    if (objectGroupObjectBLOBDataDeclaration.ObjectPartitionID.DecodedValue == 2)
                    {
                        revisionObject.FileDataObject = new FileDataObject();
                        revisionObject.FileDataObject.ObjectDataBLOBDeclaration = objectGroupObjectBLOBDataDeclaration;
                        revisionObject.FileDataObject.ObjectDataBLOBReference   = objectGroupObjectDataBLOBReference;
                    }
                }
                objectGroup.Objects.AddRange(objectDict.Values.ToArray());
            }
            else
            {
                for (int i = 0; i < dataObject.ObjectGroupDeclarations.ObjectDeclarationList.Count; i++)
                {
                    ObjectGroupObjectDeclare objectDeclaration = dataObject.ObjectGroupDeclarations.ObjectDeclarationList[i];
                    ObjectGroupObjectData    objectData        = dataObject.ObjectGroupData.ObjectGroupObjectDataList[i];

                    if (objectDeclaration.ObjectPartitionID.DecodedValue == 1)
                    {
                        EncryptionObject encrypObject = new EncryptionObject();
                        encrypObject.ObjectDeclaration = objectDeclaration;
                        encrypObject.ObjectData        = objectData.Data.Content.ToArray();
                        objectGroup.EncryptionObjects.Add(encrypObject);
                    }
                }
            }

            return(objectGroup);
        }