我有一组具有两个属性的对象:名称和小时.
例如:
array = [
{name: "ANDY", hours: 40 },
{name: "ANDY", hours: 50 },
{name: "GREG", hours: 40 },
]
Run Code Online (Sandbox Code Playgroud)
例如,在我的数组中,我希望排序的结果是Andy的小时数最多,Andy的小时数稍长,然后是Greg,因为他的名字后来按字母顺序排列,依此类推.
由于array.sort()函数传递数组的两个元素进行比较,我意识到这不是我的方法,但未能提出一个优雅的解决方案.请帮帮我.
我有以下问题:我正在编写一个循环,检查文件夹中是否出现某些文件,如果是,则将这些文件移动到另一个文件夹.
该脚本现在运行良好,这是它的代码:
$BasePath = "C:\From"
$TargetPath = "C:\To"
$files = Get-ChildItem -File -Recurse -Path "$($BasePath)\$($Filename)" -ErrorAction SilentlyContinue
foreach ($file in $files)
{
$subdirectorypath = split-path $file.FullName.Replace($BasePath, "").Trim("\")
$targetdirectorypath = "$($TargetPath)\$($subdirectorypath)"
if ((Test-Path $targetdirectorypath) -eq $false)
{
Write-Host "Creating directory: $targetdirectorypath"
md $targetdirectorypath -Force
}
Write-Host "Copying file to: $($targetdirectorypath.TrimEnd('\'))\$($File.Name)"
Move-Item $File.FullName "$($targetdirectorypath.TrimEnd('\'))\$($File.Name)" -Force
}
Run Code Online (Sandbox Code Playgroud)
但是,由于其中一些文件可能非常大,我想以"一劳永逸"的方式异步移动这些文件.使用PowerShell的最佳方法是什么?这个脚本可能会永远运行,因此我认为任何异步作业都必须在完成复制后自行处理.
谢谢你的建议
我正在开发一个使用WCF服务的SharePoint工作流 - 事实是,我无法正确部署app.config文件.这就是我所说的:
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:55693/Service1.svc" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IService1" contract="ServiceReference1.IService1"
name="WSHttpBinding_IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
我无法找到如何动态地设置代码,有人会这么善良并指出我正确的方向吗?