Exemplo n.º 1
0
        public RcStruct SetSubsAttributes(AttrCommandInfo[]  cmd)
        {
            string connStr = getConnectionString ();
            logMessage ("setSubsAttributes begin");

            RcStruct objRc = new RcStruct ();
            objRc.rc = 0;

            using (OracleConnection objConn = new OracleConnection(connStr))
            {
                objConn.Open();
                OracleTransaction transaction;

                OracleCommand objCmd = new OracleCommand("WS_SET_ATTR.set_attr", objConn);
                objCmd.CommandType = CommandType.StoredProcedure;
                transaction = objConn.BeginTransaction ();

                try
                {
                    objCmd.Transaction = transaction;

                    int i;
                    bool isOk = true;

                    for (i=0; i< cmd.Length; i++)
                    {
                        AttrCommandInfo cmdItem = cmd[i];

                        objCmd.Parameters.Clear();
                        //WS_SET_ATTR.set_attr (25995, 'STYPE', '1');
                        logMessage (string.Format ("command input: MSSIDN={0}, ATTR_NAME={1}, ATTR_VALUE={2}", cmdItem.msisdn, cmdItem.attr_name,cmdItem.attr_value));
                        objCmd.Parameters.Add("MSSIDN"    , OracleType.VarChar).Value = cmdItem.msisdn;
                        objCmd.Parameters.Add("ATTR_NAME" , OracleType.VarChar).Value = cmdItem.attr_name;
                        objCmd.Parameters.Add("ATTR_VALUE", OracleType.VarChar).Value = cmdItem.attr_value;
                        objCmd.Parameters.Add("RC", OracleType.Number).Direction = ParameterDirection.Output;

                        objCmd.ExecuteNonQuery();

                        string rc = objCmd.Parameters["RC"].Value.ToString();
                        logMessage (string.Format ("command output: RC={0}", rc));

                        if ( rc != "0" )
                        {
                            isOk = false;
                            objRc.rc  = Int32.Parse(rc);

                            string errMsg;

                            switch (objRc.rc)
                            {
                                case 1:
                                    errMsg = "subs id not found";
                                    break;

                                case 2:
                                    errMsg = "invalid attribute name";
                                    break;

                                case 3:
                                    errMsg = "invalid attribute value";
                                    break;

                                default:
                                    errMsg = "Unexpected errorcode " + rc + ". See to stored procedure for more details.";
                                    break;
                            }

                            objRc.msg = "FAILED set '" + cmdItem.attr_name + "' to value '" + cmdItem.attr_value + "' on msisdn '" + cmdItem.msisdn + "'";
                            break;
                        }
                    }

                    if ( isOk )
                    {
                        transaction.Commit();
                    }
                    else
                    {
                        transaction.Rollback ();
                    }
                }

                catch (Exception e)
                {
                    transaction.Rollback();
                    logError ("SetSubsAttributes failed", e);
                }

                finally
                {
                    objConn.Close();
                }
            }

            logMessage ("setSubsAttributes end: " + objRc.ToString());
            return objRc;
        }
Exemplo n.º 2
0
        public RcStruct checkPin(string AcctID, string MSISDN,  string pwd)
        {
            string connStr = getConnectionString ();
            logMessage ("checkPin begin");

            RcStruct objRc = new RcStruct ();
            objRc.rc = 0;

            using (OracleConnection objConn = new OracleConnection(connStr))
            {
                objConn.Open();
                OracleTransaction transaction;

                OracleCommand objCmd = new OracleCommand("ws_check_pwd.check_acct_pin", objConn);
                objCmd.CommandType = CommandType.StoredProcedure;
                transaction = objConn.BeginTransaction ();

                try
                {
                    objCmd.Transaction = transaction;

                    objCmd.Parameters.Clear();
                    //WS_SET_ATTR.set_attr (25995, 'STYPE', '1');
                    logMessage (string.Format ("input: p_acct_id={0}, MSSIDN={1}, pwd={2}", AcctID, MSISDN, "CENSORED"));
                    objCmd.Parameters.Add("p_acct_id", OracleType.VarChar).Value = dbNlv(AcctID);
                    objCmd.Parameters.Add("p_mssidn" , OracleType.VarChar).Value = dbNlv(MSISDN);
                    objCmd.Parameters.Add("p_pin"    , OracleType.VarChar).Value = dbNlv(pwd);
                    objCmd.Parameters.Add("p_result" , OracleType.Number).Direction = ParameterDirection.Output;

                    objCmd.ExecuteNonQuery();

                    string rc = objCmd.Parameters["p_result"].Value.ToString();
                    logMessage (string.Format ("command output: p_result={0}", rc));

                    objRc.rc  = Int32.Parse(rc);
                    string errMsg;

                    switch (objRc.rc)
                    {
                        case -1:
                            errMsg = "no account for mssidn";
                            break;

                        case -2:
                            errMsg = "invalid account id";
                            break;

                        case 1:
                            errMsg = "password is ok";
                            break;

                        case 0:
                            errMsg = "password is not ok";
                            break;

                        default:
                            errMsg = "Unexpected errorcode " + rc + ". See to stored procedure for more details.";
                            break;
                    }
                    objRc.msg = errMsg;

                    transaction.Commit();
                }

                catch (Exception e)
                {
                    transaction.Rollback();
                    logError ("checkPin failed", e);
                }

                finally
                {
                    objConn.Close();
                }
            }

            logMessage ("checkPin end: " + objRc.ToString());
            return objRc;
        }