|
That sounds like it could be either interesting or trivial.
What exactly do you have to do?
|
|
|
|
|
i wan't to separation and graft color plane for bitmaps
|
|
|
|
|
I'm afraid I still don't really know what you want.
Do you want to: take a bitmap and create 3 separate bitmaps from it, representing the red, green and blue components?
|
|
|
|
|
(smile) exactly, thank you verry much but I have done this exercise, forward to help next time ^^
thank you
|
|
|
|
|
I am modifying an SSRS 2008 r2 report so users can export the data to excel and sort and filter the data. The only way to accomplsh this task is to remove the report headers.
The users will click on a button that says hide 'headers' and click the view button. Then the users will export to excel.
Problem:When the SSRS 2008 R2 report is exported to excel, row one in excel is blank. The column headers and data start on line #2 in excel. I want to remove line #1 from being blank in excel.
To solve this problem, for the tablix that I want to keep, I want to set the location value to 0,0. I do not want to come up with a new report that looks
like the original report but the data is shifted. I would prefer to write C# code to solve this problem since I can not find a way to set the SSRS tablix.location
property in SSRS.
Thus can you show and/or tell me the following:
1. What C# code can be setup to accomplish my goal?
2. How would you attach the C# code to the SSRS 2008 r2 report for the code to work?
|
|
|
|
|
Hello,
I have html code that need to be converted to PDF by clicking on the button on the webpage.
Generated HTML contains table populated from the recordset.
Please check the code below. It is working, except for some reason in pdf it cuts out last row in the table.
private void GenerateReport(string Html, HttpContext context)
{
MemoryStream stream = createPDF(Html);
context.Response.ContentType = "application/pdf";
context.Response.AddHeader("Content-Disposition", "attachment; filename=\"Report.pdf\"");
context.Response.BinaryWrite(stream.ToArray());
}
private MemoryStream createPDF(string html)
{
MemoryStream msOutput = new MemoryStream();
TextReader reader = new StringReader(html);
Document document = new Document(PageSize.A4,10f,10f,10f,0f);
PdfWriter writer = PdfWriter.GetInstance(document, msOutput);
HTMLWorker worker = new HTMLWorker(document);
document.Open();
worker.StartDocument();
worker.Parse(reader);
worker.EndDocument();
worker.Close();
document.Close();
return msOutput;
}
If i run just html, all rows are displayed. The generated PDF document won't include last row.
Can't figure out why.
Any ideas would be appreciated.
Thanks.
|
|
|
|
|
This is copy of my comment on A Multi-threading Example.
I'm beginner so I have question if anyone can help me.
I've used part of threading code, I have button that should stop the process, but, as you can see in the code below, I have 3 nested loops, and operation in topmost loop (which I've put into thread) takes some time to do the work, and my stop button is not very responsive.
When I put thread sleep to 3 seconds, button is responsive, but that makes topmost loop even slower (by that 3 second per iteration).
What should be simple start stop operation now became much more than I can handle.
I have this code so far:
private void btnCaptureScreen_Click(object sender, EventArgs e) {
if (LIST_CheckedTreeNodes.Count > 0) {
btnCaptureScreen.Enabled = false;
btnSTOP.Enabled = true;
abort_process = false;
thread = new Thread(delegate() {
foreach (iTreeNode node in LIST_CheckedTreeNodes) {
if (abort_process) break;
this.BeginInvoke((ThreadStart)delegate() {
CaptureScreenFromNode(node);
});
if (abort_process) break;
}
this.BeginInvoke((ThreadStart)delegate() {
btnCaptureScreen.Enabled = true;
btnSTOP.Enabled = false;
});
Thread.Sleep(10);
});
thread.Start();
}
}
CaptureScreenFromNode(node) code:
private void CaptureScreenFromNode(iTreeNode node) {
treeView.SelectedNode = node;
string nodePI = node.GetType().GetProperty("iDiagramType").GetValue(node).ToString();
foreach (iComboBox combo in LIST_COMBOX_SelectedLoadCases) {
if (abort_process) break;
Check_Selected_Load_Cases(combo);
string comboPI = combo.GetType().GetProperty("iDiagramType").GetValue(combo).ToString();
if (comboPI == nodePI) {
if (combo.Items.Count > 0) {
for (int j = 0; j < combo.Items.Count; j++) {
if (abort_process) break;
}
}
else {
}
}
}
}
}
Please help
|
|
|
|
|
As this is a question about an article, you should direct the question to the forum at the end of the article. It's unlikely that the author will wander on by this forum and see the question, but they do get notified of posts on article forums.
|
|
|
|
|
I am new to the Code Project and I am sorry if I've broke some rule. I thought that my question is quite general so I posted it here.
|
|
|
|
|
You didn't break any rules, it's just that the author will probably have a better idea of what you're trying to do.
|
|
|
|
|
I usually make UI controls contain data that is otherwise well ordered elsewhere. BeginInvoke means the code is running on the UI thread, killing responsiveness. The catch is you can't access UI members. Thus the justification for me using separation of powers so to speak.
Also, three seconds is slow to loop through all components on a UI and get information. Perhaps, the ui can be re-thought to be less complex?
|
|
|
|
|
i have a data table which as Name and employee Id Details
Name EmpID
Tom 1238
Dick 1069
if i use the code
string json = JsonConvert.SerializeObject(dt, Formatting.Indented);
i get Json data as follows
[
{
"Name": "Tom",
"EmpID": 1238
},
{
"Name": "Dick",
"EmpID": 1069
}
]
But i need the JSon data in the below format how do i achieve it???
"DATA": [
["Tom", 1238],
["Dick", 1069]
]
|
|
|
|
|
You can probably override the ToString method and return your desired format.
|
|
|
|
|
Something like this should get you started:
var wrapper = new
{
DATA = dt.Rows.Cast<DataRow>()
.Select(row => row.ItemArray)
.ToArray()
};
string json = JsonConvert.SerializeObject(wrapper, Formatting.Indented);
That will produce:
{
"DATA": [
[
"Tom",
1238
],
[
"Dick",
1069
]
]
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
I'm quite new to C# and been working on this problem for days and already at my dead end . I have been trying to learn from sample codes from forums and doing lots of cuts and pastes. Hope someone can help.
I have a Windows Service where I am getting data from web, write it to a .txt file and email at scheduled time.
I can send scheduled email alone. But when I tried to extract data from web, write that data in .txt file and email that data as scheduled altogether, the program hangs at new StreamWriter declaration. I used eventLog1.WriteEntry() to check where it stops. There is no error message. The program just hangs there. I really don't know what is happening. Can someone help? This is what I have done so far ..
protected override void OnStart(string[] args)
{
System.Timers.Timer time = new System.Timers.Timer();
time.Start();
time.Interval = (1000 * 60 * 5);
time.Elapsed += new ElapsedEventHandler(time_elapsed);
time.AutoReset = true;
time.Start();
}
public void time_elapsed(object sender, ElapsedEventArgs e)
{
DateTime scheduledRun = DateTime.Today.AddHours(13.20);
DateTime lastRan = lastTime.LastWriteTime;
if (DateTime.Now > scheduledRun)
{
TimeSpan sinceLastRun = DateTime.Now - lastRan;
if (sinceLastRun.Minutes > 5)
{
importFrmURL("http:// ..", "@"\Import1.txt"");
}
}
}
public void importFrmURL(string url, string dir)
{
System.IO.StreamWriter fileWriter;
fileWriter = new System.IO.StreamWriter(dir);
try
{
var client = new WebClient();
using (var stream = client.OpenRead(url))
using (var reader = new StreamReader(stream))
{
string line;
while ((line = reader.ReadLine()) != null)
{
fileWriter.WriteLine(line);
}
fileWriter.Close();
}
}
catch (Exception e)
{
eventLog1.WriteEntry("Error occurred!\n\r" + e.ToString());
}
}
modified 28-Nov-13 2:28am.
|
|
|
|
|
Use a full path instead of the filename only, e.g. @"C:\Temp\Import1.txt".
Also, I'd suggest to create a FileStream first, and then write into that stream:
using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
{
using (StreamWriter writer = new StreamWriter(fs))
{
}
}
|
|
|
|
|
Yes this works! Can you please explain to me what happened when I don't do FileStream? Or if there is an article I can read from.
|
|
|
|
|
Well, the parameters of the FileStream constructor mean that you can create the file when it does not exist already. Don't know for StreamWriter when the file does not yet exist.
|
|
|
|
|
But this doesn't work when I try to save this .txt file in a server drive (e.g. S:\). It is connected and I can see the S drive in my computer but why can't I write there? Can't I just treat it like any other folder and save the text file under @"S:\Project1\Import1.txt" etc?
|
|
|
|
|
A mapped drive requires authentication, and your windows service is probably not running under the users' credentials.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Something else to be aware of - when you are running a Windows Service, it may not actually know there's an S drive. This is a mapped drive designation that applies to a particular account - unless you set the service to run as that account, it will not know about it.
|
|
|
|
|
I have an object which mimics a table structure in sql. Lets call this object validation. Validation has a property isrequired with a get and set.
when i use this property in code i.e.
validation val = new validation
and then try to change the value of isrequired intellisense says i can not assign to this isrequired because it is read only.
I have a user that wants some items for some objects to be required where as other objects isrequired is false. The table that this object mimics has fieldname and isrequired either true or false. in this case the database has isrequired as true. I just want to change the isrequired in the object and not affect change in the database table.
when i use form.fieldname.isrequiered = false it tells me I can not assign because it is read only. Thanks.
|
|
|
|
|
I would suggest changing it from readonly to read/write.
Veni, vidi, abiit domum
|
|
|
|
|
Thank you so much for your response. where would that change take place?
something like form.fieldname.isrequired.attribute = read/write?
|
|
|
|
|
Unless you show the code where the variable's properties are declared it's anyone's guess.
Veni, vidi, abiit domum
|
|
|
|