private void LoadValuesDebitAndCredit() { GenericPropertyFinder <IDbObject> property = new GenericPropertyFinder <IDbObject>(); IEnumerable <List <string> > obj = property.PrintTModelPropertyAndValue(_obj); var iznosi = new Dictionary <string, string>(); for (int i = 0; i < obj.First().Count; i++) { iznosi.Add(obj.First()[i].ToString(), obj.ElementAt(1)[i].ToString()); } foreach (DataRow row in _dt.Rows) { ExtractValues(iznosi, row); } //Remove rows with both sides 0,00 for (int i = 0; i < _dt.Rows.Count; i++) { if (string.Equals(_dt.Rows[i][4].ToString(), "0,00") && string.Equals(_dt.Rows[i][5].ToString(), "0,00")) { _dt.Rows.RemoveAt(i); i--; } } }
private void PopulateComboBoxStupac(IDbObject knjigaVrsta) { GenericPropertyFinder <IDbObject> property = new GenericPropertyFinder <IDbObject>(); IEnumerable <List <string> > obj = property.PrintTModelPropertyAndValue(knjigaVrsta); comboBoxStupac.DataSource = obj.ElementAt(0); }
public static bool AddByXML(ProductModel p, string xmlFilename) { XDocument xdoc = XDocument.Load(xmlFilename); if (p.ProductId <= 0) { p.ProductId = xdoc.Root.Elements().Count() + 1; } p.Guid = Guid.NewGuid(); GenericPropertyFinder <ProductModel> objGenericPropertyFinder = new GenericPropertyFinder <ProductModel>(); objGenericPropertyFinder.PrintTModelPropertyAndValue(p); var lstDic = objGenericPropertyFinder.ReturTModelPropertyAndValue(p); XElement ele = new XElement("ProductModel", null); foreach (var item in lstDic) { var valueOf = (from x in lstDic where x.Key.Contains(item.Key) select x.Value).FirstOrDefault(); ele.SetElementValue(item.Key, valueOf); //item.SetAttributeValue(item.Name, valueOf); } xdoc.Root.Add(ele); xdoc.Save(xmlFilename); return(true); }
public static void Main(string[] args) { //Creating Class Object class1 objClass1 = new class1 { prop1 = "value1", prop2 = "value2" }; //Passing Class Object to GenericPropertyFinder Class GenericPropertyFinder <class1> objGenericPropertyFinder = new GenericPropertyFinder <class1>(); objGenericPropertyFinder.PrintTModelPropertyAndValue(objClass1); Console.ReadLine(); }
/// <summary> /// Updates row in table. /// </summary> /// <param name="dbObject">Table name based on type name of object.</param> /// <returns></returns> public bool UpdateData(IDbObject dbObject, string condition = null) { GenericPropertyFinder <IDbObject> property = new GenericPropertyFinder <IDbObject>(); IEnumerable <List <string> > obj = property.PrintTModelPropertyAndValue(dbObject); string table = dbObject.GetType().ToString().Substring(dbObject.GetType().ToString().LastIndexOf('.') + 1); string query = new DbQueryBuilder(obj, table, condition).BuildQuery(QueryType.Update); if (condition != null) { if (query.EndsWith(';')) { query = query[0..^ 1];
/// <summary> /// Insert data in database. Name of table based on argument type. /// </summary> /// <param name="dbObject">Table name based on type name of object.</param> /// <returns>Boolean, True if operation successful</returns> public bool InsertData(IDbObject dbObject) { GenericPropertyFinder <IDbObject> property = new GenericPropertyFinder <IDbObject>(); IEnumerable <List <string> > obj = property.PrintTModelPropertyAndValue(dbObject); GetTableName(dbObject); string query = new DbQueryBuilder(obj, _table).BuildQuery(QueryType.Insert); try { using SqlConnection conn = new SqlConnection(ConnHelper.ConnStr(connection_name)); using SqlCommand command = new SqlCommand(query, conn); conn.Open(); command.ExecuteNonQuery(); command.Dispose(); conn.Close(); return(true); } catch (SqlException e) { MessageBox.Show( $"Provjerite vezu sa bazom podataka.\n {e.Message}", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } catch (Exception e) { MessageBox.Show( $"Nepoznata greška kod brisanja podataka, kontaktirajte podršku.\n {e.Message}", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }
public static bool UpdateByXML(ProductModel p, string xmlFilename) { GenericPropertyFinder <ProductModel> objGenericPropertyFinder = new GenericPropertyFinder <ProductModel>(); objGenericPropertyFinder.PrintTModelPropertyAndValue(p); var lstDic = objGenericPropertyFinder.ReturTModelPropertyAndValue(p); XDocument xdoc = XDocument.Load(xmlFilename); var elements = xdoc.Element("ArrayOfProductModel").Elements(); var valueProdID = (from x in lstDic where x.Key.Contains("Guid") select x.Value).FirstOrDefault(); foreach (var child in elements) { var elmId = child.Element("Guid"); if (elmId.Value == valueProdID) { foreach (var item in child.Elements()) { var valueOf = (from x in lstDic where x.Key.Contains(item.Name.ToString()) select x.Value).FirstOrDefault(); if (valueOf != null) { item.SetValue(valueOf); } } } else { continue; } } xdoc.Save(xmlFilename); return(true); }
private static void Main(string[] args) { int result = 0; List <FlexClientProfile> flex = new List <FlexClientProfile>() { }; string name = flex.Where(x => x.Name == "abcd1").Select(x => x.Name).FirstOrDefault(); do { var machineStore = new X509Store(StoreName.My, StoreLocation.LocalMachine); machineStore.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadOnly); var machineCerts = machineStore.Certificates.Find(X509FindType.FindBySubjectDistinguishedName, "CN=Desigo CC ClientCer", false); var cntMachineCerts = machineCerts.Count; foreach (X509Certificate2 cert in machineCerts) { //we are only interested in certificates that have a private key assigned if (cert.HasPrivateKey) { // RSACng rsa =new RSACng(); } } User u = new User() { id = 1, userName = "******" }; var propertyInfo = u.GetType().GetProperty("userName", BindingFlags.NonPublic | BindingFlags.Instance); var propertyInfo1 = u.GetType().GetProperty("id", BindingFlags.NonPublic | BindingFlags.Instance); if (propertyInfo != null) { var b = propertyInfo.GetValue(u); var a1 = propertyInfo1.GetValue(u); GenericPropertyFinder <User> a = new GenericPropertyFinder <User>(); a.PrintTModelPropertyAndValue(u); if (propertyInfo != null) { var o = propertyInfo.GetValue(u, null); } } Console.Clear(); var listGroups = new List <string>(); string[] stringArray = { "text1", "text2", "text3", "text4" }; string value = "text6"; int pos = Array.IndexOf(stringArray, value); if (pos > -1) { // the array contains the string and the pos variable // will have its position in the array } int userInput = 0; //do //{ userInput = DisplayMenu(); switch (userInput) { case 1: LDAP ldap = new LDAP(); ldap.GetGroupsForCurrentUser(); break; case 2: listGroups = LDAPDirectoryEntry.GetGroupsForUser(); break; } //} while (userInput != 3); //listGroups = TokenGroups.GetGroupsForCurrentLoggedinUser(); //listGroups= NestedGroups.GetGroupsForCurrentLoggedinUser(); //listGroups = LDAPDirectoryEntry.GetGroupsForUser(); // //listGroups = GetGroupsForCurrentLoggedinUser(); //LDAP ldap = new LDAP(); //ldap.GetGroupsForCurrentUser(); //LdapHelper.GetGroupsUsingLDAP(); if (result == 2) { Console.WriteLine("\n"); } foreach (var listGroup in listGroups) { Console.WriteLine(listGroup); } result = Convert.ToInt32(Console.ReadLine()); } while (result != 3); //LdapHelper.GetLDAPConnection(); }
/// <summary> /// Gets table from database depending on recieved object. /// </summary> /// <param name="dbObject">Table name based on type name of object.</param> /// <param name="condition">Parameter after WHERE in SQL query. (Ex. Id=0), default null</param> /// <returns>DataTable based on condition</returns> public DataTable GetTable(IDbObject dbObject, string condition = null) { GenericPropertyFinder <IDbObject> property = new GenericPropertyFinder <IDbObject>(); IEnumerable <List <string> > obj = property.PrintTModelPropertyAndValue(dbObject); string table = dbObject.GetType().ToString()[(dbObject.GetType().ToString().LastIndexOf('.') + 1)..];