/// <summary>
        /// This method will post the selected timesheet entries for accounting
        /// </summary>
        /// <param name="displayWarnings">if set to <c>true</c> display warnings.</param>
        private void PostTime(bool displayWarnings)
        {
            TimeServiceClient timeService = null;
            EarnerServiceClient earnerService = null;
            try
            {
                UnPostedTimeSearchCriteria searchCriteria = new UnPostedTimeSearchCriteria();
                searchCriteria.UserId = _logonSettings.DbUid;
                searchCriteria.TimeDate = DateTime.Now.Date;

                earnerService = new EarnerServiceClient();
                EarnerReturnValue earnerReturnVal = earnerService.GetFeeEarnerReference(_logonSettings.LogonId,
                                                                                        _logonSettings.MemberId);
                if (earnerReturnVal.Success)
                {
                    searchCriteria.FeeEarnerRef = earnerReturnVal.EarnerRef;
                }
                else
                {
                    throw new Exception(earnerReturnVal.Message);
                }

                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.StartRow = _grdTodaysTimesheet.PageIndex * _grdTodaysTimesheet.PageSize;
                collectionRequest.RowCount = _grdTodaysTimesheet.PageSize;

                //Get unposted time entries
                timeService = new TimeServiceClient();
                UnPostedTimeSearchReturnValue returnValue = timeService.UnPostedTimeSheetSearch(_logonSettings.LogonId,
                                                                                            collectionRequest,
                                                                                            searchCriteria);

                if (returnValue.UnPostedTimeSheet.Rows != null && returnValue.UnPostedTimeSheet.Rows.Length > 0)
                {
                    foreach (GridViewRow row in _grdTodaysTimesheet.Rows)
                    {
                        CheckBox timeSheetSelected = (CheckBox)row.FindControl("_chkSelect");
                        int timeId = (int)_grdTodaysTimesheet.DataKeys[row.RowIndex].Values["TimeId"];

                        //Find the item in the collection
                        UnPostedTimeSearchItem timeSheetItem = returnValue.UnPostedTimeSheet.Rows.First(time => time.TimeId == timeId);

                        //Check if the item is selected
                        if (timeSheetSelected.Checked)
                        {

                            //Validate the posting period
                            PeriodCriteria criteria = new PeriodCriteria();
                            criteria.Date = timeSheetItem.TimeDate;//returnValue.UnPostedTimeSheet.Rows[0].TimeDate;
                            criteria.IsTime = true;
                            criteria.IsPostingVATable = false;
                            criteria.IsAllowedPostBack2ClosedYear = false;

                            PeriodDetailsReturnValue periodDetailsReturnValue = new PeriodDetailsReturnValue();
                            periodDetailsReturnValue = timeService.ValidatePeriod(_logonSettings.LogonId, criteria);

                            if (periodDetailsReturnValue.Success)
                            {
                                //Display warning mesg(if any)
                                if (periodDetailsReturnValue.PeriodStatus == 3 && displayWarnings)
                                {
                                    _mdlPopUpCofirmationBox.Show();
                                    return;
                                }

                                if (periodDetailsReturnValue.PeriodStatus == 2)
                                {
                                    throw new Exception(periodDetailsReturnValue.ErrorMessage);
                                }

                                if (timeSheetItem != null)
                                {
                                    bool canBePosted = true;

                                    if (timeSheetItem.BillingTypeActive &&
                                        timeSheetItem.BillingTypeArchived == false &&
                                        timeSheetItem.TimeLAAsked == false)
                                    {
                                        canBePosted = false;
                                    }

                                    if (canBePosted)
                                    {
                                        TimeSheet timeSheet = new TimeSheet();
                                        timeSheet.TimeId = timeSheetItem.TimeId;
                                        timeSheet.PeriodId = periodDetailsReturnValue.PeriodId;
                                        timeSheet.MemberId = timeSheetItem.MemberId.ToString();
                                        timeSheet.CurrencyId = timeSheetItem.CurrencyId;
                                        timeSheet.PeriodMinutes = timeSheetItem.TimeElapsed;
                                        timeSheet.MasterPostedCost = timeSheetItem.TimeCost;
                                        timeSheet.MasterPostedCharge = timeSheetItem.TimeCharge;
                                        timeSheet.WorkingPostedCost = timeSheetItem.TimeCost;
                                        timeSheet.WorkingPostedCharge = timeSheetItem.TimeCharge;
                                        timeSheet.OrganisationId = timeSheetItem.OrganisationId;
                                        timeSheet.DepartmentId = timeSheetItem.DepartmentId;
                                        timeSheet.ProjectId = timeSheetItem.ProjectId;
                                        timeSheet.TimeTypeId = timeSheetItem.TimeTypeId;
                                        timeSheet.TimeDate = timeSheetItem.TimeDate;

                                        ReturnValue returnVal = timeService.PostTime(_logonSettings.LogonId, timeSheet);
                                        if (!returnVal.Success)
                                        {
                                            throw new Exception(returnVal.Message);
                                        }
                                    }
                                }

                            }
                            else
                            {
                                throw new Exception(periodDetailsReturnValue.Message);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (timeService != null)
                {
                    if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                        timeService.Close();
                }
                if (earnerService != null)
                {
                    if (earnerService.State != System.ServiceModel.CommunicationState.Faulted)
                        earnerService.Close();
                }
            }
        }
        /// <summary>
        /// Main method of the application
        /// </summary>
        private static void Main()
        {
            TimeServiceClient client = GetTimeService(UseSelfHosted);
            var webServiceClient     = CreateTimeWebService(UseSelfHosted);
            var bookAction           = CreateBookAction(UseSelfHosted);

            Query(client, webServiceClient, bookAction);
            client.Close();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads the time entry.
        /// </summary>
        private bool IsAdditionalDetailTimeExists(TimeDetails timeDetails)
        {
            TimeServiceClient timeService = null;

            try
            {
                timeService = new TimeServiceClient();
                IRIS.Law.WebServiceInterfaces.Time.Time time = new IRIS.Law.WebServiceInterfaces.Time.Time();
                time.Id          = timeDetails.Id;
                time.ProjectId   = timeDetails.ProjectId;
                time.FeeEarnerId = timeDetails.FeeEarnerId;
                time.TimeTypeId  = timeDetails.TimeTypeId;

                TimeReturnValue returnValue = timeService.GetAddtionalDetailTime(_logonId, time);

                if (returnValue.Success)
                {
                    if (returnValue.Time != null)
                    {
                        if (returnValue.AdditionalDetail != null)
                        {
                            if (returnValue.AdditionalDetail.CurrentAdditionalDetails != AdditionalDetails.None)
                            {
                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (timeService != null)
                {
                    if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        timeService.Close();
                    }
                }
            }
        }
        /// <summary>
        /// Loads the time entry.
        /// </summary>
        private void LoadTimeEntry(int timeId, string matterReference)
        {
            TimeServiceClient timeService = null;

            try
            {
                timeService = new TimeServiceClient();
                TimeReturnValue returnValue = timeService.GetTime(_logonSettings.LogonId, timeId);

                if (returnValue.Success)
                {
                    if (returnValue.Time != null)
                    {
                        Session[SessionName.ProjectId] = returnValue.Time.ProjectId;
                        GetClientDetails(matterReference);
                        GetTimeTypes(returnValue.Time.ProjectId);

                        _ddlTimeType.SelectedIndex = -1;
                        for (int i = 0; i < _ddlTimeType.Items.Count; i++)
                        {
                            if (GetValueOnIndexFromArray(_ddlTimeType.Items[i].Value, 0) == returnValue.Time.TimeTypeId.ToString())
                            {
                                _ddlTimeType.Items[i].Selected = true;
                                break;
                            }
                        }

                        _txtUnits.Text = returnValue.Time.Units.ToString();
                        _txtNotes.Text = returnValue.Time.Notes;
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (timeService != null)
                {
                    if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        timeService.Close();
                    }
                }
            }
        }
        /// <summary>
        /// Gets the valid time types for the matter.
        /// </summary>
        /// <param name="projectId">The project id.</param>
        private void GetTimeTypes(Guid projectId)
        {
            TimeServiceClient timeService = null;

            try
            {
                timeService = new TimeServiceClient();
                CollectionRequest      collectionRequest = new CollectionRequest();
                TimeTypeSearchCriteria criteria          = new TimeTypeSearchCriteria();
                criteria.IncludeArchived = false;
                criteria.ProjectId       = projectId;
                TimeTypeSearchReturnValue returnValue = timeService.TimeTypeSearch(_logonSettings.LogonId,
                                                                                   collectionRequest, criteria);

                if (returnValue.Success)
                {
                    if (returnValue.TimeTypes != null)
                    {
                        for (int i = 0; i < returnValue.TimeTypes.Rows.Length; i++)
                        {
                            ListItem item = new ListItem();
                            item.Text  = returnValue.TimeTypes.Rows[i].Description.ToString();
                            item.Value = returnValue.TimeTypes.Rows[i].Id.ToString().Trim() + "$" + Convert.ToString(returnValue.TimeTypes.Rows[i].CatId);
                            _ddlTimeType.Items.Add(item);
                        }
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (timeService != null)
                {
                    if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        timeService.Close();
                    }
                }
            }
        }
        /// <summary>
        /// Validates posting period on page load and gets client banks
        /// </summary>
        /// <param name="bankType"></param>
        /// Previous - private PeriodDetailsReturnValue ValidatePostingPeriod(Guid projectId, IRIS.Law.PmsCommonData.DataConstantsBankSearchTypes bankType)
        private PeriodDetailsReturnValue ValidatePostingPeriod(Guid projectId)
        {
            TimeServiceClient        timeService = null;
            PeriodDetailsReturnValue returnValue = null;

            try
            {
                PeriodCriteria criteria = new PeriodCriteria();
                criteria.Date             = Convert.ToDateTime(_ccPostDate.DateText);
                criteria.IsPostingVATable = false;
                criteria.IsTime           = false;
                criteria.ProjectId        = projectId;
                // This parameter has been passed as "false" in accounts
                criteria.IsAllowedPostBack2ClosedYear = false;

                timeService = new TimeServiceClient();
                returnValue = timeService.ValidatePeriod(_logonSettings.LogonId, criteria);
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblMessage.Text     = DataConstants.WSEndPointErrorMessage;
                _lblMessage.CssClass = "errorMessage";
            }
            catch (Exception ex)
            {
                _lblMessage.CssClass = "errorMessage";
                _lblMessage.Text     = ex.Message;
            }
            finally
            {
                if (timeService != null)
                {
                    if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        timeService.Close();
                    }
                }
            }

            return(returnValue);
        }
        protected void _btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (_txtUnits.Text == "0")
                {
                    _lblMessage.CssClass = "errorMessage";
                    _lblMessage.Text = "Units cannot be zero";
                    return;
                }

                TimeDetails timeDetails = new TimeDetails();
                timeDetails.ProjectId = (Guid)Session[SessionName.ProjectId];
                timeDetails.FeeEarnerId = _logonSettings.UserDefaultFeeMemberId;
                timeDetails.TimeTypeId = new Guid(GetValueOnIndexFromArray(_ddlTimeType.SelectedValue.Trim(), 0));
                timeDetails.TimeTypeCatId = Convert.ToInt32(GetValueOnIndexFromArray(_ddlTimeType.SelectedValue.Trim(), 1));
                timeDetails.Units = Convert.ToInt32(_txtUnits.Text.Trim());
                timeDetails.Notes = _txtNotes.Text.Trim();
                timeDetails.Date = DateTime.Now.Date;
                // No validation for limits from the web
                timeDetails.CanProceed = true;
                if (ViewState["TimeId"] == null)
                {
                    timeDetails.Id = 0;
                }
                else
                {
                    timeDetails.Id = Convert.ToInt32(ViewState["TimeId"]);
                }

                if (IsAdditionalDetailTimeExists(timeDetails))
                {
                    Session[SessionName.TimeDetails] = timeDetails;
                    Response.Redirect("~/Pages/Time/AdditionalTimeDetails.aspx", true);
                }
                else
                {
                    TimeServiceClient timeService = null;
                    TimeReturnValue returnValue = null;
                    try
                    {
                        timeService = new TimeServiceClient();
                        IRIS.Law.WebServiceInterfaces.Time.Time time = new IRIS.Law.WebServiceInterfaces.Time.Time();

                        time.ProjectId = (Guid)Session[SessionName.ProjectId];
                        time.FeeEarnerId = _logonSettings.UserDefaultFeeMemberId;
                        time.TimeTypeId = timeDetails.TimeTypeId;
                        time.Units = timeDetails.Units;
                        time.Notes = timeDetails.Notes;
                        time.Date = DateTime.Now.Date;
                        //No validation for limits from the web
                        time.DontCheckLimits = true;
                        time.BillingCodeID = 1; // Default to "Default - None Selected"

                        if (timeDetails.Id == 0)
                        {
                            //No timeId present. Add a new time entry
                            returnValue = timeService.AddTime(_logonSettings.LogonId, time, null, false);
                        }
                        else
                        {
                            //If a timeId is present then we are updating an existing time entry
                            time.Id = timeDetails.Id;
                            returnValue = timeService.UpdateTime(_logonSettings.LogonId, time, null);
                        }

                        if (returnValue.Success)
                        {
                            Session[SessionName.TimeDetails] = null;
                            //Redirect the user to the timesheet where entry would be listed
                            Response.Redirect("ViewTimesheet.aspx", true);
                        }
                        else
                        {
                            throw new Exception(returnValue.Message);
                        }
                    }
                    catch (System.ServiceModel.EndpointNotFoundException)
                    {
                        _lblMessage.Text = DataConstants.WSEndPointErrorMessage;
                        _lblMessage.CssClass = "errorMessage";
                    }
                    catch (Exception ex)
                    {
                        _lblMessage.CssClass = "errorMessage";
                        _lblMessage.Text = ex.Message;
                    }
                    finally
                    {
                        if (timeService != null)
                        {
                            if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                                timeService.Close();
                        }
                    }
                }
            }
        }
        private void SetupAttendanceExtraQuestions(TimeAdditionalDetail additionalDetails)
        {
            try
            {
                _pnlAttendance.Visible = true;
                GetAttendanceLocation();
                _ddlAttendanceLocation.SelectedIndex = (int)additionalDetails.AdditionalDetailsLocation;

                Location_IndexChanged(_ddlAttendanceLocation, _ddlServiceAttendanceLocation);

                if (_ddlServiceAttendanceLocation.Items.Count > 1)
                {
                    if(additionalDetails.LAId != null)
                    {
                        if (_ddlServiceAttendanceLocation.Items.FindByValue(Convert.ToString(additionalDetails.LAId)) != null)
                        {
                            _ddlServiceAttendanceLocation.Items.FindByValue(Convert.ToString(additionalDetails.LAId)).Selected = true;
                        }
                    }
                }

                TimeServiceClient timeService = null;
                try
                {
                    CollectionRequest collectionRequest = new CollectionRequest();
                    collectionRequest.ForceRefresh = true;

                    timeService = new TimeServiceClient();
                    AttendanceIndividualSearchReturnValue attendanceIndreturnValue = timeService.AttendanceIndividualSearch(_logonSettings.LogonId, collectionRequest);

                    if (attendanceIndreturnValue.Success)
                    {
                        if (attendanceIndreturnValue.AttendanceIndividual != null)
                        {
                            foreach (AttendanceIndividualSearchItem attendanceIndividual in attendanceIndreturnValue.AttendanceIndividual.Rows)
                            {
                                ListItem item = new ListItem();
                                item.Text = attendanceIndividual.Code + " - " + attendanceIndividual.Desciption;
                                item.Value = attendanceIndividual.Id.ToString();
                                _chklstAttendanceIndividuals.Items.Add(item);
                            }
                        }
                    }
                    else
                    {
                        throw new Exception(attendanceIndreturnValue.Message);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (timeService != null)
                    {
                        if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                            timeService.Close();
                    }
                }

                // Uncheck all the previously selected items.
                for (int i = 0; i < _chklstAttendanceIndividuals.Items.Count; i++)
                {
                    _chklstAttendanceIndividuals.Items[i].Selected = false;
                }

                // Check the Attendance Individuals.
                foreach (int individualId in additionalDetails.AttendanceIndividuals)
                {
                    for (int k = 0; k < this._chklstAttendanceIndividuals.Items.Count; k++)
                    {
                        if (Convert.ToInt32(this._chklstAttendanceIndividuals.Items[k].Value) == individualId)
                        {
                            _chklstAttendanceIndividuals.Items[k].Selected = true;
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void SaveTimeRecording()
        {
            try
            {
                if (Session[SessionName.TimeDetails] == null)
                {
                    _lblError.Text = "Session is timeout or the time details are not saved in the previous screen. Please go back and enter details again.";
                    return;
                }

                TimeServiceClient timeService = null;
                TimeAdditionalDetail timeAdditionalDetail = null;
                try
                {
                    timeService = new TimeServiceClient();
                    IRIS.Law.WebServiceInterfaces.Time.Time time = new IRIS.Law.WebServiceInterfaces.Time.Time();

                    time.ProjectId = (Guid)Session[SessionName.ProjectId];
                    time.FeeEarnerId = _logonSettings.UserDefaultFeeMemberId;
                    time.TimeTypeId = ((TimeDetails)Session[SessionName.TimeDetails]).TimeTypeId;
                    time.Units = ((TimeDetails)Session[SessionName.TimeDetails]).Units;
                    time.Notes = ((TimeDetails)Session[SessionName.TimeDetails]).Notes;
                    time.Date = DateTime.Now.Date;
                    //No validation for limits from the web
                    time.DontCheckLimits = true;
                    time.BillingCodeID = 1; // Default to "Default - None Selected"

                    if (ViewState["CurrentAdditionalDetail"] != null)
                    {
                        timeAdditionalDetail = new TimeAdditionalDetail();

                        timeAdditionalDetail.CurrentAdditionalDetails = (AdditionalDetails)ViewState["CurrentAdditionalDetail"];

                        //Get the data from listview controls if that additional details is selected
                        //and set HaveAskedLaQuestions
                        switch (timeAdditionalDetail.CurrentAdditionalDetails)
                        {
                            case AdditionalDetails.Attendance:
                                #region Attendance

                                timeAdditionalDetail.AdditionalDetailsLocation = (DetailLocation)Enum.Parse(typeof(DetailLocation), _ddlAttendanceLocation.SelectedIndex.ToString());
                                if (_ddlServiceAttendanceLocation.SelectedValue.Length > 0)
                                {
                                    timeAdditionalDetail.LAId = new Guid(_ddlServiceAttendanceLocation.SelectedValue);
                                }

                                //Get the selected joint client candidates
                                List<ListItem> selectedItems = (from item in _chklstAttendanceIndividuals.Items.Cast<ListItem>()
                                                                where item.Selected
                                                                select item).ToList();

                                int[] attendanceInd = new int[selectedItems.Count];
                                for (int i = 0; i < selectedItems.Count; i++)
                                {
                                    int attendanceIndID = Convert.ToInt32(selectedItems[i].Value);
                                    attendanceInd[i] = attendanceIndID;
                                }
                                timeAdditionalDetail.AttendanceIndividuals = attendanceInd;
                                #endregion
                                break;

                            case AdditionalDetails.Advocacy:
                                #region Advocacy

                                timeAdditionalDetail.AdditionalDetailsLocation = (DetailLocation)Enum.Parse(typeof(DetailLocation), _ddlAdvocacyLocation.SelectedIndex.ToString());
                                if (_ddlServiceAdvocacyLocation.SelectedValue.Length > 0)
                                {
                                    timeAdditionalDetail.LAId = new Guid(_ddlServiceAdvocacyLocation.SelectedValue);
                                }

                                //Get the selected joint client candidates
                                List<ListItem> selectedItemsHearing = (from item in _chklstHearingType.Items.Cast<ListItem>()
                                                                       where item.Selected
                                                                       select item).ToList();

                                int[] advocacyTypeId = new int[selectedItemsHearing.Count];
                                for (int i = 0; i < selectedItemsHearing.Count; i++)
                                {
                                    int tempAdvocacyTypeId = Convert.ToInt32(selectedItemsHearing[i].Value);
                                    advocacyTypeId[i] = tempAdvocacyTypeId;
                                }
                                timeAdditionalDetail.AdvocacyTypes = advocacyTypeId;
                                #endregion
                                break;

                            case AdditionalDetails.Travel:
                                #region Travel
                                if (_txtMiles.Text.Length > 0)
                                {
                                    timeAdditionalDetail.Miles = Convert.ToInt32(_txtMiles.Text);
                                }
                                timeAdditionalDetail.FaresDescription = _txtFaresDescription.Text;
                                if (_txtFares.Text.Length > 0)
                                {
                                    timeAdditionalDetail.FaresAmount = Convert.ToDecimal(_txtFares.Text);
                                }
                                #endregion
                                break;

                            case AdditionalDetails.PoliceStationCalls:
                                #region PoliceStationCalls
                                if (_ddlPoliceStationCalls.SelectedValue == "Police Station")
                                {
                                    timeAdditionalDetail.AdditionalDetailsLocation = DetailLocation.PoliceStation;
                                }
                                else
                                {
                                    timeAdditionalDetail.AdditionalDetailsLocation = DetailLocation.NotApplicable;
                                }

                                if (_ddlServicePoliceStationCalls.SelectedValue.Length > 0)
                                {
                                    timeAdditionalDetail.LAId = new Guid(_ddlServicePoliceStationCalls.SelectedValue);
                                }
                                #endregion
                                break;

                            case AdditionalDetails.RunningTime:
                                #region RunningTime
                                if (_txtHour.Text.Length > 0)
                                {
                                    timeAdditionalDetail.RunningHours = Convert.ToInt32(_txtHour.Text);
                                }
                                if (_txtMinutes.Text.Length > 0)
                                {
                                    timeAdditionalDetail.RunningMinutes = Convert.ToInt32(_txtMinutes.Text);
                                }
                                #endregion
                                break;

                            case AdditionalDetails.CivilImmigrationAsylumSubstantiveHearing:
                                #region CivilImmigrationAsylumSubstantiveHearing
                                timeAdditionalDetail.IsLASubstantiveHearingAttend = _chkCivilImmAsylumSubstantiveHearing.Checked;
                                #endregion
                                break;

                            case AdditionalDetails.CivilImmigrationAsylumTravelWaiting:
                                #region CivilImmigrationAsylumTravelWaiting
                                timeAdditionalDetail.IsTravelWaitingDetCentre = _chkCivilImmAsylumTravelWaitingDetCentre.Checked;
                                if (_ddlServiceCivilImmAsylumTravelWaitingDetCentre.SelectedValue.Length > 0)
                                {
                                    timeAdditionalDetail.LAId = new Guid(_ddlServiceCivilImmAsylumTravelWaitingDetCentre.SelectedValue);
                                }
                                #endregion
                                break;

                            case AdditionalDetails.CivilImmigrationAsylumJRFormFilling:
                                #region CivilImmigrationAsylumJRFormFilling
                                timeAdditionalDetail.LAIsJRFormFilling = _chkCivilImmAsylumJRFormFilling.Checked;
                                #endregion
                                break;

                            case AdditionalDetails.CivilImmigrationAsylumMentalHearing:
                                #region CivilImmigrationAsylumMentalHearing
                                timeAdditionalDetail.IsLAHearingAdjourned = _chkCivilImmAsylumMentalHearingAdjourned.Checked;
                                #endregion
                                break;

                            case AdditionalDetails.CourtDutyAttendance:
                                #region CourtDutyAttendance
                                if (_txtCourtDutyAttNoOfDef.Text.Length > 0)
                                {
                                    timeAdditionalDetail.LASuspect = Convert.ToInt32(_txtCourtDutyAttNoOfDef.Text);
                                }
                                timeAdditionalDetail.IsLAYouth = _chkCourtDutyAtYouth.Checked;
                                if (_ddlCourtDutyAttCourt.SelectedValue.Length > 0)
                                {
                                    timeAdditionalDetail.LAId = new Guid(_ddlCourtDutyAttCourt.SelectedValue);
                                }
                                else
                                {
                                    timeAdditionalDetail.LAId = DataConstants.DummyGuid;
                                }
                                #endregion
                                break;

                            case AdditionalDetails.PoliceStationAttendance:
                                #region PoliceStationAttendance
                                if (_ddlPoliceStationAttendance.SelectedValue == "Police Station")
                                {
                                    timeAdditionalDetail.AdditionalDetailsLocation = DetailLocation.PoliceStation;
                                }
                                else
                                {
                                    timeAdditionalDetail.AdditionalDetailsLocation = DetailLocation.NotApplicable;
                                }

                                //timeAdditionalDetail.AdditionalDetailsLocation = (DetailLocation)Enum.Parse(typeof(DetailLocation), _ddlPoliceStationAttendance.SelectedIndex.ToString());
                                if (_ddlServicePoliceStationAttendance.SelectedValue.Length > 0)
                                {
                                    timeAdditionalDetail.LAId = new Guid(_ddlServicePoliceStationAttendance.SelectedValue);
                                }
                                else
                                {
                                    timeAdditionalDetail.LAId = DataConstants.DummyGuid;
                                }
                                #endregion
                                break;

                            case AdditionalDetails.FileReviews:
                                #region FileReviews
                                if (ViewState["FileReviewProjectId"] == null)
                                {
                                    timeAdditionalDetail.FileReviewsProjectId = DataConstants.DummyGuid;
                                }
                                else
                                {
                                    timeAdditionalDetail.FileReviewsProjectId = new Guid(ViewState["FileReviewProjectId"].ToString());
                                }
                                timeAdditionalDetail.IsFaceToFace = _rdoBtnFaceToFace.Checked;
                                #endregion
                                break;
                        }
                    }

                    TimeReturnValue returnValue = null;

                    if (((TimeDetails)Session[SessionName.TimeDetails]).Id == 0)
                    {
                        //No timeId present. Add a new time entry
                        returnValue = timeService.AddTime(_logonSettings.LogonId, time, timeAdditionalDetail, false);
                    }
                    else
                    {
                        //If a timeId is present then we are updating an existing time entry
                        time.Id = ((TimeDetails)Session[SessionName.TimeDetails]).Id;
                        returnValue = timeService.UpdateTime(_logonSettings.LogonId, time, timeAdditionalDetail);
                    }

                    if (returnValue.Success)
                    {
                        Session[SessionName.TimeDetails] = null;
                        //Redirect the user to the timesheet where entry would be listed
                        Response.Redirect("ViewTimesheet.aspx", false);
                    }
                    else
                    {
                        throw new Exception(returnValue.Message);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (timeService != null)
                    {
                        if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                            timeService.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 10
0
        protected void _btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                TimeDetails timeDetails = new TimeDetails();

                if ((Guid)ViewState["AddTimeProjectId"] != _msAddTimeEntry.ProjectIdConfirm)
                {
                    ViewState["AddTimeProjectId"] = _msAddTimeEntry.ProjectIdConfirm;
                }

                Guid _feeEarnerId = (Guid)Session[SessionName.DefaultFeeEarner];

                if (_msAddTimeEntry.FeeEarnerId != DataConstants.DummyGuid)
                {
                    _feeEarnerId = _msAddTimeEntry.FeeEarnerId;
                }

                timeDetails.ProjectId     = (Guid)ViewState["AddTimeProjectId"];
                timeDetails.FeeEarnerId   = _feeEarnerId;//(Guid)Session[SessionName.DefaultFeeEarner];
                timeDetails.TimeTypeId    = new Guid(GetValueOnIndexFromArray(_ddlTimeType.SelectedValue.Trim(), 0));
                timeDetails.TimeTypeCatId = Convert.ToInt32(GetValueOnIndexFromArray(_ddlTimeType.SelectedValue.Trim(), 1));
                timeDetails.Units         = Convert.ToInt32(_txtUnits.Text.Trim());
                timeDetails.Notes         = _txtNotes.Text.Trim();
                timeDetails.Date          = DateTime.Now.Date;
                // No validation for limits from the web
                timeDetails.CanProceed = true;
                timeDetails.Id         = 0;

                if (IsAdditionalDetailTimeExists(timeDetails))
                {
                    Session[SessionName.TimeDetails] = timeDetails;
                    Response.Redirect("~/Pages/Time/AdditionalTimeDetailsMobile.aspx", true);
                }
                else
                {
                    TimeServiceClient timeService = null;
                    TimeReturnValue   returnValue = null;
                    try
                    {
                        timeService = new TimeServiceClient();
                        IRIS.Law.WebServiceInterfaces.Time.Time time = new IRIS.Law.WebServiceInterfaces.Time.Time();

                        time.ProjectId   = timeDetails.ProjectId;
                        time.FeeEarnerId = timeDetails.FeeEarnerId;
                        time.TimeTypeId  = timeDetails.TimeTypeId;
                        time.Units       = timeDetails.Units;
                        time.Notes       = timeDetails.Notes;
                        time.Date        = DateTime.Now.Date;
                        //No validation for limits from the web
                        time.DontCheckLimits = true;
                        time.BillingCodeID   = 1; // Default to "Default - None Selected"

                        //No timeId present. Add a new time entry
                        returnValue = timeService.AddTime(_logonId, time, null, false);

                        if (returnValue.Success)
                        {
                            Session[SessionName.TimeDetails] = null;

                            _lblMessage.CssClass = "successMessage";
                            _lblMessage.Text     = "Time entry saved successfully";

                            //Reset time entry fields
                            ResetFields();
                        }
                        else
                        {
                            throw new Exception(returnValue.Message);
                        }
                    }
                    catch (System.ServiceModel.EndpointNotFoundException)
                    {
                        _lblMessage.Text     = DataConstants.WSEndPointErrorMessage;
                        _lblMessage.CssClass = "errorMessage";
                    }
                    catch (Exception ex)
                    {
                        _lblMessage.CssClass = "errorMessage";
                        _lblMessage.Text     = ex.Message;
                    }
                    finally
                    {
                        if (timeService != null)
                        {
                            if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                            {
                                timeService.Close();
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Loads the time entry.
        /// </summary>
        private void LoadTimeEntry(int timeId, string matterReference)
        {
            TimeServiceClient timeService = null;
            try
            {
                timeService = new TimeServiceClient();
                TimeReturnValue returnValue = timeService.GetTime(_logonSettings.LogonId, timeId);

                if (returnValue.Success)
                {
                    if (returnValue.Time != null)
                    {
                        Session[SessionName.ProjectId] = returnValue.Time.ProjectId;
                        GetClientDetails(matterReference);
                        GetTimeTypes(returnValue.Time.ProjectId);

                        _ddlTimeType.SelectedIndex = -1;
                        for (int i = 0; i < _ddlTimeType.Items.Count; i++)
                        {
                            if (GetValueOnIndexFromArray(_ddlTimeType.Items[i].Value, 0) == returnValue.Time.TimeTypeId.ToString())
                            {
                                _ddlTimeType.Items[i].Selected = true;
                                break;
                            }
                        }

                        _txtUnits.Text = returnValue.Time.Units.ToString();
                        _txtNotes.Text = returnValue.Time.Notes;
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (timeService != null)
                {
                    if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                        timeService.Close();
                }
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Gets the court types.
        /// </summary>
        private void GetCourtTypes()
        {
            TimeServiceClient timeService = null;
            try
            {
                timeService = new TimeServiceClient();
                CollectionRequest collectionRequest = new CollectionRequest();
                CourtTypeSearchCriteria searchCriteria = new CourtTypeSearchCriteria();
                searchCriteria.IncludeArchived = false;
                CourtTypeReturnValue returnValue = timeService.CourtTypeSearch(_logonSettings.LogonId, collectionRequest
                                                                                    , searchCriteria);

                if (returnValue.Success)
                {
                    _ddlCourtType.DataSource = returnValue.CourtTypes.Rows;
                    _ddlCourtType.DataTextField = "Description";
                    _ddlCourtType.DataValueField = "Id";
                    _ddlCourtType.DataBind();
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (timeService != null)
                {
                    if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                        timeService.Close();
                }
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Gets the charge rates.
        /// </summary>
        /// <param name="isPublicFunded">if set to <c>true</c> [include public funded].</param>
        private void GetChargeRates(bool includePublicFunded)
        {
            TimeServiceClient timeService = null;
            try
            {
                CollectionRequest collectionRequest = new CollectionRequest();

                ChargeRateSearchCriteria criteria = new ChargeRateSearchCriteria();
                criteria.IsArchived = false;
                criteria.IsPublicFunded = includePublicFunded;

                timeService = new TimeServiceClient();
                ChargeRateSearchReturnValue returnValue = timeService.ChargeRateOnPublicFundingSearch(_logonSettings.LogonId,
                                            collectionRequest, criteria);

                if (returnValue.Success)
                {
                    if (returnValue.ChargeRates != null)
                    {
                        _ddlChargeRate.Items.Clear();
                        foreach (ChargeRateSearchItem chargeRate in returnValue.ChargeRates.Rows)
                        {
                            if (chargeRate.DescriptionId != new Guid("6e5431b2-cdf3-4360-8cbf-93654b83bd85"))
                            {
                                ListItem item = new ListItem();
                                item.Text = chargeRate.Description;
                                item.Value = chargeRate.DescriptionId.ToString() + "$" + chargeRate.CourtId.ToString();
                                _ddlChargeRate.Items.Add(item);
                            }
                        }
                        AddDefaultToDropDownList(_ddlChargeRate);
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (timeService != null)
                {
                    if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                        timeService.Close();
                }
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// This method will post the selected timesheet entries for accounting
        /// </summary>
        /// <param name="displayWarnings">if set to <c>true</c> display warnings.</param>
        private void PostTime(bool displayWarnings)
        {
            TimeServiceClient   timeService   = null;
            EarnerServiceClient earnerService = null;

            try
            {
                UnPostedTimeSearchCriteria searchCriteria = new UnPostedTimeSearchCriteria();
                searchCriteria.UserId   = _logonSettings.DbUid;
                searchCriteria.TimeDate = DateTime.Now.Date;

                earnerService = new EarnerServiceClient();
                EarnerReturnValue earnerReturnVal = earnerService.GetFeeEarnerReference(_logonSettings.LogonId,
                                                                                        _logonSettings.MemberId);
                if (earnerReturnVal.Success)
                {
                    searchCriteria.FeeEarnerRef = earnerReturnVal.EarnerRef;
                }
                else
                {
                    throw new Exception(earnerReturnVal.Message);
                }


                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.StartRow = _grdTodaysTimesheet.PageIndex * _grdTodaysTimesheet.PageSize;
                collectionRequest.RowCount = _grdTodaysTimesheet.PageSize;

                //Get unposted time entries
                timeService = new TimeServiceClient();
                UnPostedTimeSearchReturnValue returnValue = timeService.UnPostedTimeSheetSearch(_logonSettings.LogonId,
                                                                                                collectionRequest,
                                                                                                searchCriteria);

                if (returnValue.UnPostedTimeSheet.Rows != null && returnValue.UnPostedTimeSheet.Rows.Length > 0)
                {
                    foreach (GridViewRow row in _grdTodaysTimesheet.Rows)
                    {
                        CheckBox timeSheetSelected = (CheckBox)row.FindControl("_chkSelect");
                        int      timeId            = (int)_grdTodaysTimesheet.DataKeys[row.RowIndex].Values["TimeId"];

                        //Find the item in the collection
                        UnPostedTimeSearchItem timeSheetItem = returnValue.UnPostedTimeSheet.Rows.First(time => time.TimeId == timeId);


                        //Check if the item is selected
                        if (timeSheetSelected.Checked)
                        {
                            //Validate the posting period
                            PeriodCriteria criteria = new PeriodCriteria();
                            criteria.Date                         = timeSheetItem.TimeDate;//returnValue.UnPostedTimeSheet.Rows[0].TimeDate;
                            criteria.IsTime                       = true;
                            criteria.IsPostingVATable             = false;
                            criteria.IsAllowedPostBack2ClosedYear = false;

                            PeriodDetailsReturnValue periodDetailsReturnValue = new PeriodDetailsReturnValue();
                            periodDetailsReturnValue = timeService.ValidatePeriod(_logonSettings.LogonId, criteria);

                            if (periodDetailsReturnValue.Success)
                            {
                                //Display warning mesg(if any)
                                if (periodDetailsReturnValue.PeriodStatus == 3 && displayWarnings)
                                {
                                    _mdlPopUpCofirmationBox.Show();
                                    return;
                                }

                                if (periodDetailsReturnValue.PeriodStatus == 2)
                                {
                                    throw new Exception(periodDetailsReturnValue.ErrorMessage);
                                }

                                if (timeSheetItem != null)
                                {
                                    bool canBePosted = true;

                                    if (timeSheetItem.BillingTypeActive &&
                                        timeSheetItem.BillingTypeArchived == false &&
                                        timeSheetItem.TimeLAAsked == false)
                                    {
                                        canBePosted = false;
                                    }

                                    if (canBePosted)
                                    {
                                        TimeSheet timeSheet = new TimeSheet();
                                        timeSheet.TimeId              = timeSheetItem.TimeId;
                                        timeSheet.PeriodId            = periodDetailsReturnValue.PeriodId;
                                        timeSheet.MemberId            = timeSheetItem.MemberId.ToString();
                                        timeSheet.CurrencyId          = timeSheetItem.CurrencyId;
                                        timeSheet.PeriodMinutes       = timeSheetItem.TimeElapsed;
                                        timeSheet.MasterPostedCost    = timeSheetItem.TimeCost;
                                        timeSheet.MasterPostedCharge  = timeSheetItem.TimeCharge;
                                        timeSheet.WorkingPostedCost   = timeSheetItem.TimeCost;
                                        timeSheet.WorkingPostedCharge = timeSheetItem.TimeCharge;
                                        timeSheet.OrganisationId      = timeSheetItem.OrganisationId;
                                        timeSheet.DepartmentId        = timeSheetItem.DepartmentId;
                                        timeSheet.ProjectId           = timeSheetItem.ProjectId;
                                        timeSheet.TimeTypeId          = timeSheetItem.TimeTypeId;
                                        timeSheet.TimeDate            = timeSheetItem.TimeDate;

                                        ReturnValue returnVal = timeService.PostTime(_logonSettings.LogonId, timeSheet);
                                        if (!returnVal.Success)
                                        {
                                            throw new Exception(returnVal.Message);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                throw new Exception(periodDetailsReturnValue.Message);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (timeService != null)
                {
                    if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        timeService.Close();
                    }
                }
                if (earnerService != null)
                {
                    if (earnerService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        earnerService.Close();
                    }
                }
            }
        }
        /// <summary>
        /// Gets the valid time types for the matter.
        /// </summary>
        /// <param name="projectId">The project id.</param>
        private void GetTimeTypes(Guid projectId)
        {
            TimeServiceClient timeService = null;
            try
            {
                timeService = new TimeServiceClient();
                CollectionRequest collectionRequest = new CollectionRequest();
                TimeTypeSearchCriteria criteria = new TimeTypeSearchCriteria();
                criteria.IncludeArchived = false;
                criteria.ProjectId = projectId;
                TimeTypeSearchReturnValue returnValue = timeService.TimeTypeSearch(_logonSettings.LogonId,
                                                                            collectionRequest, criteria);

                if (returnValue.Success)
                {
                    if (returnValue.TimeTypes != null)
                    {
                        for (int i = 0; i < returnValue.TimeTypes.Rows.Length; i++)
                        {
                            ListItem item = new ListItem();
                            item.Text = returnValue.TimeTypes.Rows[i].Description.ToString();
                            item.Value = returnValue.TimeTypes.Rows[i].Id.ToString().Trim() + "$" + Convert.ToString(returnValue.TimeTypes.Rows[i].CatId);
                            _ddlTimeType.Items.Add(item);
                        }
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (timeService != null)
                {
                    if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                        timeService.Close();
                }
            }
        }
        protected void _btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                TimeDetails timeDetails = new TimeDetails();

                if ((Guid)ViewState["AddTimeProjectId"] != _msAddTimeEntry.ProjectIdConfirm)
                {
                    ViewState["AddTimeProjectId"] = _msAddTimeEntry.ProjectIdConfirm;
                }

                Guid _feeEarnerId = (Guid)Session[SessionName.DefaultFeeEarner];

                if (_msAddTimeEntry.FeeEarnerId != DataConstants.DummyGuid)
                {
                    _feeEarnerId = _msAddTimeEntry.FeeEarnerId;
                }

                timeDetails.ProjectId = (Guid)ViewState["AddTimeProjectId"];
                timeDetails.FeeEarnerId = _feeEarnerId;//(Guid)Session[SessionName.DefaultFeeEarner];
                timeDetails.TimeTypeId = new Guid(GetValueOnIndexFromArray(_ddlTimeType.SelectedValue.Trim(), 0));
                timeDetails.TimeTypeCatId = Convert.ToInt32(GetValueOnIndexFromArray(_ddlTimeType.SelectedValue.Trim(), 1));
                timeDetails.Units = Convert.ToInt32(_txtUnits.Text.Trim());
                timeDetails.Notes = _txtNotes.Text.Trim();
                timeDetails.Date = DateTime.Now.Date;
                // No validation for limits from the web
                timeDetails.CanProceed = true;
                timeDetails.Id = 0;

                if (IsAdditionalDetailTimeExists(timeDetails))
                {
                    Session[SessionName.TimeDetails] = timeDetails;
                    Response.Redirect("~/Pages/Time/AdditionalTimeDetailsMobile.aspx", true);
                }
                else
                {
                    TimeServiceClient timeService = null;
                    TimeReturnValue returnValue = null;
                    try
                    {
                        timeService = new TimeServiceClient();
                        IRIS.Law.WebServiceInterfaces.Time.Time time = new IRIS.Law.WebServiceInterfaces.Time.Time();

                        time.ProjectId = timeDetails.ProjectId;
                        time.FeeEarnerId = timeDetails.FeeEarnerId;
                        time.TimeTypeId = timeDetails.TimeTypeId;
                        time.Units = timeDetails.Units;
                        time.Notes = timeDetails.Notes;
                        time.Date = DateTime.Now.Date;
                        //No validation for limits from the web
                        time.DontCheckLimits = true;
                        time.BillingCodeID = 1; // Default to "Default - None Selected"

                        //No timeId present. Add a new time entry
                        returnValue = timeService.AddTime(_logonId, time, null, false);

                        if (returnValue.Success)
                        {
                            Session[SessionName.TimeDetails] = null;

                            _lblMessage.CssClass = "successMessage";
                            _lblMessage.Text = "Time entry saved successfully";

                            //Reset time entry fields
                            ResetFields();
                        }
                        else
                        {
                            throw new Exception(returnValue.Message);
                        }
                    }
                    catch (System.ServiceModel.EndpointNotFoundException)
                    {
                        _lblMessage.Text = DataConstants.WSEndPointErrorMessage;
                        _lblMessage.CssClass = "errorMessage";
                    }
                    catch (Exception ex)
                    {
                        _lblMessage.CssClass = "errorMessage";
                        _lblMessage.Text = ex.Message;
                    }
                    finally
                    {
                        if (timeService != null)
                        {
                            if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                                timeService.Close();
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Loads the time entry.
        /// </summary>
        private bool IsAdditionalDetailTimeExists(TimeDetails timeDetails)
        {
            TimeServiceClient timeService = null;
            try
            {
                timeService = new TimeServiceClient();
                IRIS.Law.WebServiceInterfaces.Time.Time time = new IRIS.Law.WebServiceInterfaces.Time.Time();
                time.Id = timeDetails.Id;
                time.ProjectId = timeDetails.ProjectId;
                time.FeeEarnerId = timeDetails.FeeEarnerId;
                time.TimeTypeId = timeDetails.TimeTypeId;

                TimeReturnValue returnValue = timeService.GetAddtionalDetailTime(_logonSettings.LogonId, time);

                if (returnValue.Success)
                {
                    if (returnValue.Time != null)
                    {
                        if (returnValue.AdditionalDetail != null)
                        {
                            if (returnValue.AdditionalDetail.CurrentAdditionalDetails != AdditionalDetails.None)
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
                return false;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (timeService != null)
                {
                    if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                        timeService.Close();
                }
            }
        }
        /// <summary>
        /// Gets the valid time types for the matter.
        /// </summary>
        private void GetTimeTypes()
        {
            _ddlTimeType.Items.Clear();
            if (_msAddTimeEntry.ProjectId != DataConstants.DummyGuid)
            {
                TimeServiceClient timeService = null;
                try
                {
                    timeService = new TimeServiceClient();
                    CollectionRequest collectionRequest = new CollectionRequest();
                    TimeTypeSearchCriteria criteria = new TimeTypeSearchCriteria();
                    criteria.IncludeArchived = false;
                    criteria.ProjectId = _msAddTimeEntry.ProjectId;
                    TimeTypeSearchReturnValue returnValue = timeService.TimeTypeSearch(_logonId,
                                                                                collectionRequest, criteria);

                    if (returnValue.Success)
                    {
                        for (int i = 0; i < returnValue.TimeTypes.Rows.Length; i++)
                        {
                            ListItem item = new ListItem();
                            item.Text = returnValue.TimeTypes.Rows[i].Description.ToString();
                            item.Value = returnValue.TimeTypes.Rows[i].Id.ToString().Trim() + "$" + Convert.ToString(returnValue.TimeTypes.Rows[i].CatId);
                            _ddlTimeType.Items.Add(item);
                        }

                        //Dont set default time type if we have come back from additional details pg
                        if (!_isLoadingLastSavedTimeEntry)
                        {
                            _ddlTimeType.SelectedIndex = -1;
                            for (int i = 0; i < _ddlTimeType.Items.Count; i++)
                            {
                                if (GetValueOnIndexFromArray(_ddlTimeType.Items[i].Value, 0) == "3ef2937c-c31b-430c-82ed-5701a84f258e")
                                {
                                    _ddlTimeType.Items[i].Selected = true;
                                }
                            }
                        }
                        else
                        {
                            TimeDetails timeDetails = (TimeDetails)Session[SessionName.TimeDetails];
                            _ddlTimeType.SelectedIndex = -1;
                            for (int i = 0; i < _ddlTimeType.Items.Count; i++)
                            {
                                if (GetValueOnIndexFromArray(_ddlTimeType.Items[i].Value, 0) == timeDetails.TimeTypeId.ToString())
                                {
                                    _ddlTimeType.Items[i].Selected = true;
                                }
                            }
                        }
                    }
                    else
                    {
                        throw new Exception(returnValue.Message);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (timeService != null)
                    {
                        if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                            timeService.Close();
                    }
                }
            }
        }
        /// <summary>
        /// Validates posting period on page load and gets client banks
        /// </summary>
        /// <param name="bankType"></param>
        /// Previous - private PeriodDetailsReturnValue ValidatePostingPeriod(Guid projectId, IRIS.Law.PmsCommonData.DataConstantsBankSearchTypes bankType)
        private PeriodDetailsReturnValue ValidatePostingPeriod(Guid projectId)
        {
            TimeServiceClient timeService = null;
            PeriodDetailsReturnValue returnValue = null;

            try
            {
                PeriodCriteria criteria = new PeriodCriteria();
                criteria.Date = Convert.ToDateTime(_ccPostDate.DateText);
                criteria.IsPostingVATable = false;
                criteria.IsTime = false;
                criteria.ProjectId = projectId;
                // This parameter has been passed as "false" in accounts
                criteria.IsAllowedPostBack2ClosedYear = false;

                timeService = new TimeServiceClient();
                returnValue = timeService.ValidatePeriod(_logonSettings.LogonId, criteria);
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblMessage.Text = DataConstants.WSEndPointErrorMessage;
                _lblMessage.CssClass = "errorMessage";
            }
            catch (Exception ex)
            {
                _lblMessage.CssClass = "errorMessage";
                _lblMessage.Text = ex.Message;
            }
            finally
            {
                if (timeService != null)
                {
                    if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                        timeService.Close();
                }
            }

            return returnValue;
        }
        private ServiceSearchItem[] GetServicesLookup(int associationRoleId)
        {
            TimeServiceClient timeService = null;
            ServiceSearchItem[] services = null;
            try
            {
                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.ForceRefresh = true;

                timeService = new TimeServiceClient();
                ServiceSearchReturnValue serviceReturnValue = timeService.ServiceSearch(_logonSettings.LogonId, collectionRequest, associationRoleId);

                if (serviceReturnValue.Success)
                {
                    if (serviceReturnValue.Service != null)
                    {
                        services = serviceReturnValue.Service.Rows;
                    }
                }
                else
                {
                    throw new Exception(serviceReturnValue.Message);
                }
                return services;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (timeService != null)
                {
                    if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                        timeService.Close();
                }
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Gets the valid time types for the matter.
        /// </summary>
        private void GetTimeTypes()
        {
            _ddlTimeType.Items.Clear();
            if (_msAddTimeEntry.ProjectId != DataConstants.DummyGuid)
            {
                TimeServiceClient timeService = null;
                try
                {
                    timeService = new TimeServiceClient();
                    CollectionRequest      collectionRequest = new CollectionRequest();
                    TimeTypeSearchCriteria criteria          = new TimeTypeSearchCriteria();
                    criteria.IncludeArchived = false;
                    criteria.ProjectId       = _msAddTimeEntry.ProjectId;
                    TimeTypeSearchReturnValue returnValue = timeService.TimeTypeSearch(_logonId,
                                                                                       collectionRequest, criteria);

                    if (returnValue.Success)
                    {
                        for (int i = 0; i < returnValue.TimeTypes.Rows.Length; i++)
                        {
                            ListItem item = new ListItem();
                            item.Text  = returnValue.TimeTypes.Rows[i].Description.ToString();
                            item.Value = returnValue.TimeTypes.Rows[i].Id.ToString().Trim() + "$" + Convert.ToString(returnValue.TimeTypes.Rows[i].CatId);
                            _ddlTimeType.Items.Add(item);
                        }

                        //Dont set default time type if we have come back from additional details pg
                        if (!_isLoadingLastSavedTimeEntry)
                        {
                            _ddlTimeType.SelectedIndex = -1;
                            for (int i = 0; i < _ddlTimeType.Items.Count; i++)
                            {
                                if (GetValueOnIndexFromArray(_ddlTimeType.Items[i].Value, 0) == "3ef2937c-c31b-430c-82ed-5701a84f258e")
                                {
                                    _ddlTimeType.Items[i].Selected = true;
                                }
                            }
                        }
                        else
                        {
                            TimeDetails timeDetails = (TimeDetails)Session[SessionName.TimeDetails];
                            _ddlTimeType.SelectedIndex = -1;
                            for (int i = 0; i < _ddlTimeType.Items.Count; i++)
                            {
                                if (GetValueOnIndexFromArray(_ddlTimeType.Items[i].Value, 0) == timeDetails.TimeTypeId.ToString())
                                {
                                    _ddlTimeType.Items[i].Selected = true;
                                }
                            }
                        }
                    }
                    else
                    {
                        throw new Exception(returnValue.Message);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (timeService != null)
                    {
                        if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                        {
                            timeService.Close();
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Loads the time entry.
        /// </summary>
        private void LoadAdditionalDetailTimeEntry()
        {
            TimeServiceClient timeService = null;
            TimeAdditionalDetail additionalDetail = null;
            try
            {
                timeService = new TimeServiceClient();
                IRIS.Law.WebServiceInterfaces.Time.Time time = new IRIS.Law.WebServiceInterfaces.Time.Time();
                time.Id = timeDetails.Id;
                time.ProjectId = timeDetails.ProjectId;
                time.FeeEarnerId = timeDetails.FeeEarnerId;
                time.TimeTypeId = timeDetails.TimeTypeId;

                TimeReturnValue returnValue = timeService.GetAddtionalDetailTime(_logonSettings.LogonId, time);

                if (returnValue.Success)
                {
                    if (returnValue.Time != null)
                    {
                        if (returnValue.AdditionalDetail != null)
                        {
                            if (returnValue.AdditionalDetail.CurrentAdditionalDetails != AdditionalDetails.None)
                            {
                                additionalDetail = returnValue.AdditionalDetail;
                            }
                            else
                            {
                                SaveTimeRecording();
                            }
                        }
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (timeService != null)
                {
                    if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                        timeService.Close();
                }
            }

            try
            {
                SetupAdditionalDetails(additionalDetail);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// Validates posting period on page load and gets client banks
        /// </summary>
        /// <param name="bankType"></param>
        /// Previous private PeriodDetailsReturnValue ValidatePostingPeriod(Guid projectId, IRIS.Law.PmsCommonData.DataConstantsBankSearchTypes bankType)
        private PeriodDetailsReturnValue ValidatePostingPeriod(Guid projectId)
        {
            TimeServiceClient timeService = null;
            PeriodDetailsReturnValue returnValue = null;

            try
            {
                PeriodCriteria criteria = new PeriodCriteria();
                criteria.Date = Convert.ToDateTime(_ccDraftBillDate.DateText);
                criteria.IsPostingVATable = false;
                criteria.IsTime = false;
                criteria.ProjectId = projectId;
                // This parameter has been passed as "false" in accounts
                criteria.IsAllowedPostBack2ClosedYear = false;

                timeService = new TimeServiceClient();
                returnValue = timeService.ValidatePeriod(_logonSettings.LogonId, criteria);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (timeService != null)
                {
                    if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                        timeService.Close();
                }
            }

            return returnValue;
        }
        protected void _btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (_txtUnits.Text == "0")
                {
                    _lblMessage.CssClass = "errorMessage";
                    _lblMessage.Text     = "Units cannot be zero";
                    return;
                }

                TimeDetails timeDetails = new TimeDetails();
                timeDetails.ProjectId     = (Guid)Session[SessionName.ProjectId];
                timeDetails.FeeEarnerId   = _logonSettings.UserDefaultFeeMemberId;
                timeDetails.TimeTypeId    = new Guid(GetValueOnIndexFromArray(_ddlTimeType.SelectedValue.Trim(), 0));
                timeDetails.TimeTypeCatId = Convert.ToInt32(GetValueOnIndexFromArray(_ddlTimeType.SelectedValue.Trim(), 1));
                timeDetails.Units         = Convert.ToInt32(_txtUnits.Text.Trim());
                timeDetails.Notes         = _txtNotes.Text.Trim();
                timeDetails.Date          = DateTime.Now.Date;
                // No validation for limits from the web
                timeDetails.CanProceed = true;
                if (ViewState["TimeId"] == null)
                {
                    timeDetails.Id = 0;
                }
                else
                {
                    timeDetails.Id = Convert.ToInt32(ViewState["TimeId"]);
                }

                if (IsAdditionalDetailTimeExists(timeDetails))
                {
                    Session[SessionName.TimeDetails] = timeDetails;
                    Response.Redirect("~/Pages/Time/AdditionalTimeDetails.aspx", true);
                }
                else
                {
                    TimeServiceClient timeService = null;
                    TimeReturnValue   returnValue = null;
                    try
                    {
                        timeService = new TimeServiceClient();
                        IRIS.Law.WebServiceInterfaces.Time.Time time = new IRIS.Law.WebServiceInterfaces.Time.Time();

                        time.ProjectId   = (Guid)Session[SessionName.ProjectId];
                        time.FeeEarnerId = _logonSettings.UserDefaultFeeMemberId;
                        time.TimeTypeId  = timeDetails.TimeTypeId;
                        time.Units       = timeDetails.Units;
                        time.Notes       = timeDetails.Notes;
                        time.Date        = DateTime.Now.Date;
                        //No validation for limits from the web
                        time.DontCheckLimits = true;
                        time.BillingCodeID   = 1; // Default to "Default - None Selected"

                        if (timeDetails.Id == 0)
                        {
                            //No timeId present. Add a new time entry
                            returnValue = timeService.AddTime(_logonSettings.LogonId, time, null, false);
                        }
                        else
                        {
                            //If a timeId is present then we are updating an existing time entry
                            time.Id     = timeDetails.Id;
                            returnValue = timeService.UpdateTime(_logonSettings.LogonId, time, null);
                        }

                        if (returnValue.Success)
                        {
                            Session[SessionName.TimeDetails] = null;
                            //Redirect the user to the timesheet where entry would be listed
                            Response.Redirect("ViewTimesheet.aspx", true);
                        }
                        else
                        {
                            throw new Exception(returnValue.Message);
                        }
                    }
                    catch (System.ServiceModel.EndpointNotFoundException)
                    {
                        _lblMessage.Text     = DataConstants.WSEndPointErrorMessage;
                        _lblMessage.CssClass = "errorMessage";
                    }
                    catch (Exception ex)
                    {
                        _lblMessage.CssClass = "errorMessage";
                        _lblMessage.Text     = ex.Message;
                    }
                    finally
                    {
                        if (timeService != null)
                        {
                            if (timeService.State != System.ServiceModel.CommunicationState.Faulted)
                            {
                                timeService.Close();
                            }
                        }
                    }
                }
            }
        }