Exemplo n.º 1
0
            protected override void ProcessRecord()
            {
                try
                {
                    if (id != null)
                    {
                        var _xml = dgcGoogleProfileService.GetProfile(service.ProfileService, id);

                        var _profileEntry = dgcGoogleProfileService.CreateProfileEntry(_xml, id, service.ProfileService);
                        WriteObject(_profileEntry);

                    }
                    else
                    {
                        nextPage = "";
                        var _xml = dgcGoogleProfileService.GetProfiles(service.ProfileService, nextPage);

                        var parseXML = new GDataTypes.ParseXML(_xml.ToString());
                        var _profileEntrys = dgcGoogleProfileService.CreateProfileEntrys(_xml, service.ProfileService);

                        while (nextPage != null)
                        {
                            nextPage = null;
                            foreach (var _elements in parseXML.ListFormat)
                            {
                                foreach (var _attribute in _elements.at)
                                {
                                    if (_attribute.Value == "next")
                                    {
                                        nextPage = _attribute.NextAttribute.NextAttribute.Value;
                                    }
                                }
                            }
                            if (nextPage != null)
                            {

                                _xml = dgcGoogleProfileService.GetProfiles(service.ProfileService, nextPage);
                                parseXML = new GDataTypes.ParseXML(_xml.ToString());
                                _profileEntrys = dgcGoogleProfileService.AppendProfileEntrys(_xml, service.ProfileService, _profileEntrys);
                            }
                        }

                        WriteObject(_profileEntrys, true);
                    }

                }
                catch (WebException _exception)
                {
                    WriteObject(_exception);
                }
            }
Exemplo n.º 2
0
            public GDataTypes.GDataUserAliasEntry AppendUserAliasEntry(string _Xml, GDataTypes.GDataUserAliasEntry userAliasEntry)
            {
                var _paresdXml = new GDataTypes.ParseXML(_Xml);
                var _userSingelAliasEntry = new GDataTypes.GDataAliasEntry();
                foreach (var _entry in _paresdXml.ListFormat)
                {
                    var _aliasEntry = new GDataTypes.GDataAliasEntry();
                    foreach (var _attribute in _entry.at)
                    {
                        if (_attribute.Value == "aliasEmail" || _attribute.Value == "userEmail")
                        {
                            if (_attribute.Value == "aliasEmail")
                            {
                                _userSingelAliasEntry.aliasEmail = _attribute.NextAttribute.Value;
                            }
                            if (_attribute.Value == "userEmail")
                            {
                                _userSingelAliasEntry.UserName = _attribute.NextAttribute.Value;
                            }
                            if (_userSingelAliasEntry.UserName != null && _userSingelAliasEntry.aliasEmail != null)
                            {
                                userAliasEntry.Add(_userSingelAliasEntry);
                            }
                        }
                    }
                    foreach (var _subEntry in _entry.sub)
                    {
                        foreach (var _attribute in _subEntry.at)
                        {

                            if (_attribute.Value == "aliasEmail" || _attribute.Value == "userEmail")
                            {
                                if (_attribute.Value == "aliasEmail")
                                {
                                    _aliasEntry.aliasEmail = _attribute.NextAttribute.Value;
                                }
                                if (_attribute.Value == "userEmail")
                                {
                                    _aliasEntry.UserName = _attribute.NextAttribute.Value;
                                }
                                if (_aliasEntry.UserName != null && _aliasEntry.aliasEmail != null)
                                {
                                    userAliasEntry.Add(_aliasEntry);
                                }
                            }
                        }
                    }
                }
                return userAliasEntry;
            }
Exemplo n.º 3
0
 public string RetriveNextPage(string xml)
 {
     var _parseXml = new GDataTypes.ParseXML(xml.ToString());
     nextPage = "";
     foreach (var _elements in _parseXml.ListFormat)
     {
         foreach (var _attribute in _elements.at)
         {
             if (_attribute.Value == "next")
             {
                 nextPage = _attribute.NextAttribute.NextAttribute.Value;
             }
         }
     }
     return nextPage;
 }
Exemplo n.º 4
0
            public GDataTypes.GDataResourceEntrys CreateResourceEntrys(string xml, GDataTypes.GDataResourceService resourceService)
            {
                var _paresdXml = new GDataTypes.ParseXML(xml);

                var _gDataResourceEntrys = new GDataTypes.GDataResourceEntrys();
                var _gdataSingelResourceEntry = new GDataTypes.GDataResourceEntry();
                foreach (var _sEntry in _paresdXml.ListFormat)
                {
                    foreach (var _attribute in _sEntry.at)
                    {

                        if (_attribute.Value == "resourceId" || _attribute.Value == "resourceCommonName" || _attribute.Value == "resourceEmail" || _attribute.Value == "resourceDescription" || _attribute.Value == "resourceType")
                        {

                            if (_attribute.Value == "resourceId")
                            {
                                if (_attribute.NextAttribute.Value != null)
                                {
                                    _gdataSingelResourceEntry.ResourceId = _attribute.NextAttribute.Value;
                                }
                                else
                                {
                                    _gdataSingelResourceEntry.ResourceId = "_EMPTY_";
                                }
                            }
                            if (_attribute.Value == "resourceCommonName")
                            {
                                if (_attribute.NextAttribute.Value != null)
                                {
                                    _gdataSingelResourceEntry.CommonName = _attribute.NextAttribute.Value;
                                }
                                else
                                {
                                    _gdataSingelResourceEntry.CommonName = "_EMPTY_";
                                }
                            }
                            if (_attribute.Value == "resourceEmail")
                            {
                                if (_attribute.NextAttribute.Value != null)
                                {
                                    _gdataSingelResourceEntry.Email = _attribute.NextAttribute.Value;
                                }
                                else
                                {
                                    _gdataSingelResourceEntry.Email = "_EMPTY_";
                                }
                            }
                            if (_attribute.Value == "resourceDescription")
                            {
                                if (_attribute.NextAttribute.Value != null)
                                {
                                    _gdataSingelResourceEntry.Description = _attribute.NextAttribute.Value;
                                }
                                else
                                {
                                    _gdataSingelResourceEntry.Description = "_EMPTY_";
                                }
                            }
                            if (_attribute.Value == "resourceType")
                            {
                                if (_attribute.NextAttribute.Value != null)
                                {
                                    _gdataSingelResourceEntry.Type = _attribute.NextAttribute.Value;
                                }
                                else
                                {
                                    _gdataSingelResourceEntry.Type = "_EMPTY_";
                                }
                            }
                        }

                    }

                    var _gdataResourceEntry = new GDataTypes.GDataResourceEntry();
                    foreach (var _subEntry in _sEntry.sub)
                    {
                        foreach (var _attribute in _subEntry.at)
                        {

                            if (_attribute.Value == "resourceId" || _attribute.Value == "resourceCommonName" || _attribute.Value == "resourceEmail" || _attribute.Value == "resourceDescription" || _attribute.Value == "resourceType")
                            {

                                if (_attribute.Value == "resourceId")
                                {

                                    _gdataResourceEntry.ResourceId = _attribute.NextAttribute.Value;
                                }
                                if (_attribute.Value == "resourceCommonName")
                                {

                                    _gdataResourceEntry.CommonName = _attribute.NextAttribute.Value;
                                }
                                if (_attribute.Value == "resourceEmail")
                                {

                                    _gdataResourceEntry.Email = _attribute.NextAttribute.Value;
                                }
                                if (_attribute.Value == "resourceDescription")
                                {

                                    _gdataResourceEntry.Description = _attribute.NextAttribute.Value;
                                }
                                if (_attribute.Value == "resourceType")
                                {

                                    _gdataResourceEntry.Type = _attribute.NextAttribute.Value;
                                }

                            }

                        }
                    }
                    if (_gdataResourceEntry.ResourceId != null)
                    {
                        _gDataResourceEntrys.Add(_gdataResourceEntry);
                    }
                }
                if (_gdataSingelResourceEntry.ResourceId != null)
                {
                    _gDataResourceEntrys.Add(_gdataSingelResourceEntry);
                }
                return _gDataResourceEntrys;
            }
Exemplo n.º 5
0
            public GDataTypes.GDataProfileEntrys CreateProfileEntrys(string xml, GDataTypes.GDataProfileService profileService)
            {
                var _paresdXml = new GDataTypes.ParseXML(xml);

                var _profileEntrys = new GDataTypes.GDataProfileEntrys();

                string _profileLink = "http://www.google.com/m8/feeds/profiles/domain/" + profileService.Domain + "/full/";

                foreach (var _sEntry in _paresdXml.ListFormat)
                {
                    if (_sEntry.name == "{http://www.w3.org/2005/Atom}entry")
                    {
                        var _profileEntry = new GDataTypes.GDataProfileEntry();
                        _profileEntry.Domain = profileService.Domain;
                        foreach (var _entry in _sEntry.sub)
                        {
                            if (_entry.name == "{http://www.w3.org/2005/Atom}id")
                            {
                                _profileEntry.UserName = _entry.value.Replace(_profileLink,"");
                            }
                            if (_entry.name == "{http://schemas.google.com/g/2005}structuredPostalAddress")
                            {
                                foreach (var _attribute in _entry.at)
                                {
                                    if (_attribute.Value == "http://schemas.google.com/g/2005#home")
                                    {
                                        _profileEntry.HomePostalAddress = _entry.value;
                                    }
                                    if (_attribute.Value == "http://schemas.google.com/g/2005#work")
                                    {
                                        _profileEntry.PostalAddress = _entry.value;
                                    }
                                }
                            }
                            if (_entry.name == "{http://schemas.google.com/g/2005}phoneNumber")
                            {
                                foreach (var _attribute in _entry.at)
                                {
                                    if (_attribute.Value == "http://schemas.google.com/g/2005#other")
                                    {
                                        _profileEntry.OtherPhoneNumber = _entry.value;
                                    }
                                    if (_attribute.Value == "http://schemas.google.com/g/2005#work")
                                    {
                                        _profileEntry.PhoneNumber = _entry.value;
                                    }
                                    if (_attribute.Value == "http://schemas.google.com/g/2005#mobile")
                                    {
                                        _profileEntry.MobilePhoneNumber = _entry.value;
                                    }
                                    if (_attribute.Value == "http://schemas.google.com/g/2005#home")
                                    {
                                        _profileEntry.HomePhoneNumber = _entry.value;
                                    }
                                }
                            }
                        }
                        _profileEntrys.Add(_profileEntry);
                    }
                }

                return _profileEntrys;
            }
Exemplo n.º 6
0
            public string SetContactTitle(string token, string selfUri, string title)
            {
                var _xml = GetContact(token, selfUri);

                var _paredXml = new GDataTypes.ParseXML(_xml);
                if(_xml.Contains("<title type='text'></title>"))
                {

                }
                foreach (var _entry in _paredXml.ListFormat)
                {
                    if (_entry.name == "{http://www.w3.org/2005/Atom}link")
                    {
                        foreach (var _attribute in _entry.at)
                        {
                            if (_attribute.Value == "edit")
                            {
                                editUri = _attribute.NextAttribute.NextAttribute.Value;
                            }
                        }
                    }
                    if (_entry.name == "{http://www.w3.org/2005/Atom}title")
                    {
                        if (_entry.value != null)
                        {
                            oldTitle = "<title type='text'>" + _entry.value + "</title>";
                        }
                        else
                        {
                            oldTitle = "<title type='text'></title>";
                        }
                    }
                }

                var _uri = new Uri(editUri);

                var _newXml = _xml.Replace(oldTitle, "<title type='text'>" + title + "</title>");

                WebRequest _webRequest = WebRequest.Create(_uri);
                _webRequest.ContentType = "application/atom+xml; charset=UTF-8";

                _webRequest.Method = "PUT";
                _webRequest.Headers.Add("Authorization: GoogleLogin auth=" + token);
                byte[] _bytes = Encoding.UTF8.GetBytes(_newXml);
                Stream _OS = null;
                _webRequest.ContentLength = _bytes.Length;
                _OS = _webRequest.GetRequestStream();
                _OS.Write(_bytes, 0, _bytes.Length);

                _OS.Close();

                WebResponse _webResponse = _webRequest.GetResponse();

                if (_webResponse == null)
                {
                    throw new Exception("WebResponse is null");
                }
                StreamReader _SR = new StreamReader(_webResponse.GetResponseStream());

                var _Result = _SR.ReadToEnd().Trim();

                return _Result;
            }
Exemplo n.º 7
0
            protected override void ProcessRecord()
            {
                if (id == null)
                {
                    try
                    {
                        if (!legacy == true)
                        {
                            nextPage = "";
                            var _xml = dgcGoogleAppsService.RetriveAllUserAlias(service.AppsService, nextPage);
                            var _userAliasEntry = dgcGoogleAppsService.CreateUserAliasEntry(_xml);
                            parseXML = new GDataTypes.ParseXML(_xml.ToString());

                            while (nextPage != null)
                            {
                                nextPage = null;
                                foreach (var _elements in parseXML.ListFormat)
                                {
                                    foreach (var _attribute in _elements.at)
                                    {
                                        if (_attribute.Value == "next")
                                        {
                                            nextPage = _attribute.NextAttribute.NextAttribute.Value;
                                        }
                                    }
                                }
                                if (nextPage != null)
                                {
                                    _xml = dgcGoogleAppsService.RetriveAllUserAlias(service.AppsService, nextPage);
                                    parseXML = new GDataTypes.ParseXML(_xml.ToString());
                                    _userAliasEntry = dgcGoogleAppsService.AppendUserAliasEntry(_xml, _userAliasEntry);
                                }
                            }

                            WriteObject(_userAliasEntry,true);
                        }
                        else
                        {
                            var _feed = service.AppsService.RetrieveAllNicknames();
                            WriteObject(_feed.Entries);
                        }
                    }
                    catch (Exception _exception)
                    {
                        WriteObject(_exception);
                    }
                }
                else
                {
                    try
                    {
                        if (!legacy == true)
                        {

                            /*
                            if (!id.Contains("@"))
                            {
                                throw new Exception("-ID must contain Domain, [email protected]");
                            }
                            */
                            var _userAliasEntry = dgcGoogleAppsService.CreateUserAliasEntry(dgcGoogleAppsService.RetriveUserAlias(id, service.AppsService));
                            WriteObject(_userAliasEntry,true);
                        }
                        else
                        {
                            var _feed = service.AppsService.RetrieveNicknames(id);
                            WriteObject(_feed);
                        }

                    }
                    catch (Exception _exception)
                    {
                        WriteObject(_exception);
                    }
                }
            }