private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { //Make sure the clicked cell isn't the header. if (e.RowIndex == -1 || e.ColumnIndex == -1) { return; } var datagridview = sender as DataGridView; AnalogSignal analogSignal = (AnalogSignal)datagridview.CurrentRow.DataBoundItem; // Check to make sure the cell clicked is the cell containing the combobox if (datagridview.Columns[e.ColumnIndex] is DataGridViewComboBoxColumn) { datagridview.BeginEdit(true); ((ComboBox)datagridview.EditingControl).DroppedDown = true; } if (datagridview.Columns[e.ColumnIndex].Name == MemberInfoGetting.GetMemberName(() => new AnalogSignal().Address)) { AddressConfig ac = new AddressConfig(analogSignal); ac.StartPosition = FormStartPosition.Manual; ac.Location = new Point(this.Location.X + (this.Width - ac.Width) / 2, this.Location.Y + (this.Height - ac.Height) / 2); ac.Show(this); } }
/// <summary> /// Update list with combobox data /// </summary> private void updateGridData() { DataGridViewCell cell; AnalogSignal analogSignal; foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.DataBoundItem == null) { break; } analogSignal = (AnalogSignal)row.DataBoundItem; //Fix area 1 cell = row.Cells[MemberInfoGetting.GetMemberName(() => new AnalogSignal().Area1)]; // http://stackoverflow.com/questions/1175645/find-an-item-in-list-by-linq analogSignal.Area1 = factory.GetAreas(null).SingleOrDefault(area => String.Equals(area.GUID, cell.Value.ToString(), StringComparison.OrdinalIgnoreCase)); //Fix area 2 cell = row.Cells[MemberInfoGetting.GetMemberName(() => new AnalogSignal().Area2)]; analogSignal.Area2 = factory.GetAreas(analogSignal.Area1).SingleOrDefault(area => String.Equals(area.GUID, cell.Value.ToString(), StringComparison.OrdinalIgnoreCase)); //Fix EGU cell = row.Cells[MemberInfoGetting.GetMemberName(() => new AnalogSignal().EGU)]; analogSignal.EGU = "" + cell.Value; } project.Plant.Name = txt_Plant.Text; project.Plant.Case = txt_Case.Text; }
private void setupCustomGridData() { AnalogSignal current; foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.DataBoundItem == null) { break; } current = (AnalogSignal)row.DataBoundItem; if (current.Area1 != null) { row.Cells[MemberInfoGetting.GetMemberName(() => new AnalogSignal().Area1)].Value = current.Area1.GUID; } if (current.Area2 != null) { row.Cells[MemberInfoGetting.GetMemberName(() => new AnalogSignal().Area2)].Value = current.Area2.GUID; } if (current.EGU != null) { row.Cells[MemberInfoGetting.GetMemberName(() => new AnalogSignal().EGU)].Value = current.EGU; } } }
public GatewayServer(string ID, string name) : base(ID, name) { JsConfig.AssumeUtc = true; activeTrips = new ActiveTrips(redisClient, ID + ":" + MemberInfoGetting.GetMemberName(() => activeTrips)); partnerAccounts = new RedisDictionary <string, PartnerAccount>(redisClient, ID + ":" + MemberInfoGetting.GetMemberName(() => partnerAccounts)); clientIdByAccessToken = new RedisDictionary <string, string>(redisClient, ID + ":" + MemberInfoGetting.GetMemberName(() => clientIdByAccessToken)); }
public override string ToString() { return(string.Format(MemberInfoGetting.GetMemberName(() => Address) + ": {0}, " + MemberInfoGetting.GetMemberName(() => PostCode) + ": {1}, " + MemberInfoGetting.GetMemberName(() => City) + ": {2}, " + MemberInfoGetting.GetMemberName(() => CompanyName) + ": {3}, " + MemberInfoGetting.GetMemberName(() => Position) + ": {4}, " + MemberInfoGetting.GetMemberName(() => Income) + ": {5}.", Address, PostCode, City, CompanyName, Position, Income)); }
public Product(string name, Color color, Size size) { if (name == null) { throw new ArgumentNullException(paramName: MemberInfoGetting.GetMemberName(() => name)); //throw new ArgumentNullException (paramName: nameof(name); =>After C# 6.0 } m_name = name; m_color = color; m_size = size; }
public MultiFunctionMachine(IPrinter printer, IScanner scanner) { if (printer == null) { throw new ArgumentNullException(paramName: MemberInfoGetting.GetMemberName(() => printer)); } if (scanner == null) { throw new ArgumentNullException(paramName: MemberInfoGetting.GetMemberName(() => scanner)); } this.printer = printer; this.scanner = scanner; }
public GatewayWithStats(string ID, string name) : base(ID, name) { JsConfig.AssumeUtc = true; redisClient = (RedisClient)redis.GetClient(); exceptions = new RedisStat(redisClient, ID + ":" + MemberInfoGetting.GetMemberName(() => exceptions)); rejects = new RedisStat(redisClient, ID + ":" + MemberInfoGetting.GetMemberName(() => rejects)); requests = new RedisStat(redisClient, ID + ":" + MemberInfoGetting.GetMemberName(() => requests)); cancels = new RedisStat(redisClient, ID + ":" + MemberInfoGetting.GetMemberName(() => cancels)); fare = new RedisStat(redisClient, ID + ":" + MemberInfoGetting.GetMemberName(() => fare)); completes = new RedisStat(redisClient, ID + ":" + MemberInfoGetting.GetMemberName(() => completes)); distance = new RedisStat(redisClient, ID + ":" + MemberInfoGetting.GetMemberName(() => distance)); }
public virtual async Task SendMessageByUserNameTest() { UserNameToSendMessage = ConfigurationManager.AppSettings[MemberInfoGetting.GetMemberName(() => UserNameToSendMessage)]; if (string.IsNullOrWhiteSpace(UserNameToSendMessage)) { throw new Exception("Please fill the" + MemberInfoGetting.GetMemberName(() => UserNameToSendMessage) + " setting in app.config file first"); } var client = NewClient(); await client.ConnectAsync(); var result = await client.SearchUserAsync(UserNameToSendMessage); var user = result.Users .Where(x => x.GetType() == typeof(TLUser)) .OfType <TLUser>() .FirstOrDefault(x => x.Username == UserNameToSendMessage.TrimStart('@')); if (user == null) { var contacts = await client.GetContactsAsync(); user = contacts.Users .Where(x => x.GetType() == typeof(TLUser)) .OfType <TLUser>() .FirstOrDefault(x => x.Username == UserNameToSendMessage.TrimStart('@')); } if (user == null) { throw new System.Exception("Username was not found: " + UserNameToSendMessage); } await client.SendTypingAsync(new TLInputPeerUser() { UserId = user.Id }); Thread.Sleep(3000); await client.SendMessageAsync(new TLInputPeerUser() { UserId = user.Id }, "TEST"); }
public AndSpecification(ISpecification <T> first, ISpecification <T> second) { if (first == null) { throw new ArgumentNullException(paramName: MemberInfoGetting.GetMemberName(() => first)); } if (second == null) { throw new ArgumentNullException(paramName: MemberInfoGetting.GetMemberName(() => second)); } this.first = first; this.second = second; //C# 7.0 can write in this way //this.first = first ?? throw new ArgumentNullException(paramName: nameof(first)); }
public virtual async Task SendMessageTest() { NumberToSendMessage = ConfigurationManager.AppSettings[MemberInfoGetting.GetMemberName(() => NumberToSendMessage)]; if (string.IsNullOrWhiteSpace(NumberToSendMessage)) { throw new Exception("Please fill the" + MemberInfoGetting.GetMemberName(() => NumberToSendMessage) + " setting in app.config file first"); } // this is because the contacts in the address come without the "+" prefix var normalizedNumber = NumberToSendMessage.StartsWith("+") ? NumberToSendMessage.Substring(1, NumberToSendMessage.Length - 1) : NumberToSendMessage; var client = NewClient(); await client.ConnectAsync(); var result = await client.GetContactsAsync(); var user = result.Users .OfType <TLUser>() .FirstOrDefault(x => x.Phone == normalizedNumber); if (user == null) { throw new System.Exception("Number was not found in Contacts List of user: "******"TEST"); }
public string Add() { string s = MemberInfoGetting.GetMemberName(() => this); return(s); }
public void TestMethod(string param1, string param2) { string nameOfParam1 = MemberInfoGetting.GetMemberName(() => param1); }
public RedisStat(RedisClient redis, string id) { allTime = new RedisObject <double>(redis, id + ":" + MemberInfoGetting.GetMemberName(() => allTime)); last24Hrs = new RedisExpiryCounter(redis, id + ":" + MemberInfoGetting.GetMemberName(() => last24Hrs), new TimeSpan(24, 0, 0)); lastHour = new RedisExpiryCounter(redis, id + ":" + MemberInfoGetting.GetMemberName(() => lastHour), new TimeSpan(1, 0, 0)); }
private void InitializePersistantDataObjects() { partners = new Dictionary <string, Gateway>(); var redisClient = (RedisClient)redis.GetClient(); originatingPartnerByTrip = new RedisDictionary <string, string>(redisClient, ID + ":" + MemberInfoGetting.GetMemberName(() => originatingPartnerByTrip)); originatingPartnerByTrip.Clear(); servicingPartnerByTrip = new RedisDictionary <string, string>(redisClient, ID + "." + MemberInfoGetting.GetMemberName(() => servicingPartnerByTrip)); servicingPartnerByTrip.Clear(); partnerCoverage = new RedisDictionary <string, List <Zone> >(redisClient, ID + "." + MemberInfoGetting.GetMemberName(() => partnerCoverage)); partnerCoverage.Clear(); partnerAccounts.Clear(); clientIdByAccessToken.Clear(); }
public static void init() { ApiHash = ConfigurationManager.AppSettings[MemberInfoGetting.GetMemberName(() => ApiHash)]; ApiId = ConfigurationManager.AppSettings[MemberInfoGetting.GetMemberName(() => ApiId)]; }
public virtual async Task addMemmberTest() { NumberToSendMessage = ConfigurationManager.AppSettings[MemberInfoGetting.GetMemberName(() => NumberToSendMessage)]; if (string.IsNullOrWhiteSpace(NumberToSendMessage)) { throw new Exception("Please fill the" + MemberInfoGetting.GetMemberName(() => NumberToSendMessage) + " setting in app.config file first"); } // this is because the contacts in the address come without the "+" prefix var normalizedNumber = NumberToSendMessage.StartsWith("+") ? NumberToSendMessage.Substring(1, NumberToSendMessage.Length - 1) : NumberToSendMessage; var client = NewClient(); await client.ConnectAsync(); var result = await client.GetContactsAsync(); var user = result.Users .OfType <TLUser>() .FirstOrDefault(x => x.Phone == normalizedNumber); if (user == null) { throw new System.Exception("Number was not found in Contacts List of user: "******"khune"); int b = 5; TLInputUser u = new TLInputUser() { UserId = user.Id, AccessHash = (long)user.AccessHash }; int a = 5; await client.ConnectAsync(); //var req = new TLRequestAddChatUser() //{ // ChatId = chat.Id, // UserId = u, // FwdLimit = 100 //}; TLVector <TLAbsInputUser> u2 = new TLVector <TLAbsInputUser>(); TLVector <TLAbsInputChannel> c2 = new TLVector <TLAbsInputChannel>(); u2.Add(u); c2.Add(new TLInputChannel() { ChannelId = chat.Id, AccessHash = (long)chat.AccessHash }); var req2 = new TLRequestInviteToChannel() { //Channel = new TLInputChannel() { ChannelId = chat.Id }, Channel = c2[0], Users = u2 }; await client.ConnectAsync(); try { var update = await client.SendRequestAsync <TLUpdates>(req2); } catch (Exception e) { //MessageBox.Show(e.ToString()); } int a2 = 5; }
private void GatherTestConfiguration() { string appConfigMsgWarning = "{0} not configured in app.config! Some tests may fail."; ApiHash = ConfigurationManager.AppSettings[MemberInfoGetting.GetMemberName(() => ApiHash)]; if (string.IsNullOrEmpty(ApiHash)) { Debug.WriteLine(appConfigMsgWarning, MemberInfoGetting.GetMemberName(() => ApiHash)); } var apiId = ConfigurationManager.AppSettings[MemberInfoGetting.GetMemberName(() => ApiId)]; if (string.IsNullOrEmpty(apiId)) { Debug.WriteLine(appConfigMsgWarning, MemberInfoGetting.GetMemberName(() => ApiId)); } else { ApiId = int.Parse(apiId); } NumberToAuthenticate = ConfigurationManager.AppSettings[MemberInfoGetting.GetMemberName(() => NumberToAuthenticate)]; if (string.IsNullOrEmpty(NumberToAuthenticate)) { Debug.WriteLine(appConfigMsgWarning, MemberInfoGetting.GetMemberName(() => NumberToAuthenticate)); } CodeToAuthenticate = ConfigurationManager.AppSettings[MemberInfoGetting.GetMemberName(() => CodeToAuthenticate)]; if (string.IsNullOrEmpty(CodeToAuthenticate)) { Debug.WriteLine(appConfigMsgWarning, MemberInfoGetting.GetMemberName(() => CodeToAuthenticate)); } PasswordToAuthenticate = ConfigurationManager.AppSettings[MemberInfoGetting.GetMemberName(() => PasswordToAuthenticate)]; if (string.IsNullOrEmpty(PasswordToAuthenticate)) { Debug.WriteLine(appConfigMsgWarning, MemberInfoGetting.GetMemberName(() => PasswordToAuthenticate)); } NotRegisteredNumberToSignUp = ConfigurationManager.AppSettings[MemberInfoGetting.GetMemberName(() => NotRegisteredNumberToSignUp)]; if (string.IsNullOrEmpty(NotRegisteredNumberToSignUp)) { Debug.WriteLine(appConfigMsgWarning, MemberInfoGetting.GetMemberName(() => NotRegisteredNumberToSignUp)); } UserNameToSendMessage = ConfigurationManager.AppSettings[MemberInfoGetting.GetMemberName(() => UserNameToSendMessage)]; if (string.IsNullOrEmpty(UserNameToSendMessage)) { Debug.WriteLine(appConfigMsgWarning, MemberInfoGetting.GetMemberName(() => UserNameToSendMessage)); } NumberToGetUserFull = ConfigurationManager.AppSettings[MemberInfoGetting.GetMemberName(() => NumberToGetUserFull)]; if (string.IsNullOrEmpty(NumberToGetUserFull)) { Debug.WriteLine(appConfigMsgWarning, MemberInfoGetting.GetMemberName(() => NumberToGetUserFull)); } NumberToAddToChat = ConfigurationManager.AppSettings[MemberInfoGetting.GetMemberName(() => NumberToAddToChat)]; if (string.IsNullOrEmpty(NumberToAddToChat)) { Debug.WriteLine(appConfigMsgWarning, MemberInfoGetting.GetMemberName(() => NumberToAddToChat)); } }
private static void Compare(List <string> lines1, List <string> lines2) { var filename1 = MemberInfoGetting.GetMemberName(() => lines1); var filename2 = MemberInfoGetting.GetMemberName(() => lines2); if (lines1.Count != lines2.Count) { Log($"WARNING: files don't have the same length: {filename1}: {lines1.Count}. {filename2}: {lines2.Count}"); } for (int i = 0; i < lines1.Count; i++) { if (i > lines2.Count - 1) { return; } var line1 = ParseLine(lines1[i]); var line2 = ParseLine(lines2[i]); var template = $"{lines1[i]},{lines2[i]},{(i * 4):X8}"; var template2 = ""; // Check if both values aren't equal to 0 if (lines1[i] == lines2[i] && lines2[i] == "00000000") { template2 = "unknown"; goto end; } if (lines1[i] == lines2[i]) { template2 = "bytes"; goto end; } if (line1[0] == line2[1] && line1[1] == line2[0] && line1[2] == line2[3] && line1[3] == line2[2]) { template2 = "short"; goto end; } if (line1[0] == line2[3] && line1[1] == line2[2] && line1[2] == line2[1] && line1[3] == line2[0]) { template2 = "int"; goto end; } if (lines1[i] != lines2[i]) { template2 = "different"; goto end; } end: Log($"{template},{template2}"); } }
// Configures columns for the DataGridView control. private void AddColumns() { //https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.autogeneratecolumns%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396 //Initial settings bindingSource1.Clear(); bindingSource1.DataSource = typeof(AnalogSignal); if (!project.AnalogSignals.IsNullOrEmpty()) { bindingSource1.DataSource = project.AnalogSignals; } dataGridView1.AutoGenerateColumns = true; dataGridView1.DataSource = bindingSource1; DataGridViewColumn column; string fieldNameString; // Handle KKS column fieldNameString = MemberInfoGetting.GetMemberName(() => new AnalogSignal().KKS); if (dataGridView1.Columns.Contains(fieldNameString)) { column = dataGridView1.Columns[fieldNameString]; column.Name = fieldNameString; column.Visible = true; column.ReadOnly = true; column.Frozen = true; } // Handle Address column fieldNameString = MemberInfoGetting.GetMemberName(() => new AnalogSignal().Address); if (dataGridView1.Columns.Contains(fieldNameString)) { column = dataGridView1.Columns[fieldNameString]; column.Name = fieldNameString; column.Visible = true; column.ReadOnly = true; } // Handle Area1 column DataGridViewComboBoxColumn dg_cb_Area1 = new DataGridViewComboBoxColumn(); dg_cb_Area1.Name = MemberInfoGetting.GetMemberName(() => new AnalogSignal().Area1); dg_cb_Area1.HeaderText = "Område 1"; dg_cb_Area1.DisplayMember = "Description"; dg_cb_Area1.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; dg_cb_Area1.ValueMember = "GUID"; dg_cb_Area1.DataSource = factory.GetAreas(null); dataGridView1.Columns.Insert(3, dg_cb_Area1); //TODO: handle index // Handle Area2 column DataGridViewComboBoxColumn dg_cb_Area2 = new DataGridViewComboBoxColumn(); dg_cb_Area2.Name = MemberInfoGetting.GetMemberName(() => new AnalogSignal().Area2); dg_cb_Area2.HeaderText = "Område 2"; dg_cb_Area2.DisplayMember = "Description"; dg_cb_Area2.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; dg_cb_Area2.ValueMember = "GUID"; dg_cb_Area2.DataSource = factory.GetAreas(new Area("", "Fællesanlæg5")); dataGridView1.Columns.Insert(4, dg_cb_Area2); //TODO: handle index // Handle EGU column DataGridViewComboBoxColumn dg_cb_EGU = new DataGridViewComboBoxColumn(); dg_cb_EGU.Name = MemberInfoGetting.GetMemberName(() => new AnalogSignal().EGU); dg_cb_EGU.HeaderText = "Enhed"; dg_cb_EGU.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; dg_cb_EGU.ValueMember = null; //Returned value is full object dg_cb_EGU.DataSource = new Factory().GetEGU(); dataGridView1.Columns.Insert(5, dg_cb_EGU); //TODO: handle index /* * // Add a button column. * DataGridViewButtonColumn buttonColumn = new DataGridViewButtonColumn(); * buttonColumn.HeaderText = ""; * buttonColumn.Name = "Status Request"; * buttonColumn.Text = "Request Status"; * buttonColumn.UseColumnTextForButtonValue = true; * dataGridView1.Columns.Insert(1, buttonColumn); // n is index */ }
public static int OrderItemInsert(Consumer consumer, int order_id) { int result = 0; SqlCommand cmd = null; SqlConnection conn = new SqlConnection(_connStr); string queryStr = "INSERT INTO order_items(order_id, item_name, item_price, quantity, cleantype ) values (@order_id, @item_name, @item_price, @quantity, @cleantype)"; conn.Open(); SqlTransaction sqlTrans = conn.BeginTransaction(); if (!String.IsNullOrEmpty(consumer.Tee)) { cmd = new SqlCommand(queryStr, conn, sqlTrans); cmd.Parameters.AddWithValue("@order_id", order_id); cmd.Parameters.AddWithValue("@item_name", MemberInfoGetting.GetMemberName(() => consumer.Tee)); cmd.Parameters.AddWithValue("@item_price", Convert.ToDecimal("3")); cmd.Parameters.AddWithValue("@quantity", Convert.ToInt32(consumer.Tee)); cmd.Parameters.AddWithValue("@cleantype", "-"); cmd.ExecuteNonQuery(); } if (!String.IsNullOrEmpty(consumer.Shorts)) { cmd = new SqlCommand(queryStr, conn, sqlTrans); cmd.Parameters.AddWithValue("@order_id", order_id); cmd.Parameters.AddWithValue("@item_name", MemberInfoGetting.GetMemberName(() => consumer.Shorts)); cmd.Parameters.AddWithValue("@item_price", Convert.ToDecimal("4")); cmd.Parameters.AddWithValue("@quantity", Convert.ToInt32(consumer.Shorts)); cmd.Parameters.AddWithValue("@cleantype", "-"); cmd.ExecuteNonQuery(); } if (!String.IsNullOrEmpty(consumer.Jeans)) { cmd = new SqlCommand(queryStr, conn, sqlTrans); cmd.Parameters.AddWithValue("@order_id", order_id); cmd.Parameters.AddWithValue("@item_name", MemberInfoGetting.GetMemberName(() => consumer.Jeans)); cmd.Parameters.AddWithValue("@item_price", Convert.ToDecimal("4")); cmd.Parameters.AddWithValue("@quantity", Convert.ToInt32(consumer.Jeans)); cmd.Parameters.AddWithValue("@cleantype", "-"); cmd.ExecuteNonQuery(); } if (!String.IsNullOrEmpty(consumer.Jacket)) { cmd = new SqlCommand(queryStr, conn, sqlTrans); cmd.Parameters.AddWithValue("@order_id", order_id); cmd.Parameters.AddWithValue("@item_name", MemberInfoGetting.GetMemberName(() => consumer.Jacket)); cmd.Parameters.AddWithValue("@item_price", Convert.ToDecimal("5")); cmd.Parameters.AddWithValue("@quantity", Convert.ToInt32(consumer.Jacket)); cmd.Parameters.AddWithValue("@cleantype", "Dry Clean"); cmd.ExecuteNonQuery(); } if (!String.IsNullOrEmpty(consumer.Formal)) { cmd = new SqlCommand(queryStr, conn, sqlTrans); cmd.Parameters.AddWithValue("@order_id", order_id); cmd.Parameters.AddWithValue("@item_name", MemberInfoGetting.GetMemberName(() => consumer.Formal)); cmd.Parameters.AddWithValue("@item_price", Convert.ToDecimal("6")); cmd.Parameters.AddWithValue("@quantity", Convert.ToInt32(consumer.Formal)); cmd.Parameters.AddWithValue("@cleantype", "Iron"); cmd.ExecuteNonQuery(); } if (!String.IsNullOrEmpty(consumer.Bed)) { cmd = new SqlCommand(queryStr, conn, sqlTrans); cmd.Parameters.AddWithValue("@order_id", order_id); cmd.Parameters.AddWithValue("@item_name", MemberInfoGetting.GetMemberName(() => consumer.Bed)); cmd.Parameters.AddWithValue("@item_price", Convert.ToDecimal("5")); cmd.Parameters.AddWithValue("@quantity", Convert.ToInt32(consumer.Bed)); cmd.Parameters.AddWithValue("@cleantype", "-"); cmd.ExecuteNonQuery(); } if (!String.IsNullOrEmpty(consumer.Curtain)) { cmd = new SqlCommand(queryStr, conn, sqlTrans); cmd.Parameters.AddWithValue("@order_id", order_id); cmd.Parameters.AddWithValue("@item_name", MemberInfoGetting.GetMemberName(() => consumer.Curtain)); cmd.Parameters.AddWithValue("@item_price", Convert.ToDecimal("5")); cmd.Parameters.AddWithValue("@quantity", Convert.ToInt32(consumer.Curtain)); cmd.Parameters.AddWithValue("@cleantype", "-"); cmd.ExecuteNonQuery(); } sqlTrans.Commit(); conn.Close(); return(result); }