|
I think I have found my answer:
private static string RedactCC(string stringToRedact)
{
const string pattern = @"(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})";
stringToRedact = Regex.Replace(
stringToRedact,
pattern,
m => "***-**-" + m.Value.Substring(m.Value.Length - 4, 4));
return stringToRedact;
}
private static string RedactSSN(string stringToRedact)
{
const string pattern = @"\d{3}-\d{2}-\d{4}";
stringToRedact = Regex.Replace(
stringToRedact,
pattern,
m => "***-**-" + m.Value.Substring(m.Value.Length - 4, 4));
return stringToRedact;
}
Maybe this post will help someone else in the future.
Anne
|
|
|
|
|
|
Find() will only load the one object. It will not load related objects. Use SingleOrDefault() instead.
If there is no primary key field for a table, EF will not work with it. You MUST define the ID field for the table, otherwise EF has no way of updating that table.
|
|
|
|
|
|
Take a look at ObjectQuery.MergeOption[^]
As I recall from a few years ago, this was related to Entity loading (or not) related objects.
A positive attitude may not solve every problem, but it will annoy enough people to be worth the effort.
|
|
|
|
|
|
Whoops! I forgot to put that in the post.
using (var context = new MyDbContext())
{
var items = context.MyTable.Include(c => c.YourRelatedCollection).Where(...);
}
You don't need a stored procedure to load related enties.
|
|
|
|
|
|
Note: I'm using VS 2015 CTP 6, but I have not seen this issue outside the Application described here using VS 2015. I observe the same behavior if the project is opened in Visual Studio 2013.
My MainForm instantiates a second utility Form, and the 'Owner property of that utility Form instance is set to the instance of the MainForm. There is only one instance of the utility Form created.
The utility Form has its FormClosing Event set so it hides the utility Form, rather than allowing it to be closed (by setting the FromClosingEventArgs.cancel property to 'true).
Here's the MainForm 'Closing EventHandler:
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
if(utilityForm != null) utilityForm .Dispose();
} How could omitting explicitly setting the value of e.Cancel to 'false in the MainForm's code produce this behavior ? Calling utilityForm.Dispose should have no possible impact on the FormClosingEventArgs of the MainForm.
Appreciate any ideas.
thanks, Bill
«To kill an error is as good a service as, and sometimes even better than, the establishing of a new truth or fact» Charles Darwin in "Prospero's Precepts"<</font>
modified 5-Mar-15 9:57am.
|
|
|
|
|
Ooh I think you have a owned form which isn't playing cricket! When the owner begins to close it tries to close the owned form but can't and then the owner's FormClosing event handler is supplied with a precancelled event args.
Rather than dispose of the utility form you should allow the form to close itself. In the example I assume that Hide should only occur when the user attempts to close the form manually.
protected override void OnFormClosing(FormClosingEventArgs e) {
if (e.CloseReason == CloseReason.UserClosing) {
Hide();
e.Cancel = true;
}
base.OnFormClosing(e);
}
Alan.
|
|
|
|
|
Thanks, Alan, that does take care of the problem. I never thought that the 'Owned Form relationship could be a factor !
«To kill an error is as good a service as, and sometimes even better than, the establishing of a new truth or fact» Charles Darwin in "Prospero's Precepts"<</font>
|
|
|
|
|
Hi,
I am using below code to save image to database.
I would like to ask how can I modify to save PDF to the database?
using (var memoryStream = new MemoryStream())
{
pictureDocument.Image.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png);
byte[] employee_document = memoryStream.ToArray();
sql_command.Parameters.AddWithValue("param_document", employee_document).MySqlDbType = MySqlDbType.LongBlob;
}
Thanks,
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|
|
Convert your PDF to a byte stream and save that instead. You can use a file stream to do this.
|
|
|
|
|
Hi all,,
I was reading about sending a mouse motion to for example Notepad..
I tried to implement something to help me send a right click to Notepad so when the event fired it shows that there is a right click fired and the right click menu appears in the notepad..
I wrote this code but I'm not sure it's correct -no error but it doesn't work..
// to send the mouse Message
[DllImport("user32.dll")]
public static extern int SendMessage(int hWnd,uint Msg, int wParam,int lParam);
// mouse input
private const uint WM_RBUTTONDOWN = 0x0204;
private const uint WM_RBUTTONUP = 0x0205;
// event handler
private void button6_Click(object sender, EventArgs e)
{
int window = FindWindow(null, "Notepad");
SendMessage(window, WM_RBUTTONDOWN, 0, 0);
SendMessage(window, WM_RBUTTONUP, 0, 0);
}
it does not work for me,,
Do I need to add extra code or functions for that??
Thanks
|
|
|
|
|
|
fyi: according to the site, the Mouse Simulation facility was never implemented.
«To kill an error is as good a service as, and sometimes even better than, the establishing of a new truth or fact» Charles Darwin in "Prospero's Precepts"<</font>
|
|
|
|
|
Well, I actually bothered to look at the code.
There is an interface (IMouseSimulator) and a class (MouseSimulator) that look suspiciously like they may have to do something with the mouse.
And executing the MouseMoveTo() method actually moved the mouse!
Maybe there is some functionality missing, but it's a pretty good start: including mouse clicks; double-clicks; left / right buttons; etc.
|
|
|
|
|
Gerry Schmitz wrote: Well, I actually bothered to look at the code. You don't want to go doing that. It'll just give you dangerous knowledge.
|
|
|
|
|
You're right. Folks will now expect me to prove the stuff actually works. Or create some documentation...
|
|
|
|
|
I need an E-relationship diagram for a dictionary that can translate english to pashto and pashto to english and it shows tha for of every words
|
|
|
|
|
And?
What have you done so far?
Where are you stuck?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
You picked the wrong forum for this. You should have asked in the design forum as your question has nothing to do with C#. When you do post a question in the correct location, please ensure you provide enough information to say exactly what problem you are facing and what steps you have taken so far.
|
|
|
|
|
For a variety of reasons I am running a Windows Forms app which creates several threads. In each of these threads I create another form that hosts an ActiveX control (3rd party which requires a window).
This runs kind of OK but I have some problems and hope you can help:
- When I try to create a Windows.Forms.Timer on the form I created in my thread, it never calls the callback. Any idea?
- I can use a System.Timers.Timer but then I have problems in the event handler to use Invoke to access methods of my second form
- If my ActiveX control sends an event from this secondary thread, is that event handled in the main application message pump?
- I have a seen a lot of articles on how I can raise an event from a thread where the event handler runs on the GUI thread. How about the other way round? Can I raise an event from the GUI thread that then executes in some other thread? I could not make that work.
Sorry about the many questions.
BTW, I cannot replace the ActiveX controls with something else and they have to run in separate threads to increase speed. I am basically doing 4 simultaneous OCR operations and I need to do it fast, hence the threads.
|
|
|
|
|
landersohn69 wrote: I am basically doing 4 simultaneous OCR operations and I need to do it fast,
hence the threads. The OCR operations should not require a GUI.
landersohn69 wrote: For a variety of reasons I am running a Windows Forms app which creates several
threads. In each of these threads I create another form That's not really a supported scenario. Each control is bound to the thread where its message-pump is executed. That may "seem" to work but can collapse without warning.
Divide the actual work over different threads and have the main-thread do the UI.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
You are correct, OCR shouldn't BUT I am required to use a 3rd party ActiveX control to do the binarization and OCR. Since it's not just a library but an ActiveX control it must have a parent window
|
|
|
|