public ApiContext GetAuthorizedContext(PelicanContext pelicanContext, Guid companyFileId) { var keyService = new OAuthKeyService(this); var configuration = new ApiConfiguration(pelicanContext.ClientKey, pelicanContext.ClientSecret, pelicanContext.RedirectUrl); // get companyfiles var cfService = new CompanyFileService(configuration, null, keyService); var companyFiles = cfService.GetRange(); // select var companyFile = companyFiles.FirstOrDefault(_ => _.Id == companyFileId); // fetch accounts var credentials = new CompanyFileCredentials("Administrator", ""); return new ApiContext { ApiConfiguration = configuration, CompanyFileCredentials = credentials, KeyService = keyService, CompanyFile = companyFile, }; }
public void InitService( CompanyFile companyFile, SDK.CompanyFileCredentials credentials, SDK.ApiConfiguration myConfiguration, OAuthKeyService myOAuthKeyService) { myCompanyFile = companyFile; myCredentials = credentials; myService = new ItemBillService(myConfiguration, null, myOAuthKeyService); }
internal CompanyFileWithResources Login(CompanyFile companyFile, string userId, string password) { var _login = new LoginContext { Username = userId, Password = password }; var _service = new CompanyFileService(APIConfiguration, null, KeyService); CompanyFileResource = _service.Get(companyFile, _login); CompanyCredential = new CompanyFileCredentials(userId, password); return CompanyFileResource; }
private void DgvCompanyFilesCellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { //Get the selected company file CompanyFile companyFile = ((CompanyFile[]) dgvCompanyFiles.DataSource)[e.RowIndex]; //Get configuration that matches server where file is IApiConfiguration config = companyFile.Uri.GetLeftPart(UriPartial.Path).ToLower().Contains(LocalApiUrl) ? _configurationLocal : _configurationCloud; //Get the credentials for the database var frmLogin = new LoginForm(); frmLogin.ShowDialog(this); if (frmLogin.Username.Length > 0) { ICompanyFileCredentials credentials = new CompanyFileCredentials(frmLogin.Username, frmLogin.Password); //load the Invoice List var frmInvoiceList = new InvoiceListForm(); frmInvoiceList.Initialise(config, companyFile, credentials, _oAuthKeyService); frmInvoiceList.Show(); } }