我有以下代码,如果对象在缓存中获取它的想法很简单,如果没有然后从数据源检索它并将其保存到缓存中,我使用resharper我得到了这个警告但是无法理解为什么
public static ModulosPorUsuario GetModulesForUser(string identityname)
{
// It needs to be cached for every user because every user can have different modules enabled.
var cachekeyname = "ApplicationModulesPerUser|" + identityname;
var cache = CacheConnectionHelper.Connection.GetDatabase();
ModulosPorUsuario modulosUsuario;
//get object from cache
string modulosUsuariosString = cache.StringGet(cachekeyname);
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
if (modulosUsuariosString != null)
{
//conver string to our object
modulosUsuario = JsonConvert.DeserializeObject<ModulosPorUsuario>(modulosUsuariosString);
return modulosUsuario;
}
// ReSharper disable once HeuristicUnreachableCode
modulosUsuario = DbApp.ModulosPorUsuario.Where(p => p.Email == identityname).FirstOrDefault();
//convert object to …
Run Code Online (Sandbox Code Playgroud) 我需要使用Active Directory中的一个或多个特定用户来保护我的Web api,在web.config中,我具有以下代码:
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="users" type="System.Configuration.NameValueFileSectionHandler,System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<users>
<add key="user" value="domain\loginname" />
</users>
<system.web>
<authentication mode="Windows" />
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
Run Code Online (Sandbox Code Playgroud)
然后,我有一个自定义授权属性,该属性从上面显示的web.config部分读取用户。
public class MyAuthorizeAttribute : AuthorizeAttribute
{
public MyAuthorizeAttribute(params string[] userKeys)
{
List<string> users = new List<string>(userKeys.Length);
var allUsers = (NameValueCollection)ConfigurationManager.GetSection("users");
foreach (var userKey in userKeys)
{
users.Add(allUsers[userKey]);
}
this.Users = string.Join(",", users);
}
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
bool …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 powershell 从 Channel9 下载视频系列,但是我在第一个文件上收到此错误,我认为它是管道字符,但即使使用替换语句它也不起作用
\n\n function Get-Media\n{\n [CmdletBinding()]\n param\n (\n [Object]\n $url,\n [Object]\n $title,\n [Object]\n $path\n )\n\n $u = New-Object System.Uri($url)\n $name = $title\n $extension = [System.IO.Path]::GetExtension($u.Segments[-1])\n $fileName = $name + $extension\n\n $fileName = $fileName -replace "\xc3\xa2\xe2\x82\xac\xe2\x84\xa2", \'\'\n $fileName = $fileName -replace "\\?", \'\'\n $fileName = $fileName -replace ":", \'\'\n $fileName = $fileName -replace \'/\', \'\'\n $fileName = $fileName -replace ",", \'\'\n $fileName = $fileName -replace \'"\', \'\'\n $fileName = $fileName -replace \'|\', \'\'\n $fileName = $fileName -replace \'\\#\', …
Run Code Online (Sandbox Code Playgroud) 我在一个文件上有这个:
export module Utils {
export enum DataSources {
SharepointList = "SharepointList",
JsonData = "JsonData"
};
}
Run Code Online (Sandbox Code Playgroud)
在另一个文件上我有这个:
import CustomerDAO from "./ICustomerDAO";
import SharepointListDAOFactory from "./SharepointListDAOFactory";
import JsonDAOFactory from "./JsonDAOFactory";
import {Utils} from "./DatasourcesEnum";
export default abstract class DAOFactory{
public static SHAREPOINTLIST: number = 1;
public static REMOTEJSON : number = 2;
public abstract getCustomerDAO(): CustomerDAO;
public static getDAOFactory(whichFactory: Utils.DataSources): DAOFactory {
switch (whichFactory) {
case whichFactory.SharepointList:
return new SharepointListDAOFactory();
case whichFactory.JsonData:
return new JsonDAOFactory();
default :
return null;
} …
Run Code Online (Sandbox Code Playgroud) 我正在尝试执行此操作:
Login-AzureRmAccount
Login-AzureRmAccount : The term 'Login-AzureRmAccount' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again
Run Code Online (Sandbox Code Playgroud)
我使用平台安装程序在 Windows 8 上安装了 Azure Powershell。
重新启动后,我得到模块名称:
Get-Module -ListAvailable
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Script 1.1.3.2 PowerShellGet {Install-Module, Find-Module, Save-Module, Update-Module...}
Binary 2.17.17... SharePointPnPPowerShell2013 …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用npm run-script build构建一个项目
我的package.json就是这样
{
"name": "isomorphic",
"version": "2.6.0",
"private": true,
"dependencies": {
"adal-angular": "^1.0.17",
"antd": "^3.0.3",
"antd-local-icon": "^0.1.3",
"axios": "^0.18.0",
"classnames": "^2.2.5",
"clone": "^2.1.1",
"history": "^4.6.3",
"nprogress": "^0.2.0",
"postcss-inline-rtl": "^0.9.8",
"q": "^1.5.1",
"react": "^16.2.0",
"react-adal": "^0.4.17",
"react-dom": "^16.2.0",
"react-highlight-words": "^0.16.0",
"react-intl": "^2.3.0",
"react-placeholder": "^2.0.0",
"react-redux": "^5.0.4",
"react-router": "^4.1.1",
"react-router-dom": "^4.1.0",
"react-router-redux": "^5.0.0-alpha.5",
"react-scripts": "1.0.17",
"react-sidebar": "^2.3.2",
"react-smooth-scrollbar": "^8.0.6",
"react-throttle": "^0.3.0",
"react-window-size-listener": "^1.0.10",
"redux": "^3.6.0",
"redux-devtools": "^3.3.2",
"redux-devtools-dock-monitor": "^1.1.1",
"redux-devtools-log-monitor": "^1.2.0",
"redux-saga": "^0.16.0",
"redux-thunk": "^2.2.0",
"smooth-scrollbar": "^8.2.5",
"styled-components": "^2.2.1",
"styled-theme": …
Run Code Online (Sandbox Code Playgroud) 我有一个包含大量行的超网格,最后添加了新行,我希望在添加新行时,选择该行并且网格也应滚动到底部.
我打算尝试使用ActiveRow,但它说它没有安装器
private void ultraButtonCreateNew_Click(object sender, EventArgs e)
{
DialogResult dr = new DialogResult();
FormAddUnit form = new FormAddUnit();
form.BuildingDataSet = _buildingDataSet;
form.SectionDataSet = _sectionDataSet;
form.UnitDataSet = _uc011_WizardStepUnitDataSet;
form.SummaryDataSet = _summaryDataSet;
form.FormState = WizardState.Create;
form.Enablement = false;
dr = form.ShowDialog();
if (dr == DialogResult.Yes)
{
UC011_WizardStepUnitDataSet.UnitRow row = form.GetRow();
_uc011_WizardStepUnitDataSet.Unit.AddUnitRow(row);
SetUltraGridData();
ultraGridOverview.DisplayLayout.ActiveRow = row;
SetSummaryDataSet();
}
}
Run Code Online (Sandbox Code Playgroud) 在过去,我有过调用WCF服务或ASMX服务的经验,你只需要添加.svc或.asmx url的服务引用,它就会为你生成代理,然后你就可以通过intellisense来调用这些方法.
非.net网络服务是否相同?
我需要称之为 http://www.earthtools.org/webservices.htm
来自winrt应用程序中的c#代码,但我不知道如何
在当前场景中,我试图将文档集从一个库复制到另一个库,事情是我无法使用DocumentSet.Import,因为我只需要docset属性而不是内容.
此代码的System.Update中引发异常.
private void CopyAgendaPointToRootSite(SPListItem agendaPointItem, string oldReasonReturned)
{
try
{
if (agendaPointItem != null)
{
SPWeb currentSite = agendaPointItem.ParentList.ParentWeb;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(currentSite.Site.RootWeb.Url))
{
using (SPWeb elevatedTargetWeb = site.OpenWeb())
{
SPList targetList = GetAgendaPointProposedTargetLibrary(agendaPointItem, elevatedTargetWeb);
SPDocumentLibrary targetDocumentLibrary = (SPDocumentLibrary)targetList;
SPContentTypeId targetCTId = targetList.ContentTypes.BestMatch(new SPContentTypeId(MeetingsCommon.Constants.CONTENTTYPES_AGENDAPOINTPROPOSED_ID));
DocumentSet documentSet = DocumentSet.GetDocumentSet(agendaPointItem.Folder);
if (documentSet != null)
{
string strAgendaPointTitle = agendaPointItem[MeetingsCommon.Constants.FIELDS_AGENDAPOINTTITLENL_NAME] +
" / " + agendaPointItem[MeetingsCommon.Constants.FIELDS_AGENDAPOINTTITLEFR_NAME];
SPListItemCollection colProposedItems = FindAgendaPointProposedItem((SPDocumentLibrary)targetList, documentSet.Item.Name);
if (colProposedItems.Count > 0)
throw new Exception(string.Format(HelperFunctions.GetResourceString( …
Run Code Online (Sandbox Code Playgroud) 出于某种原因,一个magento网址在我的网站上运行不正常.请参见此处: 完整性约束违规:1052订单子句中的列"位置"不明确
所以,我决定我可以为这个失败的url做一个重定向:我试过apache但是它不起作用看到这里: Apache简单重定向从一个页面到另一个页面
他们建议用php做
有人可以解释我如何用PHP做到这一点?
就像是
if url = 'myfaliingurl' then
redirect to new url
Run Code Online (Sandbox Code Playgroud)
而已
这是我在apache中尝试过的
Redirect 301 http://www.theprinterdepo.com/catalogsearch/result/index/?cat=100&q=1022&x=0&y=0 http://www.theprinterdepo.com/catalogsearch/advanced/result/?name=1022&sku=&price%5Bfrom%5D=&price%5Bto%5D=&free_shipping=&category=100
Run Code Online (Sandbox Code Playgroud)
更新1:
它不起作用,我把它放在index.php的最后.
if($url == 'http://www.theprinterdepo.com/catalogsearch/result/index/?cat=100&q=1022&x=0&y=0')
{
header('location:http://www.theprinterdepo.com/catalogsearch/result/index/?cat=100&q=1022&x=0&y=0 http://www.theprinterdepo.com/catalogsearch/advanced/result/?name=1022&sku=&price%5Bfrom%5D=&price%5Bto%5D=&free_shipping=&category=100');
exit();
}
else
{
Mage::run('printerdepo','website');
}
Run Code Online (Sandbox Code Playgroud) c# ×5
powershell ×2
.net ×1
apache ×1
asp.net-mvc ×1
azure ×1
azure-devops ×1
enums ×1
fxcop ×1
infragistics ×1
javascript ×1
magento ×1
npm ×1
npm-install ×1
php ×1
reactjs ×1
redirect ×1
resharper ×1
sharepoint ×1
typescript ×1
ultrawingrid ×1
web-services ×1
winforms ×1