/// <summary> /// Retrieves customers from the database and gets a set of results. /// </summary> /// <remarks> /// NOTE: You must first build the database using the provided scripts. /// See the Database project for the scripts. /// </remarks> /// <returns></returns> public static Customers Retrieve() { Customers customerList = new Customers(); // Retrieve the data using the data access component DataTable dt = Dac.ExecuteDataTable("CustomerRetrieve"); // Process each row in the table foreach (DataRow dr in dt.Rows) { Customer customerInstance = new Customer { CustomerId = (int)dr["CustomerId"], LastName = dr["LastName"].ToString(), FirstName = dr["FirstName"].ToString(), EmailAddress = dr["EmailAddress"].ToString(), CustomerType = (CustomerTypeOption)dr["CustomerType"] }; // Retrieve the invoices for this customer customerInstance.InvoiceList = Invoices.Retrieve(customerInstance.CustomerId); customerList.Add(customerInstance); } return(customerList); }
private void MainForm_Load(object sender, EventArgs e) { DisableStandardToolbar(); try { Dac dac = new Dac(); dac.LoadDatabaseFileLocationFromReqistry(); DatabaseFileLocationToolStripStatusLabel.Text = "Database : " + Dac.Current.DatabaseFileLocation; } catch { DatabaseFileLocationToolStripStatusLabel.Text = "Database Connection Error !!!"; } try { TwitterConnection twitterConnection = new TwitterConnection(); twitterConnection.LoadCredentialsFromReqistry(); twitterConnection.Connect(); TwitterUserToolStripStatusLabel.Text = "Twitter User : "******"Twitter Connection Error !!!"; } }
public static MethodResult <bool> IsTweetSaved(ITweet tweet) { Dac dac = new Dac(); MethodResult <bool> existsResult = dac.Exists("Tweet", "TweetId", tweet.Id); return(existsResult); }
private void LoadComboBox() { DataTable dataTable = new Dac().ExecuteDataTable("SELECT Id, Name FROM UserCategory ORDER BY Name").Result; UserCategoryComboBox.DataSource = dataTable; UserCategoryComboBox.DisplayMember = "Name"; UserCategoryComboBox.ValueMember = "Id"; }
private bool Generate(string pCommandText) { DataSet ds = new DataSet(); Dac.GetDataAdapter(pCommandText).FillSchema(ds, SchemaType.Mapped, TableName); string generatedCode = GenerateDataSet(ds, DSNameSpace, TableName, SchemaName, DataBaseName); string code = string.Join("", GetTDSGeneratorComment(), generatedCode); return(WriteFile(code, DSPath, DSFullPath)); }
private void SetUser(decimal userId) { if (userId == 0) { return; } Dac dac = new Dac(); Dictionary <string, object> values = dac.Select("User", "Id", userId).Result; UserNameTextBox.Text = (string)values["UserName"]; }
private void SelectUserButton_Click(object sender, EventArgs e) { UserListForm userListForm = new UserListForm(ShowMode.Select); if (userListForm.ShowDialog() == DialogResult.OK) { Dac dac = new Dac(); Dictionary <string, object> values = dac.Select("User", "Id", userListForm.SelectedUserId).Result; UserNameTextBox.Text = (string)values["UserName"]; this.userId = userListForm.SelectedUserId; } }
public void DacTest() { var discovery = new DeviceDiscovery(); var dac = discovery.FindFirstDevice(); var name = discovery.GetDeviceName(dac); var ip = discovery.GetDeviceIp(dac); Dac etherDream = new Dac(ip); var points = MakePoints(1000); etherDream.StreamPoints(points); }
private void TestButton_Click(object sender, EventArgs e) { MethodResult <bool> result = Dac.TestDatabaseConnection(DatabaseFileLocationTextBox.Text); if (result.IsSuccessful) { MessageBox.Show("Database Connection Ok :-)"); } else { MessageBox.Show("Database Connection Error :-(" + Environment.NewLine + result.Exception.ToString()); } }
public void Foo() { var dac = new Dac <int>(); // build your graph var newDac = dac.Build(m => { m.AddEdge(1); var node = m.CreateChildNode(); node.AddEdge(2); //etc. }); // now do what ever you want, IDac<T> does not have modification methods newDac.DoStuff(); }
private void DeleteAllTweetsButton_Click(object sender, EventArgs e) { if (this.userId == 0) { return; } if (MessageBox.Show("User all tweets will be deleted." + Environment.NewLine + "Are You Sure ?", "Sure", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) { Dac dac = new Dac(); dac.ExecuteNonQuery("DELETE FROM Tweet WHERE CreatedByUserId=" + this.userId.ToString()); RefreshList(); } }
public string GetMethodDescName(ulong mdAddr) { uint nameLen = 0; this.Dac.GetMethodDescName(mdAddr, 0, null, out nameLen); if (nameLen == 0) { return(""); } StringBuilder name = new StringBuilder((int)nameLen); Dac.GetMethodDescName(mdAddr, nameLen, name, out nameLen); return(name.ToString()); }
static void Main(string[] args) { Console.WriteLine("ClrInspector at work..."); ProcessStartInfo psi = new ProcessStartInfo(@"C:\Tools\sscli\ClrAddin\ClrTestApp\bin\Debug\ClrTestApp.exe"); Process process = Process.Start(psi); Thread.Sleep(5000); Dac dac = new Dac(process); ThreadStackManager tsm = dac.ConstructThreadStacks(); Console.ReadLine(); process.Kill(); }
private void OkeyButton_Click(object sender, EventArgs e) { Dac dac = new Dac(); dac.DatabaseFileLocation = DatabaseFileLocationTextBox.Text; MethodResult <bool> result = Dac.TestDatabaseConnection(DatabaseFileLocationTextBox.Text); if (result.IsSuccessful) { dac.SaveDatabaseFileLocationToReqistry(); this.DialogResult = DialogResult.OK; } else { MessageBox.Show("Database Connection Error :-(" + Environment.NewLine + result.Exception.ToString()); } }
private void OkeyButton_Click(object sender, EventArgs e) { Dictionary <string, object> columns = new Dictionary <string, object>(); columns["UserName"] = UserNameTextBox.Text; columns["Name"] = NameTextBox.Text; columns["Description"] = DescriptionTextBox.Text; columns["FriendsCount"] = Convert.ToInt32(FollowingCountTextBox.Text); columns["FollowersCount"] = Convert.ToInt32(FollowersCountTextBox.Text); columns["Language"] = LanguageTextBox.Text; columns["Location"] = LocationTextBox.Text; columns["Url"] = WebSiteTextBox.Text; columns["Protected"] = ProtectedCheckBox.Checked; columns["ProfileImageUrl400x400"] = ProfileImagePictureBox.ImageLocation; columns["UserCategoryId"] = GetComboBoxSelected <long>(UserCategoryComboBox); Dac dac = new Dac(); MethodResult result = new MethodResult(); if (this.showMode == ShowMode.Edit) { result = dac.Update("User", "Id", Convert.ToInt64(UserIdTextBox.Text), columns); } else if (this.showMode == ShowMode.Add) { columns["Id"] = Convert.ToInt64(UserIdTextBox.Text); result = dac.Insert("User", columns); } else if (this.showMode == ShowMode.Delete) { columns["Id"] = Convert.ToInt64(UserIdTextBox.Text); result = dac.Delete("User", "Id", Convert.ToInt64(UserIdTextBox.Text)); } if (result.IsSuccessful) { this.DialogResult = DialogResult.OK; } else { MessageBox.Show("Save Error :-(" + Environment.NewLine + result.Exception.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void LoadTableColumns() { if (tabControlGeneration.SelectedTab != tabPageECG) { return; } DataTable oDt1 = Dac.GetTableColumns(SchemaName, TableName); DataTable oDt2 = new DataTable(); DataTable oDt3 = new DataTable(); oDt2 = oDt1.Copy(); oDt3 = oDt1.Copy(); if (oDt1.Rows.Count > 1) { comboBoxValueField.DataSource = oDt1; comboBoxValueField.DisplayMember = "ColumnName"; comboBoxValueField.ValueMember = "ColumnId"; comboBoxValueField.SelectedIndex = 0; comboBoxTextField.DataSource = oDt2; comboBoxTextField.DisplayMember = "ColumnName"; comboBoxTextField.ValueMember = "ColumnId"; comboBoxTextField.SelectedIndex = 1; comboBoxDescription.DataSource = oDt3; comboBoxDescription.DisplayMember = "ColumnName"; comboBoxDescription.ValueMember = "ColumnId"; int selIdx = 1; if (oDt3.Rows.Count > 2) { selIdx = 2; } comboBoxDescription.SelectedIndex = selIdx; } else { MessageBox.Show(Message.TableIsEmpty, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public void RefreshList() { if (this.userId == 0) { return; } Dac dac = new Dac(); MethodResult <DataTable> result = dac.ExecuteDataTable(" SELECT CreatedAt, Text, RetweetCount, FavoriteCount, IsRetweet FROM Tweet WHERE CreatedByUserId=" + this.userId.ToString()); if (result.IsSuccessful) { MainDataGridView.DataSource = result.Result; } else { MessageBox.Show("List Error :-(" + Environment.NewLine + result.Exception.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void DownloadButton_Click(object sender, EventArgs e) { Dac dac = new Dac(); DataTable userDataTable = dac.ExecuteDataTable("SELECT * FROM User").Result; decimal progress = 0; foreach (DataRow dr in userDataTable.Rows) { IUser user = TwitterEngine.User.FindUserFromUserName((string)dr["UserName"]).Result; if (user == null) { continue; } progress++; ProgressbarDescriptionLabel.Text = user.Name; ProgressBar.Value = (int)((progress / userDataTable.Rows.Count) * 100); MethodResult <int> result = DbHelper.SaveTweetList(user.GetUserTimeline((int)TweetCountNumericUpDown.Value).ToList <ITweet>()); if (result.IsSuccessful) { //ProgressbarDescriptionLabel.Text = user.Name + " : " + result.Result.ToString() + " Tweets Saved :-)"; ResultsTextBox.Text += Environment.NewLine + user.Name + " : " + result.Result.ToString() + " Tweets Saved :-)"; //MessageBox.Show(user.Name + " : " + result.Result.ToString() + " Tweets Saved :-)", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { ProgressbarDescriptionLabel.Text = user.Name + " : " + "Save Error :-("; ResultsTextBox.Text += Environment.NewLine + user.Name + " : " + "Save Error :-("; ProgressBar.Value = 0; MessageBox.Show(user.Name + " : " + "Save Error :-(" + Environment.NewLine + result.Exception.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } ProgressbarDescriptionLabel.Text = "Finished"; ResultsTextBox.Text += Environment.NewLine + "Finished"; ProgressBar.Value = 100; }
/// <summary> /// Saves the customer properties back to the database. /// </summary> public override bool SaveItem() { bool success = false; // If the entity state is added, need to get the CustomerId back. bool isOutput = false; string spName = "CustomerUpdate"; if (EntityState == EntityStateType.Added) { isOutput = true; spName = "CustomerInsert"; } // Pass the properties back to the DAC // This would not be needed if the base class had code to use Reflection to build // the parameters from the object properties. int retVal = Dac.ExecuteNonQuery(spName, Dac.Parameter("CustomerId", CustomerId, isOutput), Dac.Parameter("LastName", LastName), Dac.Parameter("FirstName", FirstName), Dac.Parameter("EmailAddress", EmailAddress), Dac.Parameter("CustomerType", CustomerType)); // If it was an add, update the product ID if (EntityState == EntityStateType.Added) { CustomerId = retVal; } // Reset the entity's state this.SetEntityState(EntityStateType.Unchanged); // Assume success success = true; return(success); }
private void ProcessBreakMode() { try { Process2 process = (Process2)r_dte.Debugger.DebuggedProcesses.Item(1); Dictionary <int, String> threadNames = new Dictionary <int, string>(); Threads threads = process.Threads; int count = threads.Count; for (int i = 1; i <= count; ++i) { Thread thread = threads.Item(i); int id = thread.ID; String name = thread.Name; threadNames.Add(id, name); } int procid = process.ProcessID; System.Diagnostics.Process proc = System.Diagnostics.Process.GetProcessById(procid); using (Dac dac = new Dac(proc)) { ThreadStackManager man = dac.ConstructThreadStacks(); VisualStudioProcess vsProc = new VisualStudioProcess(process); r_myControl.Refresh(man, vsProc, threadNames); } } catch (ExpiredException ex) { r_myControl.Refresh(ex); } catch (Exception ex) { r_myControl.Refresh(ex); } }
private void SetUIFromUserId(decimal userId) { if (userId == 0) { return; } Dac dac = new Dac(); IDictionary <string, object> values = dac.Select("User", "Id", userId).Result; UserNameTextBox.Text = values["UserName"].ToString(); UserIdTextBox.Text = values["Id"].ToString(); NameTextBox.Text = values["Name"].ToString(); DescriptionTextBox.Text = values["Description"].ToString(); FollowingCountTextBox.Text = values["FriendsCount"].ToString(); FollowersCountTextBox.Text = values["FollowersCount"].ToString(); LanguageTextBox.Text = values["Language"].ToString(); LocationTextBox.Text = values["Location"].ToString(); WebSiteTextBox.Text = values["Url"].ToString(); ProtectedCheckBox.Checked = values["Protected"].ToString() == "1"; ProfileImagePictureBox.ImageLocation = values["ProfileImageUrl400x400"].ToString(); SetComboBoxSelected(UserCategoryComboBox, values["UserCategoryId"]); }
private void ProcessBreakMode() { try { Process2 process = (Process2)r_dte.Debugger.DebuggedProcesses.Item(1); Dictionary<int, String> threadNames = new Dictionary<int, string>(); Threads threads = process.Threads; int count = threads.Count; for (int i = 1; i <= count; ++i) { Thread thread = threads.Item(i); int id = thread.ID; String name = thread.Name; threadNames.Add(id, name); } int procid = process.ProcessID; System.Diagnostics.Process proc = System.Diagnostics.Process.GetProcessById(procid); using (Dac dac = new Dac(proc)) { ThreadStackManager man = dac.ConstructThreadStacks(); VisualStudioProcess vsProc = new VisualStudioProcess(process); r_myControl.Refresh(man, vsProc, threadNames); } } catch (ExpiredException ex) { r_myControl.Refresh(ex); } catch (Exception ex) { r_myControl.Refresh(ex); } }
public static MethodResult <bool> SaveTweet(ITweet tweet) { MethodResult <bool> result = new MethodResult <bool>(); /* * CREATE TABLE `Tweet` ( * `TweetId` NUMERIC NOT NULL UNIQUE, * `FullText` TEXT NOT NULL, * `Text` TEXT NOT NULL, * `CreatedByUserId` INTEGER NOT NULL, * `RetweetCount` INTEGER, * `FavoriteCount` INTEGER, * `Language` TEXT, * `CreatedAt` TEXT, * `Source` TEXT, * `IsRetweet` INTEGER, * `RetweetedTweetId` NUMERIC, * PRIMARY KEY(`TweetId`) * ); * * CREATE TABLE `TweetHashtag` ( * `TweetId` NUMERIC, * `Hashtag` TEXT * ); * * * CREATE TABLE `TweetMedia` ( * `TweetId` NUMERIC, * `Id` NUMERIC, * `Url` TEXT, * `MediaType` TEXT * ); * * CREATE TABLE `TweetMention` ( * `TweetId` NUMERIC NOT NULL, * `UserId` NUMERIC, * `Name` TEXT, * `ScreenName` TEXT * ); * * CREATE TABLE `TweetUrl` ( * `TweetId` NUMERIC, * `Url` TEXT * ); */ Dictionary <string, object> columns = new Dictionary <string, object>(); columns["FullText"] = tweet.FullText; columns["Text"] = tweet.Text; columns["CreatedByUserId"] = tweet.CreatedBy.Id; columns["CreatedAt"] = tweet.CreatedAt; columns["RetweetCount"] = tweet.RetweetCount; columns["FavoriteCount"] = tweet.FavoriteCount; columns["Language"] = tweet.Language.ToString(); columns["Source"] = tweet.Source; columns["IsRetweet"] = tweet.IsRetweet; columns["RetweetedTweetId"] = (tweet.IsRetweet ? tweet.RetweetedTweet.Id : 0); MethodResult <bool> existsResult = IsTweetSaved(tweet); if (!existsResult.IsSuccessful) { result.Exception = existsResult.Exception; result.IsSuccessful = false; return(result); } Dac dac = new Dac(); if (!existsResult.Result) { columns["TweetId"] = tweet.Id; MethodResult resultTweet = dac.Insert("Tweet", columns); result.Result = true; if (!resultTweet.IsSuccessful) { throw resultTweet.Exception; } foreach (var hashtag in tweet.Hashtags) { Dictionary <string, object> hashtagColumns = new Dictionary <string, object>(); hashtagColumns.Add("TweetId", tweet.Id); hashtagColumns.Add("Hashtag", hashtag.Text); MethodResult resultHashtag = dac.Insert("TweetHashtag", hashtagColumns); if (!resultHashtag.IsSuccessful) { result.Exception = resultHashtag.Exception; result.IsSuccessful = false; return(result); } } foreach (var media in tweet.Media) { Dictionary <string, object> mediaColumns = new Dictionary <string, object>(); mediaColumns.Add("TweetId", tweet.Id); mediaColumns.Add("Id", media.Id); mediaColumns.Add("Url", media.MediaURL); mediaColumns.Add("MediaType", media.MediaType); MethodResult resulMedia = dac.Insert("TweetMedia", mediaColumns); if (!resulMedia.IsSuccessful) { result.Exception = resulMedia.Exception; result.IsSuccessful = false; return(result); } } foreach (var mention in tweet.UserMentions) { Dictionary <string, object> mentionColumns = new Dictionary <string, object>(); mentionColumns.Add("TweetId", tweet.Id); mentionColumns.Add("UserId", mention.Id); mentionColumns.Add("Name", mention.Name); mentionColumns.Add("ScreenName", mention.ScreenName); MethodResult resulMention = dac.Insert("TweetMention", mentionColumns); if (!resulMention.IsSuccessful) { result.Exception = resulMention.Exception; result.IsSuccessful = false; return(result); } } foreach (var url in tweet.Urls) { Dictionary <string, object> urlColumns = new Dictionary <string, object>(); urlColumns.Add("TweetId", tweet.Id); urlColumns.Add("Url", url.URL); MethodResult resultUrl = dac.Insert("TweetUrl", urlColumns); if (!resultUrl.IsSuccessful) { result.Exception = resultUrl.Exception; result.IsSuccessful = false; return(result); } } } result.IsSuccessful = true; return(result); }
private string GenerateCode(string pNameSpace, string pClassName, string pEnumNameField, string pEnumValueField, string pEnumDescriptionField) { string sql = string.Format(@"SELECT * FROM {0}", TableFullName); if (checkBoxUseDbScript.Checked) { sql = textBoxDbScript.Text; } DataTable oDt = Dac.GetRecords(sql); if (oDt.Rows.Count < 1) { MessageBox.Show(Message.NoRecordsInTable, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return(string.Empty); } string enumList = string.Empty; string propertyList = string.Empty; string clmnTypeName = GetColumnTypeName(pEnumValueField); if (clmnTypeName == string.Empty) { MessageBox.Show(Message.NoColumnTypeName, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return(string.Empty); } string type = DataTypes.GetCSharpDataType(DatabaseType, clmnTypeName); if (!checkBoxCreateOnlyConstants.Checked) { foreach (DataRow row in oDt.Rows) { string itemName = CreateEnumName(row[pEnumNameField].ToString()); string itemvalue = row[pEnumValueField].ToString(); string itemDesc = row[pEnumDescriptionField].ToString(); if (clmnTypeName.IndexOf("int") == -1) { MessageBox.Show(Message.ColumnTypeShouldBeNumeric, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return(string.Empty); } if (checkBoxEnumWithDescription.Checked) { enumList = string.Join("", enumList, string.Format("[Description('{0}')] \r\n ||{1} = {2} , \r\n", itemDesc, itemName, itemvalue), (char)9, (char)9); } else { enumList = string.Join("", enumList, string.Format("{0} = {1} , \r\n", itemName, itemvalue), (char)9, (char)9); } propertyList = string.Join("", propertyList, string.Format("public const {0} {1} = {2};", type, itemName, itemvalue), "\r\n", (char)9, (char)9); } enumList = enumList.Substring(0, enumList.Length - 5); //5: next comma + \r + \n + double (char)9 (,rntt) propertyList = string.Join("", "||", propertyList); } else { foreach (DataRow row in oDt.Rows) { string name = CreateEnumName(row[pEnumNameField].ToString()); string value = row[pEnumValueField].ToString(); if (type == "string") { value = string.Join("", (char)34, value, (char)34); } enumList = string.Join("", enumList, "public const ", type, " ", name, " = ", value, ";", "\r\n", (char)9, (char)9); } } return(PrepareCodeByTemplate(pNameSpace, pClassName, pEnumNameField, propertyList, enumList)); }