Beispiel #1
0
        public async Task <int> InternalAddDeviceEventLog(string[] _deviceEventLogData)
        {
            int _resultFlag = 0;

            try
            {
                ParseObject DevicesEventLogTable = new ParseObject("DevicesEventLog");

                DevicesEventLogTable.Add("EventType", _deviceEventLogData[0].ToString().Trim());
                DevicesEventLogTable.Add("EventName", _deviceEventLogData[1].ToString().Trim());
                DevicesEventLogTable.Add("EventDeviceID", _deviceEventLogData[2].ToString().Trim());
                DevicesEventLogTable.Add("EventAreaID", _deviceEventLogData[3].ToString().Trim());
                DevicesEventLogTable.Add("EventValue", _deviceEventLogData[4].ToString().Trim());

                await DevicesEventLogTable.SaveAsync();

                _resultFlag = 1;
            }
            catch (Exception)
            {
                _resultFlag = 0;
            }

            return(_resultFlag);
        }
Beispiel #2
0
        public async Task <int> InternalAddSchedule(string[] _scheduleData)
        {
            int _resultFlag = 0;

            try
            {
                ParseObject ScheduleTable = new ParseObject("ScheduleRecurrence");

                ScheduleTable.Add("DeviceID", _scheduleData[0].ToString().Trim());
                ScheduleTable.Add("DeviceName", _scheduleData[1].ToString().Trim());
                ScheduleTable.Add("RecurrenceType", _scheduleData[2].ToString().Trim());
                ScheduleTable.Add("RecurrenceHourMinSec", _scheduleData[3].ToString().Trim());
                ScheduleTable.Add("RecurrenceDayDate", _scheduleData[4].ToString().Trim());
                ScheduleTable.Add("RecurrenceDayWeek", _scheduleData[5].ToString().Trim());
                ScheduleTable.Add("ScheduleCase", _scheduleData[6].ToString().Trim());
                ScheduleTable.Add("ScheduleType", _scheduleData[7].ToString().Trim());
                ScheduleTable.Add("ScheduleDone", Convert.ToBoolean(_scheduleData[8].ToString().Trim()));

                await ScheduleTable.SaveAsync();

                _resultFlag = 1;
            }
            catch (Exception)
            {
                _resultFlag = 0;
            }

            return(_resultFlag);
        }
Beispiel #3
0
        private async void onClickEditSiguiente(object sender, RoutedEventArgs e)
        {
            string organizarFecha = editFecha.Date.Day + "/" + editFecha.Date.Month + "/" + editFecha.Date.Year;
            string organizarHora  = configurarHora(editHora.Time.Hours, editHora.Time.Minutes);

            edtProgressRing.IsActive = true;
            plan["nombre"]           = editNombre.Text;
            plan["descripcion"]      = editDescripcion.Text;

            plan["fecha"]     = organizarFecha + " " + organizarHora;
            plan["direccion"] = NombreLugarTxt.Text;
            plan["lugar"]     = gPoint;
            if (photo != null)
            {
                var bytes = await GetBtyeFromFile(photo);

                ParseFile parseFile = new ParseFile("editdefault" + editHora.Time.Minutes + ".jpg", bytes, "image/jpeg");
                plan["imagen"] = parseFile;
            }
            if (nuevo_existente == 2) // crear nuevo lugar
            {
                ParseObject objectLugar = new ParseObject("Lugares");
                objectLugar.Add("nombre", NombreLugarTxt.Text);
                objectLugar.Add("direccion", NombreLugarTxt.Text);
                objectLugar.Add("ubicacion", gPoint);
                await objectLugar.SaveAsync();
            }
            try
            {
                await plan.SaveAsync();

                edtProgressRing.IsActive = false;
                rootFrame = Window.Current.Content as Frame;
                rootFrame.Navigate(typeof(MainPage));
            }
            catch
            {
                var dialog2 = new Windows.UI.Popups.MessageDialog("Error al editar el plan");
                dialog2.Commands.Add(new Windows.UI.Popups.UICommand("Aceptar")
                {
                    Id = 1
                });
                var result2 = await dialog2.ShowAsync();
            }
        }
Beispiel #4
0
        public void TestAdd()
        {
            IObjectState state = new MutableObjectState {
                ObjectId   = "waGiManPutr4Pet1r",
                ClassName  = "Pagi",
                CreatedAt  = new DateTime(),
                ServerData = new Dictionary <string, object>()
                {
                    { "username", "kevin" },
                    { "sessionToken", "se551onT0k3n" }
                }
            };
            ParseObject obj = ParseObjectExtensions.FromState <ParseObject>(state, "Omitted");

            Assert.Throws <ArgumentException>(() => obj.Add("username", "kevin"));

            obj.Add("zeus", "bewithyou");
            Assert.AreEqual("bewithyou", obj["zeus"]);
        }
Beispiel #5
0
        public async Task OperateNullProperty()
        {
            ParseObject obj = new ParseObject("Hello");

            obj.Increment("intValue", 123);
            obj.Increment("intValue", 321);
            obj.Add("intList", 1);
            obj.Add("intList", 2);
            obj.Add("intList", 3);
            await obj.Save();

            WriteLine(obj["intValue"]);
            Assert.AreEqual(obj["intValue"], 444);
            List <object> intList = obj["intList"] as List <object>;

            WriteLine(intList.Count);
            Assert.AreEqual(intList.Count, 3);
            Assert.AreEqual(intList[0], 1);
            Assert.AreEqual(intList[1], 2);
            Assert.AreEqual(intList[2], 3);
        }
Beispiel #6
0
        public async Task <int> InternalAddDeviceAlarmConfiguration(string[] _deviceAlarmConfigData)
        {
            int _resultFlag = 0;

            try
            {
                ParseObject DevicesAlarmConfigTable = new ParseObject("DevicesAlarmConfiguration");

                DevicesAlarmConfigTable.Add("DeviceID", _deviceAlarmConfigData[0].Trim());
                DevicesAlarmConfigTable.Add("AlarmValue", _deviceAlarmConfigData[1].Trim());
                DevicesAlarmConfigTable.Add("ConfigType", _deviceAlarmConfigData[2].Trim());

                await DevicesAlarmConfigTable.SaveAsync();

                _resultFlag = 1;
            }
            catch (Exception)
            {
                _resultFlag = 0;
            }

            return(_resultFlag);
        }
        public async Task <int> InternalAddHouseArea(string[] _houseAreaData)
        {
            int _resultFlag = 0;

            try
            {
                ParseObject _houseAreaTable = new ParseObject("HouseArea");

                _houseAreaTable.Add("AreaID", _houseAreaData[0].ToString().Trim());
                _houseAreaTable.Add("AreaName", _houseAreaData[1].ToString().Trim());
                _houseAreaTable.Add("AreaStatus", Convert.ToBoolean(_houseAreaData[2].ToString().Trim()));

                await _houseAreaTable.SaveAsync();

                _resultFlag = 1;
            }
            catch (Exception)
            {
                _resultFlag = 0;
            }

            return(_resultFlag);
        }
        public async Task <int> InternalAddUser(string[] _userData)
        {
            int _resultFlag = 0;

            try
            {
                ParseObject UsersTable = new ParseObject("Users");

                UsersTable.Add("UserName", _userData[0].ToString().Trim());
                UsersTable.Add("Password", _userData[1].ToString().Trim());
                UsersTable.Add("Role", _userData[2].ToString().Trim());


                await UsersTable.SaveAsync();

                _resultFlag = 1;
            }
            catch (Exception)
            {
                _resultFlag = 0;
            }

            return(_resultFlag);
        }
Beispiel #9
0
        public async Task <int> InternalAddDevice(string[] _deviceData)
        {
            int _resultFlag = 0;

            try
            {
                ParseObject DevicesTable = new ParseObject("Devices");

                DevicesTable.Add("DeviceID", _deviceData[0].ToString().Trim());
                DevicesTable.Add("DeviceName", _deviceData[1].ToString().Trim());
                DevicesTable.Add("DeviceAssignedTo", _deviceData[2].ToString().Trim());
                DevicesTable.Add("DeviceStatus", Convert.ToBoolean(_deviceData[3].ToString().Trim()));

                await DevicesTable.SaveAsync();

                _resultFlag = 1;
            }
            catch (Exception)
            {
                _resultFlag = 0;
            }

            return(_resultFlag);
        }
Beispiel #10
0
        private async void ElementClick(MapControl sender, MapElementClickEventArgs args)
        {
            string dir     = null;
            double ArgsLat = 0;
            double ArgsLon = 0;

            foreach (var e in args.MapElements)
            {
                var icon = e as MapIcon;
                dir     = icon.Title;
                ArgsLat = icon.Location.Position.Latitude;
                ArgsLon = icon.Location.Position.Longitude;
            }
            if (!dir.Equals("MiPosicion"))
            {
                var dialog = new Windows.UI.Popups.MessageDialog("Elegir Lugar");

                dialog.Commands.Add(new Windows.UI.Popups.UICommand("Aceptar")
                {
                    Id = 1
                });
                dialog.Commands.Add(new Windows.UI.Popups.UICommand("Cancelar")
                {
                    Id = 0
                });

                var result = await dialog.ShowAsync();

                if (result.Id.Equals(1))
                {
                    progressRing.IsActive = true;

                    StorageFile file  = plan.ImagenPlan;
                    var         bytes = await GetBtyeFromFile(file);

                    ParseFile parseFile = new ParseFile("defaultimg.jpg", bytes, "image/jpeg");

                    ParseObject parseObject = new ParseObject("Plan");


                    parseObject.Add("nombre", plan.NombrePlan);
                    parseObject.Add("descripcion", plan.DescripcionPlan);
                    parseObject.Add("fecha", plan.FechaPlan + " " + plan.HoraPlan);
                    parseObject.Add("id_user", ParseUser.CurrentUser);
                    parseObject.Add("imagen", parseFile);

                    ParseGeoPoint geoLugar = new ParseGeoPoint(ArgsLat, ArgsLon);
                    parseObject.Add("lugar", geoLugar);

                    parseObject.Add("direccion", dir);

                    if (crearLugar == 1)
                    {
                        ParseObject objectLugar = new ParseObject("Lugares");
                        objectLugar.Add("nombre", titulo_lugar);
                        objectLugar.Add("direccion", dir);
                        objectLugar.Add("ubicacion", geoLugar);
                        await objectLugar.SaveAsync();

                        crearLugar = -1;
                    }

                    try
                    {
                        await parseObject.SaveAsync();

                        progressRing.IsActive = false;
                        rootFrame             = Window.Current.Content as Frame;
                        rootFrame.Navigate(typeof(MainPage));
                    }
                    catch
                    {
                        var dialog2 = new Windows.UI.Popups.MessageDialog("Error al crear el plan, intentalo de nuevo");
                        dialog2.Commands.Add(new Windows.UI.Popups.UICommand("Aceptar")
                        {
                            Id = 1
                        });
                        var result2 = await dialog2.ShowAsync();

                        progressRing.IsActive = false;
                    }
                }
            }
        }