Example #1
0
        /// <summary>
        /// Gets unposted draft bills
        /// </summary>
        /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
        /// <param name="collectionRequest">List of unposted draft bills</param>
        /// <returns>Returns list of unposted draft bills</returns>
        public DraftBillSearchReturnValue GetUnpostedDraftBills(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest)
        {
            DraftBillSearchReturnValue returnValue = null;

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oAccountService = new AccountsService();
                returnValue     = oAccountService.GetUnpostedDraftBills(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest);
            }
            else
            {
                returnValue         = new DraftBillSearchReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return(returnValue);
        }
Example #2
0
        /// <summary>
        /// Loads unposted draft bills on page load.
        /// </summary>
        /// <param name="startRow">Starting row for draft bills.</param>
        /// <param name="pageSize">Page size on grid view for unposted draft bills.</param>
        /// <param name="forceRefresh"></param>
        /// <returns>Returns all unposted draft bills.</returns>
        public DraftBillSearchItem[] LoadDraftBills(int startRow, int pageSize, bool forceRefresh)
        {
            AccountsServiceClient accountsService = null;

            DraftBillSearchItem[] draftBills = null;

            try
            {
                accountsService = new AccountsServiceClient();
                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.ForceRefresh = forceRefresh;
                collectionRequest.StartRow     = startRow;
                collectionRequest.RowCount     = pageSize;

                Guid logonId = ((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId;
                DraftBillSearchReturnValue returnValue = accountsService.GetUnpostedDraftBills(logonId, collectionRequest);

                if (returnValue.Success)
                {
                    _draftBillsRowCount = returnValue.UnpostedDraftBills.TotalRowCount;
                    draftBills          = returnValue.UnpostedDraftBills.Rows;
                }
                else
                {
                    throw new Exception(returnValue.Message);
                    //_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(draftBills);
        }
        /// <summary>
        /// Gets unposted draft bills 
        /// </summary>
        /// <param name="logonId">Logon id obtained when logging on to the logon service</param>
        /// <param name="collectionRequest">List of unposted draft bills</param>
        /// <returns>Returns list of unposted draft bills</returns>
        public DraftBillSearchReturnValue GetUnpostedDraftBills(Guid logonId, CollectionRequest collectionRequest)
        {
            DraftBillSearchReturnValue returnValue = new DraftBillSearchReturnValue();

            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 bills
                    DataListCreator<DraftBillSearchItem> dataListCreator = new DataListCreator<DraftBillSearchItem>();

                    // Declare an inline event (annonymous delegate) to read the
                    // dataset if it is required
                    dataListCreator.ReadDataSet += delegate(object Sender, ReadDataSetEventArgs e)
                    {
                        DsDraftBills dsDraftBills = SrvDraftBillLookup.GetUnPostedDraftBills();

                        DataSet dsUnpostedDraftBills = new DataSet();
                        dsUnpostedDraftBills.Tables.Add("UnpostedDraftBills");
                        dsUnpostedDraftBills.Tables["UnpostedDraftBills"].Columns.Add("DraftBillId", typeof(int));
                        dsUnpostedDraftBills.Tables["UnpostedDraftBills"].Columns.Add("DraftBillDate", typeof(DateTime));
                        dsUnpostedDraftBills.Tables["UnpostedDraftBills"].Columns.Add("UserName", typeof(string));
                        dsUnpostedDraftBills.Tables["UnpostedDraftBills"].Columns.Add("MatterReference", typeof(string));
                        dsUnpostedDraftBills.Tables["UnpostedDraftBills"].Columns.Add("DraftBillDescription", typeof(string));

                        DataView dvUnpostedDraftBills = new DataView(dsDraftBills.DraftBills);
                        if (dvUnpostedDraftBills.Count != 0)
                        {
                            string columnOrderByDraftBillsDate = Convert.ToString(dsDraftBills.DraftBills.Columns["DraftBillsDate"]);
                            dvUnpostedDraftBills.Sort = columnOrderByDraftBillsDate + " " + "asc";

                            foreach (DataRowView unpostedDraftBillsRowView in dvUnpostedDraftBills)
                            {
                                int draftBillId = (int)unpostedDraftBillsRowView.Row["DraftBillsId"];

                                Guid projectId = (Guid)unpostedDraftBillsRowView.Row["ProjectId"];
                                Guid userMemberId = (Guid)unpostedDraftBillsRowView.Row["UserMemberId"];

                                // Gets matter reference by project id
                                string matterReference = SrvMatterCommon.GetMatterReference(projectId);

                                // Inserts "-" in between matter reference
                                matterReference = matterReference.Insert(6, "-");

                                // Gets user name by member id
                                DsSystemUsers dsSystemUsers = SrvUserLookup.GetUser(userMemberId.ToString());

                                string userName = string.Empty;
                                if (dsSystemUsers.uvw_SystemUsers.Count > 0)
                                {
                                    userName = dsSystemUsers.uvw_SystemUsers[0].name;
                                }
                                else
                                {
                                    DsPersonDealing dsPersonDealing = SrvMatterLookup.GetPersonDealingLookup();
                                    for (int index = 0; index < dsPersonDealing.uvw_PersonDealingLookup.Count; index++)
                                    {
                                        if (dsPersonDealing.uvw_PersonDealingLookup[index].MemberID == userMemberId)
                                        {
                                            userName = dsPersonDealing.uvw_PersonDealingLookup[index].name;
                                        }
                                    }
                                }

                                DateTime draftBillDate = (DateTime)unpostedDraftBillsRowView.Row["DraftBillsDate"];
                                string draftBillDescription = (string)unpostedDraftBillsRowView.Row["PostingDescDetails"];

                                // Create dataset for sorted unposted draft bills
                                dsUnpostedDraftBills.Tables["UnpostedDraftBills"].Rows.Add(draftBillId,
                                                                                            draftBillDate.ToShortDateString(),
                                                                                            userName,
                                                                                            matterReference,
                                                                                            draftBillDescription);

                            }
                        }

                        e.DataSet = dsUnpostedDraftBills;
                    };

                    // Create the data list
                    returnValue.UnpostedDraftBills = dataListCreator.Create(logonId,
                        // Give the query a name so it can be cached
                        "GetUnpostedDraftBills",
                        // Tell it the query criteria used so if the cache is accessed
                        // again it knows if it is the same query
                        string.Empty,
                        collectionRequest,
                        // Import mappings to map the dataset row fields to the data
                        // list entity properties
                        new ImportMapping[] {
                                            new ImportMapping("DraftBillId", "DraftBillId"),
                                            new ImportMapping("DraftBillDate", "DraftBillDate"),
                                            new ImportMapping("UserName", "UserName"),
                                            new ImportMapping("MatterReference", "MatterReference"),
                                            new ImportMapping("DraftBillDescription","DraftBillDescription")
                            }
                        );
                }
                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>
 /// Gets unposted draft bills 
 /// </summary>
 /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
 /// <param name="collectionRequest">List of unposted draft bills</param>
 /// <returns>Returns list of unposted draft bills</returns>
 public DraftBillSearchReturnValue GetUnpostedDraftBills(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest)
 {
     DraftBillSearchReturnValue returnValue = null;
     if (Functions.ValidateIWSToken(oHostSecurityToken))
     {
         oAccountService = new AccountsService();
         returnValue = oAccountService.GetUnpostedDraftBills(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest);
     }
     else
     {
         returnValue = new DraftBillSearchReturnValue();
         returnValue.Success = false;
         returnValue.Message = "Invalid Token";
     }
     return returnValue;
 }