Save() private method

private Save ( ) : Page
return Wiki.Page
Example #1
0
 private void ReturnFile(Edit e, string region)
 {
     Response.Clear();
     Response.ContentType = "application/octet-stream";
     Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}.DAT", e.Name.ToUpper()));
     byte[] data = File.ReadAllBytes(Server.MapPath(string.Format("/dats/{0}/{1}.DAT", region, e.ID)));
     Response.OutputStream.Write(data, 0, data.Length);
     Response.Flush();
     Response.Close();
     e.Downloads++;
     e.Save();
 }
Example #2
0
    public void SaveEdit(object o, EventArgs e)
    {
        if (Session["currentSim"] == null)
        {
            return;
        }
        SimFileData data         = (SimFileData)Session["currentSim"];
        ChartData   selectedData = null;

        foreach (ChartData cd in data.Charts)
        {
            if (cd.ChartInfo.ID == HdnChart.Value)
            {
                selectedData = cd;
            }
        }

        Edit edit = new Edit();

        edit.New(CurrentUser);
        edit.Comment1    = CmbComment1.SelectedIndex;
        edit.Comment2    = CmbComment2.SelectedIndex;
        edit.Difficulty  = CmbEditDifficulty.SelectedValue;
        edit.Name        = TxtName.Text;
        edit.Description = TxtNotes.Text;
        edit.Rating      = Convert.ToInt32(CmbRating.SelectedValue);
        edit.Style       = selectedData.ChartInfo.Style.ToString();
        edit.SongID      = HdnSongId.Value;
        edit.Public      = ChkPublic.Checked;
        edit.Video       = video.Text;

        Song s = Song.GetSong(edit.SongID);

        if (!s.Confirmed)
        {
            s.FirstMeasure = first.Text.ToInt();
        }

        int offset = s.FirstMeasure - data.FirstMeasure;

        if (offset > 0)
        {
            while (offset != 0)
            {
                for (int i = 0; i < 16; i++)
                {
                    selectedData.TapData.Add(Arrow.None);
                    selectedData.FreezeData.Add(Arrow.None);
                }

                offset--;
            }
        }

        if (offset < 0)
        {
            while (offset != 0)
            {
                selectedData.TapData.RemoveRange(0, 16);
                selectedData.FreezeData.RemoveRange(0, 16);
                offset++;
            }
        }

        selectedData.TapData.RemoveRange(0, 16);
        selectedData.FreezeData.RemoveRange(0, 16);

        edit.Steps = Converter.ConvertTapsToXml("STEP", selectedData.TapData).ToString() + Converter.ConvertTapsToXml("FREEZ_ARROW", selectedData.FreezeData).ToString();
        edit.Stats = selectedData.GenerateStats();
        edit.Save();
        File.WriteAllText(Server.MapPath(string.Format("/sims/{0}.sm", edit.ID)), (string)Session["simFile"]);
        Session.Remove("currentSim");
        Session.Remove("simFile");
        Session["editid"] = edit.ID;
        Response.Redirect("convert.aspx");
    }