Exemplo n.º 1
0
        public void GetMemberInbox()
        {
            Dictionary <string, string> messageHeaders = new Dictionary <string, string>();

            XmlHttpProvider provider = new XmlHttpProvider("https://api.yourmembership.com/");

            YMSDK.ApiManager manager = new YMSDK.ApiManager(provider);
            manager.ApiKeyPublic = "9FB80E52-49C5-4B31-9AE6-08D83F065897";
            manager.ApiKeySa     = "B4226439-485F-49EF-A183-37319519A0FA";
            manager.SaPasscode   = "04iHL9sU5g24";
            manager.Version      = "2.30";

            //Create session for the current user
            YMSDK.ApiResponse response = manager.SessionCreate();

            //Authenticate the user for the current session
            response = manager.AuthAuthenticate("vijaysaini", "priyank1");
            //response = manager.AuthAuthenticate("priyankmittal", "priyank1");

            if (response.ErrorCode == YMSDK.ApiErrorCode.NoError)
            {
                //Optional, store the ID or MemberID of the Authenticated User for later use
                string memberGuid = response.MethodResults.GetNamedItem("ID").Value;
                string memberID   = response.MethodResults.GetNamedItem("WebsiteID").Value;

                //Get Inbox messages for this user
                //response = manager.MemberProfileGet();
                var timestamp = DateTime.Now.ToString("yyyy-MM-dd HH mm ss");
                //2008 - 01 - 01 00:00:00
                response = manager.SaPeopleAllGetIDs(DateTime.Now, Convert.ToInt32(memberID));
                if (response.ErrorCode == YMSDK.ApiErrorCode.NoError)
                {
                    //Display the messages to the user
                    ApiMethodResults results = response.MethodResults;

                    if (results.Items.Count > 0)
                    {
                        foreach (DataItem message in results.Items)
                        {
                            messageHeaders.Add(
                                message.GetNamedItem("MessageID").Value,
                                message.GetNamedItem("Subject").Value
                                );
                        }
                    }
                }
            }

            //Console.WriteLine(string.Format("Fetched {0} messages.", messageHeaders.Count));
            Console.WriteLine(response);
            Console.ReadLine();
        }
Exemplo n.º 2
0
        public void GetMemberData(YMSDK.ApiResponse response, YMSDK.ApiManager manager, IEnumerable <string> newGuids)
        {
            MemberProfile       profile    = null;
            List <MemberMaster> newMembers = new List <MemberMaster>();

            foreach (var item in newGuids)
            {
                response = manager.SaPeopleProfileGet(item);

                if (response.ErrorCode == ApiErrorCode.NoError)
                {
                    //Get person profile
                    profile = response.MethodResults.ConvertTo <MemberProfile>();
                    newMembers.Add(new MemberMaster()
                    {
                        MemberID              = Convert.ToInt32(profile.WebsiteID),
                        WebsiteID             = Convert.ToInt32(profile.WebsiteID),
                        GUID                  = profile.ID,
                        MemberUserName        = profile.Username,
                        Email                 = profile.EmailAddr,
                        FirstName             = profile.FirstName,
                        LastName              = profile.LastName,
                        Company               = profile.Employer,
                        MemberType            = profile.EmpPhAreaCode,
                        HomeAddress1          = profile.EmpAddrLines,
                        City                  = profile.EmpCity,
                        Location              = profile.EmpLocation,
                        Country               = profile.EmpCountry,
                        Phone                 = profile.EmpPhone,
                        EmployeeName          = profile.FirstName,
                        MemberSuspended       = profile.Membership,
                        IsYBpaymentCompleted  = false,
                        IsYBStepsCompleted    = false,
                        IsGBpaymentCompleted  = false,
                        IsGBStepsCompleted    = false,
                        IsBBpaymentCompleted  = false,
                        IsBBStepsCompleted    = false,
                        IsTOIpaymentCompleted = false,
                        IsTOIStepsCompleted   = false
                    });
                }
            }
            db.MemberMasters.AddRange(newMembers);
            db.SaveChanges();
        }