<commit_before>﻿using Microsoft.Xna.Framework.Media;
using System;
using System.IO;
using System.Text;
using WPCordovaClassLib.Cordova;
using WPCordovaClassLib.Cordova.Commands;
using WPCordovaClassLib.Cordova.JSON;

public class Base64ToGallery : BaseCommand
{
    public Base64ToGallery()
	{
	}

    public void saveImageDataToLibrary(string jsonArgs)
    {
        try
        {
            var options = JsonHelper.Deserialize<string[]>(jsonArgs);

            string imageData  = options[0];
            string prefix     = options[1];
            byte[] imageBytes = Convert.FromBase64String(imageData);

            if (String.IsNullOrEmpty(prefix))
            {
                prefix = "img_";
            }

            using (var imageStream = new MemoryStream(imageBytes))
            {
                imageStream.Seek(0, SeekOrigin.Begin);

                string fileName = prefix + String.Format("{0:yyyyMMddHHmmss}", DateTime.Now);
                var library     = new MediaLibrary();
                var picture     = library.SavePicture(fileName, imageStream);

                if (picture.Name.Contains(fileName))
                {
                    DispatchCommandResult(new PluginResult(PluginResult.Status.OK, "Image saved: " + picture.Name));
                }
                else
                {
                    DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Failed to save image: " + picture.Name));
                }
            }
        }<commit_msg>removed useless log messages from WP8 class<commit_after>﻿using Microsoft.Xna.Framework.Media;
using System;
using System.IO;
using System.Text;
using WPCordovaClassLib.Cordova;
using WPCordovaClassLib.Cordova.Commands;
using WPCordovaClassLib.Cordova.JSON;

public class Base64ToGallery : BaseCommand
{
    public Base64ToGallery()
	{
	}

    public void saveImageDataToLibrary(string jsonArgs)
    {
        try
        {
            var options = JsonHelper.Deserialize<string[]>(jsonArgs);

            string imageData  = options[0];
            string prefix     = options[1];
            byte[] imageBytes = Convert.FromBase64String(imageData);

            if (String.IsNullOrEmpty(prefix))
            {
                prefix = "img_";
            }

            using (var imageStream = new MemoryStream(imageBytes))
            {
                imageStream.Seek(0, SeekOrigin.Begin);

                string fileName = prefix + String.Format("{0:yyyyMMddHHmmss}", DateTime.Now);
                var library     = new MediaLibrary();
                var picture     = library.SavePicture(fileName, imageStream);

                if (picture.Name.Contains(fileName))
                {
                    DispatchCommandResult(new PluginResult(PluginResult.Status.OK));
                }
                else
                {
                    DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Failed to save image: " + picture.Name));
                }
            }
        }
{'fraction_non_alphanumeric': 0.09012591119946985, 'fraction_numerical': 0.006958250497017893, 'mean_word_length': 1.8779790276453765, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5972066', 'n_tokens_mistral': 824, 'n_tokens_neox': 777, 'n_words': 155}