protected void Page_Load(object sender, EventArgs e)
        {
            _configurationCloud = new ApiConfiguration(SessionManager.DeveloperKey, SessionManager.DeveloperSecret, SessionManager.CallBackUrl);
            _oAuthKeyService    = new OAuthKeyService();
            if (_oAuthKeyService.OAuthResponse == null)
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(Server.MapPath("~/info.xml"));

                XmlNode nodeObj = doc.SelectSingleNode("/user/code");
                //string id = nodeObj["Project"].InnerText; // For inner text


                var oauthService = new MYOB.AccountRight.SDK.Services.OAuthService(_configurationCloud);
                _oAuthKeyService.OAuthResponse = oauthService.GetTokens(nodeObj.Attributes["value"].Value);
            }

            SessionManager.MyOAuthKeyServiceAutoBackup = _oAuthKeyService;
            SessionManager.MyConfigurationAutoBackup   = _configurationCloud;

            var cfsCloud = new MYOB.AccountRight.SDK.Services.CompanyFileService(_configurationCloud, null, _oAuthKeyService);

            CompanyFile[] companyFiles = cfsCloud.GetRange();
            CompanyFile   companyFile  = companyFiles.FirstOrDefault(a => a.Id == Guid.Parse(SessionManager.CompanyId));

            SessionManager.SelectedCompanyFileAutoBackup = companyFile;
            ICompanyFileCredentials credentials = new CompanyFileCredentials(SessionManager.CompanyUserId, SessionManager.CompanyPassword);

            SessionManager.MyCredentialsAutoBackup = credentials;
            HandleSales();
            HandlePurchase();
        }
示例#2
0
 private void GetTokenForMYOB(Credentials crendetials)
 {
     try
     {
         _configurationCloud            = new ApiConfiguration(crendetials.ConsumerKey, crendetials.ConsumerSecret, "http://desktop");
         _oAuthKeyService               = new MYOBOAuthKeyService();
         _oAuthKeyService.OAuthResponse = null;
         if (_oAuthKeyService.OAuthResponse == null)
         {
             var    oauthService = new OAuthService(_configurationCloud);
             string _accessCode  = OAuthLogin.GetAuthorizationCode(_configurationCloud);
             _oAuthKeyService.OAuthResponse =
                 oauthService.GetTokens(_accessCode);
             var frmLogin = new CompanyFileLogin();
             frmLogin.ShowDialog(this);
             if (frmLogin.Username.Length > 0)
             {
                 AccountingIntegrationConfigManager.Instance.SaveCompanyFileCredentials(frmLogin.Username, frmLogin.Password);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#3
0
        public ActionResult OAuthCallback()
        {
            var requestUri = HttpContextFactory.Current.Request.Url;
            var queries    = HttpUtility.ParseQueryString(requestUri.Query);
            var code       = queries["code"];

            var service    = new OAuthService(APIConfiguration);
            var oauthToken = service.GetTokens(code);

            KeyService = new SimpleOAuthKeyService()
            {
                OAuthResponse = oauthToken
            };


            if (OAuthInformation.Token == null)
            {
                OAuthInformation.Token = new OAuthToken();
            }
            OAuthInformation.Token.AccessToken  = KeyService.OAuthResponse.AccessToken;
            OAuthInformation.Token.RefreshToken = KeyService.OAuthResponse.RefreshToken;
            OAuthInformation.Token.ExpiresIn    = KeyService.OAuthResponse.ExpiresIn;
            //OAuthInformation.RequestAccessToken();

            return(RedirectToAction("Index", "CommandCentre"));
        }
 public void GetToken(Credentials inCredentials, string inFilename)
 {
     try
     {
         _configurationCloud = new ApiConfiguration(inCredentials.ConsumerKey, inCredentials.ConsumerSecret, "http://desktop");
         _oAuthKeyService    = new MYOBOAuthKeyService();
         var    dateTimeNow   = DateTime.UtcNow;
         var    lastTokenTime = _oAuthKeyService.OAuthResponse.ReceivedTime;
         double days          = (dateTimeNow - lastTokenTime).TotalDays;
         string days1         = days.ToString();
         ServiceLogger.Log(string.Format(@"days: {0}", days1));
         if (days < 365)
         {
             if (_oAuthKeyService.OAuthResponse.HasExpired)
             {
                 var oauthService = new OAuthService(_configurationCloud);
                 _oAuthKeyService.OAuthResponse = oauthService.RenewTokens(_oAuthKeyService.OAuthResponse);
                 ServiceLogger.Log("Token Renewed");
             }
             else
             {
                 ServiceLogger.Log("Token not Expired");
             }
             MYOBCompanyFiles companyFiles = new MYOBCompanyFiles(inCredentials);
             companyFiles.FetchFile(_configurationCloud, null, _oAuthKeyService, inFilename);
         }
     }
     catch (Exception exception)
     {
         ServiceLogger.LogException("Exception in GetTokens", exception);
     }
 }
 public DisplayAccountsViewModel(IOAuthKeyService keyService)
 {
     _keyService = keyService;
     Accounts = new ObservableCollection<Account>();
     Customers = new ObservableCollection<CustomerViewModel>();
     Invoices = new ObservableCollection<Invoice>();
     RawCustomers = new List<Contact>();
 }
        public void Initialise(IApiConfiguration configuration, CompanyFile companyFile,
                               ICompanyFileCredentials credentials, IOAuthKeyService oAuthKeyService)
        {
            // Add any initialization after the InitializeComponent() call.
            MyConfiguration   = configuration;
            MyCompanyFile     = companyFile;
            MyCredentials     = credentials;
            MyOAuthKeyService = oAuthKeyService;

            Text = string.Format("{0} - {1}", companyFile.Name, companyFile.Uri);
        }
        public void Initialise(IApiConfiguration configuration, CompanyFile companyFile,
                               ICompanyFileCredentials credentials, IOAuthKeyService oAuthKeyService)
        {
            // Add any initialization after the InitializeComponent() call.
            MyConfiguration = configuration;
            MyCompanyFile = companyFile;
            MyCredentials = credentials;
            MyOAuthKeyService = oAuthKeyService;

            Text = string.Format("{0} - {1}", companyFile.Name, companyFile.Uri);
        }
示例#8
0
 public void FetchFile(IApiConfiguration configurationCloud, IWebRequestFactory webRequestFactory, IOAuthKeyService keyService, string inFilename)
 {
     try
     {
         ServiceLogger.Log("In fetch File");
         FileName           = inFilename;
         ConfigurationCloud = configurationCloud;
         MyOAuthKeyService  = keyService;
         var cfsCloud = new CompanyFileService(configurationCloud, null, keyService);
         cfsCloud.GetRange(OnComplete, OnError);
     }
     catch (Exception ex)
     {
         ServiceLogger.LogException("Exception in FetchFile", ex);
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                _configurationCloud = new ApiConfiguration(SessionManager.DeveloperKey, SessionManager.DeveloperSecret, SessionManager.CallBackUrl);
                _oAuthKeyService    = new OAuthKeyService();

                SessionManager.MyConfiguration = _configurationCloud;

                if (_oAuthKeyService.OAuthResponse == null && string.IsNullOrEmpty(Request.QueryString["code"]))

                {
                    string url = string.Format("{0}?client_id={1}&redirect_uri={2}&scope={3}&response_type=code", SessionManager.CsOAuthServer,
                                               _configurationCloud.ClientId, HttpUtility.UrlEncode(_configurationCloud.RedirectUrl), SessionManager.CsOAuthScope);
                    Response.Redirect(url);
                }
                else
                {
                    if (_oAuthKeyService.OAuthResponse == null)
                    {
                        var oauthService = new OAuthService(_configurationCloud);
                        _oAuthKeyService.OAuthResponse = oauthService.GetTokens(Request.QueryString["code"]);
                        SessionManager.Code            = Request.QueryString["code"];

                        XmlDocument doc = new XmlDocument();
                        doc.Load(Server.MapPath("~/info.xml"));

                        XmlNode nodeObj = doc.SelectSingleNode("/user/code");
                        //string id = nodeObj["Project"].InnerText; // For inner text
                        nodeObj.Attributes["value"].Value = Request.QueryString["code"];

                        doc.Save(Server.MapPath("~/info.xml"));
                    }
                    // SessionManager.Code =  Request.QueryString["code"];
                    SessionManager.MyOAuthKeyService = _oAuthKeyService;
                    Response.Redirect("CompanyListing.aspx");
                }
            }
        }
        protected override void OnStart(string[] args)
        {
            // Update the service state to Start Pending.
            ServiceStatus serviceStatus = new ServiceStatus();

            serviceStatus.dwCurrentState = ServiceState.SERVICE_START_PENDING;
            serviceStatus.dwWaitHint     = 300000;
            SetServiceStatus(this.ServiceHandle, ref serviceStatus);
            System.Timers.Timer timer = new System.Timers.Timer();
            timer.Interval = 60000 * 60 * SessionManager.TimerInHours; // 60 seconds
            timer.Elapsed += new System.Timers.ElapsedEventHandler(this.OnTimer);
            timer.Start();
            _configurationCloud = new ApiConfiguration(SessionManager.DeveloperKey, SessionManager.DeveloperSecret, "http://localhost:60669/Default");
            _oAuthKeyService    = new OAuthKeyService();
            //if (_oAuthKeyService.OAuthResponse == null)
            //{
            var oauthService = new MYOB.AccountRight.SDK.Services.OAuthService(_configurationCloud);

            _oAuthKeyService.OAuthResponse = oauthService.GetTokens(SessionManager.Code);
            //  }

            SessionManager.MyOAuthKeyService = _oAuthKeyService;
            SessionManager.MyConfiguration   = _configurationCloud;

            var cfsCloud = new MYOB.AccountRight.SDK.Services.CompanyFileService(SessionManager.MyConfiguration, null, SessionManager.MyOAuthKeyService);

            CompanyFile[] companyFiles = cfsCloud.GetRange();
            CompanyFile   companyFile  = companyFiles.FirstOrDefault(a => a.Id == Guid.Parse(SessionManager.CompanyId));

            SessionManager.SelectedCompanyFile = companyFile;
            ICompanyFileCredentials credentials = new CompanyFileCredentials(SessionManager.CompanyUserId, SessionManager.CompanyPassword);

            SessionManager.MyCredentials = credentials;
            // OnTimer();
            // Update the service state to Running.
            serviceStatus.dwCurrentState = ServiceState.SERVICE_RUNNING;
            SetServiceStatus(this.ServiceHandle, ref serviceStatus);
            OnTimer(null, null);
        }
示例#11
0
        /// <summary>
        /// Event that is called when the form loads
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks></remarks>
        private void CompanyFilesLoad(object sender, EventArgs e)
        {
            try
            {
                ShowSpinner();

                //If developer key  enable (see above) and set useCVloud to true the following section manages OAuth token and accessing cloud service
                if (UseCloud)
                {
                    _configurationCloud = new ApiConfiguration(DeveloperKey, DeveloperSecret, "http://desktop");
                    _oAuthKeyService    = new OAuthKeyService();

                    //Get tokens if not stored
                    if (_oAuthKeyService.OAuthResponse == null)
                    {
                        var oauthService = new OAuthService(_configurationCloud);
                        _oAuthKeyService.OAuthResponse =
                            oauthService.GetTokens(OAuthLogin.GetAuthorizationCode(_configurationCloud));
                    }

                    // Load all files from cloud and local simultaneously
                    var cfsCloud = new CompanyFileService(_configurationCloud, null, _oAuthKeyService);
                    cfsCloud.GetRange(OnComplete, OnError);
                }

                _configurationLocal = new ApiConfiguration(LocalApiUrl);
                var cfsLocal = new CompanyFileService(_configurationLocal);
                cfsLocal.GetRange(OnComplete, OnError);

                //' The following two lines can be called to run synchronously rather than async
                //_companyFiles = cfs.GetRange()
                //dgvCompanyFiles.DataSource = _companyFiles
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 /// <summary>
 /// Initialise a service that can call the  <see cref="CalculateDiscountsFees"/> operation
 /// </summary>
 /// <param name="configuration">The configuration required to communicate with the API service</param>
 /// <param name="webRequestFactory">A custom implementation of the <see cref="WebRequestFactory"/>, if one is not supplied a default <see cref="WebRequestFactory"/> will be used.</param>
 /// <param name="keyService">An implementation of a service that will store/persist the OAuth tokens required to communicate with the cloud based API at http://api.myob.com/accountright </param>
 public CalculateDiscountsFeesService(IApiConfiguration configuration, IWebRequestFactory webRequestFactory = null, IOAuthKeyService keyService = null)
     : base(configuration, webRequestFactory, keyService)
 {
 }
 public CustomerViewModel(IOAuthKeyService keyService)
 {
     _keyService = keyService;
     _picture = Default;
 }
示例#14
0
 /// <summary>
 /// Initialise a service that can use <see cref="Job"/> resources
 /// </summary>
 /// <param name="configuration">The configuration required to communicate with the API service</param>
 /// <param name="webRequestFactory">A custom implementation of the <see cref="WebRequestFactory"/>, if one is not supplied a default <see cref="WebRequestFactory"/> will be used.</param>
 /// <param name="keyService">An implementation of a service that will store/persist the OAuth tokens required to communicate with the cloud based API at http://api.myob.com/accountright </param>
 public JobService(IApiConfiguration configuration, IWebRequestFactory webRequestFactory = null, IOAuthKeyService keyService = null)
     : base(configuration, webRequestFactory, keyService)
 {
 }
示例#15
0
 /// <summary>
 /// Initialise a service that can use <see cref="Statement"/> resources
 /// </summary>
 /// <param name="configuration">The configuration required to communicate with the API service</param>
 /// <param name="webRequestFactory">A custom implementation of the <see cref="WebRequestFactory"/>, if one is not supplied a default <see cref="WebRequestFactory"/> will be used.</param>
 /// <param name="keyService">An implementation of a service that will store/persist the OAuth tokens required to communicate with the cloud based API at http://api.myob.com/accountright </param>
 public StatementService(IApiConfiguration configuration, IWebRequestFactory webRequestFactory, IOAuthKeyService keyService)
     : base(configuration, webRequestFactory, keyService)
 {
 }
 /// <summary>
 /// Initialise a service that can retrieve <see cref="VersionInfo"/> resources
 /// </summary>
 /// <param name="configuration">The configuration required to communicate with the API service</param>
 /// <param name="webRequestFactory">A custom implementation of the <see cref="WebRequestFactory"/>, if one is not supplied a default <see cref="WebRequestFactory"/> will be used.</param>
 /// <param name="keyService">An implementation of a service that will store/persist the OAuth tokens required to communicate with the cloud based API at http://api.myob.com/accountright </param>
 public VersionInfoService(IApiConfiguration configuration, IWebRequestFactory webRequestFactory, IOAuthKeyService keyService = null) 
     : base(configuration, webRequestFactory, keyService)
 {
 }
示例#17
0
 /// <summary>
 /// Initialise base instance
 /// </summary>
 /// <param name="configuration">The configuration required to communicate with the API service</param>
 /// <param name="webRequestFactory">A custom implementation of the <see cref="WebRequestFactory"/>, if one is not supplied a default <see cref="WebRequestFactory"/> will be used.</param>
 /// <param name="keyService">An implementation of a service that will store/persist the OAuth tokens required to communicate with the cloud based API at http://api.myob.com/accountright </param>
 protected ReadableService(IApiConfiguration configuration, IWebRequestFactory webRequestFactory, IOAuthKeyService keyService)
     : base(configuration, webRequestFactory, keyService)
 {
 }
 /// <summary>
 ///  Initialise a service that can use <see cref="EmployeePaymentSummaryLH"/> resources
 /// </summary>
 /// <param name="configuration">The configuration required to communicate with the API service</param>
 /// <param name="webRequestFactory">A custom implementation of the <see cref="WebRequestFactory"/>, if one is not supplied a default <see cref="WebRequestFactory"/> will be used.</param>
 /// <param name="keyService">An implementation of a service that will store/persist the OAuth tokens required to communicate with the cloud based API at http://api.myob.com/accountright </param>
 public EmployeePaymentSummaryLHService(IApiConfiguration configuration, IWebRequestFactory webRequestFactory = null, IOAuthKeyService keyService = null)
     : base(configuration, webRequestFactory, keyService)
 {
 }
示例#19
0
 public MutableServiceTestClass(IApiConfiguration configuration, IWebRequestFactory webRequestFactory, IOAuthKeyService keyService)
     : base(configuration, webRequestFactory, keyService)
 {
 }
 /// <summary>
 /// Initialise a service that can fetch <see cref="BalanceSheetSummary"/> information
 /// </summary>
 /// <param name="configuration">The configuration required to communicate with the API service</param>
 /// <param name="webRequestFactory">A custom implementation of the <see cref="WebRequestFactory"/>, if one is not supplied a default <see cref="WebRequestFactory"/> will be used.</param>
 /// <param name="keyService">An implementation of a service that will store/persist the OAuth tokens required to communicate with the cloud based API at http://api.myob.com/accountright </param>
 public BalanceSheetSummaryService(IApiConfiguration configuration, IWebRequestFactory webRequestFactory = null, IOAuthKeyService keyService = null)
     : base(configuration, webRequestFactory, keyService)
 {
 }
 public TestServiceBase(IApiConfiguration configuration, IWebRequestFactory webRequestFactory, IOAuthKeyService keyService) 
     : base(configuration, webRequestFactory, keyService)
 {
 }
示例#22
0
 public CompanyFileService(IApiConfiguration configuration, IWebRequestFactory webRequestFactory = null, IOAuthKeyService keyService = null)
     : base(configuration, webRequestFactory, keyService)
 {
 }
 /// <summary>
 /// Initialise a service that can use <see cref="InventoryAdjustment"/> resources
 /// </summary>
 /// <param name="configuration">The configuration required to communicate with the API service</param>
 /// <param name="webRequestFactory">A custom implementation of the <see cref="WebRequestFactory"/>, if one is not supplied a default <see cref="WebRequestFactory"/> will be used.</param>
 /// <param name="keyService">An implementation of a service that will store/persist the OAuth tokens required to communicate with the cloud based API at http://api.myob.com/accountright </param>
 public InventoryAdjustmentService(IApiConfiguration configuration, IWebRequestFactory webRequestFactory = null, IOAuthKeyService keyService = null)
     : base(configuration, webRequestFactory, keyService)
 {
 }
 public void TestSetup()
 {
     _configuration = Substitute.For<IApiConfiguration>();
     _webRequestFactory = Substitute.For<IWebRequestFactory>();
     _keyService = Substitute.For<IOAuthKeyService>();
 }
        public ActionResult OAuthCallback()
        {
            var requestUri = HttpContextFactory.Current.Request.Url;
            var queries = HttpUtility.ParseQueryString(requestUri.Query);
            var code = queries["code"];

            var service = new OAuthService(APIConfiguration);
            var oauthToken = service.GetTokens(code);
            KeyService = new SimpleOAuthKeyService() {OAuthResponse = oauthToken};

            if (OAuthInformation.Token == null)
                OAuthInformation.Token = new OAuthToken();
            OAuthInformation.Token.AccessToken = KeyService.OAuthResponse.AccessToken;
            OAuthInformation.Token.RefreshToken = KeyService.OAuthResponse.RefreshToken;
            OAuthInformation.Token.ExpiresIn = KeyService.OAuthResponse.ExpiresIn;
            //OAuthInformation.RequestAccessToken();

            return RedirectToAction("Index", "CommandCentre");
        }
 /// <summary>
 /// Initialise a service that can use <see cref="Timesheet"/> resources
 /// </summary>
 /// <param name="configuration">The configuration required to communicate with the API service</param>
 /// <param name="webRequestFactory">A custom implementation of the <see cref="WebRequestFactory"/>, if one is not supplied a default <see cref="WebRequestFactory"/> will be used.</param>
 /// <param name="keyService">An implementation of a service that will store/persist the OAuth tokens required to communicate with the cloud based API at http://api.myob.com/accountright </param>
 public TimesheetService(IApiConfiguration configuration, IWebRequestFactory webRequestFactory = null, IOAuthKeyService keyService = null)
     : base(configuration, webRequestFactory, keyService)
 {
 }
示例#27
0
 protected ServiceBase(IApiConfiguration configuration, IWebRequestFactory webRequestFactory, IOAuthKeyService keyService)
 {
     Configuration     = configuration;
     WebRequestFactory = webRequestFactory ?? new WebRequestFactory();
     _keyService       = keyService;
 }
 public TestPhotoService(IApiConfiguration configuration, IWebRequestFactory webRequestFactory, IOAuthKeyService keyService)
     : base(configuration, webRequestFactory, keyService)
 {
 }
示例#29
0
 /// <summary>
 /// Initialise a service that can call the <see cref="SupplierPaymentRecordWithDiscountsAndFees"/> operation
 /// </summary>
 /// <param name="configuration">The configuration required to communicate with the API service</param>
 /// <param name="webRequestFactory">A custom implementation of the <see cref="WebRequestFactory"/>, if one is not supplied a default <see cref="WebRequestFactory"/> will be used.</param>
 /// <param name="keyService">An implementation of a service that will store/persist the OAuth tokens required to communicate with the cloud based API at http://api.myob.com/accountright </param>
 public SupplierPaymentRecordWithDiscountsAndFeesService(IApiConfiguration configuration, IWebRequestFactory webRequestFactory = null, IOAuthKeyService keyService = null)
     : base(configuration, webRequestFactory, keyService)
 {
 }
 /// <summary>
 /// Initialise a service that can use <see cref="ItemPurchaseOrder"/> resources
 /// </summary>
 /// <param name="configuration">The configuration required to communicate with the API service</param>
 /// <param name="webRequestFactory">A custom implementation of the <see cref="WebRequestFactory"/>, if one is not supplied a default <see cref="WebRequestFactory"/> will be used.</param>
 /// <param name="keyService">An implementation of a service that will store/persist the OAuth tokens required to communicate with the cloud based API at http://api.myob.com/accountright </param>
 public ItemPurchaseOrderService(IApiConfiguration configuration, IWebRequestFactory webRequestFactory = null, IOAuthKeyService keyService = null)
     : base(configuration, webRequestFactory, keyService)
 {
 }
示例#31
0
 /// <summary>
 /// Initialise a service that can use <see cref="PayrollSuperannuationFund"/> resources
 /// </summary>
 /// <param name="configuration">The configuration required to communicate with the API service</param>
 /// <param name="webRequestFactory">A custom implementation of the <see cref="WebRequestFactory"/>, if one is not supplied a default <see cref="WebRequestFactory"/> will be used.</param>
 /// <param name="keyService">An implementation of a service that will store/persist the OAuth tokens required to communicate with the cloud based API at http://api.myob.com/accountright </param>
 public PayrollSuperannuationFundService(IApiConfiguration configuration, IWebRequestFactory webRequestFactory = null, IOAuthKeyService keyService = null)
     : base(configuration, webRequestFactory, keyService)
 {
 }
 /// <summary>
 /// Initialise a service that can use <see cref="EmployeePayrollDetails"/> resources
 /// </summary>
 /// <param name="configuration">The configuration required to communicate with the API service</param>
 /// <param name="webRequestFactory">A custom implementation of the <see cref="WebRequestFactory"/>, if one is not supplied a default <see cref="WebRequestFactory"/> will be used.</param>
 /// <param name="keyService">An implementation of a service that will store/persist the OAuth tokens required to communicate with the cloud based API at http://api.myob.com/accountright </param>
 public EmployeePayrollDetailsService(IApiConfiguration configuration, IWebRequestFactory webRequestFactory = null, IOAuthKeyService keyService = null)
     : base(configuration, webRequestFactory, keyService)
 {
 }
        /// <summary>
        /// Event that is called when the form loads
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks></remarks>
        private void CompanyFilesLoad(object sender, EventArgs e)
        {
            try
            {
                ShowSpinner();

                //If developer key  enable (see above) and set useCVloud to true the following section manages OAuth token and accessing cloud service
                if (UseCloud)
                {
                    _configurationCloud = new ApiConfiguration(DeveloperKey, DeveloperSecret, "http://desktop");
                    _oAuthKeyService = new OAuthKeyService();

                    //Get tokens if not stored
                    if (_oAuthKeyService.OAuthResponse == null)
                    {
                        var oauthService = new OAuthService(_configurationCloud);
                        _oAuthKeyService.OAuthResponse =
                            oauthService.GetTokens(OAuthLogin.GetAuthorizationCode(_configurationCloud));
                    }

                    // Load all files from cloud and local simultaneously
                    var cfsCloud = new CompanyFileService(_configurationCloud, null, _oAuthKeyService);
                    cfsCloud.GetRange(OnComplete, OnError);
                }

                _configurationLocal = new ApiConfiguration(LocalApiUrl);
                var cfsLocal = new CompanyFileService(_configurationLocal);
                cfsLocal.GetRange(OnComplete, OnError);

                //' The following two lines can be called to run synchronously rather than async
                //_companyFiles = cfs.GetRange()
                //dgvCompanyFiles.DataSource = _companyFiles
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 /// <summary>
 /// Initialise a service that can use <see cref="ProfessionalInvoice"/> resources
 /// </summary>
 /// <param name="configuration">The configuration required to communicate with the API service</param>
 /// <param name="webRequestFactory">A custom implementation of the <see cref="WebRequestFactory"/>, if one is not supplied a default <see cref="WebRequestFactory"/> will be used.</param>
 /// <param name="keyService">An implementation of a service that will store/persist the OAuth tokens required to communicate with the cloud based API at http://api.myob.com/accountright </param>
 public ProfessionalInvoiceService(IApiConfiguration configuration, IWebRequestFactory webRequestFactory = null, IOAuthKeyService keyService = null)
     : base(configuration, webRequestFactory, keyService)
 {
 }
示例#35
0
 /// <summary>
 /// Initialise a service that can use <see cref="MiscellaneousOrder"/> resources
 /// </summary>
 /// <param name="configuration">The configuration required to communicate with the API service</param>
 /// <param name="webRequestFactory">A custom implementation of the <see cref="WebRequestFactory"/>, if one is not supplied a default <see cref="WebRequestFactory"/> will be used.</param>
 /// <param name="keyService">An implementation of a service that will store/persist the OAuth tokens required to communicate with the cloud based API at http://api.myob.com/accountright </param>
 public MiscellaneousOrderService(IApiConfiguration configuration, IWebRequestFactory webRequestFactory = null, IOAuthKeyService keyService = null)
     : base(configuration, webRequestFactory, keyService)
 {
 }
 /// <summary>
 /// Initialise a base instance
 /// </summary>
 /// <param name="configuration">The configuration required to communicate with the API service</param>
 /// <param name="webRequestFactory">A custom implementation of the <see cref="WebRequestFactory"/>, if one is not supplied a default <see cref="WebRequestFactory"/> will be used.</param>
 /// <param name="keyService">An implementation of a service that will store/persist the OAuth tokens required to communicate with the cloud based API at http://api.myob.com/accountright </param>
 protected GetOnlyService(IApiConfiguration configuration, IWebRequestFactory webRequestFactory = null, IOAuthKeyService keyService = null)
     : base(configuration, webRequestFactory, keyService)
 {
 }
 /// <summary>
 /// Initialise a service that can retrieve <see cref="VersionInfo"/> resources
 /// </summary>
 /// <param name="configuration">The configuration required to communicate with the API service</param>
 /// <param name="webRequestFactory">A custom implementation of the <see cref="WebRequestFactory"/>, if one is not supplied a default <see cref="WebRequestFactory"/> will be used.</param>
 /// <param name="keyService">An implementation of a service that will store/persist the OAuth tokens required to communicate with the cloud based API at http://api.myob.com/accountright </param>
 public VersionInfoService(IApiConfiguration configuration, IWebRequestFactory webRequestFactory, IOAuthKeyService keyService = null)
     : base(configuration, webRequestFactory, keyService)
 {
 }
 /// <summary>
 /// Initialise a service that can use <see cref="PayrollCategoryWage"/> resources
 /// </summary>
 /// <param name="configuration">The configuration required to communicate with the API service</param>
 /// <param name="webRequestFactory">A custom implementation of the <see cref="WebRequestFactory"/>, if one is not supplied a default <see cref="WebRequestFactory"/> will be used.</param>
 /// <param name="keyService">An implementation of a service that will store/persist the OAuth tokens required to communicate with the cloud based API at http://api.myob.com/accountright </param>
 public PayrollCategoryWageService(IApiConfiguration configuration, IWebRequestFactory webRequestFactory = null, IOAuthKeyService keyService = null)
     : base(configuration, webRequestFactory, keyService)
 {
 }
 /// <summary>
 /// Initialise a service that can use <see cref="BillAttachmentsData"/> resources
 /// </summary>
 /// <param name="configuration">The configuration required to communicate with the API service</param>
 /// <param name="webRequestFactory">A custom implementation of the <see cref="WebRequestFactory"/>, if one is not supplied a default <see cref="WebRequestFactory"/> will be used.</param>
 /// <param name="keyService">An implementation of a service that will store/persist the OAuth tokens required to communicate with the cloud based API at http://api.myob.com/accountright </param>
 public BillAttachmentsDataService(IApiConfiguration configuration, string Layout = null, string UID = null, IWebRequestFactory webRequestFactory = null, IOAuthKeyService keyService = null)
     : base(configuration, webRequestFactory, keyService)
 {
     _layout = Layout;
     _uid    = Guid.Parse(UID);
 }
示例#40
0
 public MYOBInvoiceController(IApiConfiguration configurationCloud, IOAuthKeyService myOAuthKeyService, ICompanyFileCredentials credentials)
 {
     MyOAuthKeyService  = myOAuthKeyService;
     ConfigurationCloud = configurationCloud;
     Credentials        = credentials;
 }
 public LoginViewModel(IOAuthKeyService keyService)
 {
     _keyService = keyService;
     _showBrowser = true;
     CompanyFiles = new ObservableCollection<CompanyFileViewModel>();
 }