예제 #1
0
파일: Class2.cs 프로젝트: mlatjac/synched
        private SynchedModel(FlowDocument fdDoc, String strUser)
        {
            ModelDB = SynchedDB.GetInstance();
            Doc     = fdDoc;

            // Get a user object for the current user
            currentUser = ModelDB.GetUserByKey(strUser);

            if (currentUser == null)
            {
                throw new Exception("No user found for user key " + strUser);
            }

            // Create an object for the current document
            SDCurrentDoc = new SynchedDocument {
                Id = 1, Owner = currentUser
            };                                                                  // FIXME Document ID is hardcoded
        }
예제 #2
0
파일: Class2.cs 프로젝트: mlatjac/synched
        // Fetch a user by key
        public SynchedUser GetUserByKey(String strKey)
        {
            // Select
            SqlCommand command = new SqlCommand("SELECT * FROM [dbo].[User] WHERE UserKey=@UserKey", conn);

            command.Parameters.Add(new SqlParameter("UserKey", strKey));

            using (SqlDataReader reader = command.ExecuteReader())
            {
                SynchedUser suUserForKey = null;
                while (reader.Read())
                {
                    // Create a Person object
                    suUserForKey = new SynchedUser {
                        Id = (int)reader["Id"], Name = (string)reader["Name"], UserKey = (string)reader["UserKey"]
                    };
                }

                return(suUserForKey);
            }
            // FIXME Remove test data stub below
            //return new SynchedUser { Name = "Suzan" }; //FIXME: actually get a user from DB
        }