所以我试图创建一些能够与用户一起存储发票号码的东西;所以我创建了一个类并为它扩展了基类。我发现由于某种原因我很难解释,所以我只是把代码放在第一位:
基类:
import logging
from logging.handlers import TimedRotatingFileHandler
my_logger = logging.getLogger('my_logger')
my_handler = TimedRotatingFileHandler('logfile.log')
my_logger.addHandler(my_handler)
def get_filename(some_logger):
return [some_handler.baseFilename
for some_handler in some_logger.handlers
if isinstance(some_handler, TimedRotatingFileHandler)]
print(get_filename(my_logger)) # ['/home/finwood/temp/so/logfile.log']
扩展类:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace AMS
{
public class AMSclient
{
private string clientFirstName; //Client first name
private string clientLastName; //Client last name
private string phoneNumber; //Client phone number.
private string streetAddress; //Client street address.
private string state; //Client state.
private string zip; //Client zip.
private string paymentMethod; //Client payment method (Credit card, BTC, cash)
private DateTime dateCreated; //Date + time client is created.
private string email; //Client email.
private int lockedUser; //If you need a password to view client.
private string userPassword; //empty is default if lockedUser != 1
private string groupName; //If client is in group.
private string clientImage; //Client Image.
private long clientID; //Clients ID number.
#region Getters/Setters and all that good shit.
public string ClientFirstName
{
get
{
return clientFirstName;
}
set
{
clientFirstName = value;
}
}
public string ClientLastName
{
get
{
return clientLastName;
}
set
{
clientLastName = value;
}
}
public string PhoneNumber
{
get
{
return phoneNumber;
}
set
{
phoneNumber = value;
}
}
public string StreetAddress
{
get
{
return streetAddress;
}
set
{
streetAddress = value;
}
}
public string State
{
get
{
return state;
}
set
{
state = value;
}
}
public string Zip
{
get
{
return zip;
}
set
{
zip = value;
}
}
public string PaymentMethod
{
get
{
return paymentMethod;
}
set
{
paymentMethod = value;
}
}
public DateTime DateCreated
{
get
{
return dateCreated;
}
set
{
dateCreated = value;
}
}
public string Email
{
get
{
return email;
}
set
{
email = value;
}
}
public int LockedUser
{
get
{
return lockedUser;
}
set
{
lockedUser = value;
}
}
public string UserPassword
{
get
{
return userPassword;
}
set
{
userPassword = value;
}
}
public string GroupName
{
get
{
return groupName;
}
set
{
groupName = value;
}
}
public string imageClient
{
get
{
return clientImage;
}
set
{
clientImage = value;
}
}
public long clientsID
{
get
{
return clientID;
}
set
{
clientID = value;
}
}
#endregion
//Contruct that shit, and fuck you I like the 'this'.
public AMSclient(string first, string last, string number, string address,
string state, string zip, string method, DateTime date, string email, int locked, string userPass, string group, string i)
{
this.clientFirstName = first;
this.clientLastName = last;
this.phoneNumber = number;
this.streetAddress = address;
this.state = state;
this.zip = zip;
this.paymentMethod = method;
this.dateCreated = date;
this.email = email;
this.lockedUser = locked;
this.userPassword = userPass;
this.groupName = group;
this.clientImage = i;
//ClientID set and save via Settings.
this.clientID = AMS.Properties.Settings.Default.clientIDValue;
this.clientID += 1;
AMS.Properties.Settings.Default.clientIDValue += 1;
AMS.Properties.Settings.Default.Save();
}
}
}
发票类:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AMS
{
public class AMSInvoiceList : AMSclient
{
private AMSclient c;
private string btcInvoiceNum;
public AMSInvoiceList(AMSclient client, string invoicenum) : base(client.ClientFirstName, client.ClientLastName,client.PhoneNumber,
client.StreetAddress, client.State, client.Zip, client.PaymentMethod, client.DateCreated, client.Email, client.LockedUser, client.UserPassword, client.GroupName, client.imageClient)
{
this.c = client;
this.btcInvoiceNum = invoicenum;
}
}
}
我尝试做的是这样做,以便我可以将此付款方式的发票存储在" custom"类型清单;我列出的将包含基类的所有内容+已创建的发票号,我希望这是有道理的。 那么如果我这样做(只是说):
//Creates an invoice number for the BTC Transaction.
//1000 - "1" before the "0"s represent a BTC type invoice.
public string createInvoiceNumber(long clientid)
{
AMS.Properties.Settings.Default.btcInvoiceValue += 1;
return clientid + "-" + "1000" + AMS.Properties.Settings.Default.btcInvoiceValue;
}
}
当我开发票时,我可以拨打 AMSInvoiceList a = new AMSInvoiceList(client, "edsudiopjsipodjips");
List<AMSInvoiceList> ax = new List<AMSInvoiceList>();
,然后将其添加到全局列表中(&#34; ax&#34;例如);所以当我想要的时候我可以只调用
AMSInvoiceList a = new AMSInvoiceList(client, "edsudiopjsipodjips");
来自基类的所有信息(所有客户信息)将与发票号一起显示。我希望这是有道理的,我不能在这里做出正面或反面!