|
WIndows Services is fine but not when the user is away or traveling and don't have access to his PC which means the windows services will not run because his PC is switched off because the server side could be linux not windows!
Technology News @ www.JassimRahma.com
|
|
|
|
|
Jassim Rahma wrote: the windows services will not run because his PC is switched off Well, I do not know of any application or service to run on a switched-off computer...
|
|
|
|
|
What is Framework of .net and its features?
Shail...
|
|
|
|
|
Here you go. There's plenty of good material here[^].
|
|
|
|
|
Wow, Pete, you are a genius!
|
|
|
|
|
You can google this to find enough resources.Your question should be as specific and concise as possible.It would be good if it is related to a practical real time issue
Thanks
Do not forget to comment and rate the article if it helped you by any means.
|
|
|
|
|
I'm working on a WPF app that call through a ASP.Net MVC 4 Web API.
I make the following call:
public CompanyInfoAddressEntity AddCompanyInfoAddress(CompanyInfoAddressEntity entity)
{
WebAPIExecutor webAPIExecutor = new WebAPIExecutor("/CompanyInfoAddresses/AddCompanyInfoAddress/");
webAPIExecutor.AddParameter(entity, "entity");
CompanyInfoAddressEntity results = webAPIExecutor.Execute<CompanyInfoAddressEntity>();
return results;
}
When I call into Execute, it runs fine and the entity is passed to the controller, BL, and DAL fine. But when it returns back to here, the 'entity' object is null.
I have no idea what's wrong. How do I debug this sort of problem?
If it's not broken, fix it until it is
|
|
|
|
|
Google has no results for WebAPIExecutor - is that a custom class you've written?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
It's a wrapper class for REST that I wrote. I'm 100% sure it's not the problem, but here's the code anyhow:
public class WebAPIExecutor
{
#region Private Fields
private RestClient client;
private RestRequest request;
#endregion
#region Properties
public string ServerName { get; private set; }
public string ServerAddress { get; private set; }
#endregion
#region CTOR
public WebAPIExecutor()
{
setupServerURL();
}
public WebAPIExecutor(string url, Method method = Method.POST)
{
if (string.IsNullOrEmpty(url))
{
throw new ArgumentNullException("Url");
}
setupServerURL();
client = new RestClient(ServerAddress);
client.AddHandler("text/plain", new JsonDeserializer());
request = new RestRequest(url, method)
{
RequestFormat = RestSharp.DataFormat.Json
};
}
#endregion
#region Public Methods
public void AddParameter(object value, string name = "")
{
if (value == null)
{
throw new ArgumentNullException("value");
}
Type type = value.GetType();
bool isPrimitive = type.IsPrimitive;
if(isPrimitive || type == typeof(string) || type == typeof(decimal))
{
if (string.IsNullOrEmpty(name) && request.Method == Method.GET)
{
throw new ArgumentNullException("Parameter 'Name' cannot be empty for Get requests");
}
request.AddParameter(name, value);
}
else
{
request.AddBody(value);
}
}
public T Execute<T>() where T : new()
{
if (request.Resource.Trim().ToLower().Contains("controller"))
{
string message = string.Format("Controller names cannot contain the word 'Controller'. Called from request {0}", request.Resource);
MessageBox.Show(message, "WebAPI Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
throw new Exception(message);
}
var url = client.BaseUrl + request.Resource;
IRestResponse<T> result = client.Execute<T>(request);
int resultValue = (int)result.StatusCode;
if (resultValue >= 299)
{
string message = string.Format("An error occured calling the WebAPI. {0} The status code is '{1}'. {2} The error message is {3}",
Environment.NewLine, result.StatusCode, Environment.NewLine, result.Content );
MessageBox.Show(message, "WebAPI Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
throw new Exception(message);
}
return result.Data;
}
public void Execute()
{
IRestResponse result = null;
try
{
result = client.Execute(request);
int resultCode = (int)result.StatusCode;
if (resultCode > 299)
{
string message = string.Format("An error occured calling the WebAPI. {0} The status code is '{1}'. {2} The error message is {3}",
Environment.NewLine, result.StatusCode, Environment.NewLine, result.Content );
MessageBox.Show(message, "WebAPI Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
throw new Exception(message);
}
}
catch (Exception e)
{
throw e;
}
}
#endregion
#region Private Methods
private void setupServerURL()
{
ServerName = ConfigurationManager.AppSettings["servername"];
string ipaddress = ConfigurationManager.AppSettings["ipaddress"];
string port = ConfigurationManager.AppSettings["port"];
ServerAddress = string.Format("http://{0}:{1}/api", ipaddress, port);
}
#endregion
}
}
If it's not broken, fix it until it is
|
|
|
|
|
Are RestClient , RestRequest and IRestResponse from Phil Haack's RestSharp[^] project? If so, are you using the latest version?
Have you tried calling the non-generic Execute method to make sure the returned Content and ContentType are what you were expecting?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
struct Connection *Database_open(const char *filename, char mode)
{
struct Connection *conn = malloc(sizeof(struct Connection));
if(!conn) die("Memory error");
conn->db = malloc(sizeof(struct Database));
if(!conn->db) die("Memory error");
if(mode == 'c') {
conn->file = fopen(filename, "w");
} else {
conn->file = fopen(filename, "r+");
if(conn->file) {
Database_load(conn);
}
}
if(!conn->file) die("Failed to open the file");
return conn;
}
|
|
|
|
|
it just check the mode you passed as a parameter is equal to 'c'. If it is equal to 'c' then create an empty file for output operations ("w"). else open a file for update ("r+") (both for input and output).
|
|
|
|
|
|
You are welcome
|
|
|
|
|
That's C code, not C#. What are you expecting from this forum?
|
|
|
|
|
Hello community,
In advance, please excuse my lack of knowledge regarding the following topic, I have tried to familiarise myself with the topic using both google and the search function.
A friend of mine asked whether I could get data from a specific website for him, I answered "yes, I can try". I feel like I am pretty close and only need a final push. So let's go:
www.regelleistung.net -> this is the website in question
Menu item : Data for Control Reserve - in the following form he would normally specify what kind of data he is interested in and would then click the submit button .
Someone gave me the TAMPER information for the post request and I came up with the following code:
1. The request requires a jsession cookie which I retrieve + from TAMPER I saw that I require several other items of interest : __fp , _sourcePage and CSRFToken.
Because I do not know how to get those information without making an actual request - I just perform a testrequest and populate an array, which I will use for the actual request
BASEURL = @"https://www.regelleistung.net/ip/action/abrufwert";
public string[] ReceiveCookiesAndHiddenData()
{
string[] tempHidden = new string[4];
HttpWebRequest tempRequest = (HttpWebRequest)WebRequest.Create(BASEURL);
using (HttpWebResponse tempResponse = (HttpWebResponse)tempRequest.GetResponse())
{
HtmlDocument doc = new HtmlDocument();
doc.Load(tempResponse.GetResponseStream());
tempHidden[0] = doc.DocumentNode.SelectNodes("//input[@type='hidden' and @name='_sourcePage']")[0].Attributes["Value"].Value;
tempHidden[1] = doc.DocumentNode.SelectNodes("//input[@type='hidden' and @name='__fp']")[0].Attributes["Value"].Value;
tempHidden[2] = doc.DocumentNode.SelectNodes("//input[@type='hidden' and @name='CSRFToken']")[0].Attributes["Value"].Value;
tempHidden[3] = tempResponse.Headers["Set-Cookie"].Split(new Char[] { ';' })[0];
}
return tempHidden;
}
2. No I have to make the actual request. which requires the following information (according to Tamper):
http://pl.vc/3f5z0[^]
public void MakeActualRequest()
{
hiddenData = ReceiveCookiesAndHiddenData();
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(BASEURL);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0";
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
request.Referer = "https://www.regelleistung.net/ip/action/abrufwert";
request.Headers.Add("Set-Cookie",hiddenData[3]);
NameValueCollection outgoingQueryString = HttpUtility.ParseQueryString(String.Empty);
outgoingQueryString.Add("von", "05.08.2014");
outgoingQueryString.Add("uenbld", "STXs440zwks=");
outgoingQueryString.Add("produkt", "MRL");
outgoingQueryString.Add("work", "anzeigen");
outgoingQueryString.Add("_sourcePage", hiddenData[0]);
outgoingQueryString.Add("__fp", hiddenData[1]);
outgoingQueryString.Add("CSRFToken", hiddenData[2]);
string postdata = outgoingQueryString.ToString();
byte[] data = Encoding.ASCII.GetBytes(postdata);
request.ContentLength = data.Length;
using(Stream requestStream = request.GetRequestStream())
{
requestStream.Write(data,0,data.Length);
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
using(StreamReader reader = new StreamReader(responseStream, Encoding.Default))
{
string content = reader.ReadToEnd();
}
}
I receive a WeException "Remote server error :(403)" in this line of code:
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
I would be thankfull for help. I know this is like the 1000000 time such a question has been posted, but I read all those threads and still cannot figure it out.
Thank you all!
|
|
|
|
|
Look at the action parameter of the form element
form action="/ip/action/abrufwert;jsessionid=v8fcThPBr1LQcMds3PrkXxwJNwYpzvQ6Zb9vcNyTMQhk9d96Bhb8!2134477355!-1323386705" method="post"
There's the URL you have to send the data to in MakeActualRequest , not BASEURL .
Also parameters "bis" and "download" are missing in your request.
|
|
|
|
|
Hi Bernhard,
thanks - Adding the jsessionid to the uri already helped solving my first issue - then changing uenbld to uenbId did the final trick.
Thanks for the quick and helpful response, highly appreciated.
Question answered!
|
|
|
|
|
i do not the main objective of using bar code but guessed that people store & hide info through bar code for to some extent security. may be i am not correct.....if anyone knows the exact objective for storing info in bar code then plzz share with me. thanks
tbhattacharjee
|
|
|
|
|
All a bar code contains is an Article Number (AN) - which is a unique identifier for a product type. So a 100g chocolate bar will have one AN, and a 100g chocolate bar from a different manufacturer will have a different one. a 200g bar from the same manufacturer will also have a different AN.
What that means is that you can scan teh product barcode, and get a number which lets you go to your database, look up the AN and get told "this is a Cadburys Dairy Milk 100g and we are selling it at £1.50, we have 72 in stock and we reorder if the stick level drops to 71". Without the user or operator having to enter any information (with the good probability that he will make a mistake).
It's not security, it's just a number (which contains a simple checksum code) which identifies something. Everything else is a database / application function.
(There are barcode types which contain more information than this - a lot more in some cases - but that's the general idea)
You looking for sympathy?
You'll find it in the dictionary, between sympathomimetic and sympatric
(Page 1788, if it helps)
|
|
|
|
|
thanks a lot for good explanation
tbhattacharjee
|
|
|
|
|
You're welcome!
You looking for sympathy?
You'll find it in the dictionary, between sympathomimetic and sympatric
(Page 1788, if it helps)
|
|
|
|
|
Hi,
Is it possible to generate vcf contact file using C# and .NET 4.0? or need to use thirdparty only?
Thanks,
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|
|
Yes, it's possible. Assuming you are a reasonably competent C# programmer, and know how to use Google to find the documents that define the vCard format.
|
|
|
|
|
See this[^] example.
/ravi
|
|
|
|