Exemplo n.º 1
0
        /// <summary>
        /// Loads disbursements by project id
        /// </summary>
        /// <param name="startRow"></param>
        /// <param name="pageSize"></param>
        /// <param name="forceRefresh"></param>
        /// <returns></returns>
        public DisbursementSearchItem[] LoadDisbursements(int startRow, int pageSize, bool forceRefresh)
        {
            AccountsServiceClient accountsService = null;

            DisbursementSearchItem[] disbursements = null;

            try
            {
                if (Session[SessionName.ProjectId] != null)
                {
                    accountsService = new AccountsServiceClient();
                    CollectionRequest collectionRequest = new CollectionRequest();
                    collectionRequest.ForceRefresh = forceRefresh;
                    collectionRequest.StartRow     = startRow;
                    collectionRequest.RowCount     = pageSize;

                    Guid projectId = (Guid)Session[SessionName.ProjectId];
                    Guid logonId   = ((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId;
                    DisbursementsSearchReturnValue returnValue = accountsService.GetDisbursementsDetails(logonId, collectionRequest, projectId);

                    if (returnValue.Success)
                    {
                        _disbursementsRowCount = returnValue.Disbursements.TotalRowCount;
                        disbursements          = returnValue.Disbursements.Rows;
                    }
                    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();
                    }
                }
            }

            return(disbursements);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads disbursement details by project id
        /// </summary>
        /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
        /// <param name="accounts">Retrieves project id to load disbursement details.</param>
        /// <returns>Loads disbursement details by project id</returns>
        public DisbursementsSearchReturnValue GetDisbursementsDetails(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, Guid projectId)
        {
            DisbursementsSearchReturnValue returnValue = null;

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oAccountService = new AccountsService();
                returnValue     = oAccountService.GetDisbursementsDetails(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, projectId);
            }
            else
            {
                returnValue         = new DisbursementsSearchReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return(returnValue);
        }
        /// <summary>
        /// Loads disbursement details by project id
        /// </summary>
        /// <param name="logonId">Logon id obtained when logging on to the logon service</param>
        /// <param name="accounts">Retrieves project id to load disbursement details.</param>
        /// <returns>Loads disbursement details by project id</returns>
        public DisbursementsSearchReturnValue GetDisbursementsDetails(Guid logonId, CollectionRequest collectionRequest, Guid projectId)
        {
            DisbursementsSearchReturnValue returnValue = new DisbursementsSearchReturnValue();

            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:
                        case DataConstants.UserType.ThirdParty:
                            throw new Exception("Access denied");
                        default:
                            throw new Exception("Access denied");
                    }

                    // Create a data list creator for a list of matters
                    DataListCreator<DisbursementSearchItem> dataListCreator = new DataListCreator<DisbursementSearchItem>();

                    // Declare an inline event (annonymous delegate) to read the
                    // dataset if it is required
                    dataListCreator.ReadDataSet += delegate(object Sender, ReadDataSetEventArgs e)
                    {
                        DsDisbLedgerTransactions dsDisbLedgerTransactions = SrvDisbLedgerLookup.GetDisbursementsLedgerTransactions(projectId);

                        DataSet dsDisbursements = new DataSet();
                        dsDisbursements.Tables.Add("Disbursements");
                        dsDisbursements.Tables["Disbursements"].Columns.Add("PostingId", typeof(int));
                        dsDisbursements.Tables["Disbursements"].Columns.Add("PostingDate", typeof(DateTime));
                        dsDisbursements.Tables["Disbursements"].Columns.Add("PostingReference", typeof(string));
                        dsDisbursements.Tables["Disbursements"].Columns.Add("PostingDisbursementType", typeof(string));
                        dsDisbursements.Tables["Disbursements"].Columns.Add("PostingDescription", typeof(string));
                        dsDisbursements.Tables["Disbursements"].Columns.Add("PostingPaid", typeof(string));
                        dsDisbursements.Tables["Disbursements"].Columns.Add("PostingVAT", typeof(string));
                        dsDisbursements.Tables["Disbursements"].Columns.Add("Amount", typeof(decimal));
                        dsDisbursements.Tables["Disbursements"].Columns.Add("BillingStatus", typeof(string));
                        dsDisbursements.Tables["Disbursements"].Columns.Add("Claimed", typeof(decimal));
                        dsDisbursements.Tables["Disbursements"].Columns.Add("Balance", typeof(decimal));

                        DataView dvDisbursements = new DataView(dsDisbLedgerTransactions.uvw_DisbLedgerTransactions);
                        if (dvDisbursements.Count != 0)
                        {
                            string columnOrderByPostingDate = Convert.ToString(dsDisbLedgerTransactions.uvw_DisbLedgerTransactions.Columns["postingDetailsDate"]);
                            dvDisbursements.Sort = columnOrderByPostingDate + " " + "asc";

                            string postingPaid = string.Empty;
                            string unbilledStatus = "Billed";
                            decimal balance = decimal.Zero;
                            decimal unbilled = decimal.Zero;
                            decimal claimed = decimal.Zero;
                            decimal amount = decimal.Zero;

                            foreach (DataRowView disbursementRowView in dvDisbursements)
                            {
                                int postingId = Convert.ToInt32(disbursementRowView.Row["PostingId"].ToString().Trim());
                                DateTime postingDate = (DateTime)disbursementRowView.Row["PostingDetailsDate"];
                                string postingReference = (string)disbursementRowView.Row["PostingDetailsRef"].ToString();
                                string postingDisbursementType = (string)disbursementRowView.Row["DisbTypeDescription"].ToString();
                                string postingDescription = (string)disbursementRowView.Row["PostingDetailsDescription"].ToString();
                                int disbursementStatusId = ((int)disbursementRowView.Row["DisbStatusId"]);

                                switch (disbursementStatusId)
                                {
                                    case 1:
                                        postingPaid = "P";
                                        break;
                                    case 2:
                                        postingPaid = "U";
                                        break;
                                    case 3:
                                        postingPaid = "C";
                                        break;
                                    case 4:
                                        postingPaid = "I";
                                        break;
                                    case 5:
                                        postingPaid = "X";
                                        break;
                                    case 6:
                                        postingPaid = "x";
                                        break;
                                    case 7:
                                        postingPaid = "P";
                                        break;
                                }

                                string postingVAT = string.Empty;
                                int VATRateId = ((int)disbursementRowView.Row["VatRateId"]);
                                if (VATRateId == 1)
                                {
                                    postingVAT = "N";
                                }
                                else
                                {
                                    postingVAT = "V";
                                }

                                amount = (decimal)disbursementRowView.Row["DisbLedgerMasterAmount"] + (decimal)disbursementRowView.Row["DisbLedgerMasterVatAmount"];
                                unbilled = (decimal)disbursementRowView.Row["DisbLedgerMasterAmount"] + (decimal)disbursementRowView.Row["DisbLedgerMasterVatAmount"] - (decimal)disbursementRowView.Row["BillDisbAllocAmount"];
                                claimed = (decimal)disbursementRowView.Row["ClaimedDisbs"];

                                balance = balance + unbilled;
                                amount = Decimal.Round(amount, 2);
                                unbilled = Decimal.Round(unbilled, 2);
                                claimed = Decimal.Round(claimed, 2);
                                balance = Decimal.Round(balance, 2);

                                unbilledStatus = (unbilled != Decimal.Zero ? unbilled.ToString("0.00") : "Billed");

                                dsDisbursements.Tables["Disbursements"].Rows.Add(postingId,
                                                                                 postingDate,
                                                                                 postingReference,
                                                                                 postingDisbursementType,
                                                                                 postingDescription,
                                                                                 postingPaid,
                                                                                 postingVAT,
                                                                                 amount.ToString("0.00"),
                                                                                 unbilledStatus,
                                                                                 claimed.ToString("0.00"),
                                                                                 balance.ToString("0.00"));
                            }
                        }

                        e.DataSet = dsDisbursements;
                    };

                    // Create the data list
                    returnValue.Disbursements = dataListCreator.Create(logonId,
                        // Give the query a name so it can be cached
                        "GetDisbursementsDetails",
                        // Tell it the query criteria used so if the cache is accessed
                        // again it knows if it is the same query
                        projectId.ToString(),
                        collectionRequest,
                        // Import mappings to map the dataset row fields to the data
                        // list entity properties
                        new ImportMapping[] {
                                            new ImportMapping("PostingId", "PostingId"),
                                            new ImportMapping("PostingDate", "PostingDate"),
                                            new ImportMapping("PostingReference", "PostingReference"),
                                            new ImportMapping("PostingType", "PostingDisbursementType"),
                                            new ImportMapping("PostingDescription","PostingDescription"),
                                            new ImportMapping("PostingPaid", "PostingPaid"),
                                            new ImportMapping("PostingVAT","PostingVAT"),
                                            new ImportMapping("Amount","Amount"),
                                            new ImportMapping("BillingStatus","BillingStatus"),
                                            new ImportMapping("Balance","Balance"),
                                            new ImportMapping("Claimed","Claimed")
                            }
                        );

                    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 disbursement details by project id
 /// </summary>
 /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
 /// <param name="accounts">Retrieves project id to load disbursement details.</param>
 /// <returns>Loads disbursement details by project id</returns>
 public DisbursementsSearchReturnValue GetDisbursementsDetails(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, Guid projectId)
 {
     DisbursementsSearchReturnValue returnValue = null;
     if (Functions.ValidateIWSToken(oHostSecurityToken))
     {
         oAccountService = new AccountsService();
         returnValue = oAccountService.GetDisbursementsDetails(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, projectId);
     }
     else
     {
         returnValue = new DisbursementsSearchReturnValue();
         returnValue.Success = false;
         returnValue.Message = "Invalid Token";
     }
     return returnValue;
 }