我有一堆行,我想分成两列,并从每列获取数据.数据看起来像这样:
current_well.well_number
current_well.well_name
current_well.well_type_code
well_location.section
well_location.range
Run Code Online (Sandbox Code Playgroud)
基本上我想要做的是根据周期分割线,将数据转换为两列,然后获取每列的数据.我知道这可以在Excel中完成,但我真的对这个问题的VI解决方案感兴趣.我知道
%s/\./
Run Code Online (Sandbox Code Playgroud)
将使用空格式格式化字符串.但是,一旦我的数据看起来像:
current_well well_number
current_well well_name
current_well well_type_code
well_location section
well_location range
Run Code Online (Sandbox Code Playgroud)
如何获取每列的所有值,以便将其粘贴到另一个应用程序中?
我遇到了ADO.NET 2.0合并/导入数据的问题.我需要将数据从一个通用表更新/插入另一个表,两个表都维护相同的模式.以下代码在本地运行良好,但不会对数据库进行更改:
OleDbDataAdapter localDA = loadLocalData();
OleDbDataAdapter hostedDA = loadHostedData();
DataSet dsLocal = new DataSet();
localDA.Fill(dsLocal);
DataSet dsChanges = new DataSet();
hostedDA.Fill(dsChanges);
dsLocal.Tables[0].Merge(dsChanges.Tables[0],false);
localDA.Update(dsLocal.Tables[0]);
Run Code Online (Sandbox Code Playgroud)
这段代码片段也是如此:
OleDbDataAdapter localDA = loadLocalData();
OleDbDataAdapter hostedDA = loadHostedData();
DataSet dsLocal = new DataSet();
localDA.Fill(dsLocal);
DataSet dsChanges = new DataSet();
hostedDA.Fill(dsChanges);
foreach (DataRow changedRow in dsChanges.Tables[0].Rows)
{
if (recordExists(dsLocal.Tables[0], changedRow["ID"]))
{
}
else
{
dsLocal.Tables[0].ImportRow(changedRow);
}
}
localDA.Update(dsLocal.Tables[0]);
Run Code Online (Sandbox Code Playgroud)
当我查看RowState属性的更改/追加行时,它们保持"不变".我想尽可能避免数据映射列,这是我可能需要使用NewRow()方法和修改现有行.
我创建了一个具有以下转换的Nuget 配置转换文件:
<?xml version="1.0">
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IMyService" />
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://mydomain/MySvc/MySvc.svc"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IMyService"
contract="MyNamespace.MyService" name="NetTcpBinding_IMyService">
<identity>
<userPrincipalName value="admin@mydomain.com" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
Run Code Online (Sandbox Code Playgroud)
当它合并到应用程序的 app.config 或 web.config 文件时会出现问题。它不是整齐地间隔,而是将所有内容合并为一行,如下所示:
<system.serviceModel><bindings><netTcpBinding><binding name="NetTcpBinding_IMyService" /></netTcpBinding></bindings><client><endpoint address="net.tcp://mydomain/MySvc/MySvc.svc" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IMyService" contract="MyNamespace.MyService" name="NetTcpBinding_IMyService"><identity><userPrincipalName value="admin@mydomain.com" /> </identity></endpoint></client></system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
对于那些使用我的包裹的人来说,这不是很容易理解。有什么我想念的吗?也许正确的回车?
我在试图找出如何恰当地命名我的命名空间时遇到了问题.我的命名空间目前是:
<CompanyName>.<ProductName>.Configuration
Run Code Online (Sandbox Code Playgroud)
但是,使用"配置"与以下内容冲突:
System.Configuration
Run Code Online (Sandbox Code Playgroud)
更糟糕的是,我还有一个名为ConfigurationManager的类.我知道我可以将其更改为:
<CompanyName>.<ProductName>.<ProductName>Configuration
Run Code Online (Sandbox Code Playgroud)
但这似乎是多余的.有任何想法吗?
编辑:此外,我知道在调用任何一个类时,我可以完全限定调用代码,但System.Configuration命名空间和<CompanyName>.<ProductName>.Configuration命名空间中的类将被使用的频率将导致丑陋的代码.
EDIT2:提供细节:
使用陈述:
using System.Configuration;
using SummitConfiguration = SST.Summit.Configuration;
Run Code Online (Sandbox Code Playgroud)
问题行 配置config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
错误消息 'SST.Summit.Configuration'是'命名空间',但它像'类型'一样使用(对于上面的问题行)
有没有办法将域对象和映射文件分成两个单独的项目?我想创建一个名为MyCompany.MyProduct.Core的项目,其中包含我的域模型,另一个名为MyCompany.MYProduct.Data.Oracle的项目包含我的Oracle数据映射.但是,当我尝试单元测试时,我收到以下错误消息:
找不到命名查询"GetClients".
这是我的映射文件:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="MyCompany.MyProduct.Core"
namespace="MyCompany.MyProduct.Core"
>
<class name="MyCompany.MyProduct.Core.Client" table="MY_CLIENT" lazy="false">
<id name="ClientId" column="ClientId"></id>
<property name="ClientName" column="ClientName" />
<loader query-ref="GetClients"/>
</class>
<sql-query name="GetClients" callable="true">
<return class="Client" />
call procedure MyPackage.GetClients(:int_SummitGroupId)
</sql-query>
</hibernate-mapping>
Run Code Online (Sandbox Code Playgroud)
这是我的单元测试:
try
{
var cfg = new Configuration();
cfg.Configure();
cfg.AddAssembly( typeof( Client ).Assembly );
ISessionFactory sessionFactory = cfg.BuildSessionFactory();
IStatelessSession session = sessionFactory.OpenStatelessSession();
IQuery query = session.GetNamedQuery( "GetClients" );
query.SetParameter( "int_SummitGroupId", 3173 );
IList<Client> clients = query.List<Client>();
Assert.AreNotEqual( 0, clients.Count );
}
catch( Exception ex )
{
throw …Run Code Online (Sandbox Code Playgroud) 我想基于表单验证禁用我的jQuery按钮.根据文档,使用常规按钮使用语法相当容易,例如:
<button ng-click="save(user)" ng-disabled="form.$invalid">Save</button>
Run Code Online (Sandbox Code Playgroud)
但是,当更改为jQuery UI按钮时,这不再有效.我假设Angular在jQuery UI和AngularJS之间没有真正的绑定,因此需要一个指令来执行以下操作:
$("button" ).button( "option", "disabled" );
Run Code Online (Sandbox Code Playgroud)
是这种情况还是有其他选择?我正在尝试做的事情是:http://jsfiddle.net/blakewell/vbMnN/.
我的代码看起来像这样:
视图
<div ng-app ng-controller="MyCtrl">
<form name="form" novalidate class="my-form">
Name: <input type="text" ng-model="user.name" required /><br/>
Email: <input type="text" ng-model="user.email" required/><br/>
<button ng-click="save(user)" ng-disabled="form.$invalid">Save</button>
</form>
</div>
Run Code Online (Sandbox Code Playgroud)
调节器
function MyCtrl($scope) {
$scope.save = function (user) {
console.log(user.name);
};
$scope.user = {};
};
$(function () {
$("button").button();
});
Run Code Online (Sandbox Code Playgroud) 我有一个带有Get方法的WebAPI控制器,如下所示:
public class MyController : ApiController
{
public ActionResult Get(string id)
{
//do some stuff
}
}
Run Code Online (Sandbox Code Playgroud)
我们面临的挑战是尝试使用Web API实现WebDAV.这意味着当用户浏览文件夹结构时,URL将更改为:
/api/MyController/ParentFolder1/ChildFolder1/item1.txt
有没有办法将该操作路由到MyController.Get并提取出路径,以便我得到:
Run Code Online (Sandbox Code Playgroud)ParentFolder1/ChildFolder1/item1.txt
谢谢!
我想使用应用程序池凭据来避免来自 Web API 方法的双跳问题。但是,我不希望模拟所有请求,而只是模拟这一特定请求。代码目前看起来像这样:
[Route("api/mycontroller/mymethod")]
public string GetDataFromOtherInternalSystem(int id)
{
var client = new WebClient ( Credentials = CredentialCache.DefaultNetworkCredentials);
return client.DownloadString('http://internaldomain/api/method/id')
}
Run Code Online (Sandbox Code Playgroud)
根据我对MSDN 的理解,用户上下文是该浏览器会话的登录用户(即我的帐户通过 Active Directory 而不是应用程序池的帐户)。
DefaultNetworkCredentials 返回的凭据表示应用程序在其中运行的当前安全上下文的身份验证凭据。对于客户端应用程序,这些通常是运行该应用程序的用户的 Windows 凭据(用户名、密码和域)。对于 ASP.NET 应用程序,默认网络凭据是登录用户或被模拟用户的用户凭据。
这会产生双跳问题,如果请求完全来自作为服务帐户的 Web 应用程序(无需我即时构建凭据),则可以消除该问题。
关于如何在不指定用户凭据的情况下模拟应用程序池的任何想法,如下所示:
var cred = new NetworkCredential("myusername", "mypassword")
Run Code Online (Sandbox Code Playgroud)
我再次尝试避免为 Kerberos 或 CORS 正确设置其他 Web 服务。
我是Silverlight的新手,所以我没有完全掌握所有可用的控件.我想要做的是使用数据绑定和视图模型来维护项目集合.这是我想要做的一些模拟代码:
模型
public class MyItem
{
public string DisplayText { get; set; }
public bool Enabled { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
视图模型
public class MyViewModel : INotifyPropertyChanged
{
private ObservableCollection<MyItem> _myItems = new ObservableCollection<MyItem>();
public ObservableCollection<MyItem> MyItems
{
get { return _myItems; }
set
{
_myItems = value
NotifyPropertyChanged(this, "MyItems");
}
}
}
Run Code Online (Sandbox Code Playgroud)
视图
<Grid x:Name="LayoutRoot" Background="White">
<StackPanel ItemsSource="{Binding MyItems}">
<StackPanel Orientation="Horizontal">
<CheckBox "{Binding Enabled, Mode=TwoWay}"></CheckBox>
<TextBlock Text="{Binding DisplayText, Mode=TwoWay}" />
</StackPanel>
</StackPanel>
</Grid>
Run Code Online (Sandbox Code Playgroud)
所以我的最终目标是每次我将另一个添加MyItem到MyItems集合时,它将创建一个带有复选框和文本块的新StackPanel.我不必使用堆栈面板但只是想我会将其用于此示例.
检索自定义类名的最佳方法是什么?我的目标是远离使用描述我的类的每个变体的枚举,如下所示:
enum
{
MyDataType1,
MyDataType2,
MyDataType3
}
Run Code Online (Sandbox Code Playgroud)
每个类的实现如下:
MyDataType1 : IGenericDataType
MyDataType2 : IGenericDataType
//etc...
Run Code Online (Sandbox Code Playgroud)
但是,我有时需要显示每个类的类型的用户友好名称.在我从枚举中得到这个之前,但现在我想从类元数据中获取它,如果可能的话.因此,而不是MyDataType1.GetType().名称将显示类名称我想使用自定义名称(无需在类中定义属性).
放置资源字符串的最佳位置在哪里?这取决于范围吗?目前,我们的大多数字符串都放置在项目级别,但某些字符串仅需要一种表单。我的想法是这些字符串应该尽可能靠近它们的用途放置。
我想创建一个可以容纳许多相同类型的类的类.例如,让我说我有一个基类,如下所示:
public class BaseClass
{
public string MyBaseString
{
get;
set;
}
}
Run Code Online (Sandbox Code Playgroud)
然后我有一些像这样的派生类:
public class DerivedClass : BaseClass
{
public MyDerivedClassString
{
get;
set;
}
}
public class DerivedClass2 : BaseClass
{
public MyDerivedClass2String
{
get;
set;
}
}
Run Code Online (Sandbox Code Playgroud)
现在我想要一个接受其中一个实现的类,并用它做一些事情.这是我唯一能想到的,但必须有一个更好的方法:
public class ClassA
{
public object MyClass
{
get;
set;
}
public ClassA (object myClass)
{
MyClass = myClass;
if (object is BaseClass)
{
//do something
}
else if (object is DerivedClass)
{
//do something specific to derived class …Run Code Online (Sandbox Code Playgroud) .net ×6
c# ×4
.net-4.0 ×1
ado.net ×1
angularjs ×1
app-config ×1
asp.net ×1
c#-4.0 ×1
jquery-ui ×1
mvvm ×1
namespaces ×1
nhibernate ×1
nuget ×1
oledb ×1
resources ×1
security ×1
silverlight ×1
vi ×1
vim ×1
web-config ×1