小编Sri*_*ri7的帖子

NodeJs - 从JWT令牌中检索用户infor?

节点和角度.我有一个MEAN堆栈身份验证应用程序,我在成功登录时设置JWT令牌,如下所示,并将其存储在控制器的会话中.通过服务拦截器将JWT令牌分配给config.headers:

var token = jwt.sign({id: user._id}, secret.secretToken, { expiresIn: tokenManager.TOKEN_EXPIRATION_SEC });
            return res.json({token:token});
Run Code Online (Sandbox Code Playgroud)

authservice.js拦截器(省略requestError,response和responseError):

authServices.factory('TokenInterceptor', ['$q', '$window', '$location','AuthenticationService',function ($q, $window, $location, AuthenticationService) {
        return {
            request: function (config) {
                config.headers = config.headers || {};
                if ($window.sessionStorage.token) {
                    config.headers.Authorization = 'Bearer ' + $window.sessionStorage.token;
                }
                return config;
            }               
        };
    }]);
Run Code Online (Sandbox Code Playgroud)

现在我想从令牌中获取登录的用户详细信息,我该怎么做?我尝试如下,不工作.当我从Users.js文件记录错误时,它说"ReferenceError:headers not defined"

authController.js:

$scope.me = function() {
    UserService.me(function(res) {
      $scope.myDetails = res;
    }, function() {
      console.log('Failed to fetch details');
      $rootScope.error = 'Failed to fetch details';
    })
  };
Run Code Online (Sandbox Code Playgroud)

authService.js:

authServices.factory('UserService',['$http', function($http) …
Run Code Online (Sandbox Code Playgroud)

javascript node.js jwt angularjs

16
推荐指数
2
解决办法
3万
查看次数

Angular Material:如何在注销时关闭所有mat-dialogs和sweet-alert

我想在Angular中注销时关闭所有对话框(mat-dialog,bootstrap modals和sweet alert).这是在AngularJS(版本1.5)中完成的方式:

function logout() {
  //hide $mdDialog modal
  angular.element('.md-dialog-container').hide();

  //hide any open $mdDialog modals & backdrop
  angular.element('.modal-dialog').hide();
  angular.element('md-backdrop').remove();

  //hide any open bootstrap modals & backdrop
  angular.element('.inmodal').hide();
  angular.element('.fade').remove();

  //hide any sweet alert modals & backdrop
  angular.element('.sweet-alert').hide();
  angular.element('.sweet-overlay').remove();
}
Run Code Online (Sandbox Code Playgroud)

我怎么能在Angular中做到这一点?使用$('.mat-dialog-container')$('.inmodal')不给我一个选择hide()或做close()

我尝试过这样做,但我无法获得元素参考:

import { ElementRef, Injectable, ViewChild } from '@angular/core';
import { MatDialog, MatDialogContainer, MatDialogRef } from '@angular/material';

export class MyClass
{
  @ViewChild('.mat-dialog-container') _matDialog: ElementRef;
  @ViewChild('.mat-dialog-container') _matDialogRef:MatDialogRef<MatDialog>;

  constructor() { }

  function logout()
  {
    //access the …
Run Code Online (Sandbox Code Playgroud)

angular-material ng-bootstrap angular sweetalert2

14
推荐指数
2
解决办法
1万
查看次数

Web部署错误ERROR_DESTINATION_NOT_REACHABLE

我正在尝试使用以下msdeploy命令部署我的应用程序:

MSDeploy.exe -source:contentPath="C:\Users\myUser\Documents\ui\dist" -dest:contentPath='c:/inetpub/wwwroot/dist',computerName="https://ec2-xx-xxx-xx-xx.ap-northeast-1.compute.amazonaws.com:8172/MSDeploy.axd?site=Default Web Site",username="administrator",password="XXXXXXXXX",authtype="Basic",includeAcls="False" -verb:sync -allowUntrusted
Run Code Online (Sandbox Code Playgroud)

收到以下错误:

Working...
    Info: Using ID '01657062-cece-4713-8dc6-585537b265fd' for connections to the rem
    ote server.
    >> Error Code: ERROR_DESTINATION_NOT_REACHABLE
    >> More Information: Could not connect to the remote computer ("ec2-52-207-222-6
    5.compute-1.amazonaws.com"). On the remote computer, make sure that Web Deploy i
    s installed and that the required process ("Web Management Service") is started.
      Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_DESTINATION
    _NOT_REACHABLE.
    >> Error: Unable to connect to the remote server
    >> Error: A connection attempt failed because …
Run Code Online (Sandbox Code Playgroud)

msdeploy microsoft-web-deploy

6
推荐指数
1
解决办法
1万
查看次数

自动化Visual Studio DB架构比较并检查GIT

我有一个用于SQL Server DB的Visual Studio 2015数据库项目,我可以在其中进行模式比较/数据比较,并手动将项目签入GIT.我想自动完成这个完整的模式/数据比较过程,生成脚本并将其检入GIT.有可能吗?如果是这样的话?

也许我会做这样的事情?使用EnvDTE自动化Visual Studio

sql-server-2012 sql-server-data-tools visual-studio-2015

5
推荐指数
1
解决办法
2336
查看次数

在AngularJs中使用微调器的甜蜜警报对话框

我正在尝试在sweet alert类似于Bootstrap模态对话框(http://jsfiddle.net/D6rD6/5/)的对话框中显示微调框

我能想到的最接近的东西是这样的:

SweetAlert.swal({
title: '<small>Import errors occurred !</small>',
text: '<i class="fa fa-spinner" aria-hidden="true"></i>',
html: true,
customClass: 'manual-upload-errors-swal-width'
});
Run Code Online (Sandbox Code Playgroud)

如果这不可能,那么最近和最好的解决方案是什么?

javascript twitter-bootstrap angularjs bootstrap-modal sweetalert

5
推荐指数
1
解决办法
6227
查看次数

AngularJS - ReferenceError:未定义成功

当从控制器到我的node.js后端执行Restful调用时,我得到"ReferenceError:success is not defined",如下所示:

authControllers.js:

authControllers.controller('authCtrl', ['$scope', '$location', '$window', 'UserService', 'AuthenticationService',
function authCtrl($scope, $location, $window, UserService, AuthenticationService) {
  $scope.me = function() {    
    UserService.me(function(res) {
      $scope.myDetails = res;
    }, function() {
      console.log('Failed to fetch details');
      $rootScope.error = 'Failed to fetch details';
    })
  };      
}]);
Run Code Online (Sandbox Code Playgroud)

authServices.js:

authServices.factory('UserService',['$http', function($http) {
  return {        
    me:function() {
    return $http.get(options.api.base_url + '/me').success(success).error(error)
    }
  }
}]);
Run Code Online (Sandbox Code Playgroud)

HTML:

<div class="row" data-ng-controller="authCtrl" data-ng-init="me()">
    <div class="col-lg-12">
        <div class="panel panel-primary">
            <div class="panel-heading">
                <strong>Your Details</strong>
            </div>
            <div class="panel-body">
                <p>{{myDetails.data.username}}</p>
                <p>{{myDetails.data.email}}</p>
            </div>
        </div>
    </div> …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

3
推荐指数
1
解决办法
3641
查看次数

C# array.sort() 对多个数组按降序排列

我有两个名为权重和值的数组。我想根据权重的排序对值进行排序。通过这样做,效果非常好

Array.Sort(Weights,Values);
Run Code Online (Sandbox Code Playgroud)

这给了我按升序排序的数组。我想按降序进行相同的排序。有没有更好的方法不使用 Array.Reverse(Weights) and Array.Reverse(Values)

c# arrays sorting

3
推荐指数
1
解决办法
3373
查看次数

Jenkinsfile windows cmd 输出变量参考

我对 groovy 很陌生。在我Jenkinsfile尝试将 windows cmd 输出存储在一个变量中,在下一个命令中使用它,但似乎没有任何效果。这是我得到的最接近的:

    pipeline {
    agent any    
    stages {        
        stage('package-windows') {
            when {
                expression { isUnix() == false}
            }
            steps {             
                script {
                FILENAME = bat(label: 'Get file name', returnStdout: true, script:"dir \".\\archive\\%MY_FOLDER%\\www\\main.*.js\" /s /b")              
                }
                bat label: 'replace content', script: "powershell -Command \"(gc \"$FILENAME\") -replace \"https://my-qa.domain.com/api/\", \"https://my-prod.domain.com/api/\" | Out-File \"$FILENAME\"\""
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

当我这样做ECHO "$FILENAME"时,我得到的输出是:

C:\Program Files (x86)\Jenkins\workspace\my-ui>dir ".\archive\55131c0d3c28dc69ce39572eaf2f8585996d9108\main.*.js" /s /b 
C:\Program Files (x86)\Jenkins\workspace\my-ui\archive\55131c0d3c28dc69ce39572eaf2f8585996d9108\www\main.16aedaf4c6be4e47266d.js
Run Code Online (Sandbox Code Playgroud)

我只需要main.16aedaf4c6be4e47266d.js在下一个命令中使用的文件名来修改内容。但是在下一个命令中"$FILENAME"是空的。如何将命令输出正确存储在变量中并在下一个命令中访问?

windows cmd jenkins-groovy jenkins-pipeline

3
推荐指数
1
解决办法
2981
查看次数

如何在 64 位服务器 (Win2k8) 上使用 .NET、SAP Crystal reports Engine 64 位将报表打印到所选打印机?

我们有一个基于 .NET 远程处理构建的 Windows 应用程序。它\xe2\x80\x99是使用.NET Framework 2.0构建的32位应用程序。我们使用 .NET Framework 4 的 SAP Crystal reports 运行时引擎(32 位 \xe2\x80\x93 版本 13.0.3)来实现报告功能。还有一个打印功能,可以在批处理运行期间将相应的报告打印到用户选择的打印机上。整个设置在 Windows Server 2003 服务器上运行良好。现在我们正在尝试将应用程序迁移到Windows Server 2008,但打印无法正常工作。它始终将报告打印到 Windows Server 2008 计算机上的默认打印机,而不是打印到所选打印机。

\n\n

CrystalDecisions.CrystalReports.Engine、CrystalDecisions.ReportSource 和 CrystalDecisions.Shared 是引用自的 DLL\xe2\x80\x99s

\n\n

C:\\Program Files\\sap Businessobjects\\crystal reports for .net Framework 4.0\\common\\sap Businessobjects enterprise xi 4.0\\win32_x86

\n\n

我们将应用程序转换为 64 位版本。在 Windows Server 2008 上,即使我们安装了 .NET Framework 4 的 SAP Crystal reports 运行时引擎(64 位 \xe2\x80\x93 版本 13.0.3),打印也无法正常工作(始终打印到默认打印机) )。在64位安装文件夹中也找不到\xe2\x80\x99s上述DLL\xe2\x80\x99s。

\n\n

C:\\Program Files\\sap Businessobjects\\crystal reports for .net Framework 4.0\\common\\sap Businessobjects enterprise …

.net c# printing crystal-reports

1
推荐指数
1
解决办法
9873
查看次数

从 AutoDesk Vault (Vault 2015 SDK) 下载文件,c# 代码给出错误

我正在尝试使用C#代码从 Vault(Vault 2015 SDK)下载文件。尝试了与此处提到的完全相同的方法:http : //inventorhub.autodesk.com/discussions/threads/301/post/5600165 但得到错误

在执行用于下载文件的相应代码行时,请求失败,HTTP 状态为 404:未找到”。

请在下面找到我的示例代码:

using Autodesk.Connectivity.WebServicesTools;
using Autodesk.Connectivity.WebServices; 

UserPasswordCredentials login = new UserPasswordCredentials("servername", "myVault", "username", "Password", true);
using (WebServiceManager serviceManager = new WebServiceManager(login))
{
    Autodesk.Connectivity.WebServices.Folder folder = serviceManager.DocumentService.GetFolderByPath("$/Myfolder");
    Autodesk.Connectivity.WebServices.File[] files = serviceManager.DocumentService.GetLatestFilesByFolderId(folder.Id, false);
    if (files != null && files.Any())
    {
        foreach (Autodesk.Connectivity.WebServices.File file in files)
        {
            //Sample code to download the files
            string localPath = AppDomain.CurrentDomain.BaseDirectory;
            Autodesk.Connectivity.WebServices.File localFile = serviceManager.DocumentService.GetFileById(file.Id);
            var FileDownloadTicket = serviceManager.DocumentService.GetDownloadTicketsByFileIds(new long[] { file.Id });
            FilestoreService fileStoreService …
Run Code Online (Sandbox Code Playgroud)

c# autodesk autodesk-vault

1
推荐指数
1
解决办法
2454
查看次数

无法在Nodejs中找到模块 - module.js

运行节点服务器时出现以下错误:

$ node server.js
module.js:339
    throw err;
    ^

Error: Cannot find module './server/routes'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (C:\Users\attas\documents\github\angular-express-auth\server.js:12:10)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:467:10)
Run Code Online (Sandbox Code Playgroud)

以下是我的项目结构:

项目结构

server.js:

var express = require('express'),
jwt = require('express-jwt'),
bodyParser = require('body-parser'),
morgan = require('morgan'),
methodOverride = require('method-override'),
errorHandler = require('express-error-handler'),
tokenManager = require('./server/config/token_manager'),
secret = require('./server/config/secret'),
http = require('http'),
path = require('path');

var app = module.exports …
Run Code Online (Sandbox Code Playgroud)

javascript node.js npm

0
推荐指数
1
解决办法
1万
查看次数