Example #1
0
        public void TestToString()
        {
            var route = new DomainList();

            route.Add("route1");
            route.Add("  \t\t ");
            route.Add("route2");

            Assert.AreEqual("@route1,@route2", route.ToString());
        }
Example #2
0
        public void TestBasicListFunctionality()
        {
            var list = new DomainList();

            Assert.IsFalse(list.IsReadOnly);
            Assert.AreEqual(0, list.Count, "Initial count");

            list.Add("domain2");

            Assert.AreEqual(1, list.Count);
            Assert.AreEqual("domain2", list[0]);

            list.Insert(0, "domain0");
            list.Insert(1, "domain1");

            Assert.AreEqual(3, list.Count);
            Assert.AreEqual("domain0", list[0]);
            Assert.AreEqual("domain1", list[1]);
            Assert.AreEqual("domain2", list[2]);

            Assert.IsTrue(list.Contains("domain1"), "Contains");
            Assert.AreEqual(1, list.IndexOf("domain1"), "IndexOf");

            var array = new string[list.Count];

            list.CopyTo(array, 0);
            list.Clear();

            Assert.AreEqual(0, list.Count);

            foreach (var domain in array)
            {
                list.Add(domain);
            }

            Assert.AreEqual(array.Length, list.Count);

            Assert.IsFalse(list.Remove("not-in-the-list"));
            Assert.IsTrue(list.Remove("domain2"));
            Assert.AreEqual(2, list.Count);
            Assert.AreEqual("domain0", list[0]);
            Assert.AreEqual("domain1", list[1]);

            list.RemoveAt(0);

            Assert.AreEqual(1, list.Count);
            Assert.AreEqual("domain1", list[0]);

            list[0] = "domain";

            Assert.AreEqual(1, list.Count);
            Assert.AreEqual("domain", list[0]);
        }
Example #3
0
        public void LoadDomain(Config config)
        {
            using (LogBlock logblock = Log.NotTracing() ? null : new LogBlock(GetType() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name))
            {
                CurrentDomainSelection = 0;

                string d = config.UserProvision.DestinationDomain;

                if (DomainList.Count > 0)
                {
                    for (int i = 0; i < DomainList.Count; i++)
                    {
                        if (d == DomainList[i])
                        {
                            CurrentDomainSelection = i;
                            DomainsFilledIn        = true;
                            break;
                        }
                    }
                }
                else
                {
                    DomainList.Add(d);
                }
            }
        }
Example #4
0
        private void AddDomainButton_Click(object sender, EventArgs e)
        {
            AddDomainForm form = new AddDomainForm();

            if (form.ShowDialog() == DialogResult.OK)
            {
                Boolean ok = true;

                foreach (Domain d in DomainList)
                {
                    if (d.Name.Equals(form.domainName))
                    {
                        ok = false;
                    }
                }

                if (DomainList.Count == 0 || ok)
                {
                    DomainList.Add(new Domain(form.domainName));
                    //DomainListbox_SelectedIndexChanged(this, null);
                    statusLabel.Text = "Le domaine \"" + form.domainName + "\" a été ajouté";
                    EnableDomainButtons();
                    AddAccountButton.Enabled    = true;
                    UnsavedModifications        = true;
                    DomainListbox.SelectedIndex = DomainList.Count - 1; //Set focus on last domain
                }
                else
                {
                    MessageBox.Show("Le domaine \"" + form.domainName + "\" existe déjà !", "Erreur", MessageBoxButtons.OK);
                    statusLabel.Text = "Le domaine \"" + form.domainName + "\" existe déjà !";
                }
            }
        }
Example #5
0
    public DomainList GetRoot()
    {
        DomainList ret = new DomainList();

        string[] domains = new string[] { "Archaea", "Eubacteria", "Eukaryota" };
        foreach (string domain in domains)
        {
            ret.Add(new Domain {
                Name = domain, Uri = domain
            });
        }
        //Message realRet = Message.CreateMessage(MessageVersion.None, "*", ret);
        return(ret);
    }
Example #6
0
        public void TestArgumentExceptions()
        {
            var list = new DomainList();

            Assert.Throws <ArgumentNullException> (() => new DomainList(null));
            Assert.Throws <ArgumentNullException> (() => list.Add(null));
            Assert.Throws <ArgumentNullException> (() => list.Contains(null));
            Assert.Throws <ArgumentNullException> (() => list.CopyTo(null, 0));
            Assert.Throws <ArgumentOutOfRangeException> (() => list.CopyTo(new string[0], -1));
            Assert.Throws <ArgumentNullException> (() => list.IndexOf(null));
            Assert.Throws <ArgumentOutOfRangeException> (() => list.Insert(-1, "item"));
            Assert.Throws <ArgumentNullException> (() => list.Insert(0, null));
            Assert.Throws <ArgumentNullException> (() => list[0] = null);
            Assert.Throws <ArgumentNullException> (() => list.Remove(null));
            Assert.Throws <ArgumentOutOfRangeException> (() => list.RemoveAt(-1));
        }
Example #7
0
		public void TestArgumentExceptions ()
		{
			var list = new DomainList ();

			Assert.Throws<ArgumentNullException> (() => new DomainList (null));
			Assert.Throws<ArgumentNullException> (() => list.Add (null));
			Assert.Throws<ArgumentNullException> (() => list.Contains (null));
			Assert.Throws<ArgumentNullException> (() => list.CopyTo (null, 0));
			Assert.Throws<ArgumentOutOfRangeException> (() => list.CopyTo (new string[0], -1));
			Assert.Throws<ArgumentNullException> (() => list.IndexOf (null));
			Assert.Throws<ArgumentOutOfRangeException> (() => list.Insert (-1, "item"));
			Assert.Throws<ArgumentNullException> (() => list.Insert (0, null));
			Assert.Throws<ArgumentNullException> (() => list[0] = null);
			Assert.Throws<ArgumentNullException> (() => list.Remove (null));
			Assert.Throws<ArgumentOutOfRangeException> (() => list.RemoveAt (-1));
		}
Example #8
0
        public void LoadDomain(Config config)
        {
            CurrentDomainSelection = 0;

            string d = config.UserProvision.DestinationDomain;

            if (DomainList.Count > 0)
            {
                for (int i = 0; i < DomainList.Count; i++)
                {
                    if (d == DomainList[i])
                    {
                        CurrentDomainSelection = i;
                        DomainsFilledIn        = true;
                        break;
                    }
                }
            }
            else
            {
                DomainList.Add(d);
            }
        }
Example #9
0
        private void UserMap()
        {
            ScheduleViewModel scheduleViewModel =
                ((ScheduleViewModel)ViewModelPtrs[(int)ViewType.SCHED]);
            bool bCSV = false;

            Microsoft.Win32.OpenFileDialog fDialog = new Microsoft.Win32.OpenFileDialog();
            fDialog.Filter          = "User Map Files|*.xml;*.csv";
            fDialog.CheckFileExists = true;
            fDialog.Multiselect     = false;
            if (fDialog.ShowDialog() == true)
            {
                int lastDot = fDialog.FileName.LastIndexOf(".");

                if (lastDot != -1)
                {
                    string substr = fDialog.FileName.Substring(lastDot, 4);

                    if (substr == ".csv")
                    {
                        bCSV = true;

                        /*try
                        * {
                        *  string names = File.ReadAllText(fDialog.FileName);
                        *  string[] nameTokens = names.Split(',');
                        *  foreach (string name in nameTokens)
                        *  {
                        *      UsersList.Add(name);
                        *      scheduleViewModel.SchedList.Add(name);
                        *  }
                        * }
                        * catch (IOException ex)
                        * {
                        *  MessageBox.Show(ex.Message, "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                        * }*/
                        List <string[]> parsedData = new List <string[]>();
                        try
                        {
                            if (File.Exists(fDialog.FileName))
                            {
                                using (StreamReader readFile = new StreamReader(fDialog.FileName)) {
                                    string line;

                                    string[] row;
                                    while ((line = readFile.ReadLine()) != null)
                                    {
                                        row = line.Split(',');
                                        parsedData.Add(row);
                                    }
                                    readFile.Close();
                                }
                            }
                            else
                            {
                                MessageBox.Show(
                                    "There is no user information stored.Please enter some user info",
                                    "Zimbra Migration", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                            }
                        }
                        catch (Exception e)
                        {
                            string message = e.Message;
                        }
                        // for (int i = 1; i < parsedData.Count; i++)
                        {
                            string[] strres = new string[parsedData.Count];

                            Users tempuser = new Users();

                            try
                            {
                                for (int j = 0; j < parsedData.Count; j++)
                                {
                                    bool bFoundSharp = false;
                                    strres = parsedData[j];
                                    int num = strres.Count();
                                    for (int k = 0; k < num; k++)
                                    {
                                        if (strres[k].Contains("#"))
                                        {
                                            bFoundSharp = true;
                                            break;
                                        }
                                    }
                                    if (!bFoundSharp) // FBS bug 71933 -- 3/21/12
                                    {
                                        tempuser.UserName   = strres[0];
                                        tempuser.MappedName = strres[1];

                                        tempuser.ChangePWD = Convert.ToBoolean(strres[2]);
                                        // tempuser.PWDdefault = strres[3];
                                        // string result = tempuser.UserName + "," + tempuser.MappedName +"," + tempuser.ChangePWD + "," + tempuser.PWDdefault;
                                        string result = tempuser.Username + "," + tempuser.MappedName;

                                        Username   = strres[0];
                                        MappedName = strres[1];
                                        UsersViewModel uvm = new UsersViewModel(Username, MappedName);
                                        uvm.MustChangePassword = tempuser.ChangePWD;
                                        UsersList.Add(uvm);
                                        scheduleViewModel.SchedList.Add(new SchedUser(Username, false));
                                    }
                                }
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("Incorrect .csv file format", "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                                return;
                            }

                            EnableNext = (UsersList.Count > 0);
                        }
                        scheduleViewModel.EnableMigrate = (scheduleViewModel.SchedList.Count > 0);
                        scheduleViewModel.EnablePreview = scheduleViewModel.EnableMigrate;

                        // /
                        // Domain information is stored in the xml and not in  the usermap.
                        // will have to revisit

                        System.Xml.Serialization.XmlSerializer reader =
                            new System.Xml.Serialization.XmlSerializer(typeof(Config));
                        if (File.Exists(scheduleViewModel.GetConfigFile()))
                        {
                            System.IO.StreamReader fileRead = new System.IO.StreamReader(
                                scheduleViewModel.GetConfigFile());

                            Config Z11 = new Config();

                            Z11 = (Config)reader.Deserialize(fileRead);
                            fileRead.Close();
                            ZimbraDomain = Z11.UserProvision.DestinationDomain;
                            if (DomainList.Count > 0)
                            {
                                CurrentDomainSelection = (ZimbraDomain == null) ? 0 :
                                                         DomainList.IndexOf(ZimbraDomain);
                            }

                            else
                            {
                                DomainList.Add(ZimbraDomain);
                            }
                        }
                        scheduleViewModel.SetUsermapFile(fDialog.FileName);
                    }
                }
                if (!bCSV)
                {
                    MessageBox.Show("Only CSV files are supported", "Zimbra Migration",
                                    MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
            }
        }
Example #10
0
		public void TestBasicListFunctionality ()
		{
			var list = new DomainList ();

			Assert.IsFalse (list.IsReadOnly);
			Assert.AreEqual (0, list.Count, "Initial count");

			list.Add ("domain2");

			Assert.AreEqual (1, list.Count);
			Assert.AreEqual ("domain2", list[0]);

			list.Insert (0, "domain0");
			list.Insert (1, "domain1");

			Assert.AreEqual (3, list.Count);
			Assert.AreEqual ("domain0", list[0]);
			Assert.AreEqual ("domain1", list[1]);
			Assert.AreEqual ("domain2", list[2]);

			Assert.IsTrue (list.Contains ("domain1"), "Contains");
			Assert.AreEqual (1, list.IndexOf ("domain1"), "IndexOf");

			var array = new string[list.Count];
			list.CopyTo (array, 0);
			list.Clear ();

			Assert.AreEqual (0, list.Count);

			foreach (var domain in array)
				list.Add (domain);

			Assert.AreEqual (array.Length, list.Count);

			Assert.IsTrue (list.Remove ("domain2"));
			Assert.AreEqual (2, list.Count);
			Assert.AreEqual ("domain0", list[0]);
			Assert.AreEqual ("domain1", list[1]);

			list.RemoveAt (0);

			Assert.AreEqual (1, list.Count);
			Assert.AreEqual ("domain1", list[0]);

			list[0] = "domain";

			Assert.AreEqual (1, list.Count);
			Assert.AreEqual ("domain", list[0]);
		}
Example #11
0
        public override void Populate(object obj)
        {
            dtDominio = (DataTable)obj;
            try
            {
                cmbDominios.Properties.DisplayMember = "DomainName";
                cmbDominios.Properties.ValueMember   = "DomainGUID";


                //if (cmbDominios._ShowActiveFlag && cmbDominios._ActiveFlagChecked)
                //    active = true;

                if (dtDominio != null)
                {
                    //AccountList _List = AccountController.AccountGet(null, active);
                    //System.Data.DataRowCollection _Rows = _DtAuthenticationType.Rows;


                    DomainList wDomainList = new DomainList();

                    foreach (DataRow dr in dtDominio.Rows)
                    {
                        Domain wDomain = new Domain();

                        //wDomain.DomainId = Convert.ToInt32( dr.Table.Rows[0]["DomainId"]);
                        wDomain.DomainName = dr.Table.Rows[0]["DomainName"].ToString();
                        wDomain.DomainGUID = dr.Table.Rows[0]["DomainGUID"].ToString();

                        wDomainList.Add(wDomain);
                    }


                    #region [Agregado de Item a lista de acuerdo a propiedad _WithTextSelection]

                    //if (_WithTextSelection == true)
                    //{
                    //    DataRow wAccountBE_Seleccione = new AccountBE();
                    //    wAccountBE_Seleccione.AccountId = -1;
                    //    wAccountBE_Seleccione.AccountName = "Seleccione";
                    //    _List.Insert(0, wAccountBE_Seleccione);
                    //}

                    #endregion
                    cmbDominios.Properties.DataSource = wDomainList;
                    cmbDominios.Refresh();
                    cmbDominios.EditValue = cmbDominios.Properties.GetDataSourceValue(cmbDominios.Properties.ValueMember, 0);
                    //cmbDominios.Properties.PopulateColumns();

                    foreach (DevExpress.XtraEditors.Controls.LookUpColumnInfo col in cmbDominios.Properties.Columns)
                    {
                        if (col.FieldName != "DomainName")
                        {
                            col.Visible = false;
                        }
                    }

                    bFirstLoad = false;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }