Exemple #1
0
        private void SerializeChangeMap(MgBinarySerializer s)
        {
            s.Write(m_changeList.Count);
            foreach (ChangeList cl in m_changeList.Values)
            {
                s.Write(cl.IsLayer);
                s.Write(cl.ObjectId);

                s.Write(cl.Changes.Count);
                foreach (Change c in cl.Changes)
                {
                    s.Write((int)c.Type);
                    s.Write(c.Params);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Serializes this instance to a binary stream
        /// </summary>
        /// <param name="s"></param>
        public virtual void Serialize(MgBinarySerializer s)
        {
            s.Write(this.Group);

            if (s.SiteVersion <= SiteVersions.GetVersion(KnownSiteVersions.MapGuideEP1_1))
                s.WriteClassId(19003);
            else
                s.WriteClassId(30501);

            s.WriteResourceIdentifier(this.LayerDefinitionID);

            if (s.SiteVersion < SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2))
            {
                s.Write(this.Name);
                s.Write(this.ObjectId);

                s.Write(this.Type);

                s.Write((byte)(this.Visible ? 1 : 0));
                s.Write((byte)(this.Selectable ? 1 : 0));
                s.Write((byte)(this.ShowInLegend ? 1 : 0));
                s.Write((byte)(this.ExpandInLegend ? 1 : 0));

                s.Write(this.LegendLabel);
                s.Write((byte)(this.NeedsRefresh ? 1 : 0));
                s.Write(this.DisplayOrder);

                s.Write(_scaleRanges.Length);
                foreach (double d in _scaleRanges)
                    s.Write(d);

                s.Write(this.FeatureSourceID);
                s.Write(this.QualifiedClassName);
                s.Write(this.GeometryPropertyName);

                s.Write(this.IdentityProperties.Length);
                foreach (var x in this.IdentityProperties)
                {
                    s.Write((short)ConvertNetTypeToMgType(x.Type));
                    s.Write(x.Name);
                }
            }
            else
            {
                s.WriteStringInternal(this.Name);
                s.WriteStringInternal(this.ObjectId);
                s.WriteRaw(BitConverter.GetBytes(this.Type));
                int flags = 0;
                flags |= this.Visible ? 1 : 0;
                flags |= this.Selectable ? 2 : 0;
                flags |= this.ShowInLegend ? 4 : 0;
                flags |= this.ExpandInLegend ? 8 : 0;
                flags |= this.NeedsRefresh ? 16 : 0;
                flags |= this.HasTooltips ? 32 : 0;
                s.WriteRaw(new byte[] { (byte)flags });

                s.WriteStringInternal(this.LegendLabel);
                s.WriteRaw(BitConverter.GetBytes(this.DisplayOrder));

                s.WriteRaw(BitConverter.GetBytes(_scaleRanges.Length));
                foreach (double d in _scaleRanges)
                    s.WriteRaw(BitConverter.GetBytes(d));

                s.WriteStringInternal(this.FeatureSourceID);
                s.WriteStringInternal(this.QualifiedClassName);
                if (s.SiteVersion > SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS2_1))
                    s.WriteStringInternal(this.Filter);
                s.WriteStringInternal(this.SchemaName);
                s.WriteStringInternal(this.GeometryPropertyName);

                s.WriteRaw(BitConverter.GetBytes(this.IdentityProperties.Length));
                foreach (var x in this.IdentityProperties)
                {
                    s.WriteRaw(BitConverter.GetBytes((short)ConvertNetTypeToMgType(x.Type)));
                    s.WriteStringInternal(x.Name);
                }
            }
        }
Exemple #3
0
 private void SaveSelectionXml(string resourceID)
 {
     ResourceIdentifier.Validate(resourceID, ResourceTypes.RuntimeMap);
     string selectionID = resourceID.Substring(0, resourceID.LastIndexOf(".")) + ".Selection"; //NOXLATE
     System.IO.MemoryStream ms = new System.IO.MemoryStream();
     MgBinarySerializer serializer = new MgBinarySerializer(ms, this.SiteVersion);
     this.Selection.Serialize(serializer);
     ms.Position = 0;
     this.ResourceService.SetResourceData(selectionID, "RuntimeData", ResourceDataType.Stream, ms); //NOXLATE
 }
Exemple #4
0
        private static void SerializeExtent(IEnvelope env, MgBinarySerializer s)
        {
            if (s.SiteVersion <= SiteVersions.GetVersion(KnownSiteVersions.MapGuideEP1_1))
                s.WriteClassId(18001);
            else
                s.WriteClassId(20001);

            s.Write((int)0);

            s.Write(env.MinX);
            s.Write(env.MinY);
            s.Write(env.MaxX);
            s.Write(env.MaxY);
        }
Exemple #5
0
        /// <summary>
        /// Serializes the layer data to the specified binary stream
        /// </summary>
        /// <param name="s"></param>
        protected void SerializeLayerData(MgBinarySerializer s)
        {
            s.Write((int)this.Groups.Count);
            //Workaround a deserialization quirk in the MgMap. It deserializes groups sequentially
            //without first checking if a parented group exists before doing the parent association
            //
            //We workaround this by re-ordering the groups, so that unparented groups are serialized first
            var groups = new List<RuntimeMapGroup>();
            var remaining = new List<RuntimeMapGroup>();
            var processed = new Dictionary<string, RuntimeMapGroup>();
            foreach (var grp in this.Groups)
            {
                if (string.IsNullOrEmpty(grp.Group)) //Un-parented
                {
                    groups.Add(grp);
                    processed.Add(grp.Name, grp);
                }
                else
                {
                    remaining.Add(grp);
                }
            }
            var indices = new List<int>();
            //Whittle down this list until all parents are resolved
            while (remaining.Count > 0)
            {
                indices.Clear();
                //Collect the indices which can be added to the final list
                for (int i = 0; i < remaining.Count; i++)
                {
                    var grp = remaining[i];
                    if (processed.ContainsKey(grp.Group)) //Parent of a group already processed
                        indices.Add(i);
                }
                //Reverse iterate so that higher indices are removed first
                for (int i = indices.Count - 1; i >= 0; i--)
                {
                    var index = indices[i];
                    var grp = remaining[index];
                    remaining.RemoveAt(index);
                    groups.Add(grp);
                    processed.Add(grp.Name, grp);
                }
            }

            foreach (var g in groups)
                g.Serialize(s);

            s.Write(this.Layers.Count);
            foreach (var t in this.Layers)
                t.Serialize(s);
        }
Exemple #6
0
        /// <summary>
        /// Serializes this instance to the specified binary stream
        /// </summary>
        /// <param name="s"></param>
        public virtual void Serialize(MgBinarySerializer s)
        {
            if (s.SiteVersion >= SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2))
            {
                s.Write(MgBinaryVersion);
                s.WriteResourceIdentifier(this.ResourceID);
            }

            s.Write(this.Name);
            s.Write(this.ObjectId);
            s.WriteResourceIdentifier(this.MapDefinition);
            s.Write(this.CoordinateSystem);
            //base.m_extents.Serialize(s);
            SerializeExtent(this.MapExtent, s);
            s.WriteCoordinates(new double[] { this.ViewCenter.X, this.ViewCenter.Y }, 0);
            s.Write(this.ViewScale);
            SerializeExtent(this.DataExtent, s);
            s.Write(this.DisplayDpi);
            s.Write(this.DisplayWidth);
            s.Write(this.DisplayHeight);
            s.Write(Utility.SerializeHTMLColor(this.BackgroundColor, true));
            s.Write(this.MetersPerUnit);

            if (s.SiteVersion >= SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2))
                s.Write(this.LayerRefreshMode);

            s.Write(_finiteDisplayScales.Length);
            foreach (double d in _finiteDisplayScales)
                s.Write(d);

            if (s.SiteVersion >= SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2))
            {
                SerializeChangeMap(s);
                if (s.SiteVersion >= new Version(2, 3)) //SiteVersions.GetVersion(KnownSiteVersions.MapGuideEP2012))
                {
                    s.Write(this.WatermarkUsage);
                }
                s.Write((int)0);
            }
            else
            {
                SerializeLayerData(s);
                SerializeChangeMap(s);
            }
        }
Exemple #7
0
 /// <summary>
 /// Serializes this instance
 /// </summary>
 /// <param name="s"></param>
 public virtual void Serialize(MgBinarySerializer s)
 {
     s.Write(this.Group);
     if (s.SiteVersion >= SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2))
         s.WriteClassId(12001);
     else
         s.WriteClassId(19001);
     s.Write(this.Name);
     s.Write(this.ObjectId);
     s.Write(this.Type);
     s.Write(this.Visible);
     s.Write(this.ShowInLegend);
     s.Write(this.ExpandInLegend);
     s.Write(this.LegendLabel);
 }