예제 #1
0
 public void AddPacoteToCollection(int collection_id, int pacote_id)
 {
     if (_connection.Table <Pacote>().Where(x => x.Id == pacote_id).FirstOrDefault() != null)
     {
         Colection c = _connection.Table <Colection>().Where(x => x.Id == collection_id).FirstOrDefault();
         c.AddPacote(pacote_id, _connection);
     }
 }
예제 #2
0
        private void InitializeSettingTable()
        {
            string dbName = "receptionist.db3";

            ILocalStorageService storageService   = ServiceProvider.GetService <ILocalStorageService>();
            IActivatorService    activatorService = ServiceProvider.GetService <IActivatorService>();
            var factory = activatorService.CreateInstance <Func <string, ISQLiteConnection> >();

            ISQLiteConnection db = factory(storageService.GetFilePath(dbName, LocalFolderKind.Data));

            if (!db.TableExists <GeneralSetting>())
            {
                db.CreateTable <GeneralSetting>();
            }
            //else
            //    db.MigrateTable<Setting>();

            if (db.Table <GeneralSetting>().ToList().Count == 0)
            {
                List <GeneralSetting> generalsetting = new List <GeneralSetting>();
                generalsetting.Add(new GeneralSetting()
                {
                    SettingId = Guid.NewGuid(), GeneralName = "barcode"
                });
                db.InsertAll(generalsetting);
            }
        }
예제 #3
0
 public List <Kitten> KittensMatching(string nameFilter)
 {
     return(_connection.Table <Kitten>()
            .OrderBy(x => x.Price)
            .Where(x => x.Name.Contains(nameFilter))
            .ToList());
 }
예제 #4
0
 public IList <ItemOfStuff> AllStuffInInbox()
 {
     return(_sqlConnection
            .Table <ItemOfStuff>()
            .OrderBy(item => item.TimeUtc)
            .ToList());
 }
예제 #5
0
 public IList <Project> AllProjects()
 {
     return(_sqlConnection
            .Table <Project>()
            .OrderBy(proj => proj.Outcome)
            .ToList());
 }
예제 #6
0
 public List <CollectedItem> All()
 {
     return(_connection
            .Table <CollectedItem>()
            .OrderByDescending(x => x.WhenUtc)
            .ToList());
 }
예제 #7
0
 public List <Item> All()
 {
     return(_connection
            .Table <Item>()
            .OrderByDescending(x => x.ItemCreated)
            .ToList());
 }
        public Data_Access_Layer.City GetOrCreateCity(Common.DTO.City model)
        {
            Data_Access_Layer.City city = null;

            if (model.Id != 0)
            {
                city = _sqliteConnection
                       .Find <Data_Access_Layer.City>(model.Id);

                return(city);
            }

            city = _sqliteConnection
                   .Table <Data_Access_Layer.City>()
                   .FirstOrDefault(ci => ci.Name == model.Name);

            if (city == null)
            {
                city = new Data_Access_Layer.City
                {
                    Name = model.Name
                };

                _sqliteConnection.Insert(city);
            }

            return(city);
        }
예제 #9
0
 public IList <Action> AllActions()
 {
     return(_sqlConnection
            .Table <Action>()
            .OrderBy(action => action.Outcome)
            .ToList());
 }
예제 #10
0
파일: test01.cs 프로젝트: pmosoft/CrazyWord
    // Use this for initialization
    void Start()
    {
        var factory = new Factory();

        var dbPath = string.Format(@"Assets/StreamingAssets/{0}", "existing.db");

        _connection = factory.Create(dbPath);
        Debug.Log("Final PATH: " + dbPath);


        var people = _connection.Table <Person>();;

        print("people=" + people.Count());

        foreach (Person p1 in people)
        {
            print("p1.Name=" + p1.Name);
        }



        //CreateDB2();

        string query = "update Person set Name='あいうぇえおか'";

        string val1 = "あいうぇえおか";

        //val1 = "aaa";

        query = string.Format("update Person set Name=\"{0}\" ", val1);



        //System.Text.Encoding.UTF8.GetByteCount(query);
        //_connection.Execute(query);
        //_connection.ExecuteScalar

        Person pp = _connection.Table <Person>().Where(x => x.Name == "あいうぇえおか").FirstOrDefault();

        print(pp.Age);

        _connection.Update(new Person {
            Id = 1, Name = "탐", Surname = "あいうぇえおか", Age = 56
        });

        //_connection.Execute("update Person set Name='abc'");
    }
예제 #11
0
        private void saveOutput(Bitmap croppedImage)
        {
            if (saveUri != null)
            {
                try
                {
                    using (var outputStream = ContentResolver.OpenOutputStream(saveUri))
                    {
                        if (outputStream != null)
                        {
                            croppedImage.Compress(outputFormat, 75, outputStream);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(this.GetType().Name, ex.Message);
                }

                Bundle extras = new Bundle();
                SetResult(Result.Ok, new Intent(saveUri.ToString())
                          .PutExtras(extras));
            }
            else
            {
                Log.Error(this.GetType().Name, "not defined image url");
            }
            //sqlite save

            ISQLiteConnection        conn    = null;
            ISQLiteConnectionFactory factory = new MvxDroidSQLiteConnectionFactory();

            var    sqlitedir = new Java.IO.File(global::Android.OS.Environment.GetExternalStoragePublicDirectory(global::Android.OS.Environment.DirectoryPictures), "Boruto");
            string filename  = sqlitedir.Path + "/mysqliteimage.db";

            //Toast.MakeText(Application.Context, filename, ToastLength.Long).Show();
            Java.IO.File f = new Java.IO.File(filename);
            conn = factory.Create(filename);
            conn.CreateTable <Myimage>();


            conn.Insert(new Myimage()
            {
                Date = "30-12-2016", Imagepath = saveUri.ToString()
            });
            var mycount = 0;

            foreach (var e in conn.Table <Myimage>().Where(e => e.Date == "30-12-2016"))
            {
                mycount++;
            }
            //Toast.MakeText(this, mycount.ToString(), ToastLength.Short).Show();
            conn.Close();
            //sqlite save end
            croppedImage.Recycle();
            Finish();
        }
예제 #12
0
 public DataService(ISQLiteConnectionFactory factory, IKittenGenesisService genesis)
 {
     _connection = factory.Create("one.sql");
     _connection.CreateTable<Kitten>();
     if (!_connection.Table<Kitten>().Any())
     {
         FillWithKittens(genesis);
     }
 }
예제 #13
0
 public DataService(ISQLiteConnectionFactory factory, IKittenGenesisService genesis)
 {
     _connection = factory.Create("one.sql");
     _connection.CreateTable <Kitten>();
     if (!_connection.Table <Kitten>().Any())
     {
         FillWithKittens(genesis);
     }
 }
        public CustomListAdapter(Activity context) //We need a context to inflate our row view from
            : base()
        {
            this.context = context;
            //For demo purposes we hard code some data here
            //sqlite save
            var myanimallist = new List <Animal>();
            ISQLiteConnection        conn        = null;
            ISQLiteConnection        connactiond = null;
            ISQLiteConnectionFactory factory     = new MvxDroidSQLiteConnectionFactory();
            ISQLiteConnectionFactory factoryd    = new MvxDroidSQLiteConnectionFactory();



            var    sqlitedir      = new Java.IO.File(global::Android.OS.Environment.GetExternalStoragePublicDirectory(global::Android.OS.Environment.DirectoryPictures), "Boruto");
            string filenameaction = sqlitedir.Path + "/mysqliteaction.db";

            connactiond = factoryd.Create(filenameaction);
            connactiond.CreateTable <MyCheckbox>();
            connactiond.CreateCommand("DELETE FROM MyCheckbox").ExecuteNonQuery();
            connactiond.Dispose();
            connactiond.Commit();
            connactiond.Close();
            if (File.Exists(filenameaction))
            {
                File.Delete(filenameaction);
            }
            string filename = sqlitedir.Path + "/mysqliteimage.db";

            //Toast.MakeText(Application.Context, filename, ToastLength.Long).Show();

            conn = factory.Create(filename);
            conn.CreateTable <Myimage>();



            var countidx = 0;

            foreach (var e in conn.Table <Myimage>().Where(e => e.Date == "30-12-2016"))
            {
                var mystrarray  = e.Imagepath.Split('/');
                var myeleidx    = mystrarray.Length - 1;
                var newanialele = new Animal()
                {
                    Name = mystrarray[myeleidx], Description = e.Imagepath, Image = e.Imagepath, Mycheckbox = countidx
                };
                myanimallist.Add(newanialele);
                countidx++;
            }
            //Toast.MakeText(this, mycount.ToString(), ToastLength.Short).Show();
            conn.Close();
            this.items = myanimallist;
            //sqlite save end
        }
예제 #15
0
        public void ShouldCreateFileDatabase()
        {
            // Items Needing Cleanup
            ISQLiteConnection conn             = null;
            string            expectedFilePath = null;

            try
            {
                // Arrange
#if __IOS__
                ISQLiteConnectionFactory factory = new MvxTouchSQLiteConnectionFactory();
#elif __ANDROID__
                ISQLiteConnectionFactory factory = new MvxDroidSQLiteConnectionFactory();
#else
                ISQLiteConnectionFactory factory = new MvxWpfSqLiteConnectionFactory();
#endif

                string filename = Guid.NewGuid().ToString() + ".db";
#if __IOS__ || __ANDROID__
                expectedFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), filename);
#else
                expectedFilePath = Path.Combine(Directory.GetCurrentDirectory(), filename);
#endif

                // Act
                conn = factory.Create(filename);
                conn.CreateTable <Person>();
                conn.Insert(new Person()
                {
                    FirstName = "Bob", LastName = "Smith"
                });
                Person expected = conn.Table <Person>().FirstOrDefault();

                // Asset
                Assert.That(File.Exists(expectedFilePath), Is.True);
                Assert.That(expected.FirstName, Is.EqualTo("Bob"));
                Assert.That(expected.LastName, Is.EqualTo("Smith"));
            }
            finally // Cleanup in Finally
            {
                if (conn != null)
                {
                    conn.Close();
                }

                if (!string.IsNullOrWhiteSpace(expectedFilePath) && File.Exists(expectedFilePath))
                {
                    File.Delete(expectedFilePath);
                }
            }
        }
예제 #16
0
    public void RemovePacote(int pacote_id, ISQLiteConnection c)
    {
        var pa = from u in c.Table <Pacote>()
                 where u.collection_id == Id && u.Id == pacote_id
                 select u;

        Pacote p = pa.FirstOrDefault();

        p.in_collection = false;
        pacotes_in_collection--;

        c.Update(p);
        c.Update(this);
    }
예제 #17
0
        public void ShouldCreateInMemoryDatabase()
        {
            // Items Needing Cleanup
            ISQLiteConnection conn = null;

            try
            {
                // Arrange
#if __IOS__
                ISQLiteConnectionFactory factory = new MvxTouchSQLiteConnectionFactory();
#elif __ANDROID__
                ISQLiteConnectionFactory factory = new MvxDroidSQLiteConnectionFactory();
#else
                ISQLiteConnectionFactory factory = new MvxWpfSqLiteConnectionFactory();
#endif

                // Act
                conn = factory.CreateInMemory();
                conn.CreateTable <Person>();
                conn.Insert(new Person()
                {
                    FirstName = "Bob", LastName = "Smith"
                });
                Person expected = conn.Table <Person>().FirstOrDefault();

                // Asset
                Assert.That(expected.FirstName, Is.EqualTo("Bob"));
                Assert.That(expected.LastName, Is.EqualTo("Smith"));
            }
            finally // Cleanup in Finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
        }
예제 #18
0
    void getLevels(object obj)
    {
        try
        {
            Action <DBCallback>           callback  = (Action <DBCallback>)obj;
            Dictionary <int, LevelEntity> levels    = new Dictionary <int, LevelEntity> ();
            IEnumerable <LevelTable>      dataTable = connection.Table <LevelTable>();
            foreach (LevelTable item in dataTable)
            {
                LevelEntity levelEntity   = new LevelEntity();
                string      levelDecrypt  = Encryption.Decrypt(item.Level);
                string      scoreDecrypt  = Encryption.Decrypt(item.Score);
                string      rateDecrypt   = Encryption.Decrypt(item.Rate);
                string      replayDecrypt = Encryption.Decrypt(item.Replay);

                try {
                    levelEntity.Level  = Convert.ToInt32(levelDecrypt);
                    levelEntity.Score  = Convert.ToInt32(scoreDecrypt);
                    levelEntity.Rate   = Convert.ToInt32(rateDecrypt);
                    levelEntity.Replay = Convert.ToInt32(replayDecrypt);

                    // Add Score Entity to Score List
                    levels[levelEntity.Level] = levelEntity;
                } catch (Exception ex) {
                    Debug.LogException(ex);
                }
            }
            Debug.LogWarning("getLevels");
            DBCallback dbCallback = new DBCallback();
            dbCallback.Data = levels;
            dbCallback.completedCallback = callback;
            DBCallbackDispatcher.Singleton.requests.Enqueue(dbCallback);
        }
        catch (Exception ex)
        {
            Debug.LogException(ex);
        }
    }
        public AzureListAdapter(Activity context) //We need a context to inflate our row view from
            : base()
        {
            this.context = context;

            //Get list Blob Images from Azure host
            //Get userid from sqlite
            ISQLiteConnection conn = null;

            ISQLiteConnectionFactory factory = new MvxDroidSQLiteConnectionFactory();

            var    sqlitedir      = new Java.IO.File(global::Android.OS.Environment.GetExternalStoragePublicDirectory(global::Android.OS.Environment.DirectoryPictures), "Boruto");
            string filenameaction = sqlitedir.Path + "/mysqlitesas.db";

            conn = factory.Create(filenameaction);
            conn.CreateTable <Azurecon>();
            foreach (var e in conn.Table <Azurecon>())
            {
                myuseridazure = e.UserId;
            }
            //Toast.MakeText(this, "Your Google UserId:" + myuseridazure, ToastLength.Short).Show();
            conn.Close();
            //var myurl = "http://93.118.34.239:8888/listblobs/" + myuseridazure;
            var myurl = "http://93.118.34.239:8888/listblobs/115708452302383620142";

            Uri azureuri     = new Uri(myurl);
            var myanimallist = new List <Animal>();
            //Toast.MakeText(this, "Connect SAS String:" + myurl, ToastLength.Short).Show();

            /*
             * HttpWebRequest request = new HttpWebRequest(azureuri);
             * request.Method = "GET";
             *
             *
             * HttpWebResponse response = request.GetResponse() as HttpWebResponse;
             * var myanimallist = new List<Animal>();
             * using (StreamReader sr = new StreamReader(response.GetResponseStream()))
             * {
             *
             *  string responseString = sr.ReadToEnd();
             *
             *  JArray bloburlarr = JArray.Parse(responseString);
             *  var countidx = 0;
             *  foreach (var perlurl in bloburlarr)
             *  {
             *      var newanialele = new Animal() { Name = "Test Azure", Description = perlurl["imgname"].ToString(), Image = "Test Path", Mycheckbox = countidx };
             *      countidx++;
             *      myanimallist.Add(newanialele);
             *  }
             *
             *
             *
             *  this.items = myanimallist;
             * }
             */
            string auzremainurl  = "https://spc.blob.core.windows.net/";
            string usercontainer = "";
            //Get SAS connection string

            ISQLiteConnection connacc = null;

            ISQLiteConnectionFactory factoryacc = new MvxDroidSQLiteConnectionFactory();

            var    sqlitediracc      = new Java.IO.File(global::Android.OS.Environment.GetExternalStoragePublicDirectory(global::Android.OS.Environment.DirectoryPictures), "Boruto");
            string filenameactionacc = sqlitediracc.Path + "/mysqlitesas.db";

            connacc = factoryacc.Create(filenameactionacc);
            connacc.CreateTable <Azurecon>();
            foreach (var e in connacc.Table <Azurecon>().Where(e => e.Sastring == "using"))
            {
                usercontainer = e.UserId;
            }
            connacc.Close();
            usercontainer = usercontainer.Replace("@", "");
            usercontainer = usercontainer.Replace(".", "");
            string azureurltoken = "http://93.118.34.239:8888/gettoken/" + usercontainer;
            var    clienttk      = new RestClient(azureurltoken);

            var           requesttk  = new RestRequest();
            IRestResponse responsetk = clienttk.Execute(requesttk);

            var myjsonstrtk = responsetk.Content;


            //End Get SAS connection string
            var client = new RestClient("http://93.115.97.151/azureservice/list.php?action=list&containerid=" + usercontainer);

            var           request  = new RestRequest();
            IRestResponse response = client.Execute(request);

            var              myjsonstr        = response.Content;
            JArray           bloburlarr       = JArray.Parse(myjsonstr);
            var              countidx         = 0;
            HashSet <string> myazureimagelist = new HashSet <string>();

            foreach (var perlurl in bloburlarr)
            {
                myazureimagelist.Add(perlurl["imgname"].ToString());
                //myazureimagenamelist.Add(perlurl["imgfilename"].ToString());

                /*
                 * var newanialele = new Animal() { Name = "Test Azure", Description = perlurl["imgname"].ToString(), Image = "Test Path", Mycheckbox = countidx };
                 * countidx++;
                 * myanimallist.Add(newanialele);
                 * */
            }

            foreach (var perlurlh in myazureimagelist)
            {
                string mymainazureurl = auzremainurl + usercontainer + "/" + perlurlh + "?" + myjsonstrtk;
                //Toast.MakeText(Application.Context, "Connect SAS String:" + mymainazureurl, ToastLength.Short).Show();
                var newanialele = new Animal()
                {
                    Name = "Test Azure", Description = mymainazureurl, Image = "Test Path", Mycheckbox = countidx
                };
                countidx++;
                myanimallist.Add(newanialele);
            }


            this.items = myanimallist;
        }
예제 #20
0
 public List <Team> GetAllTeams()
 {
     return(_connection.Table <Team> ().ToList());
 }
예제 #21
0
        static async Task UseContainerSAS(string sas)
        {
            //Toast toast1 = Toast.MakeText(Application.Context, "BBBBBBBBBBBBBBBBBBBBBBBBB", ToastLength.Short);
            //toast1.Show();
            //Try performing container operations with the SAS provided.



            //Return a reference to the container using the SAS URI.
            //CloudStorageAccount account;
            CloudBlobContainer container = new CloudBlobContainer(new Uri(sas));
            string             date      = DateTime.Now.ToString();

            try
            {
                try
                {
                    //MemoryStream memoryStream = new MemoryStream();
                    var sqlitedir = new Java.IO.File(global::Android.OS.Environment.GetExternalStoragePublicDirectory(global::Android.OS.Environment.DirectoryPictures), "Boruto");
                    //string filename = sqlitedir.Path + "/myPhoto_3c2e2adb-b374-466b-b32d-b1a2fdea65a0.jpg";
                    ISQLiteConnection        connactionc = null;
                    ISQLiteConnectionFactory factoryc    = new MvxDroidSQLiteConnectionFactory();
                    string sqlfilename = sqlitedir.Path + "/mysqliteaction.db";
                    //Toast.MakeText(Application.Context, filename, ToastLength.Long).Show();

                    connactionc = factoryc.Create(sqlfilename);
                    connactionc.CreateTable <MyCheckbox>();

                    List <string> myCollection = new List <string>();
                    var           countidx     = 0;
                    foreach (var e in connactionc.Table <MyCheckbox>())
                    {
                        string imgfilename = sqlitedir.Path + "/" + e.Name;
                        myCollection.Add(imgfilename);
                        Toast.MakeText(Application.Context, imgfilename, ToastLength.Short).Show();

                        using (FileStream fileStream = new FileStream(imgfilename, FileMode.Open, FileAccess.Read))
                        {
                            MemoryStream   memoryStream = new MemoryStream();
                            CloudBlockBlob blob         = container.GetBlockBlobReference(e.Name);
                            fileStream.CopyTo(memoryStream);
                            memoryStream.Position = 0;

                            Toast.MakeText(Application.Context, memoryStream.Length.ToString(), ToastLength.Short).Show();


                            using (memoryStream)
                            {
                                await blob.UploadFromStreamAsync(memoryStream);

                                Toast toast = Toast.MakeText(Application.Context, "Upload Complete", ToastLength.Short);
                                toast.Show();
                            }
                        }
                        countidx++;
                    }
                    connactionc.Close();
                }

                catch (Java.Lang.Exception e)
                {
                }
            }
            catch (Java.Lang.Exception eerror)
            { }
        }
예제 #22
0
 public IEnumerable <PChapter> GetAllChapters()
 {
     return(_connection.Table <PChapter>());
 }
예제 #23
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            //Set the Activity's view to our list layout
            SetContentView(Resource.Layout.ListActivity);
            //sqlite for sas azure

            ISQLiteConnection conn = null;

            ISQLiteConnectionFactory factory = new MvxDroidSQLiteConnectionFactory();

            var    sqlitedir           = new Java.IO.File(global::Android.OS.Environment.GetExternalStoragePublicDirectory(global::Android.OS.Environment.DirectoryPictures), "Boruto");
            string filenameaction      = sqlitedir.Path + "/mysqlitesas.db";
            string filenameactionazure = sqlitedir.Path + "/mysqlitesasazure.db";

            conn = factory.Create(filenameaction);
            conn.CreateTable <Azurecon>();
            var myuserid = "";

            foreach (var e in conn.Table <Azurecon>())
            {
                myuserid = e.UserId;
            }
            conn.Close();

            //sqlite for sas azure end

            //Create our adapter
            listAdapter = new CustomListAdapter(this);
            //Find the listview reference
            var listView = FindViewById <ListView>(Resource.Id.listView);

            //Hook up our adapter to our ListView
            listView.Adapter = listAdapter;
            //Wire up the click event
            //listView.ItemClick += new EventHandler<ItemEventArgs>(listView_ItemClick);
            Button deleteselectedfiles = FindViewById <Button>(Resource.Id.deleteselectfiles);

            deleteselectedfiles.Click += async delegate
            {
                //Delete files in sqlite table MyImage and in sdcard
                var myfiledir = new Java.IO.File(global::Android.OS.Environment.GetExternalStoragePublicDirectory(global::Android.OS.Environment.DirectoryPictures), "Boruto");
                ISQLiteConnection        conncf       = null;
                ISQLiteConnection        connactiondf = null;
                ISQLiteConnectionFactory factorydf    = new MvxDroidSQLiteConnectionFactory();


                string sqlfilenamed = sqlitedir.Path + "/mysqliteaction.db";
                //Toast.MakeText(Application.Context, filename, ToastLength.Long).Show();

                connactiondf = factorydf.Create(sqlfilenamed);
                connactiondf.CreateTable <MyCheckbox>();

                List <string>    myCollection = new List <string>();
                var              countidx     = 0;
                HashSet <string> myimgspath   = new HashSet <string>();
                foreach (var e in connactiondf.Table <MyCheckbox>())
                {
                    string imgfilename = "file://" + sqlitedir.Path + "/" + e.Name;
                    myimgspath.Add(imgfilename);
                    var myfilepath = myfiledir + "/" + e.Name;
                    if (File.Exists(myfilepath))
                    {
                        File.Delete(myfilepath);
                    }
                }
                connactiondf.Close();

                List <string> myimglistdeletecmd = new List <string>();
                var           myvaridx           = 0;
                foreach (string permyimg in myimgspath)
                {
                    var myquerycmd = "Delete from Myimage where Imagepath = '" + permyimg + "'";
                    myimglistdeletecmd.Add(myquerycmd);
                }
                ISQLiteConnection connactioncf = null;

                ISQLiteConnectionFactory factorycf = new MvxDroidSQLiteConnectionFactory();
                var    sqlitedirc      = new Java.IO.File(global::Android.OS.Environment.GetExternalStoragePublicDirectory(global::Android.OS.Environment.DirectoryPictures), "Boruto");
                string filenameactionc = sqlitedirc.Path + "/mysqliteimage.db";
                connactioncf = factorycf.Create(filenameactionc);
                connactioncf.CreateTable <Myimage>();


                //var permyimgfile = new Myimage(){Date = "30-12-2016",Imagepath = myimgfile};

                //myconn.CreateCommand("Delete from Myimage where Imagepath ='" + myimgfile + "'");
                //myconn.Dispose();
                //myconn.Commit();
                //connactioncf.CreateCommand("Delete from Myimage where Imagepath ='" + "file:///storage/emulated/0/Pictures/Boruto/myPhoto_69d38ce2-0a96-41ed-884d-021a24890f88.jpg" + "'").ExecuteNonQuery();
                foreach (var cmd in myimglistdeletecmd)
                {
                    connactioncf.CreateCommand(cmd).ExecuteNonQuery();
                }

                connactioncf.Commit();
                connactioncf.Close();
            };
            Button uploadtoazure = FindViewById <Button>(Resource.Id.uploadtoazure);

            uploadtoazure.Click += async delegate
            {
                uploadtoazure.Text = string.Format("{0} clicks!", count++);
                //Get userid from sqlite db file

                ISQLiteConnection connacc = null;

                ISQLiteConnectionFactory factoryacc = new MvxDroidSQLiteConnectionFactory();

                var    sqlitediracc      = new Java.IO.File(global::Android.OS.Environment.GetExternalStoragePublicDirectory(global::Android.OS.Environment.DirectoryPictures), "Boruto");
                string filenameactionacc = sqlitediracc.Path + "/mysqlitesas.db";

                connacc = factoryacc.Create(filenameactionacc);
                connacc.CreateTable <Azurecon>();
                var useridconnc = "";
                foreach (var e in connacc.Table <Azurecon>())
                {
                    useridconnc = e.UserId;
                }
                connacc.Close();
                //myuserid = "115708452302383620142";

                var myurl    = "http://93.118.34.239:8888/" + useridconnc;
                Uri azureuri = new Uri(myurl);


                HttpWebRequest request = new HttpWebRequest(azureuri);
                request.Method = "GET";


                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                using (StreamReader sr = new StreamReader(response.GetResponseStream()))
                {
                    string responseString = sr.ReadToEnd();
                    Toast.MakeText(this, "Connect SAS String:" + responseString, ToastLength.Short).Show();
                    try
                    {
                        await UseContainerSAS(responseString);
                    }
                    catch {
                    }
                }
            };
        }
예제 #24
0
 public Promotion GetPromotionByIndex(int index)
 {
     return(_connection.Table <Promotion>()
            .Where(x => x.Index == index)
            .FirstOrDefault());
 }
예제 #25
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            RequestWindowFeature(Android.Views.WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.cropimage);

            imageView = FindViewById <CropImageView>(Resource.Id.image);

            showStorageToast(this);

            Bundle extras = Intent.Extras;

            if (extras != null)
            {
                imagePath = extras.GetString("image-path");

                saveUri = getImageUri(imagePath);
                if (extras.GetString(MediaStore.ExtraOutput) != null)
                {
                    saveUri = getImageUri(extras.GetString(MediaStore.ExtraOutput));
                }

                bitmap = getBitmap(imagePath);

                aspectX = extras.GetInt("aspectX");
                aspectY = extras.GetInt("aspectY");
                outputX = extras.GetInt("outputX");
                outputY = extras.GetInt("outputY");
                scale   = extras.GetBoolean("scale", true);
                scaleUp = extras.GetBoolean("scaleUpIfNeeded", true);

                if (extras.GetString("outputFormat") != null)
                {
                    outputFormat = Bitmap.CompressFormat.ValueOf(extras.GetString("outputFormat"));
                }
            }

            if (bitmap == null)
            {
                Finish();
                return;
            }

            Window.AddFlags(WindowManagerFlags.Fullscreen);


            FindViewById <Button>(Resource.Id.discard).Click += (sender, e) => { SetResult(Result.Canceled); Finish(); };
            //FindViewById<Button>(Resource.Id.save).Click += async delegate { onSaveClicked(); };

            FindViewById <Button>(Resource.Id.save).Click += async delegate {
                if (Saving)
                {
                    return;
                }

                Saving = true;

                var r = Crop.CropRect;

                int width  = r.Width();
                int height = r.Height();

                Bitmap croppedImage = Bitmap.CreateBitmap(width, height, Bitmap.Config.Rgb565);
                {
                    Canvas canvas  = new Canvas(croppedImage);
                    Rect   dstRect = new Rect(0, 0, width, height);
                    canvas.DrawBitmap(bitmap, r, dstRect, null);
                }

                // If the output is required to a specific size then scale or fill
                if (outputX != 0 && outputY != 0)
                {
                    if (scale)
                    {
                        // Scale the image to the required dimensions
                        Bitmap old = croppedImage;
                        croppedImage = Util.transform(new Matrix(),
                                                      croppedImage, outputX, outputY, scaleUp);
                        if (old != croppedImage)
                        {
                            old.Recycle();
                        }
                    }
                    else
                    {
                        // Don't scale the image crop it to the size requested.
                        // Create an new image with the cropped image in the center and
                        // the extra space filled.
                        Bitmap b = Bitmap.CreateBitmap(outputX, outputY,
                                                       Bitmap.Config.Rgb565);
                        Canvas canvas = new Canvas(b);

                        Rect srcRect = Crop.CropRect;
                        Rect dstRect = new Rect(0, 0, outputX, outputY);

                        int dx = (srcRect.Width() - dstRect.Width()) / 2;
                        int dy = (srcRect.Height() - dstRect.Height()) / 2;

                        // If the srcRect is too big, use the center part of it.
                        srcRect.Inset(Math.Max(0, dx), Math.Max(0, dy));

                        // If the dstRect is too big, use the center part of it.
                        dstRect.Inset(Math.Max(0, -dx), Math.Max(0, -dy));

                        // Draw the cropped bitmap in the center
                        canvas.DrawBitmap(bitmap, srcRect, dstRect, null);

                        // Set the cropped bitmap as the new bitmap
                        croppedImage.Recycle();
                        croppedImage = b;
                    }
                }

                // Return the cropped image directly or save it to the specified URI.
                Bundle myExtras = Intent.Extras;

                if (myExtras != null &&
                    (myExtras.GetParcelable("data") != null || myExtras.GetBoolean("return-data")))
                {
                    Bundle extrasas = new Bundle();
                    extras.PutParcelable("data", croppedImage);
                    SetResult(Result.Ok,
                              (new Intent()).SetAction("inline-data").PutExtras(extrasas));
                    Finish();
                }
                else
                {
                    //Toast.MakeText(Application.Context, saveUri.ToString(), ToastLength.Long).Show();
                    //Toast.MakeText(Application.Context, "Upload Complete", ToastLength.Long).Show();

                    //Upload to Azure
                    ISQLiteConnection connacc = null;

                    ISQLiteConnectionFactory factoryacc = new MvxDroidSQLiteConnectionFactory();

                    var    sqlitediracc      = new Java.IO.File(global::Android.OS.Environment.GetExternalStoragePublicDirectory(global::Android.OS.Environment.DirectoryPictures), "Boruto");
                    string filenameactionacc = sqlitediracc.Path + "/mysqlitesas.db";

                    connacc = factoryacc.Create(filenameactionacc);
                    connacc.CreateTable <Azurecon>();
                    var useridconnc = "";
                    foreach (var eu in connacc.Table <Azurecon>().Where(eu => eu.Sastring == "using"))
                    {
                        useridconnc = eu.UserId;
                    }
                    connacc.Close();
                    //myuserid = "115708452302383620142";
                    useridconnc = useridconnc.Replace("@", "");
                    useridconnc = useridconnc.Replace(".", "");
                    var myurl    = "http://93.118.34.239:8888/" + useridconnc;
                    Uri azureuri = new Uri(myurl);


                    HttpWebRequest request = new HttpWebRequest(azureuri);
                    request.Method = "GET";


                    HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                    try
                    {
                        using (StreamReader sr = new StreamReader(response.GetResponseStream()))
                        {
                            string responseString = sr.ReadToEnd();
                            Toast.MakeText(this, saveUri.ToString(), ToastLength.Short).Show();
                            try
                            {
                                await UseContainerSAS(responseString, saveUri.ToString());
                            }
                            catch
                            {
                            }
                        }
                    }
                    catch {
                    }
                    //End Upload to Azure

                    Bitmap b = croppedImage;
                    BackgroundJob.StartBackgroundJob(this, null, "Saving image", () => saveOutput(b), mHandler);
                }
            };

            FindViewById <Button>(Resource.Id.rotateLeft).Click += (o, e) =>
            {
                bitmap = Util.rotateImage(bitmap, -90);
                RotateBitmap rotateBitmap = new RotateBitmap(bitmap);
                imageView.SetImageRotateBitmapResetBase(rotateBitmap, true);
                addHighlightView();
            };

            FindViewById <Button>(Resource.Id.rotateRight).Click += (o, e) =>
            {
                bitmap = Util.rotateImage(bitmap, 90);
                RotateBitmap rotateBitmap = new RotateBitmap(bitmap);
                imageView.SetImageRotateBitmapResetBase(rotateBitmap, true);
                addHighlightView();
            };

            imageView.SetImageBitmapResetBase(bitmap, true);
            addHighlightView();
        }
예제 #26
0
 public virtual async Task <IEnumerable <T> > Get()
 {
     return(_sqliteConnection.Table <T>().ToList());
 }
 /// <summary>
 /// テーブルに保存されている全てのEntityを取得
 /// </summary>
 /// <returns>The all.</returns>
 public List <T> FindAll()
 {
     return(_connection.Table <T> ().ToList());
 }
예제 #28
0
 public List <Scores> GetAll(Levels lvl)
 {
     return(connection.Table <Scores>().Where(x => x.Level == (int)lvl).ToList());
 }
        public T this[int index]
        {
#warning this definitely isn't efficient!
            get { return(_connection.Table <T>().OrderBy(_sortOrder).Skip(index).FirstOrDefault()); }
            set { throw new NotImplementedException(); }
        }
 public List <T> SearchForLocalTable <T>(System.Linq.Expressions.Expression <Func <T, bool> > predicate) where T : new()
 {
     return(_liteConnection.Table <T>().Where(predicate).ToList());
 }
예제 #31
0
 /*
  * public void CreateDB(){
  *      _connection.DropTable<Person> ();
  *      _connection.CreateTable<Person> ();
  *
  *      _connection.InsertAll (new[]{
  *              new Person{
  *                      Id = 1,
  *                      Name = "Tom",
  *                      Surname = "Perez",
  *                      Age = 56
  *              },
  *              new Person{
  *                      Id = 2,
  *                      Name = "Fred",
  *                      Surname = "Arthurson",
  *                      Age = 16
  *              },
  *              new Person{
  *                      Id = 3,
  *                      Name = "John",
  *                      Surname = "Doe",
  *                      Age = 25
  *              },
  *              new Person{
  *                      Id = 4,
  *                      Name = "Roberto",
  *                      Surname = "Huertas",
  *                      Age = 37
  *              },
  *      });
  * }
  */
 public IEnumerable <T> GetItems <T>() where T : new()
 {
     return(_connection.Table <T>());
 }