Esempio n. 1
0
        public bool Insert()
        {
            Query oQuery = new Query( "api/institution/history" );

            oQuery.RequestParameters = this._data;

            try
            {
                oQuery.SendRequestPOST();

                if ( oQuery.ResponseStatusCode == HttpStatusCode.NotModified )
                {
                    throw new ArgumentNullException( oQuery.ResponseContent, "NO SE REALIZÓ EL REGISTRO" );
                }
                else if ( oQuery.ResponseStatusCode != HttpStatusCode.Accepted )
                {
                    throw new ArgumentNullException( "Error en el Servidor la consulta a sido detenida" );
                }

                return Convert.ToBoolean( oQuery.ResponseContent.Trim() );
            }
            catch ( Exception e )
            {
                this.ExceptionHistory = e.Message;
                return false;
            }
        }
Esempio n. 2
0
        public bool Insert()
        {
            Query oQuery = new Query( "api/control/material/" + this._data.CodigoMaterial + "/income" );

            oQuery.RequestParameters = this._data;

            try
            {
                oQuery.SendRequestPOST();

                if ( oQuery.ResponseStatusCode == HttpStatusCode.InternalServerError )
                    throw new ArgumentNullException( "Existe un error en el servidor:\n", "Error en el Servidor" );
                else if ( oQuery.ResponseStatusCode == HttpStatusCode.NotFound )
                    throw new ArgumentNullException( "No se encontro recurso al cual acceder", "Recurso no encontrado" );

                msgResponse resp = JsonConvert.DeserializeObject<msgResponse>( oQuery.ResponseContent );

                if ( oQuery.ResponseStatusCode == HttpStatusCode.BadRequest )
                    throw new InvalidOperationException( resp.message );

                return Convert.ToBoolean( resp.data );
            }
            catch ( Exception e )
            {
                this.EXception = e.Message;
                return false;
            }
        }
Esempio n. 3
0
        public List<tMaterialSalon> AsignMaterialsToAula( int CodigoSalon, int CodigoMaterial, int Cantidad )
        {
            Query oQuery = new Query( string.Format( "api/control/aula/{0}/material/{1}/quantity/{2}", CodigoSalon, CodigoMaterial, Cantidad ) );

            try
            {
                oQuery.SendRequestPOST();

                if ( oQuery.ResponseStatusCode == HttpStatusCode.InternalServerError )
                    throw new ArgumentNullException( "Existe un error en el servidor:\n", "Error en el Servidor" );
                else if ( oQuery.ResponseStatusCode == HttpStatusCode.NotFound )
                    throw new ArgumentNullException( "No se encontro recurso al cual acceder", "Recurso no encontrado" );

                msgResponse resp = JsonConvert.DeserializeObject<msgResponse>( oQuery.ResponseContent );

                if ( oQuery.ResponseStatusCode == HttpStatusCode.BadRequest )
                    throw new InvalidOperationException( resp.message );

                return JsonConvert.DeserializeObject<List<tMaterialSalon>>( resp.data );
            }
            catch ( Exception ex )
            {
                this._ExceptionCM = ex.Message;
                return null;
            }
        }
Esempio n. 4
0
        public string Insert()
        {
            Query oQuery = new Query( "api/institution/information" );

            oQuery.RequestParameters = this._data;

            try
            {
                oQuery.SendRequestPOST();

                if ( oQuery.ResponseStatusCode == HttpStatusCode.NotModified )
                {
                    throw new ArgumentNullException( "La Acción ha podido concluir, verifique sus datos y vuelva a intentarlo", "Regristro ó Modificación" );
                }
                else if ( oQuery.ResponseStatusCode != HttpStatusCode.Created )
                {
                    throw new ArgumentNullException( "Error en el Servidor la consulta a sido detenida" );
                }

                return (oQuery.ResponseContent.Replace('"', ' ') ).Trim();
            }
            catch ( Exception e )
            {
                this.ExceptionInfo = e.Message;
                return null;
            }
        }
Esempio n. 5
0
        public bool ConfirmLogged()
        {
            Query oQuery = new Query( "api/prslog/confirm" );

            try
            {
                object arq = new object[2] { this.getAppSettings( "User" ), 1 };

                oQuery.RequestParameters = arq;

                oQuery.SendRequestPOST();

                if ( oQuery.ResponseStatusCode == HttpStatusCode.InternalServerError )
                    throw new ArgumentNullException( "Existe un error en el servidor:\n" + this._msgExceptionLogin, "Error en el Servidor" );
                else if ( oQuery.ResponseStatusCode == HttpStatusCode.NotFound )
                    throw new ArgumentNullException( "No se encontro recurso al cual acceder", "Recurso no encontrado" );

                msgResponse resp = JsonConvert.DeserializeObject<msgResponse>( oQuery.ResponseContent );

                if ( oQuery.ResponseStatusCode == HttpStatusCode.BadRequest )
                    throw new InvalidOperationException( resp.message );

                LoginData obj = JsonConvert.DeserializeObject<LoginData>( resp.data );

                if ( obj.UserLevel != "0" && obj.UserLevel != "1" && obj.UserLevel != "2" )
                    throw new InvalidOperationException( "TU NIVEL DE ACCESO NO ESTA PERMITIDO PARA ESTE SISTEMA" );

                this.setAppSettings( "UserName", obj.FullName );
                this.setAppSettings( "UserType", obj.UserType );
                this.setAppSettings( "UserLevel", obj.UserLevel );
                this.setAppSettings( "UserPictureUrl", ( ! string.IsNullOrEmpty(obj.ImagePath) ) ? this.ConfigBaseUrl + obj.ImagePath : "" );

                this.setAppSettings( "InstitutionName", obj.Institution.NameInstitution );
                this.setAppSettings( "InstitutionLogo", obj.Institution.LogoInstitution );
                this.setAppSettings( "BranchCode", obj.Institution.BranchCode.ToString() );
                this.setAppSettings( "BranchAddress", obj.Institution.BranchAddress );
                this.setAppSettings( "Remember_me", "true" );

                this.AuthToken = obj.Token;
                this.AccessLevel = Convert.ToInt32( obj.UserLevel );

                return true;

            }
            catch ( Exception e )
            {
                this._msgExceptionLogin = e.Message;
                return false;
            }
        }
Esempio n. 6
0
        public bool SendDataPersonal()
        {
            Query query = new Query(this._Controller);
            query.RequestParameters = this._DataPersonal;

            try
            {
                query.SendRequestPOST();
                return true;
            }
            catch (Exception e)
            {
                this._msgExceptionRegPersonal = e.Message;
                return false;
            }
        }
Esempio n. 7
0
        public int InsertReporteIndividual(int codigoMaterial, int codigoAula)
        {
            Query query = new Query("api/material/"+ codigoMaterial+ "/aula/"+ codigoAula + "/report");

            query.RequestParameters = this._reportar;

            try
            {
                query.SendRequestPOST();

                if (query.ResponseStatusCode != HttpStatusCode.Created)
                    throw new ArgumentNullException(query.MsgExceptionQuery, "ERROR");

                return Convert.ToInt32(query.ResponseContent); ;
            }
            catch (Exception e)
            {
                this._msgException = e.Message;
                return 0;
            }
        }
Esempio n. 8
0
        public bool SendLogin()
        {
            OpSendLogin objSend = new OpSendLogin();

            Query Oquery = new Query(this._Controller);

            try
            {
                objSend.UserNick = this._InputName;
                objSend.UserPass = this._InputPass;

                Oquery.RequestParameters = objSend;

                Oquery.SendRequestPOST();

                OpLogin obj = JsonConvert.DeserializeObject<OpLogin>( Oquery.ResponseContent );

                if( Oquery.ResponseStatusCode == HttpStatusCode.OK )
                {
                    this.setAppSettings( "UserName", obj.data.FullName );
                    this.setAppSettings( "UserType", obj.data.TypeUser );
                    this.setAppSettings( "UserPictureUrl", this.ConfigBaseUrl + obj.data.ImagePath );

                    this.AuthToken = Oquery.ResponseHeader[0].Value.ToString();

                    this._UserFullName  = obj.data.FullName;
                    this._UserType      = obj.data.TypeUser;
                    this._LocationImage = this.ConfigBaseUrl + obj.data.ImagePath;
                }
                else
                {
                    throw new Exception( obj.msg );
                }

                return true;
            }
            catch(Exception e)
            {
                this._msgExceptionLogin = e.Message;
                return false;
            }
        }
Esempio n. 9
0
        public int Insert( int CodigoStudent )
        {
            Query query = new Query( "api/students/" + CodigoStudent + "/parents" );

            query.RequestParameters = this._data;

            try
            {
                query.SendRequestPOST();

                if ( query.ResponseStatusCode != HttpStatusCode.Created )
                    throw new ArgumentNullException( query.MsgExceptionQuery, "ERROR AL REGISTRAR UN PARIENTE" );

                return Convert.ToInt32( query.ResponseContent ); ;
            }
            catch ( Exception e )
            {
                this.MsgExceptionParents = e.Message;
                return 0;
            }
        }
Esempio n. 10
0
        public tMaterial Insert()
        {
            Query oQuery = new Query( "api/control/material" );

            this._dataMaterial.Category = this._dataCategoria;
            this._dataMaterial.Marca = this._dataMarca;

            oQuery.RequestParameters = this._dataMaterial;

            try
            {
                oQuery.SendRequestPOST();

                if ( oQuery.ResponseStatusCode == HttpStatusCode.InternalServerError )
                    throw new ArgumentNullException( "Existe un error en el servidor:\n", "Error en el Servidor" );
                else if ( oQuery.ResponseStatusCode == HttpStatusCode.NotFound )
                    throw new ArgumentNullException( "No se encontro recurso al cual acceder", "Recurso no encontrado" );

                msgResponse resp = JsonConvert.DeserializeObject<msgResponse>( oQuery.ResponseContent );

                if ( oQuery.ResponseStatusCode == HttpStatusCode.BadRequest )
                    throw new InvalidOperationException( resp.message );

                return JsonConvert.DeserializeObject<tMaterial>( resp.data );
            }
            catch ( Exception e )
            {
                this._ExceptionCM = e.Message;
                return null;
            }
        }
Esempio n. 11
0
        public int Insert()
        {
            Query query = new Query("api/students/insert");

            this._dataMaterial.Category = this._dataCategoria;
            this._dataMaterial.Marca = this._dataMarca;

            query.RequestParameters = this._dataMaterial;

            try
            {
                query.SendRequestPOST();

                if (query.ResponseStatusCode != HttpStatusCode.Created)
                    throw new ArgumentNullException(query.MsgExceptionQuery, "ERROR AL REGISTRAR UN MATERIAL");

                return Convert.ToInt32(query.ResponseContent); ;
            }
            catch (Exception e)
            {
                this._msgExceptionRegMateriales = e.Message;
                return 0;
            }
        }
Esempio n. 12
0
        public int CreateStudent( bool Individual = false )
        {
            Query query = new Query(  ( ! Individual ) ? this._pAlumnoCtrl : this._AlumnoCtrl );

            this._dataMain.Alumno = this._dataAlumno;

            if ( ! Individual ) //si no solo se registraran datos unicos del alumno
            {
                this._dataMain.Documentos = this._dataDocumento;
                this._dataMain.Apoderado = this._dataApoderado;
                this._dataMain.CursosExonerados = this._dataCursoExonerado;
            }

            //limpiando los datos de imagen de perfil y agregandolo al contenedor de imagenes
            if ( !string.IsNullOrEmpty( DataAlumno.ImageKey ) && !string.IsNullOrEmpty( DataAlumno.ImageSrc ) )
            {
                this._File.Add( this.DataAlumno.ImageKey, this.DataAlumno.ImageSrc );
                this._dataMain.Alumno.ImageSrc = string.Empty;
            }

            if ( !Individual )
            {
                int con = 0;

                //limpiando los datos de imagen de documento y agregandolos al contenedor de imagens
                foreach ( tDocumentoAlumno items in this._dataMain.Documentos )
                {
                    if ( !string.IsNullOrEmpty( items.ImageSrc ) && !string.IsNullOrEmpty( items.ImageKey ) )
                    {
                        this._File.Add( items.ImageKey, items.ImageSrc );
                        this._dataMain.Documentos[con].ImageSrc = string.Empty;
                        con++;
                    }
                }
            }

            query.RequestParameters = this._dataMain;

            if ( this._File.Any() )
                query.AddRequestFiles( this._File );

            try
            {
                query.SendRequestPOST();

                if ( query.ResponseStatusCode != HttpStatusCode.OK )
                    throw new ArgumentNullException( query.MsgExceptionQuery, "ERROR AL REGISTRO" );

                return Convert.ToInt32( query.ResponseContent );
            }
            catch ( Exception e )
            {
                this._msgExceptionRegAlumno = e.Message;
                return 0;
            }
        }
Esempio n. 13
0
        public bool SendDataStudent( DataSet dts )
        {
            Query query = new Query( this._registerController );

            this._dataAlumno.Documents = this._dataDocuments;
            this._dataAlumno.Parents = this._dataParent;

            if(!string.IsNullOrEmpty(DataAlumno.ImageKey) &&  !string.IsNullOrEmpty(DataAlumno.Imagesrc))
            {
                this._File.Add(this.DataAlumno.ImageKey, this.DataAlumno.Imagesrc);
                this._dataAlumno.Imagesrc = string.Empty;
            }

            int con = 0;

            foreach(Document items in this.DataAlumno.Documents)
            {
                if ( !string.IsNullOrEmpty( items.Imagesrc ) && !string.IsNullOrEmpty( items.ImageKey ) )
                {
                    this._File.Add( items.ImageKey, items.Imagesrc );
                    this._dataAlumno.Documents[con].Imagesrc = string.Empty;
                    con++;
                }
            }

            query.RequestParameters = this._dataAlumno;
            query.AddRequestFiles(this._File);

            try
            {
                query.SendRequestPOST();

                if ( query.ResponseStatusCode != HttpStatusCode.OK )
                    throw new ArgumentNullException( query.MsgExceptionQuery, "ERROR AL REGISTRO" );

                ResponseAlumno alumno = JsonConvert.DeserializeObject<ResponseAlumno>( query.ResponseContent );

                object[] objAlumno = new object[]
                {
                    alumno.Id,
                    alumno.Names,
                    alumno.LastName,
                    alumno.Sexo,
                    alumno.Birthday,
                    alumno.Imagesrc,
                    alumno.Address,
                    alumno.Usuario,
                    alumno.IdLastSchool
                };

                dts.Tables["student"].Rows.Add( objAlumno );

                foreach ( ResponseDocument docs in alumno.Documents )
                {
                    object objDocuments = new object[]
                    {
                        docs.TypeDocument,
                        docs.DocumentNumber,
                        docs.Expire,
                        alumno.Id
                    };

                    dts.Tables["Documents"].Rows.Add( objDocuments );
                }

                foreach ( ResponseParent parent in alumno.Parents )
                {
                    object objParents = new object[]
                    {
                        parent.Names,
                        parent.LastName,
                        parent.TypeParent,
                        parent.GenderParent,
                        parent.TypeDocument,
                        parent.DocumentNumber,
                        parent.Phone,
                        parent.Email,
                        alumno.Id
                    };

                    dts.Tables["Parents"].Rows.Add( objParents );
                }

                return true;
            }
            catch ( Exception e )
            {
                this._msgExceptionRegAlumno = e.Message;
                return false;
            }
        }
Esempio n. 14
0
        public bool SendChangePicture( string Source )
        {
            Query oQuery = new Query( this._Controller + "/change_picture/" );
            Dictionary<string, string> file = new Dictionary<string, string>();
            object obj = new object();

            obj = new object[2]{this.getAppSettings( "User" ), 1};

            try
            {
                file.Add( "Picture", Source );

                oQuery.AddRequestFiles(file);
                oQuery.RequestParameters = obj;

                oQuery.SendRequestPOST();

                if ( oQuery.ResponseStatusCode == HttpStatusCode.InternalServerError )
                    throw new ArgumentNullException( "Existe un error en el servidor:\n" + this._msgExceptionLogin, "Error en el Servidor" );
                else if ( oQuery.ResponseStatusCode == HttpStatusCode.NotFound )
                    throw new ArgumentNullException( "No se encontro recurso al cual acceder", "Recurso no encontrado" );

                msgResponse resp = JsonConvert.DeserializeObject<msgResponse>( oQuery.ResponseContent );

                if ( oQuery.ResponseStatusCode == HttpStatusCode.BadRequest )
                    throw new InvalidOperationException( resp.message );

                this.setAppSettings( "UserPictureUrl", Convert.ToString(resp.data) );

                return true;
            }
            catch ( Exception e )
            {
                this._msgExceptionLogin = e.Message;
                return false;
            }
        }
Esempio n. 15
0
        public bool SendChangePassword( ChangePassword change )
        {
            Query oQuery = new Query( this._Controller + "/change_password" );

            try
            {
                change.UserNick = this.getAppSettings("User");
                oQuery.RequestParameters = change;
                oQuery.SendRequestPOST();

                if ( oQuery.ResponseStatusCode == HttpStatusCode.InternalServerError )
                    throw new ArgumentNullException( "Existe un error en el servidor:\n" + this._msgExceptionLogin, "Error en el Servidor" );
                else if ( oQuery.ResponseStatusCode == HttpStatusCode.NotFound )
                    throw new ArgumentNullException( "No se encontro recurso al cual acceder", "Recurso no encontrado" );

                msgResponse resp = JsonConvert.DeserializeObject<msgResponse>( oQuery.ResponseContent );

                if ( oQuery.ResponseStatusCode == HttpStatusCode.BadRequest )
                    throw new InvalidOperationException( resp.message );

                return Convert.ToBoolean( resp.data );
            }
            catch ( Exception e )
            {
                this._msgExceptionLogin = e.Message;
                return false;
            }
        }
Esempio n. 16
0
        public tPersonal Insert()
        {
            Query query = new Query( "api/personal" );

            if ( !string.IsNullOrEmpty( this._data.ImageKey ) && !string.IsNullOrEmpty( this._data.ImageSrc ) )
            {
                this._file.Add( this._data.ImageKey, this._data.ImageSrc );
                this._data.ImageSrc = string.Empty;
            }

            query.RequestParameters = this._data;

            if ( this._file.Any() )
                query.AddRequestFiles( this._file );

            try
            {
                query.SendRequestPOST();

                if ( query.ResponseStatusCode == HttpStatusCode.InternalServerError )
                    throw new ArgumentNullException( "Existe un error en el servidor:\n" + this._msgExceptionPersonal, "Error en el Servidor" );
                else if ( query.ResponseStatusCode == HttpStatusCode.NotFound )
                    throw new ArgumentNullException( "No se encontro recurso al cual acceder", "Recurso no encontrado" );

                msgResponse resp = JsonConvert.DeserializeObject<msgResponse>( query.ResponseContent );

                if ( query.ResponseStatusCode == HttpStatusCode.BadRequest )
                    throw new InvalidOperationException( resp.message );

                string[] str = resp.data.Split( '-' );

                this._data.Codigo =  Convert.ToInt32(str[0]);
                this._data.Key = str[1];

                return this._data;
            }
            catch ( Exception e )
            {
                this._msgExceptionPersonal = e.Message;
                return null;
            }
        }
Esempio n. 17
0
        public int Insert()
        {
            Query query = new Query("api/students/insert");

            query.RequestParameters = this._data;

            try
            {
                query.SendRequestPOST();

                if (query.ResponseStatusCode != HttpStatusCode.Created)
                    throw new ArgumentNullException(query.MsgExceptionQuery, "ERROR");

                return Convert.ToInt32(query.ResponseContent); ;
            }
            catch (Exception e)
            {
                this._msgException = e.Message;
                return 0;
            }
        }
Esempio n. 18
0
        public tBranch Insert()
        {
            Query oQuery = new Query( "api/institution/branches" );

            try
            {
                oQuery.RequestParameters = this._data;

                oQuery.SendRequestPOST();

                if ( oQuery.ResponseStatusCode == HttpStatusCode.InternalServerError )
                    throw new ArgumentNullException( "Existe un error en el servidor:\n" + this._exceptionHistory, "Error en el Servidor" );

                msgResponse resp = JsonConvert.DeserializeObject<msgResponse>( oQuery.ResponseContent );

                if ( oQuery.ResponseStatusCode == HttpStatusCode.NotFound )
                    throw new ArgumentNullException( "No se encontro recurso al cual acceder", "Recurso no encontrado" );
                else if ( oQuery.ResponseStatusCode == HttpStatusCode.BadRequest )
                    throw new InvalidOperationException( resp.message );

                this._data.Codigo = Convert.ToInt32( resp.data );
                return this._data;
            }
            catch ( Exception e )
            {
                this.ExceptionHistory = e.Message;
                return null;
            }
        }