Posting a tweet C# - c#

I am trying to post a tweet with TweetSharp library but a StackOverflowException is thrown. I couldn't solve this problem. What should I do? The error occurs in this line:
servis.SendTweet(new SendTweetOptions { Status = textBox1.Text });

Break it down and step through in the debugger (put a break-point on the string status = ... line):
// if you don't get this far, the problem is elsewhere
// if it fails here, the problem is accessing the textbox value
string status = textBox1.Text;
// if it fails here, the problem is inside the tweetsharp library,
// and should be referred to the library authors, but indicating which
// step fails (constructor vs Status property vs Send method)
var msg = new SendTweetOptions();
msg.Status = status;
servis.SendTweet(msg);

Related

Error SA1500: Braces for multi-line statements should not share line

Error SA1500: Braces for multi-line statements should not share line
getting this error on code
if (ObjItem != null)
{
return new JsonResult(new
{
model = new ItemModel
{
Id = ObjItem.Id,
ItemName = ObjItem.Name,
},
success = true
});
}
how can we resolve this
Now the code in the question is correct, you can refer to it. We don't know how your previous code was written. If you encounter problems again, please attach a screenshot.
For this SA1500 problem, you can refer to the official documentation. The example in the middle will clearly tell you the cause of the problem and the solution.

C# ASP.Net Errors on form submission

I was hoping to get some insight on the error that are produced by the system. I am using a already built message system that I got some time ago and it works but sometimes on the forms I will get errors that I do not understand. For instance on a Create I have a try / catch block that produces a message if it has successfully Executed. I have tried to search for these errors in my project and it does not come up with anything. Even if it was in meta data a search should find it.
I use System.Text.StringBuilder sb = new System.Text.StringBuilder(); for the message and the code looks like this:
public ActionResult Create(Vendors model)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
try
{
if (ModelState.IsValid)
{
var userId = User.Identity.GetUserId();
//var getdata = ExtendedViewModels.VendorToEntity(model);
model.VendorId = Guid.NewGuid();
model.CreatedDate = System.DateTime.Now;
model.CreatedBy = User.Identity.Name;
model.Status = true;
db.Vendors.Add(model);
db.SaveChanges();
sb.Append("Submitted");
return Content(sb.ToString());
}
else
{
foreach (var key in this.ViewData.ModelState.Keys)
{
foreach (var err in this.ViewData.ModelState[key].Errors)
{
sb.Append(err.ErrorMessage + "<br/>");
}
}
}
}
catch (Exception ex)
{
sb.Append("Error :" + ex.Message);
}
return Content(sb.ToString());
}
When this returns or closes the Modal it produces a message or if there is an error it will produce that so you can fix it like a Required field. If everything is okay it will produce from this:
#Html.StarkAjaxFormSubmiter("frmVendors", "tbVendors", true, "Action Successfully Executed")
This is a green box that shows up as "Action Successfully Executed". If something is wrong a red box shows up and you get a message. In my case I am getting a red box that says Submitted Read Warnings Alerts This is how it is spelled. I doubt this is a error that comes from ASP.Net it looks more like a custom message, I dont know what it means and I cannot find it anywhere. Regardless, it does create the record in the db. The other error I have gotten shows Something is went wrong [object, object] Not only do I want to find out what these mean, I also want to clean them up and give a proper message that makes sense. Does anyone have any ideas as to how to correct this? Could they be encypted in the custom package that was written for this? That is why I cannot find them. I have also viewed the package and did not find anything for this.
This is from Meta data:
//
// Parameters:
// stark:
//
// FormId:
// Enter Here Form ID LIKE So you have to pass = frmCreate
//
// DataTableId:
// Which DataTable You have update after submit provide that ID
//
// IsCloseAfterSubmit:
// Do you want to opened popup close after submit , So pass=true or false any
//
// SuccessMessage:
// Give any Success message
public static MvcHtmlString StarkAjaxFormSubmiter(this HtmlHelper stark, string FormId, string DataTableId, bool IsCloseAfterSubmit, string SuccessMessage);
//
// Parameters:
// stark:
//
// FormId:
// Enter Here Form ID LIKE So you have to pass = frmCreate
//
// DataTableId:
// Which DataTable You have update after submit provide that ID
//
// IsCloseAfterSubmit:
// Do you want to opened popup close after submit , So pass=true or false any
//
// SuccessMessage:
// Give any Success message
//
// AfterSuccessCode:
// Add other JQuery code if you want
public static MvcHtmlString StarkAjaxFormSubmiter(this HtmlHelper stark, string FormId, string DataTableId, bool IsCloseAfterSubmit, string SuccessMessage, string AfterSuccessCode);
Thanks for our help
UPDATE:
I did some searching on the web and found a program called JetBrains dotPeek. I decompiled the dll and sure enough the messages are in there. So I should be able to change them and recompile it and add if I want, to it.
I was not able to edit the decompiled dll. So I decided to just create a class in the main project and copy the the code to that class. Changing what I needed. Where my trouble was, was with misspellings. The dll used Sumitted as the sb.Append("Sumitted") I changed that in the controller to be Submitted. So the dll did not find "Sumitted" in the action, and in the dll class there is an If statement that faults to error if not found - which was listed as Read Warnings Error. I changed that and fixed all the misspellings. I also got rid of the Something is went wrong and changed it to something more meaningful. I will continue to add to this to give more meaningful messages. It helps to know what the error is, instead of [object], [object]. I dont know if this will help others, maybe if they have downloaded the same code I have and have issues.

Twilio StatusCallback not working:

So I'm building an app with twilio voice, and I've got all the phonecall stuff working. But I'm having a little trouble understanding which parameters my callback should have.
I've registered the URL as described in the docs:
options.From = formatPhoneNumber(callout.callback_number);
options.To = formatPhoneNumber(offer.employee_phone_number);
options.Url = TwilioCallBotController.TwilioCalloutScriptURL;
options.StatusCallback = TwilioCallBotController.StatusCallbackURL;
options.StatusCallbackEvents = new []{"initiated", "ringing", "answered", "completed" };
options.StatusCallbackMethod = "POST";
I've also made a callback method here, but I'm not having much luck finding out how the parameters are supposed to work with their API. I'm kindof at a loss as to what could be the reason behind this one not working:
[HttpPost]
public ActionResult TwilioStatusCallback()
{
var twiml = new Twilio.TwiML.TwilioResponse();
twiml.Say("This is a test");
string CallSid = Request.Form["CallSid"];
string CallStatus = Request.Form["CallStatus"];
Debug.WriteLine("Status Callback Delivered");
Shift_Offer shoffer = db.Shift_Offers.Where(s => s.twillio_sid == CallSid).ToList()[0];
shoffer.status = CallStatus.ToString();// + DateTime.Now.ToString();
return TwiML(twiml);
}
Edit:
So it turns out that the API is very sensitive about the method signature (the call was previously throwing a method not found exception in a number of microsoft DLLs, including System.Web and System.Web.Mvc.
So I've actually gotten the software to call the method by using an empty method signature (no parameters).
However I'm still having trouble getting the parameters from the HTTPPOST
Edit: So upon further investigation I've managed to inspect the Request. The values I'm after exist in Request.Form["foo"], but they don't seem to be getting put into the two strings I have declared. I've removed the ["HttpPost"] attribute to try to troubleshoot the issue, but I'm really at a loss as to why I can see the values in the debugger, but they're not translating into memory.
public ActionResult TwilioStatusCallback()
{
var twiml = new Twilio.TwiML.TwilioResponse();
string sid = Request.Form["CallSid"];
string status = Request.Form["CallStatus"];
Shift_Offer shoffer = db.Shift_Offers.Where(s => s.twillio_sid == sid).ToList()[0];
shoffer.status = status;// + DateTime.Now.ToString();
return TwiML(twiml);
}
Last issue was that the database wasn't being saved.
Just added a db.SaveChanges() and we're good.

How to get symbol from securitylist using quickfix?

I'm sending a SecurityListRequest and I am receiving confirmation. I am unable to get the symbol from the response. I'm getting response like this.
8=FIXT.1.1|9=795|35=y|34=3|49=TMATCH=YYYYY|52=20160804-09:39:56.534|56=zzzzz|320=0001|322=zzzz->zzzzx|393=19|560=0|893=Y|
146=2|
55=xxxxx|48=xxxxx|22=8|167=xxxx|762=PERIOD|15=xxx|423=1|20000=1W|
55=xxxx|48=xxxxx|22=8|167=xxxx|762=PERIOD|15=xxx|423=1|20000=1M|
10=234
I tried to get like this
QuickFix.FIX50.SecurityList.NoRelatedSymGroup symbolGroup
= new QuickFix.FIX50.SecurityList.NoRelatedSymGroup();
int noofsymbols = m.Get(new NoRelatedSym()).getValue();
symbolGroup.Get(new Symbol());
and
m.get(new symbol()).getvalue();
and
m.getfield(new stringfield(55));
Every time it is throwing exception saying "Field Not Found" for tag 55.
You created a new empty NoRelatedSymGroup object, but you forgot to populate it from your message.
I think you are using the C++ QF with the C# wrapper, so this is probably the code you'd want:
var sym1 = new Symbol();
var sym2 = new Symbol();
m.getGroup(1, symbolGroup); // first group
symbolGroup.get(sym1);
m.getGroup(2, symbolGroup); // second group
symbolGroup.get(sym2);

Change Project Owner Using PSI 2010(Project Server Interface)

I want to change ProjectOwnerUID Using PSI(Project Server Interface).I wrote that with follow similar code
var projectDataSet = this.GetProjectDataSet(projectInfo.ProjectUID);
var orginalProject = this.GetProject(projectInfo.ProjectUID, projectDataSet);
var sessionUID = this.CheckOutProject(projectInfo.ProjectUID);
if (!string.IsNullOrEmpty(projectInfo.ProjectOwnerName))
{
var resourceManager = new Resource();
var ownerResource = resourceManager.GetResource(projectInfo.ProjectOwnerName);
if (ownerResource == null)
{
throw new Exception("this is not valid");
}
orginalProject.ProjectOwnerID = ownerResource.ResourceUID;
}
this.UpdateProject(sessionUID, projectDataSet);
unfortunatly when cursor arrive to UpdateProject line it throws exception with code number
ProjectServerError(s) LastError=ProjectInvalidOwner Instructions: Pass this into PSClientError constructor to access all error information
Inner Error 1056(Invalid project owner).
I don't know what happen that Issued this exception
how can I solve this problem?
This problem occurs when you do not have permissions to edit project information using the following code snippet u can tell to project server to run this piece of code do not check permissions!!
using Microsoft.SharePoint;
public void MyVoid()
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
//Write ur Codes here :)
});
}
MSDN Reference

Categories

Resources