为什么我的Model类数据不正确?
var day = txtDay.option("value");
var shiftId = workingShift.option("value");
Log.d的内容:
$GUIDS = ($DS.Tables[0] | select -ExpandProperty siteid) | Format-Table -HideTableHeaders | Out-String
foreach($line in $guids)
{Get-Spsite -identity $line | Select -property ID, URL, OWner, Hostname | Export-Csv -Path c:\temp\url.csv -NoTypeInformation }
为什么[CmdletBinding()]
param
(
[Parameter(Mandatory=$True)]
[string]$SQLServerInstance,
[Parameter(Mandatory=$True)]
[string]$NintexConfigDBName
)
Add-PSSnapin Microsoft.SharePoint.PowerShell
$ConnectionTimeout = 30
$Query = "SELECT DISTINCT i.workflowname,i.siteid,i.workflowinitiator, a.activityname FROM dbo.workflowinstance
i inner join WorkflowProgress P on I.InstanceID=P.InstanceID inner join Activities A on P.ActivityID=A.ActivityID WHERE a.activityname IN ('Call web service','Execute SQL','Query LDAP','Query XML', 'Start workflow in Nintex Workflow Cloud ', 'Update XML ', 'Web request ', 'Capture document set version ', 'Copy to file share', 'Create list', 'Declare as record ', 'Delete drafts', 'Delete item ', 'Delete multiple items', 'Delete previous versions', 'Discard check out ','Query list','Send document set to repository', 'Send document to repository','Set approval status ','Set item permissions', 'Undeclare as record ', 'Update multiple items', 'Action set', 'Commit pending changes', 'Run parallel actions', 'State machine ', 'Pause for... ', 'Pause until... ', 'Wait for check out status change ', 'Wait for item update ', 'Create site ','Create site collection','Decommission site collection ', 'Delete site', 'Publish Workflow', 'Assign Flexi task', 'Complete workflow task ' ) "
$QueryTimeout = 120
$conn=new-object System.Data.SqlClient.SQLConnection
$ConnectionString = "Server={0};database={1};Integrated Security=True;Connect Timeout={2}" -f $SQLServerInstance,$NintexConfigDBName,$ConnectionTimeout
$conn.ConnectionString=$ConnectionString
$conn.Open()
$cmd=new-object system.Data.SqlClient.SqlCommand($Query,$conn)
$cmd.CommandTimeout=$QueryTimeout
$ds=New-Object system.Data.DataSet
$da=New-Object system.Data.SqlClient.SqlDataAdapter($cmd)
$da.fill($ds)
$conn.Close()
$DS.Tables[0]
$workflowdetails = ($DS.Tables[0] | select -ExpandProperty siteid, workflowinitiator, workflowname,activityname ) | Format-Table -HideTableHeaders | Out-String
$GUIDS = ($DS.Tables[0] | select -ExpandProperty siteid) | Format-Table -HideTableHeaders | Out-String
foreach($line in $guids)
{Get-Spsite -identity $line | Select -property ID, URL, OWner, Hostname | Export-Csv -Path c:\temp\url.csv -NoTypeInformation }
?
为什么List<DataMasterList> dataMasterLists = new ArrayList<DataMasterList>();
private void addMaster() {
for (int i = 0; i < 6; i++) {
DataMasterList dataMasterList = new DataMasterList();
dataMasterList.setMaster_code("000" + i);
dataMasterList.setProduct_name("name" + i);
dataMasterList.setAmount(4 + i + "");
dataMasterList.setUnit_price(10 + "");
dataMasterLists.add(dataMasterList);
Log.d("test1",dataMasterLists.get(i).getMaster_code()+" ");
}
Log.d("test2",dataMasterLists.get(0).getMaster_code()+" ");
}
中的每个值都是test1: 0000
test1: 0001
test1: 0002
test1: 0003
test1: 0004
test1: 0005
test2: 0005
?
答案 0 :(得分:0)
问题是关于更改字段类行为的访问修饰符。 你正在混淆类实例变量和类变量。
案例1(实例变量)
public class DataMasterList {
private String masterCode;
public DataMasterList() {
// TODO Auto-generated constructor stub
}
public String getMasterCode() {
return this.masterCode;
}
public void setMasterCode(String masterCode) {
this.masterCode = masterCode;
}
private String masterCode;
您只能使用访问器方法访问此字段,并且在创建新实例时,每个实例都有自己的字段。
案例2(静态变量)
public class DataMasterList {
static String masterCode;
public DataMasterList() {
// TODO Auto-generated constructor stub
}
public static String getMasterCode() {
return masterCode;
}
public static void setMasterCode(String masterCode) {
DataMasterList.masterCode = masterCode;
}
}
static String masterCode;
您可以直接访问该字段而无需访问者方法,也无需创建任何对象实例。无论如何,如果您创建像您的情况一样的实例,当您修改上一次 masterCode 时,它将影响所有实例。