Roustam Akhmetov

Roustam Akhmetov

  • NA
  • 12
  • 4.2k

Calling methods from another project

May 29 2022 6:11 AM

Hi,

I have two projects in my solution, one for console app and another for a web app. I need to re-use some code from the console app in my web app. I've pasted classes from my console app into my web app as links.

These are the methods I have in my web app:

namespace Export
{
    public partial class XeroExport
    {
         public async Task Call_BalanceSheet(DateTime reportDate, int entityID, DateTime periodStart, DateTime periodEnd, AccountingApi apiInstance, string xeroTenantId, string accessToken, string connectDB, string dataDB)
        {
        ...
        }

    }
}
namespace Export
{
    public partial class XeroExport
    {
        public async Task<AccountingApi> Xero_Connect(string clientId, string clientSecret, int entityID)
        {
        ...
        }
    ...
    }
    ...
}

 Below is what I have in my web app project. I need to call the following methods:
Cleanup
Call_BalanceSheet
XeroExport
I am getting errors like: "Error CS0103 The name 'Cleanup' does not exist in the current context WebReports C:\...\WebReports\ReportsSelection.aspx.cs 109 Active"

namespace WebReports
{
    public partial class ReportsSelection : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            String reportName = ReportName.SelectedItem.Value;
        ...
            RunSelectedReport(reportDate, reportName, entityID, await Xero_Connect(clientId, clientSecret, entityID), tenantId);
        }
        public void RunSelectedReport(DateTime reportDate, string reportName,int entityId, AccountingApi apiInstance, string xeroTenantId)
        {
            if (reportName == "Balance Sheet")
            {
                Cleanup(null, null, entityId, "[dbo].[myTable]", dataDB);
                Call_BalanceSheet(reportDate, entityId, startDate, endDate, apiInstance, xeroTenantId, accessToken, connectDB, dataDB);
            }
            
        }
        ...
    }
}

namespace Export
{
    public partial class XeroExport: ApiWrapper
    {
        public void DBExport(DateTime reportDate, int entityId, AccountingApi apiInstance, string xeroTenantId)
        {
        ...
        }

        public void Cleanup(Nullable<DateTime> periodStart, Nullable<DateTime> periodEnd, int entityId, String tableName, String dataDB)
        {
        ...
        }
    }
}

Any ideas?

Thanks.


Answers (3)