小编Dai*_*ges的帖子

使用PowerShell从Windows 10中删除语言

我想在Windows 10中使用Powershell添加或删除语言并从左到右或从右到左更改键盘布局.我编写了添加语言的代码,但我找不到再次删除它或更改布局.我还想询问用户是否要添加或删除语言.

这是我的代码:

$List = Get-WinUserLanguageList
$List.Add("lt-LT")
Set-WinUserLanguageList $List
Run Code Online (Sandbox Code Playgroud)

先感谢您.

powershell windows-10

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

在 JavaScript 中导出带有 # 字符的 CSV 数据不起作用

我将 JSON 数据导出为 CSV 格式并使用 JavaScript 下载。一切正常,除非数据具有井号 #。该函数不会导出所有数据,例如:

这是我在学院的第一堂 C# 课,它仅导出 this is my first C 而忽略其余部分。

这是我的代码

this.handleRow = function (row) {
    var finalVal = '';
    for (var j = 0; j < row.length; j++) {
        var innerValue = "";
        if (row[j]) {
            innerValue = row[j].toString();
        }
        if (row[j] instanceof Date) {
            innerValue = row[j].toLocaleString();
        }
        var result = innerValue.replace(/"/g, '""');
        if (result.search(/("|,|\n)/g) >= 0) {
            result = '"' + result + '"';
        }

        if (j > 0) finalVal …
Run Code Online (Sandbox Code Playgroud)

javascript export-to-csv

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

使用 Vue 从 Web API 获取数据

我有一个 Web API,我正在尝试使用 Vue 从中获取 JSON 数据,但是我既没有得到数据也没有得到错误,所以我不知道有什么问题。我想在加载页面时加载数据。

这是我的代码:

const v = new Vue({
    el: '#divContent',
    ready: function () {
        this.loadData();
    },
    data: {
        content: 'loading',
        serverData: null
    },
    methods: {
        loadData: function (viewerUserId, posterUserId) {
            const that = this;
            $.ajax({
                contentType: "application/json",
                dataType: "json",
                url: "http://my-webapi/",
                method: "Post",
                success: function (response) {                        
                    that.$data.serverData = response;

                },
                error: function () {
                    alert('Error')
                }
            });
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

我的 HTML

<div id="divContent" class="content">
 {{ content }}
</div>
Run Code Online (Sandbox Code Playgroud)

javascript vue.js vuejs2

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

添加日期至今 javascript

我想添加从文本框中获取的日期。我尝试了下面的代码,但它不起作用

    function get_renew_date ()
    {
        var chkautorenew=document.getElementById("MainContent_chk_Isauto_Renew");
        if (chkautorenew.checked) {
            end_date = document.getElementById("MainContent_txtContract_End_date").value;
            renew_date = document.getElementById("MainContent_txtContract_Renew").value;
            dat = new Date(end_date.toDateString());
            //renew_date=dat.addDays(1);
            alert(end_date.toDateString());
        }
     }
Run Code Online (Sandbox Code Playgroud)

我还担心客户端日期格式和该月的最后一天,我如何确定添加一天后不会像这样 32/03/2016

谢谢

javascript datetime

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

具有过期时间的字典缓存

我想创建一个返回值的类。此值将在字典对象中缓存2分钟。在这2分钟内,我需要返回缓存的值,在那几分钟之后,字典缓存对象应再次读取该值。我需要使用Dictionary对象而不是memorychache之类的东西,并且应该在Test方法类中执行代码,而不是Windows窗体或wpf。

我不知道在测试方法中2分钟后如何使字典对象过期。

public class CacheClass
{
   public string GetValue()
   {
      Dictionary<int, string> Cache = new Dictionary<int, string>();
      string value1 = "Lina";
      string value2 = "Jack";

      return "cached value";
   }
}
Run Code Online (Sandbox Code Playgroud)

c# caching dictionary unit-testing

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

最大长度不起作用 Web API 2 模型

我有一个模型类来接收数据,我想将文本输入限制为 10 个字符,但是当我在测试方法中尝试它时,它接受的字符数不止这个。这是我的代码:

public class Post
{
    [Required]
    public string userId { get; set; }
    [Required, StringLength(1, MinimumLength = 10)] 
    public string dataText { get; set; }
    [Required]
    public int dataType { get; set; }
}
[TestMethod()]
public void AddPostTest()
{
    SQLDB db = new SQLDB();
    Post userpost = new Post();
    userpost.userId = "1";
    userpost.dataText = "fgfdgfdgfdgdfgfdgfdgfdgfdgfdgdfgfdg";
    userpost.dataType = 1;

    Assert.IsTrue(db.AddPost(userpost));
}
Run Code Online (Sandbox Code Playgroud)

先感谢您。

c# validation asp.net-web-api2

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

WPF捕获所有异常

我正试图捕获我的WPF应用程序中的所有异常.我尝试了以下代码,但它不工作我不知道为什么?

<Application x:Class="DBFilter.App"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         StartupUri="MainWindow.xaml"
         Exit="Application_Exit"               
         DispatcherUnhandledException ="AppDispatcherUnhandledException"
         >
<Application.Resources>

</Application.Resources>
</Application>
Run Code Online (Sandbox Code Playgroud)

App.xaml.cs

protected override void OnStartup(StartupEventArgs e)
    {
        AppDomain.CurrentDomain.UnhandledException += new 
UnhandledExceptionEventHandler(AppDomainUnhandledExceptionHandler);
        System.Windows.Forms.Application.ThreadException += new 
ThreadExceptionEventHandler(Application_ThreadException);
        Application.Current.DispatcherUnhandledException += new 
DispatcherUnhandledExceptionEventHandler(AppDispatcherUnhandledException);
}

void AppDomainUnhandledExceptionHandler(object sender, 
UnhandledExceptionEventArgs ea)
    {
        Exception ex = (Exception)ea.ExceptionObject;    
 MessageBox.Show(ex.Exception.InnerException.Message);

    }

void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
    {
        MessageBox.Show(e.Exception.InnerException.Message);
    }                       

void AppDispatcherUnhandledException(object 
sender,DispatcherUnhandledExceptionEventArgs e)
    {
        MessageBox.Show(e.Exception.InnerException.Message);
    }
Run Code Online (Sandbox Code Playgroud)

稍后,我将把所有异常写入日志表.

c# wpf

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