|
Would XML file work that way? And is it possible to use CRUD with XML?
|
|
|
|
|
Yes and Yes
Use XML (file based storage) only if you have very limited data in a simple data structure AND the application is single user only.
File based data (XML) is notoriously difficult to manage when doing CRUD, you need to read the entire file, select the record you want to modify, change the record, reconstruct the file, write the entire file to the disk.
No multiuser, there is no concept of record locking.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Then what's the best method? Use XML or SQL database? Because I have to use CRUD.
|
|
|
|
|
Use SQL Server or LocalDB or SQL Lite, there are a number of databases available, I would use SQL Server express if it need to be a server based system.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi all,
I'm new to C# and was wondering what is the best way to execute a .ps1 file to perform a task in Exchange. I have a button that when click should execute the ps1 file and perform a test like get mailbox.
As part of the task, I am using a browse to all users to input and then display the output in a textbox beneath the button.
Thanks for your help in advance.
|
|
|
|
|
choppol wrote: I'm new to C# and was wondering what is the best way to execute a .ps1 file ..and that's where your specs should pause, and where you Google on how to execute a PowerShell script. Any tutorial and example should be considered.
choppol wrote: to perform a task in Exchange Prolly means executing it on that server, with some Exchange-specific libraries.
choppol wrote: I have a button that when click should execute the ps1 file and perform a test like get mailbox. Means you put the code from the tutorial under the click-event of that button. What kind of button is this btw, is it in WinForms, WPF, something webby?
choppol wrote: As part of the task, I am using a browse to all users to input and then display the output in a textbox beneath the button. How do you browse to all users and what does it have to do with the task?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
To set things up, what I was trying to do was make a TextBox flash when a user misses a required input. I got it to work but I don't understand the error I was getting at first.
Code that had an exception:
private void FlashRequiredTextBox(TextBox target)
{
ColorAnimation flash = new ColorAnimation(Colors.White, Colors.Red, new Duration(TimeSpan.FromMilliseconds(75D))) { AutoReverse = true, RepeatBehavior = new RepeatBehavior(5D) };
target.Background.BeginAnimation(SolidColorBrush.ColorProperty, flash);
}
The exception that was thrown:
Cannot animate the 'Color' property on 'System.Windows.Media.SolidColorBrush' because the object is sealed or frozen.
I understand why the exception is thrown but what I don't get is why this code fixes it.
private void FlashRequiredTextBox(TextBox target)
{
ColorAnimation flash = new ColorAnimation(Colors.White, Colors.Red, new Duration(TimeSpan.FromMilliseconds(75D))) { AutoReverse = true, RepeatBehavior = new RepeatBehavior(5D) };
target.Background = new SolidColorBrush(Colors.White);
target.Background.BeginAnimation(SolidColorBrush.ColorProperty, flash);
}
Can somebody with a better understanding of WPF control rendering explain this?
if (Object.DividedByZero == true) { Universe.Implode(); }
Meus ratio ex fortis machina. Simplicitatis de formae ac munus. -Foothill, 2016
|
|
|
|
|
The default style for the TextBox control sets the background brush to:
<Setter Property="Panel.Background">
<Setter.Value>
<DynamicResource ResourceKey="{x:Static SystemColors.WindowBrushKey}" />
</Setter.Value>
</Setter>
(I couldn't find an official source, but you can view the default styles using Style Snooper[^].)
That configures the background to use the SystemColors.WindowBrush , and to dynamically update whenever the Windows colour settings are changed.
The WindowBrush property calls the MakeBrush method[^], which explicitly freezes the brush:
private static SolidColorBrush MakeBrush(CacheSlot slot)
{
SolidColorBrush brush;
lock (_brushCacheValid)
{
if (!_brushCacheValid[(int)slot])
{
brush = new SolidColorBrush(GetSystemColor(slot));
brush.Freeze();
_brushCache[(int)slot] = brush;
_brushCacheValid[(int)slot] = true;
}
else
{
brush = _brushCache[(int)slot];
}
}
return brush;
}
When you try to animate that brush from the code-behind, you then get an error because it has been frozen: Freezable Objects Overview[^]
With your second code block, you've set the background to a new SolidColorBrush , which hasn't been frozen. The animation then works as expected. You could also use:
private void FlashRequiredTextBox(TextBox target)
{
ColorAnimation flash = ...;
if (target.Background.IsFrozen) target.Background = target.Background.Clone();
target.Background.BeginAnimation(SolidColorBrush.ColorProperty, flash);
}
As far as I can tell, when you configure the animation in the XAML markup, the system ensures that the background brush is not frozen. When you configure the animation from the code-behind, that check is left up to you.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I love this place, almost every day I can find something new (to me) and interesting. I have a great dislike for grossly animated views however this may be useful to get in a users face
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Ah, it makes sense that default brushes are created and then frozen right away. If they weren't, I suppose it might cause all sorts of nasty side effects. Thanks for the detailed explanation.
if (Object.DividedByZero == true) { Universe.Implode(); }
Meus ratio ex fortis machina. Simplicitatis de formae ac munus. -Foothill, 2016
|
|
|
|
|
Could some one suggest some way to improve the performance of getting log description. We use FormatDescription() to read the description of the logs and the performance is pathetic.
To put the matter in perspective, if I comment the FormatDescription(), my application of parsing 28000+ logs completes in about 2 minutes, and on adding that line the application takes well over 1.3 hrs!
Regards,
Pitrak
|
|
|
|
|
FormatDescription is well known for being slow - the general recommendation is to drop down to the Win32 APIs instead.
This space for rent
|
|
|
|
|
Hi,
Thanks for the reply; could you please help me with the name of the Win32 API to use.
If you could provide a simple code snippet, that would be really helpful.
I am actually intending to use C# API's to build my application. So, how would I be using the Win32 API's?
Regards,
Pitrak
|
|
|
|
|
Have you found any workarounds for this? I'm actually facing the same issue and don't know what to do.
Regards!.
|
|
|
|
|
Guys,,, please help me to create a TCP connection C# to C++. is it possible to make a code C# SERVER and the Client is C++....please help me guys...thanks
|
|
|
|
|
Jarlo Belledo wrote: is it possible to make a code C# SERVER and the Client is C++
Yes.
Jarlo Belledo wrote: please help me to create a TCP connection
What have you tried?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
|
|
TCP is TCP. What you need to do is search for an example of creating a C# TCP client/server and take the server part. Then you look for an example of creating a C++ client/server and take the client part. I suspect the question you are really asking is, what would the payload look like when communicating between them.
This space for rent
|
|
|
|
|
I suspect the question is will someone write this for me?
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I know this isn't a Powershell forum, but the question is about PS in C#..
I have the following Powershell, that clears my languagebar, Setting Norwegian language. Adds Norwegian Apple Keyboard, removes, then Adds back to the end normal Norwegian keyboard:
$li = New-WinUserLanguageList "nb-NO";
$li[0].InputMethodTips.Add("0414:A0000414");
$li[0].InputMethodTips.Remove("0414:00000414");
Set-WinUserLanguageList $li -Force
$li = Get-WinUserLanguageList
$li[0].InputMethodTips.Add("0414:00000414");
Set-WinUserLanguageList $li -Force
This works Peachy when run from the powershell commandline. It updates the Language bar, and
set the Apple keyboard as default.
But when embedding it in C# like this:
string script = "";
script += "$li = New-WinUserLanguageList nb-NO;";
script += "$li[0].InputMethodTips.Add(\"0414:A0000414\");";
script += "$li[0].InputMethodTips.Remove(\"0414:00000414\");";
script += "Set-WinUserLanguageList $li -Force;";
script += "$li[0].InputMethodTips.Add(\"0414:00000414\");";
script += "Set-WinUserLanguageList $li -Force;";
using ( PowerShell ps = PowerShell.Create() ) {
ps.AddScript( script );
var result = ps.Invoke();
foreach ( var item in result ) {
}
}
The language bar does not get updated, although the language IS switched to Norwegian...
Is there any limitations on what kind of ps-scripts you can embed in C#?
(Both the script and the c# code runs as me/current user)...
TIA.
--
Dag.
|
|
|
|
|
Your two scripts aren't identical. The first line doesn't have nb-NO quoted, so try surrounding this with \"nb-NO\" . Also, you are missing $li = Get-WinUserLanguageList from your C#.
This space for rent
|
|
|
|
|
Thanks for commenting...
Thats not it, thou... Just me trying small adjustments.
With or without quotes, and with or without re-getting the newly set list.
Results are the same.
--
Dag.
|
|
|
|
|
Thanks for commenting...
The differences are just me trying small differences. They where the same.
Didn't work in c# when they were identical either...
(But I should of course have posted them equal, to avoid confusion).
--
Dag.
|
|
|
|
|
You might need to set the execution policy:
Set-ExecutionPolicy Unrestricted -Scope Process
This space for rent
|
|
|
|