/// <summary> /// Loads write off reversal time transactions. /// </summary> /// <param name="startRow"></param> /// <param name="pageSize"></param> /// <param name="forceRefresh"></param> /// <returns>Returns write off reversal time transactions.</returns> public TimeLedgerSearchItem[] LoadWriteOffReversalTimeTransactions(int startRow, int pageSize, bool forceRefresh) { AccountsServiceClient accountsService = null; TimeLedgerSearchItem[] writeOffReversalTimeTransactions = 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; TimeLedgerSearchReturnValue returnValue = accountsService.GetWriteOffReversalTimeTransactions(logonId, collectionRequest, projectId); if (returnValue.Success) { _writeOffReversalTimeTransactionsRowCount = returnValue.TimeTransactions.TotalRowCount; writeOffReversalTimeTransactions = returnValue.TimeTransactions.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(writeOffReversalTimeTransactions); }
/// <summary> /// Loads write off time transactions by project id /// </summary> /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param> /// <param name="collectionRequest">Loads listof write off time transactions</param> /// <param name="projectId">To load write off transactions.</param> /// <returns>Loads write off time transactions</returns> public TimeLedgerSearchReturnValue GetWriteOffReversalTimeTransactions(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, Guid projectId) { TimeLedgerSearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oAccountService = new AccountsService(); returnValue = oAccountService.GetWriteOffReversalTimeTransactions(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, projectId); } else { returnValue = new TimeLedgerSearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return(returnValue); }
/// <summary> /// Loads write off time transactions by project id /// </summary> /// <param name="logonId">Logon id obtained when logging on to the logon service</param> /// <param name="collectionRequest">Loads listof write off time transactions</param> /// <param name="projectId">To load write off transactions.</param> /// <returns>Loads write off time transactions</returns> public TimeLedgerSearchReturnValue GetWriteOffTimeTransactions(Guid logonId, CollectionRequest collectionRequest, Guid projectId) { TimeLedgerSearchReturnValue returnValue = new TimeLedgerSearchReturnValue(); 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<TimeLedgerSearchItem> dataListCreator = new DataListCreator<TimeLedgerSearchItem>(); // Declare an inline event (annonymous delegate) to read the // dataset if it is required dataListCreator.ReadDataSet += delegate(object Sender, ReadDataSetEventArgs e) { DsTimeWoffGroupedTransactions dsTimeWoffGroupedTransactions = SrvTimeWoffLookup.GetTimeWoffGroupedTransactions(projectId); DataSet dsTimeWriteOffTransactions = new DataSet(); dsTimeWriteOffTransactions.Tables.Add("TimeWriteOffTransactions"); dsTimeWriteOffTransactions.Tables["TimeWriteOffTransactions"].Columns.Add("Postingid", typeof(int)); dsTimeWriteOffTransactions.Tables["TimeWriteOffTransactions"].Columns.Add("PostingDate", typeof(DateTime)); dsTimeWriteOffTransactions.Tables["TimeWriteOffTransactions"].Columns.Add("PostingReference", typeof(string)); dsTimeWriteOffTransactions.Tables["TimeWriteOffTransactions"].Columns.Add("PostingDescription", typeof(string)); dsTimeWriteOffTransactions.Tables["TimeWriteOffTransactions"].Columns.Add("Time", typeof(string)); dsTimeWriteOffTransactions.Tables["TimeWriteOffTransactions"].Columns.Add("Charge", typeof(decimal)); dsTimeWriteOffTransactions.Tables["TimeWriteOffTransactions"].Columns.Add("Cost", typeof(decimal)); dsTimeWriteOffTransactions.Tables["TimeWriteOffTransactions"].Columns.Add("CostBalance", typeof(decimal)); DataView dvTimeWriteOffTransactions = new DataView(dsTimeWoffGroupedTransactions.uvw_TimeWoffGroupedTransactions); if (dvTimeWriteOffTransactions.Count != 0) { string columnOrderByPostingDate = Convert.ToString(dsTimeWoffGroupedTransactions.uvw_TimeWoffGroupedTransactions.Columns["PostingDetailsDate"]); dvTimeWriteOffTransactions.Sort = columnOrderByPostingDate + " " + "asc"; decimal chargeAmount = decimal.Zero; decimal costAmount = decimal.Zero; foreach (DataRowView timeWriteOffTransactionsRowView in dvTimeWriteOffTransactions) { if ((string)timeWriteOffTransactionsRowView.Row["PostingTypesRef"].ToString().Trim() == "TWO") { int postingId = Convert.ToInt32(timeWriteOffTransactionsRowView.Row["PostingId"]); DateTime postingDate = (DateTime)timeWriteOffTransactionsRowView.Row["PostingDetailsDate"]; string postingReference = (string)timeWriteOffTransactionsRowView.Row["PostingDetailsRef"].ToString(); string postingDescription = (string)timeWriteOffTransactionsRowView.Row["PostingDetailsDescription"].ToString(); chargeAmount = (decimal)timeWriteOffTransactionsRowView.Row["TimeWoffMasterChargeAmount"]; costAmount = (decimal)timeWriteOffTransactionsRowView.Row["TimeWoffMasterCostAmount"]; string time = this.ConvertUnits((int)timeWriteOffTransactionsRowView.Row["TimeWoffMintues"], ApplicationSettings.Instance.TimeUnits); //create datatable of time write off transactions dsTimeWriteOffTransactions.Tables["TimeWriteOffTransactions"].Rows.Add(postingId, postingDate.ToShortDateString(), postingReference, postingDescription, time, chargeAmount.ToString("0.00"), costAmount.ToString("0.00")); } } } e.DataSet = dsTimeWriteOffTransactions; }; // Create the data list returnValue.TimeTransactions = dataListCreator.Create(logonId, // Give the query a name so it can be cached "GetWriteOffTimeTransactions", // 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("Time", "Time"), new ImportMapping("Charge","Charge"), new ImportMapping("Cost","Cost"), new ImportMapping("PostingDescription","PostingDescription") } ); } 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 all the bills by project id /// </summary> /// <param name="logonId">Logon id obtained when logging on to the logon service</param> /// <param name="projectId">To load all the bills</param> /// <returns>Loads all the bills by project id</returns> public TimeLedgerSearchReturnValue GetTimeLedger(Guid logonId, CollectionRequest collectionRequest, string timeFilter, Guid projectId) { TimeLedgerSearchReturnValue returnValue = new TimeLedgerSearchReturnValue(); 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<TimeLedgerSearchItem> dataListCreator = new DataListCreator<TimeLedgerSearchItem>(); // Declare an inline event (annonymous delegate) to read the // dataset if it is required dataListCreator.ReadDataSet += delegate(object Sender, ReadDataSetEventArgs e) { NetTimeTransactionsReturnValue totalTimeTransactions = new NetTimeTransactionsReturnValue(); DsTimeTransactions dsTimeTransactions = SrvTimeLookup.GetTimeTransactions(projectId, timeFilter, false); DataSet dsAllTimeTransactions = new DataSet(); dsAllTimeTransactions.Tables.Add("AllTimeTransactions"); dsAllTimeTransactions.Tables["AllTimeTransactions"].Columns.Add("TimeId", typeof(int)); dsAllTimeTransactions.Tables["AllTimeTransactions"].Columns.Add("TimeDate", typeof(DateTime)); dsAllTimeTransactions.Tables["AllTimeTransactions"].Columns.Add("TimeType", typeof(string)); dsAllTimeTransactions.Tables["AllTimeTransactions"].Columns.Add("FeeEarnerReference", typeof(string)); dsAllTimeTransactions.Tables["AllTimeTransactions"].Columns.Add("Time", typeof(string)); dsAllTimeTransactions.Tables["AllTimeTransactions"].Columns.Add("TotalTimeElapsed", typeof(int)); dsAllTimeTransactions.Tables["AllTimeTransactions"].Columns.Add("Cost", typeof(decimal)); dsAllTimeTransactions.Tables["AllTimeTransactions"].Columns.Add("CostBalance", typeof(decimal)); dsAllTimeTransactions.Tables["AllTimeTransactions"].Columns.Add("Charge", typeof(decimal)); dsAllTimeTransactions.Tables["AllTimeTransactions"].Columns.Add("ChargeBalance", typeof(decimal)); int timeElapsed = 0; decimal cost = decimal.Zero; decimal costBalance = decimal.Zero; decimal charge = decimal.Zero; decimal chargeBalance = decimal.Zero; DataView dvAllTimeTransactions = new DataView(dsTimeTransactions.uvw_TimeTransactions); if (dvAllTimeTransactions.Count != 0) { string columnOrderByPostingDate = Convert.ToString(dsTimeTransactions.uvw_TimeTransactions.Columns["TimeDate"]); dvAllTimeTransactions.Sort = columnOrderByPostingDate + " " + "asc"; foreach (DataRowView allTimeTransactionsRowView in dvAllTimeTransactions) { int timeId = Convert.ToInt32(allTimeTransactionsRowView.Row["TimeId"].ToString()); DateTime timeDate = (DateTime)allTimeTransactionsRowView.Row["TimeDate"]; string timeType = (string)allTimeTransactionsRowView.Row["TimeTypeDescription"].ToString(); string time = this.ConvertUnits((int)allTimeTransactionsRowView.Row["TimeElapsed"], ApplicationSettings.Instance.TimeUnits); timeElapsed = timeElapsed + (int)allTimeTransactionsRowView.Row["TimeElapsed"]; int totalTimeElapsed = timeElapsed; string feeEarnerReference = (string)allTimeTransactionsRowView.Row["feeRef"].ToString(); cost = (decimal)allTimeTransactionsRowView.Row["TimeCost"]; charge = (decimal)allTimeTransactionsRowView.Row["TimeCharge"]; costBalance = costBalance + cost; chargeBalance = chargeBalance + charge; cost = Decimal.Round(cost, 2); charge = Decimal.Round(charge, 2); chargeBalance = Decimal.Round(chargeBalance, 2); costBalance = Decimal.Round(costBalance, 2); if ((Convert.ToDecimal(allTimeTransactionsRowView.Row["ClaimedChargeAmount"]) == Convert.ToDecimal(allTimeTransactionsRowView.Row["TimeCharge"])) && (Convert.ToDecimal(allTimeTransactionsRowView.Row["ClaimedCostAmount"]) == Convert.ToDecimal(allTimeTransactionsRowView.Row["TimeCost"])) && (Convert.ToInt32(allTimeTransactionsRowView.Row["ClaimedCount"]) > 0)) { // Adds time transaction details to dataset after calculations dsAllTimeTransactions.Tables["AllTimeTransactions"].Rows.Add(timeId, timeDate.ToShortDateString(), timeType, feeEarnerReference, time, totalTimeElapsed, cost.ToString("0.00"), costBalance.ToString("0.00"), charge.ToString("0.00"), chargeBalance.ToString("0.00")); } else if ((int)allTimeTransactionsRowView.Row["WoffCount"] > 0) { // Time is wrtten off! // Adds time transaction details to dataset after calculations dsAllTimeTransactions.Tables["AllTimeTransactions"].Rows.Add(timeId, timeDate.ToShortDateString(), timeType, feeEarnerReference, time, totalTimeElapsed, cost.ToString("0.00"), costBalance.ToString("0.00"), charge.ToString("0.00"), chargeBalance.ToString("0.00")); } else if ((Convert.ToDecimal(allTimeTransactionsRowView.Row["BillTimeChargeAllocAmount"]) >= Convert.ToDecimal(allTimeTransactionsRowView.Row["TimeCharge"])) && (Convert.ToDecimal(allTimeTransactionsRowView.Row["BillTimeCostAllocAmount"]) >= Convert.ToDecimal(allTimeTransactionsRowView.Row["TimeCost"])) && (Convert.ToInt32(allTimeTransactionsRowView.Row["BilledCount"]) > 0)) { //there has been some allocations done so the time must be billed dsAllTimeTransactions.Tables["AllTimeTransactions"].Rows.Add(timeId, timeDate.ToShortDateString(), timeType, feeEarnerReference, time, totalTimeElapsed, cost.ToString("0.00"), costBalance.ToString("0.00"), charge.ToString("0.00"), chargeBalance.ToString("0.00")); } else { // no time allocations doen so time must be unbilled //create listview items //there has been some allocations done so the time must be billed dsAllTimeTransactions.Tables["AllTimeTransactions"].Rows.Add(timeId, timeDate.ToShortDateString(), timeType, feeEarnerReference, time, totalTimeElapsed, cost.ToString("0.00"), costBalance.ToString("0.00"), charge.ToString("0.00"), chargeBalance.ToString("0.00")); } } if (dsAllTimeTransactions.Tables["AllTimeTransactions"].Rows.Count > 0) { int rowCount = dsAllTimeTransactions.Tables["AllTimeTransactions"].Rows.Count; timeElapsed = (int)dsAllTimeTransactions.Tables["AllTimeTransactions"].Rows[rowCount - 1]["TotalTimeElapsed"]; chargeBalance = (decimal)dsAllTimeTransactions.Tables["AllTimeTransactions"].Rows[rowCount - 1]["ChargeBalance"]; costBalance = (decimal)dsAllTimeTransactions.Tables["AllTimeTransactions"].Rows[rowCount - 1]["CostBalance"]; if (timeFilter.Trim() == "All") { totalTimeTransactions.TotalCharge = chargeBalance; totalTimeTransactions.TotalCost = costBalance; totalTimeTransactions.TotalTimeElapsed = this.ConvertUnits(timeElapsed, ApplicationSettings.Instance.TimeUnits); } // These properties need to be set for time filter for "All" and rest of the time filters totalTimeTransactions.FilterTime = this.ConvertUnits(timeElapsed, ApplicationSettings.Instance.TimeUnits); totalTimeTransactions.FilterCost = costBalance; totalTimeTransactions.FilterCharge = chargeBalance; returnValue.TotalTimeTransactions = totalTimeTransactions; } } e.DataSet = dsAllTimeTransactions; }; // Create the data list returnValue.TimeTransactions = dataListCreator.Create(logonId, // Give the query a name so it can be cached "GetTimeLedger", // 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("TimeId", "TimeId"), new ImportMapping("TimeDate", "TimeDate"), new ImportMapping("TimeType", "TimeType"), new ImportMapping("FeeEarnerReference", "FeeEarnerReference"), new ImportMapping("Time","Time"), new ImportMapping("Cost","Cost"), new ImportMapping("CostBalance","CostBalance"), new ImportMapping("Charge","Charge"), new ImportMapping("ChargeBalance","ChargeBalance"), new ImportMapping("TotalTimeElapsed", "TotalTimeElapsed") } ); } 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 time transactions. /// </summary> /// <param name="startRow"></param> /// <param name="pageSize"></param> /// <param name="forceRefresh"></param> /// <returns>Returns time ledger.</returns> public TimeLedgerSearchItem[] LoadTimeLedger(int startRow, int pageSize, bool forceRefresh, string timeFilter) { AccountsServiceClient accountsService = null; TimeLedgerSearchItem[] allTimeTransactions = 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; TimeLedgerSearchReturnValue returnValue = accountsService.GetTimeLedger(logonId, collectionRequest, timeFilter, projectId); if (returnValue.Success) { _allTimeTransactionsRowCount = returnValue.TimeTransactions.TotalRowCount; allTimeTransactions = returnValue.TimeTransactions.Rows; if (returnValue.TotalTimeTransactions != null) { // If filter is "All", only then totals for time,cost and charge will be set in session if (timeFilter == "All") { Session[SessionName.TotalTime] = returnValue.TotalTimeTransactions.TotalTimeElapsed; Session[SessionName.TotalCost] = returnValue.TotalTimeTransactions.TotalCost.ToString("0.00"); Session[SessionName.TotalCharge] = returnValue.TotalTimeTransactions.TotalCharge.ToString("0.00"); } Session["FilterCost"] = returnValue.TotalTimeTransactions.FilterCost.ToString(); Session["FilterCharge"] = returnValue.TotalTimeTransactions.FilterCharge.ToString("0.00"); Session["FilterTime"] = Convert.ToString(returnValue.TotalTimeTransactions.FilterTime); } // If the time filter is not "All", and also there are no rows to bind on grid view, // the set sessions to "null" if (_allTimeTransactionsRowCount == 0 && timeFilter != "All") { Session["FilterCost"] = null; Session["FilterCharge"] = null; Session["FilterTime"] = null; } } 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(allTimeTransactions); }
/// <summary> /// Loads write off time transactions by project id /// </summary> /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param> /// <param name="collectionRequest">Loads listof write off time transactions</param> /// <param name="projectId">To load write off transactions.</param> /// <returns>Loads write off time transactions</returns> public TimeLedgerSearchReturnValue GetWriteOffTimeTransactions(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, Guid projectId) { TimeLedgerSearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oAccountService = new AccountsService(); returnValue = oAccountService.GetWriteOffTimeTransactions(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, projectId); } else { returnValue = new TimeLedgerSearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }