小编Rya*_*tes的帖子

如何使用外部ID工作?

upsert如何在Salesforce API中工作?

我相信它会检查它是否存在具有唯一ID的记录.在它可用的情况下,它会更新记录,否则创建记录.

它是否正确?

我收到以下错误

  Upsert failed. First exception on row 1; first error: DUPLICATE_EXTERNAL_ID, Asset Tag: more than one record found for external id field: [a11M0000000CwJqIAK, a11M0000000CwJvIAK]: [Asset_Tag__c]
Run Code Online (Sandbox Code Playgroud)

我有一个包含项目的列表,并且没有重复的Asset_Tag值.

 system.debug('LstItem Asset_Tag__c'+LstItem );
    upsert  LstItem Asset_Tag__c;
Run Code Online (Sandbox Code Playgroud)

从调试日志

   LstItem Asset_Tag__c(Item_c__c:{Scanned_By__c=005M0000000IlxyIAC, Asset_Tag__c=12149, Status__c=Active, Scan_Location__c=001M0000008GzJXIA0, Last_Scan_Date__c=2011-12-17 06:08:47}, Item_c__c:{Scanned_By__c=005M0000000IlxyIAC, Asset_Tag__c=23157, Status__c=Active, Scan_Location__c=001M0000008GzJXIA0, Last_Scan_Date__c=2011-12-17 08:26:14})
Run Code Online (Sandbox Code Playgroud)

我该怎么做才能解决这个问题?

api salesforce apex-code

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

单元测试中断言的最佳实践

我正在尝试测试一个以三个参数作为输入的应用程序(A面,B面,C面)并计算三角形isoscele(两边相等),scalene(两边都不相等)或等边(所有双方是平等的).

下面是我正在进行的单元测试的一些代码.在这种情况下,我正在测试应用程序告诉用户三角形是等速的,我的问题是在这种情况下Assert之后应该有什么?AreNotSame适用于scalene,AreSame适用于等边,但这里有什么用?提前致谢.

    public void isIsoscelesTest()
    {
        Triangle target = new Triangle(5.0, 5.0, 2.0); // TODO: Initialize to an appropriate value
        bool expected = true; // TODO: Initialize to an appropriate value
        bool actual;
        actual = target.isIsosceles();
        Assert.AreNotSame(expected, actual);
    }
Run Code Online (Sandbox Code Playgroud)

//来自应用程序......

    public bool isIsosceles() {
      if(uniqueSides()==2)
        return true;
      return false;
    }
Run Code Online (Sandbox Code Playgroud)

c# unit-testing visual-studio-2010

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

如何使用C#的Magento REST API

在哪里可以找到显示如何使用C#连接到Magento REST API的示例?

我发现是一个PHP,除了一点点我无法弄清楚.

使用我在网上找到的Dropbox OAuth示例,我试图让它适用于Magento:

private void button1_Click(object sender, RoutedEventArgs e) 
{ 
    var consumerKey = “xxxxxxxxxxxxx”; 
    var consumerSecret = “xxxxxxxxxxxxxxxx”;

    var uri = new Uri("http://www.MagentoWebsite.com/oauth/token");

    // Generate a signature 
    OAuthBase oAuth = new OAuthBase(); 
    string nonce = oAuth.GenerateNonce(); 
    string timeStamp = oAuth.GenerateTimeStamp(); 
    string parameters; 
    string normalizedUrl; 
    string signature = oAuth.GenerateSignature(uri, consumerKey, consumerSecret, 
    String.Empty, String.Empty, “GET”, timeStamp, nonce, OAuthBase.SignatureTypes.HMACSHA1, 
    out normalizedUrl, out parameters);

    signature = HttpUtility.UrlEncode(signature);

    StringBuilder requestUri = new StringBuilder(uri.ToString()); 
    requestUri.AppendFormat("?oauth_consumer_key={0}&", consumerKey); 
    requestUri.AppendFormat("oauth_nonce={0}&", nonce); 
    requestUri.AppendFormat("oauth_timestamp={0}&", timeStamp); 
    requestUri.AppendFormat("oauth_signature_method={0}&", “HMAC-SHA1"); 
    requestUri.AppendFormat("oauth_version={0}&", …
Run Code Online (Sandbox Code Playgroud)

c# api rest magento

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

获得ultragridcolumn的实际宽度

如何在UltraGrid中准确地获得扩展的UltraGridColumn宽度?

我有以下Windows窗体:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        IEnumerable<string> test = new List<string>{DateTime.Now.ToString()};
        this.ultraGrid2.DataSource = test;
        this.ultraGrid2.DisplayLayout.AutoFitStyle = AutoFitStyle.ExtendLastColumn;
    }

    private void button1_Click(object sender, EventArgs e)
    {
        MessageBox.Show("The column width is " + this.ultraGrid2.DisplayLayout.Bands[0].Columns[0].Width);
    }
}
Run Code Online (Sandbox Code Playgroud)

形式是什么样的

无论我如何操纵或调整表单.在width仍然给出了同样的默认值.只有我调整列的大小才会改变.在这种情况下,我认为宽度将接近表单本身的x大小.

c# infragistics ultrawingrid winforms

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

如何用C(整数)读取文本文件中的特定行

我遇到程序问题(程序的一部分).为了进一步继续,我需要以某种方式读取文件的一行,但必须是一个特定的行.我是C和文件的新手......

我想要做的是要求用户输入他们想要阅读的特定行,然后将其显示给他们.目前,当我尝试从行中打印文本时,它只给出了第1行的文本.请注意,通过文本我的意思是整数,因为该文件由一列中的55个整数组成.所以它看起来像这样:12 18 54 16 21 64 .....

有没有办法达到我的需要?

#include <stdio.h>

FILE *file;

char name[15];
int line;
int text;

file = fopen("veryimportantfile.txt","r");
if(file==NULL)
{
    printf("Failed to open");
    exit(1);
}


printf("Your name: ");
scanf("%s",&name);
printf("\Enter the line number you want to read: ");
scanf("%d",&line);


fscanf(pFile, "%d", &line);
printf("The text from your line is: %d",line);
Run Code Online (Sandbox Code Playgroud)

c file scanf

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

字符串"0.080"加倍使80.00

我在c#中有这个问题,我想将一个字符串转换为double.

textBoxKostOnderhoud.Text = "0.08";

kost.OnderhoudKost = double.Parse(textBoxKostOnderhoud.Text);
Run Code Online (Sandbox Code Playgroud)

这使我的数据库中的80.00,我不知道为什么.这个问题有什么解决方案吗?

这是我如何将我的值添加到数据库(mysql)

public bool insert(Kost kost)
{
    string query = "INSERT INTO kost (wagenId, onderhoudKost, tolKost, bedrijfsVerzekering, autoVerzekering, ladingVerzekering, wegenBelasting, eurovignet, accountantKost, telefoonKost, documentenEnVergunningen, onvoorzien, overige, andere) VALUES('" + kost.WagenId + "', '" + kost.OnderhoudKost + "', '" + kost.TolKost + "', '" + kost.BedrijfsVerzekering + "', '" + kost.AutoVerzekering + "', '" + kost.LadingVerzekering + "', '" + kost.WegenBelasting + "', '" + kost.Eurovignet + "', '" + kost.AccountantKost + "', '" …
Run Code Online (Sandbox Code Playgroud)

c# mysql string double parsing

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

在CheckedChange事件上禁用/启用多个项目

我有几个复选框和一个文本框.当我选中某个复选框时,它将禁用文本框和其他指定的复选框.

该代码适用于文本框.当我添加else语句时,它仍适用于文本框,但不适用于复选框.如果我省略else并且仅使用它if来禁用它们,它就可以工作.如果取消选中该复选框,我需要它重新启用它们.

我在面板中有所有问题的复选框.

    private void noModemChkbox_CheckedChanged(object sender, EventArgs e)
    {
        if (noModemChkbox.Checked == true)
        {
            custModemText.Enabled = false;
            pwrCbx.Enabled = false;
            e1Cbx.Enabled = false;
            e2Cbx.Enabled = false;
            e3Cbx.Enabled = false;
            e4Cbx.Enabled = false;
            dslblinkCbx.Enabled = false;
            enetCbx.Enabled = false;
            dslCbx.Enabled = false;
            inetCbx.Enabled = false;
            inetredCbx.Enabled = false;
            wlanCbx.Enabled = false;
            activityChkbox.Enabled = false;
        }
        else
            custModemText.Enabled = true;
        pwrCbx.Enabled = true;
        e1Cbx.Enabled = true;
        e2Cbx.Enabled = true;
        e3Cbx.Enabled = true;
        e4Cbx.Enabled = true; …
Run Code Online (Sandbox Code Playgroud)

c# checkbox winforms

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

使用XElement保存XML文件时,文件中的对齐方式也会发生变化,如何避免?

我在用

XElement root = XElement.Load(filepath);
Run Code Online (Sandbox Code Playgroud)

加载XML文件,然后找到我需要的东西.

IEnumerable<XElement> commands = from command in MyCommands
                                 where (string) command.Attribute("Number") == Number
                                 select command;

foreach (XElement command in commands)
{
     command.SetAttributeValue("Group", GroupFound);
}
Run Code Online (Sandbox Code Playgroud)

完成更改后,我使用以下代码保存文件.

root.Save(filepath);
Run Code Online (Sandbox Code Playgroud)

保存文件时,我的XML文件中的所有行都会受到影响.默认情况下,Visual Studio会对齐所有行,但我需要保存原始文件格式.

除了Group属性值之外,我无法更改文档的任何部分.

command.SetAttributeValue("Group") attributes.
Run Code Online (Sandbox Code Playgroud)

c# xml xelement whitespace

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

UnitTestIsolationException:在Release/Debug模式下运行Shims测试时抛出异常

我试图使用Microsoft Shims运行此单元测试,但它在Shims.Context.Create();方法中抛出异常.

环境: VS 2012,Win2K8 R2

namespace MyShimsUnitTest
{
    [TestClass]
    public class MyUnitTest
    {
        [TestMethod]
        public void GetCurrentYear()
        {
            using (Microsoft.QualityTools.Testing.Fakes.ShimsContext.Create())
            {
                // Some Logic...
            }
        }

    }
}
Run Code Online (Sandbox Code Playgroud)

详细例外:

Result Message: 
Test method MyShimsUnitTest.MyUnitTest.GetCurrentYear threw exception: 
Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException: UnitTestIsolation instrumentation failed to initialize. Please restart Visual Studio and rerun this test
Result StackTrace:  
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.InitializeUnitTestIsolationInstrumentationProvider()
   at Microsoft.QualityTools.Testing.Fakes.Shims.ShimRuntime.CreateContext()
   at Microsoft.QualityTools.Testing.Fakes.ShimsContext.Create()
   at MyShimsUnitTest.MyUnitTest.GetCurrentYear()
Run Code Online (Sandbox Code Playgroud)

c# unit-testing microsoft-fakes

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

Limit NLog Database Target Size

How can I configure NLog in such a way that it will log to a database table (in my case SQL Server) and purge rows after a certain time period?

I am using NLog with the database target. The file target has multiple options to rollover and eventually delete log files (e.g. by date/time, size, etc.). I would like to be able to use something similar in NLog.

The following NLog file target configuration allows me to set logs …

sql-server logging nlog

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