我有一个API返回的json response.当我打电话API给Fiddler它时,它给我json reponse
如下所示:
从网页调用API:
protected void FinalCall()
{
// try
// {
string url = txtdomainURL.Text.Trim();
string apiname = txtAPIname.Text.Trim();
string apiURL = apiname+"/"+txtStoreID.Text.Trim()+"/"+txtSerialNo.Text.Trim(); //"duediligence/1/45523354232323424";// 990000552672620";//45523354232323424";
//duediligence/1/45523354232323424 HTTP/1.1
string storeID = txtStoreID.Text.Trim();//Test Store ID:1 Live Store ID: 2
string partnerID = txtPartnerID.Text.Trim();// "1";
string scretKey = txtSecretKey.Text.Trim();// "234623ger787qws3423";
string requestBody = txtRequestBody.Text.Trim(); //"{\"category\": 8}";
string data = scretKey + requestBody;
string signatureHash = SHA1HashStringForUTF8String(data);
lblSignatureHash.Text = signatureHash;
String userName …Run Code Online (Sandbox Code Playgroud) 我创建了一个WPF应用程序,Entity framework 4.0.当我试图在PhoneNumber表中插入记录时,它成功地插入了第一条记录.但是,当我遍历一些List并尝试将另一个项插入PhoneNumber表时,它插入记录但显示错误为:
InvalidOperationException由用户代码处理:对数据库的更改已成功提交,但更新对象上下文时发生错误.ObjectContext可能处于不一致状态.内部异常消息:发生了引用完整性约束违规:定义引用约束的属性值在关系中的主体和从属对象之间不一致.
.cs文件中的代码:
protected void InsertContact(List<PhoneNumbersList> phoneList,otherparameters here)
{
Contact contact = new Contact();
PhoneNumber phnumber = new PhoneNumber();
//INSERT into Contacts Table
contact.PrefixTitleID = cfnm.PrefixTitleID;// cfnm.Title;
contact.FirstName = cfnm.FirstName;
contact.MiddleName = cfnm.MiddleName;
contact.LastName = cfnm.LastName;
contact.Website = webpageaddress;
contact.SuffixID = cfnm.SuffixID;
contact.Gender = gender;
contact.IMAddress = imaddress;
db.Contacts.Add(contact);
db.SaveChanges();
int contactid=contact.ContactID;
if (contactid > 0)
{
int phid = 0;
//INSERT into PhoneNumber Table
foreach (var ph in phoneList)
{
phnumber.PhoneTypeID …Run Code Online (Sandbox Code Playgroud) .net entity-framework invalidoperationexception foreign-key-relationship
我有一个包含三列的表我想使用自联接并检索具有别名的列.
表:Material(ID,Name,MaterialParentID)
public List<Material> GetMaterialList()
{
List<Material> materilaList = new List<Material>();
var query = (from c1 in db.Materials
join c2 in db.Materials on c1.ID equals c2.MaterialParentID
select c2);
return query.ToList();
}
Run Code Online (Sandbox Code Playgroud)
我想在exisiting查询中添加以下内容并返回List
select new { c2.ID, c2.MaterialParentID, c2.Name, ParentName = c1.Name })
Run Code Online (Sandbox Code Playgroud) 我有一个DataTable包含一些行。复制到DataView。现在,我有ID的形式List<string>。其中包含从中选择的项目GridView。现在,我想DataView使用AND作为过滤器对此进行过滤。
当我只应用一个时,它起作用,但是应用多个时,AND则不起作用。
在.cs中:
List<string> selectedAddress = new List<string>();
protected DataView GetSelectedItems()
{
DataView dv = new DataView(dtresult);
int count = selectedAddress.Count();
if (count > 0)
{
string query = "ID=";
for (int j = 0; j < selectedAddress.Count; j++)
{
string val = selectedAddress[j].ToString();
if (j == 0)
{
query += val + " and ";
}
else
{
query += "ID=" + val + "";
}
} …Run Code Online (Sandbox Code Playgroud) 我有一个方法可以生成Coupon Code. 任何人都可以帮助/建议生成ALPHANUMERIC CODE吗?
以下是方法:
public string CouponGenerator(int length)
{
var sb = new StringBuilder();
for (var i = 0; i < length; i++)
{
var ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * _random.NextDouble() + 65)));
sb.Append(ch);
}
return sb.ToString();
}
private static readonly Random _random = new Random();
Run Code Online (Sandbox Code Playgroud)
例子:
UZWKXQML 当 Lenght 设置为 8 时
但它需要像U6WK8Q2Lie 字母数字代码这样的东西。
我是新手MySQL。我有一列存储Unicode character在MySQL表中。
我有一个代码,它从twitter,facebook等处获取帖子并将text/symbol “原样”插入表中。
CREATE TABLE `tbl_unicode` (
`_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`first_name` varchar(45) NOT NULL,
`uninoce_Column` varchar(200) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`_id`)
) ENGINE=InnoDB AUTO_INCREMENT=201 DEFAULT CHARSET=utf8;
/* This query WONT work due to SYMBOL: */
INSERT INTO `tbl_unicode`
(`_id`,
`first_name`,
`uninoce_Column`)
VALUES
(2,
'rakesh',
'?????
#??#??#????#');
/* This query WORKS FINE */
INSERT INTO `tbl_unicode`
(`_id`,
`first_name`,
`uninoce_Column`)
VALUES
(1,
'shekhar', …Run Code Online (Sandbox Code Playgroud) 我有一个OpenDialog在我的wpf应用程序中,用户可以选择文件并保存到文件夹.我想将图像保存到特定文件夹,并在wpf中单击按钮时设置文件名和扩展名.
文件夹结构:
-MyAppDirectory
--ContactImages
-1.jpg
当我执行以下代码时,它会ContactImages在Bin文件夹中创建" "目录,而不是在Application main direcotry中.任何的想法?以及如何在wpf和设置文件名中获取上传文件的文件扩展名?
在xaml.cs文件中:
private void imgContactImage_MouseDown(object sender, MouseButtonEventArgs e)
{
string folderpath = Environment.CurrentDirectory + "\\ContactImages\\";
op.Title = "Select a picture";
op.Filter = "All supported graphics|*.jpg;*.jpeg;*.png|" +
"JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|" +
"Portable Network Graphic (*.png)|*.png";
bool? myResult;
myResult = op.ShowDialog();
if (myResult != null && myResult == true)
{
imgContactImage.Source = new BitmapImage(new Uri(op.FileName));
if (!Directory.Exists(folderpath))
{
Directory.CreateDirectory(folderpath);
}
//System.IO.File.Copy(op.FileName,filename);
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个标记,其中包含div一些images如图所示。目前每个部分都是div垂直显示的。但是,我想在屏幕转储中显示左侧的项目和右侧的文本。
HTML 标记:
<div id="divgetpaidnow" style="float:none;width:200px;" class="paymentclass" paytype="GetPaidNow" paytypeid="1">
<asp:Image ID="Image1" src="images/getpaidnow.jpg" runat="server" class="paymentimg" />
<div>
</div>
<asp:RadioButton ID="rdo1" Text="Get Paid Now" runat="server" class="myradio" GroupName="rdoPaymentgroup" />
<div class="payTypeFooterText" style="float:none;"> <strong>Get Paid Now:</strong><br />
Instant Cash, visit one of our Mall Locations and get Paid Today
</div>
</div>
<div id="divamazon" style="float: none;" class="paymentclass" paytype="Amazon" paytypeid="2">
<asp:Image ID="Image2" src="images/amazon.jpg" runat="server" class="paymentimg" />
<div style="margin-top: 10px;">
</div>
<asp:RadioButton ID="rdo2" Text="Recommended" runat="server" class="myradio" GroupName="rdoPaymentgroup" />
<div class="payTypeFooterText">
<strong>Amazon …Run Code Online (Sandbox Code Playgroud) 我有一个字符串,其中空格被替换为hyphen i.e '-'如果有多个连字符然后我想从字符串中删除除一个以外的所有.只有连字符必须删除; 不是连续的数字.
例如: - 11-必须是-11-而不是-1-
例如: - 12- o/p:-12-
例如:-12-- o/p:-12-
在C#中使用Linq或字符串函数.
我尝试过使用它str = str.Remove(str.Length - 1);,但它只删除一个字符.
c# ×6
asp.net ×3
.net ×1
alphanumeric ×1
css ×1
dataview ×1
filtering ×1
html ×1
json ×1
linq ×1
mysql ×1
random ×1
rowfilter ×1
save ×1
save-image ×1
sql-insert ×1
string ×1
symbols ×1
unicode ×1
wpf-controls ×1