Beispiel #1
0
        /// <summary>
        /// Cancella l'oggetto dalla base dati.
        /// </summary>
        public static void Delete(SqlInt32 p_lsr_id_stato_richiesta)
        {
            string    sqlCommand = null;
            DbCommand dbCommand  = null;

            try
            {
                Database db = DatabaseFactory.CreateDatabase("CONNECTION_STRING");

                sqlCommand = @" DELETE FROM LOOKUP_STATO_AUTORIZZAZIONE WHERE 
					(lsr_id_stato_richiesta = @lsr_id_stato_richiesta) 
					"                    ;

                dbCommand = db.GetSqlStringCommand(sqlCommand);

                db.AddInParameter(dbCommand, "lsr_id_stato_richiesta", DbType.Int32, p_lsr_id_stato_richiesta);

                db.ExecuteNonQuery(dbCommand);
            }
            catch (Exception ex)
            {
                ex.Data.Add("Class.Method", "LookupStatoAutorizzazione.Delete.");
                ex.Data.Add("SQL", GenericError.SubstituteParameters(dbCommand.CommandText, dbCommand.Parameters));

                // Gestione messaggistica all'utente e trace in DB dell'errore
                ExceptionPolicy.HandleException(ex, "Direct Data Access Policy");
            }
        }
Beispiel #2
0
        public void SaveGenericError(GenericError error)
        {
            Database oDatabase = DatabaseFactory.CreateDatabase(DataHelpers.ConnectionString());

            using (DbConnection connection = oDatabase.CreateConnection())
            {
                connection.Open();
                try
                {
                    DbCommand oCommand = oDatabase.GetStoredProcCommand("sp_GenericError_Add");
                    if (error.UniqueID == System.Guid.Empty)
                    {
                        error.UniqueID = System.Guid.NewGuid();
                    }
                    oDatabase.AddInParameter(oCommand, "@Message", System.Data.DbType.String, error.Message);
                    oDatabase.AddInParameter(oCommand, "@InnerExceptionMessage", System.Data.DbType.String, error.InnerExceptionMessage);
                    oDatabase.AddInParameter(oCommand, "@ComolUniqueID", System.Data.DbType.String, error.ComolUniqueID);
                    oDatabase.AddInParameter(oCommand, "@SentDate", System.Data.DbType.DateTime, error.SentDate);
                    oDatabase.AddInParameter(oCommand, "@Day", System.Data.DbType.Date, error.Day);
                    oDatabase.AddInParameter(oCommand, "@UniqueID", System.Data.DbType.Guid, error.UniqueID);
                    oCommand.Connection = connection;
                    if (oCommand.ExecuteNonQuery() == 0)
                    {
                        throw new Exception("no insert: sp_GenericError_Add");
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.EventLog.WriteEntry("ManagerDatabase", ex.Message);
                }
            }
        }
        /// <summary>
        /// Cancella l'oggetto dalla base dati.
        /// </summary>
        public static void Delete(SqlInt32 p_cun_id_cross_utente_notifica, DbTransaction transaction)
        {
            string    sqlCommand = null;
            DbCommand dbCommand  = null;

            try
            {
                Database db = DatabaseFactory.CreateDatabase("CONNECTION_STRING");

                sqlCommand = @" DELETE FROM CROSS_UTENTE_NOTIFICA WHERE 
					(cun_id_cross_utente_notifica = @cun_id_cross_utente_notifica) 
					"                    ;

                dbCommand = db.GetSqlStringCommand(sqlCommand);

                db.AddInParameter(dbCommand, "cun_id_cross_utente_notifica", DbType.Int32, p_cun_id_cross_utente_notifica);

                db.ExecuteNonQuery(dbCommand, transaction);
            }
            catch (Exception ex)
            {
                ex.Data.Add("Class.Method", "CrossUtenteNotifica.Delete.");
                ex.Data.Add("SQL", GenericError.SubstituteParameters(dbCommand.CommandText, dbCommand.Parameters));

                // Gestione messaggistica all'utente e trace in DB dell'errore
                ExceptionPolicy.HandleException(ex, "Direct Data Access Policy");
            }
        }
Beispiel #4
0
        public async Task <ActionResult <MessagesResponse> > ByUserID([FromRoute] Guid user_id, [FromQuery] _basisParameters qparams)
        {
            var    canAccess      = Helpers.AuthenticationHelper.canAccessUserData(HttpContext.User);
            var    claimsIdentity = HttpContext.User.Identity as ClaimsIdentity;
            string username       = claimsIdentity.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Name)?.Value;
            string userGID        = user_id.ToString();

            if (!canAccess)
            {
                canAccess = _context.Users.Any(x => !String.IsNullOrEmpty(username) && x.UserName == username && x.UserGID == userGID);
            }

            if (canAccess)
            {
                // Get the messages associated with this userGID
                var messageCount       = _context.Messages.Count(x => x.MessageRecipients.Any(y => y.UserGID == userGID));
                var unreadMessageCount = _context.Messages.Count(x => x.MessageRecipients.Any(y => y.UserGID == userGID && !y.MessageRead));

                var messages = await _context.Messages.Where(x => x.MessageRecipients.Any(y => y.UserGID == userGID)).Take(20).AsNoTracking().ToListAsync();

                // Send the response back
                return(new MessagesResponse
                {
                    Count = messageCount,
                    UnreadCount = unreadMessageCount,
                    Messages = messages
                });
            }

            // If the user is unknown, reply with an error
            return(GenericError.create(this, StatusCodes.Status401Unauthorized,
                                       "You do not have access to this user's messages"));
        }
Beispiel #5
0
        /// <summary>
        /// Cancella l'oggetto dalla base dati.
        /// </summary>
        public void Delete()
        {
            string    sqlCommand = null;
            DbCommand dbCommand  = null;

            try
            {
                Database db = DatabaseFactory.CreateDatabase("CONNECTION_STRING");

                sqlCommand = @" DELETE FROM SISTEMA 
					"                    ;

                dbCommand = db.GetSqlStringCommand(sqlCommand);


                db.ExecuteNonQuery(dbCommand);
            }
            catch (Exception ex)
            {
                ex.Data.Add("Class.Method", "Sistema.Delete.");
                ex.Data.Add("SQL", GenericError.SubstituteParameters(dbCommand.CommandText, dbCommand.Parameters));

                // Gestione messaggistica all'utente e trace in DB dell'errore
                ExceptionPolicy.HandleException(ex, "Direct Data Access Policy");
            }
        }
Beispiel #6
0
    public static void ValidateStakeAmount(StakePayload payload, ResponseCallback callback, ResponseFallback fallback)
    {
        HttpClient httpClient = new HttpClient();

        Request request = new Request(HttpClient.Method.POST, Route.VALIDATE_STAKE_ROUTE, payload);

        httpClient.Request(
            request,
            (statusCode, response) => {
            ValidateStakeResponse validateResponse = Deserialize(response);
            callback(validateResponse);
        },
            (statusCode, error) => {
            if (statusCode == StatusCodes.CODE_VALIDATION_ERROR)
            {
                ValidationError validationError = ErrorDeserilizer.DeserializeValidationErrorData(error);
                fallback(statusCode, validationError);
            }
            else
            {
                GenericError genericError = ErrorDeserilizer.DeserializeGenericErrorData(error);
                fallback(statusCode, genericError);
            }
        }
            );
    }
Beispiel #7
0
        /// <summary>
        /// Cancella l'oggetto dalla base dati.
        /// </summary>
        public static void Delete(SqlInt32 p_diz_id_dizionario)
        {
            string    sqlCommand = null;
            DbCommand dbCommand  = null;

            try
            {
                Database db = DatabaseFactory.CreateDatabase("CONNECTION_STRING");

                sqlCommand = @" DELETE FROM DIZIONARIO WHERE 
					(DIZ_ID_DIZIONARIO =@diz_id_dizionario) 
					"                    ;

                dbCommand = db.GetSqlStringCommand(sqlCommand);

                db.AddInParameter(dbCommand, "diz_id_dizionario", DbType.Int32, p_diz_id_dizionario);

                db.ExecuteNonQuery(dbCommand);
            }
            catch (Exception ex)
            {
                ex.Data.Add("Class.Method", "Dizionario.Delete.");
                ex.Data.Add("SQL", GenericError.SubstituteParameters(dbCommand.CommandText, dbCommand.Parameters));

                // Gestione messaggistica all'utente e trace in DB dell'errore
                ExceptionPolicy.HandleException(ex, "Direct Data Access Policy");
            }
        }
Beispiel #8
0
        /// <summary>
        /// Aggiorna l'ggetto nella base dati
        /// </summary>
        public void Update()
        {
            string    sqlCommand = null;
            DbCommand dbCommand  = null;

            try
            {
                Database db = DatabaseFactory.CreateDatabase("CONNECTION_STRING");

                sqlCommand = @" UPDATE SESSIONI_UTENTI SET
					 ssu_id_sessione_utente = @ssu_id_sessione_utente,                   
					 ute_id_utente = @ute_id_utente, 
					 ssu_data_last_ping = @ssu_data_last_ping					 
					 WHERE ssu_id_sessione = @ssu_id_sessione 
					 "                    ;

                dbCommand = db.GetSqlStringCommand(sqlCommand);

                db.AddInParameter(dbCommand, "ssu_id_sessione_utente", DbType.Int32, ssu_id_sessione_utente);
                db.AddInParameter(dbCommand, "ssu_id_sessione", DbType.Guid, ssu_id_sessione);
                db.AddInParameter(dbCommand, "ute_id_utente", DbType.Int32, ute_id_utente);
                db.AddInParameter(dbCommand, "ssu_data_last_ping", DbType.DateTime, ssu_data_last_ping);

                db.ExecuteNonQuery(dbCommand);
            }
            catch (Exception ex)
            {
                ex.Data.Add("Class.Method", "SessioniUtenti.Update.");
                ex.Data.Add("SQL", GenericError.SubstituteParameters(dbCommand.CommandText, dbCommand.Parameters));

                // Gestione messaggistica all'utente e trace in DB dell'errore
                ExceptionPolicy.HandleException(ex, "Direct Data Access Policy");
            }
        }
Beispiel #9
0
        /// <summary>
        /// Metodo creato ad hoc per ricavare un datareader che chiude la connessione con il DB.
        /// </summary>
        /// <param name="sqlCommand">Sql da eseguire per la Read</param>
        /// <param name="parameterCollection">Collezione di tutti i parametri da passare al metodo</param>
        /// <param name="method">Nome del metodo chiamante per gestire l'errore in caso di eccezione</param>
        public static SqlDataReader getReader(string sqlCommand, SqlParameterCollection parameterCollection, string method)
        {
            SqlCommand    dbCommand    = new SqlCommand();
            SqlConnection dbConnection = new SqlConnection();
            SqlDataReader reader       = null;

            try
            {
                dbConnection.ConnectionString = ConfigurationManager.ConnectionStrings["CONNECTION_STRING"].ToString();
                dbCommand.CommandText         = sqlCommand;
                dbCommand.CommandTimeout      = Convert.ToInt32(ConfigurationManager.AppSettings["QueryCommandTimeout"]);
                dbCommand.Connection          = dbConnection;
                dbCommand.Connection.Open();

                foreach (SqlParameter p in parameterCollection)
                {
                    dbCommand.Parameters.AddWithValue(p.ParameterName, p.SqlValue);
                }
                reader = dbCommand.ExecuteReader(CommandBehavior.CloseConnection);
            }
            catch (Exception ex)
            {
                ex.Data.Add("Class.Method", method);
                ex.Data.Add("SQL", GenericError.SubstituteParameters(dbCommand.CommandText, dbCommand.Parameters));
                throw ex;
            }
            return(reader);
        }
        public ReturnData Borrar([FromBody] Gq_formulariosDto model)
        {
            ReturnData result = new ReturnData();

            using (var transaction = Services.session.BeginTransaction())
            {
                try
                {
                    var entity = Services.Get <ServGq_formularios>().findById(model.Id);
                    var update = entity.Estado = Constantes.ESTADO_BORRADO;
                    entity.Modificado    = DateTime.Now;
                    entity.ModificadoPor = com.gq.security.Security.usuarioLogueado.UsuarioId;
                    Services.Get <ServGq_formularios>().Actualizar(entity);
                }
                catch (Exception e)
                {
                    result.isError = true;
                    result.data    = GenericError.Create(e);
                }

                if (!result.isError)
                {
                    transaction.Commit();
                }
                else
                {
                    transaction.Rollback();
                }
            }

            return(result);
        }
        /// <summary>
        /// Cancella logicamente l'oggetto dalla base dati.
        /// </summary>
        public void Delete(SqlInt32 p_wfw_id_case_azioni)
        {
            string    sqlCommand = null;
            DbCommand dbCommand  = null;

            try
            {
                Database db = DatabaseFactory.CreateDatabase("CONNECTION_STRING");

                sqlCommand = @" UPDATE WORKFLOW_AZIONI_CASES SET

					 WHERE   
				     (wfw_id_case_azioni = @wfw_id_case_azioni) 
					 "                    ;

                dbCommand = db.GetSqlStringCommand(sqlCommand);

                db.AddInParameter(dbCommand, "wfw_id_case_azioni", DbType.Int32, p_wfw_id_case_azioni);

                db.ExecuteNonQuery(dbCommand);
            }
            catch (Exception ex)
            {
                ex.Data.Add("Class.Method", "WorkflowAzioniCases.Delete.");
                ex.Data.Add("SQL", GenericError.SubstituteParameters(dbCommand.CommandText, dbCommand.Parameters));

                // Gestione messaggistica all'utente e trace in DB dell'errore
                throw ex;
            }
        }
Beispiel #12
0
        /// <summary>
        /// Cancella l'oggetto dalla base dati.
        /// </summary>
        public void Delete(int RUL_ID_RUOLO, int FNT_ID_FUNZIONALITA)
        {
            // sistemare .....
            rul_id_ruolo        = RUL_ID_RUOLO;
            fnt_id_funzionalita = FNT_ID_FUNZIONALITA;

            string    sqlCommand = null;
            DbCommand dbCommand  = null;

            try
            {
                Database db = DatabaseFactory.CreateDatabase("CONNECTION_STRING");

                sqlCommand = " DELETE FROM PERMESSO_ACCESSO WHERE " +
                             "(RUL_ID_RUOLO =@rul_id_ruolo) " + "AND (FNT_ID_FUNZIONALITA =@fnt_id_funzionalita) " + " ";

                dbCommand = db.GetSqlStringCommand(sqlCommand);

                db.AddInParameter(dbCommand, "rul_id_ruolo", DbType.Int32, rul_id_ruolo);
                db.AddInParameter(dbCommand, "fnt_id_funzionalita", DbType.Int32, fnt_id_funzionalita);

                db.ExecuteNonQuery(dbCommand);
            }
            catch (Exception ex)
            {
                ex.Data.Add("Class.Method", "PermessoAccesso.Delete.");
                ex.Data.Add("SQL", GenericError.SubstituteParameters(dbCommand.CommandText, dbCommand.Parameters));

                // Gestione messaggistica all'utente e trace in DB dell'errore
                ExceptionPolicy.HandleException(ex, "Direct Data Access Policy");
            }
        }
Beispiel #13
0
    public static void ForgotUserPassword(ForgotPasswordPayload payload, ResponseCallback callback, ResponseFallback fallback)
    {
        HttpClient httpClient = new HttpClient();

        Request request = new Request(HttpClient.Method.POST, Route.FORGOT_PASSWORD_ROUTE, payload);

        httpClient.Request(
            request,
            (statusCode, response) => {
            ForgotPasswordResponse forgotPasswordResponse = Deserialize(response);
            callback(forgotPasswordResponse);
        },
            (statusCode, error) => {
            if (statusCode == StatusCodes.CODE_VALIDATION_ERROR)
            {
                ValidationError validationError = ErrorDeserilizer.DeserializeValidationErrorData(error);
                fallback(statusCode, validationError);
            }
            else
            {
                GenericError genericError = ErrorDeserilizer.DeserializeGenericErrorData(error);
                fallback(statusCode, genericError);
            }
        }
            );
    }
Beispiel #14
0
        /// <summary>
        /// Cancella l'oggetto dalla base dati.
        /// </summary>
        public void Delete()
        {
            string    sqlCommand = null;
            DbCommand dbCommand  = null;

            try
            {
                Database db = DatabaseFactory.CreateDatabase("CONNECTION_STRING");

                sqlCommand = @" DELETE FROM AUDIT WHERE 
					(AUD_ID_AUDIT =@aud_id_audit) 
					"                    ;

                dbCommand = db.GetSqlStringCommand(sqlCommand);

                db.AddInParameter(dbCommand, "aud_id_audit", DbType.Int32, aud_id_audit);

                db.ExecuteNonQuery(dbCommand);
            }
            catch (Exception ex)
            {
                ex.Data.Add("Class.Method", "Audit.Delete.");
                ex.Data.Add("SQL", GenericError.SubstituteParameters(dbCommand.CommandText, dbCommand.Parameters));

                // Gestione messaggistica all'utente e trace in DB dell'errore
                ExceptionPolicy.HandleException(ex, "Direct Data Access Policy");
            }
        }
Beispiel #15
0
        /// <summary>
        /// Delete a <see cref="MailItem"/> with supplied id.
        /// </summary>
        public void MailDelete(ulong mailId)
        {
            GenericError result = GenericError.Ok;

            if (!availableMail.TryGetValue(mailId, out MailItem mailItem))
            {
                result = GenericError.MailDoesNotExist;
            }

            if (result == GenericError.Ok)
            {
                // TODO: Confirm that this user is allowed to delete this mail
                mailItem.EnqueueDelete();

                player.Session.EnqueueMessageEncrypted(new ServerMailUnavailable
                {
                    MailId = mailItem.Id
                });
            }

            player.Session.EnqueueMessageEncrypted(new ServerMailResult
            {
                Action = 5,
                MailId = mailId,
                Result = result
            });
        }
Beispiel #16
0
        /// <summary>
        /// Legge i dati per l'oggetto dalla base dati
        /// </summary>
        public void Read(SqlInt32 p_lsr_id_stato_richiesta)
        {
            SqlDataReader reader     = null;
            string        sqlCommand = null;
            DbCommand     dbCommand  = null;

            try
            {
                Database db = DatabaseFactory.CreateDatabase("CONNECTION_STRING");

                sqlCommand = @" SELECT 
					 LOOKUP_STATO_AUTORIZZAZIONE.lsr_id_stato_richiesta, 
					 LOOKUP_STATO_AUTORIZZAZIONE.lsa_descrizione, 
					 LOOKUP_STATO_AUTORIZZAZIONE.lsa_flag_visibile, 
					 LOOKUP_STATO_AUTORIZZAZIONE.lsa_flag_eliminato, 
					 LOOKUP_STATO_AUTORIZZAZIONE.lsa_data_creazione, 
					 LOOKUP_STATO_AUTORIZZAZIONE.lsa_data_aggiornamento, 
					 LOOKUP_STATO_AUTORIZZAZIONE.ute_id_utente, 
					 LOOKUP_STATO_AUTORIZZAZIONE.ute_aggiornato_da, 
					 LOOKUP_STATO_AUTORIZZAZIONE.ute_creato_da	 
				     FROM LOOKUP_STATO_AUTORIZZAZIONE WHERE 
					 (lsr_id_stato_richiesta = @lsr_id_stato_richiesta) 
					 "                    ;

                dbCommand = db.GetSqlStringCommand(sqlCommand);

                db.AddInParameter(dbCommand, "lsr_id_stato_richiesta", DbType.Int32, p_lsr_id_stato_richiesta);

                reader = ((RefCountingDataReader)db.ExecuteReader(dbCommand)).InnerReader as SqlDataReader;

                while (reader.Read())
                {
                    lsr_id_stato_richiesta = reader.GetSqlInt32(0);
                    lsa_descrizione        = reader.GetSqlString(1);
                    lsa_flag_visibile      = reader.GetSqlInt32(2);
                    lsa_flag_eliminato     = reader.GetSqlInt32(3);
                    lsa_data_creazione     = reader.GetSqlDateTime(4);
                    lsa_data_aggiornamento = reader.GetSqlDateTime(5);
                    ute_id_utente          = reader.GetSqlInt32(6);
                    ute_aggiornato_da      = reader.GetSqlInt32(7);
                    ute_creato_da          = reader.GetSqlInt32(8);
                }
            }
            catch (Exception ex)
            {
                ex.Data.Add("Class.Method", "LookupStatoAutorizzazione.Read.");
                ex.Data.Add("SQL", GenericError.SubstituteParameters(dbCommand.CommandText, dbCommand.Parameters));

                // Gestione messaggistica all'utente e trace in DB dell'errore
                ExceptionPolicy.HandleException(ex, "Direct Data Access Policy");
            }

            finally
            {
                if (reader != null)
                {
                    ((IDisposable)reader).Dispose();
                }
            }
        }
Beispiel #17
0
        /// <summary>
        /// Cancella l'oggetto dalla base dati.
        /// </summary>
        public void Delete()
        {
            string    sqlCommand = null;
            DbCommand dbCommand  = null;

            try
            {
                Database db = DatabaseFactory.CreateDatabase("CONNECTION_STRING");

                sqlCommand = @" DELETE FROM SESSIONI_UTENTI WHERE SSU_ID_SESSIONE = @ssu_id_sessione
					"                    ;

                dbCommand = db.GetSqlStringCommand(sqlCommand);
                db.AddInParameter(dbCommand, "ssu_id_sessione", DbType.Guid, ssu_id_sessione);
                db.ExecuteNonQuery(dbCommand);
            }
            catch (Exception ex)
            {
                ex.Data.Add("Class.Method", "SessioniUtenti.Delete.");
                ex.Data.Add("SQL", GenericError.SubstituteParameters(dbCommand.CommandText, dbCommand.Parameters));

                // Gestione messaggistica all'utente e trace in DB dell'errore
                ExceptionPolicy.HandleException(ex, "Direct Data Access Policy");
            }
        }
Beispiel #18
0
        /// <summary>
        /// Cancella l'oggetto dalla base dati.
        /// </summary>
        public static void Delete(SqlInt32 p_cnc_id_campo_nascosto)
        {
            string    sqlCommand = null;
            DbCommand dbCommand  = null;

            try
            {
                Database db = DatabaseFactory.CreateDatabase("CONNECTION_STRING");

                sqlCommand = @" DELETE FROM CAMPI_NASCOSTI_CLIENTE WHERE 
					(cnc_id_campo_nascosto = @cnc_id_campo_nascosto) 
					"                    ;

                dbCommand = db.GetSqlStringCommand(sqlCommand);

                db.AddInParameter(dbCommand, "cnc_id_campo_nascosto", DbType.Int32, p_cnc_id_campo_nascosto);

                db.ExecuteNonQuery(dbCommand);
            }
            catch (Exception ex)
            {
                ex.Data.Add("Class.Method", "CampiNascostiCliente.Delete.");
                ex.Data.Add("SQL", GenericError.SubstituteParameters(dbCommand.CommandText, dbCommand.Parameters));

                // Gestione messaggistica all'utente e trace in DB dell'errore
                ExceptionPolicy.HandleException(ex, "Direct Data Access Policy");
            }
        }
Beispiel #19
0
        /// <summary>
        /// Aggiorna le colonne att_nome_file, att_dimensione. Valorizzo a NULL
        /// att_nome_file_tmp, att_dimensione_tmp al salvataggio della nota spesa
        /// </summary>
        /// <param name="p_att_id_record">Id record</param>
        /// <param name="transaction"></param>
        /// <param name="db"></param>
        public void UpdateFinale(SqlInt32 p_att_id_record, DbTransaction transaction, Database db)
        {
            string    sqlCommand = null;
            DbCommand dbCommand  = null;

            try
            {
                sqlCommand = @" UPDATE ALLEGATI SET				 
					                att_nome_file = att_nome_file_tmp,
                                    att_dimensione = att_dimensione_tmp
					                WHERE att_id_record = @att_id_record
                                    AND att_nome_file_tmp IS NOT NULL;

                                UPDATE ALLEGATI 
                                    SET att_nome_file_tmp = null,
                                    att_dimensione_tmp = null
                                    WHERE att_id_record = @att_id_record
					            "                    ;

                dbCommand = db.GetSqlStringCommand(sqlCommand);

                db.AddInParameter(dbCommand, "att_id_record", DbType.Int32, p_att_id_record);

                db.ExecuteNonQuery(dbCommand, transaction);
            }
            catch (Exception ex)
            {
                ex.Data.Add("Class.Method", "Allegati.UpdateFinale.");
                ex.Data.Add("SQL", GenericError.SubstituteParameters(dbCommand.CommandText, dbCommand.Parameters));

                // Gestione messaggistica all'utente e trace in DB dell'errore
                ExceptionPolicy.HandleException(ex, "Direct Data Access Policy");
            }
        }
Beispiel #20
0
        public static void HandlePathUnlock(WorldSession session, ClientPathUnlock clientPathUnlock)
        {
            uint unlockCost = GameTableManager.Instance.GameFormula.GetEntry(2365).Dataint0;

            GenericError CanUnlockPath()
            {
                bool hasEnoughTokens = session.AccountCurrencyManager.CanAfford(AccountCurrencyType.ServiceToken, unlockCost);

                if (!hasEnoughTokens)
                {
                    return(GenericError.PathInsufficientFunds);
                }

                if (session.Player.PathManager.IsPathUnlocked(clientPathUnlock.Path))
                {
                    return(GenericError.PathAlreadyUnlocked);
                }

                return(GenericError.Ok);
            }

            GenericError result = CanUnlockPath();

            if (result != GenericError.Ok)
            {
                session.Player.PathManager.SendServerPathUnlockResult(result);
                return;
            }

            session.Player.PathManager.UnlockPath(clientPathUnlock.Path);
            session.AccountCurrencyManager.CurrencySubtractAmount(AccountCurrencyType.ServiceToken, unlockCost);
        }
Beispiel #21
0
    public void DisplayTransaction()
    {
        foreach (GameObject gobject in trans)
        {
            Destroy(gobject);
        }

        loading.SetActive(true);
        GetHistory.GetUserHistory(
            (response) => {
            loading.SetActive(false);

            HistoryResponse historyResponse = (HistoryResponse)response;

            foreach (HistroyModel histroy in historyResponse.history)
            {
                GenerateHistroyItem(histroy);
            }
        },
            (statusCode, error) => {
            loading.SetActive(false);
            failed.SetActive(true);

            if (statusCode == StatusCodes.CODE_VALIDATION_ERROR)
            {
                ValidationError validationError = (ValidationError)error;
            }
            else
            {
                GenericError genericError = (GenericError)error;
            }
        }
            );
    }
        /// <summary>
        /// getLookupTipoDocumento
        /// </summary>
        /// <returns>iDataReader:,_DESCRIZIONE</returns>
        public DataSet GetLookupTipoIndirizzo(string tableName)
        {
            string        sqlCommand = null;
            StringBuilder sb         = new StringBuilder(2000);
            DbCommand     dbCommand  = null;
            DataSet       ds         = new DataSet();

            try
            {
                Database db = DatabaseFactory.CreateDatabase("CONNECTION_STRING");

                sb.Append(" SELECT ");
                sb.Append(" LTI_TIPO_INDIRIZZO ");
                sb.Append(" FROM LOOKUP_TIPO_INDIRIZZO ");
                sb.Append(SqlWhereClause);

                sqlCommand = sb.ToString();
                dbCommand  = db.GetSqlStringCommand(sqlCommand);
                db.AddInParameter(dbCommand, "sqlWhereClause", DbType.String, SqlWhereClause);
                db.LoadDataSet(dbCommand, ds, tableName);
            }

            catch (Exception ex)
            {
                ex.Data.Add("Class.Method", "LookupTipoDocumento.getLookupTipoDocumento.");
                ex.Data.Add("SQL", GenericError.SubstituteParameters(dbCommand.CommandText, dbCommand.Parameters));

                // Gestione messaggistica all'utente e trace in DB dell'errore
                ExceptionPolicy.HandleException(ex, "Direct Data Access Policy");
            }

            return(ds);
        }
Beispiel #23
0
        /// <summary>
        /// Cancella l'oggetto dalla base dati.
        /// </summary>
        public void Delete()
        {
            string    sqlCommand = null;
            DbCommand dbCommand  = null;

            try
            {
                Database db = DatabaseFactory.CreateDatabase("CONNECTION_STRING");

                sqlCommand = @" DELETE FROM UTENTE_TRC WHERE 
                            UTE_ID_UTENTE = @ute_id_utente
                            AND UTR_DATA_CREAZIONE = @utr_data_creazione ";

                dbCommand = db.GetSqlStringCommand(sqlCommand);

                db.AddInParameter(dbCommand, "ute_id_utente", DbType.Int32, ute_id_utente);
                db.AddInParameter(dbCommand, "utr_data_creazione", DbType.DateTime, utr_data_creazione);

                db.ExecuteNonQuery(dbCommand);
            }
            catch (Exception ex)
            {
                ex.Data.Add("Class.Method", "UtenteTrc.Delete.");
                ex.Data.Add("SQL", GenericError.SubstituteParameters(dbCommand.CommandText, dbCommand.Parameters));

                // Gestione messaggistica all'utente e trace in DB dell'errore
                ExceptionPolicy.HandleException(ex, "Direct Data Access Policy");
            }
        }
Beispiel #24
0
        /// <summary>
        /// getLookupPermessi
        /// </summary>
        /// <param name="qCultureInfoName"></param>
        /// <returns>dataSet:PMS_ID_MODALITA_ACCESSO,PMS_DESCRIZIONE</returns>
        public IDataReader getLookupPermessi()
        {
            string    sqlCommand = null;
            DbCommand dbCommand  = null;

            try
            {
                Database db = DatabaseFactory.CreateDatabase("CONNECTION_STRING");

                sqlCommand = " SELECT " +
                             " PMS_ID_MODALITA_ACCESSO, " +
                             " PMS_DESCRIZIONE " +
                             " FROM PERMESSI_LOOKUP " + @sqlWhereClause;

                dbCommand = db.GetSqlStringCommand(sqlCommand);
                db.AddInParameter(dbCommand, "sqlWhereClause", DbType.String, sqlWhereClause);

                return(db.ExecuteReader(dbCommand));
            }

            catch (Exception ex)
            {
                ex.Data.Add("Class.Method", "PermessiLookup.getLookupPermessi.");
                ex.Data.Add("SQL", GenericError.SubstituteParameters(dbCommand.CommandText, dbCommand.Parameters));

                // Gestione messaggistica all'utente e trace in DB dell'errore
                ExceptionPolicy.HandleException(ex, "Direct Data Access Policy");

                IDataReader idr = null;
                return(idr);
            }
        }
Beispiel #25
0
        /// <summary>
        /// Crea il record nella tabella di tracciamento password.
        /// </summary>
        public void Create()
        {
            string    sqlCommand = null;
            DbCommand dbCommand  = null;

            try
            {
                Database db = DatabaseFactory.CreateDatabase("CONNECTION_STRING");

                sqlCommand = @" INSERT INTO UTENTE_TRC (
						            UTE_ID_UTENTE, 
						            UTE_PASSWORD) 
					            VALUES ( 
						            @ute_id_utente, 
						            @ute_password) "                        ;

                dbCommand = db.GetSqlStringCommand(sqlCommand);

                db.AddInParameter(dbCommand, "ute_id_utente", DbType.Int32, ute_id_utente);
                db.AddInParameter(dbCommand, "ute_password", DbType.String, ute_password);

                db.ExecuteNonQuery(dbCommand);
            }
            catch (Exception ex)
            {
                ex.Data.Add("Class.Method", "UtenteTrc.Create.");
                ex.Data.Add("SQL", GenericError.SubstituteParameters(dbCommand.CommandText, dbCommand.Parameters));

                // Gestione messaggistica all'utente e trace in DB dell'errore
                ExceptionPolicy.HandleException(ex, "Direct Data Access Policy");
            }
        }
        /// <summary>
        /// Legge i dati per l'oggetto dalla base dati
        /// </summary>
        public void Read(SqlInt32 p_cuc_id_cross_utente_cliente)
        {
            SqlDataReader reader     = null;
            string        sqlCommand = null;
            DbCommand     dbCommand  = null;

            try
            {
                Database db = DatabaseFactory.CreateDatabase("CONNECTION_STRING");

                sqlCommand = @" SELECT 
					 CROSS_UTENTE_CLIENTE.cuc_id_cross_utente_cliente, 
					 CROSS_UTENTE_CLIENTE.cli_id_cliente, 
					 CROSS_UTENTE_CLIENTE.ute_id_utente, 
					 CROSS_UTENTE_CLIENTE.cuc_flag_eliminato, 
					 CROSS_UTENTE_CLIENTE.cuc_data_creazione, 
					 CROSS_UTENTE_CLIENTE.cuc_data_aggiornamento, 
					 CROSS_UTENTE_CLIENTE.ute_creato_da, 
					 CROSS_UTENTE_CLIENTE.ute_aggiornato_da,
                     CROSS_UTENTE_CLIENTE.cuc_flag_stato
				     FROM CROSS_UTENTE_CLIENTE WHERE 
					 (cuc_id_cross_utente_cliente = @cuc_id_cross_utente_cliente) 
					 "                    ;

                dbCommand = db.GetSqlStringCommand(sqlCommand);

                db.AddInParameter(dbCommand, "cuc_id_cross_utente_cliente", DbType.Int32, p_cuc_id_cross_utente_cliente);

                reader = ((RefCountingDataReader)db.ExecuteReader(dbCommand)).InnerReader as SqlDataReader;

                while (reader.Read())
                {
                    cuc_id_cross_utente_cliente = reader.GetSqlInt32(0);
                    cli_id_cliente         = reader.GetSqlInt32(1);
                    ute_id_utente          = reader.GetSqlInt32(2);
                    cuc_flag_eliminato     = reader.GetSqlInt32(3);
                    cuc_data_creazione     = reader.GetSqlDateTime(4);
                    cuc_data_aggiornamento = reader.GetSqlDateTime(5);
                    ute_creato_da          = reader.GetSqlInt32(6);
                    ute_aggiornato_da      = reader.GetSqlInt32(7);
                    cuc_flag_stato         = reader.GetSqlInt32(8);
                }
            }
            catch (Exception ex)
            {
                ex.Data.Add("Class.Method", "CrossUtenteCliente.Read.");
                ex.Data.Add("SQL", GenericError.SubstituteParameters(dbCommand.CommandText, dbCommand.Parameters));

                // Gestione messaggistica all'utente e trace in DB dell'errore
                ExceptionPolicy.HandleException(ex, "Direct Data Access Policy");
            }

            finally
            {
                if (reader != null)
                {
                    ((IDisposable)reader).Dispose();
                }
            }
        }
Beispiel #27
0
        /// <summary>
        /// Cancella l'oggetto dalla base dati.
        /// </summary>
        public void Delete()
        {
            // sistemare .....

            string    sqlCommand = null;
            DbCommand dbCommand  = null;

            try
            {
                Database db = DatabaseFactory.CreateDatabase("CONNECTION_STRING");

                sqlCommand = @" DELETE FROM RUOLI_UTENTE
                               WHERE URL_ID_RUOLI_UTENTE = @url_id_ruoli_utente ";
                dbCommand  = db.GetSqlStringCommand(sqlCommand);
                db.AddInParameter(dbCommand, "url_id_ruoli_utente", DbType.Int32, url_id_ruoli_utente);

                db.ExecuteNonQuery(dbCommand);
            }
            catch (Exception ex)
            {
                ex.Data.Add("Class.Method", "RuoliUtente.Delete.");
                ex.Data.Add("SQL", GenericError.SubstituteParameters(dbCommand.CommandText, dbCommand.Parameters));

                // Gestione messaggistica all'utente e trace in DB dell'errore
                ExceptionPolicy.HandleException(ex, "Direct Data Access Policy");
            }
        }
Beispiel #28
0
    public static void GetUserHistory(ResponseCallback callback, ResponseFallback fallback)
    {
        HttpClient httpClient = new HttpClient();

        Request request = new Request(HttpClient.Method.GET, Route.GET_HISTORY_ROUTE);

        httpClient.Request(
            request,
            (statusCode, response) => {
            HistoryResponse historyResponse = Deserialize(response);

            callback(historyResponse);
        },
            (statusCode, error) => {
            if (statusCode == StatusCodes.CODE_VALIDATION_ERROR)
            {
                ValidationError validationError = ErrorDeserilizer.DeserializeValidationErrorData(error);
                fallback(statusCode, validationError);
            }
            else
            {
                GenericError genericError = ErrorDeserilizer.DeserializeGenericErrorData(error);
                fallback(statusCode, genericError);
            }
        }
            );
    }
Beispiel #29
0
    public static void DepositUserFunds(DepositPayload payload, ResponseCallback callback, ResponseFallback fallback)
    {
        HttpClient httpClient = new HttpClient();

        Request request = new Request(HttpClient.Method.POST, Route.DEPOSIT_ROUTE, payload);

        httpClient.Request(
            request,
            (statusCode, response) => {
            DepositResponse depositResponse = Deserialize(response);
            callback(depositResponse);
        },
            (statusCode, error) => {
            if (statusCode == StatusCodes.CODE_VALIDATION_ERROR)
            {
                ValidationError validationError = ErrorDeserilizer.DeserializeValidationErrorData(error);
                fallback(statusCode, validationError);
            }
            else
            {
                GenericError genericError = ErrorDeserilizer.DeserializeGenericErrorData(error);
                fallback(statusCode, genericError);
            }
        }
            );
    }
Beispiel #30
0
        /// <summary>
        /// Cancella l'oggetto dalla base dati.
        /// </summary>
        public void Delete(SqlInt32 p_cgc_id_cross_gruppi_cliente_utenti, DbTransaction transaction)
        {
            string    sqlCommand = null;
            DbCommand dbCommand  = null;

            try
            {
                Database db = DatabaseFactory.CreateDatabase("CONNECTION_STRING");

                sqlCommand = @" UPDATE CROSS_GRUPPI_CLIENTE_UTENTI SET CGC_FLAG_ELIMINATO = 1 WHERE 
					(cgc_id_cross_gruppi_cliente_utenti = @cgc_id_cross_gruppi_cliente_utenti) 
					"                    ;

                dbCommand = db.GetSqlStringCommand(sqlCommand);

                db.AddInParameter(dbCommand, "cgc_id_cross_gruppi_cliente_utenti", DbType.Int32, p_cgc_id_cross_gruppi_cliente_utenti);

                db.ExecuteNonQuery(dbCommand, transaction);
            }
            catch (Exception ex)
            {
                ex.Data.Add("Class.Method", "CrossGruppiClienteUtenti.Delete.");
                ex.Data.Add("SQL", GenericError.SubstituteParameters(dbCommand.CommandText, dbCommand.Parameters));

                // Gestione messaggistica all'utente e trace in DB dell'errore
                ExceptionPolicy.HandleException(ex, "Direct Data Access Policy");
            }
        }
            /// <summary>
            /// Creates an system error from an exception
            /// </summary>
            /// <param name="exception">Exception</param>
            /// <param name="additionalInformation">Additional information about this error (if any).</param>
            /// <param name="handled">Informs whether the exception was properly handled.</param>
            /// <returns>Error object.</returns>
            public static Error CreateError(Exception exception, bool handled = true, string additionalInformation = null)
            {
                Check.Argument.IsNotNull(exception, "exception");

                Error error;
                if (exception is DomainException)
                {
                    error = new DomainError();
                }
                else
                {
                    error = new GenericError();
                }

                error.GeneratedAt = DateTime.Now;
                error.Type = exception.GetType().FullName;
                error.Message = exception.Message;
                error.Details = ExceptionManager.GetExceptionAsString(exception);
                error.AdditionalInformation = additionalInformation;
                error.Handled = handled;

                return error;
            }
Beispiel #32
0
			public static ErrorMarker Create(EditorDocument EditorDoc, GenericError Error)
			{
				var em = new ErrorMarker(EditorDoc, Error);

				em.ForegroundColor = Error.ForegroundColor;
				em.BackgroundColor = Error.BackgroundColor;
				if (Error.MarkerColor.HasValue)
					em.MarkerColor = Error.MarkerColor.Value;

				// Init offsets manually
				try
				{
					if (Error.Line >= EditorDoc.Editor.Document.LineCount)
						return null;

					if (Error.Line == EditorDoc.Editor.Document.LineCount-1 &&
						EditorDoc.Editor.Document.Lines[Error.Line].Length > Error.Column)
						return null;

					em.StartOffset = EditorDoc.Editor.Document.GetOffset(Error.Line, Error.Column);
				}
				catch
				{
					return null;
				}

				if (Error.Length > 0)
					em.Length = Error.Length;
				else
					em.CalculateWordOffset(em.StartOffset, false);

				return em;
			}
Beispiel #33
0
			ErrorMarker(EditorDocument EditorDoc, GenericError Error)
				:base(EditorDoc.MarkerStrategy)
			{
				this.EditorDocument = EditorDoc;
				this.Error = Error;
			}