|
Thanks alot for the help andy, thats just what I was looking for.
|
|
|
|
|
Good day everyone!
i had problem in returning a DataReader object from a ServicedComponent class. The dataset object was return fine, but when return the DataReader, the datareader object was a transparent_proxy object. I dont understand why only the return DataReader object is a transparent_proxy?
And if i use any method of the returned DataReader, the following error will be occur:
This remoting proxy has no channel sink which means either the server has no registered server channels that are listening, or this application has no suitable client channel to talk to the server.
my codes is simplied as follow:
//First layer is DataAccess Layer
public sealed class DataAccess : ServicedComponent
{
//others methods here...
public OleDbDataReader ExecuteReader (OleDbConnection objConn, string
sql, CommandType commandType, OleDbParameters paramList)
{
//SomeOthers codes here...
return objCmd.ExecuteReader(CommandBehavior.CloseConnection);
}
}
//Second Layer is Data Access Logic
public class EmployeeDAL : ServicedComponent
{
public IDataReader GetEmployeesFirstName()
{
//someothers codes here...
DataAccess objDa=new DataAccess();
OleDbConnection objConn=new OleDbConnection();
return objDa.ExecuteReader(objConn,sql);
}
}
Thanks in advance for your help.
gkb
|
|
|
|
|
The DataSet and DataTable are designed for remoting, the DataReader is the fastest leanest class for reading data. It leaves off everything that isn't required like remoting support. Plus since it represents an open live connection, it isn't a good idea to do anything to extend the lifetime of the object. Ideally every data reader should exist in a using block. If you need data to live on past the connection, then use a DataTable or DataSet.
I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
|
|
|
|
|
I've written a video jukebox that uses the Window Media Player as a control to play video/audio. The client has contacted their vendor for media, and they can get DVD quality files, but only if we write an algorithm for encryption, including coding per install, so they can provide a media file and it will only play on some installations of the software. Is there a way to access the streaming of WMP so that I can encrypt a file ( so that it's generally useless ), and make it play properly on WMP only within my jukebox program ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I've only played around with it, but the DirectShow API is based on hooking filters together. So you would create a filter for your encrypted format and just hook it up to the wmp filter for playback. I think you need to handle a little bit more of the ui with this route, creating your own play/pause buttons, etc. But I don't think that is too much extra work.
Another option would be to write your own codec that wrapped the WMP codec, I'm not sure if that is possible, but it might be an option.
Another option would be to distribute the content in an encrypted format. On installation, they would be decrypted and stored using NTFS file system encryption. As long as the customer never got access to the account that the software ran under, they'd never be able to read the content. That way you wouldn't have to do anything special for playback, just during installation.
I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
|
|
|
|
|
Can I use the DirectShow API to hook my own filter if I'm just passing videos to WMP ? I tried using Direct Show, in fact I wrote the whole system in DS9 before discovering that it's a buggy piece of crap.
andy brummer wrote:
Another option would be to distribute the content in an encrypted format. On installation, they would be decrypted and stored using NTFS file system encryption. As long as the customer never got access to the account that the software ran under, they'd never be able to read the content. That way you wouldn't have to do anything special for playback, just during installation.
That sort of thing appeals to me, because it would not create overhead during playback. Sadly, the vendor will not accept it.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Christian Graus wrote:
Can I use the DirectShow API to hook my own filter if I'm just passing videos to WMP
I'm not sure. I only played with it long enough to research creating an AVI from a C++ DirectX application. I ended up using the crusty old multimedia Avi api because it was easier then hooking all the filters together.
How about using something like Cassini to host ASP.Net and access the files from a local web server. That way you can embed the encryption logic in your web server and you just send WMP the local url for the file. Another option would be to use an asyncronous protocol handler to keep the translation in process, but I'm not sure that WMP would support that.
I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
|
|
|
|
|
Christian Graus wrote:
Is there a way to access the streaming of WMP so that I can encrypt a file (so that it's generally useless), and make it play properly on WMP only within my jukebox program?
I don't have any experience with this topic, but isn't it a classical use case for Windows Media DRM[^]?
Best regards
Dennis
|
|
|
|
|
Thanks - that looks promising, but I want to work with standard MPEG and mp3 files.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Christian Graus wrote:
Thanks - that looks promising, but I want to work with standard MPEG and mp3 files.
Maybe you should discuss that with your client. Using MPEG standards certainly has some advantages, but they don't help you to meet your client's media vendor conditions. T-Online, one of the largest internet access providers in Europe, has been running a video on demand service based on DRM protected WMV streaming for about a year. After you've paid for viewing a title on that platform it generates a license that allows you to watch the title for 24 hours (so it wouldn't matter if the content was stored on the hard disk or not because the license runs out, anyway). I like MPEG too, but this scenario with WMV + DRM might exactly be what makes the media vendor happy.
Best regards
Dennis
|
|
|
|
|
It's my impression that the vendor is driving the decision to provide DVD quality MPEGs. I'll have to ask.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
If i use ListViewItem.BeginEdit How to determine where the Item is click
|
|
|
|
|
this code let me write optional 4 digits and 3 decimal
1234.000
const string REGULAR_EXP = "(^-?\\d{1,4}\\.$)|(^-?\\d{1,4}$)|(^-?\\d{0,4}\\.\\d{1,3}$)";
i don't understand why if i type a number for ex.
12 and then add a minus (-) in front it works,
but it doesn't if you type first minus (-) and then the number.
i want REGULAR_EXP to add optional minus (-) before u type a number
|
|
|
|
|
If you put an @ at the beginning of your string, you won't need to \\ your \'s, which makes the regex more readable.
This doesn't always match what you'd hope, if you enter 3444.223, it will match the 3444. because that's the first test that works. You should change this to be all one regex, instead of three. However, the - part work fine for me in expresso. Your regex is working, what you need to explain is in what context you feel it does not work if you type the minus first.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Is there a fast way of finding the number of times a word appears in a string?
Eg.
String: "How do I search if a words exist in a string"
Target Word: "a"
Result: 2
|
|
|
|
|
Does this meet your needs?
<br />
string str = "How do I search if a words exist in a string";<br />
MatchCollection mc = Regex.Matches(str, " a ");<br />
Console.WriteLine(mc.Count.ToString());<br />
or perhaps...
<br />
string str = "How do I search if a words exist in a string";<br />
int index = str.IndexOf(" a ");<br />
int numWords = 0;<br />
<br />
while(index != -1)<br />
{<br />
index = str.IndexOf(" a ", index + 1);<br />
numWords++;<br />
}<br />
<br />
Console.WriteLine(numWords.ToString());<br />
|
|
|
|
|
V|ktor wrote:
string str = "How do I search if a words exist in a string";
MatchCollection mc = Regex.Matches(str, " a ");
Console.WriteLine(mc.Count.ToString());
Thank You! This worked great for me.
Here's a 5.
|
|
|
|
|
Just a little addition:
V|ktor's solution will find the word only if it's surrounded by spaces.
If you use @"\ba\b" instead, then the RE will match 'a' at the beginning or the end of the string, too.
If you haven't done yet I suggest you read through this excellent tutorial: The 30 Minute Regex Tutorial
[^]
Regards,
mav
|
|
|
|
|
Thanks mav.northwind!
I was just testing V|ktor's code and was wondering abt Casing and the Spaces too.
|
|
|
|
|
i wrote this code to delete a record.
string STOCKConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ALOHA_PATH + "\\stockcontrol;Extended Properties=dBase IV";
OleDbConnection STOCKConnection = new OleDbConnection(STOCKConnString);
string colID;
colID= this.dataGrid1[index,0].ToString();
string STOCKUpQuery = "Delete * From STOCK.DBF Where ID=("+colID+")";
OleDbCommand STOCKUpCommand = new OleDbCommand(STOCKUpQuery,STOCKConnection);
STOCKConnection.Open();
STOCKUpCommand.ExecuteNonQuery();
STOCKConnection.Close();
this record is deleted from stock.dbf, but i can still see this record in my datagrid1
i want to write a code to update my datagrid, dataset !!!!
i wrote this code but it's not a good solution to refill datagrid1, coz datagtid1 is showing
the records from the beginning , not from where i deleted the record but the scroll bar location is where i deleted the record !!!!!!
string MyConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ALOHA_PATH + "\\stockcontrol;Extended Properties=dBase IV";
OleDbConnection MyOleb = new OleDbConnection(MyConnection);
OleDbDataAdapter da= new OleDbDataAdapter("Select * from STOCK.dbf",MyOleb);
DataSet dsrefresh = new DataSet();
da.Fill (dsrefresh,"Stock");
dataGrid1.DataSource = dsrefresh.DefaultViewManager;
dataGrid1.ReadOnly = true;
MyOleb.Close();
Thx
|
|
|
|
|
I noticed that my HOOK function isn't capturing mouse related messages. But others like WM_ACTIVEAPP is fine. I'm using the CallWndProc method instead of a mouse hook procedure.
I want to be able to peek at ALL mouse and keyboard related windows messages across the desktop and other applications. The mouse hook seemed to only capture what was being delivered to my app. When i was experimenting with the mouse hook proc, i did this:
hHook = SetWindowsHookEx(WH_MOUSE,MouseHookProcedure,
(IntPtr)0,0);
.. to specify all threads across the desktop (last param). But it crashed here. Doesn't like the last two parameters 0 and 0. So this is why i'm not trying CallWndProc.
Any ideas of how to do this?
private void button8_Click(object sender, System.EventArgs e)
{
if(hHook == 0)
{
CWPHookProcedure = new HookProcDT(Form1.CWPHookProc);
hHook = SetWindowsHookEx
(WH_CALLWNDPROC,
CWPHookProcedure,
IntPtr.Zero,
User32.GetWindowThreadProcessId(this.Handle.ToInt32(),
0));
.. etc
.. and then in my CallWndProc hook method:
public static int CWPHookProc(int code, IntPtr wparam, IntPtr lParam)
{
if (code < 0)
return User32.CallNextHookEx(hHook, code, wparam, lParam);
CWPSTRUCT cwp = (CWPSTRUCT) Marshal.PtrToStructure(
lParam,
typeof(CWPSTRUCT));
if (code == 0) //this means that the hook procedure should process the
//message contained in CWPSTRUCT
{
switch(cwp.message)
{
case WM_ACTIVATEAPP: //GET'S HERE
MessageBox.Show("Is here in CWPHookProc");
break;
case WM_MOUSEMOVE: //BUT NOT HERE
MessageBox.Show("Is here in CWPHookProc");
break;
}
}
return User32.CallNextHookEx(hHook, code, wparam, lParam);
}
//Declare wrapper managed CWPStruct class.
[StructLayout(LayoutKind.Sequential)]
public class CWPSTRUCT
{
public IntPtr lparam;
public IntPtr wparam;
public int message;
public IntPtr hwnd;
}
|
|
|
|
|
c121hains wrote:
I want to be able to peek at ALL mouse and keyboard related windows messages across the desktop and other applications.
What you need are global hooks. Fortunately there are WH_MOUSE_LL[^] and WH_KEYBOARD_LL[^] which don't use code injection and can be used with managed code. Check out Processing Global Mouse and Keyboard Hooks in C#[^] to get a working code example.
Best regards
Dennis
|
|
|
|
|
This worked great! Thank you!
|
|
|
|
|
|
how to edit,insert,update database on datagrid same on microsoft excel
koochinh
|
|
|
|