|
1.
John Torjo wrote: 1. why start at 7:7 (i and j)? Why go until grid_lic.ColumnCount -1 instead of grid_lic.ColumnCount? Because the checkbox columns are on the column nr. 3 and from 7 untill 19, in a 21 columns datagrid.
John Torjo wrote: 2. Your i and j iterate through columsn onlyl not through rows at all. I'm not interested in going through rows, but only through the columns of the selected row.
John Torjo wrote: 3. Why do you set that CurrentRow.Cells[3] to false or true? Because there is a checkbox column in the column nr. 3.John Torjo wrote: 4. Why the double statements (Convert.ToBoolean...)? Because being checkboxes, only booleans are read.
John Torjo wrote: 6. You need to first check ALL cells to see if they are all true or not, so that you'll know how to set them Isn't the cycle in the code doing that? What's the alternative?
|
|
|
|
|
Member 11449447 wrote: John Torjo wrote: 4. Why the double statements (Convert.ToBoolean...)? Because being checkboxes, only booleans are read.
I will address your other points at a later time. Please note that the following code
"Convert.ToBoolean(grid_lic.CurrentRow.Cells[i].Value = false);" is meaningless:
1. Convert.ToBoolean makes sense only if you want to assign the result to another value, like
x = Convert.ToBoolean(y); In your case,you don't need that.
2. And false and true are already booleans.
Best,
John
-- Log Wizard - a Log Viewer that is easy and fun to use!
|
|
|
|
|
You should be able to use a variation of this code
public void CheckGrid()
{
List<int> trueIndices = new List<int>();
for (int i = 7; i < GridItems.Count - 1; i++)
{
if (GridItems[i])
{
trueIndices.Add(i);
}
}
bool setValue = trueIndices.Count == 0 || trueIndices.Count != GridItems.Count - 8;
for (int i = 7; i < GridItems.Count - 1; i++)
{
GridItems[i] = setValue;
}
} Note that you would need to convert my GridItems calls into your grid_lic... calls but this should be incredibly trivial for you.
This space for rent
|
|
|
|
|
I replaced GridItems for grid_lic, and it throws an error in grid_lic[i], with the message no overload method fot 'this' takes one argument.
|
|
|
|
|
It would have to be to your cell level - my version was just a list of booleans. Yours would have to be something like grid_lic.CurrentRow.Cells[i] (remembering to convert this to a boolean).
This space for rent
|
|
|
|
|
Now it is working, the problem was that I didn't convert grid_lic.CurrentRow.Cells[i] to a boolean.
But my idea was to not use a list, despite this probably being the simplest way to achieve the result.
Thank you.
|
|
|
|
|
You're welcome - you could, of course, use a combination of booleans if you wanted - this was simply a quick example of how you could do this.
This space for rent
|
|
|
|
|
Hi there!
I'm just trying to use dtsearch desktop/engine on my website and I was told to use C# to program it into php or sth....
I Dont know how to do programming for dtsearch to apply to my website/host so that people can use my database search engine....
and in years to come, I'm gonna turn it into android progrm
please help me, I could give you some 25 $......I'm not rich enough
thanks a million ways to die in the west juno!
|
|
|
|
|
We don't charge for help here: if you want to pay, thn go to vWorker.com and ask there. $25 should get you a complete Android app if you don't give a damn if it works at all...
But I'd start by asking the people who wrote dtsearch (whatever that is) as they will probably have a much better idea and possibly even tutorials...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
As you were told when you posted this in QA two days ago[^], if you have questions about the code in an article, use the forum at the bottom of the article[^]. The person who wrote the code is the most likely to be able to help you.
Reposting your question in a general forum will only serve to annoy the people who answer questions here, because you're duplicating work. Particularly so when you have completely ignored the advice you were given in response to your previous post!
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
So I wasn't sure whether to post this here or in the database section, but here it goes. I have a 'logbook' that I'm developing which is basically a simple message board. Where I'm drawing a blank is how to format the data coming out of the database for the printable report. The database is set up so that all the messages are stored with various headers and a parent/child structure in a single table. You can have multiple child replies to a single parent, but only 1 level deep. Where I'm drawing a blank is how to structure the data for use in the printable reports. Any help would be massively appreciated as I'm drawing a blank as to which direction to go with this.
Here's the desired report structure[^] and the current data format[^]
modified 11-Jan-16 10:53am.
|
|
|
|
|
From your post it is difficult to understand what you want to achieve or what the problem is.
If it is a single table, I'm unsure what you mean with "how to structure the data". Linking the records seems (from your text) easy enough. What's the report for? What data should be on there? For whom is it? You're not asking for a report structure, or are you?
|
|
|
|
|
Thanks for the reply. I updated the original post with some pictures to see if that helps explain it.
|
|
|
|
|
Hello,
Much clearer, thank you.
I'm not sure what everyone has against Crystal Reports, I worked with it and never had any issues.
I think from the other answers a quick tutorial is indeed a good idea. Many report builders allow grouping/summaries and even graphs on the fly. Playing with it is the best way to learn.
Not sure about other reporting tools, but Crystal Reports allows basically two ways of fetching data. You select data from .Net and pass it to the report document allowing more dynamic control or (my favorite) you build a template and just pass some parameters from .Net to it. The report document will fetch the data itself and build the report. (advantage is that you can test the report outside your application)
Concerning the report format I can only give the advice what I always do. That's asking yourself what is important. I use the 7 seconds rule. The first thing any user asks himself when seeing a webpage, a report, a document, ... is "What am I looking at". Attract their attention with showing what the report is about. The next 7 seconds are navigation. The user passed the first 7 seconds and now wants to know how the thing is constructed. (layout, where is which data, etc ...) After that you have their attention and only then will they look in detail.
(PS: I say 7 seconds, it could be 3 or 5 or 2.45, but you get my drift)
Hope this helps.
|
|
|
|
|
|
I suggest you consult the documentation for the (Sql Server / Visual Studio) Reporting Services and do one of the "walk-throughs".
That will take you through:
1) Starting the report designer / builder
2) Specifying a data source (I.e. database tables)
3) Selecting records
4) Fields to report on
5) Sorting
6) Formatting
7) Grouping
8) Parent-child reporting
etc.
Reporting Services Tutorials (SSRS)[^]
Once you have something going, you can ask more specific questions.
|
|
|
|
|
Thanks! I didn't know they covered Parent-Child grouping.
|
|
|
|
|
|
I'm with Gerry on this, pick a report builder and use that, anything except Crystal Reports. We us SSRS and it does all you need but then so do ALL other reporting tools. Parent/Child structure are the bread and butter of reporting.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Apologies if this has been answered before.
I have a C# program that calls various PowerShell scripts as it runs. If I run the program as an administrator, it doesn't seem to pass on the elevated rights to the runspaces used for executing the scripts.
Is there any way to do this? The code I am using to run the scripts is below:
string mScriptPath = "Project.Resources." + mScriptName + ".ps1";
Assembly _assembly = Assembly.GetExecutingAssembly();
StreamReader _psStreamReader = new StreamReader(_assembly.GetManifestResourceStream(mScriptPath));
Runspace runspace = RunspaceFactory.CreateRunspace();
runspace.Open();
string powerShell = _psStreamReader.ReadToEnd();
_psStreamReader.Close();
var shell = PowerShell.Create();
shell.Commands.AddScript(powerShell);
shell.Invoke();
Any help would be appreciated
|
|
|
|
|
Would this help - Passing credentials ? (note, obviously its dangerous to store the password plain-text, Im not suggesting that as a long-term thing, but test it, if it does what you want, think about handling the password 'securely' - maybe there's a similar way of getting and using the local credentials if you're already signed on as Administrator)
(this is the guts of what you need to do to your code)
var credentials = new PSCredential(username, ConvertToSecureString(password));
var connectionInfo = new WSManConnectionInfo(false, computername, 5985, "/wsman", "http://schemas.microsoft.com/powershell/Microsoft.PowerShell", credentials);
var runspace = RunspaceFactory.CreateRunspace(connectionInfo);
Ref : WSManConnectionInfo Constructor (Boolean, String, Int32, String, String, PSCredential) (System.Management.Automation.Runspaces)[^]
[Edit] needs
using System.Management.Automation;
using System.Management.Automation.Runspaces; [/Edit]
|
|
|
|
|
I'm having some issue with my code in my Windows Service not releasing memory.
In short my Windows Service basically created about 8 timers that elapsed every X minutes which called a method that queried data from Exchange and stored in the database.
What I have noticed is the memory always climbed to the point it would crash the service when it reached maximum (32-bit process)
I switched from using timers to using the Quartz library but experienced the same results.
Here is an example of one of the timers jobs:
public class Get_MailboxDatabaseSizesTask : IJob
{
private static readonly ILog logger = LogManager.GetLogger("Get_MailboxDatabaseSizesTask");
public void Execute(IJobExecutionContext context)
{
CloudPanelDbContext db = null;
ExchActions powershell = null;
int processedCount = 0;
try
{
db = new CloudPanelDbContext(Config.ServiceSettings.SqlConnectionString);
db.Connection.Open();
powershell = new ExchActions();
var mailboxDatabases = powershell.Get_MailboxDatabaseSizes();
db.StatMailboxDatabaseSizes.InsertAllOnSubmit(mailboxDatabases);
db.SubmitChanges();
processedCount = mailboxDatabases.Count;
mailboxDatabases = null;
}
catch (Exception ex)
{
logger.ErrorFormat("Failed to retrieve mailbox database sizes: {0}", ex.ToString());
}
finally
{
if (powershell != null)
powershell.Dispose();
if (db != null)
db.Dispose();
logger.InfoFormat("Processed a total of {0} mailbox databases", processedCount);
}
}
}
As you can see I am disposing of my context and my ExchActions class... I solved the memory issue by adding this to the end of each Execute method:
GC.Collect();
GC.WaitForPendingFinalizers();
Its not ideal but its working.... but why do I have such a memory problem without it? Where should I look?
|
|
|
|
|
Take out the GC crap. It's really not helping that much and, by the description you gave, will actually hide the problem, not fix it. From what you've said, it sounds like there's some other object you have to Dispose, but haven't, before it goes out of scope or you're constantly adding to a collection. There really isn't that much code here. I don't know where that logger is going to but it may also be the problem.
Get a memory profiler[^]. It'll tell you what type the objects are that are taking up all that memory and give you a clue as to what to look for.
|
|
|
|
|
I will look into the memory profiler.
The powershell commands i'm using is the same code I'm using in a web application and haven't noticed any problems.
I thought it was the timers but I think its more LINQ to SQL since I swapped out the timers for the Quartz library.
The GC.Collect didn't actually help because when it ran I could see the memory go up and go down... however after a couple days i'm seeing i'm at 1.5GB now.
So it is possible that 1 timer is causing all this.... the logging is log4net and it logs to a text file
|
|
|
|
|
Could it be the timer itself? Nope.
But, it will most likely be in the code the timer executes.
|
|
|
|