/// <summary>
        /// 另存元数据(报表或视图)
        /// </summary>
        /// <param name="login">包装的login信息</param>
        /// <param name="sourceId">另存的源Id(报表id或视图Id)</param>
        /// <param name="savaAsName">另存的新名称</param>
        /// <param name="saveAsType">另存类型</param>
        /// <returns>另存成功,返回true;已存在要另存的名称,返回false</returns>
        public bool SaveAs(
            U8LoginInfor login,
            string sourceId,
            string savaAsName,
            string reportSubId,
            SaveAsType saveAsType,
            string runtimeForamtXml,
            string colorstyleid,
            string currentViewId)
        {
            SqlCommand cmd = new SqlCommand("UAP_Report_RuntimeSaveAs");

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(SqlHelper.GetParameter("@SourceId", SqlDbType.NVarChar, 100, sourceId));
            cmd.Parameters.Add(SqlHelper.GetParameter("@SaveAsName", SqlDbType.NVarChar, 256, savaAsName));
            cmd.Parameters.Add(SqlHelper.GetParameter("@SaveAsType", SqlDbType.NVarChar, 100, saveAsType.ToString()));
            cmd.Parameters.Add(SqlHelper.GetParameter("@cAccId", SqlDbType.NVarChar, 100, login.cAccId));
            cmd.Parameters.Add(SqlHelper.GetParameter("@cYear", SqlDbType.NVarChar, 100, login.cYear));
            cmd.Parameters.Add(SqlHelper.GetParameter("@cUserId", SqlDbType.NVarChar, 100, login.UserID));
            cmd.Parameters.Add(SqlHelper.GetParameter("@IsExistedName", SqlDbType.Bit));
            cmd.Parameters.Add(SqlHelper.GetParameter("@ReportSubId", SqlDbType.NVarChar, 100, reportSubId));
            cmd.Parameters.Add(SqlHelper.GetParameter("@NewAuthIds", SqlDbType.NVarChar, 2000));
            cmd.Parameters.Add(SqlHelper.GetParameter("@RuntimeFormat", SqlDbType.NText, runtimeForamtXml));
            cmd.Parameters.Add(SqlHelper.GetParameter("@colorstyleid", SqlDbType.NVarChar, 100, colorstyleid));
            cmd.Parameters.Add(SqlHelper.GetParameter("@CurrentViewId", SqlDbType.NVarChar, 100, currentViewId));

            bool isNameExisted = false;

            this.ExcuteStoreProc(login.UfMetaCnnString, cmd, ref isNameExisted);
            if (isNameExisted)
            {
                return(false);
            }
            if (saveAsType == SaveAsType.SaveAsReport)
            {
                this.AddAuth2Cache(cmd, login);
            }
            return(true);
        }
예제 #2
0
        /// <summary>
        /// Saves selected data
        /// </summary>
        private void SaveData()
        {
            // If the required objects are missing, return
            if (_mainForm == null || _mainForm.RomData == null || cbSave.SelectedItem == null || cbSaveAs.SelectedItem == null)
            {
                return;
            }

            // Set up objects
            ObjectID   objectID   = null;
            Bitmap     bmp        = null;
            SaveType   saveType   = (SaveType)(cbSave.SelectedItem as ObjectID).ID;
            SaveAsType saveAsType = (SaveAsType)(cbSaveAs.SelectedItem as ObjectID).ID;
            string     save       = EnumMethods.GetDescription(typeof(SaveType), saveType);
            string     saveAs     = EnumMethods.GetDescription(typeof(SaveAsType), saveAsType);

            switch (saveType)
            {
            case SaveType.PaletteGroup: objectID = GetSelectedPaletteGroup(); bmp = objectID != null?GetSelectedPaletteGroup().GetPaletteGroupImage() : null; break;

            case SaveType.Sprite: objectID = GetSelectedSprite(); bmp = pnlSprite.Image; break;

            case SaveType.SpriteTileset: objectID = GetSelectedTileset(cbSpriteTilesets); bmp = pnlSpriteTilesets.Image; break;

            case SaveType.SpriteTileMap: objectID = GetSelectedTileMap(cbSpriteTileMaps); bmp = pnlSpriteTileMaps.Image; break;

            case SaveType.Tileset: objectID = GetSelectedTileset(cbTilesets); bmp = pnlTilesets.Image; break;

            case SaveType.TileMap: objectID = GetSelectedTileMap(cbTileMaps); bmp = pnlTileMaps.Image; break;
            }

            // If no object was selected, return
            if (objectID == null)
            {
                ShowMessage("Please select a " + EnumMethods.GetDescription(typeof(SaveType), saveType).ToLower() + " to save.");
                return;
            }

            // Create open file dialog
            using (SaveFileDialog dialog = new SaveFileDialog())
            {
                // Set up the open file dialog
                dialog.Filter   = saveAsType == SaveAsType.Binary ? "Uncompressed Binary|*.bin" : saveAsType == SaveAsType.CompressedBinary ? "Compressed Binary|*.bin" : "Image|*.png";
                dialog.Title    = "Save " + save + " " + saveAs + " File";
                dialog.FileName = objectID.Name + saveType.ToString() + saveAsType.ToString();

                // Show dialog, if the user clicks OK
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    // Write data to disk, based on save as type
                    switch (saveAsType)
                    {
                    case SaveAsType.Binary: using (BinaryWriter bw = new BinaryWriter(File.Create(dialog.FileName))) { bw.Write(MainForm.RomData.Decompress(objectID.Compression, objectID.DataStart, objectID.Length)); break; }

                    case SaveAsType.CompressedBinary: using (BinaryWriter bw = new BinaryWriter(File.Create(dialog.FileName))) { bw.Write(MainForm.RomData.GetBytes(objectID.DataStart, objectID.Length)); } break;

                    case SaveAsType.Image: if (bmp != null)
                        {
                            bmp.Save(dialog.FileName, ImageFormat.Png);
                        }
                        break;
                    }
                }
            }
        }