Exemplo n.º 1
0
 public XmlDocument GetCompanyStream(SocialCastAuthDetails auth)
 {
     int companyStreamID = GetStreamIdbyStreamName("company stream", auth);
     var streams = new XmlDocument();
     streams.LoadXml(base.MakeServiceCalls(helper.GetSocialcastURL(ObjectType.StreamMessages, auth.DomainName, companyStreamID.ToString()), GetCredentials(auth.Username, auth.Password)));
     return streams;
 }
Exemplo n.º 2
0
 public XmlDocument GetMessage(string _messageID, string numberOfUsers, string page, SocialCastAuthDetails auth)
 {
     XmlDocument Message = new XmlDocument();
     var serviceParams = new List<KeyValuePair<string, string>>();
     serviceParams.Add(new KeyValuePair<string, string>("per_page", numberOfUsers));
     serviceParams.Add(new KeyValuePair<string, string>("page", page));
     Message.LoadXml(base.MakeServiceCalls(helper.GetSocialcastURL(ObjectType.MessagesById, auth.DomainName, _messageID, serviceParams), GetCredentials(auth.Username, auth.Password)));
     return Message;
 }
Exemplo n.º 3
0
 public XmlDocument GetGroups(int page, int numberOfRecords, SocialCastAuthDetails auth)
 {
     XmlDocument groups = new XmlDocument();
     var serviceParams = new List<KeyValuePair<string, string>>();
     serviceParams.Add(new KeyValuePair<string, string>("per_page", numberOfRecords.ToString()));
     serviceParams.Add(new KeyValuePair<string, string>("page", page.ToString()));
     groups.LoadXml(base.MakeServiceCalls(helper.GetSocialcastURL(ObjectType.Groups, auth.DomainName, null, serviceParams), GetCredentials(auth.Username, auth.Password)));
     return groups;
 }
Exemplo n.º 4
0
 public XmlDocument GetGroupMembers(string groupName, string page, string numberOfRecords, SocialCastAuthDetails auth)
 {
     XmlDocument users = new XmlDocument();
     var serviceParams = new List<KeyValuePair<string, string>>();
     serviceParams.Add(new KeyValuePair<string, string>("per_page", numberOfRecords));
     serviceParams.Add(new KeyValuePair<string, string>("page", page));
     users.LoadXml(base.MakeServiceCalls(helper.GetSocialcastURL(ObjectType.GroupMembers, auth.DomainName, groupName, serviceParams), GetCredentials(auth.Username, auth.Password)));
     return users;
 }
Exemplo n.º 5
0
 public XmlDocument GetFollowers(string username, int page, int numberOfMessages, SocialCastAuthDetails auth)
 {
     XmlDocument followers = new XmlDocument();
     var serviceParams = new List<KeyValuePair<string, string>>();
     serviceParams.Add(new KeyValuePair<string, string>("per_page", numberOfMessages.ToString()));
     serviceParams.Add(new KeyValuePair<string, string>("page", page.ToString()));
     followers.XmlResolver = null;
     followers.LoadXml(base.MakeServiceCalls(helper.GetSocialcastURL(ObjectType.Followers, auth.DomainName, username, serviceParams), GetCredentials(auth.Username, auth.Password)));
     return followers;
 }
Exemplo n.º 6
0
 public XmlDocument GetCompanyStream(string numberOfMessages, string page, SocialCastAuthDetails auth)
 {
     XmlDocument streams = new XmlDocument();
     var serviceParams = new List<KeyValuePair<string, string>>();
     serviceParams.Add(new KeyValuePair<string, string>("per_page", numberOfMessages));
     serviceParams.Add(new KeyValuePair<string, string>("page", page));
     int companyStreamID = GetStreamIdbyStreamName("company stream", auth);
     streams.XmlResolver = null;
     streams.LoadXml(base.MakeServiceCalls(helper.GetSocialcastURL(ObjectType.StreamMessages, auth.DomainName, companyStreamID.ToString(), serviceParams), GetCredentials(auth.Username, auth.Password)));
     return streams;
 }
Exemplo n.º 7
0
 public XmlDocument GetStreamMessages(string streamName, string numberOfMessages, string page, string sinceWhen, SocialCastAuthDetails auth)
 {
     XmlDocument streams = new XmlDocument();
     var serviceParams = new List<KeyValuePair<string, string>>();
     serviceParams.Add(new KeyValuePair<string, string>("per_page", numberOfMessages));
     serviceParams.Add(new KeyValuePair<string, string>("page", page));
     if (sinceWhen != null)
         serviceParams.Add(new KeyValuePair<string, string>("since", sinceWhen));
     int GroupID = GetGroupIdByGroupName(streamName, auth);
     if (GroupID == 0)
         throw new GroupNotFoundException(streamName, String.Format("The Group {0} was not found. Please try again", streamName));
     serviceParams.Add(new KeyValuePair<string, string>("group_id", GroupID.ToString()));
     streams.LoadXml(base.MakeServiceCalls(helper.GetSocialcastURL(ObjectType.Messages, auth.DomainName, GroupID.ToString(), serviceParams), GetCredentials(auth.Username, auth.Password)));
     return streams;
 }
Exemplo n.º 8
0
 public XmlDocument GetMessage(string _messageID, SocialCastAuthDetails auth)
 {
     XmlDocument Message = new XmlDocument();
     Message.LoadXml(base.MakeServiceCalls(helper.GetSocialcastURL(ObjectType.MessagesById, auth.DomainName, _messageID), GetCredentials(auth.Username, auth.Password)));
     return Message;
 }
Exemplo n.º 9
0
        private int GetStreamIdbyStreamName(string _streamName, SocialCastAuthDetails auth)
        {
            int _streamID = 0;
            XmlDocument streams = new XmlDocument();
            streams.LoadXml(base.MakeServiceCalls(helper.GetSocialcastURL(ObjectType.Streams, auth.DomainName, null), GetCredentials(auth.Username, auth.Password)));

            foreach (XmlNode node in streams.SelectNodes("//stream"))
            {
                if (node.SelectSingleNode("group/groupname") != null && node.SelectSingleNode("group/groupname").InnerText.ToLower() == _streamName.ToLower())
                {
                    _streamID = int.Parse(node.SelectSingleNode("id").InnerText);
                    break;
                }
            }
            return _streamID;
        }
Exemplo n.º 10
0
        private int GetGroupIdByGroupName(string groupName, SocialCastAuthDetails auth)
        {
            int _groupId = 0;
            int _pageNumber = 1;
            bool moreItems = true;

            _groupId = GroupsQuery.QueryForGroupID(groupName);
            if (_groupId != 0)
                return _groupId;
            else
            {

                while (moreItems)
                {
                    XmlDocument group = new XmlDocument();
                    var serviceParams = new List<KeyValuePair<string, string>>();
                    serviceParams.Add(new KeyValuePair<string, string>("page", _pageNumber.ToString()));
                    serviceParams.Add(new KeyValuePair<string, string>("per_page", "500"));
                    group.LoadXml(base.MakeServiceCalls(helper.GetSocialcastURL(ObjectType.Groups, auth.DomainName, null, serviceParams), GetCredentials(auth.Username, auth.Password)));
                    if (group.SelectNodes("//groups/group") == null || group.SelectNodes("//groups/group").Count == 0)
                        moreItems = false;
                    else
                    {
                        foreach (XmlNode groupNode in group.SelectNodes("//groups/group"))
                        {
                            if (String.Compare(GetNodeInnerText(groupNode, "groupname"), groupName, true) == 0)
                            {
                                string id = GetNodeInnerText(groupNode, "id");
                                _groupId = Convert.ToInt32(id);
                                GroupsQuery.AddToDictionary(groupName, _groupId);
                                moreItems = false;
                                break;
                            }
                        }
                    }
                    _pageNumber++;
                }
                return _groupId;
            }
        }
Exemplo n.º 11
0
 public XmlDocument PostMessage(string title, string body, SocialCastAuthDetails auth)
 {
     string data = String.Format("message[title]={0}&message[body]={1}", HttpUtility.UrlEncode(title), HttpUtility.UrlEncode(body));
     XmlDocument update = new XmlDocument();
     update.LoadXml(base.MakeServiceCallsPOST(helper.GetSocialcastURL(ObjectType.Messages, auth.DomainName, null), GetCredentials(auth.Username, auth.Password), data));
     return update;
 }
Exemplo n.º 12
0
        public XmlDocument GetUsers(string searchString, SocialCastAuthDetails auth)
        {
            XmlDocument users = new XmlDocument();
            var serviceParams = new List<KeyValuePair<string, string>>();
            serviceParams.Add(new KeyValuePair<string, string>("q", searchString));

            users.LoadXml(base.MakeServiceCalls(helper.GetSocialcastURL(ObjectType.SearchUsers, auth.DomainName, null, serviceParams), GetCredentials(auth.Username, auth.Password)));
            return users;
        }
Exemplo n.º 13
0
 public XmlDocument GetStreamMessagesDirectly(string streamName, string numberOfMessages, string page, SocialCastAuthDetails auth)
 {
     XmlDocument streams = new XmlDocument();
     var serviceParams = new List<KeyValuePair<string, string>>();
     serviceParams.Add(new KeyValuePair<string, string>("per_page", numberOfMessages));
     serviceParams.Add(new KeyValuePair<string, string>("page", page));
     streams.LoadXml(base.MakeServiceCalls(helper.GetSocialcastURL(ObjectType.StreamMessages, auth.DomainName, streamName, serviceParams), GetCredentials(auth.Username, auth.Password)));
     return streams;
 }
Exemplo n.º 14
0
        static void Main(string[] args)
        {
            Credentials.ReadCredentials();

            InitAD();

            var auth = new SocialCastAuthDetails()
            {
                DomainName = Credentials.ScDomain,
                Username = Credentials.ScUsername,
                Password = Credentials.ScPassword
            };

            int page = 1;
            var xDoc = new APIAccessor().GetUsers("10", page.ToString(), auth);
            var quitterCount = 0;
            var usersPrSecondMovingAverage = new RRQueue(20);
            Console.Clear();
            var startTime = DateTime.Now;
            //	var _xDoc = new APIAccessor().GetUsers("niall", auth);
            var usersNode = xDoc.SelectSingleNode("users");
            bool usersLeft = usersNode != null && usersNode.HasChildNodes;
            using (var quitters = System.IO.File.CreateText("quitters.csv"))
            {
                while (usersLeft)
                {
                    int origRow = Console.CursorTop;
                    int origCol = Console.CursorLeft;
                    int index = 1;
                    foreach (XmlNode item in xDoc.GetElementsByTagName("user"))
                    {

                        //item.Dump();
                        string id = item.SelectSingleNode("id").InnerText;
                        string email = item.SelectSingleNode("contact-info/email").InnerText;
                        //bool terminated = bool.Parse(item.SelectSingleNode("terminated").InnerText);
                        string username = item.SelectSingleNode("username").InnerText;

                        Console.SetCursorPosition(0, 0);
                        var count = index + (page - 1)*10;
                        var percent = (int) (index/1373.0*100);
                        var seconds = (DateTime.Now - startTime).TotalSeconds;
                        var usersPrSecond = (count/seconds);
                        usersPrSecondMovingAverage.Enqueue(usersPrSecond);
                        var eta = DateTime.Now.AddSeconds((1373 - count) / usersPrSecondMovingAverage.Average);
                        Console.WriteLine("Tested {0} users of ~1373 ({1} %). {2:F2} users / sec. ETA {3}  ",
                            count, percent, usersPrSecondMovingAverage.Average, eta);
                        Console.Write("Found {0} quitters", quitterCount);

                        if (!DoesUserExist(email))
                        {
                            quitterCount++;
                            quitters.WriteLine("{0}; {1}; {2}; finnes ikke i AD", id, email, username);
                            quitters.Flush();
                        }
                        index++;
                    }
                    page++;
                    xDoc = new APIAccessor().GetUsers("10", page.ToString(), auth);
                    usersNode = xDoc.SelectSingleNode("users");
                    usersLeft = usersNode != null && usersNode.HasChildNodes;
                }
            }
            Console.ReadKey(true);
        }