Search Results

Search found 144 results on 6 pages for 'hui jin'.

Page 4/6 | < Previous Page | 1 2 3 4 5 6  | Next Page >

  • Database Error Handling: What if You have to Call Outside service and the Transaction Fails?

    - by Ngu Soon Hui
    We all know that we can always wrap our database call in transaction ( with or without a proper ORM), in a form like this: $con = Propel::getConnection(EventPeer::DATABASE_NAME); try { $con->begin(); // do your update, save, delete or whatever here. $con->commit(); } catch (PropelException $e) { $con->rollback(); throw $e; } This way would guarantee that if the transaction fails, the database is restored to the correct status. But the problem is that let's say when I do a transaction, in addition to that transaction, I need to update another database ( an example would be when I update an entry in a column in databaseA, another entry in a column in databaseB must be updated). How to handle this case? Let's say, this is my code, I have three databases that need to be updated ( dbA, dbB, dbc): $con = Propel::getConnection("dbA"); try { $con->begin(); // update to dbA // update to dbB //update to dbc $con->commit(); } catch (PropelException $e) { $con->rollback(); throw $e; } If dbc fails, I can rollback the dbA but I can't rollback dbb. I think this problem should be database independent. And since I am using ORM, this should be ORM independent as well. Update: Some of the database transactions are wrapped in ORM, some are using naked PDO, oledb ( or whatever bare minimum language provided database calls). So my solution has to take care this. Any idea?

    Read the article

  • How to remove keypress from input with jquery?

    - by Jin Yong
    Does anyone know how can I remove keypress from input with jquery? Example: <input type="text" keypress="cleanMsg()" id="cleanMsg" name="cleanMsg"> How can I removed the keypress="cleanMsg()" from input by using jquery? Or anyway to replace keypress="cleanMsg()" to keypress="Msg()"??

    Read the article

  • How to add a local image in my firefox entension?

    - by jin
    I am developing a firefox extension and create a table and in it add a image , and I create a image with : var _img = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "xul:image"); and then I found I couldn't set its attribute "src" with a local image just like use its Url: chrome:\...., so I have to locate it in a web url:http:\ , but a problem will arise, when the http:\ couldn't be visted, How to do? if can I set the attribute of a image with a local url? Thank you very much!

    Read the article

  • Interop Structure: Should Unsigned Short be Mapped to byte[]?

    - by Ngu Soon Hui
    I have such a C++ structure: typedef struct _FILE_OP_BLOCK { unsigned short fid; // objective file ID unsigned short offset; // operating offset unsigned char len; // buffer length(update) // read length(read) unsigned char buff[MAX_BUFF_SIZE]; } FILE_OP_BLOCK; And now I want to map it in .Net. The tricky thing is that the I should pass a 2 byte array for fid, and integer for len, even though in C# fid is an unsigned short and len is an unsigned char I wonder whether my structure ( in C#) below is correct? public struct File_OP_Block { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public byte[] fid; public ushort offset; public byte length; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 240)] public char[] buff; }

    Read the article

  • Reverse Bredth First Search in C#

    - by Ngu Soon Hui
    Anyone has a ready implementation of the Reverse Bredth First Search algorithm in C#? By Reverse Bredth First Search, I mean instead of searching a tree starting from a common node, I want to search the tree from the bottom and gradually converged to a common node. Let's see the below figure, this is the output of a Bredth First Search: In my reverse bredth first search, 9,10,11 and 12 will be the first few nodes found ( the order of them are not important as they are all first order). 5, 6, 7 and 8 are the second few nodes found, and so on. 1 would be the last node found. Any ideas or pointers?

    Read the article

  • Reverse Breadth First traversal in C#

    - by Ngu Soon Hui
    Anyone has a ready implementation of the Reverse Breadth First traversal algorithm in C#? By Reverse Breadth First traversal , I mean instead of searching a tree starting from a common node, I want to search the tree from the bottom and gradually converged to a common node. Let's see the below figure, this is the output of a Breadth First traversal : In my reverse breadth first traversal , 9,10,11 and 12 will be the first few nodes found ( the order of them are not important as they are all first order). 5, 6, 7 and 8 are the second few nodes found, and so on. 1 would be the last node found. Any ideas or pointers? Edit: Change "Breadth First Search" to "Breadth First traversal" to clarify the question

    Read the article

  • Using LINQ to Obtain Max of Columns for Two Dimensional Arrays

    - by Ngu Soon Hui
    Is there anyway to use LINQ to obtain the maximum of each columns for two dimensional arrays? Assume that I have the following: var arrays = new double[5,100](); I want to get the maximum of arrays[0,:], arrays[1,:] .... arrays[4,:]. How to use LINQ to do it? I could have use such method public double GetMax(double[,] arr, int rowIndex) { var colCount = arr.GetLength(1); double max = 0.0; for(int i=0; i<colCount; i++) { max=Math.Max(Math.Abs(arr[rowIndex, i]), max); } return max; } But I would prefer a more succinct ways of doing things.

    Read the article

  • When Should One Call glGetError ?

    - by Ngu Soon Hui
    glLoadIdentity says GL_INVALID_OPERATION is generated if glLoadIdentity is executed between the execution of glBegin and the corresponding execution of glEnd. But GL_INVALID_OPERATION is a flag returns by glGetError. My question is, when should we call glGetError ( in order to know whether we are calling opengl in correct sequence)?

    Read the article

  • c# bound Datagridview

    - by Jin
    I have a datagridview and it is bound to a stored procedure which returns a number of result columns. There is also a binding navigator with "Add New" button included. If I click "Add New" button, it creates a new row in datagridview automatically, and If I leave that new row by clicking a different row. datagridview invokes "commit" or something. so the question is How do I make datagridview not to commit adding a new row when I leave the cell?

    Read the article

  • Reverse Breath First Search in C#

    - by Ngu Soon Hui
    Anyone has a ready implementation of the Reverse Breath First Search algorithm in C#? By Reverse Breath First Search, I mean instead of searching a tree starting from a common node, I want to search the tree from the bottom and gradually converged to a common node. Let's see the below figure, this is the output of a Breath First Search: In my reverse breath first search, 9,10,11 and 12 will be the first few nodes found ( the order of them are not important as they are all first order). 5, 6, 7 and 8 are the second few nodes found, and so on. 1 would be the last node found. Any ideas or pointers?

    Read the article

  • Transform Two Lists into One Different List

    - by Ngu Soon Hui
    I have two lists of double List<double> X List<double> Y And I have a destination object: public class PointD { public double X {get;set;} public double Y {get;set;} } How to transform them into a single list? public static List<PointD> Transform(List<double> X, List<double> Y) { } All the errors checking must be there.

    Read the article

  • Unique Constraint At Data Level in GAE

    - by Ngu Soon Hui
    It seems that the unique constraint is not natively supported in GAE, although one can enforce unique check before putting an object to store. But that was in January 2009, what about now? Can I specify unique constraint on a column during schema creation? i.e. class Account(db.Model): name = db.StringProperty() email = db.StringProperty() as unique # something like this @classmethod def create(cls, name, email): a = Account(name=name, email=email) a.put() return a

    Read the article

  • DllImport Based on OS Platform

    - by Ngu Soon Hui
    I have a mixture of unmanaged code ( backend) and managed code ( front end), as such, I would need to call the unmanaged code from my managed code, using interop techniques and DllImport attribute. Now, I've compiled two versions of unmanaged code, for both 32 and 64 bit OS; they are named service32.dll and service64.dll respectively. So, in my .Net code, I would have to do a DllImport for both dlls: [DllImport(@"service32.dll")] //for 32 bit OS invocation public static void SimpleFunction(); [DllImport(@"service64.dll")] //for 64 bit OS invocation public static void SimpleFunction(); And call them depending on which platform my application is running on. The issue now is that for every unmanaged function, I have to declared it twice, one for 32 bit OS and one for 64 bit OS. This is a duplication of work, and everytime I change the signature of an unmanaged function, I have to modified it in two places. Is there anyway that I can change the argument in DllImport so that the correct dll will be invoked automagically, depending on the platform?

    Read the article

  • Generate Color Gradient in C#

    - by Ngu Soon Hui
    My question here is similar to the question here, except that I am working with C#. I have two colors, and I have a predefine steps. How to retrieve a list of Colors that are the gradients between the two? This is an approach that I tried, which didn't work: int argbMax = Color.Chocolate.ToArgb(); int argbMin = Color.Blue.ToArgb(); var colorList = new List<Color>(); for(int i=0; i<size; i++) { var colorAverage= argbMin + (int)((argbMax - argbMin) *i/size); colorList.Add(Color.FromArgb(colorAverage)); } If you try the above code, you will find that a gradual increase in argb doesn't correspond to a visual gradual increase in the color. Any idea on this?

    Read the article

  • Observer pattern and violation of Single Responsibility Principle

    - by Devil Jin
    I have an applet which repaints itself once the text has changed Design 1: //MyApplet.java public class MyApplet extends Applet implements Listener{ private DynamicText text = null; public void init(){ text = new DynamicText("Welcome"); } public void paint(Graphics g){ g.drawString(text.getText(), 50, 30); } //implement Listener update() method public void update(){ repaint(); } } //DynamicText.java public class DynamicText implements Publisher{ // implements Publisher interface methods //notify listeners whenever text changes } Isn't this a violation of Single Responsibility Principle where my Applet not only acts as Applet but also has to do Listener job. Same way DynamicText class not only generates the dynamic text but updates the registered listeners. Design 2: //MyApplet.java public class MyApplet extends Applet{ private AppletListener appLstnr = null; public void init(){ appLstnr = new AppletListener(this); // applet stuff } } // AppletListener.java public class AppletListener implements Listener{ private Applet applet = null; public AppletListener(Applet applet){ this.applet = applet; } public void update(){ this.applet.repaint(); } } // DynamicText public class DynamicText{ private TextPublisher textPblshr = null; public DynamicText(TextPublisher txtPblshr){ this.textPblshr = txtPblshr; } // call textPblshr.notifyListeners whenever text changes } public class TextPublisher implments Publisher{ // implements publisher interface methods } Q1. Is design 1 a SPR violation? Q2. Is composition a better choice here to remove SPR violation as in design 2.

    Read the article

  • Set A Transparent Color

    - by Ngu Soon Hui
    I have a Color, and I have a method that should return a more "transparent" version of that color. I tried the following method: public static Color SetTransparency(int A, Color color) { return Color.FromArgb(A, Color.R, Color.G, Color.B); } but for some reason, no matter what the A is, the returned Color's transparency level just won't change. Any idea?

    Read the article

  • Interface that Entails the Implementation of Indexer

    - by Ngu Soon Hui
    I am looking for a framework-defined interface that declares indexer. In other words, I am looking for something like this: public interface IYourList<T> { T this[int index] { get; set; } } I just wonder whether .Net framework contains such interface? If yes, what is it called? You might ask why I can't just create the interface myself. Well, I could have. But if .Net framework already has that why should I reinvent the wheel?

    Read the article

  • Efficient copy of entire directory

    - by Hui Jin
    I want to copy one directory and the two files under it to another shared location of shared storage. Is it possible to combine the three(one directory and two files) as a continuous file writing and decompose it at another side to save the cost? I am limited to c language and Unix/Linux. I am considering to create a structure with the inode info and get the data at receiver. Thanks!

    Read the article

  • using a stored procedure for login in c#

    - by Jin Yim
    Hi all, If I run a store procedure with two parameter values (admin, admin) (parameters : admin, admin) I get the following message : Session_UID User_Group_Name Sys_User_Name NULLAdministratorsNTMSAdmin No rows affected. (1 row(s) returned) @RETURN_VALUE = 0 Finished running [dbo].[p_SYS_Login]. -- To get the same message in c# I used the code following : string strConnection = Settings.Default.ConnectionString; using (SqlConnection conn = new SqlConnection(strConnection)) { using (SqlCommand cmd = new SqlCommand()) { SqlDataReader rdr = null; cmd.Connection = conn; cmd.CommandText = "p_SYS_Login"; cmd.CommandType = CommandType.StoredProcedure; SqlParameter paramReturnValue = new SqlParameter(); paramReturnValue.ParameterName = "@RETURN_VALUE"; paramReturnValue.SqlDbType = SqlDbType.Int; paramReturnValue.SourceColumn = null; paramReturnValue.Direction = ParameterDirection.ReturnValue; cmd.Parameters.Add(paramReturnValue); cmd.Parameters.Add(paramGroupName); cmd.Parameters.Add(paramUserName); cmd.Parameters.AddWithValue("@Sys_Login", "admin"); cmd.Parameters.AddWithValue("@Sys_Password", "admin"); try { conn.Open(); rdr = cmd.ExecuteReader(); string test = (string)cmd.Parameters["@RETURN_VALUE"].Value; while (rdr.Read()) { Console.WriteLine("test : " + rdr[0]); } } catch (Exception ex) { string message = ex.Message; string caption = "MAVIS Exception"; MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBox.Show( message, caption, buttons, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); } finally { cmd.Dispose(); conn.Close(); } } } but I get nothing in SqlDataReader rdr ; is there something I am missing ? Thanks

    Read the article

  • Disable Source tab in Google Code

    - by Ngu Soon Hui
    How to disable source tab in Google Code? I don't want any random users to look at my code. Before you say that this can't be done, that Google Code is by default open source. Someone managed to do it, somehow. Edit: Before you downvote me further, take a look at the link I provided. It's possible to do it, despite whatever you want to say. And I want to know how.

    Read the article

< Previous Page | 1 2 3 4 5 6  | Next Page >