Beispiel #1
0
        private async Task <bool> CacheDevice()
        {
            IBRServiceContracts.CWriteValueCollection collection = new IBRServiceContracts.CWriteValueCollection()
            {
                Values = Values.Values.ToArray(),
            };

            db.CacheDeviceToCreate(project, workinglayer, uidowner, uidcdev, collection, tempuid, ownername, ownerpic, this.Description);

            this.ShowToast(Services.TranslateExtension.TranslateText("item_cached"));
            await this.Navigation.PopAsync(true);

            return(true);
        }
Beispiel #2
0
        public IBRServiceContracts.CWriteValueCollection GetAllCachedSpecsFromOwner(string uid, string project, string overlay)
        {
            List <IBRServiceContracts.CWriteValue> list = new List <IBRServiceContracts.CWriteValue>();

            IBRServiceContracts.CWriteValueCollection values = new IBRServiceContracts.CWriteValueCollection();

            try
            {
                lock (m_DB)
                {
                    SqliteCommand command = m_DB.CreateCommand();
                    command.CommandText = string.Format("SELECT nestedname, value, description FROM SpecCache where (specowner = '{0}' and project = '{1}' and overlay = '{2}')", uid, project, overlay);

                    var reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        IBRServiceContracts.CWriteValue obj = new IBRServiceContracts.CWriteValue
                        {
                            NestedName   = reader.GetString(0),
                            WebSystemUID = uid,
                            NewValue     = reader.GetString(1),
                            Description  = reader.GetString(2)
                        };

                        list.Add(obj);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            values.Values = list.ToArray();

            return(values);
        }
Beispiel #3
0
        private async Task <bool> SaveDeviceToComos()
        {
            IBRServiceContracts.CWriteValueCollection collection = new IBRServiceContracts.CWriteValueCollection()
            {
                Values = Values.Values.ToArray(),
            };

            if (uidowner.Equals("DUMMY_INCIDENT") && collection.Values.Any(value => value.NewValue.Equals("")))
            {
                this.ShowToast("Se deben completar todos los campos para guardar el evento");
                return(false);
            }
            else if (!uidowner.Equals("DUMMY_INCIDENT") && collection.Values.SkipWhile(value => value.NestedName.Equals("Z10T00002.Z001A")).Any(value => value.NewValue.Equals("")))
            {
                this.ShowToast("Se deben completar todos los campos para guardar el evento");
                return(false);
            }
            else
            {
                this.ShowSpinner(Services.TranslateExtension.TranslateText("creating_item"));

                var m_Http = Services.XServices.Instance.GetService <HttpClient>();
                ComosWebSDK.brcomosweb.ComosBRWeb m_comosbrweb = new ComosWebSDK.brcomosweb.ComosBRWeb(m_Http);

                try
                {
                    if (Description == "")
                    {
                        Description = Services.TranslateExtension.TranslateText("new_incident");
                    }

                    TResult <string> result;

                    if (uidowner.Equals("DUMMY_INCIDENT") && equipmentVerified.Text.Equals(Constants.OkIcon))
                    {
                        result = await m_comosbrweb.CreateComosDevice(collection, servername, project, workinglayer, language, verifiedSystemUid, uidcdev, user, Description);
                    }
                    else if (uidowner.Equals("DUMMY_INCIDENT") && !equipmentVerified.Text.Equals(Constants.OkIcon))
                    {
                        var result2 = await App.Current.MainPage.DisplayAlert("Guardar", "Desea guardar el aviso aunque el equipo donde se guardará no exista?", "Si", "No");

                        if (result2)
                        {
                            result = await m_comosbrweb.CreateComosDevice(collection, servername, project, workinglayer, language, uidowner, uidcdev, user, Description);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        result = await m_comosbrweb.CreateComosDevice(collection, servername, project, workinglayer, language, uidowner, uidcdev, user, Description);
                    }

                    this.HideSpinner();


                    try
                    {
                        if (!result.Status)
                        {
                            this.ShowToast("Error en la conexión con COMOS. Contacte al administrador. Referencia: COMOS.IO");
                        }
                        else
                        {
                            if (result.data != "")
                            {
                                db.DeleteCachedDevice(tempuid);
                                this.ShowToast(Services.TranslateExtension.TranslateText("item_created"));

                                this.ShowSpinner(Services.TranslateExtension.TranslateText("saving"));
                                await midiacontrol.UploadAllPicturesFromObject(tempuid, result.data);

                                await midiacontrol.UploadAllAudiosFromObject(tempuid, result.data);

                                this.HideSpinner();
                            }
                            else
                            {
                                this.ShowToast("Error en la conexión con COMOS. Contacte al administrador. Referencia: COMOS.IO");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        this.ShowToast(ex.Message);
                        await CacheDevice();
                    }
                    finally
                    {
                        await this.Navigation.PopAsync(true);
                    }
                }
                catch (Exception ex2)
                {
                    await App.Current.MainPage.DisplayAlert("Error", ex2.Message, "OK");

                    this.HideSpinner();
                }

                return(true);
            }
        }