Beispiel #1
0
        public void Save(Context context)
        {
            if (context.ExportMode || updateAttr[Constants.updateAttrCreated])
            {
                GmCommand cmd = context.TargetConn.CreateCommandById("insertIntoGisLib");
                cmd.AddInt("Id", id);
                cmd.AddInt("Attr", attr);
                cmd.AddString("Name", name, MaxLength.Name);
                cmd.AddString("Style", styleStr, MaxLength.Style);

//      DZ      14.01.08
//                if( defaultStyleStr == "" )
//                    cmd.AddString( "DefaultStyle", /*defaultStyleStr*/ " ", MaxLength.Style );
//                else
                cmd.AddString("DefaultStyle", defaultStyleStr, MaxLength.Style);
                cmd.AddInt("SMin", smin);
                cmd.AddInt("SMax", smax);
                cmd.AddBinary("Code", context.Buf.SetRect(bounds));
                cmd.AddBinary("IndexerCode", context.Buf.SetIntArray(indexer.ToIntArray()));
                cmd.AddBinary("Scales", context.Buf.SetIntArray(scales.Values));
                cmd.ExecuteNonQuery();
            }
            else if (updateAttr.NonEmpty)
            {
                GmCommand cmd     = context.Conn.CreateCommand();
                string    cmdText = "";
                if (updateAttr[(int)LibField.Attr])
                {
                    cmdText += "Attr= @Attr,";
                    cmd.AddInt("Attr", attr);
                }
                if (updateAttr[(int)LibField.Name])
                {
                    cmdText += "Name= @Name,";
                    cmd.AddString("Name", name, MaxLength.Name);
                }
                if (updateAttr[(int)LibField.Style])
                {
                    cmdText += "Style= @Style,";
                    cmd.AddString("Style", styleStr, MaxLength.Style);
                }
                if (updateAttr[(int)LibField.DefaultStyle])
                {
                    cmdText += "DefaultStyle= @DefaultStyle,";
                    cmd.AddString("DefaultStyle", defaultStyleStr, MaxLength.Style);
                }
                if (updateAttr[(int)LibField.SMin])
                {
                    cmdText += "SMin= @SMin,";
                    cmd.AddInt("SMin", smin);
                }
                if (updateAttr[(int)LibField.SMax])
                {
                    cmdText += "SMax= @SMax,";
                    cmd.AddInt("SMax", smax);
                }
                if (updateAttr[(int)LibField.Code])
                {
                    cmdText += "Code= @Code,";
                    cmd.AddBinary("Code", context.Buf.SetRect(bounds));
                }
                if (updateAttr[(int)LibField.IndexerCode])
                {
                    cmdText += "IndexerCode= @IndexerCode,";
                    cmd.AddBinary("IndexerCode", context.Buf.SetIntArray(indexer.ToIntArray()));
                }
                if (updateAttr[(int)LibField.Scales])
                {
                    cmdText += "Scales= @Scales,";
                    cmd.AddBinary("Scales", context.Buf.SetIntArray(scales.Values));
                }
                Geomethod.StringUtils.RemoveLastChar(ref cmdText);
                cmd.CommandText = "update gisLib set " + cmdText + " where Id= @Id";
                cmd.AddInt("Id", id);
                cmd.ExecuteNonQuery();
            }
            if (!context.ExportMode)
            {
                updateAttr = 0;
            }

            if (context.Filter != null && context.Filter.Includes(BatchLevel.Type))
            {
                if (types != null)
                {
                    foreach (GType type in types)
                    {
                        type.Save(context);
                    }
                }
            }

            if (context.ExportMode)
            {
                idGenerator.Save(context.TargetConn);
            }
            colors.Save(context);
            layers.Save(context);
            views.Save(context);
            bgImages.Save(context);
            customTables.Save(context);
        }