Exemple #1
0
 private void Initialize()
 {
     try
     {
         if (ComponentAttributes.Contains("MainWindowX") && ComponentAttributes.Contains("MainWindowY"))
         {
             this.Location = new Point(Int32.Parse((string)ComponentAttributes["MainWindowX"]),
                                       Int32.Parse((string)ComponentAttributes["MainWindowY"]));
         }
     }
     catch {}
     try
     {
         if (ComponentAttributes.Contains("MainWindowHeight") && ComponentAttributes.Contains("MainWindowWidth"))
         {
             this.Size = new Size(Int32.Parse((string)ComponentAttributes["MainWindowWidth"]),
                                  Int32.Parse((string)ComponentAttributes["MainWindowHeight"]));
         }
     }
     catch {}
     try
     {
         if (ComponentAttributes.Contains("MainWindowBackgroundColor"))
         {
             int rgb = Int32.Parse((string)ComponentAttributes["MainWindowBackgroundColor"]);
             BackColor = Color.FromArgb(
                 (rgb & 0xff0000) >> 16,              // red
                 (rgb & 0xff00) >> 8,                 // green
                 rgb & 0xff);                         // blue
         }
     }
     catch {}
 }
Exemple #2
0
        public override void LoadData(XmlNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            if (node.Name != GroupName)
            {
                throw new FormatException(String.Format("Expecting <{0}>", GroupName));
            }

            keys = new System.Collections.Specialized.ListDictionary();
            foreach (XmlNode n in node.ChildNodes)
            {
                string name = n.Attributes ["name"].Value;
                if (CheckIfAdd(name, n))
                {
                    string key = GetNodeKey(name, n);
                    if (keys.Contains(key))
                    {
                        if ((string)keys[key] != name)
                        {
                            throw new NotImplementedException("Attribute with same name but diffent value");
                        }
                    }
                    else
                    {
                        keys.Add(key, name);
                    }

                    LoadExtraData(key, n);
                }
            }
        }
        static void Main(string[] args)
        {
            // Creates and initializes a new ListDictionary.
            System.Collections.Specialized.ListDictionary listDictionary = new System.Collections.Specialized.ListDictionary();
            listDictionary.Add("Test1", "Test@123");
            listDictionary.Add("Admin", "Admin@123");
            listDictionary.Add("Temp", "Temp@123");
            listDictionary.Add("Demo", "Demo@123");
            listDictionary.Add("Test2", "Test2@123");
            listDictionary.Remove("Admin");
            if (listDictionary.Contains("Admin"))
            {
                Console.WriteLine("UserName already Esists");
            }
            else
            {
                listDictionary.Add("Admin", "Admin@123");
                Console.WriteLine("User added succesfully.");
            }

            // Get a collection of the keys.
            Console.WriteLine("UserName" + ": " + "Password");
            foreach (DictionaryEntry entry in listDictionary)
            {
                Console.WriteLine(entry.Key + ": " + entry.Value);
            }
            Console.ReadKey();
        }
Exemple #4
0
        private int JumpedSpace(int oldPosition, int newPosition)
        {
            int    spaceJumped = -1;
            string key         = string.Format("{0},{1}", oldPosition, newPosition);

            if (jumpedSpace.Contains(key))
            {
                spaceJumped = (int)jumpedSpace[key];
            }
            else
            {
                key = string.Format("{0},{1}", newPosition, oldPosition);
                if (jumpedSpace.Contains(key))
                {
                    spaceJumped = (int)jumpedSpace[key];
                }
            }
            return(spaceJumped);
        }
Exemple #5
0
        private void Load(System.Xml.XmlDocument BrowserFile)
        {
            Lookup        = new System.Collections.Specialized.ListDictionary();
            DefaultLookup = new System.Collections.Specialized.ListDictionary();
            RefNodes      = new List <Node>();
            System.Xml.XmlNode node;
            //I know this might allocate more nodes then needed but never less.
            Nodes = new Node[BrowserFile.DocumentElement.ChildNodes.Count];
            for (int a = 0; a <= BrowserFile.DocumentElement.ChildNodes.Count - 1; a++)
            {
                node = BrowserFile.DocumentElement.ChildNodes[a];

                if (node.NodeType == System.Xml.XmlNodeType.Comment)
                {
                    continue;
                }
                Nodes[a]          = new Node(node);
                Nodes[a].FileName = FileName;
                if (Nodes[a].NameType != NodeType.DefaultBrowser)
                {
                    //fxcop sugguested this was faster then
                    //Nodes[a].refID != string.Empty
                    if (Nodes[a].RefId.Length > 0)
                    {
                        RefNodes.Add(Nodes[a]);
                    }
                    else if (Lookup.Contains(Nodes[a].Id) == false)
                    {
                        Lookup.Add(Nodes[a].Id, a);
                    }
                    else
                    {
                        throw new nBrowser.Exception("Duplicate ID found \"" + Nodes[a].Id + "\"");
                    }
                }
                else
                {
                    //fxcop sugguested this was faster then
                    //Nodes[a].refID != string.Empty
                    if (Nodes[a].RefId.Length > 0)
                    {
                        RefNodes.Add(Nodes[a]);
                    }
                    else if (DefaultLookup.Contains(Nodes[a].Id) == false)
                    {
                        DefaultLookup.Add(Nodes[a].Id, a);
                    }
                    else
                    {
                        throw new nBrowser.Exception("Duplicate ID found \"" + Nodes[a].Id + "\"");
                    }
                }
            }
        }
Exemple #6
0
        public static System.Data.DataTable GetDataSource(System.Collections.Specialized.ListDictionary addressbook, bool specific, anmar.SharpWebMail.IEmailClient client)
        {
            if (!addressbook.Contains("connectionstring") ||
                !addressbook.Contains("searchstring"))
            {
                return(null);
            }
            System.String connectstring = addressbook["connectionstring"].ToString();
            System.String connectusername = null, connectpassword = null;
            if (addressbook.Contains("connectionusername") && addressbook.Contains("connectionpassword"))
            {
                connectusername = addressbook["connectionusername"].ToString();
                connectpassword = addressbook["connectionpassword"].ToString();
            }
            else if (client != null)
            {
                connectusername = client.UserName;
                connectpassword = client.Password;
            }

            System.String searchfilter;
            if (specific)
            {
                searchfilter = addressbook["searchstringrealname"].ToString();
            }
            else
            {
                searchfilter = addressbook["searchstring"].ToString();
            }
            if (client != null)
            {
                searchfilter = searchfilter.Replace("$USERNAME$", client.UserName);
            }
            else
            {
                searchfilter = searchfilter.Replace("$USERNAME$", System.String.Empty);
            }
            System.String namecolumn  = addressbook["namecolumn"].ToString();
            System.String mailcolumn  = addressbook["emailcolumn"].ToString();
            System.String ownercolumn = "owner";
            if (addressbook.Contains("ownercolumn"))
            {
                ownercolumn = addressbook["ownercolumn"].ToString();
            }
            if (addressbook["type"].Equals("ldap"))
            {
                return(GetDataSourceLDAP(addressbook["name"].ToString(), connectstring, connectusername, connectpassword, searchfilter, namecolumn, mailcolumn, ownercolumn));
            }
            else if (addressbook["type"].Equals("odbc"))
            {
                return(GetDataSourceODBC(addressbook["name"].ToString(), connectstring, connectusername, connectpassword, searchfilter, namecolumn, mailcolumn, ownercolumn));
            }
            else if (addressbook["type"].Equals("oledb"))
            {
                return(GetDataSourceOLEDB(addressbook["name"].ToString(), connectstring, connectusername, connectpassword, searchfilter, namecolumn, mailcolumn, ownercolumn));
            }
            else
            {
                return(null);
            }
        }
Exemple #7
0
        public static bool UpdateDataSource(System.Data.DataTable data, System.Collections.Specialized.ListDictionary addressbook, anmar.SharpWebMail.IEmailClient client)
        {
            bool error = false;

            if (data == null || addressbook == null || !addressbook.Contains("connectionstring") ||
                !addressbook.Contains("searchstring") || !addressbook.Contains("allowupdate") || !((bool)addressbook["allowupdate"]))
            {
                return(false);
            }
            System.String connectstring = addressbook["connectionstring"].ToString();
            System.String connectusername = null, connectpassword = null;
            if (addressbook.Contains("connectionusername") && addressbook.Contains("connectionpassword"))
            {
                connectusername = addressbook["connectionusername"].ToString();
                connectpassword = addressbook["connectionpassword"].ToString();
            }
            else if (client != null)
            {
                connectusername = client.UserName;
                connectpassword = client.Password;
            }

            System.String searchfilter = addressbook["searchstring"].ToString();
            if (client != null)
            {
                searchfilter = searchfilter.Replace("$USERNAME$", client.UserName);
            }
            else
            {
                searchfilter = searchfilter.Replace("$USERNAME$", System.String.Empty);
            }
            System.Data.Common.DbDataAdapter adapter = GetDataAdapter(addressbook["type"].ToString(), connectstring, connectusername, connectpassword, searchfilter);
            if (adapter != null)
            {
                try {
                    if (addressbook["type"].Equals("odbc"))
                    {
                        System.Data.Odbc.OdbcCommandBuilder builder = new System.Data.Odbc.OdbcCommandBuilder(adapter as System.Data.Odbc.OdbcDataAdapter);
                        adapter.Update(data);
                        builder = null;
                    }
                    else if (addressbook["type"].Equals("oledb"))
                    {
                        System.Data.OleDb.OleDbCommandBuilder builder = new System.Data.OleDb.OleDbCommandBuilder(adapter as System.Data.OleDb.OleDbDataAdapter);
                        adapter.Update(data);
                        builder = null;
                    }
                } catch (System.Exception e) {
                    if (log.IsErrorEnabled)
                    {
                        log.Error(System.String.Concat("Error updating address book [", addressbook["name"], "] for user [", client.UserName, "]"), e);
                    }
                    error = true;
                }
            }
            else
            {
                error = true;
            }
            adapter = null;
            return(!error);
        }
Exemple #8
0
		private void Load(System.Xml.XmlDocument BrowserFile)
		{
			Lookup = new System.Collections.Specialized.ListDictionary();
			DefaultLookup = new System.Collections.Specialized.ListDictionary();
			RefNodes = new List<Node>();
			System.Xml.XmlNode node;
			//I know this might allocate more nodes then needed but never less.
			Nodes = new Node[BrowserFile.DocumentElement.ChildNodes.Count];
			for (int a = 0;a <= BrowserFile.DocumentElement.ChildNodes.Count - 1;a++)
			{
				node = BrowserFile.DocumentElement.ChildNodes[a];

				if (node.NodeType == System.Xml.XmlNodeType.Comment)
				{
					continue;
				}
				Nodes[a] = new Node(node);
				Nodes[a].FileName = FileName;
				if (Nodes[a].NameType != NodeType.DefaultBrowser)
				{
					//fxcop sugguested this was faster then
					//Nodes[a].refID != string.Empty
					if (Nodes[a].RefId.Length > 0)
					{
						RefNodes.Add(Nodes[a]);
					}
					else if (Lookup.Contains(Nodes[a].Id) == false)
					{
						Lookup.Add(Nodes[a].Id, a);
					}
					else
					{
						throw new nBrowser.Exception("Duplicate ID found \"" + Nodes[a].Id + "\"");
					}
				}
				else
				{
					//fxcop sugguested this was faster then
					//Nodes[a].refID != string.Empty
					if (Nodes[a].RefId.Length > 0)
					{
						RefNodes.Add(Nodes[a]);
					}
					else if (DefaultLookup.Contains(Nodes[a].Id) == false)
					{
						DefaultLookup.Add(Nodes[a].Id, a);
					}
					else
					{
						throw new nBrowser.Exception("Duplicate ID found \"" + Nodes[a].Id + "\"");
					}
				}
			}
		}
        public override void LoadData(XmlNode node)
        {
            if (node == null)
                throw new ArgumentNullException ("node");

            if (node.Name != GroupName)
                throw new FormatException (String.Format ("Expecting <{0}>", GroupName));

            keys = new System.Collections.Specialized.ListDictionary ();
            foreach (XmlNode n in node.ChildNodes) {
                string name = n.Attributes ["name"].Value;
                if (CheckIfAdd (name, n)) {
                    string key = GetNodeKey (name, n);
                    if (keys.Contains (key)) {
                        if ((string) keys[key] != name)
                            throw new NotImplementedException ("Attribute with same name but diffent value");
                    } else {
                        keys.Add (key, name);
                    }

                    LoadExtraData (key, n);
                }
            }
        }
        private void ParseNode(System.Object parent, System.Object context, System.Xml.XmlNode node, System.Collections.Hashtable config, System.String prefix)
        {
            foreach (System.Xml.XmlNode item in node.ChildNodes)
            {
                if (item.NodeType.Equals(System.Xml.XmlNodeType.Element))
                {
                    System.String sectionname = System.String.Concat(prefix, "/", item.Name);;
                    switch (item.Name)
                    {
                    case "general":
                    case "login":
                    case "message":
                    case "inbox":
                        System.Configuration.SingleTagSectionHandler singlesection = new System.Configuration.SingleTagSectionHandler();
                        InitConfigSection(config, sectionname, singlesection.Create(parent, context, item) as System.Collections.Hashtable);
                        break;

                    case "read":
                    case "send":
                        if (item.HasChildNodes)
                        {
                            ParseNode(parent, context, item, config, sectionname);
                        }
                        break;

                    case "servers":
                        if (item.HasChildNodes)
                        {
                            config.Add(sectionname, ParseConfigServers(item.ChildNodes));
                        }
                        break;

                    case "addressbook":
                        if (!config.Contains(sectionname))
                        {
                            config.Add(sectionname, new System.Collections.SortedList());
                        }
                        System.Collections.SortedList addressbooks   = (System.Collections.SortedList)config[sectionname];
                        System.Collections.Hashtable  tmpaddressbook = (System.Collections.Hashtable)(new System.Configuration.SingleTagSectionHandler()).Create(parent, context, item);
                        System.Collections.Specialized.ListDictionary addressbook = new System.Collections.Specialized.ListDictionary(new System.Collections.CaseInsensitiveComparer());
                        foreach (System.String configitem in tmpaddressbook.Keys)
                        {
                            addressbook.Add(configitem, tmpaddressbook[configitem]);
                        }
                        tmpaddressbook = null;
                        if (addressbook.Contains("type") && !addressbook["type"].Equals("none") && addressbook.Contains("name") && !addressbooks.Contains(addressbook["name"]))
                        {
                            if (addressbook.Contains("pagesize"))
                            {
                                addressbook["pagesize"] = ParseConfigElement(addressbook["pagesize"].ToString(), 10);
                            }
                            else
                            {
                                addressbook["pagesize"] = 10;
                            }
                            addressbooks.Add(addressbook["name"], addressbook);
                            if (addressbook.Contains("allowupdate"))
                            {
                                addressbook["allowupdate"] = ParseConfigElement(addressbook["allowupdate"].ToString(), false);
                            }
                            else
                            {
                                addressbook["allowupdate"] = false;
                            }
                        }
                        break;
                    }
                }
            }
        }
Exemple #11
0
        protected string GetPreference(string preferenceId)
        {
            DataSet rtnDs;
            DataRow prefDr;
            string  strPrefValue = null;

            // Call the fn_get_global_preference
            System.Collections.ArrayList paramList = new ArrayList();


            SqlParameter p1 = new SqlParameter("@ps_preference_id", SqlDbType.VarChar);

            p1.Value = preferenceId;
            paramList.Add(p1);
            if (ComponentAttributes.Contains("CurrentUser"))
            {
                SqlParameter p2 = new SqlParameter("@userId", SqlDbType.VarChar);
                p2.Value = ComponentAttributes["CurrentUser"];
                paramList.Add(p2);
            }
            if (ComponentAttributes.Contains("ComputerID"))
            {
                SqlParameter p3 = new SqlParameter("@computerId", SqlDbType.Int);
                p3.Value = ComponentAttributes["ComputerID"];
                paramList.Add(p3);
            }
            SqlParameter[] userParams = (SqlParameter[])paramList.ToArray(typeof(SqlParameter));

            rtnDs = ExecuteSql("select dbo.fn_get_preference" +
                               "(NULL ," +
                               "@ps_preference_id," +
                               (ComponentAttributes.Contains("CurrentUser")? "@userId," : "NULL,") +
                               (ComponentAttributes.Contains("ComputerID")? "@computerId)" : "NULL)")
                               , ref userParams);
            if (rtnDs != null && rtnDs.Tables.Count > 0 && rtnDs.Tables[0].Rows.Count > 0 && rtnDs.Tables[0].Rows[0] != null)
            {
                prefDr       = rtnDs.Tables[0].Rows[0];
                strPrefValue = prefDr[0].ToString();
            }
            // Then check to see if this is encrypted then decrypt and return
            SqlParameter[] userParams2 = new SqlParameter[1];
            userParams2[0]       = new SqlParameter("@ps_preference_id", SqlDbType.VarChar);
            userParams2[0].Value = preferenceId;
            DataSet encFlagDS = ExecuteSql("select encrypted from c_preference where preference_id = @ps_preference_id", ref userParams2);

            if (encFlagDS.Tables.Count > 0 && encFlagDS.Tables[0].Rows.Count > 0 && !encFlagDS.Tables[0].Rows[0].IsNull(0))
            {
                if (encFlagDS.Tables[0].Rows[0][0].ToString().ToLower() == "y")
                {                 // preference is encrypted.  perform decryption using EproLibNET.Utilities class
                    System.Reflection.Assembly epln = System.Reflection.Assembly.LoadWithPartialName("EncounterPRO.OS.Utilities, PublicKeyToken=e3e395c42bd8c0d4");
                    Type   utilType = epln.GetType("EncounterPRO.OS.Utilities");
                    object util     = utilType.GetConstructor(System.Type.EmptyTypes).Invoke(null);
                    strPrefValue = (string)utilType.InvokeMember("DecryptString", System.Reflection.BindingFlags.InvokeMethod, null,
                                                                 util, new object[] { strPrefValue, resource });
                    util     = null;
                    utilType = null;
                    epln     = null;
                }
            }
            return(strPrefValue);
        }