Exemple #1
0
        /// <summary>
        /// Loads financial information about office, client and deposit balances
        /// by project id
        /// </summary>
        private void SetFinancialInfo()
        {
            AccountsServiceClient accountsService = null;

            try
            {
                accountsService = new AccountsServiceClient();
                Guid projectId = (Guid)Session[SessionName.ProjectId];
                Guid logonId   = ((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId;
                FinancialInfoReturnValue returnValue = accountsService.GetFinancialInfoByProjectId(logonId, projectId);

                if (returnValue.Success)
                {
                    _txtOffice.Text               = returnValue.OfficeBalance;
                    _txtClient.Text               = returnValue.ClientBalance;
                    _txtDeposit.Text              = returnValue.DepositBalance;
                    _txtClientFinancialInfo.Text  = returnValue.ClientBalance;
                    _txtOfficeFinancialInfo.Text  = returnValue.OfficeBalance;
                    _txtDepositFinancialInfo.Text = returnValue.DepositBalance;

                    // Sets warning message, if paid disbursements amount less than zero
                    if (!string.IsNullOrEmpty(returnValue.WarningMessage))
                    {
                        _lblMessage.Text = returnValue.WarningMessage;
                    }
                }
                else
                {
                    _lblMessage.CssClass = "errorMessage";
                    _lblMessage.Text     = returnValue.Message;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (accountsService != null)
                {
                    if (accountsService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        accountsService.Close();
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Loads financial information for office, client and deposit by project id.
        /// </summary>
        /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
        /// <param name="projectId">Project id usedto retrieve financial information</param>
        /// <returns>Retrieves financial information by project id.</returns>
        public FinancialInfoReturnValue GetFinancialInfoByProjectId(HostSecurityToken oHostSecurityToken, Guid projectId)
        {
            FinancialInfoReturnValue returnValue = null;

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oAccountService = new AccountsService();
                returnValue     = oAccountService.GetFinancialInfoByProjectId(Functions.GetLogonIdFromToken(oHostSecurityToken), projectId);
            }
            else
            {
                returnValue         = new FinancialInfoReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return(returnValue);
        }
        /// <summary>
        /// Loads financial information for office, client and deposit by project id.
        /// </summary>
        /// <param name="logonId">Logon id obtained when logging on to the logon service</param>
        /// <param name="projectId">Project id usedto retrieve financial information</param>
        /// <returns>Retrieves financial information by project id.</returns>
        public FinancialInfoReturnValue GetFinancialInfoByProjectId(Guid logonId, Guid projectId)
        {
            FinancialInfoReturnValue returnValue = new FinancialInfoReturnValue();

            try
            {
                // Get the logged on user from the current logons and add their
                // ApplicationSettings the list of concurrent sessions.
                Host.LoadLoggedOnUser(logonId);

                try
                {
                    Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid);
                    switch (UserInformation.Instance.UserType)
                    {
                        case DataConstants.UserType.Staff:
                            // Can do everything
                            break;
                        case DataConstants.UserType.Client:
                            if (!SrvMatterCommon.WebAllowedToAccessMatter(projectId))
                                throw new Exception("Access denied");
                            break;
                        case DataConstants.UserType.ThirdParty:
                            throw new Exception("Access denied");
                        default:
                            throw new Exception("Access denied");
                    }

                    decimal clientTotalBalance = decimal.Zero;
                    decimal officeTotalBalance = decimal.Zero;
                    decimal depositTotalBalance = decimal.Zero;

                    if (projectId != DataConstants.DummyGuid)
                    {
                        clientTotalBalance = SrvCledgerCommon.SumCledgerAmount(projectId);
                        depositTotalBalance = SrvDledgerCommon.SumDledgerAmount(projectId);

                        decimal billsLedgerAmount = SrvBledgerCommon.SumBledgerAmount(projectId);
                        decimal disbursementLedgerAmount = SrvDisbLedgerCommon.SumDisbLedgerAmount(projectId);
                        decimal disbursementLedgerVATAmount = SrvDisbLedgerCommon.SumDisbLedgerVATAmount(projectId);
                        decimal billsWaveOffLedgerAmount = SrvBillWoLedgerCommon.SumBillWoLedgerrAmount(projectId);
                        decimal payLedgerAmount = SrvPayLedgerCommon.SumPayLedgerAmount(projectId);
                        decimal unpaidDisbursementsAmount = SrvDisbLedgerCommon.SumUnpaidBilledDisbLedgerAmount(projectId);
                        decimal unpaidBilledDisbursementsVATAmount = SrvDisbLedgerCommon.SumUnpaidBilledDisbLedgerVATAmount(projectId);

                        officeTotalBalance += billsLedgerAmount;
                        officeTotalBalance += disbursementLedgerAmount;
                        officeTotalBalance += disbursementLedgerVATAmount;
                        officeTotalBalance += billsWaveOffLedgerAmount;
                        officeTotalBalance += payLedgerAmount;
                        unpaidDisbursementsAmount += unpaidBilledDisbursementsVATAmount;

                        unpaidDisbursementsAmount = decimal.Round(unpaidDisbursementsAmount, 2);

                        if (officeTotalBalance - unpaidDisbursementsAmount < decimal.Zero)
                        {
                            returnValue.WarningMessage = "Office Account Potentially in Credit due to unpaid Billed Disbs";
                        }
                    }

                    returnValue.ClientBalance = Convert.ToString(decimal.Round(clientTotalBalance, 2));
                    returnValue.OfficeBalance = Convert.ToString(decimal.Round(officeTotalBalance, 2));
                    returnValue.DepositBalance = Convert.ToString(decimal.Round(depositTotalBalance, 2));

                    returnValue.Success = true;
                }
                finally
                {
                    // Remove the logged on user's ApplicationSettings from the
                    // list of concurrent sessions
                    Host.UnloadLoggedOnUser();
                }
            }
            catch (System.Data.SqlClient.SqlException)
            {
                returnValue.Success = false;
                returnValue.Message = Functions.SQLErrorMessage;
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Message = ex.Message;
            }

            return returnValue;
        }
 /// <summary>
 /// Loads financial information for office, client and deposit by project id.
 /// </summary>
 /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
 /// <param name="projectId">Project id usedto retrieve financial information</param>
 /// <returns>Retrieves financial information by project id.</returns>
 public FinancialInfoReturnValue GetFinancialInfoByProjectId(HostSecurityToken oHostSecurityToken, Guid projectId)
 {
     FinancialInfoReturnValue returnValue = null;
     if (Functions.ValidateIWSToken(oHostSecurityToken))
     {
         oAccountService = new AccountsService();
         returnValue = oAccountService.GetFinancialInfoByProjectId(Functions.GetLogonIdFromToken(oHostSecurityToken), projectId);
     }
     else
     {
         returnValue = new FinancialInfoReturnValue();
         returnValue.Success = false;
         returnValue.Message = "Invalid Token";
     }
     return returnValue;
 }