Exemple #1
0
        public async Task testttttt(DateTime from)
        {
            List <ScreenShot> listscreenshots = null;

            try
            {
                screenShotPCService = FactorySingleton.Factory.Get <ScreenShotPCService>();
                listscreenshots     = (await screenShotPCService.GetSQLScreenShot(from))
                                      .ToList();

                if (listscreenshots != null && listscreenshots.Count != 0)
                {
                    //byte[] img =  utils.ObjectToByteArray(listscreenshots[0].ImageScreen);
                    byte[] img = (byte[])listscreenshots[0].ImageScreen;

                    if (img != null)
                    {
                        System.IO.File.WriteAllBytes("Foo.jpg", img.ToArray());
                        // System.IO.File.WriteAllBytes("sevenItems.jpg", sevenItems.ToArray());
                    }
                }
            }
            catch (Exception e)
            {
                var err = e.Message;
            }
        }
Exemple #2
0
        private async Task GetLisScreenShotFromLocalSql(ListBox lb, DateTime from, DateTime to)
        {
            lb.Items.Clear();
            List <ScreenShot> listscreenshots = null;

            try
            {
                screenShotPCService = FactorySingleton.Factory.Get <ScreenShotPCService>();
                listscreenshots     = (await screenShotPCService.GetSQLScreenShot(from, to))
                                      .ToList();
            }
            catch (Exception e)
            {
                var err = e.Message;
            }
            if (listscreenshots != null && listscreenshots.Count != 0)
            {
                lb.Items.Add(string.Format("Founds {0} records for {1}", listscreenshots.Count, DateTime.Now.Date.ToShortDateString()));
                foreach (var screenshot in listscreenshots)
                {
                    lb.Items.Add(string.Format("{0} - {1} ID = {2} synch = {3}", screenshot, screenshot, screenshot.GUID, screenshot.IsSynchronized));
                }
            }
            else
            {
                lb.Items.Add("No screenshot by data!");
            }
        }
Exemple #3
0
        private async Task <int> UpdateOrCreateScreenShotToSql(long queueCommandID)
        {
            int        result     = 0;
            ScreenShot screenshot = new ScreenShot()
            {
                dateCreate     = DateTime.Now,
                GUID           = Guid.NewGuid().ToString(),
                IsActive       = true,
                IsSynchronized = false,
                QueueCommandID = queueCommandID,
                ImageScreen    = utils.ScreenShot.MakeScreenShot()
            };

            //        utils.ScreenShot.MakeScreenShot(Application.StartupPath); // need delete - no need save screenshot in disk
            try
            {
                screenShotPCService = FactorySingleton.Factory.Get <ScreenShotPCService>();
                result = await screenShotPCService.SaveScreenShotToSql(screenshot);
            }
            catch (Exception e)
            {
                var err = e.Message;
                result = -1;
            }
            return(result);
        }
Exemple #4
0
        public async Task <int> SyncSqlWithRest(DeviceModel device, DateTime date)
        {
            int result  = 0;
            int result2 = 0;

            try
            {
                powerpcService = FactorySingleton.Factory.Get <PowerPcService>();
                result         = await powerpcService.SynchronizePowerTimeRest(device, date);

                screenShotPCService = FactorySingleton.Factory.Get <ScreenShotPCService>();
                result2             = await screenShotPCService.SynchronizeScreenShotRest(device, date);

                if (result2 > 0)
                {
                    result += result2;
                }
            }
            catch (Exception ex)
            {
                var err = ex.Message;
                result = -55;
            }
            return(result);
        }