我怎样才能捕捉到Windows用户名包含到我的下文code? [英] How can I capture the WINDOWS USERNAME included to my below code?

查看:115
本文介绍了我怎样才能捕捉到Windows用户名包含到我的下文code?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 私人无效UndeletableComments(LinqDataSourceUpdateEventArgs E)
{
    //获取当前保存的项目**** NOTE(州)的引用是类名。它的状态的表中该测试数据库
    VAR CURRENTDATA =((迈德特)e.OriginalObject).Notes;    //使无论是在编辑栏副本,并去掉了previous评论
    VAR newData =((迈德特)e.NewObject).Notes.Replace(CURRENTDATA,的String.Empty);    //检查空值两个值
    如果(CURRENTDATA = NULL&放大器;!&安培;!newData = NULL)
    {
        newData =((迈德特)e.NewObject).Notes.Replace(CURRENTDATA,的String.Empty);
    }    //替换数据被存储在数据库中与CURRENTDATA +的newData
    //我添加了一个邮戳看到添加了新的注释时。
    ((迈德特)e.NewObject).Notes =的String.Format({0}补充:{1}在(2)--- {3},CURRENTDATA,DateTime.Now.ToShortDateString(),DateTime.Now。 ToLongTimeString(),newData);
    //我需要通过捕捉到看到窗口USERNAME谁增加了一个新的评论


解决方案

看的 Environment.UserName

  Console.WriteLine(用户名:{0},System.Environment.UserName);

private void UndeletableComments(LinqDataSourceUpdateEventArgs e)
{
    //get a reference to the currently saved item ****NOTE (State) is the ClassName. It’s a table of states in this test database
    var currentData = ((MyData)e.OriginalObject).Notes;

    // make a copy of whatever is in the edit field and strip out the previous comments
    var newData = ((MyData)e.NewObject).Notes.Replace(currentData, string.Empty);

    //check both values for nulls
    if (currentData != null && newData != null)
    {
        newData = ((MyData)e.NewObject).Notes.Replace(currentData, string.Empty);
    }

    // replace the data to be stored in the database with the currentdata + the newData 
    // I added a datestamp to see when the new comment was added.
    ((MyData)e.NewObject).Notes = string.Format("{0} Added:{1} at (2) --- {3}", currentData, DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString(), newData);


    // I need to see the WINDOW USERNAME by capturing who added a new comments

解决方案

see the Environment.UserName

Console.WriteLine("UserName: {0}", System.Environment.UserName);

这篇关于我怎样才能捕捉到Windows用户名包含到我的下文code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆