Hi
Please let me know how to create Pipeline on Runspace and also give me an example with C# code .
Hi
Please let me know how to create Pipeline on Runspace and also give me an example with C# code .
private static string getPage(string _link, string ua, string customRef, string cmd) { string csrfx = csrf(cmd); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(_link); req.Headers.Add("Accept-Language", "en-US,en;q=0.5"); req.Headers.Add("CSRF", csrfx); req.Referer = customRef; req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; req.KeepAlive = true; req.UserAgent = ua; HttpWebResponse resp = null; try { resp = (HttpWebResponse)req.GetResponse() as HttpWebResponse; if (resp.StatusCode == HttpStatusCode.OK) { Stream receive = resp.GetResponseStream(); StreamReader read = null; if (resp.CharacterSet == null) read = new StreamReader(receive); else read = new StreamReader(receive, Encoding.GetEncoding(resp.CharacterSet)); string _contentanon = read.ReadToEnd(); resp.Close(); read.Close(); return _contentanon; } } catch (Exception ex) { } finally { if (resp != null) { resp.Close(); } } return "unknown result"; }
HI I am having one structure inside that another one variable is defined .that variable is referred another one child structure. I want to marshal this nested structure into c# .Can you provide a samples regarding this marshaling ?
asp.net.4 webForms , c# vs2012
i cant get the class props by reflection..
i tried to follow the http://msdn.microsoft.com/en-us/library/kyaxdd3x(v=vs.110).aspx
and i get 0 in the results array length..
protected void Page_Load(object sender, EventArgs e) { string prop1="1", prop2="2"; Class1 c = new Class1(prop1, prop2); Type t = typeof(Class1); var rr = t.GetType().Attributes.GetType().GetProperties(); var r = t.GetType().GetProperties(System.Reflection.BindingFlags.Public); System.Reflection.PropertyInfo[] propInfos = t.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
and the class
public class Class1 { private string prop1 { get; set; } private string prop2 { get; set; } public Class1() {} public Class1(string prop1, string prop2) { // TODO: Complete member initialization this.prop1 = prop1; this.prop2 = prop2; } }
that is not working..........
I want to take a date value from the database and send it into a report as a report parameter. But if I do that now I get an error (the value provided for the report parameter is not valid for its type datetime). I am currently using a combobox to contain the list of dates, and i want the selected item to be sent as a date parameter into the report. I am using c# and I am using the rdlc report file. Here is my code.
this.rptStockMismatch.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["ReportServerURL"]); this.rptStockMismatch.ShowParameterPrompts = false; ReportParameter[] reportParameter = new ReportParameter[2]; reportParameter[0] = new ReportParameter("StockCaptureDate", this.cboStockCaptureDate.SelectedItem.ToString()); //this is where I want to insert the selected combobox itme in. reportParameter[1] = new ReportParameter("DepotID", this.cboDepot.SelectedValue.ToString()); this.rptStockMismatch.ServerReport.SetParameters(reportParameter); this.rptStockMismatch.RefreshReport();
Hi, I am trying to use information from a text file to put into a graph format. It prompts the user to select which text file to use (only one if statement shown below). The code reads the file and collects grades data and counts how many A's, B's, C's, D's and E's. It then puts all these into percentages which is printed onto console. Now I want to implement it into a graph format showing 1 * per 2 grades so for example:
******************** A = 40%
********** B = 20%
***** C = 10%
***** D = 10%
***** E = 10%
***** F = 10%
Problem is I am stuck and have NO IDEA what to do and I need to do it by tomorrow :S Please please please help, I have posted my attempt below.
using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Assessment2 { class Program { public static void Main(string[] args) { Console.WriteLine("Would you like to use the single (type 1) or multiple (type 2) grades document? "); string userInput = Console.ReadLine(); if (userInput == "1") { StreamReader sr = new StreamReader(@"C:\Users\User\Desktop\grades\grades_single.txt"); string line = ""; while ((line = sr.ReadLine())!=null) { if(line == "CMP"){ Console.WriteLine("{0}", line); } int aCount = line.Count(x => x == 'A'); int bCount = line.Count(x => x == 'B'); int cCount = line.Count(x => x == 'C'); int dCount = line.Count(x => x == 'D'); int eCount = line.Count(x => x == 'E'); int fCount = line.Count(x => x == 'F'); int sum1 = (aCount * 100 / 50); int sum2 =(bCount * 100 / 50); int sum3 =(cCount * 100 / 50); int sum4 =(dCount * 100 / 50); int sum5 =(eCount * 100 / 50); int sum6 =(fCount * 100 / 50); if(aCount != 0) { Console.WriteLine("Percentage of A's = {0}%", sum1); Console.WriteLine("Percentage of B's = {0}%", sum2); Console.WriteLine("Percentage of C's = {0}%", sum3); Console.WriteLine("Percentage of D's = {0}%", sum4); Console.WriteLine("Percentage of E's = {0}%", sum5); Console.WriteLine("Percentage of F's = {0}%", sum6); Console.WriteLine("\n"); } }<< START OF GRAPH CODE >> const int input = 3; const string star = "*"; int number; List<int> numbers = new List<int>(); for (int i = 0; i < input; i++) { number = Convert.ToInt32(); numbers.Add(number / 2); } for (int i = 0; i < numbers.Count; i++) { number = numbers.ElementAt(i); while (number > 0) { Console.Write(star); number--; } Console.WriteLine(); }
Is embedding Type property inside a class a good way to associate it with another class? (like itself indicating "Hey I belong to that class over there")
I have a large setting configuration that defines 5 settings, each for working on 5 different object types
I was thinking of embedding a Type property inside the settings class that indicates the exact Type of object it refers to
Like:
SettingsClass1 : ISettings {
...
public Type ObjectTypeIBelongTo {get {return typeOf(ConcreteObject1); }}
}
SettingsClass2 : ISettings {
...
public Type ObjectTypeIBelongTo {get {return typeOf(ConcreteObject2); }}
}
Class ConcreteObject1 : IConcreteObject{
}
Class ConcreteObject2 : IConcreteObject{
}...
And then I was thinking of creating a Dictionary that contains the setting and the typeName it refers to like
Dictionary<string, ISettings> mappings;
where string would be the name of the Type ObjectTypeIBelongTo
So whenever I encountered an IConcreteObject, I can immediately pull the appropriate settings fom the dictionary by doing
IConcreteObject ConcObj = new ConcreteObject1();
string concreteObjectName = ConcObj.GetType().Name;
ISettings setting = mappings[concreteObjectName];
**The only problem I can see is that my solution only tells you who belongs to who and doesn't really enforce it strongly enough. Like nothing is preventing the user to match the wrong setting class with the concreteObject class. Although if
this is internal structure of an API that is not exposed to end user, would it still be acceptable?
Hi,
I've a list like this: public List<Tray> lstTray = new List<Tray>();
I want to add string values to the above mentioned list. But when I try to add the string values to above list, I'm getting compile error "Instance argument: cannot convert from 'System.Collections.Generic.IEnumerable<string>' to 'System.Collections.Generic.IEnumerable<String>'"
Can you please let me know whether I can add string values to objects? If yes, how ? If no, what is the alternative approach?
Kindly waiting for your response.
Thanks,
Santosh
The original question is: "Given a 2D matrix consists of only 0’s and 1’s find the longest diagonal of all 1’s".
The hard part is how to locate the diagonal elements? If a[i,i] is chosen, I only get one diagonal. How about others?
0 1 1 0 1 0 1 1 0 1 1 1 1 1 0 1 1 1 1 0 1 1 0 0 1 1 1 0Also how to deal with the diagonal from upper right to lower left?
Hi fellows !
i have a website say TestApp1 targetting framework 4.0 which i deployed on IIS 7
I can access this website from the system on which i have deployed it but unable to access it from anyother computer over the network
when i access http://abc-pc/testapp1 in the server computer it works fine (abc-pc is the server name where website is deployed)
but when i go to some other system and access the above url it says 'This webpage is not available'
from the remote system i have ping to the abc-pc using its ip address which shows success....
any suggesstions?
farooq.hnf
Hi! I need send via serial port a file with multiple message.
The text file is like this:
MESSAGE 1
MESSAGE 2
MESSAGE 3
.....
For the moment i write this, but i dont know how can i do what i need.
private void readTextFileToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog sendTextFile = new OpenFileDialog(); sendTextFile.Filter = "Text File (*.txt)|*.txt"; sendTextFile.Title = "Send Text File"; sendTextFile.InitialDirectory = @"C:/users//desktop"; if (sendTextFile.ShowDialog() == DialogResult.OK) { StreamReader read = new StreamReader(sendTextFile.FileName); } }
Hi am very new to asp.net, i want to upload images using asp.net and jquery. I want to give output like the following link. File upload in popup window. Here only image is getting saved in sever. but i want to take back the uploaded image and display it in popup. Can any one help me out to solve this issue. Thanks in advance
Hi,
I'm building a component which serves as mediator between 3rd-party API and the rest of my app.
Basically, my problem is that I need to capture and handle some events sent by the API, do some work, and then trigger an event which will be used by my app. But, I must handle the API's event as fast as possible, and if I trigger a public event as part of the handler procedure, I may get delayed by the event's consumers.
The code looks something like this
public class Mediator { private ExtApi extApi; public event StatusChangedEventHandler StatusChanged; public Mediator() { extApi = new ExtApi(); extApi.StatusChanged += extApi_StatusChanged; } private void extApi_StatusChanged(object sender, StatusChangedEventArgs e) { // do some work ... // trigger a public event - consumed by the rest of the app StatusChangedEventHandler handler = StatusChanged; if (handler != null) handler(this, e); } }
I was thinking about triggering my event "handler(this,e);" asynchronously, thus ensuring that my own handler (extApi_StatusChanged) won't be delayed.
How do I do that?
Are there better ways to solve the problem?
I have 16+ scanners coming into the computer from a single USB port. The code that I have now works fine as long as the textbox has focus. What I want is some code that I could use that would get the scan even if the windows form is minimized or some other program is being used.
I've looked around a lot and everything just says to have focus on the textbox. Is there like a barcode listener that I could use?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.DirectoryServices.AccountManagement;
using System.DirectoryServices;
namespace ActiveDirectoryHacking
{
class Program
{
static void Main(string[] args)
{
PrincipalContext adPrincipalContext = new PrincipalContext(ContextType.Domain, "192.168.1.26", "OU=Staff,DC=SFdev,DC=org", "John.Doe", "Initial Complex P234dfword");
Console.WriteLine("Validate user {0}", adPrincipalContext.ValidateCredentials("John.Doe", "Initial Complex P234dfword"));
UserPrincipal user = UserPrincipal.FindByIdentity(adPrincipalContext, "John.Doe");
Console.WriteLine(user.DistinguishedName);
user.ChangePassword("Initial Complex P234dfword", "e$213434sDKS really? www.microsoft.com");
//user.SetPassword("Initial Complex P234dfword");
user.Save();
Console.WriteLine("Press a key to exit.");
Console.ReadKey();
}
}
}
The .SetPassword works if I use a user with Domain Admin access but it appears the John.Doe is unable to change their own password with the .ChangePassword method.Validate user True
CN=John Doe,OU=Staff,DC=SFdev,DC=org
I have no clue why any password I select for the new password does not work.
I've been trying to understand C# delegates using Pro C# 5.
In short, the author describes the motivation for delegates as a structured way of dealing with function pointers and callbacks or two-way communication between objects.
The part I find confusing is the syntax/implementation for this:
On the one hand, an object of delegate type is seen as the handler or the one responsible for invoking
some method or list of methods. To this end, it has methods such as Invoke()
etc.
On the other hand, the delegate type is used as a 'wrapper' with which to pass around methods.
For example, it seems strange to me that a call to a delegate's GetInvocationList()
returns
an array of delegates. Shouldn't there be something else with which to wrap methods?
I expected there would be some other construct/type, say, MethodContainer
which
wraps methods. Then the syntax for adding methods to a delegate would be
classMyClass{voidMethod(string s){}}MyClass c =newMyClass();MethodContainer container =newMethodContainer(c.Method);delegatevoidMyDelegate(string s);MyDelegate d =newMyDelegate();
d.Add(container);
d.GetInvocationList();// returns array of MethodContainer
First of all sorry for my English :)
I want to know if some professional programmer are using windows form application to create an advance application?. DLL files can help my windows form application? how do i know if i need to create an DLL?
and how can you say that you are a proffessional programmer? :)
*Sorry for this question*
*Begineer*
I am trying to implements events in c#. my scenario is that there will be multiple events and there will be multiple events listeners to an event(many to many relationship).
the problem here is since there are many events and if i implement all in one class, maintaining code will a tough task, and if i create one class per event there will be too many classes.
I found a solution which has an event broker in this link: http://msforge.net/blogs/paki/archive/2007/11/20/EventBroker-implementation-in-C_2300_-full-source-code.aspx
but here the author is using delegates only instead of events. he is maintaining a dictionary wherein he is saving some event ID as key and list of delegates as value. this solves my problem of code maintenance.
my question is that is it fine to do this way since behind the scenes an event is a construct that wraps a delegate only or use events which c# is already providing rather than maintaining a dictionary?
which one is a better way in terms of performance or any other way?
Also is there any better way to implement my scenario with events
Please provide your inputs.