コード例 #1
0
        protected void saveButton_Click(object sender, EventArgs e)
        {
            try
            {

                if (accessToken.Text.Length == 0) { throw new Exception("Invalid Access Token"); }
                if (accessSecret.Text.Length == 0) { throw new Exception("Invalid Access Secret"); }
                if (realmId.Text.Length == 0) { throw new Exception("Invalid Realm ID"); }

                IppRealmOAuthProfile ippRealmOAuthProfile = new IppRealmOAuthProfile();
                ippRealmOAuthProfile.realmId = realmId.Text;
                switch (dataSource.SelectedValue.ToLower())
                {
                    case "qbo": ippRealmOAuthProfile.dataSource = (int)IntuitServicesType.QBO; break;
                    case "qbd": ippRealmOAuthProfile.dataSource = (int)IntuitServicesType.QBD; break;
                }
                ippRealmOAuthProfile.accessToken = accessToken.Text;
                ippRealmOAuthProfile.accessSecret = accessSecret.Text;
                ippRealmOAuthProfile.expirationDateTime = DateTime.Now;

                RestHelper.getEmployeeList(ippRealmOAuthProfile);

                ippRealmOAuthProfile.Save();
            }
            catch
            {
                errorMessage.Visible = true;
            }
        }
コード例 #2
0
 public static void clearProfile(IppRealmOAuthProfile profile)
 {
     profile.accessToken = "";
     profile.accessSecret = "";
     profile.realmId = "";
     profile.dataSource = -1;
     profile.Save();
 }
コード例 #3
0
 public static void clearProfile(IppRealmOAuthProfile profile)
 {
     profile.accessToken  = "";
     profile.accessSecret = "";
     profile.realmId      = "";
     profile.dataSource   = -1;
     profile.Save();
 }
コード例 #4
0
        protected void saveButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (accessToken.Text.Length == 0)
                {
                    throw new Exception("Invalid Access Token");
                }
                if (accessSecret.Text.Length == 0)
                {
                    throw new Exception("Invalid Access Secret");
                }
                if (realmId.Text.Length == 0)
                {
                    throw new Exception("Invalid Realm ID");
                }

                IppRealmOAuthProfile ippRealmOAuthProfile = new IppRealmOAuthProfile();
                ippRealmOAuthProfile.realmId = realmId.Text;
                switch (dataSource.SelectedValue.ToLower())
                {
                case "qbo": ippRealmOAuthProfile.dataSource = (int)IntuitServicesType.QBO; break;

                case "qbd": ippRealmOAuthProfile.dataSource = (int)IntuitServicesType.QBD; break;
                }
                ippRealmOAuthProfile.accessToken        = accessToken.Text;
                ippRealmOAuthProfile.accessSecret       = accessSecret.Text;
                ippRealmOAuthProfile.expirationDateTime = DateTime.Now;

                RestHelper.getEmployeeList(ippRealmOAuthProfile);

                ippRealmOAuthProfile.Save();
            }
            catch
            {
                errorMessage.Visible = true;
            }
        }
コード例 #5
0
        public static IppRealmOAuthProfile Read()
        {
            if (!File.Exists("ipp.xml"))
            {
                return(new IppRealmOAuthProfile());
            }
            string encryptedRealmProfile = File.ReadAllText("ipp.xml", Encoding.Unicode);

            if (encryptedRealmProfile.Length == 0)
            {
                return(new IppRealmOAuthProfile());
            }
            string               decryptedRealmProfile = StringCipher.Decrypt(encryptedRealmProfile, "<FILL_IN_PASSWORD_OR_OTHER_UNIQUE_APPLICATION_VALUE>");
            TextReader           textReader            = new StringReader(decryptedRealmProfile);
            XmlSerializer        xmlSerializer         = new XmlSerializer((new IppRealmOAuthProfile()).GetType());
            IppRealmOAuthProfile ippRealmOAuthProfile  = (IppRealmOAuthProfile)xmlSerializer.Deserialize(textReader);

            if (ippRealmOAuthProfile.expirationDateTime.Subtract(DateTime.Now).TotalDays < 30)
            {
                ippRealmOAuthProfile = callReconnect(ippRealmOAuthProfile);
                ippRealmOAuthProfile.Save();
            }
            return(ippRealmOAuthProfile);
        }