public bool ReinstateSelection(JbSelectionModel jbmodel) { var ok = _jbDb.ReinstateSelection(jbmodel); CreateAllStrips(); return(ok); }
public bool ReinstateSelection(JbSelectionModel jbmodel) { try { using (IDbConnection db = new MySqlConnection(ConfigurationManager.ConnectionStrings["JukeboxDatabase"].ConnectionString)) { db.Open(); string sqlQuery = "Update amijukebox.jbselection Set JbLetter = @jbletter, JbNumberA = @jbnumbera, JbNumberB = @jbnumberb, JbNumeric = @jbnumeric, Archived = @archived Where Id = @Id"; db.Execute(sqlQuery, new { jbmodel.JbLetter, jbmodel.JbNumberA, jbmodel.JbNumberB, jbmodel.JbNumeric, jbmodel.Archived, jbmodel.Id }); db.Close(); } } catch (Exception e) { return(false); } return(true); }
public bool UpdateImagePath(JbSelectionModel jbmodel) { try { using (IDbConnection db = new MySqlConnection(ConfigurationManager.ConnectionStrings["JukeboxDatabase"].ConnectionString)) { db.Open(); string sqlQuery = "Update amijukebox.jbselection Set ImageStripName = @imagestripname Where Id = @Id"; db.Execute(sqlQuery, new { jbmodel.ImageStripName, jbmodel.Id }); db.Close(); } } catch (Exception e) { return(false); } return(true); }
public bool ArchiveSelection(JbSelectionModel jbmodel) { if (!_jbDb.ArchiveSelection(jbmodel.Id)) { return(false); } CreateAllStrips(); return(true); }
private string CreateJbStrip(JbSelectionModel jbmodel) { var templatepath = @"C:\Users\DiNer0-2\Documents\GitHub\AmiJukeBoxRemote\AmiJukeBoxRemote\gui\assets\templates\" + jbmodel.ImageStripTemplate; var imagepath = @"C:\Users\DiNer0-2\Documents\GitHub\AmiJukeBoxRemote\AmiJukeBoxRemote\gui\assets\images\"; Bitmap bitmap = null; var bitMapImage = new System.Drawing.Bitmap(System.Drawing.Image.FromFile(templatepath)); var graphicImage = Graphics.FromImage(bitMapImage); graphicImage.SmoothingMode = SmoothingMode.AntiAlias; if (jbmodel.Archived == 0) { // Set Jukebox Selection A int opacity = 168; graphicImage.DrawString(jbmodel.JbLetter + jbmodel.JbNumberA, new Font("Traveling _Typewriter", 10, FontStyle.Bold), new SolidBrush(Color.FromArgb(opacity, Color.Black)), new Point(6, 31)); // Set Jukebox Selection B graphicImage.DrawString(jbmodel.JbLetter + jbmodel.JbNumberB, new Font("Traveling _Typewriter", 10, FontStyle.Bold), new SolidBrush(Color.FromArgb(opacity, Color.Black)), new Point(6, 51)); } var textSize = TextRenderer.MeasureText(jbmodel.Artist1, new Font("Traveling _Typewriter", 12, FontStyle.Bold, GraphicsUnit.Point)); graphicImage.DrawString(jbmodel.Artist1, new Font("Traveling _Typewriter", 12, FontStyle.Bold), SystemBrushes.WindowText, new Point(150 - Math.Min(150, (int)Math.Round(textSize.Width * 0.5)), 40)); textSize = TextRenderer.MeasureText(jbmodel.A1Song, new Font("Traveling _Typewriter", 12, FontStyle.Bold, GraphicsUnit.Point)); graphicImage.DrawString(jbmodel.A1Song, new Font("Traveling _Typewriter", 12, FontStyle.Bold), SystemBrushes.WindowText, new Point(150 - Math.Min(150, (int)Math.Round(textSize.Width * 0.5)), 15)); textSize = TextRenderer.MeasureText(jbmodel.B1Song, new Font("Traveling _Typewriter", 12, FontStyle.Bold, GraphicsUnit.Point)); if (textSize.Width > 250) { } graphicImage.DrawString(jbmodel.B1Song, new Font("Traveling _Typewriter", 12, FontStyle.Bold), SystemBrushes.WindowText, new Point(150 - Math.Min(150, (int)Math.Round(textSize.Width * 0.5)), 70)); var fileEndName = jbmodel.Id + (jbmodel.Archived == 0 ? "" : "_arch"); //Save the new image to the response output stream. var imagepathcreated = imagepath + jbmodel.ImageStripTemplate.Remove(jbmodel.ImageStripTemplate.Length - 4) + "_" + fileEndName + ".png"; bitMapImage.Save(imagepathcreated, ImageFormat.Png); graphicImage.Dispose(); bitMapImage.Dispose(); return(jbmodel.ImageStripTemplate.Remove(jbmodel.ImageStripTemplate.Length - 4) + "_" + fileEndName + ".png"); }
public bool SaveStripToDb(JbSelectionModel jbmodel) { var ok = _jbDb.SaveToDataBase(jbmodel) > -1; if (!ok) { return(false); } jbmodel.ImageStripName = CreateJbStrip(jbmodel); _jbDb.UpdateImagePath(jbmodel); return(true); }
public int SaveToDataBase(JbSelectionModel jbmodel) { var id = -1; try { using (IDbConnection db = new MySqlConnection(ConfigurationManager.ConnectionStrings["JukeboxDatabase"].ConnectionString)) { db.Open(); string sqlQuery = "INSERT INTO amijukebox.jbselection (jbletter,jbnumbera,jbnumberb,jbnumeric,a1song,a2song," + "b1song,b2song,artist1,artist2,imagestripname,musiccategory,archived,imagestriptemplate,discogslink,spotifyuri) VALUES (@jbletter,@jbnumbera," + "@jbnumberb,@jbnumeric,@a1song,@a2song,@b1song,@b2song,@artist1,@artist2,@imagestripname,@musiccategory,@archived,@imagestriptemplate,@discogslink,@spotifyuri)"; db.Execute(sqlQuery, new { jbmodel.JbLetter, jbmodel.JbNumberA, jbmodel.JbNumberB, jbmodel.JbNumeric, jbmodel.A1Song, jbmodel.A2Song, jbmodel.B1Song, jbmodel.B2Song, jbmodel.Artist1, jbmodel.Artist2, jbmodel.ImageStripName, jbmodel.MusicCategory, jbmodel.Archived, jbmodel.ImageStripTemplate, jbmodel.DiscogsLink, jbmodel.SpotifyUri }); id = db.Query <int>("SELECT CAST(LAST_INSERT_ID() AS UNSIGNED INTEGER);").Single(); db.Close(); } } catch (Exception e) { return(id); } jbmodel.Id = id; return(id); }
public GenericAPIResultModel UpdateSelectionInDb(JbSelectionModel jbmodel) { string errorMessage = string.Empty; var ok = _jbDb.UpdateInDataBase(jbmodel); if (ok) { CreateAllStrips(); } else { errorMessage = "Could not update in database"; } return(new GenericAPIResultModel() { Success = errorMessage.Length == 0, Message = errorMessage }); }
public bool UpdateInDataBase(JbSelectionModel jbmodel) { try { using (IDbConnection db = new MySqlConnection(ConfigurationManager.ConnectionStrings["JukeboxDatabase"].ConnectionString)) { db.Open(); string sqlQuery = "Update amijukebox.jbselection Set JbLetter = @jbletter, JbNumberA = @jbnumbera, JbNumberB = @jbnumberb, JbNumeric = @jbnumeric, " + "A1Song = @a1song, A2Song = @a2song, B1Song = @b1song, B2Song = @b2song, Artist1 = @artist1, Artist2 = @artist2," + "MusicCategory = @musiccategory, ImageStripTemplate = @imagestriptemplate, DiscogsLink = @discogslink, " + "SpotifyUri = @spotifyuri, Archived = @archived Where Id = @Id"; db.Execute(sqlQuery, new { jbmodel.JbLetter, jbmodel.JbNumberA, jbmodel.JbNumberB, jbmodel.JbNumeric, jbmodel.A1Song, jbmodel.A2Song, jbmodel.B1Song, jbmodel.B2Song, jbmodel.Artist1, jbmodel.Artist2, jbmodel.MusicCategory, jbmodel.ImageStripTemplate, jbmodel.DiscogsLink, jbmodel.SpotifyUri, jbmodel.Archived, jbmodel.Id }); db.Close(); } } catch (Exception e) { return(false); } return(true); }