Exemplo n.º 1
0
        public static Pkit Read(string connectionString, string id, Dber dberr)
        {
            try
            {
                var PkitMasterObject = new Pkit();

                var query = string.Format("select * from Pkit where id = {0}", id);
                var data = DbAccess.ExecuteQuery(connectionString, CommandType.Text, query);

                //assign the data object to Error master object
                if (data.Tables[0].Rows.Count > 0)
                {
                    PkitMasterObject.id = data.Tables[0].Rows[0]["id"].ToString();
                    PkitMasterObject.public_key = data.Tables[0].Rows[0]["public_key"].ToString();
                    PkitMasterObject.private_key = data.Tables[0].Rows[0]["private_key"].ToString();
                    PkitMasterObject.cs_no = data.Tables[0].Rows[0]["cs_no"].ToString();



                    return PkitMasterObject;
                }
                else
                {
                    dberr.setError(Mnemonics.DbErrorCodes.DBERR_PKIT_ERROR);
                    return null;
                }
            }
            catch (Exception ex)
            {
                dberr.setError(Mnemonics.DbErrorCodes.DBERR_PKIT_ERROR);
                return null;
            }
        }
Exemplo n.º 2
0
 public static bool Update(string connectionString, Pkit dataObject, Dber dberr)
 {
     try
     {
         var query = string.Format(@"UPDATE [SBS].[dbo].[PKIT]
                                SET 
                                    [PUBLIC_KEY] =       '{0}'
                                   ,[PRIVATE_KEY] =       '{1}'
                                   
                                   
                                   
                              WHERE CS_NO = {2}", dataObject.public_key, dataObject.private_key, dataObject.cs_no);
         return DbAccess.ExecuteNonQuery(connectionString, CommandType.Text, query) == 1;
     }
     catch(Exception ex)
     {
         dberr.setError(Mnemonics.DbErrorCodes.DBERR_PKIT_ERROR);
         return false;
     }
 }
Exemplo n.º 3
0
        public static int Create(string connectionString, Pkit dataObject, Dber dberr)
        {
            try
            {

                var query = string.Format(@"INSERT INTO [SBS].[dbo].[PKIT]
           ([PUBLIC_KEY]
           ,[PRIVATE_KEY]
           ,[CS_NO])
                    OUTPUT INSERTED.id        
                    VALUES
                    ('{0}'  ,'{1}','{2}' )",
               dataObject.public_key, dataObject.private_key, dataObject.cs_no);
                return (int)DbAccess.ExecuteScalar(connectionString, CommandType.Text, query);
            }
            catch (Exception ex)
            {
                dberr.setError(Mnemonics.DbErrorCodes.DBERR_PKIT_ERROR);
                return -1;
            }
        }
Exemplo n.º 4
0
 private static void UpdatePKIInformation(string connectionString, string customerNumber,Dber dberr)
 {
     var pkiServiceObject = new Security.PKIService();
     var pkiObject = new Pkit
     {
         cs_no = customerNumber,
         private_key = pkiServiceObject.PrivateKey,
         public_key = pkiServiceObject.PublicKey
     };
     PkitD.Create(connectionString, pkiObject, dberr);
 }