Exemplo n.º 1
0
        public frmMain(string file, Profile profile, string action, string endpoint, int depositId)
        {
            InitializeComponent();
            this.profile = profile;

                this.action = action;
                this.endpoint = endpoint;
                this.depositId = depositId;

            loadFile(file);

            if (profile.GetUsername() == null || "".Equals(profile.GetUsername()))
            {
                try
                {
                    this.username = WindowsIdentity.GetCurrent().Name.Split('\\')[1];
                }
                catch (Exception le)
                {
                    MessageBox.Show("Could not get username.\nReason: " + le.Message, "Error getting Windows credentials", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                }
            }
            else
            {
                this.username = profile.GetUsername();
            }

            sc = new SWORDClient(profile.GetServiceDocumentUri(), profile.GetUsername(), profile.GetPassword(), profile.GetOnBehalfOf());
            List<string> mimes = getAcceptableMimes();
            populateMimes(mimes);

            drawForm();
        }
Exemplo n.º 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            Profile p = getSelectedProfile();
            if (p != null)
            {
                currentProfile = p;
            }

            drawProfileForm();
        }
Exemplo n.º 3
0
 private void btnNew_Click(object sender, EventArgs e)
 {
     currentProfile = new Profile();
     int maxId = 0;
     if (profiles.Count > 0)
         maxId = profiles.Max(kvp => kvp.Key);
     int id = maxId + 1;
     currentProfile.SetId(id);
     drawProfileForm();
 }
Exemplo n.º 4
0
 private void listProfiles()
 {
     profiles = Profile.loadProfiles(Program.defaultProfileDataPath);
     listProfile.Items.Clear();
     foreach (KeyValuePair<int, Profile> kv in profiles)
     {
         Profile profile = kv.Value;
         ListViewItem i = new ListViewItem(profile.GetName());
         i.Tag = profile.GetId();
         i.Text = profile.GetName();
         i.Name = profile.GetName();
         i.SubItems.Add(profile.GetServiceDocumentUri());
         listProfile.Items.Add(i);
         if (profile.IsDefault())
             currentProfile = profile;
     }
     if (profiles.Count == 0)
         currentProfile = new Profile();
 }
Exemplo n.º 5
0
        public static Dictionary<int, Profile> loadProfiles(string path)
        {
            Dictionary<int, Profile> profiles = new Dictionary<int, Profile>();
            Profile p = new Profile();
            XmlTextReader xr = new XmlTextReader(path);

            XmlDocument profilesDoc = new XmlDocument();
            try
            {
                profilesDoc.Load(path);
            }
            catch (FileNotFoundException fe)
            {
                System.IO.File.WriteAllLines(path, new string[1] {
                    "<Profiles><Profile>" +
                        "<ID>0</ID>" +
                        "<Name>Kim's Demonstration Collection</Name>" +
                        "<ServiceDocumentUri>http://www.anonymous.org.nz:8080/swordv2/servicedocument</ServiceDocumentUri>" +
                        "<DefaultDepositUri>http://www.anonymous.org.nz:8080/swordv2/collection/123456789/2</DefaultDepositUri>" +
                        "<Default>True</Default>" +
                        "<Username>[email protected]</Username>" +
                        "<Password>rightclickdeposit</Password>" +
                        "<FinalState>Ask</FinalState>" +
                        "<MetadataInclusion>Optional</MetadataInclusion>" +
                        "<Packaging></Packaging>" +
                        "<OnBehalfOf />" +
                      "</Profile></Profiles>"
                });
            }

            foreach (XmlNode profileNode in profilesDoc.GetElementsByTagName("Profile"))
            {
                p = new Profile();

                foreach (XmlNode profileEl in profileNode.ChildNodes)
                {
                    switch (profileEl.Name)
                    {
                        case "ID":
                            p.SetId(int.Parse(profileEl.InnerText));
                            break;
                        case "Name":
                            p.SetName(profileEl.InnerText);
                            break;
                        case "ServiceDocumentUri":
                            p.SetServiceDocumentUri(profileEl.InnerText);
                            break;
                        case "DefaultDepositUri":
                            p.SetDepositUri(profileEl.InnerText);
                            break;
                        case "Default":
                            p.SetIsDefault(bool.Parse(profileEl.InnerText));
                            break;
                        case "Username":
                            p.SetUsername(profileEl.InnerText);
                            break;
                        case "Password":
                            p.SetPassword(profileEl.InnerText);
                            break;
                        case "FinalState":
                            p.SetFinalState(profileEl.InnerText);
                            break;
                        case "MetadataInclusion":
                            p.SetMetadataInclusion(profileEl.InnerText);
                            break;
                        case "Packaging":
                            p.SetPackaging(profileEl.InnerText);
                            break;
                        case "OnBehalfOf":
                            p.SetOnBehalfOf(profileEl.InnerText);
                            break;
                        default:
                            break;
                    }
                }
                profiles.Add(p.GetId(), p);
            }
            return profiles;
        }